[GRASS-SVN] r67941 - grass-addons/grass7/raster/r.soils.texture

svn_grass at osgeo.org svn_grass at osgeo.org
Wed Feb 24 11:28:23 PST 2016


Author: gianluca
Date: 2016-02-24 11:28:23 -0800 (Wed, 24 Feb 2016)
New Revision: 67941

Modified:
   grass-addons/grass7/raster/r.soils.texture/main.c
Log:
bug removed in nrow/ncol (#2927: r.soils.texture gives broken results)

Modified: grass-addons/grass7/raster/r.soils.texture/main.c
===================================================================
--- grass-addons/grass7/raster/r.soils.texture/main.c	2016-02-24 15:26:55 UTC (rev 67940)
+++ grass-addons/grass7/raster/r.soils.texture/main.c	2016-02-24 19:28:23 UTC (rev 67941)
@@ -180,7 +180,7 @@
 
     /* Allocate output buffer, use input Sand map data_type */
     nrows = Rast_window_rows();
-    ncols = Rast_window_rows();
+    ncols = Rast_window_cols();
     outrast = Rast_allocate_buf(data_type_Sand);
     data_type = data_type_Sand;
 
@@ -194,39 +194,38 @@
 
     /* for each row */
     for (row = 0; row < nrows; row++) {
-	if (verbose)
-	    G_percent(row, nrows, 2);
+		G_percent(row, nrows, 2);
 
-	/* read input Sand map */
-	Rast_get_row(infdSand, inrastSand, row, data_type_Sand);
-	/* read input Sand map */
-	Rast_get_row(infdClay, inrastClay, row, data_type_Sand);
+		/* read input Sand map */
+		Rast_get_row(infdSand, inrastSand, row, data_type_Sand);
+		/* read input Sand map */
+		Rast_get_row(infdClay, inrastClay, row, data_type_Sand);
 
 
 	/* process the data */
-	for (col = 0; col < ncols; col++) {
-	    /* use different function for each data type */
-	    switch (data_type) {
-	    case CELL_TYPE:
-		c_sand = ((CELL *) inrastSand)[col];
-		c_clay = ((CELL *) inrastClay)[col];
-		c = c_calc(c_sand, c_clay, punt_lista, &polygons);	/* calculate */
-		((CELL *) outrast)[col] = c;
-		break;
-	    case FCELL_TYPE:
-		f_sand = ((FCELL *) inrastSand)[col];
-		f_clay = ((FCELL *) inrastClay)[col];
-		f = f_calc(f_sand, f_clay, punt_lista, &polygons);	/* calculate */
-		((FCELL *) outrast)[col] = f;
-		break;
-	    case DCELL_TYPE:
-		d_sand = ((DCELL *) inrastSand)[col];
-		d_clay = ((DCELL *) inrastClay)[col];
-		d = d_calc(d_sand, d_clay, punt_lista, &polygons);	/* calculate */
-		((DCELL *) outrast)[col] = d;
-		break;
-	    }
-	}
+		for (col = 0; col < ncols; col++) {
+			/* use different function for each data type */
+			switch (data_type) {
+			case CELL_TYPE:
+			c_sand = ((CELL *) inrastSand)[col];
+			c_clay = ((CELL *) inrastClay)[col];
+			c = c_calc(c_sand, c_clay, punt_lista, &polygons);	/* calculate */
+			((CELL *) outrast)[col] = c;
+			break;
+			case FCELL_TYPE:
+			f_sand = ((FCELL *) inrastSand)[col];
+			f_clay = ((FCELL *) inrastClay)[col];
+			f = f_calc(f_sand, f_clay, punt_lista, &polygons);	/* calculate */
+			((FCELL *) outrast)[col] = f;
+			break;
+			case DCELL_TYPE:
+			d_sand = ((DCELL *) inrastSand)[col];
+			d_clay = ((DCELL *) inrastClay)[col];
+			d = d_calc(d_sand, d_clay, punt_lista, &polygons);	/* calculate */
+			((DCELL *) outrast)[col] = d;
+			break;
+			}
+		}
 
 	/* write raster row to output raster file */
 	Rast_put_row(outfd, outrast, data_type);
@@ -341,11 +340,9 @@
     for (i = 0, j = numVert - 1; i < numVert; j = i++) {
 	if ((((yClay[i] <= ClayVal) && (ClayVal < yClay[j])) ||
 	     ((yClay[j] <= ClayVal) && (ClayVal < yClay[i]))) &&
-	    (SandVal <
-	     (xSand[j] - xSand[i]) * (ClayVal - yClay[i]) / (yClay[j] -
-							     yClay[i]) +
-	     xSand[i]))
-	    textureVER = !textureVER;
+	    (SandVal <= (xSand[j] - xSand[i]) * (ClayVal - yClay[i]) / (yClay[j] -
+		yClay[i]) + xSand[i]))
+	textureVER = !textureVER;
     }
 
     if (textureVER == 1) {
@@ -356,7 +353,6 @@
     }
     return textureVER;
 
-
 }
 
 
@@ -406,3 +402,4 @@
     fclose(fp_dat);
     /*return (0); */
 }
+



More information about the grass-commit mailing list