1
0
Fork 0

Location-in-Air: pick nearest VOR/NDB (fix#228)

When entering a duplicate VOR or NDB id into the Location-in-Air
dialog, the first entry in the database was picked. This patch
assumes that the station with the given ID nearest to the current
position was requested.
A better fix would probably be to present the user a list of found
stations - that's something for the future.
This commit is contained in:
Torsten Dreyer 2011-08-22 20:01:55 +02:00
parent 793067301c
commit 65b1fd20e7

View file

@ -6,8 +6,8 @@
<nasal>
<open>
p = props.globals.getNode("/sim/gui/dialogs/location-in-air/", 1);
mode = {
var p = props.globals.getNode("/sim/gui/dialogs/location-in-air/", 1);
var mode = {
airport: p.getNode("airport", 1),
lonlat: p.getNode("lonlat", 1),
vor: p.getNode("vor", 1),
@ -15,14 +15,14 @@
fix: p.getNode("fix", 1),
};
set_radio = func(m) {
foreach (k; keys(mode)) {
var set_radio = func(m) {
foreach (var k; keys(mode)) {
mode[k].setBoolValue(m == k);
}
}
initialized = 0;
foreach (k; keys(mode)) {
var initialized = 0;
foreach (var k; keys(mode)) {
if (mode[k].getType() == "NONE") {
mode[k].setBoolValue(0);
}
@ -31,6 +31,19 @@
if (!initialized) {
set_radio("airport");
}
var pickNearest = func(type,propname,freqpropname) {
var found = navinfo(type,getprop(propname));
if( found == nil or size(found) == 0 ) {
print(type, " ", getprop(propname), " NOT found");
setprop(propname, "");
setprop(freqpropname, "");
return;
}
setprop(propname, found[0].id);
setprop(freqpropname, found[0].frequency / 100.0);
}
</open>
<close># just kept for educational purposes :-)</close>
@ -300,10 +313,14 @@
if (!mode.vor.getBoolValue()) {
setprop("/sim/presets/vor-id", "");
} else {
pickNearest("vor","/sim/presets/vor-id","/sim/presets/vor-freq");
}
if (!mode.ndb.getBoolValue()) {
setprop("/sim/presets/ndb-id", "");
} else {
pickNearest("ndb","/sim/presets/ndb-id","/sim/presets/ndb-freq");
}
if (!mode.fix.getBoolValue()) {