]> granicus.if.org Git - postgis/commitdiff
#3051, warning: 'end' may be used uninitialized in this function
authorPaul Ramsey <pramsey@cleverelephant.ca>
Mon, 23 Feb 2015 14:36:22 +0000 (14:36 +0000)
committerPaul Ramsey <pramsey@cleverelephant.ca>
Mon, 23 Feb 2015 14:36:22 +0000 (14:36 +0000)
git-svn-id: http://svn.osgeo.org/postgis/trunk@13268 b70326c6-7e19-0410-871a-916f4a2858ee

liblwgeom/ptarray.c

index 2a9d96ca6ab85f8c5b0f0ab14acfe6d307aac66f..a734c68d87686368f3a4053920396d2aa12289a5 100644 (file)
@@ -1273,14 +1273,24 @@ ptarray_locate_point(const POINTARRAY *pa, const POINT4D *p4d, double *mindistou
        int t, seg=-1;
        POINT4D start4d, end4d, projtmp;
        POINT2D proj, p;
-       const POINT2D *start, *end;
+       const POINT2D *start = NULL, *end = NULL;
 
        /* Initialize our 2D copy of the input parameter */
        p.x = p4d->x;
        p.y = p4d->y;
        
        if ( ! proj4d ) proj4d = &projtmp;
-
+       
+       /* If the pointarray has only one point, the nearest point is */
+       /* just that point */
+       if ( pa->npoints == 1 )
+       {
+               getPoint4d_p(pa, 0, proj4d);
+               *mindistout = distance2d_pt_pt(&p, start);
+               return 0.0;
+       }
+       
+       /* Loop through pointarray looking for nearest segment */
        start = getPoint2d_cp(pa, 0);
        for (t=1; t<pa->npoints; t++)
        {