From bc09d5e64d53a393bd8148da1bcb3b524f999693 Mon Sep 17 00:00:00 2001 From: James Turner Date: Wed, 12 Jan 2022 22:06:33 +0100 Subject: [PATCH] Airways: findEnroute by Positioned Avoid any ambiguity with naming from the string version --- src/Navaids/airways.cxx | 15 +++++++++++++++ src/Navaids/airways.hxx | 1 + 2 files changed, 16 insertions(+) diff --git a/src/Navaids/airways.cxx b/src/Navaids/airways.cxx index ccb8a8fca..18e120de9 100644 --- a/src/Navaids/airways.cxx +++ b/src/Navaids/airways.cxx @@ -398,6 +398,21 @@ WayptRef Airway::findEnroute(const std::string &aIdent) const return {}; } +WayptRef Airway::findEnroute(const FGPositionedRef& nav) const +{ + loadWaypoints(); + auto it = std::find_if(_elements.begin(), _elements.end(), + [&nav](WayptRef w) + { + if (!w) return false; + return w->source() == nav; + }); + + if (it != _elements.end()) + return *it; + return {}; +} + void Airway::Network::addEdge(int aWay, const SGGeod& aStartPos, const std::string& aStartIdent, const SGGeod& aEndPos, const std::string& aEndIdent) diff --git a/src/Navaids/airways.hxx b/src/Navaids/airways.hxx index 5441dda03..ea4a5d7a4 100644 --- a/src/Navaids/airways.hxx +++ b/src/Navaids/airways.hxx @@ -90,6 +90,7 @@ public: bool containsNavaid(const FGPositionedRef& navaid) const; + WayptRef findEnroute(const FGPositionedRef& navaid) const; /**