Jump to content

VATSIM API to determine where a pilot currently flying is


Recommended Posts

Hi all,

 

I'm trying to create an application that can alert pilots that have stepped away if they are within an active Air Traffic Controllers sector. I would like to know if there is a VATSIM API that can send data to my application for a specific pilot to tell them who's airspace they are in.

 

I'm new to programming but this is my summer goal

Link to post
Share on other sites
Hi all,

 

I'm trying to create an application that can alert pilots that have stepped away if they are within an active Air Traffic Controllers sector. I would like to know if there is a VATSIM API that can send data to my application for a specific pilot to tell them who's airspace they are in.

 

I'm new to programming but this is my summer goal

 

Oh boy are you gonna have some fun. To answer your question really quickly, there is no API (to my knowledge at least) that can directly tell you who's airspace you are in. If you are still interested in this project, follow on below.

 

Getting Pilot's Position

 

First off, the only way, apart from making your own add-on for FSX/X-Plane etc is to use VATSIM's status service. The status service gives loads of information, but most importantly for your project, it gives cid, callsign, position and altitude.

 

You might want to write some code yourself to decode this - beware that VATSIM policy restricts you and/or your software from pulling data more frequently than every two minutes. (It'd be pointless to anyway, since it updates every two minutes).

 

If you didn't want to write some code to decode it yourself, you could always look on GitHub for a pre-prepared method. I wrote a VATSIM Data Handler in PHP a few months ago, which deals with caching and the two-minute rule.

 

Locating Airspace Boundaries

 

One of the main reasons VATSIM doesn't have a API to specifically tell you who's airspace pilots are in, is because of the way airspace definitions change - this can be as often as monthly, which obviously when you've got so many countries, airports and sectors to handle, is a big task.

 

You might decide to start off small - maybe take a look at some AIPs and manually copy the boundaries out into a file, for your software to then work with.

 

Alternatively, if you wanted to work in a bigger scale, you could always take a look at finding sector definitions online. I couldn't really find any publicly available, but last I looked was a year ago - so things may have changed.

 

When I had to draw airspace boundaries, I shamelessly "borrowed" the airspace boundaries from VAT-Spy as a way of quickly implementing and testing the features (sorry, Ross). I'd not recommend this approach, but obviously if you're in need and haven't got the time or patience to manually write out a lot of sectors, this could be an avenue to explore.

 

Comparing The Two

 

I'm not very good with the maths side of things, and all these triangles, squares and weird 70 sided shapes confuse me. I've found two pages which might better explain to you than how I could.

 

http://alienryderflex.com/polygon/

https://www.quora.com/Given-coordinate-of-a-polygon-and-a-point-How-do-I-compute-if-the-point-is-located-inside-the-polygon

 

 

Good Luck.

Kind Regards,

Kieran Cross,

 

28.png

Link to post
Share on other sites

 

Oh boy are you gonna have some fun. To answer your question really quickly, there is no API (to my knowledge at least) that can directly tell you who's airspace you are in. If you are still interested in this project, follow on below.

 

I hope this will be fun I've never done much programming but I've always wanted a program like this so I've just decided to learn a lot of this stuff as I go.

 

 

First off, the only way, apart from making your own add-on for FSX/X-Plane etc is to use VATSIM's status service. The status service gives loads of information, but most importantly for your project, it gives cid, callsign, position and altitude.

 

You might want to write some code yourself to decode this - beware that VATSIM policy restricts you and/or your software from pulling data more frequently than every two minutes. (It'd be pointless to anyway, since it updates every two minutes).

 

If you didn't want to write some code to decode it yourself, you could always look on GitHub for a pre-prepared method. I wrote a VATSIM Data Handler in PHP a few months ago, which deals with caching and the two-minute rule.

 

 

I was looking at this earlier...and I guess I need to do some more learning on how to decode all that information. Right now I'm making my program in Visual Studio because I thought it would be the easiest, but I'm guess there isn't a way for Visual Basic to decode that API (or maybe there is? Who knows, I sure don't.)

 

 

You might decide to start off small - maybe take a look at some AIPs and manually copy the boundaries out into a file, for your software to then work with.

 

 

That is what I was thinking. For now, I would probably focus on just North Atlantic Flight Station Services and centers, then move to other areas.

 

Good Luck.

 

Thanks, I think I'll need it!

Link to post
Share on other sites

I've just decided to learn a lot of this stuff as I go.

 

That's the way to go!

 

Right now I'm making my program in Visual Studio because I thought it would be the easiest

 

Nice place to start, maybe not the most practical for the task. But, everything is a learning process, and at the same time, it's a discretionary world - you'll find what works best for you as you continue to develop and explore.

 

but I'm guess there isn't a way for Visual Basic to decode that API (or maybe there is? Who knows, I sure don't.)

 

You sure can. If you look into the VATSIM Data Handler above, you'll see how it was done. Essentially, it's just a game of exploding strings until you've got what you need.

 

That is what I was thinking. For now, I would probably focus on just North Atlantic Flight Station Services and centers, then move to other areas.

 

That's a great idea, but I have a feeling testing it could be a pain in the [Mod - Happy Thoughts], if you decide to test whilst flying - you might want to consider doing the VATSIM data last, and using static coordinates for testing.

Kind Regards,

Kieran Cross,

 

28.png

Link to post
Share on other sites

Decoding the VATSIM status data can be done in basically any language. It's called data parsing, and all you need to do is read the file, run each line through your code and do something with the end result. Accomeap is going to be providing a public web API which will provide the VATSIM status data in JSON, along with airport information, and pilot information including the sector they are in.

Andrew Ogden | I3
Gander Oceanic OCA Chief
VATSIM Web Developer

Visit us: https://ganderoceanic.com
Contact: [email protected] 

431466725_bannersmall.png.dd3c45679f76aeb32af4d6ff6fb9854a.png

Link to post
Share on other sites

Nice place to start, maybe not the most practical for the task. But, everything is a learning process, and at the same time, it's a discretionary world - you'll find what works best for you as you continue to develop and explore.

 

What would you personally recommend?

 

You sure can. If you look into the VATSIM Data Handler above, you'll see how it was done. Essentially, it's just a game of exploding strings until you've got what you need.

 

What would you call that? I'm not entirely sure how to do it. EDIT: I just realized a comment above explained it.

 

That's a great idea, but I have a feeling testing it could be a pain in the [Mod - Happy Thoughts], if you decide to test whilst flying - you might want to consider doing the VATSIM data last, and using static coordinates for testing.

 

 

Yeah I fly a lot so I think using VATSIM data would be fine.

 

Accomeap is going to be providing a public web API which will provide the VATSIM status data in JSON, along with airport information, and pilot information including the sector they are in.

 

So will this basically just tell me where that pilot is? How long will it be before it's released?

 

Thanks for helping me out here and sorry for all the questions!

Link to post
Share on other sites

What would you personally recommend?

 

If I were doing this, I'd be using something along the lines of JS/jQuery, with a PHP backend. That being said, PHP and jQuery (not so much JS) are my strengths - that's something you'll have to work out for yourself.

 

a pain in the [Mod - Happy Thoughts]

 

Lol

 

Thanks for helping me out here and sorry for all the questions!

 

That's what it's all about, I think.

Kind Regards,

Kieran Cross,

 

28.png

Link to post
Share on other sites
Is there a way to pull a users callsign and position through their CID?

 

I was thinking about it, and if the user enters their CID, it could locate them through that.

 

The VATSIM Status system has you sorted for that! Here's a list of what data they provide.

 

  • callsign
  • cid
  • realname
  • clienttype
  • frequency
  • latitude
  • longitude
  • altitude
  • groundspeed
  • planned_aircraft
  • planned_tascruise
  • planned_depairport
  • planned_altitude
  • planned_destairport
  • server
  • protrevision
  • rating
  • transponder
  • facilitytype
  • visualrange
  • planned_revision
  • planned_flighttype
  • planned_deptime
  • planned_actdeptime
  • planned_hrsenroute
  • planned_minenroute
  • planned_hrsfuel
  • planned_minfuel
  • planned_altairport
  • planned_remarks
  • planned_route
  • planned_depairport_lat
  • planned_depairport_lon
  • planned_destairport_lat
  • planned_destairport_lon
  • atis_message
  • time_last_atis_received
  • time_logon
  • heading
  • QNH_iHg
  • QNH_Mb

Kind Regards,

Kieran Cross,

 

28.png

Link to post
Share on other sites
So, how about this?

 

The user enters their CID in the program. Visual Basic then searches this VATSIM status service docomeent for their CID, then pulls their LAT/LONG, and then says what airspace they are in which are defined by predetermined coordinates?

 

Sorry if that's a lot, I just want to make sure I'm understanding all this right.

 

Sounds alright to me. Bear in mind, you can't only use the one URL, VATSIM requires that you randomize the URLs you pull from (and it'd be best practice anyway, since there's always the possibility of downtime).

Kind Regards,

Kieran Cross,

 

28.png

Link to post
Share on other sites

 

Sounds alright to me. Bear in mind, you can't only use the one URL, VATSIM requires that you randomize the URLs you pull from (and it'd be best practice anyway, since there's always the possibility of downtime).

 

Alright, looks like I will focus on this concept then. Thanks for your help!

Link to post
Share on other sites

If I recall correctly, the coordinates listed for controllers in the data files are the centre of their primary visibility range (you might want to double-check this, though). Using this data, you could warn a user when they are n miles from the visibility centre of an online controller (e.g. 150 for CTR positions and 60 for APP positions)

 

Knowing how lengthy projects (particularly the complexity headache of trying to define all of the constantly changing airspace sectors) can drag on and all motivation to complete them be completely lost, this would be a significant stepping stone and something substantial/working for your portfolio, and you'd have something to show for your work.

 

Once you get to this stage, if you still have the motivation, it would be easy enough to then build on the working model to implement more fine-grained control for specific sectors and areas.

Neil Farrington

VATSIM UK

Link to post
Share on other sites
If I recall correctly, the coordinates listed for controllers in the data files are the centre of their primary visibility range (you might want to double-check this, though). Using this data, you could warn a user when they are n miles from the visibility centre of an online controller (e.g. 150 for CTR positions and 60 for APP positions)

 

I believe the visibility range is also in the data feed.

 

However, using the primary visibility center plus the visibility range (or even a hardcoded range according to facility type) isn't going to work well for many/most facilities, since many are not round, and many use multiple visibility centers, and many set their visibility range further out than their airspace actually extends. So you'd get a lot of false positives and false negatives when deciding whether or not you should alert the pilot that they're approaching someone's airspace.

Developer: vPilot, VRC, vSTARS, vERAM, VAT-Spy

Senior Controller, Boston Virtual ARTCC

Link to post
Share on other sites
I believe the visibility range is also in the data feed.

 

However, using the primary visibility center plus the visibility range (or even a hardcoded range according to facility type) isn't going to work well for many/most facilities, since many are not round, and many use multiple visibility centers, and many set their visibility range further out than their airspace actually extends. So you'd get a lot of false positives and false negatives when deciding whether or not you should alert the pilot that they're approaching someone's airspace.

Absolutely - I suggested custom distances because of that fact, so they're at least more attuned to a realistic value. With the max allowed APP range of 150 and the max CTR range of a whopping 600, the vis range itself would be wildly inaccurate.

 

I'm definitely not saying it's a great solution, or even a good one, just that for a personal project for a new programmer, where motivation can waver, especially in the face of such complexity, it's a very simple solution to allow a milestone to be reached, which can then be developed to the necessary complexity.

Neil Farrington

VATSIM UK

Link to post
Share on other sites

I don't think it would be more realistic to use a hard coded value ... airspace just varies too much. Granted, there is less variance with approach and tower airspace than there is with center, but center airspaces are arguably the most important to get right here, because they cover so much of the planet compared to the underlying facilities.

 

I think it would be worth using the data we have for airspace boundaries, even if it changes from time to time ... it doesn't change all that often, and it would be far more accurate than just using a fixed-size circle for each center facility.

Developer: vPilot, VRC, vSTARS, vERAM, VAT-Spy

Senior Controller, Boston Virtual ARTCC

Link to post
Share on other sites

Agreed on all counts... we're literally saying the same thing.

 

I wasn't at all suggesting it would be a solution people would use, since it would be so inaccurate - it's a stepping stone to the end goal, for a small project, for a new programmer.

Neil Farrington

VATSIM UK

Link to post
Share on other sites

I'd like to ask a quick question this JSON file.

 

If I'm looking at the Moncton FIR, I first see the

{"icao":"CZQM","isOceanic":"0","isExtension":"1","points":[["48.500000","-62.000000"],["44.446667","-56.051667"]]}

 

So I was thinking "Wow, this FIR only has 2 points?" Then I see right after that line of code this:

 

{"icao":"CZQM","isOceanic":"0","isExtension":"0","points":[["49.300000","-61.000000"],["49.533333","-61.000000"],["51.000000","-58.000000"],["51.283333","-57.000000"],["51.735000","-57.000000"],["52.196389","-58.142778"],["51.633333","-59.500000"],["51.333333","-59.500000"],["50.833333","-60.000000"],["50.833333","-62.083333"],["51.416667","-64.000000"],["53.700000","-64.916667"],["54.416667","-65.333333"],["55.083333","-65.083333"],["55.355556","-64.000000"],["57.550000","-64.000000"],["58.471111","-60.351111"],["57.000000","-59.000000"],["53.000000","-54.000000"],["49.000000","-51.000000"],["45.000000","-51.000000"],["45.000000","-53.000000"],["44.446667","-56.051667"],["43.600000","-60.000000"],["41.866667","-67.000000"],["44.933333","-67.000000"],["45.625000","-67.775000"],["45.783333","-67.806944"],["45.825000","-67.583333"],["46.143056","-67.216667"],["46.200000","-67.216667"],["46.536111","-67.300000"],["46.572500","-67.249167"],["46.611944","-67.203333"],["46.645278","-67.170278"],["46.698333","-67.127500"],["46.744444","-67.097778"],["46.792222","-67.074167"],["46.841389","-67.056667"],["46.891389","-67.045556"],["46.941667","-67.040556"],["46.992222","-67.042222"],["47.042500","-67.050278"],["47.091944","-67.064722"],["47.140556","-67.085278"],["47.187500","-67.112222"],["47.232778","-67.145000"],["47.275833","-67.183611"],["47.316667","-67.227778"],["47.354444","-67.276944"],["47.389444","-67.330556"],["47.420833","-67.388889"],["47.448611","-67.450833"],["47.472778","-67.516389"],["47.492778","-67.584722"],["47.508611","-67.655556"],["47.520278","-67.728056"],["47.527500","-67.801944"],["47.530278","-67.876389"],["47.528611","-67.950833"],["47.522778","-68.025000"],["47.733333","-67.950000"],["47.883442","-66.896275"],["47.999992","-65.940733"],["47.848333","-64.622222"],["48.500000","-62.000000"]]},

 

So...am I missing something? Why does it have 2 lines of code, and why does one line have only 2 points and the other have a lot more?

Link to post
Share on other sites
-snip-

 

As I said a little further up, I took the sectors from the VAT-Spy file, and really quickly made a piece of code to decode the .dat file and to put it into a JSON format.

 

Its probable that I messed it up when doing it, which explains those issues. You might be better off writing your own conversion script for this.

 

Remember, using this file is on your own head - it was taken without permission of Ross, and only uploaded to GitHub by mistake (and since it's Git, there's little point in removing the file now).

Kind Regards,

Kieran Cross,

 

28.png

Link to post
Share on other sites
  • 11 months later...

Extending on the suggestions of others, here is an example you can try out using the Vatsim REST API.

 

EDGG is the only center position at the moment (in Europe), and he is reporting a center position of lng:8.54312 lat:50.02642, lets [Mod - Happy Thoughts]ume he is on maximum range (600 miles, or 966 Km).

 

One could leverage the REST API to query for pilots around his position in a radius of 966 Km, like so:

 

http://vatsim-api.herokuapp.com/controllers?where={"callsign": "EDGG_E_CTR"}

 

Should give you the center location for EDGG.

 

 

http://vatsim-api.herokuapp.com/pilots?where={"location": "$near": {"$geometry": {"type": "Point", "coordinates": [8.54312,50.02642]}, "$maxDistance": 966000}}}

 

Converting the Km to meters, we can query pilots in his scope.

I may or may not be working on adding alerts for such queries.

Link to post
Share on other sites

Please sign in to comment

You will be able to leave a comment after signing in



Sign In Now
×
×
  • Create New...