From: Sandro Santilli Date: Fri, 27 May 2011 09:34:18 +0000 (+0000) Subject: topology.ST_AddEdgeNewFaces: do not needlessly replace face of holes found in a face... X-Git-Tag: 2.0.0alpha1~1545 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=567986bd5e402e77462785856519fbf962d40ab5;p=postgis topology.ST_AddEdgeNewFaces: do not needlessly replace face of holes found in a face splitted by the newly added edge. Regress test it. [RT-SIGTA]. git-svn-id: http://svn.osgeo.org/postgis/trunk@7269 b70326c6-7e19-0410-871a-916f4a2858ee --- diff --git a/topology/sql/sqlmm.sql b/topology/sql/sqlmm.sql index cb83709db..a475a5613 100644 --- a/topology/sql/sqlmm.sql +++ b/topology/sql/sqlmm.sql @@ -2444,10 +2444,10 @@ BEGIN RETURN newedge.edge_id; END IF; - RAISE WARNING 'ST_AddEdgeNewFaces: edge % splitted face %', + RAISE NOTICE 'ST_AddEdgeNewFaces: edge % splitted face %', newedge.edge_id, newedge.left_face; - IF newedge.left_face != 0 THEN + IF newedge.left_face != 0 THEN -- { -- Set old face edges to zero to let AddFace do something with them EXECUTE 'UPDATE ' || quote_ident(atopology) @@ -2463,6 +2463,12 @@ BEGIN FOR rec IN SELECT geom FROM ST_Dump(fan.post) ORDER BY ST_XMin(geom), ST_YMin(geom) LOOP -- { + -- skip the polygons whose boundary does not contain + -- the newly added edge + IF NOT ST_Contains(ST_Boundary(rec.geom), acurve) THEN + CONTINUE; + END IF; + RAISE DEBUG 'Adding face %', ST_AsText(rec.geom); sql := 'SELECT topology.AddFace(' || quote_literal(atopology) @@ -2503,7 +2509,7 @@ BEGIN || '.face WHERE face_id = ' || newedge.left_face; EXECUTE sql; - ELSE + ELSE -- }{ FOR rec IN SELECT (ST_Dump(fan.post)).geom LOOP -- { @@ -2523,7 +2529,7 @@ BEGIN RAISE DEBUG 'Added faces: %', newfaces; - END IF; + END IF; -- } RETURN newedge.edge_id; END diff --git a/topology/test/regress/st_addedgenewfaces.sql b/topology/test/regress/st_addedgenewfaces.sql index 9270eeaf8..8b621dc1e 100644 --- a/topology/test/regress/st_addedgenewfaces.sql +++ b/topology/test/regress/st_addedgenewfaces.sql @@ -340,6 +340,18 @@ SELECT 'T21', 'E'||edge_id, next_left_edge, next_right_edge, UNION VALUES (36),(16) ) ORDER BY edge_id; +-- +-- Split a face containing an hole +-- +INSERT INTO newedge SELECT 22, topology.st_addedgenewfaces('city_data', + 3, 3, 'LINESTRING(25 35, 27 35, 26 34, 25 35)'); +SELECT 'T22', 'E'||edge_id, next_left_edge, next_right_edge, + left_face, right_face FROM + city_data.edge WHERE edge_id IN ( + SELECT edge_id FROM newedge WHERE id IN (22, 16) + UNION VALUES (2),(3) ) + ORDER BY edge_id; + --------------------------------------------------------------------- -- Check new relations and faces status diff --git a/topology/test/regress/st_addedgenewfaces_expected b/topology/test/regress/st_addedgenewfaces_expected index f27d54c9d..2e952b182 100644 --- a/topology/test/regress/st_addedgenewfaces_expected +++ b/topology/test/regress/st_addedgenewfaces_expected @@ -97,6 +97,10 @@ T21|E16|29|-47|14|0 T21|E36|-13|-36|0|27 T21|E46|-14|47|35|36 T21|E47|-46|36|36|0 +T22|E2|3|39|37|0 +T22|E3|48|2|37|37 +T22|E42|42|-42|37|32 +T22|E48|-3|-48|37|38 F3,F4|{3:10,3:11,3:23,3:24,3:25} F5,N4|{1:4,3:12,3:13} F0| @@ -121,10 +125,11 @@ F27|POLYGON((32 0,32 6,38 6,38 0,32 0)) F28|POLYGON((3 11,3 17,9 17,9 11,3 11)) F29|POLYGON((5 27,5 30,11 30,11 27,5 27)) F30|POLYGON((22 27,22 30,28 30,28 27,22 27)) -F31|POLYGON((17 30,17 40,31 40,31 30,17 30)) F32|POLYGON((20 34,20 37,23 37,23 34,20 34)) F33|POLYGON((35 25,35 45,63 45,63 25,35 25)) F34|POLYGON((9 0,9 6,21 6,21 0,9 0)) F35|POLYGON((35 0,35 6,47 6,47 0,35 0)) F36|POLYGON((35 -4,35 6,47 6,47 -4,35 -4)) +F37|POLYGON((17 30,17 40,31 40,31 30,17 30)) +F38|POLYGON((25 34,25 35,27 35,27 34,25 34)) Topology 'city_data' dropped