Skip to content

Interactive interface for browsing global, full-resolution satellite imagery

Options panel working with dual colormaps

Mike McGann7fd6345e5470
diff --git a/web/js/layers/wv.layers.add.js b/web/js/layers/wv.layers.add.js
index 0f2645e8f..90be4ae78 100644
--- a/web/js/layers/wv.layers.add.js
+++ b/web/js/layers/wv.layers.add.js
@@ -125,7 +125,9 @@ wv.layers.add = wv.layers.add || function(models, ui, config) {
_.each(config.layerOrder, function(layerId) {
var layer = config.layers[layerId];
- if ( layer.group === group ) {
+ if ( !layer ) {
+ console.warn("In layer order but not defined", layerId);
+ } else if ( layer.group === group ) {
renderLayer($element, group, layerId);
}
});
diff --git a/web/js/layers/wv.layers.options.js b/web/js/layers/wv.layers.options.js
index 7b9124743..6b6a86d30 100644
--- a/web/js/layers/wv.layers.options.js
+++ b/web/js/layers/wv.layers.options.js
@@ -82,11 +82,14 @@ wv.layers.options = wv.layers.options || function(config, models, layer) {
$("#wv-squash-button-check").on("ifChanged", function() {
var squash = $("#wv-squash-button-check").prop("checked");
- var $slider = $("#wv-range-slider");
+ //var $slider = $("#wv-range-slider");
+ var $slider = $range;
+ console.log("slider", $slider, $slider.val());
models.palettes.setRange(layer.id,
parseFloat($slider.val()[0]),
parseFloat($slider.val()[1]),
- squash);
+ squash,
+ index);
});
models.layers.events
@@ -195,8 +198,7 @@ wv.layers.options = wv.layers.options || function(config, models, layer) {
var startMin = legend.min || 0;
var startMax = legend.max || max;
- console.log("total max", max);
- var startSquash = legend.squash;
+
var $slider = $("<div></div>")
.noUiSlider({
start: [startMin, startMax],
@@ -243,9 +245,14 @@ wv.layers.options = wv.layers.options || function(config, models, layer) {
palette.entries.labels.length - 1 : palette.max;
current = [parseFloat($range.val()[0]), parseFloat($range.val()[1])];
if ( !_.isEqual(current, [imin, imax]) ) {
- console.log("imin", imin, "imax", imax);
$range.val([imin, imax]);
}
+
+ if ( palette.squash ) {
+ $("#wv-squash-button-check").iCheck("check");
+ } else {
+ $("#wv-squash-button-check").iCheck("uncheck");
+ }
};
var updateRangeLabels = function(min, max) {
@@ -308,10 +315,8 @@ wv.layers.options = wv.layers.options || function(config, models, layer) {
.iCheck("check");
}
- console.log("register");
$("#wv-palette-selector input").on("ifChecked", function() {
var that = this;
- console.log($(this));
setTimeout(function() {
var id = $(that).attr("data-palette");
if ( id === "__default" ) {
diff --git a/web/js/palettes/wv.palettes.model.js b/web/js/palettes/wv.palettes.model.js
index 65c1ebaf5..6275b0d79 100644
--- a/web/js/palettes/wv.palettes.model.js
+++ b/web/js/palettes/wv.palettes.model.js
@@ -325,16 +325,33 @@ wv.palettes.model = wv.palettes.model || function(models, config) {
var values = entries.values;
var target = ( palette.custom ) ?
self.getCustom(palette.custom).colors : source;
+
var min = palette.min || 0;
var max = palette.max || source.length;
+ var sourceCount = source.length;
+ var targetCount = target.length;
+ var indexCount = max - min;
+
_.each(source, function(color, index) {
var newColor;
if ( index < min || index > max ) {
targetColor = "00000000";
} else {
- var sourcePercent = index / source.length;
- var targetIndex = Math.floor(sourcePercent * target.length);
+ var sourcePercent, targetIndex;
+ if ( palette.squash ) {
+ sourcePercent = (index - min) / (max - min);
+ if ( index == max ) {
+ sourcePercent = 1.0;
+ }
+ targetIndex = Math.floor(sourcePercent * targetCount);
+ if ( targetIndex >= targetCount ) {
+ targetIndex = targetCount - 1;
+ }
+ } else {
+ sourcePercent = index / sourceCount;
+ targetIndex = Math.floor(sourcePercent * targetCount);
+ }
targetColor = target[targetIndex];
}
legend.colors.push(targetColor);
diff --git a/web/js/wv.main.js b/web/js/wv.main.js
index 56573adaf..5d55d7b1d 100644
--- a/web/js/wv.main.js
+++ b/web/js/wv.main.js
@@ -237,12 +237,15 @@ $(function() {
});
if ( layersRemoved > 0 ) {
+ // Remove for now until new GIBS has settled down.
+ /*
wv.ui.notify(
"Incomplete configuration<br><br>" +
layersRemoved + " layer(s) were removed<br><br>" +
"Contact us at " +
"<a href='mailto:@MAIL@'>" +
"@MAIL@</a>");
+ */
}
};