[postgis-tickets] r15571 - Reduce likeliness of non-noded intersections when using ST_Node

Regina Obe lr at pcorp.us
Wed Aug 23 09:16:40 PDT 2017


Author: robe
Date: 2017-08-23 09:16:40 -0700 (Wed, 23 Aug 2017)
New Revision: 15571

Modified:
   trunk/NEWS
   trunk/doc/reference_processing.xml
   trunk/liblwgeom/cunit/cu_node.c
   trunk/liblwgeom/lwgeom_geos_node.c
   trunk/regress/node.sql
   trunk/regress/node_expected
Log:
Reduce likeliness of non-noded intersections when using ST_Node
Patch contributed by Wouter Geraedts (with minor adjustments to the doc)
Closes #3647
Closes ?\226?\128?\139https://github.com/postgis/postgis/pull/136

Modified: trunk/NEWS
===================================================================
--- trunk/NEWS	2017-08-23 03:55:54 UTC (rev 15570)
+++ trunk/NEWS	2017-08-23 16:16:40 UTC (rev 15571)
@@ -26,6 +26,8 @@
            to norm_addy tiger_geocoder type.
   - #3748, address_standardizer lookup tables update
            so pagc_normalize_address better standardizes abbreviations
+  - #3647, better handling of noding in ST_Node using GEOSNode
+          (Wouter Geraedts)
 
 * Breaking Changes *
   - #3810, GEOS 3.5.0 or above minimum required to compile

Modified: trunk/doc/reference_processing.xml
===================================================================
--- trunk/doc/reference_processing.xml	2017-08-23 03:55:54 UTC (rev 15570)
+++ trunk/doc/reference_processing.xml	2017-08-23 16:16:40 UTC (rev 15571)
@@ -2293,16 +2293,20 @@
 Due to a bug in GEOS up to 3.3.1 this function fails to node self-intersecting
 lines. This is fixed with GEOS 3.3.2 or higher.
 		</para></note>
+		<note><para>
+Changed: 2.4.0 this function uses GEOSNode internally instead of GEOSUnaryUnion.
+This may cause the resulting linestrings to have a different order and direction compared to Postgis < 2.4.
+		</para></note>
 	  </refsection>
 	  <refsection>
 		<title>Examples</title>
 		<programlisting>
-SELECT ST_AsEWKT(
+SELECT ST_AsText(
 		ST_Node('LINESTRINGZ(0 0 0, 10 10 10, 0 10 5, 10 0 3)'::geometry)
 	) As  output;
 output
 -----------
-MULTILINESTRING((0 0 0,5 5 4.5),(5 5 4.5,10 10 10,0 10 5,5 5 4.5),(5 5 4.5,10 0 3))
+MULTILINESTRING Z ((0 0 0,5 5 4.5),(5 5 4.5,10 10 10,0 10 5,5 5 4.5),(5 5 4.5,10 0 3))
 		</programlisting>
 	  </refsection>
 

Modified: trunk/liblwgeom/cunit/cu_node.c
===================================================================
--- trunk/liblwgeom/cunit/cu_node.c	2017-08-23 03:55:54 UTC (rev 15570)
+++ trunk/liblwgeom/cunit/cu_node.c	2017-08-23 16:16:40 UTC (rev 15571)
@@ -53,7 +53,7 @@
 	tmp = lwgeom_to_ewkt(out);
 	/* printf("%s\n", tmp); */
 	CU_ASSERT_STRING_EQUAL(
-"MULTILINESTRING((0 0,2.5 2.5),(0 5,2.5 2.5),(22 0,20 0),(20 0,12 0,11 0,10 0),(10 0,5 5,2.5 2.5),(2.5 2.5,5 0))",
+"MULTILINESTRING((0 0,2.5 2.5),(0 5,2.5 2.5),(2.5 2.5,5 5,10 0),(10 0,11 0,12 0,20 0),(20 0,22 0),(2.5 2.5,5 0))",
 		tmp);
 	lwfree(tmp); lwgeom_free(out); lwgeom_free(in);
 }

Modified: trunk/liblwgeom/lwgeom_geos_node.c
===================================================================
--- trunk/liblwgeom/lwgeom_geos_node.c	2017-08-23 03:55:54 UTC (rev 15570)
+++ trunk/liblwgeom/lwgeom_geos_node.c	2017-08-23 16:16:40 UTC (rev 15571)
@@ -129,7 +129,7 @@
 LWGEOM*
 lwgeom_node(const LWGEOM* lwgeom_in)
 {
-	GEOSGeometry *g1, *gu, *gm;
+	GEOSGeometry *g1, *gn, *gm;
 	LWGEOM *ep, *lines;
 	LWCOLLECTION *col, *tc;
 	int pn, ln, np, nl;
@@ -153,18 +153,16 @@
 		return NULL;
 	}
 
-	/* Unary union input to fully node */
-	gu = GEOSUnaryUnion(g1);
+	gn = GEOSNode(g1);
 	GEOSGeom_destroy(g1);
-	if ( ! gu ) {
+	if ( ! gn ) {
 		lwgeom_free(ep);
 		lwerror("GEOSUnaryUnion: %s", lwgeom_geos_errmsg);
 		return NULL;
 	}
 
-	/* Linemerge (in case of overlaps) */
-	gm = GEOSLineMerge(gu);
-	GEOSGeom_destroy(gu);
+	gm = GEOSLineMerge(gn);
+	GEOSGeom_destroy(gn);
 	if ( ! gm ) {
 		lwgeom_free(ep);
 		lwerror("GEOSLineMerge: %s", lwgeom_geos_errmsg);

Modified: trunk/regress/node.sql
===================================================================
--- trunk/regress/node.sql	2017-08-23 03:55:54 UTC (rev 15570)
+++ trunk/regress/node.sql	2017-08-23 16:16:40 UTC (rev 15571)
@@ -14,3 +14,8 @@
 select 't3', st_asewkt(st_node(
 'SRID=10;LINESTRING(0 0, 10 10, 0 10, 10 0)'
 ));
+
+-- Node two overlapping 3d lines, from documentation
+select 't4', st_asewkt(st_node(
+'SRID=10;LINESTRINGZ(0 0 0, 10 10 10, 0 10 5, 10 0 3)'
+));

Modified: trunk/regress/node_expected
===================================================================
--- trunk/regress/node_expected	2017-08-23 03:55:54 UTC (rev 15570)
+++ trunk/regress/node_expected	2017-08-23 16:16:40 UTC (rev 15571)
@@ -1,3 +1,4 @@
 t1|SRID=10;MULTILINESTRING((0 0,5 0),(5 -5,5 0),(5 0,10 0),(5 0,5 5))
 t2|SRID=10;MULTILINESTRING((0 0,8 0),(8 0,10 0,15 0,20 0),(20 0,25 0))
 t3|SRID=10;MULTILINESTRING((0 0,5 5),(5 5,10 10,0 10,5 5),(5 5,10 0))
+t4|SRID=10;MULTILINESTRING((0 0 0,5 5 4.5),(5 5 4.5,10 10 10,0 10 5,5 5 4.5),(5 5 4.5,10 0 3))



More information about the postgis-tickets mailing list