1
0
Fork 0

Improved searching of Runway exits

This commit is contained in:
portree_kid 2021-08-12 22:05:05 +02:00 committed by James Turner
parent 4b7ef90b31
commit 96b9cfabe0

View file

@ -285,8 +285,27 @@ FGTaxiNodeRef FGGroundNetwork::findNearestNodeOnRunway(const SGGeod & aGeod, FGR
for (it = m_nodes.begin(); it != m_nodes.end(); ++it) { for (it = m_nodes.begin(); it != m_nodes.end(); ++it) {
if (!(*it)->getIsOnRunway()) if (!(*it)->getIsOnRunway())
continue; continue;
double localDistanceSqr = distSqr(cartPos, (*it)->cart()); double localDistanceSqr = distSqr(cartPos, (*it)->cart());
if (aRunway) {
double headingTowardsExit = SGGeodesy::courseDeg(aGeod, (*it)->geod());
double diff = fabs(aRunway->headingDeg() - headingTowardsExit);
if (diff > 10) {
// Only ahead
continue;
}
FGTaxiNodeVector exitSegments = findSegmentsFrom((*it));
// Only ends
if (exitSegments.size() != 1) {
continue;
}
double exitHeading = SGGeodesy::courseDeg((*it)->geod(),
(exitSegments.back())->geod());
diff = fabs(aRunway->headingDeg() - exitHeading);
if (diff > 10) {
// Only exits going in our direction
continue;
}
}
if (localDistanceSqr < d) { if (localDistanceSqr < d) {
d = localDistanceSqr; d = localDistanceSqr;
result = *it; result = *it;