Navigation API

Let Sim Innovations know about your Air Manager experience and let us know about your dream feature addition

Moderators: russ, Ralph

Post Reply
Message
Author
User avatar
Sling
Posts: 5237
Joined: Mon Sep 11, 2017 2:37 pm
Contact:

Re: Navigation API

#61 Post by Sling »

I just spent an hour listing out all the issues in detail and then the forum decided I needed to log in again and I lost everything i was just about to post. :evil:

To summarise what i was going to post.

Some database fields are swapped around. The wrong data is in the wrong field.
The ICAO query is not working.
A specific query caused a CTD. Sorry can't remeber which one. I did so many while testing.
Some but not all queries do not return all the stated fields.

I'll go through it again when i can.

freedom
Posts: 63
Joined: Wed Jul 29, 2020 2:41 pm

Re: Navigation API

#62 Post by freedom »

Did a fresh installation of both AM and the plug-in, restart the sim and voila! It works finally! Got the database built!

Some opinions if I may:
1. Multiple query criteria e.g. NAME + TYPE or AIRPORT + RUNWAY
- Currently if I need to fetch a runway I will need to apply API twice, first get airport and airport ID and then use airport ID and name to get runway. The X Plane API XPLMFindNavAid on the other hand offers quit decent search function by accepting multiple search entries. Unfortunately it doesn’t accept runway queries. Am I missing anything?

2. Any chance to include the function reposition aircraft as well? Hopefully just a simple bridging to the XP API XPLMPlaceUserAtLocation

User avatar
Sling
Posts: 5237
Joined: Mon Sep 11, 2017 2:37 pm
Contact:

Re: Navigation API

#63 Post by Sling »

freedom wrote: Sun Jan 31, 2021 3:23 am Did a fresh installation of both AM and the plug-in, restart the sim and voila! It works finally! Got the database built!

Some opinions if I may:
1. Multiple query criteria e.g. NAME + TYPE or AIRPORT + RUNWAY
- Currently if I need to fetch a runway I will need to apply API twice, first get airport and airport ID and then use airport ID and name to get runway. The X Plane API XPLMFindNavAid on the other hand offers quit decent search function by accepting multiple search entries. Unfortunately it doesn’t accept runway queries. Am I missing anything?

2. Any chance to include the function reposition aircraft as well? Hopefully just a simple bridging to the XP API XPLMPlaceUserAtLocation
The whole idea behind this and one of the reasons it’s taken so long in coming is it’s platform independent. Meaning it doesn’t use the Xplane database or the SDK function to query.
On the first point about combining queries. The guys can answer for sure but it’s probably better to do 2 smaller queries than a larger more complex one. I don’t think it’s a big deal to split it like they have. If you want the extra info you just query again. The airport and runways are separate tables. I suppose they could have a function that gets it all in one but it’s quite simple to write your own function that also does the same.

Just my thoughts.

freedom
Posts: 63
Joined: Wed Jul 29, 2020 2:41 pm

Re: Navigation API

#64 Post by freedom »

I am surprised to know the nav functions are actually independent of the XP API. I originally thought that’s just a bridging service like what has been happening with those scripts in FlyWithLua.

If it takes too much effort then for sure it can be left to the users to filter the queries. I just think it is convenient to do it in one pass.

Freedom

User avatar
Sling
Posts: 5237
Joined: Mon Sep 11, 2017 2:37 pm
Contact:

Re: Navigation API

#65 Post by Sling »

freedom wrote: Sun Jan 31, 2021 4:51 am I am surprised to know the nav functions are actually independent of the XP API.
It has to be otherwise how is it going to work for all the other sims. Sure if it’s xplane only then you would surely use the built in database and associated query functions.

User avatar
Sling
Posts: 5237
Joined: Mon Sep 11, 2017 2:37 pm
Contact:

Re: Navigation API

#66 Post by Sling »

I think this is going to be good in the long run but here's the more detailed list of snags for now.

The number of airports in the db is low (14k vs xplane 35K+).

Using the "ICAO" property returns no results.

A RUNWAY query does not return the SURFACE field.

This COMMUNICATION query causes a CTD. nav_get("COMMUNICATION", "AIRPORT_ID", 13380, callback).

A WAYPOINT query does not return the AIRPORT_ID field.

A VHF_NAVAID query does not return all of the db fields. TYPE, RANGE_POWER, ADDITIONAL_INFO, DECLINATION and RANGE are missing. The last 2 are perhaps because the db fields are empty but the others have data in them.

“COLLOCATED” is a rarely used spelling and should really be changed to “CO_LOCATED”. The returned data uses “COLLOCATION”. So they all need to match.

The NDB db has frequency data in the longitude field and no longitude data.
Last edited by Sling on Sun Jan 31, 2021 9:46 am, edited 1 time in total.

freedom
Posts: 63
Joined: Wed Jul 29, 2020 2:41 pm

Re: Navigation API

#67 Post by freedom »

Agree. The current API is yet to complete. Better work on it till it stabilizes.

Also the API description seems to be wrong for nav_get.

Code: Select all

-- We are looking for ENTO airport
nav_item = nav_get("AIRPORT", "IDENTIFIER", "ENTO", data_callback)
"IDENTIFIER" is not recognized

User avatar
Keith Baxter
Posts: 4671
Joined: Wed Dec 20, 2017 11:00 am
Location: Botswana

Re: Navigation API

#68 Post by Keith Baxter »

Hi

Airport "SIZE" field is missing.

Keith
AMD RYZEN 9 5950X CPU, Corsair H80I cooler, ASUS TUF GAMING B550-PLUS AMD Ryzen Mother Board,  32Gb ram Corsair Vengeance 3000Mh, MSI GTX960 4G graphics card 

freedom
Posts: 63
Joined: Wed Jul 29, 2020 2:41 pm

Re: Navigation API

#69 Post by freedom »

Insert current lat/long (22.0,114.0)

Code: Select all

function initialize_values(lat,long)
latitude=lat; longitude =long 
end

xpl_dataref_subscribe( "sim/flightmodel/position/latitude","DOUBLE", "sim/flightmodel/position/longitude","DOUBLE",  initialize_values)

local function data_callback(airports)
  if airports ~= nil then
    -- Print the found airports to log
    for i=1, #airports do
      print("ID=" .. i .. " name:" .. airports[i]["NAME"] .. " lon:" .. airports[i]["LONGITUDE"] .. " lat:" .. airports[i]["LATITUDE"])
    end
  else
    print("Error while querying nav data")
  end
end

-- Find the nearest 10 Airports from a certain latitude and longitude
nav_get_nearest("AIRPORT", latitude, longitude, 10, data_callback)
Outputs somewhere in Africa
INFO - ID=1 name:TAKORADI lon:-1.77470833 lat:4.89598611 elev:22.0

If change the variables into numbers i.e.
nav_get_nearest("AIRPORT", 22.0, 114.0, 10, data_callback)
then the result is correct

User avatar
Keith Baxter
Posts: 4671
Joined: Wed Dec 20, 2017 11:00 am
Location: Botswana

Re: Navigation API

#70 Post by Keith Baxter »

Hi


You have not got the lat and lon switched??

Mine works perfectly.
ice_screenshot_20210131-174815.png

Just need the Airport size to change the airport Icon.

Keith
AMD RYZEN 9 5950X CPU, Corsair H80I cooler, ASUS TUF GAMING B550-PLUS AMD Ryzen Mother Board,  32Gb ram Corsair Vengeance 3000Mh, MSI GTX960 4G graphics card 

Post Reply