Hi, I was trying to use geohash as an index for bbox queries in an app engine application, following this approach: http://labs.metacarta.com/blog/27.entry
Since I am storing only points, I choose to use geohash instead of geoindex, but I got strange results, i.e. lots of points out of the bbox were being returned. I worked the following example in a python console and figured out that there are actually a lot of undesired points in a bbox search using geohash. In this example I compare 9 different points a,b,c,d,e,f,g,h,i with a bbox formed by the points sw and ne. Every point except d falls out of the bbox, each one located in a different position compared to the bbox (north, north-east, east, etc.). The comparison of the bbox points hashes with the point hashes should return True only if the point falls inside the bbox: import geohash ghsw=str(geohash.Geohash((2,2))) ghne=str(geohash.Geohash((8,6))) gha=str(geohash.Geohash((1,1))) ghb=str(geohash.Geohash((4,4))) ghc=str(geohash.Geohash((1,4))) ghd=str(geohash.Geohash((4,4))) ghe=str(geohash.Geohash((1,8))) ghf=str(geohash.Geohash((4,8))) ghg=str(geohash.Geohash((9,1))) ghh=str(geohash.Geohash((9,4))) ghi=str(geohash.Geohash((9,8))) for i in [gha,ghb,ghc,ghd,ghe,ghf,ghg,ghh,ghi]: print "%s" % ((i>ghsw)&(i<ghne)) returns... False True True True True True True True False while only ghd should return True Then I tried the approach with geoindex, using a both an infinite precise bbox or a small bbox around each point and I got the very same results: approach 1: >>> gisw=str(geohash.Geoindex((2,2))) >>> gine=str(geohash.Geoindex((8,6))) >>> gia=str( geohash.Geoindex((1,1)) + geohash.Geoindex((1,1)) ) >>> gib=str( geohash.Geoindex((4,4)) + geohash.Geoindex((4,4)) ) >>> gic=str( geohash.Geoindex((1,4)) + geohash.Geoindex((1,4)) ) >>> gid=str( geohash.Geoindex((4,4)) + geohash.Geoindex((4,4)) ) >>> gie=str( geohash.Geoindex((1,8)) + geohash.Geoindex((1,8)) ) >>> gif=str( geohash.Geoindex((4,8)) + geohash.Geoindex((4,8)) ) >>> gig=str( geohash.Geoindex((9,1)) + geohash.Geoindex((9,1)) ) >>> gih=str( geohash.Geoindex((9,4)) + geohash.Geoindex((9,4)) ) >>> gii=str( geohash.Geoindex((9,8)) + geohash.Geoindex((9,8)) ) >>> >>> for i in [gia,gib,gic,gid,gie,gif,gig,gih,gii]: ... print "%s" % ((i>gisw)&(i<gine)) returns... False True True True True True True True False approach 2: gisw=str(geohash.Geoindex((2,2))) gine=str(geohash.Geoindex((8,6))) gia=str( geohash.Geoindex((0.9,0.9)) + geohash.Geoindex((1.1,1.1)) ) gib=str( geohash.Geoindex((3.9,3.9)) + geohash.Geoindex((4.1,4.1)) ) gic=str( geohash.Geoindex((0.9,3.9)) + geohash.Geoindex((1.1,4.1)) ) gid=str( geohash.Geoindex((3.9,3.9)) + geohash.Geoindex((4.1,4.1)) ) gie=str( geohash.Geoindex((0.9,7.9)) + geohash.Geoindex((1.1,8.1)) ) gif=str( geohash.Geoindex((3.9,7.9)) + geohash.Geoindex((4.1,8.1)) ) gig=str( geohash.Geoindex((8.9,0.9)) + geohash.Geoindex((9.1,1.1)) ) gih=str( geohash.Geoindex((8.9,3.9)) + geohash.Geoindex((9.1,4.1)) ) gii=str( geohash.Geoindex((8.9,7.9)) + geohash.Geoindex((9.1,8.1)) ) for i in [gia,gib,gic,gid,gie,gif,gig,gih,gii]: print "%s" % ((i>gisw)&(i<gine)) returns... False True True True True True True True False Am I missing something? Is there a way to use geohash or geoindex to get profitable bbox searches? Regards jgui --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Google App Engine" group. To post to this group, send email to google-appengine@googlegroups.com To unsubscribe from this group, send email to google-appengine+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/google-appengine?hl=en -~----------~----~----~----~------~----~------~--~---