[GRASS-SVN] r46424 - grass-addons/raster/r.viewshed
svn_grass at osgeo.org
svn_grass at osgeo.org
Thu May 26 09:06:36 EDT 2011
Author: hamish
Date: 2011-05-26 06:06:36 -0700 (Thu, 26 May 2011)
New Revision: 46424
Modified:
grass-addons/raster/r.viewshed/grass.cc
grass-addons/raster/r.viewshed/main.cc
grass-addons/raster/r.viewshed/visibility.h
Log:
don't hardcode refection coeff
Modified: grass-addons/raster/r.viewshed/grass.cc
===================================================================
--- grass-addons/raster/r.viewshed/grass.cc 2011-05-26 08:30:49 UTC (rev 46423)
+++ grass-addons/raster/r.viewshed/grass.cc 2011-05-26 13:06:36 UTC (rev 46424)
@@ -81,29 +81,11 @@
if (!viewOptions.doRefr)
return h - adjustment;
- /* in future we should calculate this based on the physics, for now we
- just fudge by the 1/7th approximation.
-
- ?? See ??
-
- @article{yoeli1985making,
- title={The making of intervisibility maps with computer and plotter},
- author={Yoeli, Pinhas},
- journal={Cartographica: The International Journal for Geographic Information and Geovisualization},
- volume={22},
- number={3},
- pages={88--103},
- year={1985},
- publisher={UT Press}
- }
-
- */
- return h - (adjustment * 6.0/7.0);
+ return h - (adjustment * (1.0 - viewOptions.refr_coef));
}
-
/* ************************************************************ */
/*return a GridHeader that has all the relevant data filled in */
GridHeader *read_header(char *rastName, Cell_head * region)
Modified: grass-addons/raster/r.viewshed/main.cc
===================================================================
--- grass-addons/raster/r.viewshed/main.cc 2011-05-26 08:30:49 UTC (rev 46423)
+++ grass-addons/raster/r.viewshed/main.cc 2011-05-26 13:06:36 UTC (rev 46424)
@@ -146,8 +146,9 @@
viewOptions.obsElev = DEFAULT_OBS_ELEVATION;
viewOptions.maxDist = INFINITY_DISTANCE;
viewOptions.outputMode = OUTPUT_ANGLE;
- viewOptions.doCurv = 0;
- viewOptions.doRefr = 0;
+ viewOptions.doCurv = FALSE;
+ viewOptions.doRefr = FALSE;
+ viewOptions.refr_coef = 1.0/7.0;
parse_args(argc, argv, &vpRow, &vpCol, &viewOptions, &memSizeBytes,
®ion);
@@ -531,6 +532,33 @@
maxDistOpt->answer = infdist;
maxDistOpt->guisection = _("Input_options");
+ /* atmospheric refraction coeff. 1/7 for visual, 0.325 for radio waves, ... */
+ /* in future we might calculate this based on the physics, for now we
+ just fudge by the 1/7th approximation.
+
+ ?? See ??
+
+ @article{yoeli1985making,
+ title={The making of intervisibility maps with computer and plotter},
+ author={Yoeli, Pinhas},
+ journal={Cartographica: The International Journal for Geographic Information and Geovisualization},
+ volume={22},
+ number={3},
+ pages={88--103},
+ year={1985},
+ publisher={UT Press}
+ }
+ */
+ struct Option *refrCoeffOpt;
+
+ refrCoeffOpt = G_define_option();
+ refrCoeffOpt->key = "refraction_coeff";
+ refrCoeffOpt->description = _("Refraction coefficient");
+ refrCoeffOpt->type = TYPE_DOUBLE;
+ refrCoeffOpt->required = NO;
+ refrCoeffOpt->answer = "0.14286";
+ refrCoeffOpt->options = "0.0-1.0";
+
/* memory size */
struct Option *memAmountOpt;
@@ -579,11 +607,11 @@
viewOptions->doCurv = curvature->answer;
viewOptions->doRefr = refractionFlag->answer;
-
if (refractionFlag->answer && !curvature->answer)
G_fatal_error(_("Atmospheric refraction is only calculated with "
"respect to the curvature of the Earth. "
"Enable the -c flag as well."));
+ viewOptions->refr_coef = atof(refrCoeffOpt->answer);
if (booleanOutput->answer)
viewOptions->outputMode = OUTPUT_BOOL;
Modified: grass-addons/raster/r.viewshed/visibility.h
===================================================================
--- grass-addons/raster/r.viewshed/visibility.h 2011-05-26 08:30:49 UTC (rev 46423)
+++ grass-addons/raster/r.viewshed/visibility.h 2011-05-26 13:06:36 UTC (rev 46424)
@@ -122,6 +122,7 @@
when calculating. Only implemented for GRASS version. */
int doRefr;
+ double refr_coef;
/*determines if atmospheric refraction should be considered
when calculating. Only implemented for GRASS version. */
More information about the grass-commit
mailing list