Skip to content

Commit

Permalink
Add stepclimb support for AT3 RTE menu (#33)
Browse files Browse the repository at this point in the history
added route resolve code and moved it to the end of judging auto assigning route code is needed
  • Loading branch information
LeoChen98 authored Aug 5, 2024
1 parent 14bc81a commit bd83a70
Show file tree
Hide file tree
Showing 2 changed files with 32 additions and 1 deletion.
15 changes: 14 additions & 1 deletion AT3/AT3Tags.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,8 @@
#include <array>
#include <chrono>
#include <ctime>
#include <boost/algorithm/string.hpp>
#include <boost/format.hpp>

using namespace EuroScopePlugIn;

Expand Down Expand Up @@ -671,7 +673,6 @@ string AT3Tags::GetRouteCodeLine4(CFlightPlan& FlightPlan, CRadarTarget& RadarTa
string spadCurrent = FlightPlan.GetControllerAssignedData().GetScratchPadString();
string flightStrip = FlightPlan.GetControllerAssignedData().GetFlightStripAnnotation(3);
string runway = FlightPlan.GetFlightPlanData().GetArrivalRwy();
string fpRoute = FlightPlan.GetFlightPlanData().GetRoute();
string lineStr;

size_t startContainer = flightStrip.find("/R/");
Expand All @@ -685,6 +686,18 @@ string AT3Tags::GetRouteCodeLine4(CFlightPlan& FlightPlan, CRadarTarget& RadarTa
}
}
else if (arptSet.find(FlightPlan.GetFlightPlanData().GetDestination()) != arptSet.end() && strlen(FlightPlan.GetFlightPlanData().GetArrivalRwy()) != 0) {

// resolve flightplan route and remove stepclimb info to avoid the interference
vector<string> route = split(FlightPlan.GetFlightPlanData().GetRoute(), ' ');
string fpRoute = "";
for (std::size_t i = 0; i < route.size(); i++) {
if (i != 0 && i != route.size()) {
route[i] = route[i].substr(0, route[i].find_first_of('/'));
}
boost::to_upper(route[i]);
fpRoute = fpRoute + route[i] + " ";
}

for (auto& rte : rteJson[FlightPlan.GetFlightPlanData().GetDestination()][runway.substr(0, 2)]["routes"].items()) { //matches exact route only for auto assigning route code
if (fpRoute.find(rte.value()["route"]) != string::npos) {
lineStr = rte.key();
Expand Down
18 changes: 18 additions & 0 deletions AT3/AT3Tags.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,8 @@
#include "MAESTROapi.h"
#include <chrono>
#include <ctime>
#include <boost/algorithm/string.hpp>
#include <boost/format.hpp>

using namespace std;
using namespace EuroScopePlugIn;
Expand Down Expand Up @@ -95,4 +97,20 @@ class AT3Tags :
COLORREF colorAssumed;
COLORREF colorNotAssumed;
COLORREF colorRedundant;

private:
template <typename Out>
void split(const string& s, char delim, Out result) {
istringstream iss(s);
string item;
while (getline(iss, item, delim)) {
*result++ = item;
}
}

vector<string> split(const string& s, char delim) {
vector<string> elems;
split(s, delim, back_inserter(elems));
return elems;
}
};

0 comments on commit bd83a70

Please sign in to comment.