Skip to content

Interactive interface for browsing global, full-resolution satellite imagery

extractConfigFromWMTS conversion wip

ZachTRicef14774f835fa
diff --git a/tasks/buildOptions.sh b/tasks/buildOptions.sh
index 7a8f559b4..96bfe8f63 100755
--- a/tasks/buildOptions.sh
+++ b/tasks/buildOptions.sh
@@ -78,10 +78,12 @@ if [ -e "$BUILD_DIR/features.json" ] ; then
fi
# # Run extractConfigFromWMTS.py script with config.json
-# if [ -e "$BUILD_DIR/config.json" ] ; then
-# "$PYTHON_SCRIPTS_DIR/extractConfigFromWMTS.py" "$BUILD_DIR/config.json" "$BUILD_DIR/gc" \
-# "$BUILD_DIR/_wmts"
-# fi
+if [ -e "$BUILD_DIR/config.json" ] ; then
+ `node $NODE_SCRIPTS_DIR/extractConfigFromWMTS.js \
+ --config "$BUILD_DIR/config.json" \
+ --inputDir "$BUILD_DIR/gc" \
+ --outputDir "$BUILD_DIR/_wmts"
+fi
# # Run processVectorStyles.py and move vectorstyles where we want them
# if [ -e "$BUILD_DIR/gc/vectorstyles" ] ; then
diff --git a/tasks/node/extractConfigFromWMTS.js b/tasks/node/extractConfigFromWMTS.js
new file mode 100755
index 000000000..8de0c6ab1
--- /dev/null
+++ b/tasks/node/extractConfigFromWMTS.js
@@ -0,0 +1,81 @@
+const fs = require('fs')
+const path = require('path')
+const yargs = require('yargs')
+const console = require('console')
+
+const prog = path.basename(__filename)
+
+const options = yargs
+ .usage('Usage: $0 [options]')
+ .option('config', {
+ demandOption: true,
+ alias: 'c',
+ type: 'string',
+ description: 'config file'
+ })
+ .option('inputDir', {
+ demandOption: true,
+ alias: 'i',
+ type: 'string',
+ description: 'getcapabilities input directory'
+ })
+ .option('outputDir', {
+ demandOption: true,
+ alias: 'o',
+ type: 'string',
+ description: 'wmts output directory'
+ })
+ .epilog('Extracts configuration information from a WMTS GetCapabilities file, converts the XML to JSON')
+
+const { argv } = options
+if (!argv.config && !argv.inputDir && !argv.outputDir) {
+ throw new Error('Invalid number of arguments')
+}
+
+const configFile = argv.config
+const configData = fs.readFileSync(configFile)
+const config = JSON.parse(configData)
+// const inputDir = argv.inputDir
+const outputDir = argv.outputDir
+
+if (!Object.prototype.hasOwnProperty.call(config, 'wv-options-wmts')) {
+ throw new Error(`${prog}: Error: "wv-options-wmts" not in config file`)
+}
+
+if (!fs.existsSync(outputDir)) {
+ fs.mkdirSync(outputDir)
+}
+
+// const tolerant = config.tolerant
+const entries = config['wv-options-wmts']
+// let skip = []
+
+// if (config.skip) {
+// skip = config.skip
+// }
+
+// const totalLayerCount = 0
+// const totalWarningCount = 0
+// const totalErrorCount = 0
+
+async function main () {
+ for (entry of entries) {
+ processEntry(entry)
+ }
+}
+
+async function processLayer (gcLayer, wvLayers, entry) {
+
+}
+
+async function processEntry (entry) {
+ try {
+ processLayer()
+ } catch (error) {
+
+ }
+}
+
+main().catch((err) => {
+ console.error(err.stack)
+})
diff --git a/tasks/node/validateConfigs.js b/tasks/node/validateConfigs.js
index a53e520eb..7102b2463 100755
--- a/tasks/node/validateConfigs.js
+++ b/tasks/node/validateConfigs.js
@@ -12,17 +12,17 @@ const options = yargs
.usage('Usage: $0 [options]')
.option('inputDirectory', {
demandOption: true,
- alias: 'o',
+ alias: 'i',
type: 'string',
description: 'the wv.json layers directory'
})
.option('schemaFile', {
demandOption: true,
- alias: 'c',
+ alias: 's',
type: 'string',
description: 'layer-config.json schema'
})
- .epilog('Pulls visualization metadata files')
+ .epilog('Validates layers using a JSON schema')
const { argv } = options
if (!argv.inputDirectory && !argv.schemaFile) {