-
-
Notifications
You must be signed in to change notification settings - Fork 98
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
d860ed7
commit 5da82a2
Showing
1 changed file
with
42 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,42 @@ | ||
const fs = require('fs'); | ||
const path = require('path'); | ||
|
||
var template = { type: "FeatureCollection", name: "fix", crs: { type: "name", properties: { name: "urn:ogc:def:crs:OGC:1.3:CRS84" } }, features: [] } | ||
|
||
const files = []; | ||
traverseDir(path.join(__dirname, "Boundaries")); | ||
|
||
let promises = files.map(function(value, index) { | ||
return new Promise(function(resolve) { | ||
fs.readFile(value, 'utf8', (err, data) => { | ||
if (err) { | ||
console.error(err); | ||
return; | ||
} | ||
template.features.push(JSON.parse(data)); | ||
resolve(); | ||
}) | ||
}) | ||
}) | ||
|
||
Promise.all(promises).then(function() { | ||
fs.writeFile(__dirname + "/TRACONBoundaries.geojson", JSON.stringify(template), err => { | ||
if (err) { | ||
console.error(err); | ||
} | ||
}); | ||
}); | ||
|
||
function traverseDir(dir) { | ||
fs.readdirSync(dir).forEach(file => { | ||
let fullPath = path.join(dir, file); | ||
if (fs.lstatSync(fullPath).isDirectory()) { | ||
traverseDir(fullPath); | ||
} else { | ||
if (!path.dirname(fullPath).toLowerCase().includes("node_modules") && | ||
path.extname(fullPath).toLowerCase() === ".json") { | ||
files.push(fullPath); | ||
} | ||
} | ||
}) | ||
} |