Reword exception message, make algorithm more robust not relying on constructive functions to detect relation between inputs

git-svn-id: http://svn.osgeo.org/postgis/trunk@5436 b70326c6-7e19-0410-871a-916f4a2858ee
This commit is contained in:
Sandro Santilli 2010-03-13 12:55:00 +00:00
parent b6d3dc4d04
commit 30fe3142f4
3 changed files with 23 additions and 33 deletions

View file

@ -56,6 +56,8 @@ lwline_split_by_line(LWLINE* lwline_in, LWLINE* blade_in)
GEOSGeometry* gdiff; /* difference */
GEOSGeometry* g1;
GEOSGeometry* g2;
char* i9;
int ret;
/* Possible outcomes:
*
@ -80,43 +82,31 @@ lwline_split_by_line(LWLINE* lwline_in, LWLINE* blade_in)
lwerror("LWGEOM2GEOS: %s", lwgeom_geos_errmsg);
return NULL;
}
/* If interior intersecton is linear we can't split */
ret = GEOSRelatePattern(g1, g2, "1********");
if ( 2 == ret ) {
lwerror("GEOSRelatePattern: %s", lwgeom_geos_errmsg);
GEOSGeom_destroy(g1);
GEOSGeom_destroy(g2);
return NULL;
}
if ( ret ) {
GEOSGeom_destroy(g1);
GEOSGeom_destroy(g2);
lwerror("Splitter line has linear intersection with input");
return NULL;
}
gdiff = GEOSDifference(g1,g2);
GEOSGeom_destroy(g1);
GEOSGeom_destroy(g2);
if (gdiff == NULL) {
GEOSGeom_destroy(g1);
lwerror("GEOSDifference: %s", lwgeom_geos_errmsg);
return NULL;
}
/* If we lost any point, raise an exception */
g2 = GEOSDifference(g1, gdiff);
if (gdiff == NULL) {
GEOSGeom_destroy(g1);
lwerror("GEOSDifference (check): %s", lwgeom_geos_errmsg);
return NULL;
}
if ( ! GEOSisEmpty(g2) )
{
GEOSGeom_destroy(g1);
GEOSGeom_destroy(g2);
lwerror("Splitter line overlaps input");
return NULL;
}
/*
lwnotice("Difference between original (%s) and split (%s) is not empty (%s)",
lwgeom_to_ewkt(GEOS2LWGEOM(gdiff, 0),
PARSER_CHECK_NONE),
lwgeom_to_ewkt(GEOS2LWGEOM(g1, 0),
PARSER_CHECK_NONE),
lwgeom_to_ewkt(GEOS2LWGEOM(g2, 0),
PARSER_CHECK_NONE));
*/
GEOSGeom_destroy(g1);
GEOSGeom_destroy(g2);
diff = GEOS2LWGEOM(gdiff, TYPE_HASZ(lwline_in->type));
GEOSGeom_destroy(gdiff);
if (NULL == diff) {

View file

@ -28,5 +28,5 @@ select '7', st_asewkt(ST_SplitGeometry('SRID=10;LINESTRING(0 0, 10 0, 10 10, 0 1
-- Split line by overlapping line (1)
select '8.1', st_asewkt(ST_SplitGeometry('SRID=10;LINESTRING(0 0, 10 0)', 'SRID=10;LINESTRING(5 0, 20 0)'));
-- Split line by overlapping line (2)
-- Split line by contained line (2)
select '8.2', st_asewkt(ST_SplitGeometry('SRID=10;LINESTRING(0 0, 10 0)', 'SRID=10;LINESTRING(5 0, 8 0)'));

View file

@ -8,5 +8,5 @@ ERROR: Operation on mixed SRID geometries
5|SRID=10;GEOMETRYCOLLECTION(LINESTRING(0 0,10 0))
6|SRID=10;GEOMETRYCOLLECTION(LINESTRING(0 0,5 0),LINESTRING(5 0,10 0))
7|SRID=10;GEOMETRYCOLLECTION(LINESTRING(0 0,5 0),LINESTRING(5 0,10 0,10 10,5 10),LINESTRING(5 10,0 10,0 20,5 20),LINESTRING(5 20,10 20))
ERROR: Splitter line overlaps input
ERROR: Splitter line overlaps input
ERROR: Splitter line has linear intersection with input
ERROR: Splitter line has linear intersection with input