Interactive interface for browsing global, full-resolution satellite imagery
Remove unneeded vector style build steps
ZachTRice61685b0795b9
diff --git a/tasks/buildOptions.sh b/tasks/buildOptions.shindex 814340555..0c97bf030 100755--- a/tasks/buildOptions.sh+++ b/tasks/buildOptions.sh@@ -54,7 +54,6 @@ fimkdir -p "$DEST_DIR/config"mkdir -p "$BUILD_DIR/colormaps"-mkdir -p "$BUILD_DIR/vectorstyles"if [ -e "$BUILD_DIR/features.json" ] ; thencp "$BUILD_DIR/features.json" "$BUILD_DIR/config/wv.json/_features.json"@@ -63,18 +62,7 @@ fi# Run extractConfigFromWMTS.py script with config.jsonif [ -e "$BUILD_DIR/config.json" ] ; then"$TASKS_DIR/extractConfigFromWMTS.py" "$BUILD_DIR/config.json" "$BUILD_DIR/gc" \- "$BUILD_DIR/config/wv.json/_wmts"-fi--# Run processVectorStyles.py and move colormaps where we want them-if [ -e "$BUILD_DIR/vectorstyles" ] ; then- mkdir -p "$BUILD_DIR"/config/vectorstyles- if [ -d "$BUILD_DIR"/gc/vectorstyles ] ; then- cp -r "$BUILD_DIR"/gc/vectorstyles "$BUILD_DIR"/vectorstyles/gc- fi- "$TASKS_DIR/processVectorStyles.py" "$OPT_DIR/$OPT_SUBDIR/config.json" \- "$BUILD_DIR/vectorstyles" \- "$BUILD_DIR/config/vectorstyles"+ "$BUILD_DIR/config/wv.json/_wmts" "$BUILD_DIR/colormaps"fi# Run processColormap.py and move colormaps where we want themdiff --git a/tasks/extractConfigFromWMTS.py b/tasks/extractConfigFromWMTS.pyindex 96c38ea17..1f9391384 100755--- a/tasks/extractConfigFromWMTS.py+++ b/tasks/extractConfigFromWMTS.py@@ -1,10 +1,13 @@#!/usr/bin/env python+from datetime import datetime, date, timedeltaimport jsonfrom optparse import OptionParserimport osimport sys+import urllib2 as urllibimport xmltodict+import isodatefrom processTemporalLayer import process_temporalfrom collections import OrderedDict@@ -15,23 +18,24 @@ help_description = """\Extracts configuration information from a WMTS GetCapabilities file."""-parser = OptionParser(usage="Usage: %s <config_file> <input_dir> <output_dir>" % prog,+parser = OptionParser(usage="Usage: %s <config_file> <input_dir> <output_dir> <colormaps_dir>" % prog,version="%s version %s" % (prog, version),epilog=help_description)(options, args) = parser.parse_args()-if len(args) != 3:+if len(args) != 4:parser.error("Invalid number of arguments")config_file = args[0]input_dir = args[1]output_dir = args[2]+colormaps_dir = args[3]with open(config_file) as fp:config = json.load(fp)tolerant = config.get("tolerant", False)-if "wv-options-wmts" not in config:+if not "wv-options-wmts" in config:sys.exit(0)if not os.path.exists(output_dir):@@ -51,11 +55,9 @@ json_options = {}json_options["indent"] = 4json_options["separators"] = (',', ': ')-class SkipException(Exception):pass-def process_layer(gc_layer, wv_layers, colormaps):id = gc_layer["ows:Identifier"]if id in skip:@@ -99,19 +101,10 @@ def process_layer(gc_layer, wv_layers, colormaps):colormap_link = item["@xlink:href"]colormap_file = os.path.basename(colormap_link)colormap_id = os.path.splitext(colormap_file)[0]- wv_layer["vectorStyle"] = {+ wv_layer["palette"] = {"id": colormap_id}- elif schema_version == "http://earthdata.nasa.gov/gibs/metadata-type/mapbox-gl-style/1.0":- colormap_link = item["@xlink:href"]- colormap_file = os.path.basename(colormap_link)- colormap_id = os.path.splitext(colormap_file)[0]- wv_layer["vectorStyle"] = {- "id": colormap_id- }--def process_entry(entry, colormaps):layer_count = 0warning_count = 0diff --git a/tasks/getCapabilities.py b/tasks/getCapabilities.pyindex 1b52e946a..2c864c032 100755--- a/tasks/getCapabilities.py+++ b/tasks/getCapabilities.py@@ -28,9 +28,7 @@ if len(args) != 2:config_file = args[0]output_dir = args[1]colormaps = {}-vectorstyles = {}colormaps_dir = os.path.join(output_dir, "colormaps")-vectorstyles_dir = os.path.join(output_dir, "vectorstyles")remote_count = 0error_count = 0warning_count = 0@@ -54,6 +52,7 @@ def process_layer(layer):schema_version = item["@xlink:role"]if schema_version == "http://earthdata.nasa.gov/gibs/metadata-type/colormap/1.3":colormap_link = item["@xlink:href"]+ #colormap_link = layer["ows:Metadata"]["@xlink:href"]colormap_file = os.path.basename(colormap_link)colormap_id = os.path.splitext(colormap_file)[0]colormaps[colormap_id] = colormap_link@@ -76,28 +75,16 @@ def process_remote(entry):returntry:- for layer in gc["Capabilities"]["Contents"]["Layer"]:- ident = layer["ows:Identifier"]- if "ows:Metadata" in layer:- if ident in config.get("skipPalettes", []):- sys.stderr.write("%s: WARN: Skipping palette for %s\n" %- prog, ident)- global warning_count- warning_count += 1- else:- for item in layer["ows:Metadata"]:- schema_version = item["@xlink:role"]- if schema_version == "http://earthdata.nasa.gov/gibs/metadata-type/colormap/1.3":- colormap_link = item["@xlink:href"]- colormap_file = os.path.basename(colormap_link)- colormap_id = os.path.splitext(colormap_file)[0]- colormaps[colormap_id] = colormap_link+ if(type(gc["Capabilities"]["Contents"]["Layer"]) is OrderedDict):+ process_layer(gc["Capabilities"]["Contents"]["Layer"])+ else:+ for layer in gc["Capabilities"]["Contents"]["Layer"]:+ process_layer(layer)except Exception as e:print('error: %s: %s' % (url, str(e)))print(str(traceback.format_exc()))-# Fetch every colormap from the API and write response to file systemdef process_colormaps():print "%s: Fetching %d colormaps" % (prog, len(colormaps))@@ -108,8 +95,7 @@ def process_colormaps():try:response = urllib.urlopen(link)contents = response.read()- if link.endswith('.xml'):- output_file = os.path.join(colormaps_dir, os.path.basename(link))+ output_file = os.path.join(colormaps_dir, os.path.basename(link))with open(output_file, "w") as fp:fp.write(contents)except Exception as e:@@ -119,29 +105,6 @@ def process_colormaps():warning_count += 1print "%s: Fetching %d colormaps" % (prog, len(colormaps))--# Fetch every colormap from the API and write response to file system-def process_vectorstyles():- print "%s: Fetching %d vectorstyles" % (prog, len(vectorstyles))- sys.stdout.flush()- if not os.path.exists(vectorstyles_dir):- os.makedirs(vectorstyles_dir)- for link in vectorstyles.values():- try:- response = urllib.urlopen(link)- contents = response.read()- if link.endswith('.json'):- output_file = os.path.join(vectorstyles_dir, os.path.basename(link))- with open(output_file, "w") as fp:- fp.write(contents)- except Exception as e:- sys.stderr.write("%s: WARN: Unable to fetch %s: %s" %- (prog, link, str(e)))- global warning_count- warning_count += 1- print "%s: Fetching %d vectorstyles_dir" % (prog, len(vectorstyles_dir))--tolerant = config.get("tolerant", False)if "wv-options-fetch" in config:for entry in config["wv-options-fetch"]:@@ -157,8 +120,6 @@ if "wv-options-fetch" in config:sys.stderr.write("%s: ERROR: %s\n" % (prog, str(e)))if colormaps:process_colormaps()- if vectorstyles:- process_vectorstyles()print "%s: %d error(s), %d remote(s)" % (prog, error_count, remote_count)diff --git a/tasks/processColormap.py b/tasks/processColormap.pyindex 7b4504add..a2fd4b8b7 100755--- a/tasks/processColormap.py+++ b/tasks/processColormap.py@@ -14,7 +14,7 @@ help_description = """\Converts colormaps to JSON files"""-parser = OptionParser(usage="Usage: %s <config_file> <colormap_input_dir> <output_dir>" % prog,+parser = OptionParser(usage="Usage: %s <config_file> <input_dir> <output_dir>" % prog,version="%s version %s" % (prog, version),epilog=help_description)@@ -23,7 +23,7 @@ if len(args) != 3:parser.error("Invalid number of arguments")config_file = args[0]-colormap_input_dir = args[1]+input_dir = args[1]output_dir = args[2]with open(config_file) as fp:@@ -231,7 +231,7 @@ def process_file(file):file_count = 0error_count = 0-for root, dirs, files in os.walk(colormap_input_dir):+for root, dirs, files in os.walk(input_dir):for file in files:try:file_count += 1diff --git a/tasks/processVectorStyles.py b/tasks/processVectorStyles.pydeleted file mode 100644index 4907ee6c5..000000000--- a/tasks/processVectorStyles.py+++ /dev/null@@ -1,59 +0,0 @@-#!/usr/bin/env python--from optparse import OptionParser-import os-import sys-import json-import shutil--prog = os.path.basename(__file__)-base_dir = os.path.join(os.path.dirname(__file__), "..")-version = "3.0.0"-help_description = """\-Converts colormaps to JSON files-"""--parser = OptionParser(usage="Usage: %s <config_file> <vectorstyles_input_dir> <output_dir>" % prog,- version="%s version %s" % (prog, version),- epilog=help_description)--(options, args) = parser.parse_args()-if len(args) != 3:- parser.error("Invalid number of arguments")--config_file = args[0]-vectorstyles_input_dir = args[1]-output_dir = args[2]--with open(config_file) as fp:- config = json.load(fp)-skips = config.get("skipPalettes", [])--def copy_file(file):- input_file = os.path.join(root, file)- id = os.path.splitext(os.path.basename(input_file))[0]- if id in skips:- sys.stderr.write("%s: WARN: [%s] %s\n" % (prog, input_file,- "Skipping"))- return-- if input_file.endswith('.json'):- shutil.copy(input_file, output_dir)--# Main-file_count = 0-error_count = 0--for root, dirs, files in os.walk(vectorstyles_input_dir):- for file in files:- try:- file_count += 1- copy_file(file)- except Exception as e:- sys.stderr.write("%s: ERROR: [%s] %s\n" % (prog, file, str(e)))- error_count += 1--print "%s: %d error(s), %d file(s)" % (prog, error_count, file_count)--if error_count > 0:- sys.exit(1)diff --git a/tasks/validateOptions.py b/tasks/validateOptions.pyindex ef98765d4..6c686f8cb 100755--- a/tasks/validateOptions.py+++ b/tasks/validateOptions.py@@ -99,14 +99,6 @@ for layer_id in wv["layers"].keys():palette_id + ".json")):error("[%s] Unknown palette: %s" % (layer_id, palette_id))del layer["palette"]- if "vectorStyle" in layer and "id" not in layer["vectorStyle"]:- error("[%s] No vectorStyle definition" % (layer_id))- elif "vectorStyle" in layer:- vector_style_id = layer["vectorStyle"]["id"]- if not os.path.exists(os.path.join(config_dir, "vectorstyles",- vector_style_id + ".json")):- error("[%s] Unknown vector style: %s" % (layer_id, vector_style_id))- del layer["vectorStyle"]if "group" not in layer and opt.get("warnOnUnexpectedLayer"):error("[%s] Possible unexpected layer, no group defined" % layer_id)remove_layer(wv, layer_id)