Added road incidents, just need to update backbone object to deal with them
This commit is contained in:
parent
1be9414e21
commit
32dd4a0b24
10
server.js
10
server.js
@ -218,6 +218,16 @@ app.get('/incidents', cache('5 minutes'), (req, res) => {
|
||||
|
||||
});
|
||||
|
||||
app.get('/comb', asyncMiddleware(async (req, res, next) => {
|
||||
logger.debug(req.query);
|
||||
let m = await directions.doGetEstDirectionsWithIncidents(req.query.olat, req.query.olon, req.query.dlat, req.query.dlon).then((b) => {
|
||||
logger.debug('b', b);
|
||||
});
|
||||
|
||||
logger.debug('m', m);
|
||||
res.send(m);
|
||||
}));
|
||||
|
||||
app.listen(port, (err) => {
|
||||
if (err)
|
||||
return logger.error('Server error:', err);
|
||||
|
@ -9,7 +9,8 @@ const { reduceEstDirections, reduceIncidents } = require('./reducers/directions'
|
||||
|
||||
module.exports = {
|
||||
'getTraffic': doGetEstDirections,
|
||||
'getIncidents' : doGetTraffic
|
||||
'getIncidents' : doGetTraffic,
|
||||
doGetEstDirectionsWithIncidents
|
||||
};
|
||||
|
||||
const headers = {};
|
||||
@ -18,7 +19,15 @@ const lastGood = {};
|
||||
//
|
||||
// https://maps.googleapis.com/maps/api/directions/json?origin=Toronto&destination=Montreal&key=AIzaSyBl7O9LHIthCagcqIaDkQ4um_hghYG5reE
|
||||
|
||||
function doGetEstDirections(olat, olon, dlat, dlon) {
|
||||
async function doGetEstDirectionsWithIncidents(olat, olon, dlat, dlon) {
|
||||
let traff = await doGetEstDirections(olat, olon, dlat, dlon);
|
||||
let incid = await doGetTraffic();
|
||||
|
||||
logger.debug('after...');
|
||||
return {traff, incid};
|
||||
}
|
||||
|
||||
async function doGetEstDirections(olat, olon, dlat, dlon) {
|
||||
logger.debug('doGetEstDirections');
|
||||
const url = `https://sgws2.maps.yahoo.com/Directions?time=now&cache=n&flags=J&olat=${olat}&olon=${olon}&dlat=${dlat}&dlon=${dlon}`;
|
||||
|
||||
@ -50,7 +59,7 @@ function doGetEstDirections(olat, olon, dlat, dlon) {
|
||||
});
|
||||
}
|
||||
|
||||
function doGetTraffic() {
|
||||
async function doGetTraffic() {
|
||||
logger.debug('doGetTraffic');
|
||||
|
||||
return new Promise((resolve, reject) => {
|
||||
|
Loading…
Reference in New Issue
Block a user