]> granicus.if.org Git - postgis/commitdiff
ST_ModEdgeHeal: update TopoGeom definitions, and test it [RT-SIGTA]
authorSandro Santilli <strk@keybit.net>
Wed, 4 May 2011 18:20:20 +0000 (18:20 +0000)
committerSandro Santilli <strk@keybit.net>
Wed, 4 May 2011 18:20:20 +0000 (18:20 +0000)
git-svn-id: http://svn.osgeo.org/postgis/trunk@7089 b70326c6-7e19-0410-871a-916f4a2858ee

topology/sql/sqlmm.sql
topology/test/regress/st_modedgeheal.sql
topology/test/regress/st_modedgeheal_expected

index bb9956c934946b10018c2eab0c44629d195d7cfb..11b92cebcb27dabcbb2e9b1dfee4a0390ad207fe 100644 (file)
@@ -323,15 +323,20 @@ BEGIN
 
        --
   -- NOT IN THE SPECS:
-       -- Update references in the Relation table.
-       -- We only take into considerations non-hierarchical
-       -- TopoGeometry here, for obvious reasons.
-       --
-  -- Now we can safely drop composition rows involving second
-  -- edge, as the first edge took its space.
-
+  -- Drop composition rows involving second
+  -- edge, as the first edge took its space,
+  -- and all affected TopoGeom have been previously checked
+  -- for being composed by both edges.
+  sql := 'DELETE FROM ' || quote_ident(toponame)
+    || '.relation r USING topology.layer l '
+    || 'WHERE l.level = 0 AND l.feature_type = 2'
+    || ' AND l.topology_id = ' || topoid
+    || ' AND l.layer_id = r.layer_id AND abs(r.element_id) = '
+    || e2id;
+  --RAISE DEBUG 'SQL: %', sql;
+  EXECUTE sql;
 
-       RETURN commonnode;
+  RETURN commonnode;
 END
 $$
 LANGUAGE 'plpgsql' VOLATILE;
index d4d9b649eaaad0b2cb683ef5919ef3d689ee328a..8c872d6135969989ea2e1e109477c05200e9a9ef 100644 (file)
@@ -78,27 +78,29 @@ SELECT 'MH(2,1)', topology.ST_ModEdgeHeal('t', 2, 1);
 
 -- Now see how signed edges are updated
 
---SELECT 'E'||topology.AddEdge('t', 'LINESTRING(0 0, 5 0)');         -- 3
---SELECT 'E'||topology.AddEdge('t', 'LINESTRING(10 0, 5 0)');        -- 4
---
---INSERT INTO t.f VALUES ('F+E3-E4',
---  topology.CreateTopoGeom('t', 2, 1, '{{3,2},{-4,2}}')); 
---INSERT INTO t.f VALUES ('F-E3+E4',
---  topology.CreateTopoGeom('t', 2, 1, '{{-3,2},{4,2}}')); 
---
---SELECT r.topogeo_id, r.element_id
---  FROM t.relation r, t.f f WHERE 
---  r.layer_id = layer_id(f.g) AND r.topogeo_id = id(f.g)
---  ORDER BY r.layer_id, r.topogeo_id;
---
----- This is fine, but will have to tweak definition of
----- 'F+E3-E4' and 'F-E3+E4'
---SELECT 'MH(3,4)', topology.ST_ModEdgeHeal('t', 3, 4);
---
---SELECT r.topogeo_id, r.element_id
---  FROM t.relation r, t.f f WHERE 
---  r.layer_id = layer_id(f.g) AND r.topogeo_id = id(f.g)
---  ORDER BY r.layer_id, r.topogeo_id;
+SELECT 'E'||topology.AddEdge('t', 'LINESTRING(0 0, 5 0)');         -- 3
+SELECT 'E'||topology.AddEdge('t', 'LINESTRING(10 0, 5 0)');        -- 4
+
+INSERT INTO t.f VALUES ('F+E3-E4',
+  topology.CreateTopoGeom('t', 2, 1, '{{3,2},{-4,2}}')); 
+INSERT INTO t.f VALUES ('F-E3+E4',
+  topology.CreateTopoGeom('t', 2, 1, '{{-3,2},{4,2}}')); 
+
+SELECT r.topogeo_id, r.element_id
+  FROM t.relation r, t.f f WHERE 
+  r.layer_id = layer_id(f.g) AND r.topogeo_id = id(f.g)
+  AND r.topogeo_id in (2,3)
+  ORDER BY r.layer_id, r.topogeo_id;
+
+-- This is fine, but will have to tweak definition of
+-- 'F+E3-E4' and 'F-E3+E4'
+SELECT 'MH(3,4)', topology.ST_ModEdgeHeal('t', 3, 4);
+
+SELECT r.topogeo_id, r.element_id
+  FROM t.relation r, t.f f WHERE 
+  r.layer_id = layer_id(f.g) AND r.topogeo_id = id(f.g)
+  AND r.topogeo_id in (2,3)
+  ORDER BY r.layer_id, r.topogeo_id;
 
 SELECT topology.DropTopology('t');
 
index b19e2e3d000fe734ca428fd4b78f74bb20c5b59f..dc0072fddb955c7a38f72084c0782e7b60cd9eb4 100644 (file)
@@ -107,4 +107,13 @@ E1
 E2
 ERROR:  TopoGeom 1 in layer 1 (t.f.g) cannot be represented healing edges 1 and 2
 ERROR:  TopoGeom 1 in layer 1 (t.f.g) cannot be represented healing edges 2 and 1
+E3
+E4
+2|-4
+2|3
+3|4
+3|-3
+MH(3,4)|5
+2|3
+3|-3
 Topology 't' dropped