Skip to content

Instantly share code, notes, and snippets.

@momentfree
Last active March 18, 2017 15:17
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save momentfree/fd3da18cdc34f49625d68b616465b60a to your computer and use it in GitHub Desktop.
Save momentfree/fd3da18cdc34f49625d68b616465b60a to your computer and use it in GitHub Desktop.
Plot flights with Opensky-Network and Worldmap

This flow needs internet connection to:

  1. get flights from Opensky via rest
  2. plot active flights to WORLDMAP node

Required node:node-red-contrib-web-worldmap

Because of Opensky Network limitations, injection msg is every 30secs. Use a lower rate at your own risk, this flow plots > 2000+ points, ALL flights all over the world. Use free account on opensky to get more control and faster rate update. Set your account on the flow editing 2nd node (get from Opensky Network) URL property from:

https://opensky-network.org/api/states/all

to

https://username:password@opensky-network.org/api/states/all

now you can set lower rate on injection node. Edit 1st node(interval 30 secs) set interval to 15 secs.

Opensky Network Limitiations for anonymous (unauthenticated) users Anonymous are those users who access the API without using credentials. The limitations for anonymous users are: Anonymous users can only get the most recent state vectors, i.e. the time parameter will be ignored. Anonymous users can only retrieve data with a time resultion of 10 seconds. That means, the API will return state vectors for time now−(now mod 10)now−(now mod 10). Limitations for OpenSky users An OpenSky user is anybody who uses a valid OpenSky account (see below) to access the API. The rate limitations for OpenSky users are: OpenSky users can retrieve data of up to 1 hour in the past. If the time parameter has a value t<now−3600t<now−3600 the API will return 400 Bad Request. OpenSky users can retrieve data with a time resultion of 5 seconds. That means, if the time parameter was set to tt, the API will return state vectors for time t−(t mod 5)t−(t mod 5).

[{"id":"dcc41a2d.900458","type":"http request","z":"2f8472b0.84438e","name":"get from Opensky Network","method":"GET","ret":"obj","url":"https://opensky-network.org/api/states/all","tls":"","x":376,"y":540,"wires":[["f8f66972.c46d98"]]},{"id":"11e3a8e1.02dc67","type":"inject","z":"2f8472b0.84438e","name":"interval 30 secs","topic":"","payload":"","payloadType":"date","repeat":"30","crontab":"","once":false,"x":130,"y":540,"wires":[["dcc41a2d.900458"]]},{"id":"f8f66972.c46d98","type":"function","z":"2f8472b0.84438e","name":"flights filter func","func":"var allFlights=msg.payload.states;\nvar filteredFlights = [];\n\nfor (var i = 0, len = allFlights.length; i < len; i++) {\n // get longitude not null flights only\n if (allFlights[i][5]){\n filteredFlights.push(allFlights[i]);\n }\n}\n\nmsg.payload=filteredFlights;\nreturn msg;","outputs":1,"noerr":0,"x":436,"y":480,"wires":[["5cf4ce68.f9f9e"]]},{"id":"ad326887.d1bc08","type":"worldmap","z":"2f8472b0.84438e","name":"","lat":"","lon":"","zoom":"","layer":"","cluster":"","maxage":"","usermenu":"show","panit":"false","x":866,"y":540,"wires":[]},{"id":"5cf4ce68.f9f9e","type":"split","z":"2f8472b0.84438e","name":"split flights","splt":"\\n","x":646,"y":480,"wires":[["8bdd67c6.3db3d8"]]},{"id":"8bdd67c6.3db3d8","type":"function","z":"2f8472b0.84438e","name":"add flight to map","func":"var flight = {\n name: msg.payload[1], \n lat:msg.payload[6], \n lon:msg.payload[5],\n bearing:msg.payload[10],\n speed:msg.payload[9],\n layer:\"flights track\",\n icon:\"plane\",\n iconColor:\"red\",\n extrainfo:msg.payload[0]\n};\n\nmsg.payload = flight;\nreturn msg;","outputs":1,"noerr":0,"x":656,"y":540,"wires":[["ad326887.d1bc08"]]}]
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment