Dustin Oprea
Dustin Oprea

Reputation: 10236

AppEngine: Geospatial queries under Go

There appears to be geospatial-query support under Java (https://cloud.google.com/appengine/docs/java/datastore/geosearch) but there appears to be absolutely no documentation for doing the same under Go. Grepping google.golang.org/appengine for "geo" renders nothing but construction and validation of GeoPoint values.

Since Java supports this the API support must obviously be there. Does anyone have any experience with this or advice? Thanks.

Edit:

It looks like what limited support there is is only offered for Java:

http://startup-with-gae.blogspot.com/2016/01/geospatial-queries-with-google-cloud.html

Upvotes: 0

Views: 233

Answers (1)

Dustin Oprea
Dustin Oprea

Reputation: 10236

It's, officially, completely unsupported in Datastore at this time. Use geohashes: https://github.com/gansidui/geohash/blob/master/geohash.go . It reduces this fro ma geospatial-storage/RTREE support problem to a string prefix-search.

It allows you derive a hash that describes a particular location, and then you can take this string and successively remove characters from the right side (and do string prefix-searches against your list of places and their geohashes with what remains) to find places near your principal location and expanding outward.

There is a predictable amount of geographic precision between each adjacent character of a geohash string, so you can either use this or the common prefix bytes between the principal point and the corner latitude/longitude of the map window to identify all places that should appear within it.

Upvotes: 1

Related Questions