Skip to content

Commit

Permalink
Add "Find ICAO airport codes" menu entries
Browse files Browse the repository at this point in the history
  • Loading branch information
fboes committed Mar 24, 2019
1 parent d171dd1 commit 376b382
Show file tree
Hide file tree
Showing 10 changed files with 33 additions and 23 deletions.
3 changes: 2 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ Change log
==========

* 🎁 Add "Update" / "Help" menu entries
* 🎁 Add "Find ICAO airport codes" menu entries

1.1.0
-----
Expand All @@ -11,7 +12,7 @@ Change log
1.0.1
-----

* 💊 Improve handling of ICAO codes
* 💊 Improve handling of ICAO airport codes
* 💊 Fix behaviour of seconds in UTC time

1.0.0
Expand Down
9 changes: 5 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -25,9 +25,10 @@ Requirements
Installation
------------

1. Download the current release ZIP from https://github.com/fboes/aerofly-wettergeraet/releases/latest.
2. Unpack the ZIP file to some sensible location.
3. Create a shortcut on your desktop by right-clicking `aerofly-wettergeraet-desktop.exe` > "Send to" > "Desktop (Create shortcut)".
1. Download the latest release ZIP from https://github.com/fboes/aerofly-wettergeraet/releases/latest.
2. Unpack the ZIP file to some sensible location, e.g. `C:\Program Files\aerofly-wettergeraet`.
3. Create a shortcut on your desktop by right-clicking `aerofly-wettergeraet-desktop.exe` > "Send to" > "Desktop (Create shortcut)".
You might want to re-label the shortcut to "Aerofly Wettergerät".
3. Start the desktop application by clicking on the desktop link.

In case you want to use this application on a different operation system, consider [building your own executable from this project](CONTRIBUTING.md).
Expand All @@ -49,7 +50,7 @@ You will need a copy of IPACS' Aerofly FS 2 which has run at least once. This cr

Before starting the <i>Aerofly Wettergerät</i> be sure that Aerofly FS 2 is _not_ running. On start-up the application will load the current settings from your `main.mcf`.

By starting the application METAR data will be fetched from a remote internet service for the given ICAO code. If it is successful, it will paste the METAR code and convert it into the corresponding Aerofly FS 2 values. It also allows for changing values which are not accessible from inside Aerofly FS 2.
By starting the application METAR data will be fetched from a remote internet service for the given ICAO airport code. If it is successful, it will paste the METAR code and convert it into the corresponding Aerofly FS 2 values. It also allows for changing values which are not accessible from inside Aerofly FS 2.

Optionally you can enter a METAR code manually.

Expand Down
2 changes: 1 addition & 1 deletion src/MetarParserSimple/MetarParserSimple.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -112,7 +112,7 @@ bool MetarParserSimple::convert(std::string metarString)

