]> granicus.if.org Git - postgis/commitdiff
Reword exception message, make algorithm more robust not relying on constructive...
authorSandro Santilli <strk@keybit.net>
Sat, 13 Mar 2010 12:55:00 +0000 (12:55 +0000)
committerSandro Santilli <strk@keybit.net>
Sat, 13 Mar 2010 12:55:00 +0000 (12:55 +0000)
git-svn-id: http://svn.osgeo.org/postgis/trunk@5436 b70326c6-7e19-0410-871a-916f4a2858ee

postgis/lwgeom_geos_split.c
regress/split.sql
regress/split_expected

index 233eb1ba0cf500ae9e907db573f1dba1afe57785..39698e82e1c923bb7429e85e46184005fae4ba27 100644 (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,42 +82,30 @@ lwline_split_by_line(LWLINE* lwline_in, LWLINE* blade_in)
                lwerror("LWGEOM2GEOS: %s", lwgeom_geos_errmsg);
                return NULL;
        }
-       gdiff = GEOSDifference(g1,g2);
-       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) {
+       /* 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);
-               lwerror("GEOSDifference (check): %s", lwgeom_geos_errmsg);
+               GEOSGeom_destroy(g2);
                return NULL;
        }
-       if ( ! GEOSisEmpty(g2) )
-       {
+       if ( ret ) {
                GEOSGeom_destroy(g1);
                GEOSGeom_destroy(g2);
-               lwerror("Splitter line overlaps input");
+               lwerror("Splitter line has linear intersection with 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));
-*/
 
+       gdiff = GEOSDifference(g1,g2);
        GEOSGeom_destroy(g1);
        GEOSGeom_destroy(g2);
-
+       if (gdiff == NULL) {
+               lwerror("GEOSDifference: %s", lwgeom_geos_errmsg);
+               return NULL;
+       }
 
        diff = GEOS2LWGEOM(gdiff, TYPE_HASZ(lwline_in->type));
        GEOSGeom_destroy(gdiff);
index 022df6c1aaf4692a5c2bcdeb3069e00c315acb39..3dc13c11d3f5b4e6f149575b0564776233a7951a 100644 (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)'));
index 5dd2d459e861ea24598d7108ad72a278d74acc71..ea59b4196648cfa8b1b4f46f0bf30fb921bd296d 100644 (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