As many have probably noticed, I have been documenting the Nasal library (hist). While testing some APIs that search for an object using an ID/code, namely findFixesByID() and findNavaidsByID(), I discovered a bug in both (although they are quite similar and probably related): inputting partial IDs/codes doesn't work as expected.
findFixesByID():
- Code: Select all
# Expected result: Print all fix IDs beginning with "B"
# Actual result: Prints just one ID, but it is "B," which isn't a valid fix name
var fixes = findFixesByID("B");
foreach(var fix; fixes){
print("ID: ", fix.id);
}
- Code: Select all
# Expected result: Print all fix IDs beginning with "N"
# Actual result: Prints a list of IDs, but all of them are "N," which isn't a valid fix name
var fixes = findFixesByID("N");
foreach(var fix; fixes){
print("ID: ", fix.id);
}
- Code: Select all
# Expected result: Print all fix IDs beginning with "ZUNA"
# Actual result: Prints nothing; should at least print "ZUNAP" (a real fix)
var fixes = findFixesByID("ZUNA");
foreach(var fix; fixes){
print("ID: ", fix.id);
}
- Code: Select all
# Expected result: Print "ZUNAP"
# Actual result: Works as expected (prints "ZUNAP")
var fixes = findFixesByID("ZUNAP");
foreach(var fix; fixes){
print("ID: ", fix.id); # prints "ZUNAP"
}
findNavaidsByID():
- Code: Select all
# Expected result: Print all navaid codes beginning with "K"
# Actual result: Prints a list of navaid codes, but all of them are "K"
var fixes = findNavaidsByID("K");
foreach(var fix; fixes){
print("ID: ", fix.id);
}
- Code: Select all
# Expected result: Print all navaid codes containing "MX"
# Actual result: Prints several codes, but they are all "MX"
var fixes = findNavaidsByID("MX");
foreach(var fix; fixes){
print("ID: ", fix.id);
}
- Code: Select all
# Expected result: Print "MXW"
# Actual result: Works as expected (prints "MXW")
var fixes = findNavaidsByID("MXW");
foreach(var fix; fixes){
print("ID: ", fix.id); # prints "MXW"
}
I have looked through the Doxygen documentation, and here's what I think is the solution:
findFixesByID():
The search function that this uses is FGPositioned::findAllWithIdent. One argument is called aExact, which defaults to true. Now, findAirportsByICAO() uses the same function, and behaves correctly, however, it sets this aExact to false. So I think that line 1,641 of src/Scripting/NasalPositioned.cxx needs changing from:
- Code: Select all
FGPositionedList fixes = FGPositioned::findAllWithIdent(ident, &filter);
to
- Code: Select all
FGPositionedList fixes = FGPositioned::findAllWithIdent(ident, &filter, false);
findNavaidsByID():
Very similar to the above, but something needs changing in a different place. Line 272 of src/Navaids/navlist.cxx needs changing from:
- Code: Select all
FGPositionedList stations = FGPositioned::findAllWithIdent(ident, filter);
to
- Code: Select all
FGPositionedList stations = FGPositioned::findAllWithIdent(ident, filter, false);
Hopefully this will solve the problem.
For system specs, see my profile. I am using Scenery 1.0 (from FG 2.12) with custom EGOD scenery from FGUK and no TerraSync.
Regards,
Red Leader
P.S. I know this is in the wrong place for a bug report (I don't have access to SourceForge).