1 // ----------------------------------------------------------------------------
2 // weather.cxx -- a part of fldigi
3 //
4 // Copyright (C) 2012
5 // Dave Freese, W1HKJ
6 //
7 // This file is part of fldigi.
8 //
9 // Fldigi is free software: you can redistribute it and/or modify
10 // it under the terms of the GNU General Public License as published by
11 // the Free Software Foundation, either version 3 of the License, or
12 // (at your option) any later version.
13 //
14 // Fldigi is distributed in the hope that it will be useful,
15 // but WITHOUT ANY WARRANTY; without even the implied warranty of
16 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
17 // GNU General Public License for more details.
18 //
19 // You should have received a copy of the GNU General Public License
20 // along with fldigi. If not, see <http://www.gnu.org/licenses/>.
21 // ----------------------------------------------------------------------------
22
23 #include <config.h>
24
25 #ifdef __MINGW32__
26 # include "compat.h"
27 #endif
28
29 #include <sys/time.h>
30 #include "signal.h"
31 #include <string>
32 #include <iostream>
33 #include <cstring>
34 #include <cmath>
35 #include <cctype>
36
37 #include "threads.h"
38
39 #include "misc.h"
40 #include "configuration.h"
41
42 #include "main.h"
43 #include "confdialog.h"
44 #include "fl_digi.h"
45 #include "trx.h"
46
47 #include "xmlreader.h"
48
49 #include "qrunner.h"
50 #include "debug.h"
51 #include "network.h"
52
53 #include "weather.h"
54 #include "metar.h"
55
getwx(std::string & wx,std::string wxsta)56 void getwx(std::string& wx, std::string wxsta)
57 {
58 std::string metar;
59 if (wxsta.empty())
60 metar = progdefaults.wx_sta;
61 else
62 metar = wxsta;
63
64 for (size_t n = 0; n < metar.length(); n++)
65 metar[n] = toupper(metar[n]);
66
67 Metar local_wx;
68
69 local_wx.params( progdefaults.wx_inches, progdefaults.wx_mbars,
70 progdefaults.wx_fahrenheit, progdefaults.wx_celsius,
71 progdefaults.wx_mph, progdefaults.wx_kph,
72 progdefaults.wx_condx, progdefaults.wx_station_name);
73
74 local_wx.debug(true);
75
76 if (local_wx.get(metar) == 0) {
77 if (progdefaults.wx_full) {
78 wx = local_wx.full();
79 return;
80 }
81 wx = local_wx.parsed();
82 } else
83 wx.clear();
84 return;
85
86 }
87
get_METAR_station()88 void get_METAR_station()
89 {
90 cb_mnuVisitURL(0, (void*)std::string("http://www.rap.ucar.edu/weather/surface/stations.txt").c_str());
91 }
92