2 Provide Data for the ATIS Encoder from metarproperties
3 Copyright (C) 2014 Torsten Dreyer
5 This program is free software; you can redistribute it and/or
6 modify it under the terms of the GNU General Public License
7 as published by the Free Software Foundation; either version 2
8 of the License, or (at your option) any later version.
10 This program is distributed in the hope that it will be useful,
11 but WITHOUT ANY WARRANTY; without even the implied warranty of
12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 GNU General Public License for more details.
15 You should have received a copy of the GNU General Public License
16 along with this program; if not, write to the Free Software
17 Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
20 #include "MetarPropertiesATISInformationProvider.hxx"
21 #include <Main/globals.hxx>
22 #include <simgear/constants.h>
26 MetarPropertiesATISInformationProvider::MetarPropertiesATISInformationProvider( SGPropertyNode_ptr metar ) :
31 MetarPropertiesATISInformationProvider::~MetarPropertiesATISInformationProvider()
35 bool MetarPropertiesATISInformationProvider::isValid()
37 return _metar->getBoolValue( "valid", false );
40 string MetarPropertiesATISInformationProvider::airportId()
42 return _metar->getStringValue( "station-id", "xxxx" );
45 long MetarPropertiesATISInformationProvider::getTime()
47 return makeAtisTime( 0,
48 _metar->getIntValue( "hour" ) % 24,
49 _metar->getIntValue( "minute" ) % 60 );
52 int MetarPropertiesATISInformationProvider::getWindDeg()
54 return _metar->getIntValue( "base-wind-dir-deg" );
57 int MetarPropertiesATISInformationProvider::getWindMinDeg()
59 return _metar->getIntValue( "base-wind-range-from" );
61 int MetarPropertiesATISInformationProvider::getWindMaxDeg()
63 return _metar->getIntValue( "base-wind-range-to" );
65 int MetarPropertiesATISInformationProvider::getWindSpeedKt()
67 return _metar->getIntValue( "base-wind-speed-kt" );
70 int MetarPropertiesATISInformationProvider::getGustsKt()
72 return _metar->getIntValue( "gust-wind-speed-kt" );
75 int MetarPropertiesATISInformationProvider::getQnh()
77 return _metar->getDoubleValue("pressure-inhg") * SG_INHG_TO_PA / 100.0;
80 double MetarPropertiesATISInformationProvider::getQnhInHg()
82 return _metar->getDoubleValue("pressure-inhg");
85 bool MetarPropertiesATISInformationProvider::isCavok()
87 return _metar->getBoolValue( "cavok" );
90 int MetarPropertiesATISInformationProvider::getVisibilityMeters()
92 return _metar->getIntValue( "min-visibility-m" );
95 string MetarPropertiesATISInformationProvider::getPhenomena()
97 return _metar->getStringValue( "decoded" );
100 ATISInformationProvider::CloudEntries MetarPropertiesATISInformationProvider::getClouds()
104 using simgear::PropertyList;
105 PropertyList layers = _metar->getNode("clouds", true )->getChildren("layer");
106 for( PropertyList::iterator it = layers.begin(); it != layers.end(); ++it ) {
107 const char * coverage = (*it)->getStringValue("coverage","clear");
108 double elevation = (*it)->getDoubleValue("elevation-ft", -9999 );
109 if( elevation > 0 ) {
110 reply[elevation] = coverage;
116 int MetarPropertiesATISInformationProvider::getTemperatureDeg()
118 return _metar->getIntValue( "temperature-degc" );
121 int MetarPropertiesATISInformationProvider::getDewpointDeg()
123 return _metar->getIntValue( "dewpoint-degc" );
126 string MetarPropertiesATISInformationProvider::getTrend()