index.d.ts 1.7 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344
  1. import { FeatureCollection, Point, Polygon } from "@turf/helpers";
  2. export interface Pt {
  3. x: number;
  4. y: number;
  5. z?: number;
  6. __sentinel?: boolean;
  7. }
  8. export interface Vertice {
  9. x: number;
  10. y: number;
  11. }
  12. /**
  13. * Takes a set of {@link Point|points} and creates a
  14. * [Triangulated Irregular Network](http://en.wikipedia.org/wiki/Triangulated_irregular_network),
  15. * or a TIN for short, returned as a collection of Polygons. These are often used
  16. * for developing elevation contour maps or stepped heat visualizations.
  17. *
  18. * If an optional z-value property is provided then it is added as properties called `a`, `b`,
  19. * and `c` representing its value at each of the points that represent the corners of the
  20. * triangle.
  21. *
  22. * @name tin
  23. * @param {FeatureCollection<Point>} points input points
  24. * @param {String} [z] name of the property from which to pull z values
  25. * This is optional: if not given, then there will be no extra data added to the derived triangles.
  26. * @returns {FeatureCollection<Polygon>} TIN output
  27. * @example
  28. * // generate some random point data
  29. * var points = turf.randomPoint(30, {bbox: [50, 30, 70, 50]});
  30. *
  31. * // add a random property to each point between 0 and 9
  32. * for (var i = 0; i < points.features.length; i++) {
  33. * points.features[i].properties.z = ~~(Math.random() * 9);
  34. * }
  35. * var tin = turf.tin(points, 'z');
  36. *
  37. * //addToMap
  38. * var addToMap = [tin, points]
  39. * for (var i = 0; i < tin.features.length; i++) {
  40. * var properties = tin.features[i].properties;
  41. * properties.fill = '#' + properties.a + properties.b + properties.c;
  42. * }
  43. */
  44. export default function tin(points: FeatureCollection<Point, any>, z?: string): FeatureCollection<Polygon>;