]> granicus.if.org Git - postgis/commitdiff
#1780 ST_GeoHash should support geography type without cast
authorPaul Ramsey <pramsey@cleverelephant.ca>
Thu, 13 Sep 2012 02:08:45 +0000 (02:08 +0000)
committerPaul Ramsey <pramsey@cleverelephant.ca>
Thu, 13 Sep 2012 02:08:45 +0000 (02:08 +0000)
git-svn-id: http://svn.osgeo.org/postgis/trunk@10278 b70326c6-7e19-0410-871a-916f4a2858ee

NEWS
liblwgeom/lwalgorithm.c
postgis/geography.sql.in.c
postgis/lwgeom_functions_basic.c

diff --git a/NEWS b/NEWS
index 35bb146dc1e1a815174d3b173b39ef2c84b6d395..86b3f04195ce9f6e24e86905a66395db29895c91 100644 (file)
--- a/NEWS
+++ b/NEWS
@@ -35,6 +35,7 @@ PostGIS 2.1.0
   - #1856, tiger geocoder: reverse geocoder rating setting for prefer numbered highway name
   - #1938, Refactor basic ST_AddBand to add multiple new bands in one call
   - #1978, wrong answer when calculating length of a closed circular arc (circle)
+  - #1780, support ST_GeoHash for geography
 
 * Fixes *
 
index a63e972e510a37b5b75c6a6e0b74befd8f31f9b8..01f043caefecd2dafa5ba2110c9d316c4201daf1 100644 (file)
@@ -496,7 +496,7 @@ char *lwgeom_geohash(const LWGEOM *lwgeom, int precision)
        gbox_init(&gbox);
        gbox_init(&gbox_bounds);
 
-       result = lwgeom_calculate_gbox(lwgeom, &gbox);  
+       result = lwgeom_calculate_gbox_cartesian(lwgeom, &gbox);        
        if ( result == LW_FAILURE ) return NULL;
 
        /* Return error if we are being fed something outside our working bounds */
index 2efdcf53b50669a004a13c6f2261b772bc514dfe..811ca3ed93bae912d1a687a7e7171651c9523499 100644 (file)
@@ -774,6 +774,12 @@ CREATE OR REPLACE FUNCTION ST_Summary(geography)
        AS 'MODULE_PATHNAME', 'LWGEOM_summary'
        LANGUAGE 'c' IMMUTABLE STRICT;
 
+-- Availability: 2.1.0
+CREATE OR REPLACE FUNCTION ST_GeoHash(geog geography, maxchars int4 DEFAULT 0)
+       RETURNS TEXT
+       AS 'MODULE_PATHNAME', 'ST_GeoHash'
+       LANGUAGE 'c' IMMUTABLE STRICT;
+
        
 -----------------------------------------------------------------------------
 
index 2e31c57da6e53b0fa8b18b938686bd06de51862f..c6106fd9f4ec51e2722f41542e027779e99ba794 100644 (file)
@@ -2504,9 +2504,8 @@ Datum ST_GeoHash(PG_FUNCTION_ARGS)
 
        GSERIALIZED *geom = NULL;
        int precision = 0;
-       int len = 0;
        char *geohash = NULL;
-       char *result = NULL;
+       text *result = NULL;
 
        if ( PG_ARGISNULL(0) )
        {
@@ -2525,13 +2524,10 @@ Datum ST_GeoHash(PG_FUNCTION_ARGS)
        if ( ! geohash )
                PG_RETURN_NULL();
 
-       len = strlen(geohash) + VARHDRSZ;
-       result = palloc(len);
-       SET_VARSIZE(result, len);
-       memcpy(VARDATA(result), geohash, len-VARHDRSZ);
+       result = cstring2text(geohash);
        pfree(geohash);
-       PG_RETURN_POINTER(result);
-
+       
+       PG_RETURN_TEXT_P(result);
 }
 
 PG_FUNCTION_INFO_V1(ST_CollectionExtract);