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

lineSliceAlong

lineSliceAlong 是 Turf 的 Misc(杂项)模块中的函数之一,用于沿着线段从起点到终点截取一段子线段。

参数

  • line:Type:Feature<LineString> 沿着该线段截取子线段。
  • startDist:Type:number 起点的距离线段起点的距离。
  • stopDist:Type:number 终点的距离线段起点的距离。

返回值

Type:Feature<LineString> 返回截取后的子线段。

示例

var line = turf.lineString([[-77.031669, 38.878605], [-77.029609, 38.881946], [-77.020339, 38.884084], [-77.025661, 38.885821], [-77.021884, 38.889563]]);
var sliced = turf.lineSliceAlong(line, 0, 1000);
console.log(sliced);

返回结果:

{
  "type": "Feature",
  "geometry": {
    "type": "LineString",
    "coordinates": [
      [-77.031669, 38.878605],
      [-77.029609, 38.881946],
      [-77.020339, 38.884084]
    ]
  },
  "properties": {}
}

以上示例中,输入的线段 line 有5个点,然后截取了距离线段起点1000个单位距离处的子线段 sliced