Skip to content

Commit

Permalink
Add airport names to labels, ignoring extra information while calling…
Browse files Browse the repository at this point in the history
… APIs
  • Loading branch information
fboes committed Sep 27, 2019
1 parent d60e8a3 commit 2d7cfa4
Show file tree
Hide file tree
Showing 3 changed files with 21 additions and 11 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ Change log
1.3.1
-----

* 🎁 Add airport names to labels, ignoring extra information while calling APIs
* 🎁 Make GUI sliders snap to next readable value

1.3.0
Expand Down
28 changes: 17 additions & 11 deletions src/WettergeraetDesktop/Frame.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -240,20 +240,26 @@ Frame::Frame(const wxString& title, int argc, char * argv[]) : wxFrame(nullptr,
if (strlen(this->argumentor.metarfile) != 0) {
this->loadMetarFile(this->argumentor.metarfile);
}
this->addIcaoChoice("KDEN"); // Denver
this->addIcaoChoice("KJFK"); // New York - JFK
this->addIcaoChoice("KLAS"); // Las Vegas
this->addIcaoChoice("KLAX"); // Los Angeles
this->addIcaoChoice("KMIA"); // Miami
this->addIcaoChoice("KORD"); // Chicago
this->addIcaoChoice("KSFO"); // San Francisco
this->addIcaoChoice("KDEN (Denver International, USA)");
this->addIcaoChoice("KJFK (New York/John F Kennedy International, USA)");
this->addIcaoChoice("KLAS (Las Vegas/McCarran International, USA)");
this->addIcaoChoice("KLAX (Los Angeles International, USA)");
this->addIcaoChoice("KMIA (Miami International, USA)");
this->addIcaoChoice("KORD (Chicago O'Hare International, USA)");
this->addIcaoChoice("KSFO (San Francisco International, USA)");
}

Frame::~Frame()
{

}

wxString Frame::getIcaoFromInput()
{
wxString icao = this->icaoInput->GetValue();
return icao.BeforeFirst(' ');
}

// --------------------------------------------------------------------------------------

void Frame::fromObjectToInput()
Expand Down Expand Up @@ -365,7 +371,7 @@ void Frame::loadMainMcf()

void Frame::actionFetch(wxCommandEvent& WXUNUSED(event))
{
auto icaoCode = this->icaoInput->GetValue();
auto icaoCode = this->getIcaoFromInput();
if (icaoCode == "") {
wxLogError(_("No ICAO airport code given"));
return;
Expand Down Expand Up @@ -475,7 +481,7 @@ void Frame::actionSaveMetarFile(wxCommandEvent& WXUNUSED(event))

char timestamp[25];
sprintf(timestamp, "%04d-%02d-%02d_%02d%02dZ", year, month, day, hour, minute);
wxString defaultFilename = this->icaoInput->GetValue() + "_" + timestamp + ".rwx";
wxString defaultFilename = this->getIcaoFromInput() + "_" + timestamp + ".rwx";

wxFileDialog saveFileDialog(this, _("Save METAR file"), "", defaultFilename, "Text files (*.txt, *.rwx)|*.txt;*.rwx", wxFD_SAVE);
if (saveFileDialog.ShowModal() == wxID_CANCEL) {
Expand Down Expand Up @@ -580,7 +586,7 @@ void Frame::actionHelp(wxCommandEvent& WXUNUSED(event))
void Frame::actionFindIcao(wxCommandEvent& WXUNUSED(event))
{
wxString url = "https://opennav.com/";
auto icaoCode = this->icaoInput->GetValue();
auto icaoCode = this->getIcaoFromInput();
if (icaoCode != "") {
url += "airport/" + icaoCode;
}
Expand All @@ -590,7 +596,7 @@ void Frame::actionFindIcao(wxCommandEvent& WXUNUSED(event))
void Frame::actionGetAirportPlates(wxCommandEvent& WXUNUSED(event))
{
wxString url = "https://flightaware.com/";
auto icaoCode = this->icaoInput->GetValue();
auto icaoCode = this->getIcaoFromInput();
if (icaoCode != "") {
url += "resources/airport/" + icaoCode + "/procedures";
}
Expand Down
3 changes: 3 additions & 0 deletions src/WettergeraetDesktop/Frame.h
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,9 @@ class Frame : public wxFrame
Frame(const wxString& title, int argc, char * argv[]);
virtual ~Frame();

// Get the _parsed_ version from input field, ignoring extra information
virtual wxString getIcaoFromInput();

// Copy state of objects to form
virtual void fromObjectToInput();

Expand Down

0 comments on commit 2d7cfa4

Please sign in to comment.