bboxClip
描述
¥Description
获取 特性 和边界框,并使用 lineclip 将要素裁剪到边界框内。裁剪多边形时可能会导致边缘退化。
¥Takes a Feature and a bbox and clips the feature to the bbox using lineclip. May result in degenerate edges when clipping Polygons.
参数
¥Parameters
名称 | 类型 | 描述 |
---|---|---|
feature | 特性<LineString | MultiLineString | 多边形 | MultiPolygon> | 要裁剪到边界框的特性 |
bbox | BBox | 按 [minX, minY, maxX, maxY] 顺序排列的范围 |
返回
¥Returns
特性<LineString | MultiLineString | 多边形 | MultiPolygon> 裁剪后的要素
¥Feature<LineString | MultiLineString | Polygon | MultiPolygon> clipped Feature
示例
¥Examples
var bbox = [0, 0, 10, 10];
var poly = turf.polygon([
[
[2, 2],
[8, 4],
[12, 8],
[3, 7],
[2, 2],
],
]);
var clipped = turf.bboxClip(poly, bbox);
安装
¥Installation
$ npm install @turf/bbox-clip
import { bboxClip } from "@turf/bbox-clip";
const result = bboxClip(...);
$ npm install @turf/turf
import * as turf from "@turf/turf";
const result = turf.bboxClip(...);