-
Notifications
You must be signed in to change notification settings - Fork 0
/
index.js
39 lines (32 loc) · 903 Bytes
/
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
const data = require("./sg-mrt.json");
const allStations = data.mrt;
// find mrt and line based on station
const findStation = station => {
let result = {
found: false
};
allStations.filter(mrt => {
mrt.line.map(line => {
line.station.map(station => {
stationName = station.name;
})
if (station.includes(stationName)) {
result.found = true;
result.mrt = mrt.name;
result.line_name = line.name;
result.line_color = line.color;
result.line_code = line.code;
line.station.map(station => {
result.station_name = station.name;
result.station_code = station.stationCode;
result.latitude = station.latitude;
result.longitude = station.longitude;
});
}
return null;
});
return null;
});
return result;
};
module.exports = findStation;