]> granicus.if.org Git - postgis/commitdiff
#2118: ST_Boundary support for Triangle type
authorRegina Obe <lr@pcorp.us>
Sun, 5 May 2013 16:24:09 +0000 (16:24 +0000)
committerRegina Obe <lr@pcorp.us>
Sun, 5 May 2013 16:24:09 +0000 (16:24 +0000)
git-svn-id: http://svn.osgeo.org/postgis/trunk@11358 b70326c6-7e19-0410-871a-916f4a2858ee

postgis/lwgeom_geos.c
regress/Makefile.in
regress/boundary.sql [new file with mode: 0644]
regress/boundary_expected [new file with mode: 0644]

index c86e9bf0f61c0efaa1970f4112c505a4debbea4b..f342385f37802e5a1762d261287d514c6f790e61 100644 (file)
@@ -903,9 +903,24 @@ Datum boundary(PG_FUNCTION_ARGS)
 
        srid = gserialized_get_srid(geom1);
 
+       LWGEOM *lwgeom = lwgeom_from_gserialized(geom1);
+       if ( ! lwgeom ) {
+               lwerror("POSTGIS2GEOS: unable to deserialize input");
+               return NULL;
+       }
+
+       /* GEOS doesn't do triangle type, so we special case that here */
+       if (lwgeom->type == TRIANGLETYPE) {
+               lwgeom->type = LINETYPE;
+               result = geometry_serialize(lwgeom);
+               lwgeom_free(lwgeom);
+               PG_RETURN_POINTER(result);
+       }
+
        initGEOS(lwnotice, lwgeom_geos_error);
 
-       g1 = (GEOSGeometry *)POSTGIS2GEOS(geom1 );
+       g1 = LWGEOM2GEOS(lwgeom);
+       lwgeom_free(lwgeom);
 
        if ( 0 == g1 )   /* exception thrown at construction */
        {
index 6560bd33249a5f73c1da4bbb8b3a70cd25544e86..83304f13795428ec5c3bad8103d6d636de9b9da0 100644 (file)
@@ -108,6 +108,7 @@ TESTS = \
        regress_management \
        dump \
        dumppoints \
+       boundary \
        wmsservers \
        wkt \
        wkb \
diff --git a/regress/boundary.sql b/regress/boundary.sql
new file mode 100644 (file)
index 0000000..68dc883
--- /dev/null
@@ -0,0 +1,5 @@
+SELECT ST_AsText(ST_Boundary(ST_GeomFromText('LINESTRING(1 1,0 0, -1 1)')));
+SELECT ST_AsText(ST_Boundary(ST_GeomFromText('POLYGON((1 1,0 0, -1 1, 1 1))')));
+SELECT ST_AsEWKT(ST_Boundary(ST_GeomFromEWKT('POLYGON((1 1 1,0 0 1, -1 1 1, 1 1 1))')));
+SELECT ST_AsEWKT(ST_Boundary(ST_GeomFromEWKT('MULTILINESTRING((1 1 1,0 0 0.5, -1 1 1),(1 1 0.5,0 0 0.5, -1 1 0.5, 1 1 0.5) )')));
+SELECT ST_AsText(ST_Boundary(ST_GeomFromText('TRIANGLE((1 1,0 0, -1 1, 1 1))')));
diff --git a/regress/boundary_expected b/regress/boundary_expected
new file mode 100644 (file)
index 0000000..8105f0b
--- /dev/null
@@ -0,0 +1,5 @@
+MULTIPOINT(1 1,-1 1)
+LINESTRING(1 1,0 0,-1 1,1 1)
+LINESTRING(1 1 1,0 0 1,-1 1 1,1 1 1)
+MULTIPOINT(-1 1 1,1 1 0.75)
+LINESTRING(1 1,0 0,-1 1,1 1)