Ejemplo n.º 1
0
 def add_restaurant(self, name, location):
     restaurant = Restaurant.create(name, location)
     hashcode = "%s.%s" % (GeoHash.encode(location), restaurant.id)
     bisect.insort(self.geo_value, hashcode)
     self.restaurants[hashcode] = restaurant
     self.ids[restaurant.id] = hashcode
     return restaurant.id
Ejemplo n.º 2
0
 def add_restaurant(self, name, location):
     # Write your code here
     rest = Restaurant.create(name, location)
     code = "%s.%s" % (GeoHash.encode(location), rest.id)
     self.codes[rest.id] = code
     self.rests[code] = rest
     bisect.insort(self.geos, code)
     return rest.id
Ejemplo n.º 3
0
    def add_restaurant(self, name, location):
        r = Restaurant.create(name, location)
        # add r.id incase two locations has the same geohash
        hashcode = "{}.{}".format(GeoHash.encode(location), r.id)

        self.restaurants[hashcode] = r
        self.id2hashcode[r.id] = hashcode
        bisect.insort(self.geo_value, hashcode)
        return r.id
Ejemplo n.º 4
0
    def add_restaurant(self, name, location):
        restaurant = Restaurant.create(name, location)
        hashcode = self.get_restr_hashcode(restaurant)

        self.restaurants[hashcode] = restaurant
        self.restr_to_geohash[restaurant.id] = hashcode
        bisect.insort(self.geohashs, hashcode)

        return restaurant.id
Ejemplo n.º 5
0
    def add_restaurant(self, name, location):
        restaurant = Restaurant.create(name, location)
        hashcode = self.get_restr_hashcode(restaurant)

        self.restaurants[hashcode] = restaurant
        self.restr_to_geohash[restaurant.id] = hashcode
        self.trie.put(hashcode)

        return restaurant.id
Ejemplo n.º 6
0
    def add_restaurant(self, name, location):
        restaurant = Restaurant.create(name, location)
        r_id = restaurant.id

        self.id2restaurant[r_id] = restaurant

        geocode = GeoHash.encode(location)

        for i in range(9):
            self.loc_table[i][geocode[:i]].add(r_id)

        return r_id
Ejemplo n.º 7
0
 def add_restaurant(self, name, location):
     r = Restaurant.create(name, location)
     self.restaurants[r.id] = r
     return r.id
Ejemplo n.º 8
0
 def add_restaurant(self, name, location):
     self.restaurants[self.count] = Restaurant.create(name, location)
     self.count += 1
     return self.count - 1