]> granicus.if.org Git - postgis/commitdiff
Fixed GeometryFromText() to add a bbox cache FOR_COMPLEX_GEOMS
authorSandro Santilli <strk@keybit.net>
Wed, 23 Feb 2005 09:58:16 +0000 (09:58 +0000)
committerSandro Santilli <strk@keybit.net>
Wed, 23 Feb 2005 09:58:16 +0000 (09:58 +0000)
git-svn-id: http://svn.osgeo.org/postgis/trunk@1430 b70326c6-7e19-0410-871a-916f4a2858ee

lwgeom/BBOXCACHE_BEHAVIOURS
lwgeom/lwgeom_ogc.c

index 2dc44634922f032525e7774be6c418410d5d3c8a..b538afd3bc95291be7a6643f291b64bbcf22a987 100644 (file)
@@ -53,7 +53,7 @@ section also use it.
        geometry_recv(internal) **SRL**
        geometry(text) **SRL**
        geometry(bytea) **SRL**
-       GeometryFromText(geometry, SRID) **SRL**
+       GeometryFromText(geometry, SRID) *SRL*
        GeomFromWKB(bytea, SRID) **SRL**
        GeomFromEWKB(bytea) **SRL**
        GeomFromEWKT(text) **SRL**
index 077b6c6b8e3983642f52fb10da550675f2cb9013..8357a959fdcd99d7468db5669779007e5d6f148b 100644 (file)
@@ -784,6 +784,7 @@ Datum LWGEOM_from_text(PG_FUNCTION_ARGS)
        size_t size;
        PG_LWGEOM *geom;
        PG_LWGEOM *result = NULL;
+       LWGEOM *lwgeom;
 
        size = VARSIZE(wkttext)-VARHDRSZ;
 
@@ -812,22 +813,20 @@ Datum LWGEOM_from_text(PG_FUNCTION_ARGS)
 
        geom = (PG_LWGEOM *)parse_lwgeom_wkt(wkt);
 
-       if ( pglwgeom_getSRID(geom) != -1 || TYPE_GETZM(geom->type) != 0 )
+       lwgeom = lwgeom_deserialize(SERIALIZED_FORM(geom));
+
+       if ( lwgeom->SRID != -1 || TYPE_GETZM(lwgeom->type) != 0 )
        {
                elog(WARNING, "OGC WKT expected, EWKT provided - use GeomFromEWKT() for this");
        }
 
        // read user-requested SRID if any
-       if ( PG_NARGS() > 1 )
-       {
-               SRID = PG_GETARG_INT32(1);
-               if ( SRID != pglwgeom_getSRID(geom) )
-               {
-                       result = pglwgeom_setSRID(geom, SRID);
-                       pfree(geom);
-               }
-       }
-       if ( ! result ) result = geom;
+       if ( PG_NARGS() > 1 ) lwgeom->SRID = PG_GETARG_INT32(1);
+
+       result = pglwgeom_serialize(lwgeom);
+
+       pfree(geom);
+       lwgeom_release(lwgeom);
 
        PG_RETURN_POINTER(result);
 }