]> granicus.if.org Git - postgis/commitdiff
Base vertex snap tolerance in lwline_split_by_point on line length
authorSandro Santilli <strk@keybit.net>
Tue, 15 Jan 2013 11:54:29 +0000 (11:54 +0000)
committerSandro Santilli <strk@keybit.net>
Tue, 15 Jan 2013 11:54:29 +0000 (11:54 +0000)
Fixes robustness issue in splitting line with own vertex (#2173)
Also fixes one case of topology building (#2172)

git-svn-id: http://svn.osgeo.org/postgis/trunk@10973 b70326c6-7e19-0410-871a-916f4a2858ee

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

index 17646d47abdacae9577b4df1a72fdd05ed822f1b..7bf9a153af7b3a6b8f5d8da5496a25b0e0b7958c 100644 (file)
@@ -198,7 +198,11 @@ lwline_split_by_point_to(const LWLINE* lwline_in, const LWPOINT* blade_in,
        }
 
        /* There is a real intersection, let's get two substrings */
-       vstol = 1e-14; /* TODO: take this as parameter ? */
+
+       /* Compute vertex snap tolerance based on line length
+        * TODO: take as parameter ? */
+       vstol = ptarray_length_2d(lwline_in->points) / 1e14;
+
        pa1 = ptarray_substring(lwline_in->points, 0, loc, vstol);
        pa2 = ptarray_substring(lwline_in->points, loc, 1, vstol);
 
index 9ce7e7fc707640d26345bf2548d8a64bbefe8d15..6567bc3146823fa6d95982ba6c2d2972ab38d2de 100644 (file)
@@ -69,4 +69,13 @@ select '70', st_asewkt(ST_Split('SRID=11;LINESTRING(1691983.26 4874594.81 312.24
 select '80', st_asewkt(ST_Split('LINESTRING(0 1, 0 1, 0 1)', 'POINT(0 1)'));
 select '81', st_asewkt(ST_Split('LINESTRING(0 1, 0 1)', 'POINT(0 1)'));
 
+-- Split long line by vertex point
+-- See http://trac.osgeo.org/postgis/ticket/2173
+with inp as ( SELECT 
+'01020000001000000034030F8FB15866C0F2311FFD3B9A53C0571C87CF1BB65BC0182DB847DB9052C0EBD57BDEEBF658C05CA18B9FA81B52C074384E71C20552C05AD308B7C38351C0A4B3920AA7914CC0ACD200FB29784FC0F8892AEE70E14040C0C8143E325651C0234604DC104E5440EF10F2807BF850C08FEE52B6CAE15F4002BF1C6676B450C0051A57A65BB061405B9E445AEC9F50C05AF3E1D5815665405E3A4A2BB6CF51C0591DE7ECD21F66400D33BFE91C7E53C0000000E0FF7F6640000000C04E9353C0000000000080664000000000008056C000000000008066C000000000008056C000000000008066C0000000E04D9353C034030F8FB15866C0F2311FFD3B9A53C0'
+  ::geometry as g, 14 as p )
+select '82', st_equals(g, st_union(
+    st_geometryn(st_split(g, st_pointn(g,p)), 1), 
+    st_geometryn(st_split(g, st_pointn(g,p)), 2))) from inp;
+
 -- TODO: split line by collapsed line 
index 331b34eff594ae19986511abaa71f72fa82b5249..94234e604073beb941171ad2d900b0f452e3c92d 100644 (file)
@@ -23,3 +23,4 @@ ERROR:  Splitter line has linear intersection with input
 70|SRID=11;GEOMETRYCOLLECTION(LINESTRING(1691983.26 4874594.81 312.24,1691984.86 4874593.69 312.24,1691982 4874589.60428571 312.24),LINESTRING(1691982 4874589.60428571 312.24,1691981.30515131 4874588.61164472 312.24),LINESTRING(1691981.30515131 4874588.61164472 312.24,1691979.54 4874586.09 312.24,1691978.03 4874587.16 298.36))
 80|GEOMETRYCOLLECTION(LINESTRING(0 1,0 1,0 1))
 81|GEOMETRYCOLLECTION(LINESTRING(0 1,0 1))
+82|t