From 645634d9a3c6fd1f64e1e86d47fe726468711fca Mon Sep 17 00:00:00 2001 From: Sandro Santilli Date: Thu, 11 Mar 2010 20:34:01 +0000 Subject: [PATCH] Set interface specs in stone within the implementation file, add a testcase to show what's "left" and what's "right" in the split-line-by-point git-svn-id: http://svn.osgeo.org/postgis/trunk@5414 b70326c6-7e19-0410-871a-916f4a2858ee --- postgis/lwgeom_geos_split.c | 9 ++++++++- regress/split.sql | 2 ++ regress/split_expected | 1 + 3 files changed, 11 insertions(+), 1 deletion(-) diff --git a/postgis/lwgeom_geos_split.c b/postgis/lwgeom_geos_split.c index a89039666..5c7b52406 100644 --- a/postgis/lwgeom_geos_split.c +++ b/postgis/lwgeom_geos_split.c @@ -14,7 +14,14 @@ * ST_SplitGeometry * * Split polygon by line, line by line, line by point. - * Returns components as a collection + * Returns at most components as a collection. + * First element of the collection is always the part which + * remains after the cut, while the second element is the + * part which has been cut out. We arbitrarely take the part + * on the *right* of cut lines as the part which has been cut out. + * For a line cut by a point the part which remains is the one + * from start of the line to the cut point. + * * * Author: Sandro Santilli * diff --git a/regress/split.sql b/regress/split.sql index be86daefa..f9fdeae05 100644 --- a/regress/split.sql +++ b/regress/split.sql @@ -1,6 +1,8 @@ -- Point on line select '1',st_asewkt(st_splitgeometry('SRID=10;LINESTRING(0 0, 10 0)', 'POINT(5 0)')); +select '1.1',st_asewkt(st_splitgeometry('SRID=10;LINESTRING(10 0, 0 0)', 'POINT(5 0)')); + -- Point on line boundary select '2',st_asewkt(st_splitgeometry('SRID=10;LINESTRING(0 0, 10 0)', 'POINT(10 0)')); diff --git a/regress/split_expected b/regress/split_expected index 8e40501aa..a9937352d 100644 --- a/regress/split_expected +++ b/regress/split_expected @@ -1,3 +1,4 @@ 1|SRID=10;GEOMETRYCOLLECTION(LINESTRING(0 0,5 0),LINESTRING(5 0,10 0)) +1.1|SRID=10;GEOMETRYCOLLECTION(LINESTRING(10 0,5 0),LINESTRING(5 0,0 0)) 2|SRID=10;GEOMETRYCOLLECTION(LINESTRING(0 0,10 0)) 3|SRID=10;GEOMETRYCOLLECTION(LINESTRING(0 0,10 0)) -- 2.40.0