Interactive interface for browsing global, full-resolution satellite imagery
WV-1694: Update labels to include units if available
Taylor Gunnoec24428b4ca9e
diff --git a/bin/wv-options-colormap b/bin/wv-options-colormapindex 6ec9b6d00..138b2ee55 100755--- a/bin/wv-options-colormap+++ b/bin/wv-options-colormap@@ -71,13 +71,13 @@ def process_entries(colormap):if a == 0:continuecolors += [color_format.format(int(r), int(g), int(b), a)]- tooltips += entry["@tooltip"]if "Legend" in colormap:legend = match_legend(entry, legends)if "@label" in legend:labels += [legend["@label"]]elif "@label" in entry:labels += [entry["@label"]]+ tooltips += [legend["@tooltip"]]elif "@label" in entry:labels += [entry["@label"]]if (map_type == "continuous") or (map_type == "discrete"):@@ -136,7 +136,7 @@ def process_file(file):result["entries"]["title"] = colormap["@title"]result["legend"]["title"] = colormap["@title"]if "Legend" in colormap:- if "@minLabel" in colormap["Legend"]):+ if "@minLabel" in colormap["Legend"]:result["legend"]["minLabel"] = colormap["Legend"]["@minLabel"]result["entries"]["minLabel"] = colormap["Legend"]["@minLabel"]if "@maxLabel" in colormap["Legend"]:diff --git a/bin/wv-options-fetch b/bin/wv-options-fetchindex 47c4d90e2..6c7879482 100755--- a/bin/wv-options-fetch+++ b/bin/wv-options-fetch@@ -69,10 +69,7 @@ def process_remote(entry):else:for item in layer["ows:Metadata"]:schema_version = item["@xlink:role"]- #if item != "@xlink:role":- # continue- #if layer["ows:Metadata"][item] == "http://earthdata.nasa.gov/gibs/metadata-type/colormap":- 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_link = layer["ows:Metadata"]["@xlink:href"]colormap_file = os.path.basename(colormap_link)diff --git a/web/js/layers/wv.layers.options.js b/web/js/layers/wv.layers.options.jsindex 77f730311..3166058fd 100644--- a/web/js/layers/wv.layers.options.js+++ b/web/js/layers/wv.layers.options.js@@ -263,9 +263,8 @@ wv.layers.options = wv.layers.options || function(config, models, layer) {var legend = models.palettes.getLegend(layer.id, index);min = min || palette.min || 0;max = max || palette.max || legend.labels.length - 1;-- var minLabel = legend.labels[min] + " " + legend.units;- var maxLabel = legend.labels[max] + " " + legend.units;+ var minLabel = ( legend.units ) ? legend.labels[min] + " " + legend.units : legend.labels[min];+ var maxLabel = ( legend.units ) ? legend.labels[max] + " " + legend.units : legend.labels[max];$("#wv-layers-options-dialog .wv-label-range-min").html(minLabel);$("#wv-layers-options-dialog .wv-label-range-max").html(maxLabel);};diff --git a/web/js/palettes/wv.palettes.legend.js b/web/js/palettes/wv.palettes.legend.jsindex 7c897a264..10cd45a5d 100644--- a/web/js/palettes/wv.palettes.legend.js+++ b/web/js/palettes/wv.palettes.legend.js@@ -136,6 +136,8 @@ wv.palettes.legend = wv.palettes.legend || function(spec) {});var $detailPanel = $("<div></div>");_.each(legend.colors, function(color, classIndex) {+ var label = legend.labels[classIndex];+ label = (legend.units) ? label + " " + legend.units : label;var $row = $("<div></div>").addClass("wv-palettes-class-detail").attr("data-class-index", classIndex);@@ -149,7 +151,7 @@ wv.palettes.legend = wv.palettes.legend || function(spec) {.addClass("wv-palettes-class-label").attr("data-index", index).attr("data-class-index", classIndex)- .html(legend.labels[classIndex] + " " + legend.units));+ .html(label));$detailPanel.append($row);});$panel.tooltip("option", "content", $detailPanel.html());@@ -181,11 +183,12 @@ wv.palettes.legend = wv.palettes.legend || function(spec) {_.each(legends, function(legend, index) {var min = legend.minLabel || _.first(legend.labels);var max = legend.maxLabel || _.last(legend.labels);- var units = legend.units;+ min = (legend.units) ? min + " " + legend.units : min;+ max = (legend.units) ? max + " " + legend.units : max;$(selector + " [data-index='" + index + "'] .wv-palettes-min")- .html(min + " " + unit);+ .html(min);$(selector + " [data-index='" + index + "'] .wv-palettes-max")- .html(max + " " + unit);+ .html(max);var title = legend.title || " ";if (legends.length === 1 ){@@ -216,11 +219,11 @@ wv.palettes.legend = wv.palettes.legend || function(spec) {var color = legend.colors[colorIndex];var label = legend.tooltips[colorIndex];- var unit = legend.units;+ label = (legend.units) ? label + " " + legend.units : label;$colorbar.tooltip("option", "content","<span class='wv-palettes-color-box' style='background: " +- wv.util.hexToRGBA(color) + "'>" + "</span>" + label + " " + units);+ wv.util.hexToRGBA(color) + "'>" + "</span>" + label);};var highlightClass = function() {