]> git.mxchange.org Git - flightgear.git/blob - src/ATC/MetarPropertiesATISInformationProvider.cxx
Launcher shows polygon/polyline data
[flightgear.git] / src / ATC / MetarPropertiesATISInformationProvider.cxx
1 /*
2 Provide Data for the ATIS Encoder from metarproperties
3 Copyright (C) 2014 Torsten Dreyer
4
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.
9
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.
14
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.
18 */
19
20 #include "MetarPropertiesATISInformationProvider.hxx"
21 #include <Main/globals.hxx>
22 #include <simgear/constants.h>
23
24 using std::string;
25
26 MetarPropertiesATISInformationProvider::MetarPropertiesATISInformationProvider( SGPropertyNode_ptr metar ) :
27   _metar( metar )
28 {
29 }
30
31 MetarPropertiesATISInformationProvider::~MetarPropertiesATISInformationProvider()
32 {
33 }
34
35 bool MetarPropertiesATISInformationProvider::isValid()
36 {
37   return _metar->getBoolValue( "valid", false );
38 }
39
40 string MetarPropertiesATISInformationProvider::airportId()
41 {
42   return _metar->getStringValue( "station-id", "xxxx" );
43 }
44
45 long MetarPropertiesATISInformationProvider::getTime()
46 {
47   return makeAtisTime( 0,
48     _metar->getIntValue( "hour" ) % 24, 
49     _metar->getIntValue( "minute" ) % 60 );
50 }
51
52 int MetarPropertiesATISInformationProvider::getWindDeg()
53 {
54    return _metar->getIntValue( "base-wind-dir-deg" );
55 }
56
57 int MetarPropertiesATISInformationProvider::getWindMinDeg()
58 {
59    return _metar->getIntValue( "base-wind-range-from" );
60 }
61 int MetarPropertiesATISInformationProvider::getWindMaxDeg()
62 {
63    return _metar->getIntValue( "base-wind-range-to" );
64 }
65 int MetarPropertiesATISInformationProvider::getWindSpeedKt()
66 {
67   return _metar->getIntValue( "base-wind-speed-kt" );
68 }
69
70 int MetarPropertiesATISInformationProvider::getGustsKt()
71 {
72   return _metar->getIntValue( "gust-wind-speed-kt" );
73 }
74
75
76 int MetarPropertiesATISInformationProvider::getQnh()
77 {
78   return _metar->getDoubleValue("pressure-sea-level-inhg") * SG_INHG_TO_PA / 100.0;
79 }
80
81 bool MetarPropertiesATISInformationProvider::isCavok()
82 {
83   return _metar->getBoolValue( "cavok" );
84 }
85
86 int MetarPropertiesATISInformationProvider::getVisibilityMeters()
87 {
88   return _metar->getIntValue( "min-visibility-m" );
89 }
90
91 string MetarPropertiesATISInformationProvider::getPhenomena()
92 {
93   return _metar->getStringValue( "decoded" );
94 }
95
96 ATISInformationProvider::CloudEntries MetarPropertiesATISInformationProvider::getClouds()
97 {
98   CloudEntries reply;
99
100   using simgear::PropertyList;
101   PropertyList layers = _metar->getNode("clouds", true )->getChildren("layer");
102   for( PropertyList::iterator it = layers.begin(); it != layers.end(); ++it ) {
103     const char * coverage = (*it)->getStringValue("coverage","clear");
104     double elevation = (*it)->getDoubleValue("elevation-ft", -9999 );
105     if( elevation > 0 ) {
106       reply[elevation] = coverage;
107     }
108   }
109   return reply;
110 }
111
112 int MetarPropertiesATISInformationProvider::getTemperatureDeg()
113 {
114   return _metar->getIntValue( "temperature-degc" );
115 }
116
117 int MetarPropertiesATISInformationProvider::getDewpointDeg()
118 {
119   return _metar->getIntValue( "dewpoint-degc" );
120 }
121
122 string MetarPropertiesATISInformationProvider::getTrend()
123 {
124   return "nosig";
125 }
126