From: Regina Obe Date: Sun, 5 May 2013 16:24:09 +0000 (+0000) Subject: #2118: ST_Boundary support for Triangle type X-Git-Tag: 2.1.0beta2~58 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=673fcda4346206a45cfeebca7fee3260532c57bd;p=postgis #2118: ST_Boundary support for Triangle type git-svn-id: http://svn.osgeo.org/postgis/trunk@11358 b70326c6-7e19-0410-871a-916f4a2858ee --- diff --git a/postgis/lwgeom_geos.c b/postgis/lwgeom_geos.c index c86e9bf0f..f342385f3 100644 --- a/postgis/lwgeom_geos.c +++ b/postgis/lwgeom_geos.c @@ -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 */ { diff --git a/regress/Makefile.in b/regress/Makefile.in index 6560bd332..83304f137 100644 --- a/regress/Makefile.in +++ b/regress/Makefile.in @@ -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 index 000000000..68dc883d8 --- /dev/null +++ b/regress/boundary.sql @@ -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 index 000000000..8105f0bcb --- /dev/null +++ b/regress/boundary_expected @@ -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)