[GRASS-SVN] r67241 - grass/trunk/vector/v.surf.idw

svn_grass at osgeo.org svn_grass at osgeo.org
Fri Dec 18 21:06:08 PST 2015


Author: mlennert
Date: 2015-12-18 21:06:08 -0800 (Fri, 18 Dec 2015)
New Revision: 67241

Modified:
   grass/trunk/vector/v.surf.idw/main.c
   grass/trunk/vector/v.surf.idw/proto.h
Log:
reverting last fix and using Paul's static var solution


Modified: grass/trunk/vector/v.surf.idw/main.c
===================================================================
--- grass/trunk/vector/v.surf.idw/main.c	2015-12-19 00:53:41 UTC (rev 67240)
+++ grass/trunk/vector/v.surf.idw/main.c	2015-12-19 05:06:08 UTC (rev 67241)
@@ -62,7 +62,6 @@
     double dist;
     double sum1, sum2, interp_value;
     int n;
-    int max;
     double p;
     struct
     {
@@ -299,7 +298,6 @@
 		else {
 		    pointsfound = 0;
 		    i = 0;
-		    max = 0;
 
 		    if (searchallpoints == 1) {
 			/* If there aren't many sites just check them all to find
@@ -307,7 +305,7 @@
 			for (n = 0; n < ncells; n++)
 			    calculate_distances(shortlistrows[n],
 						shortlistcolumns[n], north,
-						east, &pointsfound, &max);
+						east, &pointsfound);
 		    }
 		    else {
 			radius = 0;
@@ -328,7 +326,7 @@
 					col + search_list[radius]->column;
 				    calculate_distances(searchrow,
 							searchcolumn, north,
-							east, &pointsfound, &max);
+							east, &pointsfound);
 				}
 
 				/* Only if at least one offset is not 0 */
@@ -342,7 +340,7 @@
 					col - search_list[radius]->column;
 				    calculate_distances(searchrow,
 							searchcolumn, north,
-							east, &pointsfound, &max);
+							east, &pointsfound);
 				}
 
 				/* Only if both offsets are not 0 */
@@ -359,7 +357,7 @@
 					calculate_distances(searchrow,
 							    searchcolumn,
 							    north, east,
-							    &pointsfound, &max);
+							    &pointsfound);
 				    }
 				    if (row >= search_list[radius]->row &&
 					col <
@@ -372,7 +370,7 @@
 					calculate_distances(searchrow,
 							    searchcolumn,
 							    north, east,
-							    &pointsfound, &max);
+							    &pointsfound);
 				    }
 				}
 
@@ -458,9 +456,10 @@
 }
 
 void calculate_distances(int row, int column, double north,
-			 double east, int *pointsfound, int *max)
+			 double east, int *pointsfound)
 {
     int j, n;
+    static int max;
     double dx, dy, dist;
     static double maxdist;
 
@@ -476,10 +475,10 @@
 
 	    /* find the maximum distance */
 	    if (i == nsearch) {
-		maxdist = list[*max = 0].dist;
+		maxdist = list[max = 0].dist;
 		for (n = 1; n < nsearch; n++) {
 		    if (maxdist < list[n].dist)
-			maxdist = list[*max = n].dist;
+			maxdist = list[max = n].dist;
 		}
 	    }
 	}
@@ -492,12 +491,12 @@
 
 	    if (dist < maxdist) {
 		/* replace the largest dist */
-		list[*max].z = points[row][column][j].z;
-		list[*max].dist = dist;
-		maxdist = list[*max = 0].dist;
+		list[max].z = points[row][column][j].z;
+		list[max].dist = dist;
+		maxdist = list[max = 0].dist;
 		for (n = 1; n < nsearch; n++) {
 		    if (maxdist < list[n].dist)
-			maxdist = list[*max = n].dist;
+			maxdist = list[max = n].dist;
 		}
 	    }
 

Modified: grass/trunk/vector/v.surf.idw/proto.h
===================================================================
--- grass/trunk/vector/v.surf.idw/proto.h	2015-12-19 00:53:41 UTC (rev 67240)
+++ grass/trunk/vector/v.surf.idw/proto.h	2015-12-19 05:06:08 UTC (rev 67241)
@@ -2,5 +2,5 @@
 void read_sites(const char *, const char *, const char *, int);
 
 void newpoint(double, double, double, int);
-void calculate_distances(int, int, double, double, int *, int *);
+void calculate_distances(int, int, double, double, int *);
 void calculate_distances_noindex(double, double);



More information about the grass-commit mailing list