index.js 1.1 KB

12345678910111213141516171819202122232425262728293031323334
  1. 'use strict';
  2. var bbox = require('@turf/bbox');
  3. var bboxPolygon = require('@turf/bbox-polygon');
  4. function _interopDefaultLegacy (e) { return e && typeof e === 'object' && 'default' in e ? e : { 'default': e }; }
  5. var bbox__default = /*#__PURE__*/_interopDefaultLegacy(bbox);
  6. var bboxPolygon__default = /*#__PURE__*/_interopDefaultLegacy(bboxPolygon);
  7. /**
  8. * Takes any number of features and returns a rectangular {@link Polygon} that encompasses all vertices.
  9. *
  10. * @name envelope
  11. * @param {GeoJSON} geojson input features
  12. * @returns {Feature<Polygon>} a rectangular Polygon feature that encompasses all vertices
  13. * @example
  14. * var features = turf.featureCollection([
  15. * turf.point([-75.343, 39.984], {"name": "Location A"}),
  16. * turf.point([-75.833, 39.284], {"name": "Location B"}),
  17. * turf.point([-75.534, 39.123], {"name": "Location C"})
  18. * ]);
  19. *
  20. * var enveloped = turf.envelope(features);
  21. *
  22. * //addToMap
  23. * var addToMap = [features, enveloped];
  24. */
  25. function envelope(geojson) {
  26. return bboxPolygon__default['default'](bbox__default['default'](geojson));
  27. }
  28. module.exports = envelope;
  29. module.exports.default = envelope;