[postgis-tickets] r14890 - #3523, kmeans compile warnings

Daniel Baston dbaston at gmail.com
Wed May 11 07:10:24 PDT 2016


Author: dbaston
Date: 2016-05-11 07:10:24 -0700 (Wed, 11 May 2016)
New Revision: 14890

Modified:
   trunk/liblwgeom/lwkmeans.c
Log:
#3523, kmeans compile warnings

Modified: trunk/liblwgeom/lwkmeans.c
===================================================================
--- trunk/liblwgeom/lwkmeans.c	2016-05-11 09:53:39 UTC (rev 14889)
+++ trunk/liblwgeom/lwkmeans.c	2016-05-11 14:10:24 UTC (rev 14890)
@@ -81,13 +81,13 @@
 	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 @@
 		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;
 	}
 
 	/*



More information about the postgis-tickets mailing list