Route Manager internals
Internal documentation for people wanting to work with the [route manager].
The major change in the route manager is that waypoints are no longer popped when they are sequenced. Instead, the current waypoint index is incremented. This change is necessary to allow the route manager to function as the flight plan backend of real-world GPS and navigation devices, which, for example, show previous waypoints and route on a moving map display.
Since most real navigation systems deal in legs, not waypoints, the active leg is defined as that between waypoints[currentWpt - 1] and waypoints[currentWpt]. This is why current waypoint property is initialised to '1' on activating a route, and why activating a route adds the current location (usually the departure runway) as waypoint 0 - taken together, the user and GPS see the expected first leg from the runway to the first waypoint they entered.
To keep older aircraft and instruments work, the properties wp, wp and wp-last are maintained, implicitly updated to refer to the current waypoint, the next waypoint and the final waypoint.