index.js 1.3 KB

12345678910111213141516171819202122232425262728293031323334
  1. "use strict";
  2. var __importDefault = (this && this.__importDefault) || function (mod) {
  3. return (mod && mod.__esModule) ? mod : { "default": mod };
  4. };
  5. Object.defineProperty(exports, "__esModule", { value: true });
  6. var rectangle_grid_1 = __importDefault(require("@turf/rectangle-grid"));
  7. /**
  8. * Creates a square grid from a bounding box.
  9. *
  10. * @name squareGrid
  11. * @param {Array<number>} bbox extent in [minX, minY, maxX, maxY] order
  12. * @param {number} cellSide of each cell, in units
  13. * @param {Object} [options={}] Optional parameters
  14. * @param {string} [options.units='kilometers'] used in calculating cellSide, can be degrees,
  15. * radians, miles, or kilometers
  16. * @param {Feature<Polygon|MultiPolygon>} [options.mask] if passed a Polygon or MultiPolygon,
  17. * the grid Points will be created only inside it
  18. * @param {Object} [options.properties={}] passed to each point of the grid
  19. * @returns {FeatureCollection<Polygon>} grid a grid of polygons
  20. * @example
  21. * var bbox = [-95, 30 ,-85, 40];
  22. * var cellSide = 50;
  23. * var options = {units: 'miles'};
  24. *
  25. * var squareGrid = turf.squareGrid(bbox, cellSide, options);
  26. *
  27. * //addToMap
  28. * var addToMap = [squareGrid]
  29. */
  30. function squareGrid(bbox, cellSide, options) {
  31. if (options === void 0) { options = {}; }
  32. return rectangle_grid_1.default(bbox, cellSide, cellSide, options);
  33. }
  34. exports.default = squareGrid;