index.d.ts 1.0 KB

1234567891011121314151617181920
  1. import { BBox, Feature, LineString, MultiLineString, MultiPolygon, Polygon, Properties } from "@turf/helpers";
  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. * @name bboxClip
  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. export default function bboxClip<G extends Polygon | MultiPolygon | LineString | MultiLineString, P = Properties>(feature: Feature<G, P> | G, bbox: BBox): Feature<LineString, {}> | Feature<MultiLineString, {}> | Feature<Polygon, {}> | Feature<MultiPolygon, {}>;