25#include <simgear/structure/exception.hxx>
39 for (
unsigned int i=0;
i<wps.size(); ++
i) {
40 wps[
i]->setFlag(f,
true);
61 app->setRunway(aRunway);
62 app->setPrimaryAndMissed(aPath,
WayptVec());
73 return _runway->airport();
83void Approach::setPrimaryAndMissed(
const WayptVec& aPrimary,
const WayptVec& aMissed)
86 _primary[0]->setFlag(
WPT_IAF,
true);
87 _primary[_primary.size()-1]->setFlag(
WPT_FAF,
true);
92 if (!_missed.empty()) {
94 _missed[0]->setFlag(
WPT_MAP,
true);
100void Approach::addTransition(
Transition* aTrans)
103 _transitions[entry] = aTrans;
120 bool haveTrans =
false;
121 for (
auto te : _transitions) {
123 if (t->enroute()->matches(aIAF)) {
131 if (_primary.front()->matches(aIAF)) {
137 SG_LOG(SG_NAVAID, SG_INFO,
"approach " <<
ident() <<
" has no transition " <<
138 "for IAF: " << aIAF->ident());
145 if (ok && !aWps.empty() && aIAF.valid() && aWps.front()->matches(aIAF)) {
148 aWps.erase(aWps.begin());
156 aWps.insert(aWps.end(), _primary.begin(), _primary.end());
160 aWps.insert(aWps.end(), _missed.begin(), _missed.end());
172 r.reserve(_transitions.size());
173 for (
const auto& t : _transitions) {
174 r.push_back(t.second->ident());
181 auto it = std::find_if(_transitions.begin(), _transitions.end(), [aIdent](
const WptTransitionMap::value_type& t) {
182 return aIdent == t.second->ident();
185 if (it == _transitions.end())
201 assert(aWay->airport() == _airport);
219 RunwayTransitionMap::const_iterator it =
_runways.begin();
220 for (; it !=
_runways.end(); ++it) {
221 r.push_back(it->first);
227void ArrivalDeparture::addTransition(
Transition* aTrans)
231 _enrouteTransitions[entry] = aTrans;
237 WptTransitionMap::const_iterator eit;
238 for (eit = _enrouteTransitions.begin(); eit != _enrouteTransitions.end(); ++eit) {
239 r.push_back(eit->second->ident());
246 assert(aWay->ident() == aTrans->
ident());
248 throw sg_io_exception(
"adding transition for unspecified runway:" + aWay->ident(),
ident());
266 WayptVec::iterator firstCommon = _common.begin();
271 for (; firstCommon != _common.end(); ++firstCommon) {
272 if ((*firstCommon)->matches(transEnd)) {
281 firstCommon = _common.begin();
287 aPath.insert(aPath.end(), firstCommon, _common.end());
294 RunwayTransitionMap::iterator r =
_runways.find(aRwy);
310 SG_LOG(SG_NAVAID, SG_INFO,
ident() <<
" using runway transition for " << r->first->ident());
311 r->second->route(aPath);
321 WptTransitionMap::const_iterator eit;
322 for (eit = _enrouteTransitions.begin(); eit != _enrouteTransitions.end(); ++eit) {
323 if (eit->second->enroute()->matches(aEnroute)) {
337 WptTransitionMap::const_iterator eit;
338 for (eit = _enrouteTransitions.begin(); eit != _enrouteTransitions.end(); ++eit) {
339 if (eit->second->enroute()->matches(aEnroute)) {
350 if (_enrouteTransitions.empty()) {
351 SG_LOG(SG_NAVAID, SG_INFO,
"no enroute transitions for " <<
ident());
352 return _common.front();
357 WptTransitionMap::const_iterator eit;
358 for (eit = _enrouteTransitions.begin(); eit != _enrouteTransitions.end(); ++eit) {
359 WayptRef c = eit->second->enroute();
360 SG_LOG(SG_NAVAID, SG_INFO,
"findBestTransition for " <<
ident() <<
", looking at " << c->ident());
362 double cd = SGGeodesy::distanceM(aPos, c->position());
376 WptTransitionMap::const_iterator eit;
377 for (eit = _enrouteTransitions.begin(); eit != _enrouteTransitions.end(); ++eit) {
378 if (eit->second->ident() == aIdent) {
388SID::SID(
const string& aIdent,
FGAirport* apt) :
396 SG_LOG(SG_NAVAID, SG_WARN,
"SID " <<
ident() <<
" not for runway " << aWay->ident());
407 std::back_insert_iterator<WayptVec> bi(aPath);
408 std::reverse_copy(path.begin(), path.end(), bi);
417 std::back_insert_iterator<WayptVec> bi(path);
418 std::reverse_copy(aPath.begin(), aPath.end(), bi);
420 SID* sid =
new SID(aIdent, aRunway->
airport());
428STAR::STAR(
const string& aIdent,
FGAirport* apt) :
452void Transition::setPrimary(
const WayptVec& aWps)
455 assert(!_primary.empty());
461 assert(!_primary.empty());
467 assert(!_primary.empty());
468 return _primary[_primary.size() - 1];
473 aPath.insert(aPath.end(), _primary.begin(), _primary.end());
479 return _parent->airport();
SGSharedPtr< FGRunway > FGRunwayRef
FGAirportRef airport() const
Transition * findTransitionByName(const std::string &aIdent) const
virtual FGAirport * airport() const
static Approach * createTempApproach(const std::string &aIdent, FGRunway *aRunway, const WayptVec &aPath)
static bool isApproach(ProcedureType ty)
bool routeFromVectors(WayptVec &aWps)
Build route as above, but ignore transitions, and assume radar vectoring to the start of main approac...
string_list transitionIdents() const
virtual RunwayVec runways() const
bool routeWithTransition(FGRunwayRef runway, Transition *trans, WayptVec &aWps)
bool route(FGRunwayRef runway, WayptRef aIAF, WayptVec &aWps)
Build a route from a valid IAF to the runway, including the missed segment.
virtual bool isForRunway(const FGRunway *aWay) const
Predicate, test if this procedure applies to the requested runway.
virtual WayptFlag flagType() const =0
ArrivalDeparture(const std::string &aIdent, FGAirport *apt)
RunwayTransitionMap _runways
void addRunway(FGRunwayRef aRwy)
string_list transitionIdents() const
bool commonRoute(Transition *t, WayptVec &aPath, FGRunwayRef aRwy)
void setCommon(const WayptVec &aWps)
Transition * findTransitionByEnroute(FGPositioned *aEnroute) const
WayptRef findBestTransition(const SGGeod &aPos) const
Given an enroute location, find the best enroute transition point for this arrival/departure.
virtual RunwayVec runways() const
Transition * findTransitionByName(const std::string &aIdent) const
Find an enroute transition waypoint by identifier.
virtual std::string ident() const
Procedure(const std::string &aIdent)
Waypoint based upon a runway.
virtual bool route(FGRunwayRef aWay, Transition *aTrans, WayptVec &aPath)
Find a path between the runway and enroute structure.
static SID * createTempSID(const std::string &aIdent, FGRunway *aRunway, const WayptVec &aPath)
virtual bool route(FGRunwayRef aWay, Transition *aTrans, WayptVec &aPath)
Find a path between the runway and enroute structure.
Encapsulate a transition segment.
bool route(WayptVec &aPath)
WayptRef procedureEnd() const
Return the procedure end of the transition.
virtual FGAirport * airport() const
WayptRef enroute() const
Return the enroute end of the transition.
Abstract base class for waypoints (and things that are treated similarly by navigation systems).
void setFlag(WayptFlag aFlag, bool aV=true)
std::vector< std::string > string_list
FlightPlan.hxx - defines a full flight-plan object, including departure, cruise, arrival information ...
SGSharedPtr< Waypt > WayptRef
@ WPT_MAP
missed approach point
@ WPT_MISS
segment is part of missed approach
@ WPT_TRANSITION
transition to/from enroute structure
@ WPT_FAF
final approach fix
@ WPT_IAF
initial approach fix
std::vector< WayptRef > WayptVec
@ PROCEDURE_APPROACH_RNAV
std::vector< FGRunwayRef > RunwayVec
static void markWaypoints(WayptVec &wps, WayptFlag f)