summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorSalvatore Sanfilippo <antirez@gmail.com>2020-04-15 10:23:23 +0200
committerGitHub <noreply@github.com>2020-04-15 10:23:23 +0200
commitdfd3ead90ddaf188a3a922acb100807d4d1b29ff (patch)
tree4b57e2473f3ed66f749730818afc2aa035fb8559
parent7428f5121755f0f49aaf5f46321da64cd122aa1a (diff)
parent3fbfa1885c082b1043970f9c273a9413bce05a83 (diff)
downloadredis-dfd3ead90ddaf188a3a922acb100807d4d1b29ff.tar.gz
Merge pull request #7078 from karelrooted/fix/geo-hash-edge-case
FIX truncate max/min longitude,latitude related geo_point
-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;
}