--
-- 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;
-- 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');