index.d.ts 1.6 KB

12345678910111213141516171819202122232425262728293031323334353637
  1. import { Feature, FeatureCollection, LineString, MultiLineString, MultiPolygon, Polygon, Properties } from "@turf/helpers";
  2. /**
  3. * Converts a {@link Polygon} to {@link LineString|(Multi)LineString} or {@link MultiPolygon} to a
  4. * {@link FeatureCollection} of {@link LineString|(Multi)LineString}.
  5. *
  6. * @name polygonToLine
  7. * @param {Feature<Polygon|MultiPolygon>} poly Feature to convert
  8. * @param {Object} [options={}] Optional parameters
  9. * @param {Object} [options.properties={}] translates GeoJSON properties to Feature
  10. * @returns {FeatureCollection|Feature<LineString|MultiLinestring>} converted (Multi)Polygon to (Multi)LineString
  11. * @example
  12. * var poly = turf.polygon([[[125, -30], [145, -30], [145, -20], [125, -20], [125, -30]]]);
  13. *
  14. * var line = turf.polygonToLine(poly);
  15. *
  16. * //addToMap
  17. * var addToMap = [line];
  18. */
  19. export default function <G extends Polygon | MultiPolygon, P = Properties>(poly: Feature<G, P> | G, options?: {
  20. properties?: any;
  21. }): Feature<LineString | MultiLineString, P> | FeatureCollection<LineString | MultiLineString, P>;
  22. /**
  23. * @private
  24. */
  25. export declare function polygonToLine<G extends Polygon, P = Properties>(poly: Feature<G, P> | G, options?: {
  26. properties?: any;
  27. }): Feature<LineString | MultiLineString, P>;
  28. /**
  29. * @private
  30. */
  31. export declare function multiPolygonToLine<G extends MultiPolygon, P = Properties>(multiPoly: Feature<G, P> | G, options?: {
  32. properties?: P;
  33. }): FeatureCollection<LineString | MultiLineString, P>;
  34. /**
  35. * @private
  36. */
  37. export declare function coordsToLine<P = Properties>(coords: number[][][], properties: P): Feature<LineString | MultiLineString, P>;