7

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!

ehfeng
  • 3,807
  • 4
  • 33
  • 42

4 Answers4

9

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.

Nick Johnson
  • 100,655
  • 16
  • 128
  • 198
  • Is there any plan of supporting spatial indexing in the future? – Lipis Oct 11 '11 at 20:01
  • @Lipis We haven't announced anything on the roadmap. – Nick Johnson Oct 11 '11 at 23:05
  • Nothing public at least.. I was hoping if you can share something that the rest of the world doesn't know.. :) Hopefully we'll see it one day before the end of the world that is coming in 2012.. :P Keep up the good work.. – Lipis Oct 12 '11 at 12:44
4

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

pufferfish
  • 16,651
  • 15
  • 56
  • 65
2

I guess I'm going to some kind of digger achievement, but here it is:

I was looking for a solution for this issue and came across this Google's oficial docs: https://cloud.google.com/appengine/docs/java/search/query_strings#Java_Queries_on_geopoint_fields

I really think that Google should have made some more noise about this. I find it weird that they have a lesson on Python for doing the same thing but says nothing on how to do it for Java.

VyMajoris
  • 66
  • 12
0

geohash set very close points in different hashes so another or next layer should be preferred. you can make a radius, quadratic inside/outside shape test or even any mathematical shape and test whether the point is within our outside the shape.

Niklas Rosencrantz
  • 25,640
  • 75
  • 229
  • 424