MapStructure: a few WPT/RTE bugfixes
This commit is contained in:
parent
807062d0b6
commit
501f8ba881
5 changed files with 13 additions and 9 deletions
|
@ -403,6 +403,7 @@ var Symbol = {
|
||||||
# Private constructor:
|
# Private constructor:
|
||||||
_new: func(m) {
|
_new: func(m) {
|
||||||
m.style = m.layer.style;
|
m.style = m.layer.style;
|
||||||
|
m.options = m.layer.options;
|
||||||
if (m.controller != nil) {
|
if (m.controller != nil) {
|
||||||
temp = m.controller.new(m,m.model);
|
temp = m.controller.new(m,m.model);
|
||||||
if (temp != nil)
|
if (temp != nil)
|
||||||
|
|
|
@ -42,12 +42,11 @@ var searchCmd = func {
|
||||||
# http://wiki.flightgear.org/Nasal_Flightplan
|
# http://wiki.flightgear.org/Nasal_Flightplan
|
||||||
var fp = flightplan();
|
var fp = flightplan();
|
||||||
var fpSize = fp.getPlanSize();
|
var fpSize = fp.getPlanSize();
|
||||||
|
if (!getprop(me.layer.options.active_node)) fpSize = 0;
|
||||||
var coords = [];
|
var coords = [];
|
||||||
for (var i=0; i<fpSize; i += 1) {
|
for (var i=0; i<fpSize; i += 1) {
|
||||||
var leg = fp.getWP(i);
|
var leg = fp.getWP(i);
|
||||||
foreach (var c; leg.path()) {
|
coords ~= leg.path();
|
||||||
append(coords, c);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
append(plans, coords);
|
append(plans, coords);
|
||||||
return plans;
|
return plans;
|
||||||
|
|
|
@ -17,6 +17,7 @@ var new = func(layer) {
|
||||||
var m = {
|
var m = {
|
||||||
parents: [__self__],
|
parents: [__self__],
|
||||||
layer: layer,
|
layer: layer,
|
||||||
|
options: layer.options,
|
||||||
map: layer.map,
|
map: layer.map,
|
||||||
listeners: [],
|
listeners: [],
|
||||||
};
|
};
|
||||||
|
@ -33,8 +34,8 @@ var del = func() {
|
||||||
};
|
};
|
||||||
|
|
||||||
var WPT_model = {
|
var WPT_model = {
|
||||||
new: func(fp, idx) {
|
new: func(fp, idx, offset=0) {
|
||||||
var m = { parents:[WPT_model], idx:idx };
|
var m = { parents:[WPT_model], idx:(idx+offset) };
|
||||||
var wp = fp.getWP(idx);
|
var wp = fp.getWP(idx);
|
||||||
|
|
||||||
m.name = wp.wp_name;
|
m.name = wp.wp_name;
|
||||||
|
@ -42,7 +43,8 @@ var WPT_model = {
|
||||||
if (alt != 0)
|
if (alt != 0)
|
||||||
m.name ~= "\n"~alt;
|
m.name ~= "\n"~alt;
|
||||||
|
|
||||||
var n = wp.path()[0];
|
if (idx) var n = wp.path()[-1];
|
||||||
|
else var n = fp.getWP(1).path()[0];
|
||||||
(m.lat,m.lon) = (n.lat,n.lon);
|
(m.lat,m.lon) = (n.lat,n.lon);
|
||||||
return m;
|
return m;
|
||||||
},
|
},
|
||||||
|
@ -55,10 +57,12 @@ var WPT_model = {
|
||||||
var searchCmd = func {
|
var searchCmd = func {
|
||||||
printlog(_MP_dbg_lvl, "Running query: "~name);
|
printlog(_MP_dbg_lvl, "Running query: "~name);
|
||||||
|
|
||||||
|
if (!getprop(me.options.active_node)) return [];
|
||||||
|
|
||||||
var fp = flightplan();
|
var fp = flightplan();
|
||||||
var fpSize = fp.getPlanSize();
|
var fpSize = fp.getPlanSize();
|
||||||
var result = [];
|
var result = [];
|
||||||
for (var i = 1; i < fpSize; i+=1)
|
for (var i = 0; i < fpSize; i+=1)
|
||||||
append(result, WPT_model.new(fp, i));
|
append(result, WPT_model.new(fp, i));
|
||||||
return result;
|
return result;
|
||||||
};
|
};
|
||||||
|
|
|
@ -20,6 +20,7 @@ var new = func(symbol, model) {
|
||||||
symbol.update();
|
symbol.update();
|
||||||
m.last_idx = n;
|
m.last_idx = n;
|
||||||
}, 0, 0));
|
}, 0, 0));
|
||||||
|
m.last_idx = getprop(symbol.layer.options.current_wp_node);
|
||||||
|
|
||||||
return m;
|
return m;
|
||||||
}
|
}
|
||||||
|
|
|
@ -19,7 +19,6 @@ var element_type = "group"; # we want a group, becomes "me.element"
|
||||||
var active = nil;
|
var active = nil;
|
||||||
|
|
||||||
var init = func {
|
var init = func {
|
||||||
# TODO: active vs inactive?
|
|
||||||
me.path = me.element.createChild("path")
|
me.path = me.element.createChild("path")
|
||||||
.setStrokeLineWidth(me.style.line_width)
|
.setStrokeLineWidth(me.style.line_width)
|
||||||
.moveTo(0,-25)
|
.moveTo(0,-25)
|
||||||
|
@ -40,7 +39,7 @@ var init = func {
|
||||||
me.draw();
|
me.draw();
|
||||||
};
|
};
|
||||||
var draw = func {
|
var draw = func {
|
||||||
var active = (getprop(me.layer.options.current_wp_node) == me.model.idx);
|
var active = (getprop(me.options.current_wp_node) == me.model.idx);
|
||||||
if (active != me.active) {
|
if (active != me.active) {
|
||||||
me.path.setColor(
|
me.path.setColor(
|
||||||
active ?
|
active ?
|
||||||
|
|
Loading…
Reference in a new issue