Explorar el Código

reverting last fix and using Paul's static var solution

git-svn-id: https://svn.osgeo.org/grass/grass/trunk@67241 15284696-431f-4ddb-bdfa-cd5b030d7da7
Moritz Lennert hace 9 años
padre
commit
09d5511a80
Se han modificado 2 ficheros con 14 adiciones y 15 borrados
  1. 13 14
      vector/v.surf.idw/main.c
  2. 1 1
      vector/v.surf.idw/proto.h

+ 13 - 14
vector/v.surf.idw/main.c

@@ -62,7 +62,6 @@ int main(int argc, char *argv[])
     double dist;
     double dist;
     double sum1, sum2, interp_value;
     double sum1, sum2, interp_value;
     int n;
     int n;
-    int max;
     double p;
     double p;
     struct
     struct
     {
     {
@@ -299,7 +298,6 @@ int main(int argc, char *argv[])
 		else {
 		else {
 		    pointsfound = 0;
 		    pointsfound = 0;
 		    i = 0;
 		    i = 0;
-		    max = 0;
 
 
 		    if (searchallpoints == 1) {
 		    if (searchallpoints == 1) {
 			/* If there aren't many sites just check them all to find
 			/* If there aren't many sites just check them all to find
@@ -307,7 +305,7 @@ int main(int argc, char *argv[])
 			for (n = 0; n < ncells; n++)
 			for (n = 0; n < ncells; n++)
 			    calculate_distances(shortlistrows[n],
 			    calculate_distances(shortlistrows[n],
 						shortlistcolumns[n], north,
 						shortlistcolumns[n], north,
-						east, &pointsfound, &max);
+						east, &pointsfound);
 		    }
 		    }
 		    else {
 		    else {
 			radius = 0;
 			radius = 0;
@@ -328,7 +326,7 @@ int main(int argc, char *argv[])
 					col + search_list[radius]->column;
 					col + search_list[radius]->column;
 				    calculate_distances(searchrow,
 				    calculate_distances(searchrow,
 							searchcolumn, north,
 							searchcolumn, north,
-							east, &pointsfound, &max);
+							east, &pointsfound);
 				}
 				}
 
 
 				/* Only if at least one offset is not 0 */
 				/* Only if at least one offset is not 0 */
@@ -342,7 +340,7 @@ int main(int argc, char *argv[])
 					col - search_list[radius]->column;
 					col - search_list[radius]->column;
 				    calculate_distances(searchrow,
 				    calculate_distances(searchrow,
 							searchcolumn, north,
 							searchcolumn, north,
-							east, &pointsfound, &max);
+							east, &pointsfound);
 				}
 				}
 
 
 				/* Only if both offsets are not 0 */
 				/* Only if both offsets are not 0 */
@@ -359,7 +357,7 @@ int main(int argc, char *argv[])
 					calculate_distances(searchrow,
 					calculate_distances(searchrow,
 							    searchcolumn,
 							    searchcolumn,
 							    north, east,
 							    north, east,
-							    &pointsfound, &max);
+							    &pointsfound);
 				    }
 				    }
 				    if (row >= search_list[radius]->row &&
 				    if (row >= search_list[radius]->row &&
 					col <
 					col <
@@ -372,7 +370,7 @@ int main(int argc, char *argv[])
 					calculate_distances(searchrow,
 					calculate_distances(searchrow,
 							    searchcolumn,
 							    searchcolumn,
 							    north, east,
 							    north, east,
-							    &pointsfound, &max);
+							    &pointsfound);
 				    }
 				    }
 				}
 				}
 
 
@@ -458,9 +456,10 @@ void newpoint(double z, double east, double north, int noindex)
 }
 }
 
 
 void calculate_distances(int row, int column, double north,
 void calculate_distances(int row, int column, double north,
-			 double east, int *pointsfound, int *max)
+			 double east, int *pointsfound)
 {
 {
     int j, n;
     int j, n;
+    static int max;
     double dx, dy, dist;
     double dx, dy, dist;
     static double maxdist;
     static double maxdist;
 
 
@@ -476,10 +475,10 @@ void calculate_distances(int row, int column, double north,
 
 
 	    /* find the maximum distance */
 	    /* find the maximum distance */
 	    if (i == nsearch) {
 	    if (i == nsearch) {
-		maxdist = list[*max = 0].dist;
+		maxdist = list[max = 0].dist;
 		for (n = 1; n < nsearch; n++) {
 		for (n = 1; n < nsearch; n++) {
 		    if (maxdist < list[n].dist)
 		    if (maxdist < list[n].dist)
-			maxdist = list[*max = n].dist;
+			maxdist = list[max = n].dist;
 		}
 		}
 	    }
 	    }
 	}
 	}
@@ -492,12 +491,12 @@ void calculate_distances(int row, int column, double north,
 
 
 	    if (dist < maxdist) {
 	    if (dist < maxdist) {
 		/* replace the largest dist */
 		/* 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++) {
 		for (n = 1; n < nsearch; n++) {
 		    if (maxdist < list[n].dist)
 		    if (maxdist < list[n].dist)
-			maxdist = list[*max = n].dist;
+			maxdist = list[max = n].dist;
 		}
 		}
 	    }
 	    }
 
 

+ 1 - 1
vector/v.surf.idw/proto.h

@@ -2,5 +2,5 @@
 void read_sites(const char *, const char *, const char *, int);
 void read_sites(const char *, const char *, const char *, int);
 
 
 void newpoint(double, double, double, 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);
 void calculate_distances_noindex(double, double);