MultiPolygon
是一种几何对象,它由一个或多个 Polygon
组成。它可以表示一个由多个多边形构成的区域。
multipolygons
(Array.<Array.<Array.<Array.<Number>>>>): 一个由多个 Polygon
组成的数组。每个 Polygon
是一个由多个点组成的数组,每个点由经度和纬度组成。MultiPolygon
):返回一个 MultiPolygon
对象。var multipolygons = [
[
[[0, 0], [0, 1], [1, 1], [1, 0], [0, 0]], // polygon 1
[[0.2, 0.2], [0.2, 0.4], [0.4, 0.4], [0.4, 0.2], [0.2, 0.2]] // polygon 2
],
[
[[2, 2], [2, 3], [3, 3], [3, 2], [2, 2]], // polygon 3
[[2.2, 2.2], [2.2, 2.4], [2.4, 2.4], [2.4, 2.2], [2.2, 2.2]] // polygon 4
]
];
var multiPolygon = turf.multiPolygon(multipolygons);
MultiPolygon
对象中的每个 Polygon
可以有自己的属性。可以通过在 Polygon
对象中添加属性来实现。var multipolygons = [
[
{
"name": "polygon 1",
"coordinates": [[...], [...], ...],
"properties": {
"color": "red"
}
}
],
[
{
"name": "polygon 2",
"coordinates": [[...], [...], ...],
"properties": {
"color": "green"
}
}
]
];
var multiPolygon = turf.multiPolygon(multipolygons);