Skip to content

Interactive interface for browsing global, full-resolution satellite imagery

Add some error handling for processing colormaps

Taylor Gunnoe0c5743e2ea15
diff --git a/bin/wv-options-colormap b/bin/wv-options-colormap
index f85e699e1..0416c0102 100755
--- a/bin/wv-options-colormap
+++ b/bin/wv-options-colormap
@@ -46,6 +46,8 @@ def to_list(v):
def match_legend(entry, legends):
try:
for legend in legends:
+ if "@id" not in legend:
+ raise KeyError("No legend IDs")
if legend["@id"] == entry["@ref"]:
return legend
except ValueError as e:
@@ -53,7 +55,10 @@ def match_legend(entry, legends):
def process_entries(colormap):
entries = to_list(colormap["Entries"]["ColorMapEntry"])
- map_type = colormap["Legend"]["@type"]
+ if "Legend" not in colormap:
+ raise KeyError("No Legend")
+ else:
+ map_type = colormap["Legend"]["@type"]
legends = to_list(colormap["Legend"]["LegendEntry"])
colors = []
values = []
@@ -72,6 +77,8 @@ def process_entries(colormap):
continue
colors += [color_format.format(int(r), int(g), int(b), a)]
legend = match_legend(entry, legends)
+ if "@tooltip" not in legend:
+ raise KeyError("No tooltips in legend")
tooltips += [legend["@tooltip"]]
if (map_type == "continuous") or (map_type == "discrete"):
items = re.sub(r"[\(\)\[\]]", "", entry["@value"]).split(",")
diff --git a/bin/wv-options-wmts b/bin/wv-options-wmts
index 35f7a4fbc..53354bd69 100755
--- a/bin/wv-options-wmts
+++ b/bin/wv-options-wmts
@@ -123,7 +123,7 @@ def process_layer(gc_layer, wv_layers, colormaps):
for item in gc_layer["ows:Metadata"]:
schema_version = item["@xlink:role"]
- if schema_version == "http://earthdata.nasa.gov/gibs/metadata-type/colormap/1.2":
+ 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]