def get(self): paramCheck=True for each in ('lat','lon'): if not self.request.params.has_key(each): logging.debug("%s not found" %each) paramCheck=False self.error(400) self.response.out.write("Missing Parameters") if paramCheck: try: lat=float(self.request.params.get('lat')) lon=float(self.request.params.get('lon')) except StandardError: logging.debug("Lat/Lon wouldn't convert to float") self.error(400) self.response.out.write("Invalid Parameters") latlon=db.GeoPt(lat,lon) q = db.GqlQuery("SELECT * FROM GeoHit WHERE latlon = :1", latlon) geohits = q.fetch(25) if geohits: for gh in geohits: gh.hitCount+=1 gh.put() else: mp=MercatorProjection() tiles=mp.getZoomTileSet(lat,lon) for zoom in tiles.keys(): geohit=model.GeoHit(latlon=latlon, hitCount=1, zoom=zoom, tileX=tiles[zoom][0], tileY=tiles[zoom][1]) geohit.put() self.response.out.write("ok")
def addPoint(self, lat, lon, x, y, zoom): mp=MercatorProjection() self.locs.append(mp.project(lat,lon,x,y,zoom))