Esempio n. 1
0
    def create_box(self, name, lat, long):
        latlongstring = '%f,%f' % (lat, long)

        new_box = model.Box(name = name)
        new_box.put()
        quad = tile.location_to_quadtile(lat, long, 18)
        
        dropped_box = model.DroppedBox(quadtile = quad, boxid = str(new_box.key()))
        dropped_box.drop_location = latlongstring
        dropped_box.drop_message = name 
        dropped_box.put()
        
        hi = model.History(boxid = str(new_box.key()))
        hi.drop_location = latlongstring
        hi.drop_message = name
        hi.put()
        
        self.response.out.write("box '%s' created in %f, %f quadtile '%s' (boxid: %s) drop location: %s\n" % (name, lat, long, quad, str(new_box.key()), hi.drop_location))
Esempio n. 2
0
File: map.py Progetto: eladb/boxes
    def get_quad_prefix_from_params(self):
        quad_prefix = self.request.get('quad_prefix')
        
        if quad_prefix == "":
            if self.request.get('lat') == "" or self.request.get('long') == "":
                self.bad_request("either'quad_prefix' or 'lat' and 'long' parameters should be specified (you can use 'zoom' to specify a different zoom level)")
                return None

            lat = float(self.request.get('lat'))
            long = float(self.request.get('long'))
            zoom = self.request.get('zoom')
            
            if zoom == "": zoom = 6
            else: zoom = int(zoom)
            
            quad_prefix = tile.location_to_quadtile(lat, long, zoom)

        return quad_prefix
        
Esempio n. 3
0
File: drop.py Progetto: eladb/boxes
 def get(self):
     if not self.required_field('boxid'): return
     if not self.required_field('lat'): return
     if not self.required_field('long'): return
     userid = self.userid_from_token()
     if not userid: return;
     
     boxid = self.request.get('boxid')
     lat = float(self.request.get('lat'))
     long = float(self.request.get('long'))
     message = self.request.get('message')
     
     # verify last drop was picked up
     last_drop = model.History.get_last_drop(boxid)
     if not last_drop.next_picker or last_drop.next_picker == "":
         self.conflict('box already dropped')
         return
     
     new_entry = model.History(boxid = boxid)
     new_entry.drop_location = '%f,%f' % (lat, long)
     new_entry.drop_message = message
     new_entry.put()
     
     quadtile = tile.location_to_quadtile(lat, long, 18) # 18 is like in the pickup
     dropped = model.DroppedBox(quadtile = quadtile, boxid = boxid)         
     #dropped.worth = db.IntegerProperty()
     #dropped.total_distance = db.FloatProperty()
     #dropped.total_hands = db.IntegerProperty()
     dropped.drop_location = new_entry.drop_location
     dropped.drop_message = message
     dropped.put()
     
     # remove from my boxes
     myBoxes = model.MyBox.all().filter('userid =', userid).filter('boxid =', boxid)
     for b in myBoxes: b.delete()
     
     self.emit_text("box dropped")
Esempio n. 4
0
File: model.py Progetto: eladb/boxes
 def query_by_location(cls, lat, long, zoom):
     quad_prefix = tile.location_to_quadtile(lat, long, zoom)
     logging.info('quad_prefix = %s' % quad_prefix)
     return cls.query_by_quadkey(quad_prefix)