[postgis-tickets] r16043 - Do not allow empty points as topology isolated nodes

Sandro Santilli strk at kbt.io
Sun Oct 22 10:36:19 PDT 2017


Author: strk
Date: 2017-10-22 10:36:18 -0700 (Sun, 22 Oct 2017)
New Revision: 16043

Modified:
   trunk/NEWS
   trunk/liblwgeom/lwgeom_topo.c
   trunk/topology/postgis_topology.c
   trunk/topology/test/regress/st_addisonode.sql
   trunk/topology/test/regress/st_addisonode_expected
Log:
Do not allow empty points as topology isolated nodes

Includes testcase
Fixes #3232

Modified: trunk/NEWS
===================================================================
--- trunk/NEWS	2017-10-22 16:34:02 UTC (rev 16042)
+++ trunk/NEWS	2017-10-22 17:36:18 UTC (rev 16043)
@@ -18,6 +18,7 @@
   - #3900, GCC warnings fixed, make -j is now working (Darafei Praliaskouski)
   - Topology population robustness improvements (Sandro Santilli)
     #1855, #1946, #3718 #3838
+  - #3232, Do not accept EMPTY points as topology nodes (Sandro Santilli)
 
 PostGIS 2.4.0
 2017/09/30

Modified: trunk/liblwgeom/lwgeom_topo.c
===================================================================
--- trunk/liblwgeom/lwgeom_topo.c	2017-10-22 16:34:02 UTC (rev 16042)
+++ trunk/liblwgeom/lwgeom_topo.c	2017-10-22 17:36:18 UTC (rev 16043)
@@ -525,6 +525,13 @@
 {
   LWT_ELEMID foundInFace = -1;
 
+  if ( lwpoint_is_empty(pt) )
+  {
+    lwerror("Cannot add empty point as isolated node");
+    return -1;
+  }
+
+
   if ( ! skipISOChecks )
   {
     if ( lwt_be_ExistsCoincidentNode(topo, pt) ) /*x*/

Modified: trunk/topology/postgis_topology.c
===================================================================
--- trunk/topology/postgis_topology.c	2017-10-22 16:34:02 UTC (rev 16042)
+++ trunk/topology/postgis_topology.c	2017-10-22 17:36:18 UTC (rev 16043)
@@ -3159,13 +3159,15 @@
   if ( ! pt ) {
     lwgeom_free(lwgeom);
 	  PG_FREE_IF_COPY(geom, 2);
-#if 0
-    lwpgerror("ST_AddIsoNode third argument must be a point geometry");
-#else
     lwpgerror("SQL/MM Spatial exception - invalid point");
-#endif
     PG_RETURN_NULL();
   }
+  if ( lwpoint_is_empty(pt) ) {
+    lwgeom_free(lwgeom);
+	  PG_FREE_IF_COPY(geom, 2);
+    lwpgerror("SQL/MM Spatial exception - empty point");
+    PG_RETURN_NULL();
+  }
 
   if ( SPI_OK_CONNECT != SPI_connect() ) {
     lwpgerror("Could not connect to SPI");

Modified: trunk/topology/test/regress/st_addisonode.sql
===================================================================
--- trunk/topology/test/regress/st_addisonode.sql	2017-10-22 16:34:02 UTC (rev 16042)
+++ trunk/topology/test/regress/st_addisonode.sql	2017-10-22 17:36:18 UTC (rev 16043)
@@ -49,5 +49,8 @@
 -- TODO: test for bug #1503
 --SELECT 'T5', st_addisonode('city_data', 22, 'POINT(28.5 32.5)');
 
+-- Test for #3234
+SELECT '#3234', topology.ST_AddIsoNode('city_data', 0, 'POINT EMPTY'::geometry);
+
 DROP TABLE nn;
 select topology.DropTopology('city_data');

Modified: trunk/topology/test/regress/st_addisonode_expected
===================================================================
--- trunk/topology/test/regress/st_addisonode_expected	2017-10-22 16:34:02 UTC (rev 16042)
+++ trunk/topology/test/regress/st_addisonode_expected	2017-10-22 17:36:18 UTC (rev 16043)
@@ -22,4 +22,5 @@
 T4|26|5
 T5|27|0
 T6|28|9
+ERROR:  SQL/MM Spatial exception - empty point
 Topology 'city_data' dropped



More information about the postgis-tickets mailing list