]> granicus.if.org Git - postgis/commitdiff
setSRID() and force_2d() changed to use PG_LWGEOM_construct() entry point,
authorSandro Santilli <strk@keybit.net>
Wed, 12 Jan 2005 07:37:10 +0000 (07:37 +0000)
committerSandro Santilli <strk@keybit.net>
Wed, 12 Jan 2005 07:37:10 +0000 (07:37 +0000)
for AUTOCACHE_BBOX support.

git-svn-id: http://svn.osgeo.org/postgis/trunk@1282 b70326c6-7e19-0410-871a-916f4a2858ee

lwgeom/BBOXCACHE_BEHAVIOURS
lwgeom/lwgeom_functions_basic.c
lwgeom/lwgeom_ogc.c

index 6b1e1f0ec71ce0ecce36599e6c17277052db2b0a..2561a654f6948b58b33ffda7d15984db8f56b206 100644 (file)
@@ -81,8 +81,11 @@ section also use it.
 [ WHEN_SIMPLE (use input bbox if present) ]
        noop(geometry) *LWG*
        ExteriorRing(geometry) *LWG*
-       SetSRID(geometry,int4) **SRL**
-       force_2d(geometry) **SRL**
+       SetSRID(geometry,int4) *SRL*
+
+       # doesn't change bbox cache status if input is already 2d
+       force_2d(geometry) *SRL*
+
        force_3dz(geometry) **SRL**
        force_3d(geometry) **SRL**
        force_3dm(geometry) **SRL**
index 3e18b716068cca14578b3a3be64fdd1e8ef84abe..4e883fb8dac72fa154127eef9bcf5e773a72675b 100644 (file)
@@ -1156,6 +1156,7 @@ PG_FUNCTION_INFO_V1(LWGEOM_force_2d);
 Datum LWGEOM_force_2d(PG_FUNCTION_ARGS)
 {
        PG_LWGEOM *geom = (PG_LWGEOM *)PG_DETOAST_DATUM(PG_GETARG_DATUM(0));
+       char *srl;
        PG_LWGEOM *result;
        size_t size = 0;
 
@@ -1163,16 +1164,13 @@ Datum LWGEOM_force_2d(PG_FUNCTION_ARGS)
        if ( lwgeom_ndims(geom->type) == 2 ) PG_RETURN_POINTER(geom);
 
        // allocate a larger for safety and simplicity
-       result = (PG_LWGEOM *) lwalloc(geom->size);
+       srl = (char *) lwalloc(geom->size);
 
        lwgeom_force2d_recursive(SERIALIZED_FORM(geom),
-               SERIALIZED_FORM(result), &size);
+               srl, &size);
 
-       // we can safely avoid this... memory will be freed at
-       // end of query processing anyway.
-       //result = lwrealloc(result, size+4);
-
-       result->size = size+4;
+       result = PG_LWGEOM_construct(srl, pglwgeom_getSRID(geom),
+               lwgeom_hasBBOX(geom->type));
 
        PG_RETURN_POINTER(result);
 }
index d1d4579fb5b50a6be7432f9ec6c1b5b75af2675a..31c5c338c473cd2b4b0e9cc53c611174712deea9 100644 (file)
@@ -84,11 +84,12 @@ Datum LWGEOM_getSRID(PG_FUNCTION_ARGS)
 PG_FUNCTION_INFO_V1(LWGEOM_setSRID);
 Datum LWGEOM_setSRID(PG_FUNCTION_ARGS)
 {
-       PG_LWGEOM *lwgeom = (PG_LWGEOM *)  PG_DETOAST_DATUM(PG_GETARG_DATUM(0));
+       PG_LWGEOM *geom = (PG_LWGEOM *)PG_DETOAST_DATUM(PG_GETARG_DATUM(0));
        int newSRID = PG_GETARG_INT32(1);
        PG_LWGEOM *result;
 
-       result = pglwgeom_setSRID(lwgeom, newSRID);
+       result = PG_LWGEOM_construct(SERIALIZED_FORM(geom), newSRID,
+               lwgeom_hasBBOX(geom->type));
 
        PG_RETURN_POINTER(result);
 }