index.d.cts 1.1 KB

1234567891011121314151617181920212223
  1. import { Polygon, MultiPolygon, LineString, MultiLineString, GeoJsonProperties, Feature, BBox } from 'geojson';
  2. /**
  3. * Takes a {@link Feature} and a bbox and clips the feature to the bbox using
  4. * [lineclip](https://github.com/mapbox/lineclip).
  5. * May result in degenerate edges when clipping Polygons.
  6. *
  7. * @function
  8. * @param {Feature<LineString|MultiLineString|Polygon|MultiPolygon>} feature feature to clip to the bbox
  9. * @param {BBox} bbox extent in [minX, minY, maxX, maxY] order
  10. * @returns {Feature<LineString|MultiLineString|Polygon|MultiPolygon>} clipped Feature
  11. * @example
  12. * var bbox = [0, 0, 10, 10];
  13. * var poly = turf.polygon([[[2, 2], [8, 4], [12, 8], [3, 7], [2, 2]]]);
  14. *
  15. * var clipped = turf.bboxClip(poly, bbox);
  16. *
  17. * //addToMap
  18. * var addToMap = [bbox, poly, clipped]
  19. */
  20. declare function bboxClip<G extends Polygon | MultiPolygon | LineString | MultiLineString, P extends GeoJsonProperties = GeoJsonProperties>(feature: Feature<G, P> | G, bbox: BBox): Feature<LineString, P | {}> | Feature<MultiLineString, P | {}> | Feature<Polygon, P | {}> | Feature<MultiPolygon, P | {}>;
  21. export { bboxClip, bboxClip as default };