Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How do I query for entities that are "nearby" with the GeoPt property in Google App Engine?

How should I create a GQL query that returns the nearest entities (from my current location) based on their GeoPt property? Should I just created a 'distance' function that calculates for a set of entities with a reasonably close distance?

Thanks ahead of time!

like image 264
ehfeng Avatar asked Jun 23 '09 15:06

ehfeng


2 Answers

App Engine doesn't treat GeoPt properties specially - it has no built in spatial indexing. There are a number of third-party libraries that add support for spatial indexing, however. The best one (in my opinion) being geomodel.

like image 150
Nick Johnson Avatar answered Oct 04 '22 02:10

Nick Johnson


You could store the locations in App Engine in a Quadtree structure.

Here's one description of how it would be done: Geographic Queries on Google App Engine

like image 35
pufferfish Avatar answered Oct 04 '22 02:10

pufferfish