From 5b2a29f1f2c99b3277b314e6752b5bbcc31880f4 Mon Sep 17 00:00:00 2001 From: Sandro Santilli Date: Tue, 3 Jan 2012 09:44:10 +0000 Subject: [PATCH] Don't consider shared nodes as edge intersections. Fixes #1428. git-svn-id: http://svn.osgeo.org/postgis/trunk@8648 b70326c6-7e19-0410-871a-916f4a2858ee --- topology/sql/sqlmm.sql | 40 ++++++++++++++----- topology/test/regress/st_changeedgegeom.sql | 4 ++ .../test/regress/st_changeedgegeom_expected | 3 +- 3 files changed, 37 insertions(+), 10 deletions(-) diff --git a/topology/sql/sqlmm.sql b/topology/sql/sqlmm.sql index 6e6ec7dc9..fda288e24 100644 --- a/topology/sql/sqlmm.sql +++ b/topology/sql/sqlmm.sql @@ -2503,16 +2503,38 @@ BEGIN END LOOP; -- - -- h) Check if curve intersects any other edge - -- - FOR rec IN EXECUTE 'SELECT * FROM ' - || quote_ident(atopology) || '.edge_data ' - || ' WHERE edge_id != ' || anedge - || ' AND ST_Intersects(geom, ' - || quote_literal(acurve::text) || '::geometry)' + -- h) Check if this geometry has any interaction with any existing edge + -- + FOR rec IN EXECUTE 'SELECT edge_id, ST_Relate(geom,' + || quote_literal(acurve::text) + || '::geometry, 2) as im FROM ' + || quote_ident(atopology) + || '.edge_data WHERE geom && ' + || quote_literal(acurve::text) || '::geometry' LOOP - RAISE EXCEPTION - 'SQL/MM Spatial exception - geometry intersects an edge'; + + --RAISE DEBUG 'IM=%',rec.im; + + IF ST_RelateMatch(rec.im, 'F********') THEN + CONTINUE; -- no interior-interior intersection + END IF; + + IF ST_RelateMatch(rec.im, '1FFF*FFF2') THEN + RAISE EXCEPTION + 'SQL/MM Spatial exception - coincident edge'; + END IF; + + -- NOT IN THE SPECS: geometry touches an edge + IF ST_RelateMatch(rec.im, '1********') THEN + RAISE EXCEPTION + 'Spatial exception - geometry intersects edge %', rec.edge_id; + END IF; + + IF ST_RelateMatch(rec.im, 'T********') THEN + RAISE EXCEPTION + 'SQL/MM Spatial exception - geometry crosses an edge'; + END IF; + END LOOP; -- diff --git a/topology/test/regress/st_changeedgegeom.sql b/topology/test/regress/st_changeedgegeom.sql index 72e2690dc..cc9a5ccfa 100644 --- a/topology/test/regress/st_changeedgegeom.sql +++ b/topology/test/regress/st_changeedgegeom.sql @@ -25,6 +25,10 @@ SELECT topology.ST_ChangeEdgeGeom('city_data', 666, SELECT topology.ST_ChangeEdgeGeom('city_data', 25, 'LINESTRING(9 35, 11 40, 13 35)'); +-- Test change in presence of edges sharing node (#1428) +SELECT topology.ST_ChangeEdgeGeom('city_data', 5, + 'LINESTRING(41 40, 57 33)'); + -- TODO: test changing closed edge -- TODO: test reverse direction of closed edge diff --git a/topology/test/regress/st_changeedgegeom_expected b/topology/test/regress/st_changeedgegeom_expected index 385828afc..4fcedf1a5 100644 --- a/topology/test/regress/st_changeedgegeom_expected +++ b/topology/test/regress/st_changeedgegeom_expected @@ -9,5 +9,6 @@ ERROR: SQL/MM Spatial exception - start node not geometry start point. ERROR: SQL/MM Spatial exception - end node not geometry end point. ERROR: SQL/MM Spatial exception - geometry crosses a node ERROR: SQL/MM Spatial exception - non-existent edge 666 -ERROR: SQL/MM Spatial exception - geometry intersects an edge +ERROR: SQL/MM Spatial exception - geometry crosses an edge +Edge 5 changed Topology 'city_data' dropped -- 2.49.0