mirror of
https://github.com/CIMEngine/cimengine-build-tools.git
synced 2024-11-21 19:56:22 +03:00
feat: area
This commit is contained in:
parent
4c340926bf
commit
ace13c9b01
3 changed files with 9 additions and 6 deletions
4
package-lock.json
generated
4
package-lock.json
generated
|
@ -1,12 +1,12 @@
|
|||
{
|
||||
"name": "cimengine-build-tools",
|
||||
"version": "1.2.2",
|
||||
"version": "1.3.0",
|
||||
"lockfileVersion": 3,
|
||||
"requires": true,
|
||||
"packages": {
|
||||
"": {
|
||||
"name": "cimengine-build-tools",
|
||||
"version": "1.2.2",
|
||||
"version": "1.3.0",
|
||||
"license": "MIT",
|
||||
"dependencies": {
|
||||
"@turf/turf": "^6.5.0",
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
{
|
||||
"name": "cimengine-build-tools",
|
||||
"version": "1.2.2",
|
||||
"version": "1.3.0",
|
||||
"description": "Geojson data processing tools for CIMEngine",
|
||||
"main": "index.js",
|
||||
"scripts": {
|
||||
|
|
|
@ -379,16 +379,19 @@ if (config?.reProperty) {
|
|||
console.log();
|
||||
}
|
||||
|
||||
console.log("Set new ids");
|
||||
console.time("Set new ids");
|
||||
console.log("Set new ids and area");
|
||||
console.time("Set new ids and area");
|
||||
|
||||
let id = 0;
|
||||
geo.features = geo.features.map((val) => {
|
||||
val.id = id++;
|
||||
val.properties.area = (turf.area(val) / 1000000)
|
||||
.toFixed(2)
|
||||
.replace(/(\d)(?=(\d\d\d)+([^\d]|$))/g, "$1 ");
|
||||
return val;
|
||||
});
|
||||
|
||||
console.timeEnd("Set new ids");
|
||||
console.timeEnd("Set new ids and area");
|
||||
|
||||
fs.writeFileSync(geofixConf.output, JSON.stringify(geo, null, " "));
|
||||
console.timeEnd("Total");
|
||||
|
|
Loading…
Add table
Reference in a new issue