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

To help you get started, we’ve selected a few @turf/turf 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 gbif / portal16 / app / controllers / api / occurrence / breakdown / rangeUtils.js View on Github external
function getMinMaxGeometry(value, field) {
    // ex: ["polygon((...))] would use a lib to determine the bounding box and set min max latitude from that.
    if (typeof value !== 'undefined') {
        let geo = wkt2geojson(value);
        let bbox = turf.bbox(geo);
        return {
            min: bbox[1],
            max: bbox[3]
        };
    } else {
        let constantField = changeCase.constantCase(field);
        return {
            min: facetConfig.fields[constantField].range.min,
            max: facetConfig.fields[constantField].range.max
        };
    }
}
github syousif94 / frugalmaps / functions / getEvents.js View on Github external
.then(results => {
        if (!results.hits.hits.length) {
          return results.hits.hits;
        }

        const points = results.hits.hits.map(doc =>
          turf.point(doc._source.coordinates)
        );

        if (lat && lng && !bounds) {
          points.push(turf.point([lng, lat]));
        }

        // create a bounding box for the results
        const envelope = turf.bbox(
          turf.buffer(turf.envelope(turf.featureCollection(points)), 0.5, {
            units: "miles"
          })
        );

        bounds = {
          southwest: {
            lat: envelope[1],
            lng: envelope[0]
          },
          northeast: {
            lat: envelope[3],
            lng: envelope[2]
          }
        };
github osmlab / osmlint / validators / unconnectedHighways / map.js View on Github external
function objBbox(obj, id) {
  var bboxExtent = ['minX', 'minY', 'maxX', 'maxY'];
  var bbox = {};
  var valBbox = turf.bbox(obj);
  for (var d = 0; d < valBbox.length; d++) {
    bbox[bboxExtent[d]] = valBbox[d];
  }
  bbox.id = id || obj.properties['@id'];
  return bbox;
}
github osmlab / osmlint / validators / crossingHighways / map.js View on Github external
function objBbox(obj, id) {
  var bboxExtent = ['minX', 'minY', 'maxX', 'maxY'];
  var bbox = {};
  var valBbox = turf.bbox(obj);
  for (var d = 0; d < valBbox.length; d++) {
    bbox[id || bboxExtent[d]] = valBbox[d];
  }
  bbox.id = obj.properties['@id'];
  return bbox;
}
github osmlab / osmlint / validators / crossingHighwaysBridges / map.js View on Github external
function objBbox(obj, id) {
  var bboxExtent = ['minX', 'minY', 'maxX', 'maxY'];
  var bbox = {};
  var valBbox = turf.bbox(obj);
  for (var d = 0; d < valBbox.length; d++) {
    bbox[bboxExtent[d]] = valBbox[d];
  }
  bbox.id = id || obj.properties['@id'];
  return bbox;
}
github osmlab / osmlint / validators / islandsHighways / map.js View on Github external
function objBbox(obj, id) {
  var bboxExtent = ['minX', 'minY', 'maxX', 'maxY'];
  var bbox = {};
  var valBbox = turf.bbox(obj);
  for (var d = 0; d < valBbox.length; d++) {
    bbox[bboxExtent[d]] = valBbox[d];
  }
  bbox.id = id || obj.properties['@id'];
  return bbox;
}
github osmlab / osmlint / validators / mixedLayer / map.js View on Github external
function objBbox(obj, id) {
  var bboxExtent = ['minX', 'minY', 'maxX', 'maxY'];
  var bbox = {};
  var valBbox = turf.bbox(obj);
  for (var d = 0; d < valBbox.length; d++) {
    bbox[bboxExtent[d]] = valBbox[d];
  }
  bbox.id = id || obj.properties['@id'];
  return bbox;
}
github osmlab / osmlint / helper / formatRbush.js View on Github external
function objBbox(feature, id) {
  var bboxExtent = ['minX', 'minY', 'maxX', 'maxY'];
  var bbox = {};
  var valBbox = turf.bbox(feature);
  for (var d = 0; d < valBbox.length; d++) {
    bbox[bboxExtent[d]] = valBbox[d];
  }
  bbox.id = id || feature.properties['@id'];
  return bbox;
}
github osmlab / osmlint / validators / duplicateBuilding / map.js View on Github external
function objBbox(obj, id) {
  var bboxExtent = ['minX', 'minY', 'maxX', 'maxY'];
  var bbox = {};
  var valBbox = turf.bbox(obj);
  for (var d = 0; d < valBbox.length; d++) {
    bbox[id || bboxExtent[d]] = valBbox[d];
  }
  bbox.id = obj.properties['@id'];
  return bbox;
}