HSL public transport (worldmap v1)

Updated flow and icon & color selected from topic.

[{"id":"aef87d81.d61ca","type":"mqtt-broker","broker":"mqtt.hsl.fi","port":"1883","clientid":""},{"id":"c1c326a1.eb4538","type":"worldmap","name":"","x":557.372200012207,"y":114.04295349121094,"z":"aadda172.68a1c","wires":[]},{"id":"3ddede24.9ace42","type":"inject","name":"Map center to Helsinki","topic":"","payload":"","payloadType":"str","repeat":"","crontab":"","once":true,"x":204.7452621459961,"y":67,"z":"aadda172.68a1c","wires":[["a449d467.82c578"]]},{"id":"e2420f35.6055d","type":"mqtt in","name":"HSL open API","topic":"/hfp/journey/#","broker":"aef87d81.d61ca","x":150.84467315673828,"y":140.64647102355957,"z":"aadda172.68a1c","wires":[["9424298f.cb7fc8"]]},{"id":"9424298f.cb7fc8","type":"function","name":"Parse","func":"var data=JSON.parse(msg.payload);\nvar icon=\"car\";\nvar color=\"blue\";\nif (msg.topic.search(\"tram\")>0) {\n    icon=\"train\";\n    color=\"green\";\n}\nelse {\n    icon=\"bus\";\n    color=\"blue\";\n}\nvar thing = {\n    name:data.VP.veh, \n    lat:data.VP.lat, \n    lon:data.VP.long,\n    bearing:data.VP.dir,\n    icon:icon,\n    iconColor:color,\n    extrainfo:data.VP.desi\n};\nmsg.payload=thing;\nreturn msg;","outputs":1,"noerr":0,"x":367.00378036499023,"y":140.8055601119995,"z":"aadda172.68a1c","wires":[["c1c326a1.eb4538"]]},{"id":"a449d467.82c578","type":"function","name":"Helsinki","func":"msg.payload={};\nmsg.payload.command =  {\n     layer:\"OSM\",  \n     lat:60.17, \n     lon:24.94,\n     zoom:14\n};\nreturn msg;","outputs":1,"noerr":0,"x":382.90904998779297,"y":68.44442558288574,"z":"aadda172.68a1c","wires":[["c1c326a1.eb4538"]]}]
mikakaraila

Flow Info

created 1 year, 6 months ago

Node Types

Core
  • function (x2)
  • inject (x1)
  • mqtt in (x1)
  • mqtt-broker (x1)
Other

Tags

  • HSL
  • mqtt
  • openapi
  • worldmap
Copy this flow JSON to your clipboard and then import into Node-RED using the Import From > Clipboard (Ctrl-I) menu option