[GRASS-SVN] r46201 - grass-addons/raster/r.viewshed

svn_grass at osgeo.org svn_grass at osgeo.org
Fri May 6 05:52:44 EDT 2011


Author: mmetz
Date: 2011-05-06 02:52:44 -0700 (Fri, 06 May 2011)
New Revision: 46201

Modified:
   grass-addons/raster/r.viewshed/grass.cc
Log:
set invisible cells to NULL

Modified: grass-addons/raster/r.viewshed/grass.cc
===================================================================
--- grass-addons/raster/r.viewshed/grass.cc	2011-05-06 08:26:38 UTC (rev 46200)
+++ grass-addons/raster/r.viewshed/grass.cc	2011-05-06 09:52:44 UTC (rev 46201)
@@ -1,3 +1,4 @@
+
 /****************************************************************************
  *
  * MODULE:       r.viewshed
@@ -645,17 +646,21 @@
     for (i = 0; i < G_window_rows(); i++) {
 	for (j = 0; j < G_window_cols(); 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_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;
+		}
 	    }
+	    else
+		writeNodataValue(outrast, j, type);
 	}			/* for j */
 	G_put_raster_row(outfd, outrast, type);
     }				/* for i */
@@ -756,8 +761,12 @@
 		/* elevation cannot be null */
 		assert(!isNull);
 		/* write INVISIBLE */
+		/*
 		viewshed_value = INVISIBLE;
 		writeValue(visrast, j, viewshed_value, elev_data_type);
+		*/
+		/* write  NODATA */
+		writeNodataValue(visrast, j, elev_data_type);
 	    }
 	    else {
 		/* nodata */
@@ -864,7 +873,10 @@
 	    if (curResult->row == i && curResult->col == j) {
 		/*cell is recodred in the visibility stream: it must be
 		   either visible, or NODATA  */
-		writeValue(visrast, j, fun(curResult->angle), type);
+		if (is_visible(curResult->angle))
+		    writeValue(visrast, j, fun(curResult->angle), type);
+		else
+		    writeNodataValue(visrast, j, type);
 
 		/*read next element of stream */
 		if (counter < streamLen) {
@@ -874,8 +886,8 @@
 		}
 	    }
 	    else {
-		/*  this cell is not in stream, so it is  invisible */
-		writeValue(visrast, j, fun(INVISIBLE), type);
+		/*  this cell is not in stream, so it is invisible */
+		writeNodataValue(visrast, j, type);
 	    }
 	}			/* for j */
 
@@ -1000,7 +1012,7 @@
 	    }
 	    else {
 		/*  this cell is not in stream, so it is  invisible */
-		writeValue(visrast, j, INVISIBLE, elev_data_type);
+		    writeNodataValue(visrast, j, elev_data_type);
 	    }
 	}			/* for j */
 



More information about the grass-commit mailing list