How to use the @turf/bbox.default function in @turf/bbox

To help you get started, we’ve selected a few @turf/bbox 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
const {
    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.
github hotosm / MapCampaigner / lambda_functions / process / make_pdf_grid / index.js View on Github external
async function main(event) {
    const response = await getS3File(event.campaign_uuid);
    const f = JSON.parse(response).features
    const options = {units:"meters"}
    const features = []
    for (let i = 0; i < f.length; i++) {
        const box = bbox(f[i]);
        const w = distance([box[0], box[1]],[box[2],box[1]],{units:"meters"})
        const h = distance([box[0], box[1]],[box[0],box[3]],{units:"meters"})
        const wDiff = 1000 - (w % 1000);
        const hDiff = 706 - (h % 706);
        const poly = bboxPolygon(box);
        const c = centerOfMass(poly);
        const maxY = destination(c,(50 + h + hDiff)/2, 0, options).geometry.coordinates[1];
        const minY = destination(c,(50 +h + hDiff)/2, 180,options).geometry.coordinates[1];
        const maxX = destination(c,(50 + w + wDiff)/2, 90,options).geometry.coordinates[0];
        const minX = destination(c,(50 + w + wDiff)/2, -90,options).geometry.coordinates[0];
        const grid = rectangleGrid([minX, minY, maxX, maxY], 1000, 706, {units:"meters"});
        for (let j=0; j
github derhuerst / svg-world-map / build.js View on Github external
.then((world) => {

	const box = bbox(world)
	const west = box[0]
	const south = -57
	const east = box[2]
	const north = 77.5

	simplify(world, {tolerance: .17, highQuality: true, mutate: true})
	const polylines = svgify(world, {
		projection,
		computeProps: () => ({className: 'country'})
	})

	const [left, top] = projection([west, north])
	const [right, bottom] = projection([east, south])
	const width = right - left
	const height = bottom - top
	const ratio = width / height
github DenisCarriere / geojson-rbush / index.js View on Github external
featureEach(features, function (feature) {
                if (feature.type !== 'Feature') throw new Error('invalid features');
                feature.bbox = feature.bbox ? feature.bbox : turfBBox(feature);
                load.push(feature);
            });
        }
github Turfjs / turf / packages / turf-bbox-clip / bench.js View on Github external
    suite.add(name, () => bboxClip(geojson.features[0], bbox(geojson.features[1])));
}
github simonepri / geojson-geometries-lookup / index.js View on Github external
options.ignorePoints,
      options.ignoreLines,
      options.ignorePolygons
    ];

    for (let d = size; d < 3; d++) {
      if (ignores[d] === true) {
        continue;
      }

      const dim = this.D[d];
      if (dim.lookup === null) {
        continue;
      }

      const bbox = tbbox(geometry);
      const bboxs = dim.lookup.search({
        minX: bbox[0],
        minY: bbox[1],
        maxX: bbox[2],
        maxY: bbox[3]
      });

      for (let i = 0, len = bboxs.length; i < len; i++) {
        const geom = dim.list[bboxs[i].id];
        if (!tcontains(geom, geometry)) {
          continue;
        }

        func(geom, count);
        count++;
        if (options.limit > 0 && options.limit === count) {
github simonepri / geojson-geometries-lookup / index.js View on Github external
this.D[0] = {list: extracted.points.features, bboxs: null, lookup: null};
    this.D[1] = {list: extracted.lines.features, bboxs: null, lookup: null};
    this.D[2] = {list: extracted.polygons.features, bboxs: null, lookup: null};

    for (let d = 0; d < 3; d++) {
      const dim = this.D[d];
      if (dim.list.length > 0) {
        dim.bboxs = new Array(dim.list.length);
        dim.lookup = rbush();

        const geoms = dim.list;
        const bboxs = dim.bboxs;
        const lookup = dim.lookup;

        for (let i = 0, len = geoms.length; i < len; i++) {
          const bbox = tbbox(geoms[i]);
          bboxs[i] = {
            minX: bbox[0],
            minY: bbox[1],
            maxX: bbox[2],
            maxY: bbox[3],
            id: i
          };
        }

        lookup.load(bboxs);
      }
    }
  }

@turf/bbox

turf bbox module

MIT
Latest version published 3 months ago

Package Health Score

98 / 100
Full package analysis

Popular @turf/bbox functions