switch (parsingMode) {
case 0:
// ICAO Code
// ICAO Airport Code
if (metarPart != "METAR") {
strcpy(this->icao, metarPart.c_str());
parsingMode = 1;
Expand Down
2 changes: 1 addition & 1 deletion src/MetarParserSimple/MetarParserSimple.h
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,7 @@ class METARPARSERSIMPLE_API MetarParserSimple
unsigned long baseFeetAgl = 0;
};

// ICAO code of METAR report
// ICAO airport code of METAR report
char icao[8] = "";

// Time of observation
Expand Down
2 changes: 1 addition & 1 deletion src/WettergeraetCli/main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,7 @@ void showMetar(MetarParserSimple metar) {
std::cout << "Flight category " << metar.getFlightCategory() << endl;
}

// Return origin / desitnation ICAO code from flightplan depending on inIcao bein "DEP" or "ARR".
// Return origin / destination ICAO airport code from flightplan depending on inIcao bein "DEP" or "ARR".
std::string getIcaoFromFlightplan(std::string inIcao, std::tuple<std::string, std::string> flightplan) {
std::string origin;
std::string destination;
Expand Down
26 changes: 15 additions & 11 deletions src/WettergeraetDesktop/Frame.cpp
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
#define wxUSE_DATEPICKCTRL 1
#define MY_APP_VERSION_STRING "1.1.0"
#define MY_APP_VERSION_STRING "1.1.1"

#include <wx/wx.h>
#include <wx/datectrl.h>
Expand Down Expand Up @@ -28,6 +28,7 @@ Frame::Frame(const wxString& title, int argc, char * argv[]) : wxFrame(nullptr,
wxMenu *help = new wxMenu;
help->Append(wxID_HELP, wxT("View &help"));
help->Append(EL_MENU_UPDATE, wxT("Check for &updates"));
help->Append(EL_MENU_FIND_ICAO, wxT("Find &ICAO airport codes"));
help->AppendSeparator();
help->Append(wxID_ABOUT, wxT("&About"));
menubar->Append(help, wxT("&Help"));
Expand All @@ -45,7 +46,7 @@ Frame::Frame(const wxString& title, int argc, char * argv[]) : wxFrame(nullptr,
// build hbox1
wxBoxSizer *hbox1 = new wxBoxSizer(wxHORIZONTAL);
{
wxStaticText *icaoLabel = new wxStaticText(panel, wxID_ANY, wxT("ICAO code"));
wxStaticText *icaoLabel = new wxStaticText(panel, wxID_ANY, wxT("ICAO airport code"));
hbox1->Add(icaoLabel, 1, wxRIGHT | wxALIGN_CENTER_VERTICAL, labelBorder);

this->icaoInput = new wxTextCtrl(panel, wxID_ANY);
Expand All @@ -70,9 +71,6 @@ Frame::Frame(const wxString& title, int argc, char * argv[]) : wxFrame(nullptr,
hbox2->Add(this->metarInput, 3, wxLEFT | wxEXPAND);

hbox2->Add(10, -1);

/*wxButton *parseButton = new wxButton(panel, Frame::EL_BUTTON_PARSE, wxT("Convert METAR data"), wxPoint(5, 5));
hbox2->Add(parseButton, 1, wxLEFT);*/
}
vbox->Add(hbox2, 1, wxEXPAND | wxLEFT | wxRIGHT, 10);
vbox->Add(-1, 10);
Expand Down Expand Up @@ -204,6 +202,8 @@ Frame::~Frame()

}

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

void Frame::fromObjectToInput()
{
this->icaoInput->SetValue(wxString(this->aerofly.nearestAirport));
Expand Down Expand Up @@ -276,19 +276,20 @@ void Frame::loadMainMcf()
this->fromObjectToInput();
}

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

void Frame::actionFetch(wxCommandEvent& WXUNUSED(event))
{
auto icaoCode = this->icaoInput->GetValue();
if (icaoCode == "") {
this->metarInput->SetValue("No ICAO code given");
this->metarInput->SetValue("No ICAO airport code given");
return;
}
this->metarInput->SetValue("Loading...");
FetchUrl urlFetcher;
try {
auto metarString = urlFetcher.fetch(this->argumentor.url, icaoCode, this->argumentor.response, this->argumentor.apikey);
this->metarInput->SetValue(metarString);
//this->metarInput->SetValue("METAR KTTN 051853Z 04011KT 1/2SM VCTS SN FZFG BKN003 OVC010 M02/M02 A3006 RMK AO2 TSB40 SLP176 P0002 T10171017=");
this->saveButton->SetFocus();
}
catch (std::invalid_argument& e) {
Expand All @@ -304,7 +305,6 @@ void Frame::actionParse(wxCommandEvent& WXUNUSED(event))
}
try {
this->aerofly.setFromMetarString(metarInput);
//this->icaoInput->SetValue();
this->fromObjectToInput();
}
catch (std::invalid_argument& e) {
Expand Down Expand Up @@ -332,7 +332,7 @@ void Frame::actionAbout(wxCommandEvent& WXUNUSED(event))
aboutInfo.SetName("Aerofly Wetterger\u00E4t");
aboutInfo.SetVersion(MY_APP_VERSION_STRING);
aboutInfo.SetDescription(_("Copy METAR weather information into IPCAS' Aerofly FS 2.\n\nCurrentAPI:\n") + this->argumentor.url);
aboutInfo.SetCopyright("(C) 2019");
aboutInfo.SetCopyright("\u00A9 2019");
aboutInfo.SetWebSite("https://github.com/fboes/aerofly-wettergeraet");
aboutInfo.AddDeveloper("Frank Bo\u00EBs");
aboutInfo.SetIcon(wxICON(APPICON));
Expand All @@ -356,15 +356,19 @@ void Frame::actionHelp(wxCommandEvent& WXUNUSED(event))
wxLaunchDefaultBrowser("https://github.com/fboes/aerofly-wettergeraet/blob/master/README.md");
}

void Frame::actionFindIcao(wxCommandEvent& WXUNUSED(event))
{
wxLaunchDefaultBrowser("https://www.world-airport-codes.com/");
}

wxBEGIN_EVENT_TABLE(Frame, wxFrame)
EVT_BUTTON(Frame::EL_BUTTON_FETCH, Frame::actionFetch)
//EVT_BUTTON(Frame::EL_BUTTON_PARSE, Frame::actionParse)
EVT_BUTTON(wxID_SAVE, Frame::actionSave)
EVT_MENU(wxID_HELP, Frame::actionHelp)
EVT_MENU(EL_MENU_UPDATE, Frame::actionUpdate)
EVT_MENU(EL_MENU_FIND_ICAO, Frame::actionFindIcao)
EVT_MENU(wxID_ABOUT, Frame::actionAbout)
EVT_MENU(wxID_EXIT, Frame::actionExit)
EVT_MENU(wxID_OPEN, Frame::actionLoadMainMcf)
EVT_TEXT(Frame::EL_CTRL_METAR, Frame::actionParse)
//EVT_COMMAND_SCROLL_CHANGED(Frame::actionSave);
wxEND_EVENT_TABLE()
4 changes: 4 additions & 0 deletions src/WettergeraetDesktop/Frame.h
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,7 @@ class Frame : public wxFrame
static const unsigned short EL_CTRL_DATETIME = 5;
static const unsigned short EL_CTRL_SLIDER = 6;
static const unsigned short EL_MENU_UPDATE = 7;
static const unsigned short EL_MENU_FIND_ICAO = 8;

Frame(const wxString& title, int argc, char * argv[]);
virtual ~Frame();
Expand Down Expand Up @@ -75,4 +76,7 @@ class Frame : public wxFrame
virtual void actionUpdate(wxCommandEvent&);

virtual void actionHelp(wxCommandEvent&);

virtual void actionFindIcao(wxCommandEvent&);

};
2 changes: 1 addition & 1 deletion src/WettergeraetLib/AeroflyWeather.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -90,7 +90,7 @@ void AeroflyWeather::setThermalActivity(double celsius)

void AeroflyWeather::setVisibility(unsigned long meters)
{
const unsigned long maxMiles = 10 * 1609.344;
const unsigned long maxMiles = (long)(10 * 1609.344);
if (this->maxVisibility > 9999 && (meters == 9999 || meters == 10000)) {
// because meters cannot be greater than 9999
// but miles can reach up to 10sm
Expand Down
2 changes: 1 addition & 1 deletion src/WettergeraetLib/AeroflyWeather.h
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ class AeroflyWeather
double windStrength = 0.0; // 0.0..1.0
double windTurbulence = 0.0; // 0.0..1.0
double thermalActivity = 0.0; // 0.0..1.0
char nearestAirport[8] = ""; // ICAO code of METAR report
char nearestAirport[8] = ""; // ICAO airport code of METAR report

AeroflyWeather();
~AeroflyWeather();
Expand Down
4 changes: 2 additions & 2 deletions src/WettergeraetLib/Argumentor.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -15,9 +15,9 @@ std::string Argumentor::showHelp(std::string cmd)
+ " Defaults to URL of AvWX.\n"
+ " --icao <ICAO> ICAO code of airport the METAR will be fetched for.\n"
+ " If this is set to '?' the value will be asked for.\n"
+ " If this contains 'DEP', ICAO code will be fetched\n"
+ " If this contains 'DEP', ICAO airport code will be fetched\n"
+ " from Aerofly FS 2 flightplan departure airport.\n"
+ " If this contains 'ARR', ICAO code will be fetched\n"
+ " If this contains 'ARR', ICAO airport code will be fetched\n"
+ " from Aerofly FS 2 flightplan arrival airport.\n"
+ " --apikey <APIKEY> Sent HTTP header 'X-API-Key' set to <APIKEY>.\n"
+ " --response <TYPE> How to interpret HTTP response. 'json' is default.\n"
Expand Down

0 comments on commit 376b382

Please sign in to comment.