描述
接收任何 LineString 或 Polygon GeoJSON 并返回相交点。
参数
| 名称 | 类型 | 描述 |
|---|---|---|
| line1 | GeoJSON | 任何 LineString 或 Polygon |
| line2 | GeoJSON | 任何 LineString 或 Polygon |
| options? | Object | 可选参数 (默认 {}) |
| options.removeDuplicates? | boolean | 移除重复的交点 (默认 true) |
| options.ignoreSelfIntersections? | boolean | 忽略输入要素的自相交 (默认 true) |
返回值
FeatureCollection<Point> 与两者相交的点
示例
javascript
var line1 = turf.lineString([
[126, -11],
[129, -21],
]);
var line2 = turf.lineString([
[123, -18],
[131, -14],
]);
var intersects = turf.lineIntersect(line1, line2);安装
javascript
$ npm install @turf/line-intersect
import { lineIntersect } from "@turf/line-intersect";
const result = lineIntersect(...);javascript
$ npm install @turf/turf
import * as turf from "@turf/turf";
const result = turf.lineIntersect(...);