update the IAF distance estimation to provide better results
This commit is contained in:
@@ -376,6 +376,7 @@ void PlugIn::generateAircraftReportMessage(EuroScopePlugIn::CRadarTarget& radarT
|
|||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
int iafRouteIndex = flightPlan.GetExtractedRoute().GetPointsNumber();
|
||||||
auto currentPosition = radarTarget.GetPosition().GetPosition();
|
auto currentPosition = radarTarget.GetPosition().GetPosition();
|
||||||
EuroScopePlugIn::CPosition iafPosition;
|
EuroScopePlugIn::CPosition iafPosition;
|
||||||
std::string iafName;
|
std::string iafName;
|
||||||
@@ -397,6 +398,7 @@ void PlugIn::generateAircraftReportMessage(EuroScopePlugIn::CRadarTarget& radarT
|
|||||||
iafPosition = flightPlan.GetExtractedRoute().GetPointPosition(i);
|
iafPosition = flightPlan.GetExtractedRoute().GetPointPosition(i);
|
||||||
iafName = flightPlan.GetExtractedRoute().GetPointName(i);
|
iafName = flightPlan.GetExtractedRoute().GetPointName(i);
|
||||||
report->set_initialapproachfix(iafName);
|
report->set_initialapproachfix(iafName);
|
||||||
|
iafRouteIndex = i;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -408,27 +410,35 @@ void PlugIn::generateAircraftReportMessage(EuroScopePlugIn::CRadarTarget& radarT
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (0 != iafName.length()) {
|
if (0 != iafName.length()) {
|
||||||
const auto iafDistance = currentPosition.DistanceTo(iafPosition);
|
const std::string_view direct(flightPlan.GetControllerAssignedData().GetDirectToPointName());
|
||||||
|
bool directBehindIAF = false;
|
||||||
|
|
||||||
/* calculate the distance to the IAF */
|
if (0 != direct.length()) {
|
||||||
double distanceToIaf = 0.0f;
|
for (int i = 0; i < flightPlan.GetExtractedRoute().GetPointsNumber(); ++i) {
|
||||||
for (int i = 1; i < flightPlan.GetPositionPredictions().GetPointsNumber(); ++i) {
|
if (direct == flightPlan.GetExtractedRoute().GetPointName(i)) {
|
||||||
const double distance = flightPlan.GetPositionPredictions().GetPosition(i).DistanceTo(currentPosition);
|
directBehindIAF = iafRouteIndex < i;
|
||||||
const double headingDelta = std::abs(radarTarget.GetPosition().GetReportedHeading() - flightPlan.GetPositionPredictions().GetPosition(i).DirectionTo(iafPosition));
|
break;
|
||||||
|
}
|
||||||
/*
|
}
|
||||||
* 1. no direct way to IAF -> some direct given -> stop after lateral passing
|
|
||||||
* 2. passed the IAF on a way to a direct
|
|
||||||
*/
|
|
||||||
if ((90.0 < headingDelta && 270.0 > headingDelta) || iafDistance < distance)
|
|
||||||
break;
|
|
||||||
|
|
||||||
distanceToIaf += distance;
|
|
||||||
currentPosition = flightPlan.GetPositionPredictions().GetPosition(i);
|
|
||||||
}
|
}
|
||||||
if (0.01f >= std::abs(distanceToIaf))
|
|
||||||
distanceToIaf = iafDistance;
|
if (true == directBehindIAF) {
|
||||||
report->set_distancetoiaf(static_cast<int>(std::round(distanceToIaf)));
|
PlugIn::distanceToPredictedIaf(radarTarget, flightPlan, iafPosition, report);
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
const GeoCoordinate iaf(static_cast<float>(iafPosition.m_Longitude) * degree, static_cast<float>(iafPosition.m_Latitude) * degree);
|
||||||
|
const Velocity groundspeed = static_cast<float>(radarTarget.GetGS()) * knot;
|
||||||
|
Length distanceToIaf;
|
||||||
|
const auto idx = Inbound::matchToPredictedPath(flightPlan.GetPositionPredictions(), iaf, groundspeed, distanceToIaf);
|
||||||
|
|
||||||
|
/* not inbound the IAF -> check if we passed it */
|
||||||
|
if (flightPlan.GetPositionPredictions().GetPointsNumber() <= idx)
|
||||||
|
PlugIn::distanceToPredictedIaf(radarTarget, flightPlan, iafPosition, report);
|
||||||
|
else
|
||||||
|
report->set_distancetoiaf(static_cast<int>(std::round(distanceToIaf.convert(nauticmile))));
|
||||||
|
}
|
||||||
|
|
||||||
|
this->DisplayUserMessage("TEST", "TEST", (radarTarget.GetCallsign() + std::string(": ") + std::to_string(report->distancetoiaf())).c_str(), true, true, false, false, false);
|
||||||
}
|
}
|
||||||
report->set_destination(std::string(destination));
|
report->set_destination(std::string(destination));
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user