[GRASS-SVN] r71686 - grass/branches/releasebranch_7_2/raster/r.viewshed
svn_grass at osgeo.org
svn_grass at osgeo.org
Sun Nov 12 04:07:58 PST 2017
Author: mmetz
Date: 2017-11-12 04:07:58 -0800 (Sun, 12 Nov 2017)
New Revision: 71686
Modified:
grass/branches/releasebranch_7_2/raster/r.viewshed/grass.cpp
grass/branches/releasebranch_7_2/raster/r.viewshed/grass.h
grass/branches/releasebranch_7_2/raster/r.viewshed/viewshed.cpp
grass/branches/releasebranch_7_2/raster/r.viewshed/visibility.cpp
Log:
r.viewshed: fix binary output (backport trunk r71681, #1788)
Modified: grass/branches/releasebranch_7_2/raster/r.viewshed/grass.cpp
===================================================================
--- grass/branches/releasebranch_7_2/raster/r.viewshed/grass.cpp 2017-11-12 12:03:40 UTC (rev 71685)
+++ grass/branches/releasebranch_7_2/raster/r.viewshed/grass.cpp 2017-11-12 12:07:58 UTC (rev 71686)
@@ -782,7 +782,6 @@
/* helper function to deal with GRASS writing to a row buffer */
void writeValue(void *bufrast, int j, double x, RASTER_MAP_TYPE data_type)
{
-
switch (data_type) {
case CELL_TYPE:
((CELL *) bufrast)[j] = (CELL) x;
@@ -824,7 +823,8 @@
void
save_io_visibilitygrid_to_GRASS(IOVisibilityGrid * visgrid,
char *fname, RASTER_MAP_TYPE type,
- float (*fun) (float))
+ float (*fun) (float),
+ OutputMode mode)
{
G_message(_("Saving grid to <%s>"), fname);
@@ -878,7 +878,10 @@
}
else {
/* this cell is not in stream, so it is invisible */
- writeNodataValue(visrast, j, type);
+ if (mode == OUTPUT_BOOL)
+ writeValue(visrast, j, BOOL_INVISIBLE, type);
+ else if (mode == OUTPUT_ANGLE)
+ writeNodataValue(visrast, j, type);
}
} /* for j */
Modified: grass/branches/releasebranch_7_2/raster/r.viewshed/grass.h
===================================================================
--- grass/branches/releasebranch_7_2/raster/r.viewshed/grass.h 2017-11-12 12:03:40 UTC (rev 71685)
+++ grass/branches/releasebranch_7_2/raster/r.viewshed/grass.h 2017-11-12 12:07:58 UTC (rev 71686)
@@ -136,7 +136,8 @@
void
save_io_visibilitygrid_to_GRASS(IOVisibilityGrid * visgrid,
char *outfname, RASTER_MAP_TYPE type,
- float (*fun) (float));
+ float (*fun) (float),
+ OutputMode mode);
Modified: grass/branches/releasebranch_7_2/raster/r.viewshed/viewshed.cpp
===================================================================
--- grass/branches/releasebranch_7_2/raster/r.viewshed/viewshed.cpp 2017-11-12 12:03:40 UTC (rev 71685)
+++ grass/branches/releasebranch_7_2/raster/r.viewshed/viewshed.cpp 2017-11-12 12:07:58 UTC (rev 71686)
@@ -151,8 +151,10 @@
}
else {
/* this is the max value of size_t */
- long long maxsizet = ((long long)1 << (sizeof(size_t) * 8)) - 1;
+ long long maxsizet = ((long long)1 << (sizeof(size_t) * 8 - 1)) - 1;
+ maxsizet += ((long long)1 << (sizeof(size_t) * 8 - 1));
+
G_debug(1, "max size_t is %lld", maxsizet);
/* checking whether allocating totalsize causes an overflow */
Modified: grass/branches/releasebranch_7_2/raster/r.viewshed/visibility.cpp
===================================================================
--- grass/branches/releasebranch_7_2/raster/r.viewshed/visibility.cpp 2017-11-12 12:03:40 UTC (rev 71685)
+++ grass/branches/releasebranch_7_2/raster/r.viewshed/visibility.cpp 2017-11-12 12:07:58 UTC (rev 71686)
@@ -401,11 +401,13 @@
if (viewOptions.outputMode == OUTPUT_BOOL)
save_io_visibilitygrid_to_GRASS(visgrid, viewOptions.outputfname,
- CELL_TYPE, booleanVisibilityOutput);
+ CELL_TYPE, booleanVisibilityOutput,
+ OUTPUT_BOOL);
else if (viewOptions.outputMode == OUTPUT_ANGLE)
save_io_visibilitygrid_to_GRASS(visgrid, viewOptions.outputfname,
- FCELL_TYPE, angleVisibilityOutput);
+ FCELL_TYPE, angleVisibilityOutput,
+ OUTPUT_ANGLE);
else
/* elevation output */
save_io_vis_and_elev_to_GRASS(visgrid, viewOptions.inputfname,
More information about the grass-commit
mailing list