Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
id,
poi,
origins,
osrmFile,
adminArea,
gridSize,
maxTime,
maxSpeed
} = e;
const osrm = new OSRM(osrmFile);
process.send({type: 'status', data: 'srv_loaded_files', id: id});
// Split the input region in squares for parallelisation.
let extent = bbox(adminArea);
let squares = squareGrid(extent, gridSize || 500, 'kilometers').features;
process.send({type: 'squarecount', data: squares.length, id: id});
// Create a task for each square to be run below.
var squareTasks = squares.map(square => {
// Clip the square with the input geometry. In this way we work with a
// smaller area..
let workArea = intersect(adminArea, square);
return createProcessAreaTask(workArea, poi, origins, osrm, maxTime, maxSpeed, id);
});
async.parallelLimit(squareTasks, config.cpus, (err, allSquaresRes) => {
if (err) {
throw err;
}
// allSquaresRes -> is an array of square results.
// Flatten the array.