From: Sandro Santilli Date: Fri, 27 May 2011 10:18:38 +0000 (+0000) Subject: Simplify face registration by the end of ST_AddEdgeNewFaces [RT-SIGTA] X-Git-Tag: 2.0.0alpha1~1543 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=9568ec8e5d3e39852964a6c3a1dcaa5f8510266a;p=postgis Simplify face registration by the end of ST_AddEdgeNewFaces [RT-SIGTA] git-svn-id: http://svn.osgeo.org/postgis/trunk@7271 b70326c6-7e19-0410-871a-916f4a2858ee --- diff --git a/topology/sql/sqlmm.sql b/topology/sql/sqlmm.sql index a475a5613..b63fd33d9 100644 --- a/topology/sql/sqlmm.sql +++ b/topology/sql/sqlmm.sql @@ -2440,44 +2440,35 @@ BEGIN INTO STRICT fan.post; IF ST_NumGeometries(fan.pre) = ST_NumGeometries(fan.post) THEN - -- all done, I hope + -- No splits, all done RETURN newedge.edge_id; END IF; RAISE NOTICE 'ST_AddEdgeNewFaces: edge % splitted face %', newedge.edge_id, newedge.left_face; - IF newedge.left_face != 0 THEN -- { - - -- Set old face edges to zero to let AddFace do something with them - EXECUTE 'UPDATE ' || quote_ident(atopology) - || '.edge_data SET left_face = 0 WHERE left_face = ' - || newedge.left_face; - EXECUTE 'UPDATE ' || quote_ident(atopology) - || '.edge_data SET right_face = 0 WHERE right_face = ' - || newedge.left_face; - - -- Now we call topology.AddFace for each of the two new - -- faces. These are the ones that do contain the new edge - -- The ORDER serves predictability of which face is added first - 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) - || ', ' || quote_literal(rec.geom::text) || ')'; - EXECUTE sql INTO newface; - newfaces := array_append(newfaces, newface); - END LOOP; --} + -- Call topology.AddFace for every face containing the new edge + -- The ORDER serves predictability of which face is added first + FOR rec IN SELECT geom FROM ST_Dump(fan.post) + WHERE ST_Contains( + ST_Boundary(geom), + ST_MakeLine( + ST_StartPoint(newedge.cleangeom), + ST_PointN(newedge.cleangeom, 2) + ) + ) + ORDER BY ST_XMin(geom), ST_YMin(geom) + LOOP -- { + RAISE DEBUG 'Adding face %', ST_AsText(rec.geom); + sql := + 'SELECT topology.AddFace(' || quote_literal(atopology) + || ', ' || quote_literal(rec.geom::text) || ', true)'; + EXECUTE sql INTO newface; + newfaces := array_append(newfaces, newface); + END LOOP; --} + RAISE DEBUG 'Added faces: %', newfaces; - RAISE DEBUG 'Added faces: %', newfaces; + IF newedge.left_face != 0 THEN -- { -- NOT IN THE SPECS: -- update TopoGeometry compositions to substitute oldface with newfaces @@ -2509,26 +2500,6 @@ BEGIN || '.face WHERE face_id = ' || newedge.left_face; EXECUTE sql; - ELSE -- }{ - - FOR rec IN SELECT (ST_Dump(fan.post)).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) - || ', ' || quote_literal(rec.geom::text) || ')'; - EXECUTE sql INTO newface; - newfaces := array_append(newfaces, newface); - END LOOP; --} - - RAISE DEBUG 'Added faces: %', newfaces; - END IF; -- } RETURN newedge.edge_id;