-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathstationChooser.js
30 lines (26 loc) · 1.07 KB
/
stationChooser.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
console.log('APP JS STARTED');
var express = require('express');
var path = require('path');
var favicon = require('serve-favicon');
var logger = require('morgan');
var cookieParser = require('cookie-parser');
var bodyParser = require('body-parser');
var request = require('request');
var fs = require('fs');
var stationMetaDataFromDisk = require('./stationMetaData.json');
var stationIDForName = function(requestedStationName) {
var stationsMDArray = stationMetaDataFromDisk['data']['stations'];
var requestedID = '000';
// console.log('stationChooser ENTERED');
stationsMDArray.forEach(function(stationMetaObject, i) {
// console.log('stationChooser LOOP ENTERED');
// console.log(requestedStationName);
if (requestedStationName == stationMetaObject['name']) {
// console.log('stationChooser LOOP CONDITIONAL ENTERED');
requestedID = stationMetaObject['station_id'];
// console.log("stationID in loop:"+requestedID);
}
});
return requestedID;
}
module.exports.stationIDForName = stationIDForName;