#include "fgmetar.hxx"
#include "environment.hxx"
#include "atmosphere.hxx"
+#include "metarairportfilter.hxx"
#include <simgear/scene/sky/cloud.hxx>
#include <simgear/structure/exception.hxx>
#include <Main/fg_props.hxx>
{
// 1. check the id given in the metar
FGAirport* a = FGAirport::findByIdent(m->getId());
-/*
+
// 2. if unknown, find closest airport with metar to current position
if( a == NULL ) {
- SGGeod pos = SGGeod::fromDeg(_longitude_n->getDoubleValue(), _latitude_n->getDoubleValue());
- a = FGAirport::findClosest(pos, 10000.0, &_airportWithMetarFilter);
+ SGGeod pos = SGGeod::fromDeg(
+ fgGetDouble( "/position/longitude-deg", 0.0 ),
+ fgGetDouble( "/position/latitude-deg", 0.0 ) );
+ a = FGAirport::findClosest(pos, 10000.0, MetarAirportFilter::instance() );
}
-*/
+
// 3. otherwise use ground elevation
if( a != NULL ) {
_station_elevation = a->getElevation();
_station_longitude = towerPosition.getLongitudeDeg();
_station_id = a->ident();
} else {
- _station_elevation = 0.0;
- _station_latitude = 0.0;
- _station_longitude = 0.0;
+ _station_elevation = fgGetDouble("/position/ground-elev-m", 0.0 ) * SG_METER_TO_FEET;
+ _station_latitude = fgGetDouble( "/position/latitude-deg", 0.0 );
+ _station_longitude = fgGetDouble( "/position/longitude-deg", 0.0 );
_station_id = "XXXX";
-// station_elevation_ft = _ground_elevation_n->getDoubleValue() * SG_METER_TO_FEET;
-// _station_id = m->getId();
}
}
SGPropertyNode_ptr cloudsNode = _rootNode->getNode("clouds", true );
const vector<SGMetarCloud> & metarClouds = m->getClouds();
unsigned layerOffset = 0; // Oh, this is ugly!
- bool setGroundCloudLayer = _rootNode->getBoolValue("set-ground-cloud-layer", false );
+
+ // fog/mist/haze cloud layer does not work with 3d clouds yet :-(
+ bool setGroundCloudLayer = _rootNode->getBoolValue("set-ground-cloud-layer", false ) &&
+ false == (fgGetBool("/sim/rendering/shader-effects", false ) &&
+ fgGetBool("/sim/rendering/clouds3d-enable", false ) );
+
if( setGroundCloudLayer ) {
// create a cloud layer #0 starting at the ground if its fog, mist or haze
coverage = SGMetarCloud::getCoverage(fgGetString("/environment/params/fog-mist-haze-layer/mist-2dlayer-coverage", SGMetarCloud::COVERAGE_OVERCAST_STRING));
thickness = fgGetDouble("/environment/params/fog-mist-haze-layer/mist-thickness-ft",2000) - LAYER_BOTTOM_STATION_OFFSET;
alpha = fgGetDouble("/environment/params/fog-mist-haze-layer/mist-2dlayer-alpha",0.8);
- } else if( isHZ ) { // hase
+ } else if( isHZ ) { // haze
coverage = SGMetarCloud::getCoverage(fgGetString("/environment/params/fog-mist-haze-layer/mist-2dlayer-coverage", SGMetarCloud::COVERAGE_OVERCAST_STRING));
thickness = fgGetDouble("/environment/params/fog-mist-haze-layer/haze-thickness-ft",2000) - LAYER_BOTTOM_STATION_OFFSET;
alpha = fgGetDouble("/environment/params/fog-mist-haze-layer/haze-2dlayer-alpha",0.6);
}
if( coverage != SGMetarCloud::COVERAGE_NIL ) {
+
+ // if there is a layer above the fog, limit the top to one foot below that layer's bottom
+ if( metarClouds[0].getCoverage() != SGMetarCloud::COVERAGE_CLEAR )
+ thickness = metarClouds[0].getAltitude_ft() - LAYER_BOTTOM_STATION_OFFSET - 1;
+
SGPropertyNode_ptr layerNode = cloudsNode->getChild(LAYER, 0, true );
layerNode->setDoubleValue( "coverage-type", SGCloudLayer::getCoverageType(coverage_string[coverage]) );
layerNode->setStringValue( "coverage", coverage_string[coverage] );