From 9ed745892ee022fdfd7ed42ec751beeb3b6f5617 Mon Sep 17 00:00:00 2001 From: Paul Ramsey Date: Tue, 26 Mar 2013 15:24:19 +0000 Subject: [PATCH] #2201, ST_GeoHash wrong on boundaries git-svn-id: http://svn.osgeo.org/postgis/trunk@11212 b70326c6-7e19-0410-871a-916f4a2858ee --- NEWS | 1 + liblwgeom/cunit/cu_algorithm.c | 4 ++-- liblwgeom/lwalgorithm.c | 4 ++-- 3 files changed, 5 insertions(+), 4 deletions(-) diff --git a/NEWS b/NEWS index 5d29123cb..963c11cc4 100644 --- a/NEWS +++ b/NEWS @@ -153,6 +153,7 @@ PostGIS 2.1.0 when copying data from a GDAL dataset - #2198, Fix incorrect dimensions used when generating bands of out-db rasters in ST_Tile() + - #2201, ST_GeoHash wrong on boundaries - #2203, Changed how rasters with unknown SRID and default geotransform are handled when passing to GDAL Warp API - #2215, Fixed raster exclusion constraint for conflicting name of diff --git a/liblwgeom/cunit/cu_algorithm.c b/liblwgeom/cunit/cu_algorithm.c index c24b09e70..4a359188b 100644 --- a/liblwgeom/cunit/cu_algorithm.c +++ b/liblwgeom/cunit/cu_algorithm.c @@ -716,12 +716,12 @@ static void test_geohash_point(void) geohash = geohash_point(0, 0, 16); //printf("\ngeohash %s\n",geohash); - CU_ASSERT_STRING_EQUAL(geohash, "7zzzzzzzzzzzzzzz"); + CU_ASSERT_STRING_EQUAL(geohash, "s000000000000000"); lwfree(geohash); geohash = geohash_point(90, 0, 16); //printf("\ngeohash %s\n",geohash); - CU_ASSERT_STRING_EQUAL(geohash, "mzzzzzzzzzzzzzzz"); + CU_ASSERT_STRING_EQUAL(geohash, "w000000000000000"); lwfree(geohash); geohash = geohash_point(20.012345, -20.012345, 15); diff --git a/liblwgeom/lwalgorithm.c b/liblwgeom/lwalgorithm.c index 928ecf98e..17aeadc0b 100644 --- a/liblwgeom/lwalgorithm.c +++ b/liblwgeom/lwalgorithm.c @@ -592,7 +592,7 @@ char *geohash_point(double longitude, double latitude, int precision) if (is_even) { mid = (lon[0] + lon[1]) / 2; - if (longitude > mid) + if (longitude >= mid) { ch |= bits[bit]; lon[0] = mid; @@ -605,7 +605,7 @@ char *geohash_point(double longitude, double latitude, int precision) else { mid = (lat[0] + lat[1]) / 2; - if (latitude > mid) + if (latitude >= mid) { ch |= bits[bit]; lat[0] = mid; -- 2.40.0