lineOverlap
函数计算两条线段是否有重叠区域,并返回重叠线段的几何信息。
line1
:Array<Array<Number>> 第一条线段的坐标数组,形如 [[x1, y1], [x2, y2]]
line2
:Array<Array<Number>> 第二条线段的坐标数组,形如 [[x3, y3], [x4, y4]]
Object
:重叠线段的几何信息对象,包括以下属性:
overlap
: Boolean,是否存在重叠部分line1
: Array<Array<Number>>,重叠部分在第一条线段上的坐标数组line2
: Array<Array<Number>>,重叠部分在第二条线段上的坐标数组var line1 = [[0,0],[5,5]];
var line2 = [[5,5],[10,10]];
var overlap = turf.lineOverlap(line1, line2);
// 返回结果: {"overlap": true, "line1": [[5,5]], "line2": [[5,5]]}