]> granicus.if.org Git - postgis/commitdiff
ST_InterpolatePoint returns empty M value (#1873)
authorPaul Ramsey <pramsey@cleverelephant.ca>
Tue, 19 Jun 2012 20:47:45 +0000 (20:47 +0000)
committerPaul Ramsey <pramsey@cleverelephant.ca>
Tue, 19 Jun 2012 20:47:45 +0000 (20:47 +0000)
git-svn-id: http://svn.osgeo.org/postgis/trunk@9955 b70326c6-7e19-0410-871a-916f4a2858ee

liblwgeom/cunit/cu_ptarray.c
liblwgeom/ptarray.c

index 47eeec89ff86f23408e61a9b52ecca341b41edfd..7ecec2dfd82c730f7f7cf1f51158ccdce448b771 100644 (file)
@@ -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)
index eab44e4d3bbdd02d914a3b9bf4ec8fe80f6cf3d7..571f3f7db1940a7e41ec556e2ee0fbcc1a7883a3 100644 (file)
@@ -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;