mirror of
https://github.com/CIMEngine/cimengine-build-tools.git
synced 2024-11-05 20:53:58 +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
4
package-lock.json
generated
4
package-lock.json
generated
|
@ -1,12 +1,12 @@
|
|||
{
|
||||
"name": "cimengine-build-tools",
|
||||
"version": "1.4.3",
|
||||
"version": "1.5.0",
|
||||
"lockfileVersion": 3,
|
||||
"requires": true,
|
||||
"packages": {
|
||||
"": {
|
||||
"name": "cimengine-build-tools",
|
||||
"version": "1.4.3",
|
||||
"version": "1.5.0",
|
||||
"license": "MIT",
|
||||
"dependencies": {
|
||||
"@turf/turf": "^6.5.0",
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
{
|
||||
"name": "cimengine-build-tools",
|
||||
"version": "1.4.3",
|
||||
"version": "1.5.0",
|
||||
"description": "Geojson data processing tools for CIMEngine",
|
||||
"main": "index.js",
|
||||
"scripts": {
|
||||
|
|
|
@ -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…
Reference in a new issue