我正在用python在googleappengine上构建一个应用程序,我有一个具有GPS属性的位置实体。这个属性被存储为一个字符串(尽管如果需要的话我可以更改它),我想让用户输入一个位置并让我的程序返回5个纬度或经度范围内的所有站点。你知道吗
我有下面的代码,它给我的位置,在全球定位系统,用户正在搜索,但我不知道我可以从那里做什么,我怎么可以做一个在我的范围内的所有全球定位系统的位置查询。你知道吗
class Map(BlogHandler):
def get(self):
#do some stuff here
def post(self):
inputlocation = self.request.get("q")
#this returns the GPS location that the user searched for
g = geocoders.Google()
place, (lat, lng) = g.geocode(inputlocation)
#I would like to be able to do something like this
bound = 5
upper = GPSlocation + bound
lower = GPSlocation - bound
left = GPSlocation + bound
right = GPSlocation - bound
locations = db.GqlQuery("select * from Location where GPSlocation.lat<:1 and where GPSlocation.lat>:2 and where GPSlocation.long <:3 and where GPSlocation.long >:4 order by created desc limit 20", upper, lower, left, right)
self.render('map.html', locations=locations, centerlocation=GPSlocation)
按
5 points
搜索非常简单,因为那只是一个正方形区域:如果你的目标是一个圆形的边界,那么你就需要更多的数学知识。你知道吗
请注意,您自己的查询中的where条件无效,将导致语法错误。语法在哪里
不是
当前代码的一个问题是边界情况。首先是本初子午线,经度从0到360。然后你有两极,那里的纬度不高于90或低于-90。这一点可能不那么重要(因为它们是没有人居住的地方),但是你需要根据具体情况来决定。经度和本初子午线将给你适合,如果你需要附近的位置。你知道吗
相关问题 更多 >
编程相关推荐