Turf的lineIntersect
函数是用于计算两条线之间的交点的函数。它将返回两条线之间的交点坐标数组。
turf.lineIntersect(line1, line2)
line1
(Feature<LineString>): 第一条用于计算交点的线line2
(Feature<LineString>): 第二条用于计算交点的线results
(FeatureCollection<Point>): 一个包含所有交点坐标的FeatureCollection对象。var line1 = turf.lineString([[0, 0], [10, 10]]);
var line2 = turf.lineString([[0, 10], [10, 0]]);
var intersects = turf.lineIntersect(line1, line2);
console.log(intersects);
输出:
{
"type": "FeatureCollection",
"features": [
{
"type": "Feature",
"geometry": {
"type": "Point",
"coordinates": [
5,
5
]
},
"properties": {}
}
]
}