From: Sandro Santilli Date: Thu, 11 Mar 2010 20:19:14 +0000 (+0000) Subject: Have ST_SplitGeometry return a collection of at most 2 elements (original part, cut... X-Git-Tag: 2.0.0alpha1~3124 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=e44c62ca567a1a2f3d606f962a93075fb199d046;p=postgis Have ST_SplitGeometry return a collection of at most 2 elements (original part, cut-away part) so it's easier to handle by callers git-svn-id: http://svn.osgeo.org/postgis/trunk@5412 b70326c6-7e19-0410-871a-916f4a2858ee --- diff --git a/postgis/lwgeom_geos_split.c b/postgis/lwgeom_geos_split.c index b8ed1f99c..150b1362e 100644 --- a/postgis/lwgeom_geos_split.c +++ b/postgis/lwgeom_geos_split.c @@ -84,10 +84,10 @@ lwline_split_by_point(LWLINE* lwline_in, LWPOINT* blade_in) /* TODO: check if either pa1 or pa2 are empty ? */ components = lwalloc(sizeof(LWGEOM*)*2); - components[0] = (LWGEOM*)lwline_construct(lwline_in->SRID, NULL, pa1); - components[1] = (LWGEOM*)lwline_construct(lwline_in->SRID, NULL, pa2); + components[0] = (LWGEOM*)lwline_construct(-1, NULL, pa1); + components[1] = (LWGEOM*)lwline_construct(-1, NULL, pa2); - out = lwcollection_construct(MULTILINETYPE, lwline_in->SRID, + out = lwcollection_construct(COLLECTIONTYPE, lwline_in->SRID, NULL, 2, components); /* That's all folks */ diff --git a/regress/split.sql b/regress/split.sql index 7c9005d84..be86daefa 100644 --- a/regress/split.sql +++ b/regress/split.sql @@ -1,9 +1,9 @@ -- Point on line -select '1',st_astext(st_splitgeometry('LINESTRING(0 0, 10 0)', 'POINT(5 0)')); +select '1',st_asewkt(st_splitgeometry('SRID=10;LINESTRING(0 0, 10 0)', 'POINT(5 0)')); -- Point on line boundary -select '2',st_astext(st_splitgeometry('LINESTRING(0 0, 10 0)', 'POINT(10 0)')); +select '2',st_asewkt(st_splitgeometry('SRID=10;LINESTRING(0 0, 10 0)', 'POINT(10 0)')); -- Point off line -select '3',st_astext(st_splitgeometry('LINESTRING(0 0, 10 0)', 'POINT(5 1)')); +select '3',st_asewkt(st_splitgeometry('SRID=10;LINESTRING(0 0, 10 0)', 'POINT(5 1)')); diff --git a/regress/split_expected b/regress/split_expected index f6cc7bec9..b5f1a0d73 100644 --- a/regress/split_expected +++ b/regress/split_expected @@ -1,3 +1,3 @@ -1|MULTILINESTRING((0 0,5 0),(5 0,10 0)) -2|LINESTRING(0 0,10 0) -3|LINESTRING(0 0,10 0) +1|SRID=10;GEOMETRYCOLLECTION(LINESTRING(0 0,5 0),LINESTRING(5 0,10 0)) +2|SRID=10;LINESTRING(0 0,10 0) +3|SRID=10;LINESTRING(0 0,10 0)