Compare commits
No commits in common. "7badd97610f9b022eea1c10389c3b9effd6f05ec" and "dd008d7ee23d0fee38dd6d9b4481b135a7ea7651" have entirely different histories.
7badd97610
...
dd008d7ee2
|
@ -1,6 +1,7 @@
|
|||
const unzip = require('unzip-stream');
|
||||
const csv = require('csv-parse');
|
||||
const axios = require('axios');
|
||||
const request = require('request');
|
||||
const requestp = require('request-promise-native');
|
||||
|
||||
const overpassEndpoint = 'https://lz4.overpass-api.de/api/interpreter';
|
||||
|
||||
|
@ -11,10 +12,10 @@ const overpassEndpoint = 'https://lz4.overpass-api.de/api/interpreter';
|
|||
* @param query Query in Overpass QL.
|
||||
* @return Results as provided by the endpoint.
|
||||
*/
|
||||
const queryOverpass = query => axios.post(
|
||||
const queryOverpass = query => requestp.post(
|
||||
overpassEndpoint,
|
||||
'data=' + query
|
||||
).then(res => res.data);
|
||||
{form: 'data=' + query}
|
||||
);
|
||||
|
||||
exports.queryOverpass = queryOverpass;
|
||||
|
||||
|
@ -76,9 +77,8 @@ const tamRealtimeEndpoint = 'http://data.montpellier3m.fr/node/10732/download';
|
|||
*/
|
||||
const fetchTamRealtime = (callback) =>
|
||||
{
|
||||
axios.get(tamRealtimeEndpoint, {
|
||||
responseType: 'stream'
|
||||
}).then(res => processTamPassingStream(res.data, callback));
|
||||
const csvStream = request(tamRealtimeEndpoint);
|
||||
processTamPassingStream(csvStream, callback);
|
||||
};
|
||||
|
||||
exports.fetchTamRealtime = fetchTamRealtime;
|
||||
|
@ -96,11 +96,7 @@ const tamTheoreticalFileName = 'offre_du_jour.csv';
|
|||
*/
|
||||
const fetchTamTheoretical = (callback) =>
|
||||
{
|
||||
axios.get(tamTheoreticalEndpoint, {
|
||||
responseType: 'stream'
|
||||
}).then(res =>
|
||||
{
|
||||
const fileStream = res.data.pipe(unzip.Parse());
|
||||
const fileStream = request(tamTheoreticalEndpoint).pipe(unzip.Parse());
|
||||
|
||||
fileStream.on('entry', entry =>
|
||||
{
|
||||
|
@ -114,7 +110,6 @@ const fetchTamTheoretical = (callback) =>
|
|||
});
|
||||
|
||||
fileStream.on('error', err => callback(err));
|
||||
});
|
||||
};
|
||||
|
||||
exports.fetchTamTheoretical = fetchTamTheoretical;
|
||||
|
|
|
@ -1,3 +1,5 @@
|
|||
const geolib = require('geolib');
|
||||
|
||||
const {choosePlural, joinSentence} = require('../util');
|
||||
const {queryOverpass, fetchTamTheoretical} = require('./endpoints');
|
||||
|
||||
|
@ -157,7 +159,7 @@ out body qt;
|
|||
const associations = await fetchStopsRefAssociations();
|
||||
|
||||
// List of retrieved objects
|
||||
const elementsList = rawData.elements;
|
||||
const elementsList = JSON.parse(rawData).elements;
|
||||
|
||||
// List of retrieved lines
|
||||
const routeMasters = elementsList.filter(elt =>
|
||||
|
@ -395,7 +397,7 @@ ${routeDescription} is one-way and cannot be used in reverse.`);
|
|||
path.indexOf(stops[stopIndex + 1] + 1),
|
||||
).map(id => ({
|
||||
lat: elements[id].lat,
|
||||
lon: elements[id].lon
|
||||
lon: elements[id].lon,
|
||||
})));
|
||||
}
|
||||
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
const axios = require('axios');
|
||||
const request = require('request');
|
||||
const csv = require('csv-parse');
|
||||
|
||||
const network = require('./network');
|
||||
|
@ -7,17 +7,13 @@ const {TAM_REALTIME} = require('./endpoints');
|
|||
const sortByFirstKey = (a, b) => a[0] - b[0];
|
||||
|
||||
const fetchRealtime = () => new Promise((res, rej) =>
|
||||
{
|
||||
const stream = axios.get(TAM_REALTIME, {
|
||||
responseType: 'stream'
|
||||
}).then(stream =>
|
||||
{
|
||||
const parser = csv({
|
||||
delimiter: ';',
|
||||
});
|
||||
|
||||
const stream = request(TAM_REALTIME).pipe(parser);
|
||||
const courses = {};
|
||||
stream.pipe(parser);
|
||||
|
||||
stream.on('readable', () =>
|
||||
{
|
||||
|
@ -54,7 +50,6 @@ const fetchRealtime = () => new Promise((res, rej) =>
|
|||
stream.on('end', () => res(courses));
|
||||
stream.on('error', err => rej(err));
|
||||
});
|
||||
});
|
||||
|
||||
const updateVehicles = async (lines, vehicles) =>
|
||||
{
|
||||
|
|
File diff suppressed because it is too large
Load Diff
|
@ -12,18 +12,19 @@
|
|||
"author": "",
|
||||
"license": "ISC",
|
||||
"dependencies": {
|
||||
"axios": "^0.19.2",
|
||||
"color": "^3.1.2",
|
||||
"csv-parse": "^4.8.3",
|
||||
"express": "^4.17.1",
|
||||
"geolib": "^3.2.1",
|
||||
"leaflet": "^1.6.0",
|
||||
"ol": "^6.1.1",
|
||||
"parcel-bundler": "^1.12.4",
|
||||
"request": "^2.88.0",
|
||||
"request-promise-native": "^1.0.8",
|
||||
"unzip-stream": "^0.3.0"
|
||||
},
|
||||
"devDependencies": {
|
||||
"eslint": "^6.8.0",
|
||||
"nodemon": "^2.0.2",
|
||||
"parcel-bundler": "^1.12.4"
|
||||
"nodemon": "^2.0.2"
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue