2013-12-01 12:29:22 +00:00
|
|
|
##
|
2014-02-04 21:07:35 +00:00
|
|
|
# Draw a route with tracks and waypoints
|
2013-12-01 12:29:22 +00:00
|
|
|
#
|
|
|
|
|
|
|
|
## FIXME: encapsulate properly
|
|
|
|
var wp = [];
|
|
|
|
var text_wp = [];
|
|
|
|
|
2014-02-13 18:36:27 +00:00
|
|
|
# Change color of active waypoints
|
|
|
|
var updatewp = func(activeWp)
|
|
|
|
{
|
|
|
|
forindex(var i; wp) {
|
|
|
|
if(i == activeWp) {
|
|
|
|
wp[i].setColor(1,0,1);
|
|
|
|
#text_wp[i].setColor(1,0,1);
|
|
|
|
} else {
|
|
|
|
wp[i].setColor(1,1,1);
|
|
|
|
#text_wp[i].setColor(1,1,1);
|
2013-12-01 12:29:22 +00:00
|
|
|
}
|
2014-02-13 18:36:27 +00:00
|
|
|
}
|
|
|
|
};
|
2013-12-01 12:29:22 +00:00
|
|
|
|
|
|
|
var draw_route = func (group, theroute, controller=nil, lod=0)
|
|
|
|
{
|
|
|
|
#print("draw_route");
|
|
|
|
var route_group = group;
|
|
|
|
|
|
|
|
var route = route_group.createChild("path","route")
|
|
|
|
.setStrokeLineWidth(5)
|
|
|
|
.setColor(1,0,1);
|
|
|
|
|
2014-02-13 18:36:27 +00:00
|
|
|
var cmds = [];
|
|
|
|
var coords = [];
|
2013-12-01 12:29:22 +00:00
|
|
|
|
2014-02-13 18:36:27 +00:00
|
|
|
var fp = flightplan();
|
|
|
|
var fpSize = fp.getPlanSize();
|
|
|
|
|
|
|
|
wp = [];
|
|
|
|
text_wp = [];
|
|
|
|
setsize(wp,fpSize);
|
|
|
|
setsize(text_wp,fpSize);
|
|
|
|
|
|
|
|
# Retrieve route coordinates
|
|
|
|
for (var i=0; i<(fpSize); i += 1)
|
|
|
|
{
|
|
|
|
if (i == 0) {
|
|
|
|
var leg = fp.getWP(1);
|
2014-02-16 14:12:16 +00:00
|
|
|
var j = 0;
|
2014-02-13 18:36:27 +00:00
|
|
|
foreach (var pt; leg.path()) {
|
|
|
|
append(coords,"N"~pt.lat);
|
|
|
|
append(coords,"E"~pt.lon);
|
2014-02-16 14:12:16 +00:00
|
|
|
if (j==0){
|
2013-12-01 12:29:22 +00:00
|
|
|
append(cmds,2);
|
2014-02-16 14:12:16 +00:00
|
|
|
j=1;
|
2014-02-13 18:36:27 +00:00
|
|
|
} else
|
|
|
|
append(cmds,4);
|
2013-12-01 12:29:22 +00:00
|
|
|
}
|
2014-02-13 18:36:27 +00:00
|
|
|
canvas.drawwp(group, leg.path()[0].lat, leg.path()[0].lon, fp.getWP(0).alt_cstr, fp.getWP(0).wp_name, i, wp);
|
2014-02-16 14:12:16 +00:00
|
|
|
i+=1;
|
2014-02-13 18:36:27 +00:00
|
|
|
}
|
|
|
|
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);
|
|
|
|
}
|
2014-01-26 17:07:18 +00:00
|
|
|
|
2014-02-13 18:36:27 +00:00
|
|
|
# Set Top Of Climb coordinate
|
|
|
|
canvas.drawprofile(route_group, "tc", "T/C");
|
|
|
|
# Set Top Of Descent coordinate
|
|
|
|
canvas.drawprofile(route_group, "td", "T/D");
|
|
|
|
# Set Step Climb coordinate
|
|
|
|
canvas.drawprofile(route_group, "sc", "S/C");
|
|
|
|
# Set Top Of Descent coordinate
|
|
|
|
canvas.drawprofile(route_group, "ed", "E/D");
|
2014-01-26 17:07:18 +00:00
|
|
|
|
2014-02-13 18:36:27 +00:00
|
|
|
# Update route coordinates
|
|
|
|
debug.dump(cmds);
|
|
|
|
debug.dump(coords);
|
|
|
|
route.setDataGeo(cmds, coords);
|
2014-02-23 05:02:28 +00:00
|
|
|
updatewp(getprop("/autopilot/route-manager/current-wp"));
|
2014-01-26 17:07:18 +00:00
|
|
|
|
2014-02-04 21:07:35 +00:00
|
|
|
}
|