From 1b4a4c9f52808308a90225a079cfcb505f194d5f Mon Sep 17 00:00:00 2001 From: Torsten Dreyer Date: Sun, 12 Dec 2010 21:30:39 +0100 Subject: [PATCH] Metar fog/mist/haze: no hardcoded constants Move hardcoded constants to the property tree --- src/Environment/metarproperties.cxx | 37 ++++++++++++++++------------- 1 file changed, 21 insertions(+), 16 deletions(-) diff --git a/src/Environment/metarproperties.cxx b/src/Environment/metarproperties.cxx index ea605d73a..1876d3552 100644 --- a/src/Environment/metarproperties.cxx +++ b/src/Environment/metarproperties.cxx @@ -30,6 +30,7 @@ #include "atmosphere.hxx" #include #include +#include
using std::string; @@ -222,9 +223,9 @@ void MetarProperties::set_metar( const char * metar ) // if its fog(FG) (might be shallow(MI) or patches(BC)) or haze (HZ) or mist(BR) if( phenomenon == "FG" ) isFG = true; if( phenomenon == "HZ" ) isHZ = true; + if( phenomenon == "BR" ) isBR = true; if( description == "MI" ) isMI = true; if( description == "BC" ) isBC = true; - if( description == "BR" ) isBR = true; } } } @@ -238,35 +239,38 @@ void MetarProperties::set_metar( const char * metar ) const vector & metarClouds = m->getClouds(); unsigned layerOffset = 0; // Oh, this is ugly! bool setGroundCloudLayer = _rootNode->getBoolValue("set-ground-cloud-layer", false ); - if( setGroundCloudLayer ) { // create a cloud layer #0 starting at the ground if its fog, mist or haze // make sure layer actually starts at ground and set it's bottom at a constant // value below the station's elevation - const double LAYER_BOTTOM_BELOW_STATION_ELEVATION=200; + const double LAYER_BOTTOM_BELOW_STATION_ELEVATION = + fgGetDouble( "/environment/config/offset-from-station-elevation-ft", 200 ); SGMetarCloud::Coverage coverage = SGMetarCloud::COVERAGE_NIL; double thickness = 0; double alpha = 1.0; if( isFG ) { // fog - coverage = isBC ? SGMetarCloud::COVERAGE_SCATTERED : SGMetarCloud::COVERAGE_BROKEN; - thickness = isMI ? - 30 + LAYER_BOTTOM_BELOW_STATION_ELEVATION : // shallow fog, 10m/30ft - 500 + LAYER_BOTTOM_BELOW_STATION_ELEVATION; // fog, 150m/500ft - alpha = 1.0; + coverage = SGMetarCloud::getCoverage( isBC ? + fgGetString( "/environment/config/fog-bc-2dlayer-coverage", SGMetarCloud::COVERAGE_SCATTERED_STRING ) : + fgGetString( "/environment/config/fog-2dlayer-coverage", SGMetarCloud::COVERAGE_BROKEN_STRING ) + ); + thickness = isMI ? + fgGetDouble("/environment/config/fog-shallow-thickness-ft",30) + LAYER_BOTTOM_BELOW_STATION_ELEVATION : // shallow fog, 10m/30ft + fgGetDouble("/environment/config/fog-thickness-ft",500) + LAYER_BOTTOM_BELOW_STATION_ELEVATION; // fog, 150m/500ft + alpha = fgGetDouble("/environment/config/fog-alpha",0.0); } else if( isBR ) { // mist - coverage = SGMetarCloud::COVERAGE_OVERCAST; - thickness = 2000 + LAYER_BOTTOM_BELOW_STATION_ELEVATION; - alpha = 0.8; + coverage = SGMetarCloud::getCoverage(fgGetString("/environment/config/mist-2dlayer-coverage", SGMetarCloud::COVERAGE_OVERCAST_STRING)); + thickness = fgGetDouble("/environment/config/mist-thickness-ft",2000) + LAYER_BOTTOM_BELOW_STATION_ELEVATION; + alpha = fgGetDouble("/environment/config/mist-alpha",0.8); } else if( isHZ ) { // hase - coverage = SGMetarCloud::COVERAGE_OVERCAST; - thickness = 2000 + LAYER_BOTTOM_BELOW_STATION_ELEVATION; - alpha = 0.6; + coverage = SGMetarCloud::getCoverage(fgGetString("/environment/config/mist-2dlayer-coverage", SGMetarCloud::COVERAGE_OVERCAST_STRING)); + thickness = fgGetDouble("/environment/config/haze-thickness-ft",2000) + LAYER_BOTTOM_BELOW_STATION_ELEVATION; + alpha = fgGetDouble("/environment/config/haze-alpha",0.6); } - // fog is "overcast" by default of "broken" for patches of fog + if( coverage != SGMetarCloud::COVERAGE_NIL ) { SGPropertyNode_ptr layerNode = cloudsNode->getChild(LAYER, 0, true ); layerNode->setDoubleValue( "coverage-type", SGCloudLayer::getCoverageType(coverage_string[coverage]) ); @@ -275,7 +279,8 @@ void MetarProperties::set_metar( const char * metar ) layerNode->setDoubleValue( "thickness-ft", thickness ); layerNode->setDoubleValue( "visibility-m", _min_visibility ); layerNode->setDoubleValue( "alpha", alpha ); - _min_visibility = _max_visibility = 20000.0; // assume good visibility above the fog + _min_visibility = _max_visibility = + fgGetDouble("/environment/config/visibility-above-layer-m",20000.0); // assume good visibility above the fog layerOffset = 1; // shudder } } -- 2.39.5