]> granicus.if.org Git - postgis/commitdiff
topology.AddFace: prepare ring geometry and check intersection with an interior edge...
authorSandro Santilli <strk@keybit.net>
Mon, 4 Apr 2011 12:11:00 +0000 (12:11 +0000)
committerSandro Santilli <strk@keybit.net>
Mon, 4 Apr 2011 12:11:00 +0000 (12:11 +0000)
git-svn-id: http://svn.osgeo.org/postgis/trunk@7002 b70326c6-7e19-0410-871a-916f4a2858ee

topology/sql/populate.sql

index 25b69ac4e43717062a031bf417169a13085fee6d..302c4f1f9cfc70fdb2435d5d4d11811bb7a00c29 100644 (file)
@@ -370,14 +370,12 @@ BEGIN
       || quote_ident(atopology) || '.edge e, (SELECT '
       || quote_literal(bounds::text)
       || '::geometry as geom) r WHERE '
-      || 'r.geom && e.geom AND ST_Relate(e.geom, r.geom'
-      || ', ''1FF******'')'
+      || 'r.geom && e.geom'
     ;
     -- RAISE DEBUG 'SQL: %', sql;
     FOR rec IN EXECUTE sql
     LOOP -- {
-
-      -- Find the side of the edge on the face
+      --RAISE DEBUG 'Edge % has bounding box intersection', rec.edge_id;
 
       -- Find first non-empty segment of the edge
       numsegs = ST_NumPoints(rec.geom);
@@ -396,8 +394,24 @@ BEGIN
         CONTINUE; -- we don't want to spend time on it
       END IF;
 
-      
       edgeseg = ST_MakeLine(p1, p2);
+
+      -- Skip non-covered edges
+      IF NOT ST_Equals(p2, ST_EndPoint(rec.geom)) THEN
+        IF NOT ( _ST_Intersects(bounds, p1) AND _ST_Intersects(bounds, p2) )
+        THEN
+          --RAISE DEBUG 'Edge % has points % and % not intersecting with ring bounds', rec.edge_id, st_astext(p1), st_astext(p2);
+          CONTINUE;
+        END IF;
+      ELSE
+        -- must be a 2-points only edge, let's use Covers (more expensive)
+        IF NOT _ST_Covers(bounds, edgeseg) THEN
+          --RAISE DEBUG 'Edge % is not covered by ring', rec.edge_id;
+          CONTINUE;
+        END IF;
+      END IF;
+
+
       p3 = ST_StartPoint(bounds);
       IF ST_DWithin(edgeseg, p3, 0) THEN
         -- Edge segment covers ring endpoint, See bug #874
@@ -418,8 +432,6 @@ BEGIN
       right_side = ST_Line_Locate_Point(bounds, p1) < 
                    ST_Line_Locate_Point(bounds, p2);
   
-      --SELECT DISTINCT (st_dump(st_sharedpaths(rec.geom, bounds))).path[1] = 1 INTO STRICT right_side;
-
       RAISE DEBUG 'Edge % (left:%, right:%) - ring : % - right_side : %',
         rec.edge_id, rec.left_face, rec.right_face, rrec.path, right_side;