mirror of
https://github.com/CIMEngine/cimengine-build-tools.git
synced 2024-11-24 04:56:21 +03:00
fix: area calculation only for countries
This commit is contained in:
parent
ace13c9b01
commit
98f9f5ae72
3 changed files with 8 additions and 6 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.3.0",
|
"version": "1.3.1",
|
||||||
"lockfileVersion": 3,
|
"lockfileVersion": 3,
|
||||||
"requires": true,
|
"requires": true,
|
||||||
"packages": {
|
"packages": {
|
||||||
"": {
|
"": {
|
||||||
"name": "cimengine-build-tools",
|
"name": "cimengine-build-tools",
|
||||||
"version": "1.3.0",
|
"version": "1.3.1",
|
||||||
"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.3.0",
|
"version": "1.3.1",
|
||||||
"description": "Geojson data processing tools for CIMEngine",
|
"description": "Geojson data processing tools for CIMEngine",
|
||||||
"main": "index.js",
|
"main": "index.js",
|
||||||
"scripts": {
|
"scripts": {
|
||||||
|
|
|
@ -385,9 +385,11 @@ console.time("Set new ids and area");
|
||||||
let id = 0;
|
let id = 0;
|
||||||
geo.features = geo.features.map((val) => {
|
geo.features = geo.features.map((val) => {
|
||||||
val.id = id++;
|
val.id = id++;
|
||||||
val.properties.area = (turf.area(val) / 1000000)
|
if (val.geometry.type === "MultiPolygon") {
|
||||||
.toFixed(2)
|
val.properties.area = (turf.area(val) / 1000000)
|
||||||
.replace(/(\d)(?=(\d\d\d)+([^\d]|$))/g, "$1 ");
|
.toFixed(2)
|
||||||
|
.replace(/(\d)(?=(\d\d\d)+([^\d]|$))/g, "$1 ");
|
||||||
|
}
|
||||||
return val;
|
return val;
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|
Loading…
Add table
Reference in a new issue