Skip to content

Instantly share code, notes, and snippets.

@mikakaraila
Created May 18, 2016 11:46
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 mikakaraila/143127a0fc9b612e05d260e6182be6fb to your computer and use it in GitHub Desktop.
Save mikakaraila/143127a0fc9b612e05d260e6182be6fb to your computer and use it in GitHub Desktop.
HSL public transport vehicle locations through Open API

Uses public mqtt API and puts trafic into worldmap.

[{"id":"eb89d20e.80ad7","type":"mqtt-broker","broker":"mqtt.hsl.fi","port":"1883","clientid":""},{"id":"51a0d6.314d5f2c","type":"websocket-listener","path":"/ws/worldmap","wholemsg":"false"},{"id":"7ceea90f.5baac8","type":"worldmap","name":"","x":465.8541946411133,"y":125.30556869506836,"z":"8f216ca4.df9c7","wires":[]},{"id":"2522acde.dfe564","type":"websocket out","name":"","server":"51a0d6.314d5f2c","client":"","x":492.8541946411133,"y":48.055559158325195,"z":"8f216ca4.df9c7","wires":[]},{"id":"92696722.a8e9b8","type":"inject","name":"Map center to Helsinki","topic":"","payload":"","payloadType":"str","repeat":"","crontab":"","once":true,"x":170.50003051757812,"y":46.444443702697754,"z":"8f216ca4.df9c7","wires":[["2522acde.dfe564"]]},{"id":"954adec.b86ee2","type":"mqtt in","name":"HSL open API","topic":"/hfp/journey/#","broker":"eb89d20e.80ad7","x":116.59944152832031,"y":120.09091472625732,"z":"8f216ca4.df9c7","wires":[["5c403301.5bb7fc"]]},{"id":"5c403301.5bb7fc","type":"function","name":"Parse","func":"var data=JSON.parse(msg.payload);\nvar thing = {\n name:data.VP.veh, \n lat:data.VP.lat, \n lon:data.VP.long,\n icon:\"car\",\n iconColor:\"red\",\n extrainfo:data.VP.desi\n};\nmsg.payload=thing;\nreturn msg;","outputs":1,"noerr":0,"x":271.84946060180664,"y":119.34091377258301,"z":"8f216ca4.df9c7","wires":[["2522acde.dfe564"]]}]
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment