]> granicus.if.org Git - postgis/commitdiff
#2201, ST_GeoHash wrong on boundaries
authorPaul Ramsey <pramsey@cleverelephant.ca>
Tue, 26 Mar 2013 15:24:19 +0000 (15:24 +0000)
committerPaul Ramsey <pramsey@cleverelephant.ca>
Tue, 26 Mar 2013 15:24:19 +0000 (15:24 +0000)
git-svn-id: http://svn.osgeo.org/postgis/trunk@11212 b70326c6-7e19-0410-871a-916f4a2858ee

NEWS
liblwgeom/cunit/cu_algorithm.c
liblwgeom/lwalgorithm.c

diff --git a/NEWS b/NEWS
index 5d29123cbd19da5bda3d3fe0b20778ddea526ce1..963c11cc4ffb1e8c11566fa2562cc8621453cdad 100644 (file)
--- 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
index c24b09e70d0761607c8373a234c72ec9f03e786a..4a359188b1d928caed994b29cbf451e0938b380b 100644 (file)
@@ -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);
index 928ecf98e60eda17cabd0c457745a235d592cd11..17aeadc0b8b07c36a6fd772920e15c17f8c29ca6 100644 (file)
@@ -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;