Skip to content

Interactive interface for browsing global, full-resolution satellite imagery

Fix start with threshold bug #2407

Benjamin King377990548f9a
diff --git a/web/js/components/layer/settings/palette-threshold.js b/web/js/components/layer/settings/palette-threshold.js
index c64509def..e11d256c1 100644
--- a/web/js/components/layer/settings/palette-threshold.js
+++ b/web/js/components/layer/settings/palette-threshold.js
@@ -7,11 +7,11 @@ import { Checkbox } from '../../util/checkbox';
class ThresholdSelect extends React.Component {
constructor(props) {
super(props);
- const { start, end, palette, legend } = props;
+ const { start, end, palette, legend, squashed } = props;
this.state = {
- start: start ? legend.refs.indexOf(palette.entries.refs[start]) : start,
- end: end ? legend.refs.indexOf(palette.entries.refs[end]) : start,
- squashed: props.squashed,
+ start,
+ end,
+ squashed,
activeDragger: 'start'
};
this.debounceSetRange = lodashDebounce(props.setRange, 300);
@@ -50,7 +50,6 @@ class ThresholdSelect extends React.Component {
const newEnd = Math.ceil(Number(thresholdArray[1]));
const startRef = legend.refs[newStart];
const endRef = legend.refs[newEnd];
-
if (newStart !== start && newEnd !== end) {
this.setState({
start: newStart,
@@ -91,6 +90,7 @@ class ThresholdSelect extends React.Component {
end === legend.tooltips.length - 1 && legend.maxLabel
? legend.maxLabel + ' ' + units
: legend.tooltips[end] + ' ' + units;
+
return (
<div className="layer-threshold-select settings-component">
<h2 className="wv-header">Thresholds</h2>
diff --git a/web/js/components/layer/settings/settings.js b/web/js/components/layer/settings/settings.js
index a05c25561..1e351bef3 100644
--- a/web/js/components/layer/settings/settings.js
+++ b/web/js/components/layer/settings/settings.js
@@ -82,8 +82,8 @@ class LayerSettings extends React.Component {
);
const palette = getPalette(layer.id, i);
const max = legend.colors.length - 1;
- const start = palette.min || 0;
- const end = palette.max || max;
+ const start = palette.min ? legend.refs.indexOf(palette.entries.refs[palette.min]) : 0;
+ const end = palette.max ? legend.refs.indexOf(palette.entries.refs[palette.max]) : max;
let paneItemEl;
if (
legend.type !== 'continuous' &&
@@ -100,6 +100,7 @@ class LayerSettings extends React.Component {
<TabPane key={legend.id + 'pane'} tabId={i}>
{legend.type !== 'classification' ? (
<PaletteThreshold
+ key={layer.id + i + `_threshold`}
legend={legend}
setRange={setThresholdRange}
min={0}
@@ -113,8 +114,8 @@ class LayerSettings extends React.Component {
palette={palette}
/>
) : (
- ''
- )}
+ ''
+ )}
<Palette
setCustomPalette={setCustomPalette}
groupName={groupName}
@@ -168,18 +169,18 @@ class LayerSettings extends React.Component {
const palette = getPalette(layer.id, 0);
const legend = getPaletteLegend(layer.id, 0);
const max = palette.legend.colors.length - 1;
- const start = palette.min || 0;
- const end = palette.max || max;
+ const start = palette.min ? legend.refs.indexOf(palette.entries.refs[palette.min]) : 0;
+ const end = palette.max ? legend.refs.indexOf(palette.entries.refs[palette.max]) : max;
if (len > 1) {
return this.renderMultiColormapCustoms(paletteLegends);
} else if (legend.type === 'classification' && legend.colors.length > 1) {
return '';
}
-
return (
<React.Fragment>
{legend.type !== 'classification' &&
<PaletteThreshold
+ key={layer.id + `0_threshold`}
legend={legend}
setRange={setThresholdRange}
min={0}