From a7ee3c3e77d04ac98c68b43ef18231eefd1f2615 Mon Sep 17 00:00:00 2001 From: liumiuyong Date: Thu, 9 Apr 2020 17:48:29 +0800 Subject: [PATCH] FIX: truncate max/min longitude,latitude related geo_point (ex: {180, 85.05112878} ) --- src/geohash.c | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/src/geohash.c b/src/geohash.c index db5ae025a..de9620b7a 100644 --- a/src/geohash.c +++ b/src/geohash.c @@ -206,7 +206,11 @@ int geohashDecodeWGS84(const GeoHashBits hash, GeoHashArea *area) { int geohashDecodeAreaToLongLat(const GeoHashArea *area, double *xy) { if (!xy) return 0; xy[0] = (area->longitude.min + area->longitude.max) / 2; + if (xy[0] > GEO_LONG_MAX) xy[0] = GEO_LONG_MAX; + if (xy[0] < GEO_LONG_MIN) xy[0] = GEO_LONG_MIN; xy[1] = (area->latitude.min + area->latitude.max) / 2; + if (xy[1] > GEO_LAT_MAX) xy[1] = GEO_LAT_MAX; + if (xy[1] < GEO_LAT_MIN) xy[1] = GEO_LAT_MIN; return 1; }