-
Notifications
You must be signed in to change notification settings - Fork 0
/
index.js
66 lines (53 loc) · 2.01 KB
/
index.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
const dotenv = require("dotenv").config();
const NROD = require("./consumers/nrod");
const Digitraffic = require("./consumers/digitraffic");
const HSL = require("./consumers/hsl");
const Oxyfi = require("./consumers/oxyfi");
const GtfsRealtime = require("./consumers/gtfs-rt");
//const Skanetrafiken = require('./consumers/skane');
const Trafikverket = require("./consumers/trafikverket");
const Cleaner = require("./consumers/cleaner");
// blacklist to filter non-rail vehicles
const blacklist = require("./blacklist.json");
// vehicle data mapping to real types and numbers
const vehicles = require("./vehicles.json");
function run() {
const nrod = new NROD("mqtt://127.0.0.1:11883");
nrod.connect();
const digitraffic = new Digitraffic("mqtt://rata-mqtt.digitraffic.fi");
digitraffic.connect();
const hsl = new HSL("mqtt://mqtt.hsl.fi:1883");
hsl.connect();
const oxyfi = new Oxyfi(
`wss://api.oxyfi.com/trainpos/listen?v=1&key=${process.env.OXYFI_API_KEY}`,
vehicles,
blacklist
);
oxyfi.connect();
const nysse = new GtfsRealtime(
"https://data.waltti.fi/tampere/api/gtfsrealtime/v1.0/feed/vehicleposition",
process.env.WALTTI_API_KEY,
vehicles,
{},
"NYSSE"
);
nysse.start();
// Östgötatrafiken GTFS-RT
//const otraf = new GtfsRealtime(`https://opendata.samtrafiken.se/gtfs-rt/otraf/VehiclePositions.pb?key=${process.env.GTFS_RT_API_KEY}`,
// null, vehicles, blacklist, 'OTRAF');
//otraf.start();
// Skånetrafiken (GTFS-RT but with train numbers as vehicle id)
//const skane = new Skanetrafiken(`https://opendata.samtrafiken.se/gtfs-rt/skane/VehiclePositions.pb?key=${process.env.GTFS_RT_API_KEY}`);
//skane.start();
// Trafikverket TrainPosition
const trafik = new Trafikverket(
"https://api.trafikinfo.trafikverket.se/v2/data.json",
process.env.TRAFIKVERKET_API_KEY
);
trafik.start();
// Set Cleaner to work every 5 minutes
const cleaner = new Cleaner(300000);
cleaner.run(); // run run run
// THIS DOES NOT REALLY WORK, F-WORD! WHY??
}
run();