From 7ecbeee84ea3e20b69ad1282869f528e2ce393d9 Mon Sep 17 00:00:00 2001 From: Paul Ramsey Date: Tue, 19 Jun 2012 20:47:45 +0000 Subject: [PATCH] ST_InterpolatePoint returns empty M value (#1873) git-svn-id: http://svn.osgeo.org/postgis/trunk@9955 b70326c6-7e19-0410-871a-916f4a2858ee --- liblwgeom/cunit/cu_ptarray.c | 10 ++++++++++ liblwgeom/ptarray.c | 16 ++++------------ 2 files changed, 14 insertions(+), 12 deletions(-) diff --git a/liblwgeom/cunit/cu_ptarray.c b/liblwgeom/cunit/cu_ptarray.c index 47eeec89f..7ecec2dfd 100644 --- a/liblwgeom/cunit/cu_ptarray.c +++ b/liblwgeom/cunit/cu_ptarray.c @@ -258,6 +258,16 @@ static void test_ptarray_locate_point(void) CU_ASSERT_EQUAL(dist, 0.0); lwline_free(line); + line = lwgeom_as_lwline(lwgeom_from_text("LINESTRING M (0 0 0, 10 0 20)")); + + p.x = 5; p.y = 0; + loc = ptarray_locate_point(line->points, &p, &dist, &l); + CU_ASSERT_EQUAL(loc, 0.5); + CU_ASSERT_EQUAL(dist, 0.0); + CU_ASSERT_EQUAL(l.m, 10.0); + + lwline_free(line); + } static void test_ptarray_isccw(void) diff --git a/liblwgeom/ptarray.c b/liblwgeom/ptarray.c index eab44e4d3..571f3f7db 100644 --- a/liblwgeom/ptarray.c +++ b/liblwgeom/ptarray.c @@ -1001,20 +1001,12 @@ ptarray_locate_point(const POINTARRAY *pa, const POINT4D *p4d, double *mindistou LWDEBUGF(3, "mindist: %g", mindist); /* - * If mindist is not 0 we need to project the + * We need to project the * point on the closest segment. */ - if ( FP_GT(mindist, 0.0) ) - { - getPoint4d_p(pa, seg, &start4d); - getPoint4d_p(pa, seg+1, &end4d); - closest_point_on_segment(p4d, &start4d, &end4d, proj4d); - } - else - { - if ( proj4d) - *proj4d = *p4d; - } + getPoint4d_p(pa, seg, &start4d); + getPoint4d_p(pa, seg+1, &end4d); + closest_point_on_segment(p4d, &start4d, &end4d, proj4d); /* Copy 4D values into 2D holder */ proj.x = proj4d->x; -- 2.50.1