How do I find places that are nearby a location?

42 views
Skip to first unread message

vb

unread,
Apr 15, 2008, 7:05:31 AM4/15/08
to Google App Engine
For my app I need to do a distance query on point of interests.
I can see that there is geopt, but I can't find anyway of indexing
that data. So that I can do a distance query on the column.

barryhunter

unread,
Apr 15, 2008, 8:24:21 AM4/15/08
to Google App Engine
I think a good (cheap and chearful) way would be with geohashs

http://geohash.org/

Encode[1] your location as a hash and store as a string.

But the magic is expressed by this statement:
"Geohashes offer properties like arbitrary precision, similar prefixes
for nearby positions, and the possibility of gradually removing
characters from the end of the code to reduce its size (and gradually
lose precision)."

So you can search by prefix[2] to find points in a box, make it quite
short and you will get the area. If you want you could also check the
surrounding boxes - I admit the maths could be tricky there, but
should be doable. (would have to do multiple queries as you dont have
'OR' in the dartastore.)



This basically equates to a poormans QuadTree index, which would be
the correct way to do it.

(If I get the time will actully try this out! - maybe as an addon to
the geodatastore?)


[1] the above site offers an API, that you could call with the fetch
API, or there is a PHP class:
http://blog.dixo.net/2008/02/28/geohash-php-class/
which should be portable to Python fairly easily.

[2] See the 'Tip' here:
http://code.google.com/appengine/docs/datastore/queriesandindexes.html#Introducing_Indexes

Kim Pepper

unread,
May 29, 2008, 7:52:04 AM5/29/08
to Google App Engine
Fantastic! This is exactly what I was looking for. I also found this
Python library http://www.refactor.fi/software/gis/geohash/

-- Kim

On Apr 15, 10:24 pm, barryhunter <BarryBHun...@googlemail.com> wrote:
> I think a good (cheap and chearful) way would be with geohashs
>
> http://geohash.org/
>
> Encode[1] your location as a hash and store as a string.
>
> But the magic is expressed by this statement:
> "Geohashes offer properties like arbitrary precision, similar prefixes
> for nearby positions, and the possibility of gradually removing
> characters from the end of the code to reduce its size (and gradually
> lose precision)."
>
> So you can search by prefix[2] to find points in a box, make it quite
> short and you will get the area. If you want you could also check the
> surrounding boxes - I admit the maths could be tricky there, but
> should be doable. (would have to do multiple queries as you dont have
> 'OR' in the dartastore.)
>
> This basically equates to a poormans QuadTree index, which would be
> the correct way to do it.
>
> (If I get the time will actully try this out! - maybe as an addon to
> the geodatastore?)
>
> [1] the above site offers an API, that you could call with the fetch
> API, or there is a PHP class:http://blog.dixo.net/2008/02/28/geohash-php-class/
> which should be portable to Python fairly easily.
>
> [2] See the 'Tip' here:http://code.google.com/appengine/docs/datastore/queriesandindexes.htm...
>
> On Apr 15, 12:05 pm, vb <vikram.bhan...@gmail.com> wrote:
>
> > For my app I need to do a distancequeryon point of interests.
> > I can see that there isgeopt, but I can't find anyway of indexing
Reply all
Reply to author
Forward
0 new messages