diff --git a/functions/index.js b/functions/index.js
index 2f11229..01496b0 100644
--- a/functions/index.js
+++ b/functions/index.js
@@ -81,7 +81,7 @@ exports.postStationData = functions.https.onRequest((request, response) => {
// store all dart codes into a hashset
// compare these with the station call with code "all" to avoid duplicates
let dartCodes = new Set()
- batchWriteDB(request, response, db, jsonData, dartCodes, "Dart")
+ batchWriteDB(request, response, db, jsonData, dartCodes, "DART")
// populate the dartCodes hashset
jsonData.forEach((doc) => {
@@ -186,7 +186,7 @@ exports.postLiveTrainData = functions.https.onRequest((request, response) => {
axios.get('https://api.irishrail.ie/realtime/realtime.asmx/getCurrentTrainsXML_WithTrainType?TrainType=D').then(res => {
parseString(res.data, function(err, result) {
let jsonData = parseJSON(result)
- batchWriteDB(request, response, db, jsonData, "Dart");
+ batchWriteDB(request, response, db, jsonData, "DART");
response.send({data: "Successfully fetched and uploaded live train data from Irish Rail"});
})
})
@@ -208,4 +208,4 @@ exports.securefunction = functions.https.onCall((data, context) => {
// user logged in
return "User is logged in"
}
-})
\ No newline at end of file
+})
diff --git a/src/pages/MapPage.vue b/src/pages/MapPage.vue
index 6e62a84..b9d49bb 100644
--- a/src/pages/MapPage.vue
+++ b/src/pages/MapPage.vue
@@ -2,11 +2,27 @@
@@ -29,7 +45,7 @@
-
+

@@ -45,7 +61,7 @@
-
+
@@ -86,10 +102,18 @@ export default {
const fillColor = ref('red');
let showTrains = [];
+ let showStations = [];
+ let showNormalStations = true;
+ let showDARTStations = true;
let showLate = true;
let showOnTime = true;
let showEarly = true;
+ let showNormal = true;
+ let showDART = true;
+ let showRunning = true;
+ let showTerminated = true;
+ let showNotYetRunning = true;
return {
center,
@@ -102,6 +126,7 @@ export default {
fillColor,
showTrains: [],
+ showStations: [],
trainCoordinates: [],
stationCoordinates: [],
allTrains: {},
@@ -110,9 +135,16 @@ export default {
isPaused: false,
store,
+ showNormalStations,
+ showDARTStations,
showLate,
showOnTime,
- showEarly
+ showEarly,
+ showNormal,
+ showDART,
+ showRunning,
+ showTerminated,
+ showNotYetRunning
}
},
@@ -140,7 +172,25 @@ export default {
// method to determine whether or not to show each train
decideShowTrains() {
for (let i = 0; i < this.showTrains.length; i++) {
- this.showTrains[i] = (this.showLate && this.isTrainLate(i)) || (this.showOnTime && !this.isTrainLate(i));
+ // determine whether or not the tain is a DART or not
+ let isDART = this.getTrainType(i) == "DART";
+
+ if ((this.showRunning && this.allTrains[i]["TrainStatus"][0] == "R") || (this.showTerminated && this.allTrains[i]["TrainStatus"][0] == "T") || this.showNotYetRunning && this.allTrains[i]["TrainStatus"][0] == "N") {
+ if ((this.showDART && isDART) || (this.showNormal && !isDART)) {
+ this.showTrains[i] = (this.showLate && this.isTrainLate(i)) || (this.showOnTime && !this.isTrainLate(i)); // || (this.showNormal && !isDART) || (this.showDART && isDART);
+ }
+ }
+ else {
+ this.showTrains[i] = false;
+ }
+ }
+ },
+
+ // method to determine whether or not to show each station
+ decideShowStations() {
+ for (let i = 0; i < this.showStations.length; i++) {
+ let isDARTStation = this.allStations[i]["StationType"][0] == "DART";
+ this.showStations[i] = (this.showDARTStations && isDARTStation) || (this.showNormalStations && !isDARTStation);
}
},
@@ -173,66 +223,6 @@ export default {
return false;
},
- // // method to determine whether or not a selected train is early
- // isTrainEarly(i) {
- // // check if the train is running
- // if (this.allTrains[i]["TrainStatus"][0] == "R") {
- // let publicMessage = this.allTrains[i]["PublicMessage"][0];
- // let startTimeStr = publicMessage.indexOf("(");
- //
- // // check if the train is early
- // if (publicMessage[startTimeStr+1] == "-" && publicMessage[startTimeStr+1] != "0") {
- // return true;
- // }
- // }
- // return false;
- // },
- //
- // // method to determine whether or not a selected train is on time
- // isTrainOnTime(i) {
- // // check if the train is running
- // if (this.allTrains[i]["TrainStatus"][0] == "R") {
- // let publicMessage = this.allTrains[i]["PublicMessage"][0];
- // let startTimeStr = publicMessage.indexOf("(");
- //
- // // check if the train is on time
- // if (publicMessage[startTimeStr+1] != "-" && publicMessage[startTimeStr+1] == "0") {
- // return true;
- // }
- // }
- // return false;
- // },
- //
- // // method to determine whether or not a selected train is late
- // isTrainLate(i) {
- // // check if the train is running
- // if (this.allTrains[i]["TrainStatus"][0] == "R") {
- // let publicMessage = this.allTrains[i]["PublicMessage"][0];
- // let startTimeStr = publicMessage.indexOf("(");
- //
- // // check if the train is late
- // if (publicMessage[startTimeStr+1] != "-" && publicMessage[startTimeStr+1] != "0") {
- // return true;
- // }
- // }
- // return false;
- // },
- //
- // // method to determine whether or not a selected train is late
- // isTrainLate(i) {
- // // check if the train is running
- // if (this.allTrains[i]["TrainStatus"][0] == "R") {
- // let publicMessage = this.allTrains[i]["PublicMessage"][0];
- // let startTimeStr = publicMessage.indexOf("(");
- //
- // // check if the train is late
- // if (publicMessage[startTimeStr+1] != "-" && publicMessage[startTimeStr+1] != "0") {
- // return true;
- // }
- // }
- // return false;
- // },
-
// method to determine whether or not a selected train is running
isTrainRunning(i) {
if (this.allTrains[i]["TrainStatus"][0] == "R") {
@@ -243,7 +233,7 @@ export default {
}
},
- // method that returns the type of train (either "Train" or "Dart")
+ // method that returns the type of train (either "Train" or "DART")
getTrainType(i) {
return this.allTrains[i]["TrainType"][0];
},
@@ -294,7 +284,7 @@ export default {
insights["totalNumTrains"] += 1
if (train["TrainType"][0] == "Train") insights["numTrains"] += 1;
- else if (train["TrainType"][0] == "Dart") insights["numDarts"] += 1;
+ else if (train["TrainType"][0] == "DART") insights["numDarts"] += 1;
// filter out \n in public messages
train["PublicMessage"][0] = train["PublicMessage"][0].replace(/\\n/g, ". ");
@@ -351,10 +341,14 @@ export default {
for (var i=0; i