Geohash encode/decode floating point problems

Details

Description

i'm finding the Geohash support in the spatial package to be rather unreliable.
Here is the outcome of a test that encodes/decodes the same lat/lon and geohash a few times.
the format:
action geohash=(latitude, longitude)

Wouter, or anyone, do you have an idea on where the problem is, or how to fix it?

I'm not sure if there is something to fix. Spatial uses error correction if you use GeoHashUtils#decode. It calculates a precision values and rounds the result accordingly. If you use GeoHashUtils#decode_exactly the result looks much better though if you expect the result to be very very precise.

don't know if this is a huge issue. I could change the implementation to ignore decode and encode precision maybe that makes our impl closer to the one on google code. Again don't know if that is really an issue.
The lat values 52.3738007 and 52.373799999999996 are very very close so I guess you won't even realize it on a map.

Simon Willnauer
added a comment - 24/Aug/09 13:08 Wouter, or anyone, do you have an idea on where the problem is, or how to fix it?
I'm not sure if there is something to fix. Spatial uses error correction if you use GeoHashUtils#decode. It calculates a precision values and rounds the result accordingly. If you use GeoHashUtils#decode_exactly the result looks much better though if you expect the result to be very very precise.
don't know if this is a huge issue. I could change the implementation to ignore decode and encode precision maybe that makes our impl closer to the one on google code. Again don't know if that is really an issue.
The lat values 52.3738007 and 52.373799999999996 are very very close so I guess you won't even realize it on a map.
simon

To me it was major since geohashes are THE way for us to search a location through millions of records our index has, and small numbers do count!

I see it this way, if a jpeg picture would not decode like it encoded would you accept it, also if it would be slightly different?

Right now i don't want to spend my time on finding the cause of the issue since i have working (google) code and I prefer doing cooler stuff like implementing a solution for the 'greenwich' geohash problem.

Wouter Heijke
added a comment - 27/Aug/09 21:14 To me it was major since geohashes are THE way for us to search a location through millions of records our index has, and small numbers do count!
I see it this way, if a jpeg picture would not decode like it encoded would you accept it, also if it would be slightly different?
Right now i don't want to spend my time on finding the cause of the issue since i have working (google) code and I prefer doing cooler stuff like implementing a solution for the 'greenwich' geohash problem.