index.d.ts 1.6 KB

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