From ec4f2f59c92f073d99dc4109e497c1e7119eac98 Mon Sep 17 00:00:00 2001
From: James Turner <zakalawe@mac.com>
Date: Wed, 9 May 2012 09:39:33 +0100
Subject: [PATCH] Airways routing is driven via Nasal now.

---
 src/Autopilot/route_mgr.cxx | 72 -------------------------------------
 src/Autopilot/route_mgr.hxx | 16 ---------
 2 files changed, 88 deletions(-)

diff --git a/src/Autopilot/route_mgr.cxx b/src/Autopilot/route_mgr.cxx
index 7aa3b15fc..39778e393 100644
--- a/src/Autopilot/route_mgr.cxx
+++ b/src/Autopilot/route_mgr.cxx
@@ -51,7 +51,6 @@
 #include "Main/fg_props.hxx"
 #include "Navaids/positioned.hxx"
 #include <Navaids/waypoint.hxx>
-#include <Navaids/airways.hxx>
 #include <Navaids/procedure.hxx>
 #include "Airports/simple.hxx"
 #include "Airports/runways.hxx"
@@ -290,9 +289,6 @@ void FGRouteMgr::init() {
   cruise->getChild("speed-kts", 0, true);
   cruise->setDoubleValue("speed-kts", 160.0);
   
-  _routingType = cruise->getChild("routing", 0, true);
-  _routingType->setIntValue(ROUTE_HIGH_AIRWAYS);
-  
   totalDistance = fgGetNode(RM "total-distance", true);
   totalDistance->setDoubleValue(0.0);
   distanceToGo = fgGetNode(RM "distance-remaining-nm", true);
@@ -592,69 +588,6 @@ void FGRouteMgr::removeLegAtIndex(int aIndex)
   _plan->deleteIndex(aIndex);
 }
   
-/**
- * route between index-1 and index, using airways.
- */
-bool FGRouteMgr::routeToIndex(int index, RouteType aRouteType)
-{
-  WayptRef wp1;
-  WayptRef wp2;
-  
-  if (index == -1) {
-    index = numLegs();
-  }
-  
-  if (index == 0) {
-    if (!_plan->departureAirport()) {
-      SG_LOG(SG_AUTOPILOT, SG_WARN, "routeToIndex: no departure set");
-      return false;
-    }
-    
-    wp1 = new NavaidWaypoint(_plan->departureAirport().get(), NULL);
-  } else {
-    wp1 = wayptAtIndex(index - 1);
-  }
-  
-  if (index >= numLegs()) {
-    if (!_plan->destinationAirport()) {
-      SG_LOG(SG_AUTOPILOT, SG_WARN, "routeToIndex: no destination set");
-      return false;
-    }
-    
-    wp2 = new NavaidWaypoint(_plan->destinationAirport().get(), NULL);
-  } else {
-    wp2 = wayptAtIndex(index);
-  }
-  
-  double distNm = SGGeodesy::distanceNm(wp1->position(), wp2->position());
-  if (distNm < 100.0) {
-    SG_LOG(SG_AUTOPILOT, SG_INFO, "routeToIndex: existing waypoints are nearby, direct route");
-    return true;
-  }
-  
-  WayptVec r;
-  switch (aRouteType) {
-  case ROUTE_HIGH_AIRWAYS:
-    Airway::highLevel()->route(wp1, wp2, r);
-    break;
-    
-  case ROUTE_LOW_AIRWAYS:
-    Airway::lowLevel()->route(wp1, wp2, r);
-    break;
-    
-  case ROUTE_VOR:
-    throw sg_exception("VOR routing not supported yet");
-  }
-  
-  if (r.empty()) {
-    SG_LOG(SG_AUTOPILOT, SG_INFO, "routeToIndex: no route found");
-    return false;
-  }
-
-  _plan->insertWayptsAtIndex(r, index);
-  return true;
-}
-
 void FGRouteMgr::departureChanged()
 {
   _plan->clearWayptsWithFlag(WPT_DEPARTURE);
@@ -849,11 +782,6 @@ void FGRouteMgr::InputListener::valueChanged(SGPropertyNode *prop)
             r++;
         if (*r)
             mgr->flightPlan()->insertWayptAtIndex(mgr->waypointFromString(r), pos);
-    } else if (!strncmp(s, "@ROUTE", 6)) {
-      char* r;
-      int endIndex = strtol(s + 6, &r, 10);
-      RouteType rt = (RouteType) mgr->_routingType->getIntValue();
-      mgr->routeToIndex(endIndex, rt);
     } else if (!strcmp(s, "@POSINIT")) {
       mgr->initAtPosition();
     } else
diff --git a/src/Autopilot/route_mgr.hxx b/src/Autopilot/route_mgr.hxx
index bb885c7df..f3c939f0e 100644
--- a/src/Autopilot/route_mgr.hxx
+++ b/src/Autopilot/route_mgr.hxx
@@ -57,20 +57,6 @@ public:
   void unbind ();
   void update (double dt);
   
-  typedef enum {
-    ROUTE_HIGH_AIRWAYS, ///< high-level airways routing
-    ROUTE_LOW_AIRWAYS, ///< low-level airways routing
-    ROUTE_VOR ///< VOR-VOR routing
-  } RouteType;
-  
-  /**
-   * Insert waypoints from index-1 to index. In practice this means you can
-   * 'fill in the gaps' between defined waypoints. If index=0, the departure
-   * airport is used as index-1; if index is -1, the destination airport is
-   * used as the final waypoint.
-   */
-  bool routeToIndex(int index, RouteType aRouteType);
-        
   bool isRouteActive() const;
          
   int currentIndex() const;
@@ -156,8 +142,6 @@ private:
     SGPropertyNode_ptr _pathNode;
     SGPropertyNode_ptr _currentWpt;
     
-    /// integer property corresponding to the RouteType enum
-    SGPropertyNode_ptr _routingType;
     
     /** 
      * Signal property to notify people that the route was edited