Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
process.on('message', function (e) {
process.send({type: 'status', data: 'srv_started', id: e.id});
const {
id,
poi: poiByType,
villages,
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 box = envelope(adminArea);
let extent = [box.geometry.coordinates[0][0][0], box.geometry.coordinates[0][0][1], box.geometry.coordinates[0][2][0], box.geometry.coordinates[0][2][1]];
let squares = squareGrid(extent, gridSize || 30, '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, poiByType, villages, osrm, maxTime, maxSpeed, id);
});