index.d.cts 1.4 KB

123456789101112131415161718192021222324252627
  1. import { AllGeoJSON } from '@turf/helpers';
  2. import { Point, MultiPoint, Feature, FeatureCollection, LineString, MultiLineString, Polygon, MultiPolygon } from 'geojson';
  3. /**
  4. * Flattens any {@link GeoJSON} to a {@link FeatureCollection} inspired by [geojson-flatten](https://github.com/tmcw/geojson-flatten).
  5. *
  6. * @function
  7. * @param {GeoJSON} geojson any valid GeoJSON Object
  8. * @returns {FeatureCollection<any>} all Multi-Geometries are flattened into single Features
  9. * @example
  10. * var multiGeometry = turf.multiPolygon([
  11. * [[[102.0, 2.0], [103.0, 2.0], [103.0, 3.0], [102.0, 3.0], [102.0, 2.0]]],
  12. * [[[100.0, 0.0], [101.0, 0.0], [101.0, 1.0], [100.0, 1.0], [100.0, 0.0]],
  13. * [[100.2, 0.2], [100.8, 0.2], [100.8, 0.8], [100.2, 0.8], [100.2, 0.2]]]
  14. * ]);
  15. *
  16. * var flatten = turf.flatten(multiGeometry);
  17. *
  18. * //addToMap
  19. * var addToMap = [flatten]
  20. */
  21. declare function flatten<T extends Point | MultiPoint>(geojson: Feature<T> | FeatureCollection<T> | T): FeatureCollection<Point>;
  22. declare function flatten<T extends LineString | MultiLineString>(geojson: Feature<T> | FeatureCollection<T> | T): FeatureCollection<LineString>;
  23. declare function flatten<T extends Polygon | MultiPolygon>(geojson: Feature<T> | FeatureCollection<T> | T): FeatureCollection<Polygon>;
  24. declare function flatten(geojson: AllGeoJSON): FeatureCollection<any>;
  25. export { flatten as default, flatten };