metar report

* add unprocessed ob: line as a report option
This commit is contained in:
dave-w1hkj 2023-11-07 10:40:03 -06:00
parent 80882af131
commit 2e5db4f16a
8 changed files with 57 additions and 9 deletions

View file

@ -9666,6 +9666,13 @@ static void cb_btn_wx_mbars(Fl_Check_Button* o, void*) {
progdefaults.changed = true;
}
Fl_Check_Button *btn_wx_raw=(Fl_Check_Button *)0;
static void cb_btn_wx_raw(Fl_Check_Button* o, void*) {
progdefaults.wx_raw=o->value();
progdefaults.changed = true;
}
Fl_Button *btnSaveConfig=(Fl_Button *)0;
static void cb_btnSaveConfig(Fl_Button*, void*) {
@ -19941,6 +19948,12 @@ i on a\ntouch screen device such as a tablet."));
btn_wx_mbars->callback((Fl_Callback*)cb_btn_wx_mbars);
o->value(progdefaults.wx_mbars);
} // Fl_Check_Button* btn_wx_mbars
{ Fl_Check_Button* o = btn_wx_raw = new Fl_Check_Button(522, 138, 70, 15, _("Unprocessed METAR data"));
btn_wx_raw->tooltip(_("Insert full METAR report"));
btn_wx_raw->down_box(FL_DOWN_BOX);
btn_wx_raw->callback((Fl_Callback*)cb_btn_wx_raw);
o->value(progdefaults.wx_raw);
} // Fl_Check_Button* btn_wx_raw
CONFIG_PAGE *p = new CONFIG_PAGE(o, _("Web/WX"));
config_pages.push_back(p);
tab_tree->add(_("Web/WX"));

View file

@ -8528,7 +8528,7 @@ number to the default value.} xywh {624 313 73 22}
}
}
Fl_Group grpOperator {
label {Operator-Station} open selected
label {Operator-Station} open
xywh {200 0 600 350} box ENGRAVED_BOX color 50 align 21 hide
code0 {CONFIG_PAGE *p = new CONFIG_PAGE(o, _("Operator-Station"));}
code1 {config_pages.push_back(p);}
@ -12141,7 +12141,7 @@ progdefaults.changed = true;}
}
}
Fl_Group {} {
label {Web/WX}
label {Web/WX} selected
xywh {200 0 600 350} box ENGRAVED_BOX align 21 hide
code0 {CONFIG_PAGE *p = new CONFIG_PAGE(o, _("Web/WX"));}
code1 {config_pages.push_back(p);}
@ -12240,6 +12240,13 @@ progdefaults.changed = true;}
tooltip {report millibars} xywh {522 280 70 15} down_box DOWN_BOX
code0 {o->value(progdefaults.wx_mbars);}
}
Fl_Check_Button btn_wx_raw {
label {Unprocessed METAR data}
callback {progdefaults.wx_raw=o->value();
progdefaults.changed = true;}
tooltip {Insert full METAR report} xywh {522 138 70 15} down_box DOWN_BOX
code0 {o->value(progdefaults.wx_raw);}
}
}
Fl_Button btnSaveConfig {
label Save

View file

@ -10102,6 +10102,7 @@ void set_default_btn_color()
btn_wx_kph,
btn_wx_inches,
btn_wx_mbars,
btn_wx_raw,
btnNoiseOn,
btnOffsetOn,

View file

@ -1077,6 +1077,7 @@ extern Fl_Check_Button *btn_wx_mph;
extern Fl_Check_Button *btn_wx_kph;
extern Fl_Check_Button *btn_wx_inches;
extern Fl_Check_Button *btn_wx_mbars;
extern Fl_Check_Button *btn_wx_raw;
extern Fl_Button *btnSaveConfig;
#include <FL/Fl_Return_Button.H>
extern Fl_Return_Button *btnCloseConfig;

View file

@ -2641,6 +2641,9 @@
ELEM_(bool, wx_station_name, "WX_STATION_NAME", \
"Report station noun name", \
true) \
ELEM_(bool, wx_raw, "WX_RAW", \
"Unparsed METAR report", \
true) \
/* KML Keyhole Markup Language */ \
ELEM_(bool, kml_purge_on_startup, "KML_PURGE_ON_STARTUP", \
"Purge KML data at startup", \

View file

@ -45,6 +45,7 @@ class Metar {
bool _kph;
bool _condx;
bool _name;
bool _wx_raw;
bool _debug;
public:
@ -71,7 +72,8 @@ public:
_inches = _mbars =
_fahrenheit = _celsius =
_mph = _kph =
_condx = _name = true;
_condx = _name =
_wx_raw = true;
_debug = false;
}
@ -94,7 +96,7 @@ public:
void params( bool inches, bool mbars,
bool fahrenheit, bool celsius,
bool mph, bool kph,
bool condx, bool name)
bool condx, bool name, bool wx_raw)
{
_inches = inches;
_mbars = mbars;
@ -104,6 +106,7 @@ public:
_kph = kph;
_condx = condx;
_name = name;
_wx_raw = wx_raw;
}
void inches(bool b) { _inches = b; }
bool inches() { return _inches; }

View file

@ -21,6 +21,7 @@
// ----------------------------------------------------------------------------
#include "metar.h"
#include "debug.h"
/*======================================================================
*
@ -157,10 +158,14 @@ static wxpairs cloud_type[] = {
{"CI", "cirrus"},
{NULL, NULL} };
#define METAR_DEBUG 1
void Metar::parse()
{
size_t p, p1, p2, p3;
if (METAR_DEBUG) LOG_DEBUG("%s", _metar_text.c_str());
p = _metar_text.find(_metar_station);
if (p == std::string::npos) {
_wx_text_full.assign(_metar_station).append(" not found in url response!");
@ -197,7 +202,16 @@ void Metar::parse()
return;
}
_wx_text_full.assign(_metar_text.substr(0, p3));
_wx_text_full.assign(_metar_text);//.substr(0, p3));
// METAR report is now _metar_text
std::string metar_report = _metar_text.substr(p3);
p = metar_report.find(_metar_station);
if (p != std::string::npos) metar_report.erase(0, p);
p = metar_report.find("\n");
if (p != std::string::npos) metar_report.erase(p);
if (METAR_DEBUG) LOG_INFO("%s", metar_report.c_str());
p = _metar_text.find(_metar_station, p3 + 1);
_metar_text.erase(0, p + 1 + _metar_station.length());
@ -363,6 +377,10 @@ void Metar::parse()
if ((_inches || _mbars) && !_baro.empty()) {
_wx_text_parsed.append("Baro: ").append(_baro).append("\n");
}
if ((_wx_raw) && !metar_report.empty()) {
_wx_text_parsed.append(metar_report);
if (METAR_DEBUG) LOG_INFO("%s", _wx_text_parsed.c_str());
}
return;

View file

@ -66,10 +66,12 @@ void getwx(std::string& wx, std::string wxsta)
Metar local_wx;
local_wx.params( progdefaults.wx_inches, progdefaults.wx_mbars,
progdefaults.wx_fahrenheit, progdefaults.wx_celsius,
progdefaults.wx_mph, progdefaults.wx_kph,
progdefaults.wx_condx, progdefaults.wx_station_name);
local_wx.params(
progdefaults.wx_inches, progdefaults.wx_mbars,
progdefaults.wx_fahrenheit, progdefaults.wx_celsius,
progdefaults.wx_mph, progdefaults.wx_kph,
progdefaults.wx_condx, progdefaults.wx_station_name,
progdefaults.wx_raw);
local_wx.debug(true);