From: Sandro Santilli Date: Wed, 4 May 2011 18:20:20 +0000 (+0000) Subject: ST_ModEdgeHeal: update TopoGeom definitions, and test it [RT-SIGTA] X-Git-Tag: 2.0.0alpha1~1718 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=67bce7164787e00a929a153c71d3335e27707a0f;p=postgis ST_ModEdgeHeal: update TopoGeom definitions, and test it [RT-SIGTA] git-svn-id: http://svn.osgeo.org/postgis/trunk@7089 b70326c6-7e19-0410-871a-916f4a2858ee --- diff --git a/topology/sql/sqlmm.sql b/topology/sql/sqlmm.sql index bb9956c93..11b92cebc 100644 --- a/topology/sql/sqlmm.sql +++ b/topology/sql/sqlmm.sql @@ -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; diff --git a/topology/test/regress/st_modedgeheal.sql b/topology/test/regress/st_modedgeheal.sql index d4d9b649e..8c872d613 100644 --- a/topology/test/regress/st_modedgeheal.sql +++ b/topology/test/regress/st_modedgeheal.sql @@ -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'); diff --git a/topology/test/regress/st_modedgeheal_expected b/topology/test/regress/st_modedgeheal_expected index b19e2e3d0..dc0072fdd 100644 --- a/topology/test/regress/st_modedgeheal_expected +++ b/topology/test/regress/st_modedgeheal_expected @@ -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