From 9d2b1faeb48c6a2ff9ebff7e949c59d4efa13a8e Mon Sep 17 00:00:00 2001 From: Sandro Santilli Date: Wed, 22 Dec 2010 18:45:07 +0000 Subject: [PATCH] Support faces with all edges on the same side, and test [RT-SIGTA] git-svn-id: http://svn.osgeo.org/postgis/trunk@6474 b70326c6-7e19-0410-871a-916f4a2858ee --- topology/sql/populate.sql | 32 +++++++++++++++----------- topology/test/regress/addface.sql | 10 ++++++++ topology/test/regress/addface_expected | 11 ++++++++- 3 files changed, 38 insertions(+), 15 deletions(-) diff --git a/topology/sql/populate.sql b/topology/sql/populate.sql index 89e1a3211..4522235cc 100644 --- a/topology/sql/populate.sql +++ b/topology/sql/populate.sql @@ -420,24 +420,28 @@ BEGIN -- -- Update all edges having this face on the left -- - EXECUTE 'UPDATE ' - || quote_ident(atopology) - || '.edge_data SET left_face = ' - || quote_literal(faceid) - || ' WHERE edge_id = ANY(' - || quote_literal(left_edges) - || ') '; + IF left_edges IS NOT NULL THEN + EXECUTE 'UPDATE ' + || quote_ident(atopology) + || '.edge_data SET left_face = ' + || quote_literal(faceid) + || ' WHERE edge_id = ANY(' + || quote_literal(left_edges) + || ') '; + END IF; -- -- Update all edges having this face on the right -- - EXECUTE 'UPDATE ' - || quote_ident(atopology) - || '.edge_data SET right_face = ' - || quote_literal(faceid) - || ' WHERE edge_id = ANY(' - || quote_literal(right_edges) - || ') '; + IF right_edges IS NOT NULL THEN + EXECUTE 'UPDATE ' + || quote_ident(atopology) + || '.edge_data SET right_face = ' + || quote_literal(faceid) + || ' WHERE edge_id = ANY(' + || quote_literal(right_edges) + || ') '; + END IF; RETURN faceid; diff --git a/topology/test/regress/addface.sql b/topology/test/regress/addface.sql index ffc5173f7..d52435c95 100644 --- a/topology/test/regress/addface.sql +++ b/topology/test/regress/addface.sql @@ -23,6 +23,16 @@ SELECT 'f1', topology.addFace('tt', 'POLYGON((0 0, 0 10, 10 10, 10 0, 0 0))'); -- Register the _same_ face again SELECT 'f1*', topology.addFace('tt', 'POLYGON((0 0, 0 10, 10 10, 10 0, 0 0))'); +-- Add 3 more edges closing a squre to the right, +-- all edges with same direction + +SELECT 'e6', topology.addEdge('tt', 'LINESTRING(10 10, 20 10)'); +SELECT 'e7', topology.addEdge('tt', 'LINESTRING(20 10, 20 0)'); +SELECT 'e8', topology.addEdge('tt', 'LINESTRING(20 0, 10 0)'); + +-- Register a face with no holes matching all edges in the same direction +SELECT 'f2', topology.addFace('tt', 'POLYGON((10 10, 20 10, 20 0, 10 0, 10 10))'); + -- Check added faces SELECT face_id, mbr from tt.face ORDER by face_id; diff --git a/topology/test/regress/addface_expected b/topology/test/regress/addface_expected index 731e7c2bd..6609eab5f 100644 --- a/topology/test/regress/addface_expected +++ b/topology/test/regress/addface_expected @@ -9,11 +9,20 @@ WARNING: Not checking if face contains any edge f1|1 WARNING: Not checking if face contains any edge f1*|1 +e6|6 +e7|7 +e8|8 +WARNING: Not checking if face contains any edge +f2|2 0| 1|BOX(0 0,10 10) +2|BOX(10 0,20 10) 1|1|0 -2|1|0 +2|1|2 3|0|1 4|0|1 5|0|0 +6|0|2 +7|0|2 +8|0|2 Topology 'tt' dropped