Interactive interface for browsing global, full-resolution satellite imagery
WV-3479: Added 'Clip Palette' option to palettes (#6600)
christof-wittreich578c521985aa
diff --git a/doc/url_parameters.md b/doc/url_parameters.mdindex 8da489c5c..804d4d1e8 100644--- a/doc/url_parameters.md+++ b/doc/url_parameters.md@@ -9,8 +9,9 @@| | string | *`layer_id(`**`opacity`**`=value)`* | If present, assigns an opacity value to a layer where `layer_id` is the identifier of the layer, as defined in the configuration file, and `value` is a real number in the range of 0 to 1 where 0 is fully transparent and 1 is fully opaque. Any number of layer to opacity value mappings may be specified. || | string | *`layer_id(`**`palettes`**`=value1,value2,..,valueN)`* | If `palettes` is present, a custom palette will be assigned to a raster layer where `layer_id` is the identifier of the layer and `value` is the identifier of the palette, as defined in the configuration file. Any number of raster layer to palette mappings may be specified. || | string | *`layer_id(`**`squash`**`)`* | If `squash` is present and a `min` or `max` value is set, the palette will start or end at the designated min/max values and the palette will adjust to these bounds. |-| | string | *`layer_id(`**`min`**`=value1,value2)`* | If `min` is present, the raster layer `palettes` will start at the defined value. This value can be paired with `max` and `squash` to customize the entire palette range. |-| | string | *`layer_id(`**`max`**`=value1,value2)`* | If `max` is present, the raster layer `palettes` will end at the defined value. This value can be paired with `min` and `squash` to customize the entire palette range. |+| | string | *`layer_id(`**`noclip`**`)`* | If `noclip` is present and a `min` or `max` value is set, the palette will start or end at the designated min/max values and the palette outside the designated min/max will be shown in the palette's edge color. |+| | string | *`layer_id(`**`min`**`=value1,value2)`* | If `min` is present, the raster layer `palettes` will start at the defined value. This value can be paired with `max`, `squash`, and `noclip` to customize the entire palette range. |+| | string | *`layer_id(`**`max`**`=value1,value2)`* | If `max` is present, the raster layer `palettes` will end at the defined value. This value can be paired with `min`, `squash`, and `noclip` to customize the entire palette range. || | string | *`layer_id(`**`style`**`=value)`* | If `style` is present, a custom vector style, will be assigned to a vector layer where `layer_id` is the identifier of the layer and `value` is the identifier of the vector style, as defined in the configuration file. || `lg` (`lg1` for B state) | boolean | <i>`true`</i> or <i>`false`</i> | If `false`, layers are not grouped. If this parameter is absent, it is considered `true` and layers will be grouped || `t` (`t1` for B state) | date | *`YYYY-MM-DD-Thh:mm:ssZ`* | Selected UTC day and time.\*\* |diff --git a/web/js/components/layer/settings/layer-settings.js b/web/js/components/layer/settings/layer-settings.jsindex eb3ad745e..32de092e3 100644--- a/web/js/components/layer/settings/layer-settings.js+++ b/web/js/components/layer/settings/layer-settings.js@@ -32,7 +32,7 @@ import {getGranulePlatform,} from '../../../modules/layers/selectors';import {- setThresholdRangeAndSquash,+ setThresholdRangeSquashAndNoClip,setCustomPalette as setCustomPaletteAction,clearCustomPalette as clearCustomPaletteAction,setToggledClassification,@@ -156,6 +156,7 @@ class LayerSettings extends React.Component {end={end}layerId={layer.id}squashed={!!palette.squash}+ noclipped={!!palette.noclip}index={i}palette={palette}/>@@ -250,6 +251,7 @@ class LayerSettings extends React.Component {layerId={layer.id}end={end}squashed={!!palette.squash}+ noclipped={!!palette.noclip}groupName={groupName}index={0}palette={palette}@@ -404,9 +406,12 @@ const mapDispatchToProps = (dispatch) => ({refreshDisabledClassification(layerId, disabledArray, index, groupName),);},- setThresholdRange: (layerId, min, max, squash, index, groupName) => {+ setThresholdRange: (layerId, min, max, squash, noclip, index, groupName) => {+ const props = {+ min, max, squash, noclip,+ };dispatch(- setThresholdRangeAndSquash(layerId, { min, max, squash }, index, groupName),+ setThresholdRangeSquashAndNoClip(layerId, props, index, groupName),);},setFilterRange: (layerId, min, max, index, groupName) => {diff --git a/web/js/components/layer/settings/palette-threshold.js b/web/js/components/layer/settings/palette-threshold.jsindex 70742c9e6..dc3a115e9 100644--- a/web/js/components/layer/settings/palette-threshold.js+++ b/web/js/components/layer/settings/palette-threshold.js@@ -11,16 +11,19 @@ const thumbsize = 26;class PaletteThreshold extends React.Component {constructor(props) {super(props);- const { start, end, squashed } = props;+ const {+ start, end, squashed, noclipped,+ } = props;this.state = {start,end,squashed,+ noclipped,avg: Math.round((start + end) / 2),sliderWidth: 264,};this.debounceSetRange = lodashDebounce(props.setRange, 300);- this.updateSquash = this.updateSquash.bind(this);+ this.updateSquashOrNoClip = this.updateSquashOrNoClip.bind(this);this.updateThreshold = this.updateThreshold.bind(this);this.slider = React.createRef();}@@ -32,12 +35,15 @@ class PaletteThreshold extends React.Component {}}- updateSquash() {+ updateSquashOrNoClip(type) {const {setRange, layerId, index, groupName, palette, legend,} = this.props;- const { start, end, squashed } = this.state;- const isSquashed = !squashed;+ const {+ start, end, squashed, noclipped,+ } = this.state;+ const isSquashed = type === 'squash' ? !squashed : squashed;+ const isNoClipped = type === 'noclip' ? !noclipped : noclipped;const startIndex = legend.refs[start];const endIndex = legend.refs[end];@@ -46,10 +52,15 @@ class PaletteThreshold extends React.Component {parseFloat(palette.entries.refs.indexOf(startIndex)),parseFloat(palette.entries.refs.lastIndexOf(endIndex)),isSquashed,+ isNoClipped,index,groupName,);- this.setState({ squashed: isSquashed });+ if (type === 'squash') {+ this.setState({ squashed: isSquashed });+ } else {+ this.setState({ noclipped: isNoClipped });+ }}/**@@ -60,7 +71,9 @@ class PaletteThreshold extends React.Component {const {layerId, index, groupName, palette, legend,} = this.props;- const { start, end, squashed } = this.state;+ const {+ start, end, squashed, noclipped,+ } = this.state;const newStart = parseInt(thresholdArray[0], 10);const newEnd = parseInt(thresholdArray[1], 10);const startRef = legend.refs[newStart];@@ -97,6 +110,7 @@ class PaletteThreshold extends React.Component {min,max,squashed,+ noclipped,index,groupName,);@@ -116,7 +130,7 @@ class PaletteThreshold extends React.Component {render() {const {- start, end, squashed, avg, sliderWidth,+ start, end, squashed, noclipped, avg, sliderWidth,} = this.state;const {index, min, max, legend, globalTemperatureUnit,@@ -172,7 +186,18 @@ class PaletteThreshold extends React.Component {label="Squash Palette"classNames="wv-squash-button-check"id={`wv-squash-button-check${index}`}- onCheck={this.updateSquash}+ onCheck={() => this.updateSquashOrNoClip('squash')}+ />+ </div>+ <div id={`wv-palette-clip${index}`} className="wv-palette-clip">+ <Checkbox+ name="Clip Palette"+ color="gray"+ checked={!noclipped}+ label="Clip Palette"+ classNames="wv-clip-button-check"+ id={`wv-clip-button-check${index}`}+ onCheck={() => this.updateSquashOrNoClip('noclip')}/></div><div@@ -225,6 +250,7 @@ PaletteThreshold.propTypes = {palette: PropTypes.oneOfType([PropTypes.object, PropTypes.oneOf(['null'])]),setRange: PropTypes.func,squashed: PropTypes.bool,+ noclipped: PropTypes.bool,start: PropTypes.number,};diff --git a/web/js/components/layer/settings/palette.js b/web/js/components/layer/settings/palette.jsindex 6ee5937ae..e9e45eb9a 100644--- a/web/js/components/layer/settings/palette.js+++ b/web/js/components/layer/settings/palette.js@@ -170,7 +170,7 @@ function PaletteSelect (props) {id={`wv-palette-selector${index}`}><h2 className="wv-header">Color Palette</h2>- <Scrollbar style={{ maxHeight: '200px' }}>+ <Scrollbar style={{ maxHeight: '165px', border: 'solid 1px #535353', paddingLeft: '11px', paddingTop: '5px' }}>{renderDefault()}{diff --git a/web/js/components/sidebar/paletteLegend.js b/web/js/components/sidebar/paletteLegend.jsindex 3204c724c..b20e02c07 100644--- a/web/js/components/sidebar/paletteLegend.js+++ b/web/js/components/sidebar/paletteLegend.js@@ -208,11 +208,13 @@ function PaletteLegend(props) {* @param {string} hex - The hex color to match against the legend.* @param {number} acceptableDifference - The maximum allowed difference between colors.* Lower values require closer color matches.+ * @param {Object} palette - The color palette of the legend** @returns {Object|null} The matched legend object or null if no match is found.**/- const getLegendObject = (legend, hex, acceptableDifference) => {+ const getLegendObject = (legend, hex, acceptableDifference, palette) => {+ const { min, max, noclip, squash } = palette;const units = legend.units || '';const { needsConversion, legendTempUnit } = checkTemperatureUnitConversion(@@ -229,6 +231,16 @@ function PaletteLegend(props) {} else {label = units ? `${tooltipRange} ${units}` : tooltipRange;}+ // If noclip is active, generate labels for indexes out of the min/max range+ if (noclip) {+ // If palette is squashed, labels outside range are now <= and >= instead+ const squashEquals = squash ? '=' : '';+ if (i < min || (squash && i === min)) {+ label = `<${squashEquals} ${legend.tooltips[min]}`;+ } else if (i > max || (squash && i === max)) {+ label = `>${squashEquals} ${legend.tooltips[max]}`;+ }+ }return {label,len,@@ -255,8 +267,9 @@ function PaletteLegend(props) {if (isRunningDataState && colorHexState && widthState > 0) {const isContinuousVectorLayer = layer.colormapType === 'continuous' && layer.type === 'vector';- const acceptableDifference = isContinuousVectorLayer ? 1 : 3;- legendObj = getLegendObject(legend, colorHexState, acceptableDifference); // {label,len,index}+ const acceptableDifference = isContinuousVectorLayer ? 1 : 2;+ // {label,len,index}+ legendObj = getLegendObject(legend, colorHexState, acceptableDifference, palette);if (legendObj) {percent = getPercent(legendObj.len, legendObj.index);textWidth = util.getTextWidth(legendObj.label, '10px Open Sans');@@ -374,17 +387,17 @@ function PaletteLegend(props) {* @param {Number} index | Legend Index*/const renderClasses = (legend, legendIndex) => {- const activeKeyObj = isRunningDataState && colorHexState &&- getLegendObject(legend, colorHexState, 5);- const legendClass = activeKeyObj- ? 'wv-running wv-palettes-legend wv-palettes-classes'- : 'wv-palettes-legend wv-palettes-classes';const singleKey = legend.colors.length === 1;const legendTooltip = legend.tooltips && legend.tooltips.length ? legend.tooltips[0] : '';const trackLabel = layer.track && legendTooltip? `${legendTooltip} - ${getOrbitTrackTitle(layer)}`: getOrbitTrackTitle(layer);const palette = getPalette(layer.id, legendIndex);+ const activeKeyObj = isRunningData && colorHexState &&+ getLegendObject(legend, colorHexState, 5, palette);+ const legendClass = activeKeyObj+ ? 'wv-running wv-palettes-legend wv-palettes-classes'+ : 'wv-palettes-legend wv-palettes-classes';return (<VisibilitySensorkey={`${legend.id}-${legendIndex}vis-sensor`}diff --git a/web/js/fixtures.js b/web/js/fixtures.jsindex a696a2a93..60671b38e 100644--- a/web/js/fixtures.js+++ b/web/js/fixtures.js@@ -690,6 +690,26 @@ fixtures.config = function() {r: 255,},},+ 'max-1-noclipped': {+ '0,255,0,255': {+ a: 255,+ b: 0,+ g: 255,+ r: 0,+ },+ '255,0,0,255': {+ a: 255,+ b: 0,+ g: 0,+ r: 255,+ },+ '255,255,0,255': {+ a: 255,+ b: 0,+ g: 255,+ r: 255,+ },+ },},},rendered: {diff --git a/web/js/mapUI/components/update-projection/updateProjection.js b/web/js/mapUI/components/update-projection/updateProjection.jsindex 6400aacbc..f4ac0a511 100644--- a/web/js/mapUI/components/update-projection/updateProjection.js+++ b/web/js/mapUI/components/update-projection/updateProjection.js@@ -380,7 +380,7 @@ function UpdateProjection(props) {return undefined;case layerConstants.TOGGLE_OVERLAY_GROUPS:return reloadLayers();- case paletteConstants.SET_THRESHOLD_RANGE_AND_SQUASH:+ case paletteConstants.SET_THRESHOLD_RANGE_SQUASH_AND_NOCLIP:case paletteConstants.SET_CUSTOM:case paletteConstants.SET_DISABLED_CLASSIFICATION:case paletteConstants.CLEAR_CUSTOM:diff --git a/web/js/mapUI/mapUI.js b/web/js/mapUI/mapUI.jsindex 2c6eaaee0..12ce79d35 100644--- a/web/js/mapUI/mapUI.js+++ b/web/js/mapUI/mapUI.js@@ -123,7 +123,7 @@ function MapUI(props) {case compareConstants.TOGGLE_ON_OFF:case compareConstants.CHANGE_MODE:case layerConstants.TOGGLE_OVERLAY_GROUPS:- case paletteConstants.SET_THRESHOLD_RANGE_AND_SQUASH:+ case paletteConstants.SET_THRESHOLD_RANGE_SQUASH_AND_NOCLIP:case paletteConstants.SET_CUSTOM:case paletteConstants.SET_DISABLED_CLASSIFICATION:case paletteConstants.CLEAR_CUSTOM:diff --git a/web/js/modules/layers/reducers.js b/web/js/modules/layers/reducers.jsindex 77551dd19..e5fe9b050 100644--- a/web/js/modules/layers/reducers.js+++ b/web/js/modules/layers/reducers.js@@ -29,7 +29,7 @@ import {import {SET_CUSTOM as SET_CUSTOM_PALETTE,CLEAR_CUSTOM as CLEAR_CUSTOM_PALETTE,- SET_THRESHOLD_RANGE_AND_SQUASH,+ SET_THRESHOLD_RANGE_SQUASH_AND_NOCLIP,SET_DISABLED_CLASSIFICATION,} from '../palettes/constants';import {@@ -215,7 +215,7 @@ export function layerReducer(state = initialState, action) {},});- case SET_THRESHOLD_RANGE_AND_SQUASH:+ case SET_THRESHOLD_RANGE_SQUASH_AND_NOCLIP:case SET_DISABLED_CLASSIFICATION: {const layerIndex = getLayerIndex();if (layerIndex < 0) return state;diff --git a/web/js/modules/layers/reducers.test.js b/web/js/modules/layers/reducers.test.jsindex 9a8da9423..2bef0d465 100644--- a/web/js/modules/layers/reducers.test.js+++ b/web/js/modules/layers/reducers.test.js@@ -18,7 +18,7 @@ import {import {SET_CUSTOM as SET_CUSTOM_PALETTE,CLEAR_CUSTOM as CLEAR_CUSTOM_PALETTE,- SET_THRESHOLD_RANGE_AND_SQUASH,+ SET_THRESHOLD_RANGE_SQUASH_AND_NOCLIP,} from '../palettes/constants';const config = fixtures.config();@@ -196,16 +196,18 @@ describe('layer Reducer tests', () => {expect(response.active.prevLayers).toEqual(initialLayers);});- test('SET_THRESHOLD_RANGE_AND_SQUASH action updates palette-related props [layers-reducer-update-palettes]', () => {+ test('SET_THRESHOLD_RANGE_SQUASH_AND_NOCLIP action updates palette-related props [layers-reducer-update-palettes]', () => {const response = layerReducer(initialState, {- type: SET_THRESHOLD_RANGE_AND_SQUASH,- props: { squash: true, min: 0.3 },+ type: SET_THRESHOLD_RANGE_SQUASH_AND_NOCLIP,+ props: { squash: true, noclip: true, min: 0.3 },id: 'terra-cr',activeString: 'active',});const responseLayer = getTestLayer(response.active.layers);expect(getTestLayer(initialLayers).squash).toEqual(undefined);+ expect(getTestLayer(initialLayers).noclip).toEqual(undefined);expect(responseLayer.squash).toBeTruthy();+ expect(responseLayer.noclip).toBeTruthy();expect(responseLayer.min).toEqual(0.3);});diff --git a/web/js/modules/layers/selectors.js b/web/js/modules/layers/selectors.jsindex c6de48a7d..a34ecdb88 100644--- a/web/js/modules/layers/selectors.js+++ b/web/js/modules/layers/selectors.js@@ -46,6 +46,7 @@ export function addLayer(def.custom = spec.custom || undefined;def.max = spec.max || undefined;def.squash = spec.squash || undefined;+ def.noclip = spec.noclip || undefined;def.disabled = spec.disabled || undefined;def.count = spec.count || def.count || undefined;diff --git a/web/js/modules/layers/util.js b/web/js/modules/layers/util.jsindex 74f49764f..ad2d72728 100644--- a/web/js/modules/layers/util.js+++ b/web/js/modules/layers/util.js@@ -880,7 +880,7 @@ export function serializeLayers(layers, state, groupName) {});}if (def.palette &&- (def.custom || def.min || def.max || def.squash || def.disabled ||+ (def.custom || def.min || def.max || def.squash || def.noclip || def.disabled ||(palettes[def.id] && palettes[def.id].maps && palettes[def.id].maps.length > 1))) {// If layer has palette and palette attributesconst paletteAttributeArray = getPaletteAttributeArray(@@ -945,6 +945,7 @@ const getLayerSpec = (attributes) => {let max;let min;let squash;+ let noclip;let custom;let disabled;let count;@@ -1018,6 +1019,18 @@ const getLayerSpec = (attributes) => {squash = squashArray.length ? squashArray : undefined;}}+ if (attr.id === 'noclip') {+ if (attr.value === true) {+ noclip = [true];+ } else if (typeof attr.value === 'string') {+ const noClipArray = [];+ const values = util.toArray(attr.value.split(';'));+ lodashEach(values, (value) => {+ noClipArray.push(value === 'true');+ });+ noclip = noClipArray.length ? noClipArray : undefined;+ }+ }if (attr.id === 'bands') {const values = util.toArray(attr.value.split(';'));@@ -1055,6 +1068,7 @@ const getLayerSpec = (attributes) => {...isArray(custom) && { custom },...isArray(min) && { min },...isArray(squash) && { squash },+ ...isArray(noclip) && { noclip },...isArray(max) && { max },...isArray(disabled) && { disabled },};diff --git a/web/js/modules/layers/util.test.js b/web/js/modules/layers/util.test.jsindex 60d2c0479..347b8cde8 100644--- a/web/js/modules/layers/util.test.js+++ b/web/js/modules/layers/util.test.js@@ -24,7 +24,7 @@ let defaultStateFromLocation = {};const globalState = fixtures.getState();const config = fixtures.config();-const PALETTE_LAYER_STRING = 'AMSRE_Brightness_Temp_89H_Night(hidden,opacity=0.54,palette=red_2,min=224,225,max=294,295,squash=true),mask';+const PALETTE_LAYER_STRING = 'AMSRE_Brightness_Temp_89H_Night(hidden,opacity=0.54,palette=red_2,min=224,225,max=294,295,squash=true,noclip=true),mask';const VECTOR_LAYER_STRING = 'OrbitTracks_Aqua_Ascending(hidden,opacity=0.46,style=yellow1),mask';test('Layer parser, retrieves correct number of palette layers from permalink string [layers-palette-layers]', () => {@@ -46,6 +46,11 @@ test('Layer parser, gets squashed boolean from permalink string [layers-squashedconst layer = layers[0];expect(layer.squash[0]).toBe(true);});+test('Layer parser, gets noclipped boolean from permalink string [layers-noclipped-boolean]', () => {+ const layers = layersParse12(PALETTE_LAYER_STRING, config);+ const layer = layers[0];+ expect(layer.noclip[0]).toBe(true);+});test('Layer parser, gets correct min value from permalink string [layers-min-value]', () => {const layers = layersParse12(PALETTE_LAYER_STRING, config);const layer = layers[0];diff --git a/web/js/modules/map/util.js b/web/js/modules/map/util.jsindex 2974357c7..cbb0d0151 100644--- a/web/js/modules/map/util.js+++ b/web/js/modules/map/util.js@@ -294,6 +294,9 @@ export async function promiseImageryForTour(state, layers, dateString, activeStrif (layer.squash) {keys.push('squash');}+ if (layer.noclip) {+ keys.push('noclip');+ }if (keys.length > 0) {options.style = keys.join(',');}diff --git a/web/js/modules/palettes/actions.js b/web/js/modules/palettes/actions.jsindex 48f06ab91..d4bfb2ba3 100644--- a/web/js/modules/palettes/actions.js+++ b/web/js/modules/palettes/actions.js@@ -5,7 +5,7 @@ import {import { requestAction } from '../core/actions';import {REQUEST_PALETTE,- SET_THRESHOLD_RANGE_AND_SQUASH,+ SET_THRESHOLD_RANGE_SQUASH_AND_NOCLIP,CLEAR_CUSTOM,SET_CUSTOM,SET_DISABLED_CLASSIFICATION,@@ -42,11 +42,11 @@ export function requestPalette(id) {/*** @param {String} layerId- * @param {Object} props | contains min max and squash attributes+ * @param {Object} props | contains min max squash and noclip attributes* @param {Number} index | Palette index value for multi-paletted layers* @param {String} groupName | layer group string*/-export function setThresholdRangeAndSquash(layerId, props, index, groupName) {+export function setThresholdRangeSquashAndNoClip(layerId, props, index, groupName) {return (dispatch, getState) => {const state = getState();const newActivePalettesObj = setRangeSelector(@@ -57,7 +57,7 @@ export function setThresholdRangeAndSquash(layerId, props, index, groupName) {state,);dispatch({- type: SET_THRESHOLD_RANGE_AND_SQUASH,+ type: SET_THRESHOLD_RANGE_SQUASH_AND_NOCLIP,groupName,activeString: groupName,layerId,@@ -173,14 +173,16 @@ export function clearCustoms(keepDisabledClassification) {const { palettes, compare } = state;const groupName = compare.activeString;const activePalettes = palettes[groupName];- const props = { squash: undefined, min: undefined, max: undefined };+ const props = {+ squash: undefined, noclip: undefined, min: undefined, max: undefined,+ };lodashForOwn(activePalettes, (value, key) => {activePalettes[key].maps.forEach((colormap, index) => {if (colormap.custom) {dispatch(clearCustomPalette(key, index, groupName));}- if (colormap.max || colormap.min || colormap.squash) {- dispatch(setThresholdRangeAndSquash(key, props, index, groupName));+ if (colormap.max || colormap.min || colormap.squash || colormap.noclip) {+ dispatch(setThresholdRangeSquashAndNoClip(key, props, index, groupName));}if (colormap.disabled && !keepDisabledClassification) {dispatch(setToggledClassification(key, undefined, index, groupName));@@ -242,13 +244,16 @@ export function refreshPalettes(activePalettes) {const groupName = getState().compare.activeString;lodashForOwn(activePalettes, (value, key) => {activePalettes[key].maps.forEach((colormap, index) => {+ const props = {+ squash: colormap.squash, noclip: colormap.noclip, min: colormap.min, max: colormap.max,+ };if (colormap.custom) {dispatch(setCustomPalette(key, colormap.custom, index, groupName));}- if (colormap.max || colormap.min || colormap.squash) {- dispatch(setThresholdRangeAndSquash(+ if (colormap.max || colormap.min || colormap.squash || colormap.noclip) {+ dispatch(setThresholdRangeSquashAndNoClip(key,- { squash: colormap.squash, min: colormap.min, max: colormap.max },+ props,index,groupName,));diff --git a/web/js/modules/palettes/actions.test.js b/web/js/modules/palettes/actions.test.jsindex 9f49eb843..112442923 100644--- a/web/js/modules/palettes/actions.test.js+++ b/web/js/modules/palettes/actions.test.js@@ -5,7 +5,7 @@ import { assign, cloneDeep } from 'lodash';import update from 'immutability-helper';import {requestPalette,- setThresholdRangeAndSquash,+ setThresholdRangeSquashAndNoClip,setCustomPalette,clearCustomPalette,} from './actions';@@ -14,7 +14,7 @@ import {REQUEST_PALETTE_START,REQUEST_PALETTE_SUCCESS,REQUEST_PALETTE_FAILURE,- SET_THRESHOLD_RANGE_AND_SQUASH,+ SET_THRESHOLD_RANGE_SQUASH_AND_NOCLIP,SET_CUSTOM,CLEAR_CUSTOM,} from './constants';@@ -76,12 +76,12 @@ describe('Test lookup actions [palettes-actions-lookup]', () => {beforeEach(() => {fetch.resetMocks();});- test(`test ${setThresholdRangeAndSquash} action with min equal to 1`, () => {+ test(`test ${setThresholdRangeSquashAndNoClip} action with min equal to 1`, () => {const store = mockStore(stateWithLayers);- store.dispatch(setThresholdRangeAndSquash('terra-aod', { min: 1 }, 0, 'active'));+ store.dispatch(setThresholdRangeSquashAndNoClip('terra-aod', { min: 1 }, 0, 'active'));const response = store.getActions()[0];- expect(response.type).toEqual(SET_THRESHOLD_RANGE_AND_SQUASH);+ expect(response.type).toEqual(SET_THRESHOLD_RANGE_SQUASH_AND_NOCLIP);expect(response.props).toEqual({ min: 1 });expect(response.groupName).toEqual('active');expect(response.layerId).toEqual('terra-aod');@@ -94,18 +94,19 @@ describe('Test lookup actions [palettes-actions-lookup]', () => {expect(response.palettes['terra-aod'].maps[0].min).toEqual(1);expect(response.palettes['terra-aod'].maps[0].max).toEqual(undefined);expect(response.palettes['terra-aod'].maps[0].squash).toEqual(undefined);+ expect(response.palettes['terra-aod'].maps[0].noclip).toEqual(undefined);expect(response.palettes['terra-aod'].lookup).toEqual(config.palettes.lookups['terra-aod']['min-1'],);});- test(`test ${setThresholdRangeAndSquash} action with squash and max [palettes-actions-threshold]`, () => {+ test(`test ${setThresholdRangeSquashAndNoClip} action with squash and max [palettes-actions-threshold-1]`, () => {const store = mockStore(stateWithLayers);store.dispatch(- setThresholdRangeAndSquash('terra-aod', { max: 1, squash: true }, 0, 'active'),+ setThresholdRangeSquashAndNoClip('terra-aod', { max: 1, squash: true }, 0, 'active'),);const response = store.getActions()[0];- expect(response.type).toEqual(SET_THRESHOLD_RANGE_AND_SQUASH);+ expect(response.type).toEqual(SET_THRESHOLD_RANGE_SQUASH_AND_NOCLIP);expect(response.props).toEqual({ max: 1, squash: true });expect(response.groupName).toEqual('active');expect(response.layerId).toEqual('terra-aod');@@ -121,6 +122,29 @@ describe('Test lookup actions [palettes-actions-lookup]', () => {config.palettes.lookups['terra-aod']['max-1-squashed'],);});+ test(`test ${setThresholdRangeSquashAndNoClip} action with noclip and max [palettes-actions-threshold-2]`, () => {+ const store = mockStore(stateWithLayers);+ store.dispatch(+ setThresholdRangeSquashAndNoClip('terra-aod', { max: 1, noclip: true }, 0, 'active'),+ );+ const response = store.getActions()[0];++ expect(response.type).toEqual(SET_THRESHOLD_RANGE_SQUASH_AND_NOCLIP);+ expect(response.props).toEqual({ max: 1, noclip: true });+ expect(response.groupName).toEqual('active');+ expect(response.layerId).toEqual('terra-aod');+ expect(response.activeString).toEqual('active');+ expect(response.palettes['terra-aod'].maps[0].legend.colors).toEqual([+ '00ff00ff',+ 'ffff00ff',+ 'ff0000ff',+ ]);+ expect(response.palettes['terra-aod'].maps[0].max).toEqual(1);+ expect(response.palettes['terra-aod'].maps[0].noclip).toEqual(true);+ expect(response.palettes['terra-aod'].lookup).toEqual(+ config.palettes.lookups['terra-aod']['max-1-noclipped'],+ );+ });test(`test ${setCustomPalette} action with red-1 fixture palette [palettes-actions-set-custom]`, () => {const expectedLegendColors = config.palettes.custom['red-1'].colors;const store = mockStore(stateWithLayers);@@ -180,7 +204,7 @@ describe('Test lookup actions [palettes-actions-lookup]', () => {expect(response.activeString).toEqual('active');});test(- `test ${clearCustomPalette} action with threshold and squash applied [palettes-actions-clear-custom-threshold]`,+ `test ${clearCustomPalette} action with threshold and squash applied [palettes-actions-clear-custom-threshold-1]`,() => {let terraAOD = assign({}, config.palettes.rendered['terra-aod']);terraAOD = update(terraAOD, {@@ -245,4 +269,70 @@ describe('Test lookup actions [palettes-actions-lookup]', () => {);},);+ test(+ `test ${clearCustomPalette} action with threshold and noclip applied [palettes-actions-clear-custom-threshold-2]`,+ () => {+ let terraAOD = assign({}, config.palettes.rendered['terra-aod']);+ terraAOD = update(terraAOD, {+ lookup: { $set: config.palettes.lookups['terra-aod']['red-1'] },+ });+ terraAOD = update(terraAOD, {+ maps: {+ 0: {+ custom: {+ $set: 'red-1',+ },+ },+ },+ });+ terraAOD = update(terraAOD, {+ maps: {+ 0: {+ legend: {+ colors: { $set: config.palettes.custom['red-1'].colors },+ },+ },+ },+ });+ terraAOD = update(terraAOD, {+ maps: {+ 0: {+ max: { $set: 1 },+ },+ },+ });+ terraAOD = update(terraAOD, {+ maps: {+ 0: {+ noclip: { $set: true },+ },+ },+ });+ const previousPaletteObject = cloneDeep(terraAOD);++ const customPalatteState = update(stateWithLayers, {+ palettes: { active: { $set: { 'terra-aod': terraAOD } } },+ });++ const store = mockStore(customPalatteState);+ store.dispatch(clearCustomPalette('terra-aod', 0, 'active'));+ const response = store.getActions()[0];+ expect(response.type).toEqual(CLEAR_CUSTOM);+ expect(previousPaletteObject.lookup).toBeDefined();+ expect(response.groupName).toEqual('active');+ expect(response.layerId).toEqual('terra-aod');+ expect(response.activeString).toEqual('active');++ expect(response.palettes['terra-aod'].maps[0].legend.colors).toEqual([+ '00ff00ff',+ 'ffff00ff',+ 'ff0000ff',+ ]);+ expect(response.palettes['terra-aod'].maps[0].max).toEqual(1);+ expect(response.palettes['terra-aod'].maps[0].noclip).toEqual(true);+ expect(response.palettes['terra-aod'].lookup).toEqual(+ config.palettes.lookups['terra-aod']['max-1-noclipped'],+ );+ },+ );});diff --git a/web/js/modules/palettes/constants.js b/web/js/modules/palettes/constants.jsindex 0fed27083..e769dd405 100644--- a/web/js/modules/palettes/constants.js+++ b/web/js/modules/palettes/constants.js@@ -4,7 +4,7 @@ export const REQUEST_PALETTE_SUCCESS = 'PALETTES/REQUEST_PALETTE_SUCCESS';export const REQUEST_PALETTE_FAILURE = 'PALETTES/REQUEST_PALETTE_FAILURE';export const SET_DISABLED_CLASSIFICATION = 'PALETTES/SET_DISABLED_CLASSIFICATION';export const PALETTE_CHANGE = 'PALETTES/CHANGE_OF_ACTIVE_PALETTE';-export const SET_THRESHOLD_RANGE_AND_SQUASH = 'PALETTES/SET_THRESHOLD_RANGE_AND_SQUASH';+export const SET_THRESHOLD_RANGE_SQUASH_AND_NOCLIP = 'PALETTES/SET_THRESHOLD_RANGE_SQUASH_AND_NOCLIP';export const CLEAR_CUSTOM = 'PALETTES/CLEAR_CUSTOM';export const CLEAR_CUSTOMS = 'PALETTES/CLEAR_CUSTOMS';export const SET_CUSTOM = 'PALETTES/SET_CUSTOM';@@ -15,8 +15,9 @@ export const BULK_PALETTE_PRELOADING_SUCCESS = 'PALETTES/BULK_PALETTE_PRELOADINGexport const PALETTE_STRINGS_PERMALINK_ARRAY = ['palette','squash',+ 'noclip','min','max','disabled',];-export const CUSTOM_PALETTE_TYPE_ARRAY = ['custom', 'squash', 'min', 'max', 'disabled'];+export const CUSTOM_PALETTE_TYPE_ARRAY = ['custom', 'squash', 'noclip', 'min', 'max', 'disabled'];diff --git a/web/js/modules/palettes/reducers.js b/web/js/modules/palettes/reducers.jsindex 49d4a8a58..13f9516d1 100644--- a/web/js/modules/palettes/reducers.js+++ b/web/js/modules/palettes/reducers.js@@ -9,7 +9,7 @@ import {REQUEST_PALETTE_SUCCESS,SET_CUSTOM,REQUEST_PALETTE_START,- SET_THRESHOLD_RANGE_AND_SQUASH,+ SET_THRESHOLD_RANGE_SQUASH_AND_NOCLIP,LOADED_CUSTOM_PALETTES,BULK_PALETTE_RENDERING_SUCCESS,BULK_PALETTE_PRELOADING_SUCCESS,@@ -73,7 +73,7 @@ export function paletteReducer(state = defaultPaletteState, action) {return lodashAssign({}, state, {activeB: lodashAssign({}, lodashCloneDeep(state.active), lodashCloneDeep(state.activeB)),});- case SET_THRESHOLD_RANGE_AND_SQUASH:+ case SET_THRESHOLD_RANGE_SQUASH_AND_NOCLIP:case SET_CUSTOM:case SET_DISABLED_CLASSIFICATION:case CLEAR_CUSTOM:diff --git a/web/js/modules/palettes/reducers.test.js b/web/js/modules/palettes/reducers.test.jsindex c249ba45f..3eace5be2 100644--- a/web/js/modules/palettes/reducers.test.js+++ b/web/js/modules/palettes/reducers.test.js@@ -2,7 +2,7 @@ import update from 'immutability-helper';import { getInitialPaletteState, paletteReducer } from './reducers';import fixtures from '../../fixtures';import {- SET_THRESHOLD_RANGE_AND_SQUASH,+ SET_THRESHOLD_RANGE_SQUASH_AND_NOCLIP,CLEAR_CUSTOM,SET_CUSTOM,REQUEST_PALETTE_START,@@ -13,10 +13,10 @@ import { INIT_SECOND_LAYER_GROUP } from '../layers/constants';const config = fixtures.config();-test('SET_THRESHOLD_RANGE_AND_SQUASH action updates active palette Object [palettes-reducer-threshold]', () => {+test('SET_THRESHOLD_RANGE_SQUASH_AND_NOCLIP action updates active palette Object [palettes-reducer-threshold]', () => {const initialPaletteState = getInitialPaletteState(config);const response = paletteReducer(initialPaletteState, {- type: SET_THRESHOLD_RANGE_AND_SQUASH,+ type: SET_THRESHOLD_RANGE_SQUASH_AND_NOCLIP,layerId: 'terra-aod',groupName: 'active',palettes: { 'terra-aod': config.palettes.rendered['terra-aod'] },diff --git a/web/js/modules/palettes/selectors.js b/web/js/modules/palettes/selectors.jsindex c1407d1f0..e8465bb9d 100644--- a/web/js/modules/palettes/selectors.js+++ b/web/js/modules/palettes/selectors.js@@ -191,14 +191,24 @@ const updateLookup = function(layerId, palettesObj, state) {const disabled = palette.disabled || [];lodashEach(source, (color, indexArg) => {let targetColor;- if (indexArg < min || indexArg > max || disabled.includes(indexArg)) {+ if ((indexArg < min || indexArg > max || disabled.includes(indexArg)) && !palette.noclip) {targetColor = '00000000';} else {- let sourcePercent; let- targetIndex;+ let sourcePercent;+ let targetIndex;+ let modifiedIndex = indexArg;+ // If noclip is active, modify indexes outside the min/max range+ // so that the targetIndex is calculated correctly for them+ if (palette.noclip) {+ if (indexArg < min) {+ modifiedIndex = palette.squash ? min : min - 1;+ } else if (indexArg > max) {+ modifiedIndex = palette.squash ? max : max + 1;+ }+ }if (palette.squash) {- sourcePercent = (indexArg - min) / (max - min);- if (indexArg === max) {+ sourcePercent = (modifiedIndex - min) / (max - min);+ if (modifiedIndex === max) {sourcePercent = 1.0;}targetIndex = Math.floor(sourcePercent * targetCount);@@ -206,7 +216,7 @@ const updateLookup = function(layerId, palettesObj, state) {targetIndex = targetCount - 1;}} else {- sourcePercent = indexArg / sourceCount;+ sourcePercent = modifiedIndex / sourceCount;targetIndex = Math.round(sourcePercent * targetCount);}targetColor = target[targetIndex];@@ -374,6 +384,9 @@ export function getKey(layerId, groupStr, state) {if (def.squash) {keys.push('squash');}+ if (def.noclip) {+ keys.push('noclip');+ }return keys.join(',');}@@ -458,7 +471,7 @@ export function setRange(layerId, props, indexInt, palettes, state) {let index = indexInt;let { min } = props;let { max } = props;- const { squash } = props;+ const { squash, noclip } = props;let newPalettes = prepare(layerId, palettes, state);index = lodashIsUndefined(index) ? 0 : index;if (min === 0) {@@ -482,6 +495,7 @@ export function setRange(layerId, props, indexInt, palettes, state) {max,min,squash,+ noclip,},},},diff --git a/web/js/modules/palettes/util.js b/web/js/modules/palettes/util.jsindex 301e24d61..f71b68294 100644--- a/web/js/modules/palettes/util.js+++ b/web/js/modules/palettes/util.js@@ -301,6 +301,7 @@ export function getPaletteAttributeArray(layerId, palettes, state) {let minObj = lodashAssign({}, { key: 'min', array: [] }, DEFAULT_OBJ);let maxObj = lodashAssign({}, { key: 'max', array: [] }, DEFAULT_OBJ);let squashObj = lodashAssign({}, { key: 'squash', array: [] }, DEFAULT_OBJ);+ let noClipObj = lodashAssign({}, { key: 'noclip', array: [] }, DEFAULT_OBJ);let disabledObj = lodashAssign({}, { key: 'disabled', array: [] }, DEFAULT_OBJ);const attrArray = [];for (let i = 0; i < count; i += 1) {@@ -347,6 +348,12 @@ export function getPaletteAttributeArray(layerId, palettes, state) {squashObj,count,);+ noClipObj = createPaletteAttributeObject(+ paletteDef,+ true,+ noClipObj,+ count,+ );disabledObj = createPaletteAttributeObject(paletteDef,disabledValue,@@ -355,7 +362,7 @@ export function getPaletteAttributeArray(layerId, palettes, state) {);}- [palObj, minObj, maxObj, squashObj, disabledObj].forEach((obj) => {+ [palObj, minObj, maxObj, squashObj, noClipObj, disabledObj].forEach((obj) => {if (obj.isActive || (obj.key === 'disabled' && obj.value !== '')) {attrArray.push({id: obj.key === 'custom' ? 'palette' : obj.key,@@ -393,6 +400,7 @@ export function loadPalettes(permlinkState, stateObject) {const min = [];const max = [];let squash = [];+ let noclip = [];let count = 0;if (layerDef.custom) {lodashEach(layerDef.custom, (value, index) => {@@ -449,6 +457,9 @@ export function loadPalettes(permlinkState, stateObject) {if (layerDef.squash) {squash = layerDef.squash;}+ if (layerDef.noclip) {+ noclip = layerDef.noclip;+ }if (layerDef.disabled) {lodashEach(layerDef.disabled, (value, index) => {try {@@ -473,7 +484,10 @@ export function loadPalettes(permlinkState, stateObject) {const vmin = min.length > 0 ? min[i] : undefined;const vmax = max.length > 0 ? max[i] : undefined;const vsquash = squash.length > 0 ? squash[i] : undefined;- const props = { min: vmin, max: vmax, squash: vsquash };+ const vnoclip = noclip.length > 0 ? noclip[i] : undefined;+ const props = {+ min: vmin, max: vmax, squash: vsquash, noclip: vnoclip,+ };const newPalettes = setRangeSelector(layerId,props,diff --git a/web/js/modules/palettes/util.test.js b/web/js/modules/palettes/util.test.jsindex 913a888ac..09baff26b 100644--- a/web/js/modules/palettes/util.test.js+++ b/web/js/modules/palettes/util.test.js@@ -9,13 +9,13 @@ import fixtures from '../../fixtures';const state = fixtures.getState();const config = fixtures.config();-const LAYER_STRING = 'terra-aod(hidden,opacity=0.54,palette=red-1,min=1,max=2,squash=true),mask';+const LAYER_STRING = 'terra-aod(hidden,opacity=0.54,palette=red-1,min=1,max=2,squash=true,noclip=true),mask';const layerArrayFromPermalinkString = layersParse12(LAYER_STRING, config);const PERMALINK_STATE = { l: LAYER_STRING };test('hasCustomTypePalette func determines if custom palette is in string [palettes-custom-palette-string-1.1]', () => {const bool = hasCustomTypePalette(- 'terra-aod(hidden,opacity=0.54,palette=red-1,min=1,max=2,squash=true)',+ 'terra-aod(hidden,opacity=0.54,palette=red-1,min=1,max=2,squash=true,noclip=true)',);expect(bool).toBeTruthy();});@@ -42,6 +42,7 @@ test('loadPalettes func updates state with correct palette attributes [palettes-expect(colorMap.min).toEqual(1);expect(colorMap.custom).toEqual('red-1');expect(colorMap.squash).toEqual(true);+ expect(colorMap.noclip).toEqual(true);});describe('permalink 1.1', () => {diff --git a/web/js/modules/vector-styles/actions.js b/web/js/modules/vector-styles/actions.jsindex 783df4c3b..a6776778c 100644--- a/web/js/modules/vector-styles/actions.js+++ b/web/js/modules/vector-styles/actions.js@@ -11,7 +11,7 @@ import {/*** @param {String} layerId- * @param {Object} props | contains min max and squash attributes+ * @param {Object} props | contains min max squash and noclip attributes* @param {Number} index | VectorStyle index value for multi-vectorStyled layers* @param {String} groupName | layer group string*/diff --git a/web/scss/components/checkbox.scss b/web/scss/components/checkbox.scssindex 914214313..eb8ce3401 100644--- a/web/scss/components/checkbox.scss+++ b/web/scss/components/checkbox.scss@@ -82,5 +82,5 @@}.wv-checkbox-round.checked::before {- background-color: transparent !important;+ background-color: #eee !important;}diff --git a/web/scss/components/range.scss b/web/scss/components/range.scssindex e47dda7eb..f45bc26cd 100644--- a/web/scss/components/range.scss+++ b/web/scss/components/range.scss@@ -3,12 +3,12 @@.form-range {&::-moz-range-track {height: 6px;- background-color: #ccc;+ background-color: #4f4f4f;}&::-ms-track {height: 6px;- background-color: #ccc;+ background-color: #4f4f4f;}// Customize the handle@@ -45,16 +45,16 @@height: 4px;background: linear-gradient(to right,- #ABE2FB 0%,- #ABE2FB var(--value-percent, 0%),- #ccc var(--value-percent, 0%),- #ccc 100%+ #3e7ac1 0%,+ #3e7ac1 var(--value-percent, 0%),+ #4f4f4f var(--value-percent, 0%),+ #4f4f4f 100%);}&:not(.double-range)::-moz-range-progress {height: 4px;- background-color: variables.$wv-dark-blue;+ background-color: #3e7ac1;}}@@ -112,26 +112,26 @@border-bottom-right-radius: 0;background: linear-gradient(to right,- #ccc 0%,- #ccc var(--min-range-percent),- #ABE2FB var(--min-range-percent),- #ABE2FB 100%+ #4f4f4f 0%,+ #4f4f4f var(--min-range-percent),+ #3e7ac1 var(--min-range-percent),+ #3e7ac1 100%);}&.start-range::-moz-range-track {height: 4px;- border: solid 1px #ccc;+ border: solid 1px #4f4f4f;border-left: none;border-right: none;border-top-right-radius: 0;border-bottom-right-radius: 0;background: linear-gradient(to right,- #ccc 0%,- #ccc var(--min-range-percent),- variables.$wv-dark-blue var(--min-range-percent),- variables.$wv-dark-blue 100%+ #4f4f4f 0%,+ #4f4f4f var(--min-range-percent),+ #3e7ac1 var(--min-range-percent),+ #3e7ac1 100%);}@@ -140,26 +140,26 @@border-bottom-left-radius: 0;background: linear-gradient(to right,- #ABE2FB 0%,- #ABE2FB var(--max-range-percent),- #ccc var(--max-range-percent),- #ccc 100%+ #3e7ac1 0%,+ #3e7ac1 var(--max-range-percent),+ #4f4f4f var(--max-range-percent),+ #4f4f4f 100%);}&.end-range::-moz-range-track {height: 4px;- border: solid 1px #ccc;+ border: solid 1px #4f4f4f;border-left: none;border-right: none;border-top-left-radius: 0;border-bottom-left-radius: 0;background: linear-gradient(to right,- variables.$wv-dark-blue 0%,- variables.$wv-dark-blue var(--max-range-percent),- #ccc var(--max-range-percent),- #ccc 100%+ #3e7ac1 0%,+ #3e7ac1 var(--max-range-percent),+ #4f4f4f var(--max-range-percent),+ #4f4f4f 100%);}}diff --git a/web/scss/features/palettes.scss b/web/scss/features/palettes.scssindex 321cb4ffe..a6db68c90 100644--- a/web/scss/features/palettes.scss+++ b/web/scss/features/palettes.scss@@ -1,24 +1,25 @@@use "variables";.wv-palette-selector {- width: 280px;- height: 220px;+ width: 272px;+ height: 200px;position: relative;}.wv-palette-selector-row {- background: #eee;padding: 0.5em;margin-right: 10px;color: #000;- margin-bottom: 1px;min-height: 41px;display: flex;align-items: center;+ margin-top: -6px;+ margin-left: -6px;}.wv-palette-selector-row label {- margin-left: 10px;+ margin-left: 7px;+ color: #b5b5b7 !important;}.wv-palette-label {@@ -27,7 +28,7 @@}.wv-palette-selector-row img {- border: 1px solid #404040;+ border: 1px solid #b5b5b7;vertical-align: middle;}diff --git a/web/scss/features/sidebar.scss b/web/scss/features/sidebar.scssindex fb4b3ac63..c8c47d9fc 100644--- a/web/scss/features/sidebar.scss+++ b/web/scss/features/sidebar.scss@@ -1141,6 +1141,10 @@ p.recharts-tooltip-label {.layer-settings-modal {width: 300px;+ .wv-header {+ margin-bottom: 12px !important;+ }+@media (max-width: variables.$mobile-max-width) {width: 100%;}@@ -1219,7 +1223,11 @@ p.recharts-tooltip-label {}.layer-threshold-select {- margin-bottom: 3rem;+ margin-bottom: 4rem;++ .wv-checkbox label {+ margin-left: 5px;+ }}.wv-label-opacity,@@ -1240,25 +1248,41 @@ p.recharts-tooltip-label {}.wv-palette-squash {- float: right;- margin-top: -26px;+ display: inline-block;++ .wv-checkbox.gray span {+ color: #eee;+ }+ }++ .wv-palette-clip {+ display: inline-block;+ margin-left: 20px;.wv-checkbox.gray span {color: #eee;}}+ .wv-layer-options-threshold {+ margin-top: 10px;+ }+/** inline-block extra spacing */.wv-palette-selector .wv-checkbox input {margin-left: 6px;}+ .wv-palette-selector .wv-header {+ margin-bottom: 16px !important;+ }+.layer-opacity-select .wv-header {margin-top: 0;}.layer-orbit-tracks .wv-checkbox {- margin: 10px 0 10px 10px;+ margin: 10px 0;display: flex;align-items: center;