3 XCSoar Glide Computer - http://www.xcsoar.org/
4 Copyright (C) 2000-2013 The XCSoar Project
5 A detailed list of copyright holders can be found in the file "AUTHORS".
7 This program is free software; you can redistribute it and/or
8 modify it under the terms of the GNU General Public License
9 as published by the Free Software Foundation; either version 2
10 of the License, or (at your option) any later version.
12 This program is distributed in the hope that it will be useful,
13 but WITHOUT ANY WARRANTY; without even the implied warranty of
14 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 GNU General Public License for more details.
17 You should have received a copy of the GNU General Public License
18 along with this program; if not, write to the Free Software
19 Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
23 #include "Weather/METARParser.hpp"
24 #include "Weather/METAR.hpp"
25 #include "Weather/ParsedMETAR.hpp"
26 #include "Units/System.hpp"
27 #include "TestUtil.hpp"
30 main(int argc
, char **argv
)
38 metar
.content
= _T("EDDL 231050Z 31007MPS 9999 FEW020 SCT130 23/18 Q1015 NOSIG");
39 metar
.decoded
= _T("");
40 if (!ok1(METARParser::Parse(metar
, parsed
)))
43 ok1(parsed
.icao_code
== _T("EDDL"));
44 ok1(parsed
.day_of_month
== 23);
45 ok1(parsed
.hour
== 10);
46 ok1(parsed
.minute
== 50);
47 ok1(parsed
.qnh_available
);
48 ok1(equals(parsed
.qnh
.GetHectoPascal(), 1015));
49 ok1(parsed
.wind_available
);
50 ok1(equals(parsed
.wind
.norm
, 7));
51 ok1(equals(parsed
.wind
.bearing
, 310));
52 ok1(parsed
.temperatures_available
);
53 ok1(equals(parsed
.temperature
, Units::ToSysUnit(fixed(23), Unit::DEGREES_CELCIUS
)));
54 ok1(equals(parsed
.dew_point
, Units::ToSysUnit(fixed(18), Unit::DEGREES_CELCIUS
)));
55 ok1(parsed
.visibility_available
);
56 ok1(parsed
.visibility
== 9999);
58 ok1(!parsed
.location_available
);
62 metar
.content
= _T("METAR KTTN 051853Z 04011KT 1/2SM VCTS SN FZFG BKN003 OVC010 M02/M02 A3006 RMK AO2 TSB40 SLP176 P0002 T10171017=");
63 metar
.decoded
= _T("Pudahuel, Chile (SCEL) 33-23S 070-47W 476M\r\n"
64 "Nov 04, 2011 - 07:50 PM EDT / 2011.11.04 2350 UTC\r\n");
65 if (!ok1(METARParser::Parse(metar
, parsed
)))
68 ok1(parsed
.icao_code
== _T("KTTN"));
69 ok1(parsed
.day_of_month
== 5);
70 ok1(parsed
.hour
== 18);
71 ok1(parsed
.minute
== 53);
72 ok1(parsed
.qnh_available
);
73 ok1(equals(parsed
.qnh
.GetHectoPascal(),
74 Units::ToSysUnit(fixed(30.06), Unit::INCH_MERCURY
)));
75 ok1(parsed
.wind_available
);
76 ok1(equals(parsed
.wind
.norm
, Units::ToSysUnit(fixed(11), Unit::KNOTS
)));
77 ok1(equals(parsed
.wind
.bearing
, 40));
78 ok1(parsed
.temperatures_available
);
79 ok1(equals(parsed
.temperature
, Units::ToSysUnit(fixed(-1.7), Unit::DEGREES_CELCIUS
)));
80 ok1(equals(parsed
.dew_point
, Units::ToSysUnit(fixed(-1.7), Unit::DEGREES_CELCIUS
)));
81 ok1(!parsed
.visibility_available
);
83 ok1(parsed
.location_available
);
84 ok1(equals(parsed
.location
, -33.3833333333333, -70.78333333333333));
88 metar
.content
= _T("METAR EDJA 231950Z VRB01KT CAVOK 21/17 Q1017=");
89 metar
.decoded
= _T("Duesseldorf, Germany (EDDL) 51-18N 006-46E 41M\r\n"
90 "Nov 04, 2011 - 07:50 PM EDT / 2011.11.04 2350 UTC\r\n");
91 if (!ok1(METARParser::Parse(metar
, parsed
)))
94 ok1(parsed
.icao_code
== _T("EDJA"));
95 ok1(parsed
.day_of_month
== 23);
96 ok1(parsed
.hour
== 19);
97 ok1(parsed
.minute
== 50);
98 ok1(parsed
.qnh_available
);
99 ok1(equals(parsed
.qnh
.GetHectoPascal(), 1017));
100 ok1(!parsed
.wind_available
);
101 ok1(parsed
.temperatures_available
);
102 ok1(equals(parsed
.temperature
, Units::ToSysUnit(fixed(21), Unit::DEGREES_CELCIUS
)));
103 ok1(equals(parsed
.dew_point
, Units::ToSysUnit(fixed(17), Unit::DEGREES_CELCIUS
)));
104 ok1(!parsed
.visibility_available
);
106 ok1(parsed
.location_available
);
107 ok1(equals(parsed
.location
, 51.3, 6.766666666666667));
110 return exit_status();