Flightplan stringing: if the last waypoint of a SID is found en-route, then we delete all preceeding points according to the manual
This commit is contained in:
parent
8bbe755c7c
commit
252501a0ca
2 changed files with 23 additions and 5 deletions
|
@ -55,7 +55,26 @@ var A320RouteManagerDelegate = {
|
|||
# and we have a SID
|
||||
var sid = me.flightplan.sid;
|
||||
logprint(LOG_INFO, 'routing via SID ' ~ sid.id);
|
||||
me.flightplan.insertWaypoints(sid.route(me.flightplan.departure_runway, me.flightplan.sid_trans), 1);
|
||||
|
||||
var wps = sid.route(me.flightplan.departure_runway, me.flightplan.sid_trans);
|
||||
var lastWP = wps[-1];
|
||||
var foundIdx = -999;
|
||||
|
||||
for (var wptIdx = 0; wptIdx < me.flightplan.getPlanSize(); wptIdx = wptIdx + 1) {
|
||||
if (me.flightplan.getWP(wptIdx).id == lastWP.id) {
|
||||
foundIdx = wptIdx;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
if (foundIdx != -999) {
|
||||
while (foundIdx > 0) {
|
||||
me.flightplan.deleteWP(1);
|
||||
foundIdx -= 1;
|
||||
}
|
||||
}
|
||||
|
||||
me.flightplan.insertWaypoints(wps, 1);
|
||||
|
||||
for (var wpIdx = 0; wpIdx < me.flightplan.getPlanSize(); wpIdx = wpIdx + 1) {
|
||||
if (me.flightplan.getWP(wpIdx).wp_type == "vectors" and (me.flightplan.getWP(wpIdx + 1) == nil or me.flightplan.getWP(wpIdx + 1).wp_type != "discontinuity")) {
|
||||
|
|
|
@ -403,17 +403,16 @@ var flightPlanController = {
|
|||
deleteWP: func(index, n, a = 0) { # a = 1, means adding a waypoint via deleting intermediate
|
||||
var wp = me.flightplans[n].getWP(index);
|
||||
if ((left(wp.wp_name, 4) != FMGCInternal.depApt and left(wp.wp_name, 4) != FMGCInternal.arrApt) and me.flightplans[n].getPlanSize() > 2) {
|
||||
|
||||
if (me.flightplans[n].getWP(index).id != "DISCONTINUITY" and a == 0) { # if it is a discont, don't make a new one
|
||||
if (wp.id != "DISCONTINUITY" and a == 0) { # if it is a discont, don't make a new one
|
||||
me.flightplans[n].deleteWP(index);
|
||||
fmgc.windController.deleteWind(n, index);
|
||||
if (me.flightplans[n].getWP(index) != nil) {
|
||||
if (me.flightplans[n].getWP(index) != nil) { # This refers to the next one after the one we deleted
|
||||
if (me.flightplans[n].getWP(index).id != "DISCONTINUITY") { # else, if the next one isn't a discont, add one
|
||||
me.addDiscontinuity(index, n);
|
||||
}
|
||||
}
|
||||
} else {
|
||||
if (me.flightplans[n].getWP(index).id == "DISCONTINUITY" and index > 0 and (me.flightplans[n].getWP(index - 1).id == "PPOS" or find(me.flightplans[n].getWP(index - 1).id, "VECTORS"))) {
|
||||
if (wp.id == "DISCONTINUITY" and index > 0 and (me.flightplans[n].getWP(index - 1).id == "PPOS" or find("VECTORS", me.flightplans[n].getWP(index - 1).id) != -1)) {
|
||||
return 1;
|
||||
} else {
|
||||
me.flightplans[n].deleteWP(index);
|
||||
|
|
Loading…
Reference in a new issue