jillesvangurp / geogeometry

GeoGeometry is a set of algorithms and functions for manipulating geo hashes and geometric shapes with geo coordinates.

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

decode_bbox return array comment

johndww opened this issue · comments

Hi,

Excellent job on this util - very helpful.

I think the order of return values in the decode_bbox array are incorrect. The code says:

 * @return double array representing the bounding box for the geohash of [north latitude, south latitude, east
 *         longitude, west longitude]

but really, it's [south,north,west,east] as seen in
return new double[] { latInterval[0], latInterval[1], lonInterval[0], lonInterval[1] };
where double[] latInterval = { -90.0, 90.0 };
, so latInterval[0] is really south (-90), I believe.

This manifest itself (though the code still works), in geoHashesForPolygon(). The comments say
// lets start at the top left:

    String rowHash = encode(bbox[0], bbox[2], hashLength);

bbox[0], bbox[2] REALLY is starting in the south west corner, rather than the NE corner (even though the comment says top left, which would be NW)

it appears that the east() method works correct, and the south() method really moves the bounding box north - so the result is correct.

If I'm reading it wrong -sorry! but in the debugger thats what it appeared to be, and was quite confusing :)

Thanks for reporting this. It seems you are right. Amazing I did not catch this. Probably I changed this at some point without editing the documentation. I'll need to sit down and clean this up. Alternatively, I'd be happy to accept a pull request.

Otherwise the code indeed should work as expected. I've done quite a bit of visual inspection of shapes covered with geohashes using the included javascript.

finally fixed this, thanks again for reporting