|
@@ -376,6 +376,7 @@ void PlugIn::generateAircraftReportMessage(EuroScopePlugIn::CRadarTarget& radarT
|
|
|
break;
|
|
|
}
|
|
|
|
|
|
+ int iafRouteIndex = flightPlan.GetExtractedRoute().GetPointsNumber();
|
|
|
auto currentPosition = radarTarget.GetPosition().GetPosition();
|
|
|
EuroScopePlugIn::CPosition iafPosition;
|
|
|
std::string iafName;
|
|
@@ -397,6 +398,7 @@ void PlugIn::generateAircraftReportMessage(EuroScopePlugIn::CRadarTarget& radarT
|
|
|
iafPosition = flightPlan.GetExtractedRoute().GetPointPosition(i);
|
|
|
iafName = flightPlan.GetExtractedRoute().GetPointName(i);
|
|
|
report->set_initialapproachfix(iafName);
|
|
|
+ iafRouteIndex = i;
|
|
|
break;
|
|
|
}
|
|
|
}
|
|
@@ -408,27 +410,35 @@ void PlugIn::generateAircraftReportMessage(EuroScopePlugIn::CRadarTarget& radarT
|
|
|
}
|
|
|
|
|
|
if (0 != iafName.length()) {
|
|
|
- const auto iafDistance = currentPosition.DistanceTo(iafPosition);
|
|
|
-
|
|
|
- /* calculate the distance to the IAF */
|
|
|
- double distanceToIaf = 0.0f;
|
|
|
- for (int i = 1; i < flightPlan.GetPositionPredictions().GetPointsNumber(); ++i) {
|
|
|
- const double distance = flightPlan.GetPositionPredictions().GetPosition(i).DistanceTo(currentPosition);
|
|
|
- const double headingDelta = std::abs(radarTarget.GetPosition().GetReportedHeading() - flightPlan.GetPositionPredictions().GetPosition(i).DirectionTo(iafPosition));
|
|
|
-
|
|
|
- /*
|
|
|
- * 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;
|
|
|
+ const std::string_view direct(flightPlan.GetControllerAssignedData().GetDirectToPointName());
|
|
|
+ bool directBehindIAF = false;
|
|
|
+
|
|
|
+ if (0 != direct.length()) {
|
|
|
+ for (int i = 0; i < flightPlan.GetExtractedRoute().GetPointsNumber(); ++i) {
|
|
|
+ if (direct == flightPlan.GetExtractedRoute().GetPointName(i)) {
|
|
|
+ directBehindIAF = iafRouteIndex < i;
|
|
|
+ break;
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
|
|
|
- distanceToIaf += distance;
|
|
|
- currentPosition = flightPlan.GetPositionPredictions().GetPosition(i);
|
|
|
+ if (true == directBehindIAF) {
|
|
|
+ PlugIn::distanceToPredictedIaf(radarTarget, flightPlan, iafPosition, report);
|
|
|
}
|
|
|
- if (0.01f >= std::abs(distanceToIaf))
|
|
|
- distanceToIaf = iafDistance;
|
|
|
- report->set_distancetoiaf(static_cast<int>(std::round(distanceToIaf)));
|
|
|
+ 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));
|
|
|
|