From: Sandro Santilli Date: Tue, 15 Jan 2013 11:54:29 +0000 (+0000) Subject: Base vertex snap tolerance in lwline_split_by_point on line length X-Git-Tag: 2.1.0beta2~253 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=bea0d083f5d5c5c789e51575fc169aad51ce6b3a;p=postgis Base vertex snap tolerance in lwline_split_by_point on line length 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 --- diff --git a/liblwgeom/lwgeom_geos_split.c b/liblwgeom/lwgeom_geos_split.c index 17646d47a..7bf9a153a 100644 --- a/liblwgeom/lwgeom_geos_split.c +++ b/liblwgeom/lwgeom_geos_split.c @@ -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); diff --git a/regress/split.sql b/regress/split.sql index 9ce7e7fc7..6567bc314 100644 --- a/regress/split.sql +++ b/regress/split.sql @@ -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 diff --git a/regress/split_expected b/regress/split_expected index 331b34eff..94234e604 100644 --- a/regress/split_expected +++ b/regress/split_expected @@ -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