summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorliumiuyong <lmy@meitu.com>2020-04-09 17:48:29 +0800
committerliumiuyong <lmy@meitu.com>2020-04-09 17:48:29 +0800
commit3fbfa1885c082b1043970f9c273a9413bce05a83 (patch)
treea4dae22b3a824688987cca0ee54e6c439e89ec5d
parent96688aa6462f330dfd4780d222ce4806d766ff33 (diff)
downloadredis-3fbfa1885c082b1043970f9c273a9413bce05a83.tar.gz
FIX: truncate max/min longitude,latitude related geo_point (ex: {180, 85.05112878} )
-rw-r--r--src/geohash.c4
1 files changed, 4 insertions, 0 deletions
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;
}