index.d.ts 1.3 KB

12345678910111213141516171819202122232425262728293031
  1. import { GeoJsonProperties, BBox, Feature, Polygon, MultiPolygon, FeatureCollection, Point } from 'geojson';
  2. import { Units } from '@turf/helpers';
  3. /**
  4. * Creates a grid of points
  5. *
  6. * @function
  7. * @param {BBox} bbox extent of grid in [minX, minY, maxX, maxY] order
  8. * @param {number} cellSide the distance between points
  9. * @param {Object} [options={}] Optional parameters
  10. * @param {Units} [options.units='kilometers'] the units of the cellSide value. Supports all valid Turf {@link https://github.com/Turfjs/turf/blob/master/packages/turf-helpers/README_UNITS.md Units}
  11. * @param {Feature<Polygon|MultiPolygon>} [options.mask] if passed a Polygon or MultiPolygon, the grid Points will be created only inside it
  12. * @param {Object} [options.properties={}] passed to each point of the grid
  13. * @returns {FeatureCollection<Point>} grid of points
  14. * @example
  15. * var extent = [-70.823364, -33.553984, -70.473175, -33.302986];
  16. * var cellSide = 3;
  17. * var options = {units: 'miles'};
  18. *
  19. * var grid = turf.pointGrid(extent, cellSide, options);
  20. *
  21. * //addToMap
  22. * var addToMap = [grid];
  23. */
  24. declare function pointGrid<P extends GeoJsonProperties = GeoJsonProperties>(bbox: BBox, cellSide: number, options?: {
  25. units?: Units;
  26. mask?: Feature<Polygon | MultiPolygon>;
  27. properties?: P;
  28. }): FeatureCollection<Point, P>;
  29. export { pointGrid as default, pointGrid };