Jump to content
cw777

Unable to search airports

Recommended Posts

I have this code (where destination is a input from user such as 'egkk', 'egll')


 

nav.setSearchGroups( 1,0,0,0, 0,0,0,0,0,0,0,0 )

navID = nav.findNavAid(string.upper(destination), "*", "*", "*", "*")  
navaid_type, destLat, destLon, alt, ICAO_ID, Name, reg, freq, heading = nav.getNavAidInfo(navID)

console.log(navaid_type..ICAO_ID..Name..reg)

and when I quickly output some of the response data, I get not found (when trying with famous obvious airports like heathrow and gatwick). When I make more searchGroups 1, I do get responses but of irrelevant DMEs, etc. So my question is, How can I retrieve (correct and reliable) airport data based on a ICAO input?

 

Cheers

Share this post


Link to post
Share on other sites

XPLMFindNavAid require six parameters, not five.

As you're using the ICAO code try this:

navID = nav.findNavAid(nil, string.upper(destination), nil, nil, nil, nil)

 

Share this post


Link to post
Share on other sites
10 hours ago, AlfaMike said:

My bad, I thought that it uses the same syntax of XPLMFindNavAid, sorry.

 

Hey, no prob!

To my best of my understanding, Gizmo API has omitted the last parameter of XPLMFindNavAid, which is nav_type, because you have already set that by the nav.setSearchGroups(). 

And if you really think, why Ben put it that way... it makes absolute sense in the long run!

Share this post


Link to post
Share on other sites

Looking again at the documentation the ID parameter is still the 2nd, not the 1st:

Quote

nav.findNavAid( name, id, lat, lon, frequency )

So now I'd try with:

navID = nav.findNavAid(nil, string.upper(destination), nil, nil, nil)

 

Share this post


Link to post
Share on other sites

Thanks for the replies - will try this when i get home. Meanwhile, i also noticed that even when it did find a navaid in JKF (new york) and I was in london, using the trig function that finds distance between two global points would give a decimal answer, which i am (according to docs) meant to multiply by 60 to get in nm. It returned as 72...which is obviously not right. Any ideas? (will get back to you on the airport search). just for further clarification, I used the acf.getPosition() lon and lat, with the lon and lat of the found nav id (have checked those values and they are all correct up untill the output of distancebetweentwoglobalpoints*60)

Many thanks.

Share this post


Link to post
Share on other sites

That's the code i'm using to calculate the distance from the aircraft to next waypoint:

    distances_tbl[1] = trig.distanceBetweenWorldPoints(acft_pos[1], acft_pos[2],
        fmc_info[fmc.getDestination()][2], fmc_info[fmc.getDestination()][3]) * 60

 

 

Share this post


Link to post
Share on other sites

Cheers. Will get back on all this once I get home. Looks like exactly what I am doing assuming the referenced elements are normal lon/lat.

Appreciate the help.

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

  • Recently Browsing   0 members

    No registered users viewing this page.

×