我有一个数组(Geojson 文件),我想将它分成三个数组。有一些多边形坐标,我想为每个 id 放置连续的坐标,我想得到:
arrGeo =
[
[-4.66478, 58.42441, 5127.4,-4.65982, 58.42082, 5074.7],
[-3.94815, 57.71632, 5000,-3.94812, 57.71576, 4374.1,-3.94216, 57.71541, 4283,-3.93717,
57.71583, 5001],
[-3.93224, 57.71476, 4048,-3.93261, 57.71456, 3800.4]
]
我尝试通过使用 for 循环来做到这一点,但我无法将它们分开,我的意思是我需要为每个 ID 创建单独的坐标数组。我的代码有什么问题?我应该怎么做才能解决它?
这是我的代码:
positions =
[
{
"type": "Feature",
"geometry": {
"type": "GeometryCollection",
"geometries": [
{
"type": "Polygon",
"coordinates": [
[
[-4.66478, 58.42441, 5127.4],
[-4.65982, 58.42082, 5074.7],
]
]
},
]
},
"id": "kml_1"
},
{
"type": "Feature",
"geometry": {
"type": "GeometryCollection",
"geometries": [
{
"type": "Polygon",
"coordinates": [
[
[-3.94815, 57.71632, 5000],
[-3.94812, 57.71576, 4374.1],
]
]
},
{
"type": "Polygon",
"coordinates": [
[
[-3.94216, 57.71541, 4283],
[-3.93717, 57.71583, 5001],
]
]
},
]
},
"id": "kml_2"
},