[postgis-tickets] r15871 - Gracefully handle short-measure issue (Closes #3845)

Paul Ramsey pramsey at cleverelephant.ca
Mon Oct 2 05:50:57 PDT 2017


Author: pramsey
Date: 2017-10-02 05:50:57 -0700 (Mon, 02 Oct 2017)
New Revision: 15871

Modified:
   branches/2.3/NEWS
   branches/2.3/liblwgeom/lwlinearreferencing.c
Log:
Gracefully handle short-measure issue (Closes #3845)



Modified: branches/2.3/NEWS
===================================================================
--- branches/2.3/NEWS	2017-10-02 11:51:01 UTC (rev 15870)
+++ branches/2.3/NEWS	2017-10-02 12:50:57 UTC (rev 15871)
@@ -24,6 +24,7 @@
   - #3818, Triangles unclosed in M should be parseable
   - #3866, Rare crash generating TWKB with large coordinate values
   - #3869, Fix build with "gold" linker
+  - #3845, Gracefully handle short-measure issue
 
 
 PostGIS 2.3.3

Modified: branches/2.3/liblwgeom/lwlinearreferencing.c
===================================================================
--- branches/2.3/liblwgeom/lwlinearreferencing.c	2017-10-02 11:51:01 UTC (rev 15870)
+++ branches/2.3/liblwgeom/lwlinearreferencing.c	2017-10-02 12:50:57 UTC (rev 15871)
@@ -50,14 +50,15 @@
 			*pn = *p1;
 			return LW_TRUE;
 		}
-		/* If the points are different we can out.
-		   Correct behavior is probably an mprop of 0.5? */
-		lwerror("Zero measure-length line encountered!");
-		return LW_FALSE;
+		/* If the points are different we split the difference */
+		mprop = 0.5;
 	}
+	else
+	{
+		mprop = (m - m1) / (m2 - m1);
+	}
 
 	/* M is in range, new point to be generated. */
-	mprop = (m - m1) / (m2 - m1);
 	pn->x = p1->x + (p2->x - p1->x) * mprop;
 	pn->y = p1->y + (p2->y - p1->y) * mprop;
 	pn->z = p1->z + (p2->z - p1->z) * mprop;



More information about the postgis-tickets mailing list