PythonでGoogleAppEngineにウェブサイトを書いていますが、GPS座標を含む文字列プロパティを持つLocationデータストアエンティティがあります。ユーザーにGPS座標で検索させたいのですが、緯度または経度の+/-10ポイント以内にあるすべての場所を返したいのです。基本的に私がやりたかったのは次のコードですが、GPSをそのように並べ替えることはできません。1つは文字列であるため、2つは同じプロパティであるためです。
inputlocation = self.request.get("userlocation")
g = geocoders.Google()
try:
place, (lat, lng) = g.geocode(inputlocation)
except ValueError:
geocodespot = g.geocode(inputlocation, exactly_one=False)
place, (lat, lng) = geocodespot[0]
GPSlocation = "("+str(lat)+", "+str(lng)+")"
GPSlocation = float(GPSlocation)
bound = 10
upper = GPSlocation + bound
lower = GPSlocation - bound
left = GPSlocation + bound
right = GPSlocation - bound
if GPSlocation:
locations = db.GqlQuery("select * from Location where GPSlocation>:1 and where GPSlocation>:2 and where GPSlocation <:3 and where GPSlocation <:4 order by created desc limit 20", upper, lower, left, right)
#example GPSlocation in the datastore = "(37.7699298, -93.4469157)"
データストアの設定方法を変更せずに、基本的にこれを行う方法を考えられますか?Latitude用とLongitude用の2つのプロパティを作成せずに、その情報を取得する方法はありますか?