From: Sandro Santilli Date: Wed, 23 Feb 2005 09:58:16 +0000 (+0000) Subject: Fixed GeometryFromText() to add a bbox cache FOR_COMPLEX_GEOMS X-Git-Tag: pgis_1_0_0RC3~9 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=f8ae98c28f7e6e25db00b4d5de88a29546ae1d27;p=postgis Fixed GeometryFromText() to add a bbox cache FOR_COMPLEX_GEOMS git-svn-id: http://svn.osgeo.org/postgis/trunk@1430 b70326c6-7e19-0410-871a-916f4a2858ee --- diff --git a/lwgeom/BBOXCACHE_BEHAVIOURS b/lwgeom/BBOXCACHE_BEHAVIOURS index 2dc446349..b538afd3b 100644 --- a/lwgeom/BBOXCACHE_BEHAVIOURS +++ b/lwgeom/BBOXCACHE_BEHAVIOURS @@ -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** diff --git a/lwgeom/lwgeom_ogc.c b/lwgeom/lwgeom_ogc.c index 077b6c6b8..8357a959f 100644 --- a/lwgeom/lwgeom_ogc.c +++ b/lwgeom/lwgeom_ogc.c @@ -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); }