mirror of
https://github.com/CIMEngine/cimengine-build-tools.git
synced 2025-02-20 19:33:12 +03:00
feat: convert all multipolygons to polygons
This commit is contained in:
parent
0153fbd617
commit
e12d8f54d4
3 changed files with 20 additions and 7 deletions
|
@ -42,12 +42,25 @@ for (country of layers) {
|
|||
)
|
||||
);
|
||||
|
||||
co_features.features = co_features.features.flatMap((val) => {
|
||||
if (val?.geometry?.type === "MultiPolygon") {
|
||||
return val.geometry.coordinates.map((coordinateSet) => {
|
||||
return {
|
||||
...val,
|
||||
geometry: {
|
||||
type: "Polygon",
|
||||
coordinates: coordinateSet,
|
||||
},
|
||||
};
|
||||
});
|
||||
} else {
|
||||
return val;
|
||||
}
|
||||
});
|
||||
|
||||
co_features.features = co_features.features.map((val) => {
|
||||
if (val?.geometry?.type === "Polygon") {
|
||||
if (val?.geometry?.type.endsWith("Polygon")) {
|
||||
val.properties = {};
|
||||
} else if (val?.geometry?.type === "MultiPolygon") {
|
||||
console.error("Error: MultiPolygons are not allowed!");
|
||||
process.exit(1);
|
||||
}
|
||||
|
||||
return val;
|
||||
|
|
Loading…
Add table
Reference in a new issue