From a036c64c01b38aceebfcfd467da04ed3f95fd363 Mon Sep 17 00:00:00 2001
From: Amin Mesbah <dev@aminmesbah.com>
Date: Sun, 2 Sep 2018 00:06:20 -0700
Subject: [PATCH] Use geohash limit defines in constraint check

Slight robustness improvement, especially if the limit values are
changed, as was suggested in antires/redis#4291 [1].

[1] https://github.com/antirez/redis/pull/4291
---
 src/geohash.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/src/geohash.c b/src/geohash.c
index b40282e7..db5ae025 100644
--- a/src/geohash.c
+++ b/src/geohash.c
@@ -127,8 +127,8 @@ int geohashEncode(const GeoHashRange *long_range, const GeoHashRange *lat_range,
 
     /* Return an error when trying to index outside the supported
      * constraints. */
-    if (longitude > 180 || longitude < -180 ||
-        latitude > 85.05112878 || latitude < -85.05112878) return 0;
+    if (longitude > GEO_LONG_MAX || longitude < GEO_LONG_MIN ||
+        latitude > GEO_LAT_MAX || latitude < GEO_LAT_MIN) return 0;
 
     hash->bits = 0;
     hash->step = step;