kungfoo / geohash-java

Implementation of GeoHashes in java. We try to be/stay compliant to the spec, as far as possible.
Other
982 stars 310 forks source link

GeoHashCircleQuery fails near the poles #10

Closed ChrisWooldridge closed 6 years ago

ChrisWooldridge commented 13 years ago

The following code:

WGS84Point target = new WGS84Point(new LatLonPair(89.99904405694745,-60.02364542228088));
GeoHashCircleQuery query = new GeoHashCircleQuery(target, 250);
List<GeoHash> boundingHashes = query.getSearchHashes();
for(GeoHash hash : boundingHashes ){
  System.out.println(hash);
}

produces the following output:

0 -> (90.0,-180.0) -> (-90.0,180.0) ->

Reducing the radius in the query to 100m gives:

100000000000000000000000000000000000000000000000000000000000000 -> (90.0,-180.0) -> (0.0,0.0), bits: 2 1100000000000000000000000000000000000000000000000000000000000000 -> (90.0,0.0) -> (0.0,180.0), bits: 2

Neither of these results looks correct. I would expect to see some results grouped around the hash 'czurvpx2uxj9'.

Also, for the case of the poles themselves, there can be upto 32 nearby hashes. Should there be a special case to handle the poles?

kungfoo commented 13 years ago

I will look into this, but it will take me at least a week to find the time... In the meantime, you can also fork the repository and work on a possible fix (if you want to, that is :) ). If you do so, please provide test coverage for any new code that goes in.

You can run all the test cases from your IDE or on the command line, using either ant or maven:

$ ant test

or

$ mvn test

Cheers.

kungfoo commented 6 years ago

If this is still an issue that bothers you, please reopen it.