Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
.then(poiTypes => {
const bbox = [-180, -90, 180, 90];
const toOsmOptions = {
bounds: {minlon: bbox[0], minlat: bbox[1], maxlon: bbox[2], maxlat: bbox[3]}
};
const osmDb = getDatabase(projId, scId);
const formatTransform = obj2osm(toOsmOptions);
formatTransform.on('error', (err) => {
throw err;
});
logger && logger.log('Exporting data from osm-p2p');
let stream = osmP2PApi(osmDb).getMap(bbox, {order: 'type'})
.pipe(processOSMP2PExport());
// Extract the POI into a promise and continue with the road network.
let splitting = collectPOIs(stream, poiTypes);
stream = splitting.stream.pipe(formatTransform);
function processRN () {
const fileName = `road-network_${Date.now()}`;
const filePath = `scenario-${scId}/${fileName}`;
return putFileStream(filePath, stream)
// Get previous file.
.then(() => db('scenarios_files')
.select('path')
.where('type', 'road-network')
export function getRouter (projId, scId) {
return osmrouter(getDatabase(projId, scId));
}