index.d.cts 1.9 KB

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