Пример #1
0
    def all_within (self, longitude, latitude, km_radius=EARTH_EQUAT_RADIUS*2, set_to_render=False):
        """Create a list of carrier hotels within a given radius in km."""
        try:
            point = ll_to_xyz(latitude, longitude)
        except ValueError:
            return []

        chotel = None
        chotel_tuple_list = [ ]

        # --- Create list of chotels within radius ---
        for ch in self.chotels:
            dist = ixmaps.distance_km (point, ch['xyz'] )
            if dist < km_radius:
                chotel_tuple_list.append ( (dist, ch) )

        # --- Sort chotels list ---
        chotel_tuple_list.sort ( )

        # --- Convert to non-tupple by removing distance meta-info ---
        chotel_list = [ ]
        for ch in chotel_tuple_list:
            chotel_list.append (ch[1])

        # --- Set whether to render ---
        for ch in chotel_list:
            if set_to_render:
                ch['networks'] = ''
                # ch['to_render'] = True

        # print chotel_list

        return chotel_list
Пример #2
0
    def all_within (self, longitude, latitude, km_radius=EARTH_EQUAT_RADIUS*2, set_to_render=False):
        """Create a list of carrier hotels within a given radius in km."""
        try:
            point = ll_to_xyz(latitude, longitude)
        except ValueError:
            return []

        chotel = None
        chotel_tuple_list = [ ]

        # --- Create list of chotels within radius ---
        for ch in self.chotels:
            dist = ixmaps.distance_km (point, ch['xyz'] )
            if dist < km_radius:
                chotel_tuple_list.append ( (dist, ch) )

        # --- Sort chotels list ---
        chotel_tuple_list.sort ( )

        # --- Convert to non-tupple by removing distance meta-info ---
        chotel_list = [ ]
        for ch in chotel_tuple_list:
            chotel_list.append (ch[1])

        # --- Set whether to render ---
        for ch in chotel_list:
            if set_to_render:
                ch['networks'] = ''
                # ch['to_render'] = True

        # print chotel_list

        return chotel_list
Пример #3
0
 def closest(d, point):
     min_distance = EARTH_MEAN_RADIUS
     index = None
     for id in d:
         curr_distance = distance_km(d[id].xyz, point)
         if curr_distance < min_distance:
             min_distance = curr_distance
             index = id
     return (index, min_distance)
Пример #4
0
 def nearest(self, longitude, latitude, km_radius=ixmaps.EARTH_EQUAT_RADIUS*2):
     """Find the nearest carrier hotel that's within a given radius in km."""
     point = ixmaps.ll_to_xyz(latitude, longitude)
     max_dist = km_radius
     chotel = None
     for ch in self.chotels:
         dist = ixmaps.distance_km(point, ch['xyz'])
         if dist < max_dist:
             #print ch['id'], ch['long'], ch['lat'], dist, max_dist
             max_dist = dist
             chotel = ch
     return chotel
Пример #5
0
 def distance(self, point):
     return distance_km(self.xyz, point)