]> granicus.if.org Git - postgis/commitdiff
Drop geography-specific C-side of AsBinary function. Proxy to geometry.
authorSandro Santilli <strk@keybit.net>
Wed, 11 Jan 2012 14:46:13 +0000 (14:46 +0000)
committerSandro Santilli <strk@keybit.net>
Wed, 11 Jan 2012 14:46:13 +0000 (14:46 +0000)
See #288

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

postgis/geography.sql.in.c
postgis/geography_inout.c
regress/tickets_expected

index d87d6b6208b9f86ec04108dce1dbe7667bd58603..a8134430667d34434982fea6fc4f963861006b6f 100644 (file)
@@ -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;
+       
+
 -----------------------------------------------------------------------------
 
 
index ff1e43d096d70dae4bc5366ade06b5de567d179b..d7899b83ea7491b543cf77b4b3ffc64c67866b1f 100644 (file)
@@ -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
 */
index 412af22ccf5ee92626b77660a55c5fbbfb8948af..e250707e9498868a46db4cbe82d3dba49594b649 100644 (file)
@@ -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