MEASUREMENT
COORDINATE MUTATION
TRANSFORMATION
FEATURE_CONVERSION
MISC
HELPER
RANDOM
GRIDS
AGGREGATION
META
ASSERTIONS
BOOLEANS
UNIT CONVERSION
DATA
JOINS
CLASSIFICATION

lineOverlap

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]]}