From ba555d1cafceeeb4f21ed16568662c44cae30eba Mon Sep 17 00:00:00 2001 From: Sandro Santilli Date: Fri, 17 Feb 2012 15:11:36 +0000 Subject: [PATCH] Rework edge motion range construction (#1571) Includes a new testcase which was failing before this change git-svn-id: http://svn.osgeo.org/postgis/trunk@9226 b70326c6-7e19-0410-871a-916f4a2858ee --- topology/sql/sqlmm.sql.in.c | 28 +++++++++++++++---- topology/test/regress/st_changeedgegeom.sql | 5 ++++ .../test/regress/st_changeedgegeom_expected | 3 +- 3 files changed, 30 insertions(+), 6 deletions(-) diff --git a/topology/sql/sqlmm.sql.in.c b/topology/sql/sqlmm.sql.in.c index 9ddeae651..f78143e3e 100644 --- a/topology/sql/sqlmm.sql.in.c +++ b/topology/sql/sqlmm.sql.in.c @@ -2538,6 +2538,8 @@ DECLARE rec RECORD; oldedge RECORD; range GEOMETRY; -- movement range + tmp1 GEOMETRY; + tmp2 GEOMETRY; sql TEXT; iscw BOOLEAN; BEGIN @@ -2672,12 +2674,28 @@ BEGIN -- Not in the specs: -- Check topological isomorphism -- - range := ST_MakeLine(oldedge.geom, ST_Reverse(acurve)); - RAISE DEBUG 'Made line: %', ST_AsText(range); - range := ST_MakePolygon(range); - RAISE DEBUG 'Made poly: %', ST_AsText(range); - range := ST_CollectionExtract(ST_MakeValid(range), 3); + tmp1 := ST_MakeLine(ST_EndPoint(oldedge.geom), ST_StartPoint(oldedge.geom)); + RAISE DEBUG 'end-to-start: %', ST_AsText(tmp1); + + tmp2 := ST_MakeLine(oldedge.geom, tmp1); + IF ST_NumPoints(tmp2) < 4 THEN + tmp2 := ST_AddPoint(tmp2, ST_StartPoint(oldedge.geom)); + END IF; + RAISE DEBUG 'Old-ring: %', ST_AsText(tmp2); + tmp2 := ST_CollectionExtract(ST_MakeValid(ST_MakePolygon(tmp2)), 3); + RAISE DEBUG 'Old-ring (poly): %', ST_AsText(tmp2); + + range := ST_MakeLine(acurve, tmp1); + IF ST_NumPoints(range) < 4 THEN + range := ST_AddPoint(range, ST_StartPoint(oldedge.geom)); + END IF; + RAISE DEBUG 'New-ring: %', ST_AsText(range); + range := ST_CollectionExtract(ST_MakeValid(ST_MakePolygon(range)), 3); + RAISE DEBUG 'New-ring (poly): %', ST_AsText(range); + + range := ST_SymDifference(range, tmp2); RAISE DEBUG 'Range motion: %', ST_AsText(range); + sql := 'SELECT node_id, geom FROM ' || quote_ident(atopology) || '.node WHERE ST_Contains(' diff --git a/topology/test/regress/st_changeedgegeom.sql b/topology/test/regress/st_changeedgegeom.sql index 4902def1b..f6cefdc2f 100644 --- a/topology/test/regress/st_changeedgegeom.sql +++ b/topology/test/regress/st_changeedgegeom.sql @@ -62,6 +62,10 @@ SELECT 'T7', topology.ST_ChangeEdgeGeom('city_data', 2, SELECT topology.ST_ChangeEdgeGeom('city_data', 2, 'LINESTRING(25 30, 28 39, 20 39, 25 30)'); +-- This movement should be fine +SELECT 'T7.1', topology.ST_ChangeEdgeGeom('city_data', 2, +'LINESTRING(25 30, 28 39, 17 39, 25 30)'); + -- Test changing winding direction of closed edge SELECT topology.ST_ChangeEdgeGeom('city_data', 26, ST_Reverse('LINESTRING(4 31, 7 31, 4 34, 4 31)')); @@ -74,6 +78,7 @@ SELECT 'T8', topology.ST_ChangeEdgeGeom('city_data', 26, SELECT topology.ST_ChangeEdgeGeom('city_data', 13, 'LINESTRING(21 6, 21 2, 6 2, 6 25, 50 25, 50 2, 35 2, 35 6)'); + -- TODO: test moving closed edge into another face -- TODO: test face mbr update diff --git a/topology/test/regress/st_changeedgegeom_expected b/topology/test/regress/st_changeedgegeom_expected index cc2e55b1c..74e1ce560 100644 --- a/topology/test/regress/st_changeedgegeom_expected +++ b/topology/test/regress/st_changeedgegeom_expected @@ -18,7 +18,8 @@ T5|Edge 3 changed T6|Edge 3 changed ERROR: Edge motion collision at POINT(20 37) T7|Edge 2 changed -ERROR: Edge motion collision at POINT(25 35) +ERROR: Edge motion collision at POINT(20 37) +T7.1|Edge 2 changed ERROR: Edge twist at node POINT(4 31) T8|Edge 26 changed ERROR: Edge motion collision at POINT(9 6) -- 2.50.1