index.d.cts 1.7 KB

123456789101112131415161718192021222324252627282930313233343536
  1. import { GeoJsonProperties, BBox, Feature, Polygon, FeatureCollection } from 'geojson';
  2. import { Units } from '@turf/helpers';
  3. /**
  4. * Takes a bounding box and the diameter of the cell and returns a {@link FeatureCollection} of flat-topped
  5. * hexagons or triangles ({@link Polygon} features) aligned in an "odd-q" vertical grid as
  6. * described in [Hexagonal Grids](http://www.redblobgames.com/grids/hexagons/).
  7. *
  8. * @function
  9. * @param {BBox} bbox extent in [minX, minY, maxX, maxY] order
  10. * @param {number} cellSide length of the side of the the hexagons or triangles, in units. It will also coincide with the
  11. * radius of the circumcircle of the hexagons.
  12. * @param {Object} [options={}] Optional parameters
  13. * @param {string} [options.units='kilometers'] used in calculating cell size, can be degrees, radians, miles, or kilometers
  14. * @param {Object} [options.properties={}] passed to each hexagon or triangle of the grid
  15. * @param {Feature<Polygon>} [options.mask] if passed a Polygon or MultiPolygon, the grid Points will be created only inside it
  16. * @param {boolean} [options.triangles=false] whether to return as triangles instead of hexagons
  17. * @returns {FeatureCollection<Polygon>} a hexagonal grid
  18. * @example
  19. * var bbox = [-96,31,-84,40];
  20. * var cellSide = 50;
  21. * var options = {units: 'miles'};
  22. *
  23. * var hexgrid = turf.hexGrid(bbox, cellSide, options);
  24. *
  25. * //addToMap
  26. * var addToMap = [hexgrid];
  27. */
  28. declare function hexGrid<P extends GeoJsonProperties = GeoJsonProperties>(bbox: BBox, cellSide: number, options?: {
  29. units?: Units;
  30. triangles?: boolean;
  31. properties?: P;
  32. mask?: Feature<Polygon>;
  33. }): FeatureCollection<Polygon, P>;
  34. export { hexGrid as default, hexGrid };