From: Paul Ramsey Date: Mon, 2 Oct 2017 12:51:58 +0000 (+0000) Subject: Gracefully handle short-measure issue (Closes #3845) X-Git-Tag: 2.4.1~22 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=cce0c7ee91d056ad2ed7f78387addc8b27dccc19;p=postgis Gracefully handle short-measure issue (Closes #3845) git-svn-id: http://svn.osgeo.org/postgis/branches/2.4@15872 b70326c6-7e19-0410-871a-916f4a2858ee --- diff --git a/NEWS b/NEWS index 32a39f49e..4b589491a 100644 --- a/NEWS +++ b/NEWS @@ -4,6 +4,7 @@ YYYY/MM/DD * Bug fixes * - #3864, Fix memory leaks in BTREE operators - #3869, Fix build with "gold" linker + - #3845, Gracefully handle short-measure issue PostGIS 2.4.0 2017/09/30 diff --git a/liblwgeom/lwlinearreferencing.c b/liblwgeom/lwlinearreferencing.c index fdd8c6301..5cb81bb21 100644 --- a/liblwgeom/lwlinearreferencing.c +++ b/liblwgeom/lwlinearreferencing.c @@ -50,14 +50,15 @@ segment_locate_along(const POINT4D *p1, const POINT4D *p2, double m, double offs *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;