index.js 786 B

1234567891011121314151617181920212223242526
  1. import bbox from '@turf/bbox';
  2. import bboxPolygon from '@turf/bbox-polygon';
  3. /**
  4. * Takes any number of features and returns a rectangular {@link Polygon} that encompasses all vertices.
  5. *
  6. * @name envelope
  7. * @param {GeoJSON} geojson input features
  8. * @returns {Feature<Polygon>} a rectangular Polygon feature that encompasses all vertices
  9. * @example
  10. * var features = turf.featureCollection([
  11. * turf.point([-75.343, 39.984], {"name": "Location A"}),
  12. * turf.point([-75.833, 39.284], {"name": "Location B"}),
  13. * turf.point([-75.534, 39.123], {"name": "Location C"})
  14. * ]);
  15. *
  16. * var enveloped = turf.envelope(features);
  17. *
  18. * //addToMap
  19. * var addToMap = [features, enveloped];
  20. */
  21. function envelope(geojson) {
  22. return bboxPolygon(bbox(geojson));
  23. }
  24. export default envelope;