Reviewing merge request #14: extend airportinfo() and navinfo().
The airportinfo() and navinfo() functions in Nasal are second class citizens to their C++ counterparts, with Nasal used to prototype functionality in glass cockpits.
This patch provides a backward compatible extended function parameter list to allow greater access to apt.dat and nav.dat data.
1. The groundradar texture is centred on the tower position at a airport, add the tower position to the HashSet values returned.
2. Extends airportinfo() with optional parameters;
airportinfo([lat, lon], {type | id}, [range])
3. Extends navinfo() with optional parameters;
navinfo([lat, lon], {type [, range] | [frequency,] id})
Examples:
# find single airport by ICAO
var apt = airportinfo("YSSY");
debug.dump(apt);
# find single nearest airport
var aptNear = airportinfo("airport");
print("find nearest airport");
debug.dump(aptNear);
# find "vor" within 5.0nm of apt (YSSY)
var navList1 = navinfo(apt.lat, apt.lon, "vor", 5.0);
print("navList1 size: "~size(navList1));
debug.dump(navList1);
# find "ils" within 5.0nm of apt (YSSY)
var navList2 = navinfo(apt.lat, apt.lon, "ils", 5.0);
print("navList2 ils info");
debug.dump(navList2);
# find all navaids starting with 'HAM'
var navList3 = navinfo("HAM");
print("navList3 id 'HAM'");
debug.dump(navList3);
# find all "vor" within 5.0nm of current position
var navList4 = navinfo("vor", 5.0);
print("navList4 size: "~size(navList4));
debug.dump(navList4);
# find all "vor" starting with 'SY' ordered by distance from apt (YSSY)
var navList5 = navinfo(apt.lat, apt.lon, "vor", "SY");
print("navList5 size: "~size(navList5));
debug.dump(navList5);
# find all navaids with frequency 112.50 starting with 'SY'
var navList6 = navinfo(112.50, "SY");
print("navList6 size: "~size(navList6));
debug.dump(navList6);
# find all airports within 20nm of current position
var aptList1 = airportinfo("airport", 20.0);
print("aptList1 size: "~size(aptList1));
debug.dump(aptList1);
# find all airports within 20nm of Hamburg (index 2 of the VOR list starting with 'HAM')
var hLat = navList3[2].lat;
var hLon = navList3[2].lon;
var aptList2 = airportinfo(hLat, hLon, "airport", 20.0);
print("aptList2 near HAM size: "~size(aptList2));
debug.dump(aptList2);
# find all airports within 20nm of EGLL
var aptList3 = airportinfo("EGLL", 20.0);
print("all airports within 20nm of EGLL size: "~size(aptList3));
debug.dump(aptList3)
Commits that would be merged:
- 8b340ff
- 394a4d7
Add extra values to HashSet for airportinfo(), provide backward compatible extensions to airportinfo() and navinfo() to help glass cockpit
8b340ff-394a4d7Comments
Pushed new version 1
Whoops, completely forgot about this. Is it still relevant?
I have some design changes – basically I'd suggest new front-end functions:
find_airport_near(lat, lon)
find_navaid_by_frequency(frequency, lat, lon)
.. and some others..
Because the overloading of different combinations of arguments is very confusing, especially in an untyped language such as Nasal. If you could suggest what combinations of position / range / ident / frequency are actually useful, we can add those and leave the existing navinfo / airport info alone for compatibility.
I'd like to make sure “tower_lat” and “tower_lon” are added to the current airportinfo() hash that is returned, these are useful because the ground radar is centred on the tower.
And I suspect the buildAirportHash(), buildFixHash() and buildNavHash() are still useful.
I’ll discuss with you offline the other methods, I like the idea of having methods that closely follow the C++ interface, is it possible to pass in a filter function then?
S.
Scott and I have discussed and committed something similar, so this request can die now.


Add a new comment:
Login or create an account to post a comment