]> granicus.if.org Git - postgis/commitdiff
#3523, kmeans compile warnings
authorDaniel Baston <dbaston@gmail.com>
Wed, 11 May 2016 14:10:24 +0000 (14:10 +0000)
committerDaniel Baston <dbaston@gmail.com>
Wed, 11 May 2016 14:10:24 +0000 (14:10 +0000)
git-svn-id: http://svn.osgeo.org/postgis/trunk@14890 b70326c6-7e19-0410-871a-916f4a2858ee

liblwgeom/lwkmeans.c

index 83b39ab11fd64c898768c9c9d8642c3628213fe3..4daa946b33aad51c27821e5afd513454d50ef06c 100644 (file)
@@ -81,13 +81,13 @@ lwgeom_cluster_2d_kmeans(const LWGEOM **geoms, int ngeoms, int k)
        LWGEOM **centroids;
        POINT2D *centers_raw;
        const POINT2D *cp;
-       POINT2D min, max;
+       POINT2D min = { FLT_MAX, FLT_MAX };
+       POINT2D max = { FLT_MIN, FLT_MIN };
        double dx, dy;
        kmeans_config config;
        kmeans_result result;
        int *seen;
        int sidx = 0;
-       int initialized = 0;
 
        assert(k>0);
        assert(ngeoms>0);
@@ -157,19 +157,10 @@ lwgeom_cluster_2d_kmeans(const LWGEOM **geoms, int ngeoms, int k)
                config.objs[i] = (Pointer)cp;
 
                /* Since we're already here, let's calculate the extrema of the set */
-               if (!initialized)
-               {
-                       initialized = 1;
-                       min = *cp;
-                       max = *cp;
-               }
-               else
-               {
-                       if (cp->x < min.x) min.x = cp->x;
-                       if (cp->y < min.y) min.y = cp->y;
-                       if (cp->x > max.x) max.x = cp->x;
-                       if (cp->y > max.y) max.y = cp->y;
-               }
+               if (cp->x < min.x) min.x = cp->x;
+               if (cp->y < min.y) min.y = cp->y;
+               if (cp->x > max.x) max.x = cp->x;
+               if (cp->y > max.y) max.y = cp->y;
        }
 
        /*