Interactive interface for browsing global, full-resolution satellite imagery
WTMS GC can now contain multiple time entries, min/max taken for now. When validation fails entry removed from layerOrder too. Configuration build can be fully forced when there are errors
Mike McGannc2a4dc722820
diff --git a/bin/wv-options-build b/bin/wv-options-buildindex 082745ec6..f4ec741fb 100755--- a/bin/wv-options-build+++ b/bin/wv-options-build@@ -66,3 +66,5 @@ donecp -r "$BUILD_DIR/brand" "$DEST_DIR""$BIN_DIR"/wv-options-validate "$BUILD_DIR/config.json" "$DEST_DIR/config"++exit 0diff --git a/bin/wv-options-validate b/bin/wv-options-validateindex 07689ad34..621d3aff3 100755--- a/bin/wv-options-validate+++ b/bin/wv-options-validate@@ -46,7 +46,11 @@ def warn(message):global warning_countsys.stderr.write("%s: WARN: %s\n" % (prog, message))warning_count += 1-++def remove_layer(wv, layer_id):+ print "REMOVING: " + layer_id+ del wv["layers"][layer_id]+ if layer_id in wv["layerOrder"]: wv["layerOrder"].remove(layer_id)main_config_file = os.path.join(config_dir, "wv.json")with open(main_config_file) as fp:@@ -56,14 +60,15 @@ with open(options_file) as fp:for layer_id in wv["layers"].keys():layer = wv["layers"][layer_id]- if len(layer["projections"]) == 0:- warn("[%s] No projections defined or not found in GC documents" %- layer_id)if layer_id not in wv["layerOrder"]:if "warnOnUnexpectedLayer" in opt:warn("[%s] Unexpected layer" % layer_id)- del wv["layers"][layer_id]+ remove_layer(wv, layer_id)continue+ if "projections" not in layer or len(layer["projections"]) == 0:+ warn("[%s] No projections defined or not found in GC documents" %+ layer_id)+ remove_layer(wv, layer_id)if "palette" in layer:palette_id = layer["palette"]["id"]if not os.path.exists(os.path.join(config_dir, "palettes",@@ -71,7 +76,7 @@ for layer_id in wv["layers"].keys():error("[%s] Unknown palette: %s" % (layer_id, palette_id))if "group" not in layer:error("[%s] No group defined" % palette_id)- del wv["layers"][layer_id]+ remove_layer(wv, layer_id)continuefor layer_id in wv["layerOrder"]:@@ -80,12 +85,12 @@ for layer_id in wv["layerOrder"]:print "%s: %d error(s), %d warning(s)" % (prog, error_count, warning_count)-if error_count > 0:- sys.exit(1)-json_options = {}json_options["indent"] = 4json_options["separators"] = (',', ': ')with open(main_config_file, "w") as fp:json.dump(wv, fp)++if error_count > 0:+ sys.exit(1)diff --git a/bin/wv-options-wmts b/bin/wv-options-wmtsindex 0c3538e35..cb0896646 100755--- a/bin/wv-options-wmts+++ b/bin/wv-options-wmts@@ -63,6 +63,9 @@ json_options["separators"] = (',', ': ')class SkipException(Exception):pass+def to_list(val):+ return [val] if not hasattr(val, 'reverse') else val+def process_layer(gc_layer, wv_layers, colormaps):id = gc_layer["ows:Identifier"]if id in skip:@@ -81,17 +84,23 @@ def process_layer(gc_layer, wv_layers, colormaps):if dimension["ows:Identifier"] == "time":try:wv_layer["period"] = "daily"- values = dimension["Value"].split("/")-+ ranges = to_list(dimension["Value"])+ start_date = datetime.max;+ end_date = datetime.min;+ for range in ranges:+ times = range.split('/')+ start_date = min(start_date,+ datetime.strptime(times[0], "%Y-%m-%d"))+ end_date = min(start_date,+ datetime.strptime(times[1], "%Y-%m-%d"))# Layer is still actively being produced if the end date# greater than yesterday- end_date = datetime.strptime(values[1], "%Y-%m-%d")yesterday = datetime.now() - timedelta(days=1)- wv_layer["startDate"] = values[0]+ wv_layer["startDate"] = start_date.strftime("%Y-%m-%d")if end_date < yesterday:- wv_layer["endDate"] = values[1]+ wv_layer["endDate"] = end_date.strftime("%Y-%m-%d")except ValueError:- raise Exception("Invalid time: {0}".format(values))+ raise Exception("Invalid time: {0}".format(range))# Extract matrix setmatrixSet = gc_layer["TileMatrixSetLink"]["TileMatrixSet"]