index.d.ts 3.2 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879
  1. import { BBox, Position, FeatureCollection, Point, Polygon, LineString } from 'geojson';
  2. /**
  3. * Returns a random position within a {@link BBox|bounding box}.
  4. *
  5. * @function
  6. * @param {BBox} [bbox=[-180, -90, 180, 90]] a bounding box inside of which positions are placed.
  7. * @returns {Position} Position [longitude, latitude]
  8. * @throws {Error} if bbox is invalid
  9. * @example
  10. * var position = turf.randomPosition([-180, -90, 180, 90])
  11. * // => position
  12. */
  13. declare function randomPosition(bbox?: BBox | {
  14. bbox: BBox;
  15. }): Position;
  16. /**
  17. * Returns a random {@link point}.
  18. *
  19. * @function
  20. * @param {number} [count=1] how many geometries will be generated
  21. * @param {Object} [options={}] Optional parameters
  22. * @param {BBox} [options.bbox=[-180, -90, 180, 90]] a bounding box inside of which geometries are placed.
  23. * @returns {FeatureCollection<Point>} GeoJSON FeatureCollection of points
  24. * @throws {Error} if bbox is invalid
  25. * @example
  26. * var points = turf.randomPoint(25, {bbox: [-180, -90, 180, 90]})
  27. * // => points
  28. */
  29. declare function randomPoint(count?: number, options?: {
  30. bbox?: BBox;
  31. }): FeatureCollection<Point, any>;
  32. /**
  33. * Returns a random {@link polygon}.
  34. *
  35. * @function
  36. * @param {number} [count=1] how many geometries will be generated
  37. * @param {Object} [options={}] Optional parameters
  38. * @param {BBox} [options.bbox=[-180, -90, 180, 90]] a bounding box inside of which geometries are placed.
  39. * @param {number} [options.num_vertices=10] is how many coordinates each LineString will contain.
  40. * @param {number} [options.max_radial_length=10] is the maximum number of decimal degrees latitude or longitude that a
  41. * vertex can reach out of the center of the Polygon.
  42. * @returns {FeatureCollection<Polygon>} GeoJSON FeatureCollection of polygons
  43. * @throws {Error} if bbox is invalid
  44. * @example
  45. * var polygons = turf.randomPolygon(25, {bbox: [-180, -90, 180, 90]})
  46. * // => polygons
  47. */
  48. declare function randomPolygon(count?: number, options?: {
  49. bbox?: BBox;
  50. num_vertices?: number;
  51. max_radial_length?: number;
  52. }): FeatureCollection<Polygon, any>;
  53. /**
  54. * Returns a random {@link LineString}.
  55. *
  56. * @function
  57. * @param {number} [count=1] how many geometries will be generated
  58. * @param {Object} [options={}] Optional parameters
  59. * @param {BBox} [options.bbox=[-180, -90, 180, 90]] a bounding box inside of which geometries are placed.
  60. * @param {number} [options.num_vertices=10] is how many coordinates each LineString will contain.
  61. * @param {number} [options.max_length=0.0001] is the maximum number of decimal degrees that a
  62. * vertex can be from its predecessor
  63. * @param {number} [options.max_rotation=Math.PI / 8] is the maximum number of radians that a
  64. * line segment can turn from the previous segment.
  65. * @returns {FeatureCollection<LineString>} GeoJSON FeatureCollection of linestrings
  66. * @throws {Error} if bbox is invalid
  67. * @example
  68. * var lineStrings = turf.randomLineString(25, {bbox: [-180, -90, 180, 90]})
  69. * // => lineStrings
  70. */
  71. declare function randomLineString(count?: number, options?: {
  72. bbox?: BBox;
  73. num_vertices?: number;
  74. max_length?: number;
  75. max_rotation?: number;
  76. }): FeatureCollection<LineString, any>;
  77. export { randomLineString, randomPoint, randomPolygon, randomPosition };