]> git.mxchange.org Git - flightgear.git/blobdiff - src/Navaids/procedure.cxx
commradio: improvements for atis speech
[flightgear.git] / src / Navaids / procedure.cxx
index be3df320436af163ed363a62f647e8e0df78e297..96f8a77d77176e40db9f30063ca29c54dbb1d52f 100644 (file)
@@ -24,6 +24,7 @@
 
 #include <simgear/structure/exception.hxx>
 
+#include <Airports/runways.hxx>
 #include <Navaids/waypoint.hxx>
 
 using std::string;
@@ -49,6 +50,14 @@ Approach::Approach(const string& aIdent, ProcedureType ty) :
 {
 
 }
+    
+Approach* Approach::createTempApproach(const std::string& aIdent, FGRunway* aRunway, const WayptVec& aPath)
+{
+    Approach* app = new Approach(aIdent, PROCEDURE_APPROACH_RNAV);
+    app->setRunway(aRunway);
+    app->setPrimaryAndMissed(aPath, WayptVec());
+    return app;
+}
 
 void Approach::setRunway(FGRunwayRef aRwy)
 {
@@ -106,7 +115,7 @@ bool Approach::route(WayptRef aIAF, WayptVec& aWps)
     } // of transitions iteration
     
     if (!haveTrans) {
-      SG_LOG(SG_GENERAL, SG_INFO, "approach " << ident() << " has no transition " <<
+      SG_LOG(SG_NAVAID, SG_INFO, "approach " << ident() << " has no transition " <<
         "for IAF: " << aIAF->ident());
       return false;
     }
@@ -118,7 +127,9 @@ bool Approach::route(WayptRef aIAF, WayptVec& aWps)
 bool Approach::routeFromVectors(WayptVec& aWps)
 {
   aWps.insert(aWps.end(), _primary.begin(), _primary.end());
-  aWps.push_back(new RunwayWaypt(_runway, NULL));
+  RunwayWaypt* rwy = new RunwayWaypt(_runway, NULL);
+  rwy->setFlag(WPT_APPROACH);
+  aWps.push_back(rwy);
   aWps.insert(aWps.end(), _missed.begin(), _missed.end());
   return true;
 }
@@ -150,7 +161,7 @@ bool ArrivalDeparture::isForRunway(const FGRunway* aWay) const
   }
   
   FGRunwayRef r(const_cast<FGRunway*>(aWay));
-  return (_runways.count(r));
+  return (_runways.count(r) > 0);
 }
 
 RunwayVec ArrivalDeparture::runways() const
@@ -240,7 +251,7 @@ bool ArrivalDeparture::commonRoute(Transition* t, WayptVec& aPath, FGRunwayRef a
     return true;
   }
   
-  SG_LOG(SG_GENERAL, SG_INFO, ident() << " using runway transition for " << r->first->ident());
+  SG_LOG(SG_NAVAID, SG_INFO, ident() << " using runway transition for " << r->first->ident());
   r->second->route(aPath);
   return true;
 }
@@ -254,7 +265,7 @@ Transition* ArrivalDeparture::findTransitionByEnroute(Waypt* aEnroute) const
   WptTransitionMap::const_iterator eit;
   for (eit = _enrouteTransitions.begin(); eit != _enrouteTransitions.end(); ++eit) {
     if (eit->second->enroute()->matches(aEnroute)) {
-      SG_LOG(SG_GENERAL, SG_INFO, ident() << " using enroute transition " << eit->second->ident());
+      SG_LOG(SG_NAVAID, SG_INFO, ident() << " using enroute transition " << eit->second->ident());
       return eit->second;
     }
   } // of enroute transition iteration
@@ -266,7 +277,7 @@ WayptRef ArrivalDeparture::findBestTransition(const SGGeod& aPos) const
 {
   // no transitions, that's easy
   if (_enrouteTransitions.empty()) {
-    SG_LOG(SG_GENERAL, SG_INFO, "no enroute transitions for " << ident());
+    SG_LOG(SG_NAVAID, SG_INFO, "no enroute transitions for " << ident());
     return _common.front();
   }
   
@@ -275,7 +286,7 @@ WayptRef ArrivalDeparture::findBestTransition(const SGGeod& aPos) const
   WptTransitionMap::const_iterator eit;
   for (eit = _enrouteTransitions.begin(); eit != _enrouteTransitions.end(); ++eit) {
     WayptRef c = eit->second->enroute();
-    SG_LOG(SG_GENERAL, SG_INFO, "findBestTransition for " << ident() << ", looking at " << c->ident());
+    SG_LOG(SG_NAVAID, SG_INFO, "findBestTransition for " << ident() << ", looking at " << c->ident());
     // assert(c->hasFixedPosition());
     double cd = SGGeodesy::distanceM(aPos, c->position());
     
@@ -311,7 +322,7 @@ SID::SID(const string& aIdent, FGAirport* apt) :
 bool SID::route(FGRunwayRef aWay, Transition* trans, WayptVec& aPath)
 {
   if (!isForRunway(aWay)) {
-    SG_LOG(SG_GENERAL, SG_WARN, "SID " << ident() << " not for runway " << aWay->ident());
+    SG_LOG(SG_NAVAID, SG_WARN, "SID " << ident() << " not for runway " << aWay->ident());
     return false;
   }
   
@@ -327,6 +338,19 @@ bool SID::route(FGRunwayRef aWay, Transition* trans, WayptVec& aPath)
 
   return true;
 }
+    
+SID* SID::createTempSID(const std::string& aIdent, FGRunway* aRunway, const WayptVec& aPath)
+{
+// flip waypoints since SID stores them reversed
+    WayptVec path;
+    std::back_insert_iterator<WayptVec> bi(path);
+    std::reverse_copy(aPath.begin(), aPath.end(), bi);
+    
+    SID* sid = new SID(aIdent, aRunway->airport());
+    sid->setCommon(path);
+    sid->addRunway(aRunway);
+    return sid;
+}
 
 ////////////////////////////////////////////////////////////////////////////