Skip to content

Interactive interface for browsing global, full-resolution satellite imagery

wip

ZachTRice7fc09d20d63c
diff --git a/tasks/node/extractConfigFromWMTS.js b/tasks/node/extractConfigFromWMTS.js
index 972f87f16..1215656c8 100755
--- a/tasks/node/extractConfigFromWMTS.js
+++ b/tasks/node/extractConfigFromWMTS.js
@@ -75,9 +75,9 @@ async function main () {
}
}
-async function processLayer (gcLayer, wvLayers, entry) {
+// async function processLayer (gcLayer, wvLayers, entry) {
-}
+// }
async function processEntry (entry) {
const inputFile = path.join(inputDir, entry.from)
@@ -87,7 +87,7 @@ async function processEntry (entry) {
layers: {},
sources: {}
}
- const wvMatrixSets = {}
+ // const wvMatrixSets = {}
let gc
@@ -118,9 +118,9 @@ async function processEntry (entry) {
}
}
-async function processMatrixSet (gcMatricSet) {
+// async function processMatrixSet (gcMatricSet) {
-}
+// }
main().catch((err) => {
console.error(err.stack)
diff --git a/tasks/node/generateCategoryGroupOrder.js b/tasks/node/generateCategoryGroupOrder.js
new file mode 100644
index 000000000..1a83f1456
--- /dev/null
+++ b/tasks/node/generateCategoryGroupOrder.js
@@ -0,0 +1,67 @@
+const fs = require('fs')
+const path = require('path')
+
+const prog = path.basename(__filename)
+
+const inputDir = process.argv[2]
+const outputDir = process.argv[3]
+
+if (!inputDir || !outputDir) {
+ throw new Error(`Usage: node ${prog} <input_dir> <output_dir>`)
+}
+
+const categoryDirectory = inputDir
+
+const categoryDict = {}
+
+const walk = (dir, callback) => {
+ fs.readdirSync(dir).forEach(f => {
+ const dirPath = path.join(dir, f)
+ const isDirectory = fs.statSync(dirPath).isDirectory()
+ isDirectory ? walk(dirPath, callback) : callback(path.join(dir, f))
+ })
+}
+
+const processFile = async filePath => {
+ return new Promise((resolve, reject) => {
+ fs.readFile(filePath, 'utf8', (err, data) => {
+ if (err) {
+ console.error(`${prog} ERROR: Could not read category config. Check formatting of: ${filePath}`)
+ reject(err)
+ }
+ try {
+ const config = JSON.parse(data)
+ const category = config.categories[0]
+ categoryDict[category] = true
+ resolve()
+ } catch (e) {
+ console.error(`${prog} ERROR: Could not read category config. Check formatting of: ${filePath}`)
+ reject(e)
+ }
+ })
+ })
+}
+
+const main = async () => {
+ try {
+ walk(categoryDirectory, filePath => {
+ processFile(filePath)
+ })
+ await fs.promises.writeFile(
+ path.join(outputDir, 'categoryGroupOrder.json'),
+ JSON.stringify({ categoryGroupOrder: Object.keys(categoryDict) }, null, 2),
+ 'utf8'
+ )
+ console.log(
+ `${prog} Successfully generated categoryGroupOrder.json with these categories: ${Object.keys(
+ categoryDict
+ )}`
+ )
+ } catch (err) {
+ throw new Error(`${prog} ERROR: Could not write categoryGroupOrder.json`)
+ }
+}
+
+main().catch((err) => {
+ console.error(err.stack)
+})