NavDisplay: fix route drawing
This commit is contained in:
parent
38b916a18c
commit
69280a75c9
1 changed files with 56 additions and 49 deletions
|
@ -6,19 +6,19 @@
|
||||||
var wp = [];
|
var wp = [];
|
||||||
var text_wp = [];
|
var text_wp = [];
|
||||||
|
|
||||||
# Change color of active waypoints
|
# Change color of active waypoints
|
||||||
var updatewp = func(activeWp)
|
var updatewp = func(activeWp)
|
||||||
{
|
{
|
||||||
forindex(var i; wp) {
|
forindex(var i; wp) {
|
||||||
if(i == activeWp) {
|
if(i == activeWp) {
|
||||||
wp[i].setColor(1,0,1);
|
wp[i].setColor(1,0,1);
|
||||||
#text_wp[i].setColor(1,0,1);
|
#text_wp[i].setColor(1,0,1);
|
||||||
} else {
|
} else {
|
||||||
wp[i].setColor(1,1,1);
|
wp[i].setColor(1,1,1);
|
||||||
#text_wp[i].setColor(1,1,1);
|
#text_wp[i].setColor(1,1,1);
|
||||||
}
|
|
||||||
}
|
}
|
||||||
};
|
}
|
||||||
|
};
|
||||||
|
|
||||||
var draw_route = func (group, theroute, controller=nil, lod=0)
|
var draw_route = func (group, theroute, controller=nil, lod=0)
|
||||||
{
|
{
|
||||||
|
@ -29,48 +29,55 @@ var draw_route = func (group, theroute, controller=nil, lod=0)
|
||||||
.setStrokeLineWidth(5)
|
.setStrokeLineWidth(5)
|
||||||
.setColor(1,0,1);
|
.setColor(1,0,1);
|
||||||
|
|
||||||
var cmds = [];
|
var cmds = [];
|
||||||
var coords = [];
|
var coords = [];
|
||||||
|
|
||||||
var fp = flightplan();
|
var fp = flightplan();
|
||||||
var fpSize = fp.getPlanSize();
|
var fpSize = fp.getPlanSize();
|
||||||
|
|
||||||
wp = [];
|
wp = [];
|
||||||
text_wp = [];
|
text_wp = [];
|
||||||
setsize(wp,fpSize);
|
setsize(wp,fpSize);
|
||||||
setsize(text_wp,fpSize);
|
setsize(text_wp,fpSize);
|
||||||
|
|
||||||
# Retrieve route coordinates
|
# Retrieve route coordinates
|
||||||
for (var i=0; i<(fpSize); i += 1)
|
for (var i=0; i<(fpSize); i += 1)
|
||||||
{
|
{
|
||||||
if (i == 0) {
|
if (i == 0) {
|
||||||
var leg = fp.getWP(1);
|
var leg = fp.getWP(1);
|
||||||
append(coords,"N"~leg.path()[0].lat);
|
foreach (var pt; leg.path()) {
|
||||||
append(coords,"E"~leg.path()[0].lon);
|
append(coords,"N"~pt.lat);
|
||||||
|
append(coords,"E"~pt.lon);
|
||||||
|
if (i==0){
|
||||||
append(cmds,2);
|
append(cmds,2);
|
||||||
canvas.drawwp(group, leg.path()[0].lat, leg.path()[0].lon, fp.getWP(0).alt_cstr, fp.getWP(0).wp_name, i, wp);
|
|
||||||
i+=1;
|
i+=1;
|
||||||
}
|
} else
|
||||||
var leg = fp.getWP(i);
|
append(cmds,4);
|
||||||
append(coords,"N"~leg.path()[1].lat);
|
|
||||||
append(coords,"E"~leg.path()[1].lon);
|
|
||||||
append(cmds,4);
|
|
||||||
canvas.drawwp(group, leg.path()[1].lat, leg.path()[1].lon, leg.alt_cstr, leg.wp_name, i, wp);
|
|
||||||
}
|
}
|
||||||
|
canvas.drawwp(group, leg.path()[0].lat, leg.path()[0].lon, fp.getWP(0).alt_cstr, fp.getWP(0).wp_name, i, wp);
|
||||||
|
}
|
||||||
|
var leg = fp.getWP(i);
|
||||||
|
foreach (var pt; leg.path()) {
|
||||||
|
append(coords,"N"~pt.lat);
|
||||||
|
append(coords,"E"~pt.lon);
|
||||||
|
append(cmds,4);
|
||||||
|
}
|
||||||
|
canvas.drawwp(group, leg.path()[-1].lat, leg.path()[-1].lon, leg.alt_cstr, leg.wp_name, i, wp);
|
||||||
|
}
|
||||||
|
|
||||||
# Set Top Of Climb coordinate
|
# Set Top Of Climb coordinate
|
||||||
canvas.drawprofile(route_group, "tc", "T/C");
|
canvas.drawprofile(route_group, "tc", "T/C");
|
||||||
# Set Top Of Descent coordinate
|
# Set Top Of Descent coordinate
|
||||||
canvas.drawprofile(route_group, "td", "T/D");
|
canvas.drawprofile(route_group, "td", "T/D");
|
||||||
# Set Step Climb coordinate
|
# Set Step Climb coordinate
|
||||||
canvas.drawprofile(route_group, "sc", "S/C");
|
canvas.drawprofile(route_group, "sc", "S/C");
|
||||||
# Set Top Of Descent coordinate
|
# Set Top Of Descent coordinate
|
||||||
canvas.drawprofile(route_group, "ed", "E/D");
|
canvas.drawprofile(route_group, "ed", "E/D");
|
||||||
|
|
||||||
# Update route coordinates
|
# Update route coordinates
|
||||||
debug.dump(cmds);
|
debug.dump(cmds);
|
||||||
debug.dump(coords);
|
debug.dump(coords);
|
||||||
route.setDataGeo(cmds, coords);
|
route.setDataGeo(cmds, coords);
|
||||||
updatewp(0);
|
updatewp(0);
|
||||||
|
|
||||||
}
|
}
|
Loading…
Reference in a new issue