From: Sandro Santilli Date: Wed, 11 Jan 2012 14:46:13 +0000 (+0000) Subject: Drop geography-specific C-side of AsBinary function. Proxy to geometry. X-Git-Tag: 2.0.0alpha1~108 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=63838db72e926a22ca7159f0eca065dd4d8e29b4;p=postgis Drop geography-specific C-side of AsBinary function. Proxy to geometry. See #288 git-svn-id: http://svn.osgeo.org/postgis/trunk@8772 b70326c6-7e19-0410-871a-916f4a2858ee --- diff --git a/postgis/geography.sql.in.c b/postgis/geography.sql.in.c index d87d6b620..a81344306 100644 --- a/postgis/geography.sql.in.c +++ b/postgis/geography.sql.in.c @@ -110,19 +110,6 @@ CREATE OR REPLACE FUNCTION ST_GeogFromText(text) AS 'MODULE_PATHNAME','geography_from_text' LANGUAGE 'C' IMMUTABLE STRICT; --- Availability: 1.5.0 -CREATE OR REPLACE FUNCTION ST_AsBinary(geography) - RETURNS bytea - AS 'MODULE_PATHNAME','geography_as_binary' - LANGUAGE 'C' IMMUTABLE STRICT; - --- Availability: 1.5.0 - this is just a hack to prevent unknown from causing ambiguous name because of geography --- TODO Remove in 2.0 -CREATE OR REPLACE FUNCTION ST_AsBinary(text) - RETURNS bytea AS - $$ SELECT ST_AsBinary($1::geometry); $$ - LANGUAGE 'SQL' IMMUTABLE STRICT; - -- Availability: 1.5.0 CREATE OR REPLACE FUNCTION ST_GeogFromWKB(bytea) RETURNS geography @@ -685,6 +672,19 @@ CREATE OR REPLACE FUNCTION ST_Intersection(text, text) $$ SELECT ST_Intersection($1::geometry, $2::geometry); $$ LANGUAGE 'SQL' IMMUTABLE STRICT; +-- Availability: 1.5.0 +CREATE OR REPLACE FUNCTION ST_AsBinary(geography) + RETURNS bytea AS + $$ SELECT ST_AsBinary($1::geometry); $$ + LANGUAGE 'SQL' IMMUTABLE STRICT; + +-- Availability: 2.0.0 +CREATE OR REPLACE FUNCTION ST_AsBinary(geography,text) + RETURNS bytea AS + $$ SELECT ST_AsBinary($1::geometry, $2); $$ + LANGUAGE 'SQL' IMMUTABLE STRICT; + + ----------------------------------------------------------------------------- diff --git a/postgis/geography_inout.c b/postgis/geography_inout.c index ff1e43d09..d7899b83e 100644 --- a/postgis/geography_inout.c +++ b/postgis/geography_inout.c @@ -39,7 +39,6 @@ Datum geography_as_geojson(PG_FUNCTION_ARGS); Datum geography_as_gml(PG_FUNCTION_ARGS); Datum geography_as_kml(PG_FUNCTION_ARGS); Datum geography_as_svg(PG_FUNCTION_ARGS); -Datum geography_as_binary(PG_FUNCTION_ARGS); Datum geography_from_binary(PG_FUNCTION_ARGS); Datum geography_from_geometry(PG_FUNCTION_ARGS); Datum geometry_from_geography(PG_FUNCTION_ARGS); @@ -518,44 +517,6 @@ Datum geography_from_text(PG_FUNCTION_ARGS) PG_RETURN_DATUM(rv); } -/* -** geography_as_binary(*GSERIALIZED) returns bytea -*/ -PG_FUNCTION_INFO_V1(geography_as_binary); -Datum geography_as_binary(PG_FUNCTION_ARGS) -{ - LWGEOM *lwgeom = NULL; - uint8_t *wkb = NULL; - bytea *wkb_result; - size_t wkb_size = 0; - GSERIALIZED *g = (GSERIALIZED*)PG_DETOAST_DATUM(PG_GETARG_DATUM(0)); - - /* Get our lwgeom form */ - lwgeom = lwgeom_from_gserialized(g); - - if ( gserialized_ndims(g) > 2 ) - { - /* Strip out the higher dimensions */ - LWGEOM *tmp = lwgeom_force_2d(lwgeom); - lwgeom_free(lwgeom); - lwgeom = tmp; - } - - /* Create WKB */ - wkb = lwgeom_to_wkb(lwgeom, WKB_SFSQL, &wkb_size); - - /* Copy to varlena pointer */ - wkb_result = palloc(wkb_size + VARHDRSZ); - SET_VARSIZE(wkb_result, wkb_size + VARHDRSZ); - memcpy(VARDATA(wkb_result), wkb, wkb_size); - - /* Clean up */ - pfree(wkb); - lwgeom_free(lwgeom); - - PG_RETURN_BYTEA_P(wkb_result); -} - /* ** geography_from_binary(*char) returns *GSERIALIZED */ diff --git a/regress/tickets_expected b/regress/tickets_expected index 412af22cc..e250707e9 100644 --- a/regress/tickets_expected +++ b/regress/tickets_expected @@ -96,7 +96,7 @@ NOTICE: IllegalArgumentException: Invalid number of points in LinearRing found #650|MULTIPOINT(0 0,1 1,2 2) #667|SRID=4326;CURVEPOLYGON(CIRCULARSTRING(30 40,18.2842712474619 11.7157287525381,-9.99999999999994 0,-38.284271247462 68.2842712474618,30 40)) #677|1121395 -#680|010100000000000000000024c00000000000004940 +#680|01d107000000000000000024c000000000000049400000000000000040 #682|0103000020E610000000000000 #683|0103000020E610000000000000 #684|0103000020E610000000000000