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

Paul Ramsey pramsey at cleverelephant.ca
Mon Oct 2 05:52:15 PDT 2017


Author: pramsey
Date: 2017-10-02 05:52:15 -0700 (Mon, 02 Oct 2017)
New Revision: 15873

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



Modified: trunk/liblwgeom/lwlinearreferencing.c
===================================================================
--- trunk/liblwgeom/lwlinearreferencing.c	2017-10-02 12:51:58 UTC (rev 15872)
+++ trunk/liblwgeom/lwlinearreferencing.c	2017-10-02 12:52:15 UTC (rev 15873)
@@ -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