From: Paul Ramsey Date: Wed, 22 Jul 2015 14:54:03 +0000 (+0000) Subject: #2641, ST_SRID and ST_SetSRID for geography X-Git-Tag: 2.2.0rc1~230 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=9fc3981a43285c61863cc6a8810808100a613bc4;p=postgis #2641, ST_SRID and ST_SetSRID for geography git-svn-id: http://svn.osgeo.org/postgis/trunk@13827 b70326c6-7e19-0410-871a-916f4a2858ee --- diff --git a/postgis/geography.sql.in b/postgis/geography.sql.in index b8ac6807f..be9f4b998 100644 --- a/postgis/geography.sql.in +++ b/postgis/geography.sql.in @@ -801,7 +801,18 @@ CREATE OR REPLACE FUNCTION ST_GeoHash(geog geography, maxchars int4 DEFAULT 0) AS 'MODULE_PATHNAME', 'ST_GeoHash' LANGUAGE 'c' IMMUTABLE STRICT; +-- Availability: 2.2.0 +CREATE OR REPLACE FUNCTION ST_SRID(geog geography) + RETURNS int4 + AS 'MODULE_PATHNAME', 'LWGEOM_get_srid' + LANGUAGE 'c' IMMUTABLE STRICT; +-- Availability: 2.2.0 +CREATE OR REPLACE FUNCTION ST_SetSRID(geog geography, srid int4) + RETURNS geography + AS 'MODULE_PATHNAME', 'LWGEOM_set_srid' + LANGUAGE 'c' IMMUTABLE STRICT; + ----------------------------------------------------------------------------- diff --git a/postgis/lwgeom_ogc.c b/postgis/lwgeom_ogc.c index a4d82cca3..f4b1879dc 100644 --- a/postgis/lwgeom_ogc.c +++ b/postgis/lwgeom_ogc.c @@ -91,15 +91,10 @@ Datum LWGEOM_get_srid(PG_FUNCTION_ARGS) PG_FUNCTION_INFO_V1(LWGEOM_set_srid); Datum LWGEOM_set_srid(PG_FUNCTION_ARGS) { - GSERIALIZED *result; - GSERIALIZED *geom = PG_GETARG_GSERIALIZED_P(0); + GSERIALIZED *g = (GSERIALIZED *)PG_DETOAST_DATUM_COPY(PG_GETARG_DATUM(0)); int srid = PG_GETARG_INT32(1); - LWGEOM *lwgeom = lwgeom_from_gserialized(geom); - lwgeom_set_srid(lwgeom, srid); - result = geometry_serialize(lwgeom); - lwgeom_free(lwgeom); - PG_FREE_IF_COPY(geom, 0); - PG_RETURN_POINTER(result); + gserialized_set_srid(g, srid); + PG_RETURN_POINTER(g); } /* returns a string representation of this geometry's type */