index.d.cts 1.8 KB

1234567891011121314151617181920212223242526272829303132333435
  1. import { GeoJsonProperties, BBox, Feature, Polygon, MultiPolygon, FeatureCollection } from 'geojson';
  2. import { Units } from '@turf/helpers';
  3. /**
  4. * Creates a grid of square polygons with cell length consistent in degrees
  5. *
  6. * @function
  7. * @param {BBox} bbox extent of grid in [minX, minY, maxX, maxY] order. If the grid does not fill the bbox perfectly, it is centered.
  8. * @param {number} cellSide length of each cell side.
  9. * @param {Object} [options={}] Optional parameters
  10. * @param {Units} [options.units='kilometers'] the units of the cellSide value.
  11. * Supports all valid Turf {@link https://github.com/Turfjs/turf/blob/master/packages/turf-helpers/README_UNITS.md Units}.
  12. * If you are looking for squares with sides of equal lengths in linear units (e.g. kilometers) this is not the module for you.
  13. * The cellSide is converted from units provided to degrees internally, so the width and height of resulting polygons will be consistent only in degrees.
  14. * @param {Feature<Polygon|MultiPolygon>} [options.mask] if passed a Polygon or MultiPolygon,
  15. * the grid Points will be created only inside it
  16. * @param {Object} [options.properties={}] passed to each point of the grid
  17. * @returns {FeatureCollection<Polygon>} a grid of polygons with equal width and height in degrees.
  18. * @example
  19. * var bbox = [-95, 30 ,-85, 40];
  20. * var cellSide = 50;
  21. * var options = {units: 'miles'};
  22. *
  23. * var squareGrid = turf.squareGrid(bbox, cellSide, options);
  24. *
  25. * //addToMap
  26. * var addToMap = [squareGrid]
  27. */
  28. declare function squareGrid<P extends GeoJsonProperties = GeoJsonProperties>(bbox: BBox, cellSide: number, options?: {
  29. units?: Units;
  30. properties?: P;
  31. mask?: Feature<Polygon | MultiPolygon> | Polygon | MultiPolygon;
  32. }): FeatureCollection<Polygon, P>;
  33. export { squareGrid as default, squareGrid };