mirror of
https://github.com/CIMEngine/cimengine-build-tools.git
synced 2024-11-24 04:56:21 +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",
|
"name": "cimengine-build-tools",
|
||||||
"version": "1.4.3",
|
"version": "1.5.0",
|
||||||
"lockfileVersion": 3,
|
"lockfileVersion": 3,
|
||||||
"requires": true,
|
"requires": true,
|
||||||
"packages": {
|
"packages": {
|
||||||
"": {
|
"": {
|
||||||
"name": "cimengine-build-tools",
|
"name": "cimengine-build-tools",
|
||||||
"version": "1.4.3",
|
"version": "1.5.0",
|
||||||
"license": "MIT",
|
"license": "MIT",
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"@turf/turf": "^6.5.0",
|
"@turf/turf": "^6.5.0",
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
{
|
{
|
||||||
"name": "cimengine-build-tools",
|
"name": "cimengine-build-tools",
|
||||||
"version": "1.4.3",
|
"version": "1.5.0",
|
||||||
"description": "Geojson data processing tools for CIMEngine",
|
"description": "Geojson data processing tools for CIMEngine",
|
||||||
"main": "index.js",
|
"main": "index.js",
|
||||||
"scripts": {
|
"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) => {
|
co_features.features = co_features.features.map((val) => {
|
||||||
if (val?.geometry?.type === "Polygon") {
|
if (val?.geometry?.type.endsWith("Polygon")) {
|
||||||
val.properties = {};
|
val.properties = {};
|
||||||
} else if (val?.geometry?.type === "MultiPolygon") {
|
|
||||||
console.error("Error: MultiPolygons are not allowed!");
|
|
||||||
process.exit(1);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
return val;
|
return val;
|
||||||
|
|
Loading…
Add table
Reference in a new issue