Debian Codegraph @

src/ATC/MetarPropertiesATISInformationProvider.cxx

raw symbols SCIP
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() const
36 {
37 return _metar->getBoolValue( "valid", false );
38 }
39
40 string MetarPropertiesATISInformationProvider::airportId() const
41 {
42 return _metar->getStringValue( "station-id", "xxxx" );
43 }
44
45 long MetarPropertiesATISInformationProvider::getTime() const
46 {
47 return makeAtisTime( 0,
48 _metar->getIntValue( "hour" ) % 24,
49 _metar->getIntValue( "minute" ) % 60 );
50 }
51
52 int MetarPropertiesATISInformationProvider::getWindDeg() const
53 {
54 return _metar->getIntValue( "base-wind-dir-deg" );
55 }
56
57 int MetarPropertiesATISInformationProvider::getWindMinDeg() const
58 {
59 return _metar->getIntValue( "base-wind-range-from" );
60 }
61 int MetarPropertiesATISInformationProvider::getWindMaxDeg() const
62 {
63 return _metar->getIntValue( "base-wind-range-to" );
64 }
65 int MetarPropertiesATISInformationProvider::getWindSpeedKt() const
66 {
67 return _metar->getIntValue( "base-wind-speed-kt" );
68 }
69
70 int MetarPropertiesATISInformationProvider::getGustsKt() const
71 {
72 return _metar->getIntValue( "gust-wind-speed-kt" );
73 }
74
75 int MetarPropertiesATISInformationProvider::getQnh() const
76 {
77 return _metar->getDoubleValue("pressure-inhg") * SG_INHG_TO_PA / 100.0;
78 }
79
80 double MetarPropertiesATISInformationProvider::getQnhInHg() const
81 {
82 return _metar->getDoubleValue("pressure-inhg");
83 }
84
85 bool MetarPropertiesATISInformationProvider::isCavok() const
86 {
87 return _metar->getBoolValue( "cavok" );
88 }
89
90 int MetarPropertiesATISInformationProvider::getVisibilityMeters() const
91 {
92 return _metar->getIntValue( "min-visibility-m" );
93 }
94
95 string MetarPropertiesATISInformationProvider::getPhenomena() const
96 {
97 return _metar->getStringValue( "decoded" );
98 }
99
100 ATISInformationProvider::CloudEntries MetarPropertiesATISInformationProvider::getClouds()
101 {
102 CloudEntries reply;
103
104 using simgear::PropertyList;
105
106 PropertyList layers = _metar->getNode("clouds", true )->getChildren("layer");
107 for( PropertyList::iterator it = layers.begin(); it != layers.end(); ++it ) {
108 std::string coverage = (*it)->getStringValue("coverage", "clear");
109 double elevation = (*it)->getDoubleValue("elevation-ft", -9999 );
110 if( elevation > 0 ) {
111 reply[elevation] = coverage;
112 }
113 }
114
115 return reply;
116 }
117
118 int MetarPropertiesATISInformationProvider::getTemperatureDeg() const
119 {
120 return _metar->getIntValue( "temperature-degc" );
121 }
122
123 int MetarPropertiesATISInformationProvider::getDewpointDeg() const
124 {
125 return _metar->getIntValue( "dewpoint-degc" );
126 }
127
128 string MetarPropertiesATISInformationProvider::getTrend() const
129 {
130 return "nosig";
131 }