Interactive interface for browsing global, full-resolution satellite imagery
Finish fixing build scripts
ZachTRice6e884d333e05
diff --git a/package.json b/package.jsonindex 0f6ef5b4d..03e5a705f 100644--- a/package.json+++ b/package.json@@ -39,8 +39,8 @@"build:dev": "cross-env NODE_ENV=development webpack","build:prod": "cross-env NODE_ENV=production webpack","clean": "node ./tasks/util/clean.js",- "dist": "run-s clean getcapabilities build:config build:prod && node ./tasks/dist.js",- "dist:dev": "run-s clean getcapabilities build:config build:dev && node ./tasks/dist.js",+ "dist": "run-s clean getcapabilities build:config build:prod && node ./tasks/util/dist.js",+ "dist:dev": "run-s clean getcapabilities build:config build:dev && node ./tasks/util/dist.js","distclean": "npm run clean && node ./tasks/util/distclean.js","docker:ci": "npm run docker:restart && docker exec -it worldview /bin/bash /build/e2e/docker-ci.sh ; npm run docker:stop","docker:image": "docker build -t worldview .",diff --git a/tasks/build-options/getVisMetadata.js b/tasks/build-options/getVisMetadata.jsindex 5b50a183a..af918fde4 100644--- a/tasks/build-options/getVisMetadata.js+++ b/tasks/build-options/getVisMetadata.js@@ -105,11 +105,15 @@ async function getDAAC (metadata) {if (!Array.isArray(metadata.conceptIds) || !metadata.conceptIds.length) {return metadata}- for (collection in metadata.conceptIds) {- origDataCenter = collection.dataCenter- dataCenter = daacMap.origDataCenter- if (!dataCenter && !metadata.dataCenter) {- metadata.dataCenter === [dataCenter]+ for (collection of metadata.conceptIds) {+ const origDataCenter = collection.dataCenter+ const dataCenter = daacMap[origDataCenter]+ if (!dataCenter) {+ continue+ }+ await delete collection.dataCenter+ if (!metadata.dataCenter) {+ metadata.dataCenter = [dataCenter]} else if (!metadata.dataCenter.includes(dataCenter)) {metadata.dataCenter.push(dataCenter)}diff --git a/tasks/build-options/processColormap.js b/tasks/build-options/processColormap.jsindex 8a4889472..f2be035d8 100755--- a/tasks/build-options/processColormap.js+++ b/tasks/build-options/processColormap.js@@ -155,7 +155,7 @@ async function processEntries (colormap) {const rHex = parseInt(r).toString(16).padStart(2, '0')const gHex = parseInt(g).toString(16).padStart(2, '0')const bHex = parseInt(b).toString(16).padStart(2, '0')- const colorString = '#' + rHex + gHex + bHex + 'ff'+ const colorString = rHex + gHex + bHex + 'ff'colors.push(colorString)if (mapType === 'continuous' || mapType === 'discrete') {@@ -172,6 +172,7 @@ async function processEntries (colormap) {}newItems.push(v)}+ values.push(newItems)} catch (error) {throw new Error(`Invalid value: ${entry._attributes.value}`)}@@ -185,7 +186,7 @@ async function processEntries (colormap) {await Promise.all(legends.map(async (entry, index) => {if (refSkipList.includes(entry._attributes.id)) {- skipIndex += 1+ skipIndex++}const [r, g, b] = entry._attributes.rgb.split(',')@@ -195,7 +196,6 @@ async function processEntries (colormap) {const bHex = parseInt(b).toString(16).padStart(2, '0')const colorString = rHex + gHex + bHex + 'ff'- colors.push(colorString)legendColors.push(colorString)if (!entry._attributes.tooltip) {throw new Error('No tooltips in legend')@@ -206,7 +206,7 @@ async function processEntries (colormap) {}idList.push(entry._attributes.id)if (entry._attributes.showTick) {- ticks.push(index - skipIndex)+ ticks.push(skipIndex - 1)}}))diff --git a/tasks/buildOptions.sh b/tasks/buildOptions.shindex 8635e01de..8bc79470a 100755--- a/tasks/buildOptions.sh+++ b/tasks/buildOptions.sh@@ -47,118 +47,115 @@ fimkdir -p "$DEST_DIR/config"mkdir -p "$BUILD_DIR/colormaps"-# TODO: dataCenter merging is not working properly, check the wv.json file--# # If $FETCH_GC is set, make various API requests-# if [ "$FETCH_GC" ] ; then-# # Fetch GC files and create colormaps, vectordata and vectorstyle files-# rm -rf "$OPT_DIR/$OPT_SUBDIR/gc/*"-# rm -rf "$OPT_DIR/$OPT_SUBDIR/colormaps/gc/*"-# `node $SCRIPTS_DIR/getCapabilities.js \-# --config "$OPT_DIR/$OPT_SUBDIR/config.json" \-# --getcapabilities "$OPT_DIR/$OPT_SUBDIR/gc"`--# # Get metadata for files in layerOrder.json and combine this data into 1 file-# rm -rf "$OPT_DIR/$OPT_SUBDIR/layer-metadata"-# mkdir -p "$OPT_DIR/$OPT_SUBDIR/layer-metadata"-# `node $SCRIPTS_DIR/getVisMetadata.js \-# --features "$BUILD_DIR/features.json" \-# --layerOrder "$BUILD_DIR/config/wv.json/layerOrder.json" \-# --layerMetadata "$OPT_DIR/$OPT_SUBDIR/layer-metadata/all.json"`-# fi--# Validate layers in wv.json with a JSON schema-`node $SCRIPTS_DIR/validateConfigs.js \- --inputDirectory "$SRC_DIR/common/config/wv.json/layers" \- --schemaFile "$BASE/schemas/layer-config.json"`--if [ -e "$BUILD_DIR/features.json" ] ; then- cp "$BUILD_DIR/features.json" "$BUILD_DIR/config/wv.json/_features.json"-fi--# Run extractConfigFromWMTS.js script with config.json-if [ -e "$BUILD_DIR/config.json" ] ; then- `node $SCRIPTS_DIR/extractConfigFromWMTS.js \- --config "$BUILD_DIR/config.json" \- --inputDir "$BUILD_DIR/gc" \- --outputDir "$BUILD_DIR/_wmts"`-fi--# Run processVectorStyles.js and move vectorstyles where we want them-if [ -e "$BUILD_DIR/gc/vectorstyles" ] ; then- mkdir -p "$BUILD_DIR/config/wv.json/vectorstyles"- `node $SCRIPTS_DIR/processVectorStyles.js \- --inputDir "$BUILD_DIR/gc/vectorstyles" \- --outputDir "$BUILD_DIR/config/wv.json/vectorstyles"`-fi--# Run processVectorData.js and move vectordata where we want them-if [ -e "$BUILD_DIR/gc/vectordata" ] ; then- mkdir -p "$BUILD_DIR/config/wv.json/vectordata"- `node $SCRIPTS_DIR/processVectorData.js \- --inputDir "$BUILD_DIR/gc/vectordata" \- --outputDir "$BUILD_DIR/config/wv.json/vectordata"`-fi--# Run processColormap.js and move colormaps where we want them-if [ -e "$BUILD_DIR/colormaps" ] ; then- mkdir -p "$BUILD_DIR"/config/palettes- if [ -d "$BUILD_DIR"/gc/colormaps ] ; then- cp -r "$BUILD_DIR"/gc/colormaps "$BUILD_DIR"/colormaps/gc- fi- `node $SCRIPTS_DIR/processColormap.js \+# If $FETCH_GC is set, make various API requests+if [ "$FETCH_GC" ] ; then+ # Fetch GC files and create colormaps, vectordata and vectorstyle files+ rm -rf "$OPT_DIR/$OPT_SUBDIR/gc/*"+ rm -rf "$OPT_DIR/$OPT_SUBDIR/colormaps/gc/*"+ `node $SCRIPTS_DIR/getCapabilities.js \--config "$OPT_DIR/$OPT_SUBDIR/config.json" \- --inputDir "$BUILD_DIR/colormaps" \- --outputDir "$BUILD_DIR/config/palettes"`-fi--# Throw error if no categoryGroupOrder.json file present-if [ ! -e "$BUILD_DIR/config/wv.json/categoryGroupOrder.json" ] ; then- echo "categoryGroupOrder.json not found. Generating..."- `node $SCRIPTS_DIR/generateCategoryGroupOrder.js \- --inputDir "$SRC_DIR/common/config/wv.json/categories/" \- --outputDir "$SRC_DIR/common/config/wv.json/"`-fi--if [ -e "$OPT_DIR/$OPT_SUBDIR/layer-metadata/all.json" ] ; then- cp "$OPT_DIR/$OPT_SUBDIR/layer-metadata/all.json" "$BUILD_DIR/config/wv.json/layer-metadata.json"+ --getcapabilities "$OPT_DIR/$OPT_SUBDIR/gc"`++ # Get metadata for files in layerOrder.json and combine this data into 1 file+ rm -rf "$OPT_DIR/$OPT_SUBDIR/layer-metadata"+ mkdir -p "$OPT_DIR/$OPT_SUBDIR/layer-metadata"+ `node $SCRIPTS_DIR/getVisMetadata.js \+ --features "$BUILD_DIR/features.json" \+ --layerOrder "$BUILD_DIR/config/wv.json/layerOrder.json" \+ --layerMetadata "$OPT_DIR/$OPT_SUBDIR/layer-metadata/all.json"`+else+ # Validate layers in wv.json with a JSON schema+ `node $SCRIPTS_DIR/validateConfigs.js \+ --inputDirectory "$SRC_DIR/common/config/wv.json/layers" \+ --schemaFile "$BASE/schemas/layer-config.json"`++ if [ -e "$BUILD_DIR/features.json" ] ; then+ cp "$BUILD_DIR/features.json" "$BUILD_DIR/config/wv.json/_features.json"+ fi++ # Run extractConfigFromWMTS.js script with config.json+ if [ -e "$BUILD_DIR/config.json" ] ; then+ `node $SCRIPTS_DIR/extractConfigFromWMTS.js \+ --config "$BUILD_DIR/config.json" \+ --inputDir "$BUILD_DIR/gc" \+ --outputDir "$BUILD_DIR/_wmts"`+ fi++ # Run processVectorStyles.js and move vectorstyles where we want them+ if [ -e "$BUILD_DIR/gc/vectorstyles" ] ; then+ mkdir -p "$BUILD_DIR/config/wv.json/vectorstyles"+ `node $SCRIPTS_DIR/processVectorStyles.js \+ --inputDir "$BUILD_DIR/gc/vectorstyles" \+ --outputDir "$BUILD_DIR/config/wv.json/vectorstyles"`+ fi++ # Run processVectorData.js and move vectordata where we want them+ if [ -e "$BUILD_DIR/gc/vectordata" ] ; then+ mkdir -p "$BUILD_DIR/config/wv.json/vectordata"+ `node $SCRIPTS_DIR/processVectorData.js \+ --inputDir "$BUILD_DIR/gc/vectordata" \+ --outputDir "$BUILD_DIR/config/wv.json/vectordata"`+ fi++ # Run processColormap.js and move colormaps where we want them+ if [ -e "$BUILD_DIR/colormaps" ] ; then+ mkdir -p "$BUILD_DIR"/config/palettes+ if [ -d "$BUILD_DIR"/gc/colormaps ] ; then+ cp -r "$BUILD_DIR"/gc/colormaps "$BUILD_DIR"/colormaps/gc+ fi+ `node $SCRIPTS_DIR/processColormap.js \+ --config "$OPT_DIR/$OPT_SUBDIR/config.json" \+ --inputDir "$BUILD_DIR/colormaps" \+ --outputDir "$BUILD_DIR/config/palettes"`+ fi++ # Throw error if no categoryGroupOrder.json file present+ if [ ! -e "$BUILD_DIR/config/wv.json/categoryGroupOrder.json" ] ; then+ echo "categoryGroupOrder.json not found. Generating..."+ `node $SCRIPTS_DIR/generateCategoryGroupOrder.js \+ --inputDir "$SRC_DIR/common/config/wv.json/categories/" \+ --outputDir "$SRC_DIR/common/config/wv.json/"`+ fi++ if [ -e "$OPT_DIR/$OPT_SUBDIR/layer-metadata/all.json" ] ; then+ cp "$OPT_DIR/$OPT_SUBDIR/layer-metadata/all.json" "$BUILD_DIR/config/wv.json/layer-metadata.json"+ fi++ # Run mergeConfig.js on each directory in /config containing .json files+ # This creates on palettes-custom.json and wv.json+ configs=$(ls "$BUILD_DIR/config")+ for config in $configs; do+ case $config in+ *.json)+ bash -c "node $SCRIPTS_DIR/mergeConfig.js \+ --inputDir '$BUILD_DIR/config/$config' \+ --outputFile '$DEST_DIR/config/$config'"+ ;;+ *)+ cp -r "$BUILD_DIR/config/$config" "$DEST_DIR/config/$config"+ ;;+ esac+ done++ # Run mergeConfigWithWMTS.js to merge layer metadata from WMTS GC with worldview layer configs into wv.json+ `node $SCRIPTS_DIR/mergeConfigWithWMTS.js \+ --inputDir "$BUILD_DIR/_wmts" \+ --outputFile "$DEST_DIR/config/wv.json"`++ # Copy brand files from build to dest+ cp -r "$BUILD_DIR/brand" "$DEST_DIR"+ cp "$BUILD_DIR/brand.json" "$DEST_DIR"+++ # Validate the options build+ `node $SCRIPTS_DIR/validateOptions.js \+ --optionsFile "$BUILD_DIR/config.json" \+ --configDir "$DEST_DIR/config"`++ # Fetch preview images from WV Snapshots for any layers which they are missing+ # `node $SCRIPTS_DIR/fetchPreviewSnapshots.js \+ # --wvJsonFile "$DEST_DIR/config/wv.json" \+ # --overridesFile "$OPT_DIR/common/previewLayerOverrides.json" \+ # --featuresFile "$BUILD_DIR/features.json"`fi--# Run mergeConfig.js on each directory in /config containing .json files-# This creates on palettes-custom.json and wv.json-configs=$(ls "$BUILD_DIR/config")-for config in $configs; do- case $config in- *.json)- bash -c "node $SCRIPTS_DIR/mergeConfig.js \- --inputDir '$BUILD_DIR/config/$config' \- --outputFile '$DEST_DIR/config/$config'"- ;;- *)- cp -r "$BUILD_DIR/config/$config" "$DEST_DIR/config/$config"- ;;- esac-done--# Run mergeConfigWithWMTS.js to merge layer metadata from WMTS GC with worldview layer configs into wv.json-`node $SCRIPTS_DIR/mergeConfigWithWMTS.js \- --inputDir "$BUILD_DIR/_wmts" \- --outputFile "$DEST_DIR/config/wv.json"`--# Copy brand files from build to dest-cp -r "$BUILD_DIR/brand" "$DEST_DIR"-cp "$BUILD_DIR/brand.json" "$DEST_DIR"---# Validate the options build-# `node $SCRIPTS_DIR/validateOptions.js \-# --optionsFile "$BUILD_DIR/config.json" \-# --configDir "$DEST_DIR/config"`--# Fetch preview images from WV Snapshots for any layers which they are missing-# `node $SCRIPTS_DIR/fetchPreviewSnapshots.js \-# --wvJsonFile "$DEST_DIR/config/wv.json" \-# --overridesFile "$OPT_DIR/common/previewLayerOverrides.json" \-# --featuresFile "$BUILD_DIR/features.json"`-exit 0diff --git a/tasks/util/start.js b/tasks/util/start.jsindex 6cda88ac6..09d7eee00 100755--- a/tasks/util/start.js+++ b/tasks/util/start.js@@ -6,7 +6,7 @@ const port = process.env.PORT || 3000const app = express()app.use(compression())-app.use(express.static(path.join(__dirname, '../web')))+app.use(express.static(path.join(__dirname, '../../web')))// app.use('/test', express.static(path.join(__dirname, '../build/worldview'))); // test dist in a "test" sub directoryapp.set('port', port)app.listen(port, () => {