Plotting planes using dump1090 and worldmap.
This example uses an external program and 2 non-core nodes.
dump1090 - the awesome ADS-B program from @antirez - https://github.com/antirez/dump1090
worldmap node - http://flows.nodered.org/node/node-red-contrib-web-worldmap
daemon node - http://flows.nodered.org/node/node-red-node-daemon
The Daemon node runs dump1090 --net
in the background. If you don't want to install this node then you can just run it in a separate window.
dump1090 --net
One of dump1090's hidden features is the ability to provide a json
object of the planes it can see via http://localhost:8080/data.json
. So we can poll this url to get a pre-decoded array of planes, then split this into individual planes, add the necessary parameters for the map, and finally forward to the map page's websocket.
[{"id":"c9c26db2.572ff","type":"worldmap","z":"5e316136.c9343","name":"","x":597,"y":260,"wires":[]},{"id":"ee8117db.660788","type":"http request","z":"5e316136.c9343","name":"","method":"GET","ret":"obj","url":"http://localhost:8080/data.json","tls":"","x":288,"y":199,"wires":[["1158850f.f2be6b"]]},{"id":"76c2b099.8578e","type":"inject","z":"5e316136.c9343","name":"","topic":"","payload":"","payloadType":"str","repeat":"3","crontab":"","once":true,"x":128,"y":199,"wires":[["ee8117db.660788"]]},{"id":"1158850f.f2be6b","type":"function","z":"5e316136.c9343","name":"Split array into individual planes","func":"var m = [];\nfor (var i in msg.payload) {\n m.push({payload:msg.payload[i]});\n}\nreturn [m];","outputs":1,"noerr":0,"x":528,"y":199,"wires":[["1b108949.a69537"]]},{"id":"1b108949.a69537","type":"change","z":"5e316136.c9343","name":"","rules":[{"t":"set","p":"payload.name","pt":"msg","to":"payload.hex","tot":"msg"},{"t":"set","p":"payload.bearing","pt":"msg","to":"payload.track","tot":"msg"},{"t":"set","p":"payload.icon","pt":"msg","to":"plane","tot":"str"},{"t":"set","p":"payload.layer","pt":"msg","to":"ADSB","tot":"str"},{"t":"delete","p":"payload.track","pt":"msg"}],"action":"","property":"","from":"","to":"","reg":false,"x":358,"y":259,"wires":[["c9c26db2.572ff"]]},{"id":"ecb8190.4425de8","type":"daemon","z":"5e316136.c9343","command":"dump1090","args":"--net","cr":false,"redo":true,"op":"string","name":"","x":168,"y":339,"wires":[[],[],[]]}]