index.d.ts 1.5 KB

12345678910111213141516171819202122232425262728293031323334
  1. import * as geojson from 'geojson';
  2. import { LineString, MultiLineString, Feature, FeatureCollection, GeoJsonProperties } from 'geojson';
  3. /**
  4. * Converts (Multi)LineString(s) to Polygon(s).
  5. *
  6. * @function
  7. * @param {FeatureCollection|Feature<LineString|MultiLineString>} lines Features to convert
  8. * @param {Object} [options={}] Optional parameters
  9. * @param {Object} [options.properties={}] translates GeoJSON properties to Feature
  10. * @param {boolean} [options.autoComplete=true] auto complete linestrings (matches first & last coordinates)
  11. * @param {boolean} [options.orderCoords=true] sorts linestrings to place outer ring at the first position of the coordinates
  12. * @param {boolean} [options.mutate=false] mutate the original linestring using autoComplete (matches first & last coordinates)
  13. * @returns {Feature<Polygon|MultiPolygon>} converted to Polygons
  14. * @example
  15. * var line = turf.lineString([[125, -30], [145, -30], [145, -20], [125, -20], [125, -30]]);
  16. *
  17. * var polygon = turf.lineToPolygon(line);
  18. *
  19. * //addToMap
  20. * var addToMap = [polygon];
  21. */
  22. declare function lineToPolygon<G extends LineString | MultiLineString>(lines: Feature<G> | FeatureCollection<G> | G, options?: {
  23. properties?: GeoJsonProperties;
  24. autoComplete?: boolean;
  25. orderCoords?: boolean;
  26. mutate?: boolean;
  27. }): Feature<geojson.MultiPolygon, {
  28. [name: string]: any;
  29. } | null> | Feature<geojson.Polygon, {
  30. [name: string]: any;
  31. } | null>;
  32. export { lineToPolygon as default, lineToPolygon };