[GRASS-SVN] r69959 - grass-addons/grass7/raster/r.resamp.tps

svn_grass at osgeo.org svn_grass at osgeo.org
Thu Dec 1 00:07:42 PST 2016


Author: mmetz
Date: 2016-12-01 00:07:42 -0800 (Thu, 01 Dec 2016)
New Revision: 69959

Modified:
   grass-addons/grass7/raster/r.resamp.tps/pavl.c
   grass-addons/grass7/raster/r.resamp.tps/tps.c
Log:
r.resamp.tps: count weighted averages

Modified: grass-addons/grass7/raster/r.resamp.tps/pavl.c
===================================================================
--- grass-addons/grass7/raster/r.resamp.tps/pavl.c	2016-11-30 21:54:47 UTC (rev 69958)
+++ grass-addons/grass7/raster/r.resamp.tps/pavl.c	2016-12-01 08:07:42 UTC (rev 69959)
@@ -264,20 +264,20 @@
 
     assert(tree != NULL && item != NULL);
 
-    if (tree->pavl_root == NULL)
-	return NULL;
-
     p = tree->pavl_root;
     dir = 0;
-    cmp = tree->pavl_compare(item, p->pavl_data);
-    while (cmp != 0) {
+    while (p != NULL) {
+	cmp = tree->pavl_compare(item, p->pavl_data);
+
+	if (cmp == 0)
+	    break;
+
 	dir = cmp > 0;
 	p = p->pavl_link[dir];
-	if (p == NULL)
-	    return NULL;
+    }
+    if (p == NULL)
+	return NULL;
 
-	cmp = tree->pavl_compare(item, p->pavl_data);
-    }
     item = p->pavl_data;
 
     q = p->pavl_parent;

Modified: grass-addons/grass7/raster/r.resamp.tps/tps.c
===================================================================
--- grass-addons/grass7/raster/r.resamp.tps/tps.c	2016-11-30 21:54:47 UTC (rev 69958)
+++ grass-addons/grass7/raster/r.resamp.tps/tps.c	2016-12-01 08:07:42 UTC (rev 69959)
@@ -977,7 +977,7 @@
     CELL *maskbuf;
     int solved;
     int pfound;
-    double distmax, mindist;
+    double distmax;
     int mask_fd;
     FLAG *mask_flag, *pnt_flag;
     struct tps_out tps_out;
@@ -987,6 +987,7 @@
     int rmin, rmax, cmin, cmax, rminp, rmaxp, cminp, cmaxp;
     int irow, irow1, irow2, icol, icol1, icol2;
     int wsize;
+    unsigned int wacnt;
     double dxyw;
 #ifndef USE_RC
     double i_n, i_e;
@@ -1088,6 +1089,7 @@
 
     wmin = 10;
     wmax = 0;
+    wacnt = 0;
 
     if (overlap > 1.0)
 	overlap = 1.0;
@@ -1168,7 +1170,6 @@
 		    i_n = dst->north - (row + 0.5) * dst->ns_res;
 		    i_e = dst->west + (col + 0.5) * dst->ew_res;
 
-		    mindist = -1;
 		    result = 0;
 		    wsum = 0;
 		    maxweight = 0;
@@ -1189,7 +1190,7 @@
 			weight = exp(-dist2 * 4.0);
 			
 			/* weight for tps */
-			if (mindist > dist2 || mindist > 0)
+			if (maxweight < weight)
 			    maxweight = weight;
 
 			wsum += weight;
@@ -1205,6 +1206,8 @@
 		    tps_out.val += result * weight;
 		    tps_out.wsum += weight;
 		    Segment_put(out_seg, (void *)&tps_out, row, col);
+
+		    wacnt++;
 		}
 		continue;
 	    }
@@ -1340,6 +1343,7 @@
 
     G_debug(1, "wmin: %g", wmin);
     G_debug(1, "wmax: %g", wmax);
+    G_debug(1, "wacnt: %u", wacnt);
 
     flag_destroy(pnt_flag);
 



More information about the grass-commit mailing list