Finland, Helsinki - Real-time HSL transit map

A realtime transit map generated from the Helsinki transportation realtime MQTT stream, including rate limiting and WebSockets output.

[
    {
        "id": "e2195212.a4714",
        "type": "mqtt in",
        "z": "266e93fa.65ea04",
        "name": "HSL open API",
        "topic": "/hfp/journey/#",
        "qos": "2",
        "broker": "a7e4e343.855248",
        "x": 247.7452392578125,
        "y": 209,
        "wires": [
            [
                "68c08c01.967884"
            ]
        ]
    },
    {
        "id": "3dc8e41d.4f6cb4",
        "type": "function",
        "z": "266e93fa.65ea04",
        "name": "Parse Vehicle",
        "func": "var data = msg.payload;\n\nvar vehicle = {\n    name: data.VP.veh,\n    lat: data.VP.lat,\n    lon: data.VP.long,\n    icon: \"ship\",\n    iconColor: \"red\",\n    source: data.VP.source,\n    bearing: data.VP.hdg,\n    speed: data.VP.spd,\n    designation: data.VP.desi\n    //extrainfo: data.VP.desi,\n    //timeStamp: data.VP.tst\n};\n\nif (\n    vehicle.source === 'hsl helmi'\n    ||\n    vehicle.source === 'hsl roisto'\n    ) {\n    // bus\n    vehicle.icon = 'friend';\n    vehicle.iconColor = 'blue';\n    vehicle.layer = \"Bus\";\n} else if (\n    vehicle.source === 'hsl live'\n    ||\n    vehicle.source === 'sm5logger'\n    ) {\n    // Local trains/trams\n    vehicle.iconColor = 'green';\n    vehicle.layer = \"Train/tram\";\n} else if (vehicle.source === 'vr') {\n    // VR train (local)\n    vehicle.iconColor = 'chartreuse';\n    vehicle.layer = \"VR train (local)\";\n} else if (vehicle.source === 'meri-test.digitraffic.fi') {\n    // ferry\n    vehicle.iconColor = 'aqua';\n    vehicle.layer = \"Ferry\";\n} else {\n    node.error('Unknown source:' + vehicle.source);\n    node.error('Unknown designation:' + vehicle.designation);\n}\n\nmsg.topic = vehicle.name;\nmsg.payload = vehicle;\n\nreturn msg;",
        "outputs": 1,
        "noerr": 0,
        "x": 423.9952392578125,
        "y": 311.25,
        "wires": [
            [
                "5d7249be.1cd9d8",
                "5467e8f0.ab2c18"
            ]
        ]
    },
    {
        "id": "5467e8f0.ab2c18",
        "type": "debug",
        "z": "266e93fa.65ea04",
        "name": "",
        "active": false,
        "console": "false",
        "complete": "false",
        "x": 586.2452392578125,
        "y": 251.353515625,
        "wires": []
    },
    {
        "id": "68c08c01.967884",
        "type": "json",
        "z": "266e93fa.65ea04",
        "name": "",
        "x": 347.2452392578125,
        "y": 258.353515625,
        "wires": [
            [
                "3dc8e41d.4f6cb4",
                "dd715ade.0ffc3"
            ]
        ]
    },
    {
        "id": "5d7249be.1cd9d8",
        "type": "worldmap",
        "z": "266e93fa.65ea04",
        "name": "",
        "lat": "60",
        "lon": "25",
        "zoom": "10",
        "layer": "OSM",
        "cluster": "",
        "maxage": "",
        "usermenu": "hide",
        "panit": "false",
        "x": 601.5,
        "y": 363,
        "wires": []
    },
    {
        "id": "dd715ade.0ffc3",
        "type": "debug",
        "z": "266e93fa.65ea04",
        "name": "",
        "active": false,
        "console": "false",
        "complete": "false",
        "x": 488.5,
        "y": 188,
        "wires": []
    },
    {
        "id": "a7e4e343.855248",
        "type": "mqtt-broker",
        "broker": "mqtt.hsl.fi",
        "port": "1883",
        "clientid": "",
        "usetls": false,
        "verifyservercert": true,
        "compatmode": true,
        "keepalive": 15,
        "cleansession": true,
        "willQos": "0",
        "birthQos": "0"
    }
]
brylie

Flow Info

created 1 year, 6 months ago
updated 6 months ago

Node Types

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

Tags

  • Transportation
  • Finland
  • helsinki
  • HSL
  • MQTT
  • Map
  • rate-limiting
  • proxy
  • real-time
Copy this flow JSON to your clipboard and then import into Node-RED using the Import From > Clipboard (Ctrl-I) menu option