8

I've recently start working on a personal project involving geo locations, maps (Google Maps V3) etc.

The project is developed in Python and is intended to run on Google App Engine. I've learned that in order to find markers/position close to a position one can use to geohash algorithm (which is pretty cool).

What I don't understand is this: lets say I have all my locations in the data store (along with a latitude, longitude and a geohash (with high precision) of each location.)

I know that I should use the prefix of the geohash (to match locations within), but how do I calculate a geohash of a bounding box? Considering the bounding box is made up of two points, North-East and South-West, I do not understand how to go about doing this..

In order for me to querying which locations should be returned for the currently visible bounding box, I need the geohash of the visible/viewable bounding box - Now I know I can geohash the center location on the viewable map, but I do not know how many letters to cut off (to reduce precision) to achieve 'a fit' to the actual bounding box. (Or maybe that isn't the way...?)

What do you do when the bounding box container to geohashes? (like in the middle of the viewable area it splits between 'dqcjr0' and 'dqcjqb')

Also, lets assume I have a 5 letter geohash, how can I convert that back into a viewable bounding box? or in other words, how do I know what is 'included' the hash, and what is in adjacent hashes?

Thanks in advance for your help,

Ken.

Ken
  • 691
  • 5
  • 14

2 Answers2

0

I used geohash with google app engine data types ie db.GeoPt a lot and I used to keep a geohash which I found was inferior to combine the db.GeoPt with the very good but a bit slow library called geomodel Geomodel can do bounding-box and radius mappings and I suggest that you try with the bounding-box since it is not as expensive as the radius. I can perform a bounding-box query like this:

    articles = Article.bounding_box_fetch(Article.all().filter('modified >',
                          timeline).filter('published =',
                          True).filter('modified <=',
                          bookmark).order('-modified'),
                          bounds,
                          max_results=PAGESIZE + 1)

So even if I stored geohash for every article, using geomodel was much better in my case. Maybe you already evaluated geomodel and found that it didn't suit your purpose and that you absolutely must use geohashes I suggest that we agree on a common library for the geohash so that our coordinates hash to the same value. I do keep a version of the geohash library I used somewhere but it is probably outdated and the recent articles about geospatial queries also metion geomodel, so if you didn't look at geomodel yet, I really propose you look at the geomodel library to perform your geospatial queries.

Niklas Rosencrantz
  • 25,640
  • 75
  • 229
  • 424
  • of course I came across GeoModel in my research, but geomodel won't work for me as I'm using django and django models. :( – Ken Dec 03 '11 at 22:47
0

Ken You may want to update your question stating whether or not you're using django / django-nonrel?

I'm just about to try this (currently archived) port of Geomodel to django:

https://bitbucket.org/scotch/django-geomodel/

Kyle suggests that the upcoming Google "full text search" would replace his Geomodel implmentation. Nonetheless, I need it working within the next few days.

(My current conversation re: this topic:

https://groups.google.com/forum/#!topic/django-non-relational/WCxFjkUzw18 )

Jon

jonincanada
  • 417
  • 5
  • 5