[postgis-tickets] [SCM] PostGIS branch master updated. 3.1.0alpha1-141-g2ce98e2

git at osgeo.org git at osgeo.org
Fri Jun 26 09:19:09 PDT 2020


This is an automated email from the git hooks/post-receive script. It was
generated because a ref change was pushed to the repository containing
the project "PostGIS".

The branch, master has been updated
       via  2ce98e26bc76fc0ae615774c9d2adfa0a39df008 (commit)
      from  96615d90e6d5e4716310eca25647ee373a8535f8 (commit)

Those revisions listed above that are new to this repository have
not appeared on any other notification email; so we list those
revisions in full, below.

- Log -----------------------------------------------------------------
commit 2ce98e26bc76fc0ae615774c9d2adfa0a39df008
Author: Sandro Santilli <strk at kbt.io>
Date:   Fri Jun 26 17:07:24 2020 +0200

    Handle non-closed edge rings by human readable error
    
    Handle both topological and geometrical corruption
    
    Have getRingEdges raise an error if topology is corrupted
    
    References #4709
    References #3042

diff --git a/liblwgeom/lwgeom_topo.c b/liblwgeom/lwgeom_topo.c
index 2bc954f..173cd80 100644
--- a/liblwgeom/lwgeom_topo.c
+++ b/liblwgeom/lwgeom_topo.c
@@ -1898,6 +1898,14 @@ _lwt_AddFaceSplit( LWT_TOPOLOGY* topo,
     return -2;
   }
   const POINTARRAY *pa = shell->rings[0];
+  if ( ! ptarray_is_closed(pa) )
+  {
+    lwpoly_free(shell);
+    lwfree( signed_edge_ids );
+    lwerror("Corrupted topology: ring of edge %" LWTFMT_ELEMID
+            " is geometrically not-closed", sedge);
+    return -2;
+  }
 
   int isccw = ptarray_isccw(pa);
   LWDEBUGF(1, "Ring of edge %" LWTFMT_ELEMID " is %sclockwise",
diff --git a/topology/postgis_topology.c b/topology/postgis_topology.c
index abadfb3..32bedb0 100644
--- a/topology/postgis_topology.c
+++ b/topology/postgis_topology.c
@@ -1231,6 +1231,40 @@ cb_getRingEdges(const LWT_BE_TOPOLOGY *topo, LWT_ELEMID edge, uint64_t *numelems
     val = DatumGetInt32(dat);
     edges[i] = val;
     POSTGIS_DEBUGF(1, "Component " UINT64_FORMAT " in ring of edge %" LWTFMT_ELEMID " is edge %d", i, edge, val);
+
+    /* For the last entry, check that we returned back to start
+     * point, or complain about topology being corrupted */
+    if ( i == *numelems - 1 )
+    {
+      int32 nextedge;
+      int sidecol = val > 0 ? 3 : 4;
+      const char *sidetext = val > 0 ? "left" : "right";
+
+      dat = SPI_getbinval(row, rowdesc, sidecol, &isnull);
+      if ( isnull )
+      {
+        lwfree(edges);
+        cberror(topo->be_data, "Edge %d" /*LWTFMT_ELEMID*/
+                               " has NULL next_%s_edge",
+                               val, sidetext);
+        *numelems = UINT64_MAX;
+        return NULL;
+      }
+      nextedge = DatumGetInt32(dat);
+      POSTGIS_DEBUGF(1, "Last component in ring of edge %"
+                        LWTFMT_ELEMID " (%" LWTFMT_ELEMID ") has next_%s_edge %d",
+                        edge, val, sidetext, nextedge);
+      if ( nextedge != edge )
+      {
+        lwfree(edges);
+        cberror(topo->be_data, "Corrupted topology: ring of edge %"
+                               LWTFMT_ELEMID " is topologically non-closed",
+                               edge);
+        *numelems = UINT64_MAX;
+        return NULL;
+      }
+    }
+
   }
 
   SPI_freetuptable(SPI_tuptable);

-----------------------------------------------------------------------

Summary of changes:
 liblwgeom/lwgeom_topo.c     |  8 ++++++++
 topology/postgis_topology.c | 34 ++++++++++++++++++++++++++++++++++
 2 files changed, 42 insertions(+)


hooks/post-receive
-- 
PostGIS


More information about the postgis-tickets mailing list