|| ' AND l.topology_id = ' || topoid
|| ' AND abs(r.element_id) IN (' || e1id || ',' || e2id || ') '
|| 'group by r.topogeo_id, r.layer_id, l.schema_name, l.table_name, '
- || ' l.feature_column ) t WHERE t.elems && '
- || quote_literal(eidary)
- || ' AND NOT t.elems @> '
+ || ' l.feature_column ) t WHERE NOT t.elems @> '
|| quote_literal(eidary);
- RAISE DEBUG 'SQL: %', sql;
+ --RAISE DEBUG 'SQL: %', sql;
FOR rec IN EXECUTE sql LOOP
RAISE EXCEPTION 'TopoGeom % in layer % (%.%.%) cannot be represented healing edges % and %',
rec.topogeo_id, rec.layer_id,
-- 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.
-- clean up
SELECT topology.DropTopology('city_data');
--- TODO: add TopoGeometry tests !
+-------------------------------------------------------------------------
+-------------------------------------------------------------------------
+-------------------------------------------------------------------------
+
+-- Now test in presence of features
+
+SELECT topology.CreateTopology('t') > 1;
+CREATE TABLE t.f(id varchar);
+SELECT topology.AddTopoGeometryColumn('t', 't', 'f','g', 'LINE');
+
+SELECT 'E'||topology.AddEdge('t', 'LINESTRING(2 2, 2 8)'); -- 1
+SELECT 'E'||topology.AddEdge('t', 'LINESTRING(2 8, 8 8)'); -- 2
+
+INSERT INTO t.f VALUES ('F+E1',
+ topology.CreateTopoGeom('t', 2, 1, '{{1,2}}'));
+
+-- This should be forbidden, as F+E1 above could not be
+-- defined w/out one of the edges
+SELECT 'MH(1,2)', topology.ST_ModEdgeHeal('t', 1, 2);
+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 topology.DropTopology('t');
+
+-------------------------------------------------------------------------
+-------------------------------------------------------------------------
+-------------------------------------------------------------------------
+
-- TODO: test registered but unexistent topology
-- TODO: test registered but corrupted topology
-- (missing node, edge, relation...)