index.d.ts 1.8 KB

1234567891011121314151617181920212223242526272829303132333435363738
  1. import { FeatureCollection, Point, GeoJsonProperties, MultiLineString } from 'geojson';
  2. /**
  3. * Takes a grid {@link FeatureCollection} of {@link Point} features with z-values and an array of
  4. * value breaks and generates [isolines](https://en.wikipedia.org/wiki/Contour_line).
  5. *
  6. * @function
  7. * @param {FeatureCollection<Point>} pointGrid input points
  8. * @param {Array<number>} breaks values of `zProperty` where to draw isolines
  9. * @param {Object} [options={}] Optional parameters
  10. * @param {string} [options.zProperty='elevation'] the property name in `points` from which z-values will be pulled
  11. * @param {Object} [options.commonProperties={}] GeoJSON properties passed to ALL isolines
  12. * @param {Array<Object>} [options.breaksProperties=[]] GeoJSON properties passed, in order, to the correspondent isoline;
  13. * the breaks array will define the order in which the isolines are created
  14. * @returns {FeatureCollection<MultiLineString>} a FeatureCollection of {@link MultiLineString} features representing isolines
  15. * @example
  16. * // create a grid of points with random z-values in their properties
  17. * var extent = [0, 30, 20, 50];
  18. * var cellWidth = 100;
  19. * var pointGrid = turf.pointGrid(extent, cellWidth, {units: 'miles'});
  20. *
  21. * for (var i = 0; i < pointGrid.features.length; i++) {
  22. * pointGrid.features[i].properties.temperature = Math.random() * 10;
  23. * }
  24. * var breaks = [0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10];
  25. *
  26. * var lines = turf.isolines(pointGrid, breaks, {zProperty: 'temperature'});
  27. *
  28. * //addToMap
  29. * var addToMap = [lines];
  30. */
  31. declare function isolines(pointGrid: FeatureCollection<Point>, breaks: number[], options?: {
  32. zProperty?: string;
  33. commonProperties?: GeoJsonProperties;
  34. breaksProperties?: GeoJsonProperties[];
  35. }): FeatureCollection<MultiLineString, GeoJsonProperties>;
  36. export { isolines as default, isolines };