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

multiPoint

该Turf模块用于创建包含多个点的点集合。

安装

通过npm进行安装:

npm install @turf/multi-point

用法

import multiPoint from '@turf/multi-point';

const coordinates = [
  [-77.032, 38.913],
  [-122.414, 37.776],
  [-77.206, 38.88]
];

const points = multiPoint(coordinates);

参数

  • coordinates (Array<Array<number>>): 一个由点坐标组成的数组,格式为 [[longitude, latitude], [longitude, latitude], ...]。

输出

函数将返回一个Turf Point类型的GeoJSON Feature对象。

示例

const coordinates = [
  [-77.032, 38.913],
  [-122.414, 37.776],
  [-77.206, 38.88]
];

const points = multiPoint(coordinates);

console.log(points);

输出结果:

{
  "type": "Feature",
  "properties": {},
  "geometry": {
    "type": "MultiPoint",
    "coordinates": [
      [-77.032, 38.913],
      [-122.414, 37.776],
      [-77.206, 38.88]
    ]
  }
}

注意事项

  • 输入的点坐标顺序会保留在输出的MultiPoint对象中。
  • 输入的点坐标数组中必须至少包含两个点。如果只有一个点,则应该使用Turf Point模块来创建一个单独的点。