How to use the @turf/square-grid.default function in @turf/square-grid

To help you get started, we’ve selected a few @turf/square-grid examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github stvno / worlda11y / calculate-eta / index.js View on Github external
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.

@turf/square-grid

turf square-grid module

MIT
Latest version published 5 months ago

Package Health Score

94 / 100
Full package analysis

Popular @turf/square-grid functions