FlightGear next
MetarPropertiesATISInformationProvider.cxx
Go to the documentation of this file.
1/*
2Provide Data for the ATIS Encoder from metarproperties
3Copyright (C) 2014 Torsten Dreyer
4
5This program is free software; you can redistribute it and/or
6modify it under the terms of the GNU General Public License
7as published by the Free Software Foundation; either version 2
8of the License, or (at your option) any later version.
9
10This program is distributed in the hope that it will be useful,
11but WITHOUT ANY WARRANTY; without even the implied warranty of
12MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13GNU General Public License for more details.
14
15You should have received a copy of the GNU General Public License
16along with this program; if not, write to the Free Software
17Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
18*/
19
21#include <Main/globals.hxx>
22#include <simgear/constants.h>
23
24using std::string;
25
27 _metar( metar )
28{
29}
30
34
36{
37 return _metar->getBoolValue( "valid", false );
38}
39
41{
42 return _metar->getStringValue( "station-id", "xxxx" );
43}
44
46{
47 return makeAtisTime( 0,
48 _metar->getIntValue( "hour" ) % 24,
49 _metar->getIntValue( "minute" ) % 60 );
50}
51
53{
54 return _metar->getIntValue( "base-wind-dir-deg" );
55}
56
58{
59 return _metar->getIntValue( "base-wind-range-from" );
60}
62{
63 return _metar->getIntValue( "base-wind-range-to" );
64}
66{
67 return _metar->getIntValue( "base-wind-speed-kt" );
68}
69
71{
72 return _metar->getIntValue( "gust-wind-speed-kt" );
73}
74
76{
77 return _metar->getDoubleValue("pressure-inhg") * SG_INHG_TO_PA / 100.0;
78}
79
81{
82 return _metar->getDoubleValue("pressure-inhg");
83}
84
86{
87 return _metar->getBoolValue( "cavok" );
88}
89
91{
92 return _metar->getIntValue( "min-visibility-m" );
93}
94
96{
97 return _metar->getStringValue( "decoded" );
98}
99
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
119{
120 return _metar->getIntValue( "temperature-degc" );
121}
122
124{
125 return _metar->getIntValue( "dewpoint-degc" );
126}
127
129{
130 return "nosig";
131}
std::map< int, std::string > CloudEntries
static long makeAtisTime(int day, int hour, int minute)