kungfoo / geohash-java

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

Cannot convert a geohash to base32 if the precision is not a multiple of 5 #43

Closed joey-happy closed 4 years ago

joey-happy commented 4 years ago
    Double lat = new Double("39.941800");
    Double lon = new Double("116.352380");
    double radius = 500;
    WGS84Point center = new WGS84Point(lat, lon);
    GeoHashCircleQuery query = new GeoHashCircleQuery(center, radius);
    List<GeoHash> searchHashes = query.getSearchHashes();

    for (GeoHash searchHash : searchHashes) {
        System.out.println(searchHash.toBase32());
    }

How can I resolve it??

kungfoo commented 4 years ago

There is no way to represent non-multiples of five as base32, so it doe not exactly work like this. If you can, instead of a radius query you can use a precision query and just find the closest multiple of 5 that gets you to 500m in radius.

Hope this helps.

On Tue, May 12, 2020 at 5:24 AM joey notifications@github.com wrote:

Double lat = new Double("39.941800");
Double lon = new Double("116.352380");
double radius = 500;
WGS84Point center = new WGS84Point(lat, lon);
GeoHashCircleQuery query = new GeoHashCircleQuery(center, radius);
List<GeoHash> searchHashes = query.getSearchHashes();

for (GeoHash searchHash : searchHashes) {
    System.out.println(searchHash.toBase32());
}

How can I resolve it??

— You are receiving this because you are subscribed to this thread. Reply to this email directly, view it on GitHub https://github.com/kungfoo/geohash-java/issues/43, or unsubscribe https://github.com/notifications/unsubscribe-auth/AAAKAKA2LZGBCXTLEFSAJQDRRC6NXANCNFSM4M6OLZTA .

joey-happy commented 4 years ago

Thanks for your answer. Could you help me to give one demo for my requriement?

Mvpanswer7 commented 2 years ago

没看懂啥意思,遇到同样的问题了,怎么解决?