Skip to main content
Version: Next

lineString

描述

¥Description

Creates a LineString 特性 from an Array of Positions.

¥Creates a LineString Feature from an Array of Positions.

参数

¥Parameters

名称类型描述
coordinates数组<位置>位置数组
properties?GeoJsonPropertiesan Object of key-value pairs to add as properties (default )
options?对象可选参数(默认
options.bbox?BBoxBounding Box Array [west, south, east, north] associated with the Feature
options.id?IDIdentifier associated with the Feature

返回

¥Returns

特性<LineString, GeoJsonProperties> 线串要素

¥Feature<LineString, GeoJsonProperties> LineString Feature

示例

¥Examples

var linestring1 = turf.lineString(
[
[-24, 63],
[-23, 60],
[-25, 65],
[-20, 69],
],
{ name: "line 1" },
);
var linestring2 = turf.lineString(
[
[-14, 43],
[-13, 40],
[-15, 45],
[-10, 49],
],
{ name: "line 2" },
);

//=linestring1
//=linestring2

安装

¥Installation

$ npm install @turf/helpers

import { lineString } from "@turf/helpers";
const result = lineString(...);
$ npm install @turf/turf

import * as turf from "@turf/turf";
const result = turf.lineString(...);