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

coordAll

coordAll函数将给定线或多边形的坐标转换为一个坐标数组,其中每个坐标由[longitude,latitude]组成。

参数

  • geojson (GeoJSON对象):要转换的线或多边形

  • options (可选对象):可以使用以下属性:

    • order (字符串):指定输出坐标数组中经度和纬度的顺序。有效值是["latlong", "longlat"]。默认为"latlong"

返回值

  • (坐标数组):该函数返回一组由[longitude,latitude]组成的坐标数组。

示例

var polygon = turf.polygon([[
  [-77.031669, 38.878605],
  [-77.029609, 38.881946],
  [-77.020339, 38.884084],
  [-77.025661, 38.885821],
  [-77.021884, 38.889563],
  [-77.019824, 38.892368],
  [-77.022124, 38.893704],
  [-77.023705, 38.892368],
  [-77.022915, 38.890155],
  [-77.025319, 38.888789],
  [-77.027723, 38.88886],
  [-77.029783, 38.886017],
  [-77.031669, 38.878605]
]], { name: 'poly1' });
var coords = turf.coordAll(polygon);

//=coords
//
//[
//  [-77.031669, 38.878605],
//  [-77.029609, 38.881946],
//  [-77.020339, 38.884084],
//  [-77.025661, 38.885821],
//  [-77.021884, 38.889563],
//  [-77.019824, 38.892368],
//  [-77.022124, 38.893704],
//  [-77.023705, 38.892368],
//  [-77.022915, 38.890155],
//  [-77.025319, 38.888789],
//  [-77.027723, 38.88886],
//  [-77.029783, 38.886017],
//  [-77.031669, 38.878605]
//]
//

注意事项

  • coordAll返回的坐标数组的第一个值和最后一个值是相等的,因为多边形和线在构造时总是通过重复第一个坐标来关闭多边形或线。