index.d.cts 1.8 KB

12345678910111213141516171819202122232425262728293031323334353637383940
  1. import { Polygon, MultiPolygon, GeoJsonProperties, Feature, LineString, MultiLineString, FeatureCollection } from 'geojson';
  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. * @function
  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. declare function polygonToLine<G extends Polygon | MultiPolygon, P extends GeoJsonProperties = GeoJsonProperties>(poly: Feature<G, P> | G, options?: {
  20. properties?: any;
  21. }): Feature<LineString | MultiLineString, P> | FeatureCollection<LineString | MultiLineString, P>;
  22. /**
  23. * @private
  24. */
  25. declare function singlePolygonToLine<G extends Polygon, P extends GeoJsonProperties = GeoJsonProperties>(poly: Feature<G, P> | G, options?: {
  26. properties?: any;
  27. }): Feature<LineString | MultiLineString, P>;
  28. /**
  29. * @private
  30. */
  31. declare function multiPolygonToLine<G extends MultiPolygon, P extends GeoJsonProperties = GeoJsonProperties>(multiPoly: Feature<G, P> | G, options?: {
  32. properties?: P;
  33. }): FeatureCollection<LineString | MultiLineString, P>;
  34. /**
  35. * @private
  36. */
  37. declare function coordsToLine<P extends GeoJsonProperties = GeoJsonProperties>(coords: number[][][], properties: P): Feature<LineString | MultiLineString, P>;
  38. export { coordsToLine, polygonToLine as default, multiPolygonToLine, polygonToLine, singlePolygonToLine };