[GRASS-SVN] r62467 - grass/trunk/raster/r.viewshed

svn_grass at osgeo.org svn_grass at osgeo.org
Tue Oct 28 17:42:59 PDT 2014


Author: annakrat
Date: 2014-10-28 17:42:59 -0700 (Tue, 28 Oct 2014)
New Revision: 62467

Modified:
   grass/trunk/raster/r.viewshed/grass.cpp
   grass/trunk/raster/r.viewshed/grass.h
   grass/trunk/raster/r.viewshed/visibility.cpp
Log:
r.viewshed: fix #1788 (r.viewshed binary flag (-b) not working correctly)

Modified: grass/trunk/raster/r.viewshed/grass.cpp
===================================================================
--- grass/trunk/raster/r.viewshed/grass.cpp	2014-10-29 00:27:09 UTC (rev 62466)
+++ grass/trunk/raster/r.viewshed/grass.cpp	2014-10-29 00:42:59 UTC (rev 62467)
@@ -616,7 +616,7 @@
    in row-column order and writes fun(x) to file. */
 void
 save_grid_to_GRASS(Grid * grid, char *filename, RASTER_MAP_TYPE type,
-		   float (*fun) (float))
+                   OutputMode mode)
 {
 
     G_important_message(_("Writing output raster map..."));
@@ -638,22 +638,20 @@
     for (i = 0; i < Rast_window_rows(); i++) {
         G_percent(i, Rast_window_rows(), 5);
 	for (j = 0; j < Rast_window_cols(); j++) {
-
-	    if (is_visible(grid->grid_data[i][j])) {
-		switch (type) {
-		case CELL_TYPE:
-		    ((CELL *) outrast)[j] = (CELL) fun(grid->grid_data[i][j]);
-		    break;
-		case FCELL_TYPE:
-		    ((FCELL *) outrast)[j] = (FCELL) fun(grid->grid_data[i][j]);
-		    break;
-		case DCELL_TYPE:
-		    ((DCELL *) outrast)[j] = (DCELL) fun(grid->grid_data[i][j]);
-		    break;
+	    if (is_invisible_nodata(grid->grid_data[i][j])) {
+		writeNodataValue(outrast, j, type);
+	    }
+	    else if (mode == OUTPUT_BOOL) {
+		((CELL *) outrast)[j] = (CELL) booleanVisibilityOutput(grid->grid_data[i][j]);
+	    }
+	    else if (mode == OUTPUT_ANGLE) {
+		if (is_visible(grid->grid_data[i][j])) {
+		    ((FCELL *) outrast)[j] = (FCELL) angleVisibilityOutput(grid->grid_data[i][j]);
 		}
+		else {
+		    writeNodataValue(outrast, j, FCELL_TYPE);
+		}
 	    }
-	    else
-		writeNodataValue(outrast, j, type);
 	}			/* for j */
 	Rast_put_row(outfd, outrast, type);
     }				/* for i */

Modified: grass/trunk/raster/r.viewshed/grass.h
===================================================================
--- grass/trunk/raster/r.viewshed/grass.h	2014-10-29 00:27:09 UTC (rev 62466)
+++ grass/trunk/raster/r.viewshed/grass.h	2014-10-29 00:42:59 UTC (rev 62467)
@@ -114,7 +114,7 @@
    in row-column order and writes fun(x) to file. */
 void
 save_grid_to_GRASS(Grid * grid, char *filename, RASTER_MAP_TYPE type,
-		   float (*fun) (float));
+		   OutputMode mode);
 
 
 /* ************************************************************ */

Modified: grass/trunk/raster/r.viewshed/visibility.cpp
===================================================================
--- grass/trunk/raster/r.viewshed/visibility.cpp	2014-10-29 00:27:09 UTC (rev 62466)
+++ grass/trunk/raster/r.viewshed/visibility.cpp	2014-10-29 00:42:59 UTC (rev 62467)
@@ -261,10 +261,10 @@
 
     if (viewOptions.outputMode == OUTPUT_BOOL)
 	save_grid_to_GRASS(visgrid->grid, viewOptions.outputfname, CELL_TYPE,
-			   booleanVisibilityOutput);
+			   OUTPUT_BOOL);
     else if (viewOptions.outputMode == OUTPUT_ANGLE)
 	save_grid_to_GRASS(visgrid->grid, viewOptions.outputfname, FCELL_TYPE,
-			   angleVisibilityOutput);
+			   OUTPUT_ANGLE);
     else
 	/* elevation  output */
 	save_vis_elev_to_GRASS(visgrid->grid, viewOptions.inputfname,



More information about the grass-commit mailing list