Interactive interface for browsing global, full-resolution satellite imagery
Add vector default style to settings and continue splitting out palettes
ZachTRice24d0b4ea2bc9
diff --git a/web/js/components/layer/settings/settings.js b/web/js/components/layer/settings/settings.jsindex a2e33dc6d..3fec1aa14 100644--- a/web/js/components/layer/settings/settings.js+++ b/web/js/components/layer/settings/settings.js@@ -21,10 +21,15 @@ import {isPaletteAllowed} from '../../../modules/palettes/selectors';import {- setRangeAndSquash,+ setThresholdRangeAndSquash,setCustomPalette,clearCustomPalette} from '../../../modules/palettes/actions';+import {+ setFilterRange,+ setStyle,+ clearStyle+} from '../../../modules/vector-styles/actions';import {getVectorStyle@@ -56,7 +61,7 @@ class LayerSettings extends React.Component {setCustomPalette,palettesTranslate,groupName,- setRange,+ setThresholdRange,layer} = this.props;const { activeIndex } = this.state;@@ -96,7 +101,7 @@ class LayerSettings extends React.Component {{legend.type !== 'classification' ? (<PaletteThresholdlegend={legend}- setRange={setRange}+ setThresholdRange={setThresholdRange}min={0}max={max}start={start}@@ -150,7 +155,7 @@ class LayerSettings extends React.Component {getPaletteLegends,getPalette,getPaletteLegend,- setRange,+ setThresholdRange,paletteOrder,groupName,layer@@ -174,7 +179,7 @@ class LayerSettings extends React.Component {{legend.type !== 'classification' &&<PaletteThresholdlegend={legend}- setRange={setRange}+ setThresholdRange={setThresholdRange}min={0}max={max}start={start}@@ -207,7 +212,7 @@ class LayerSettings extends React.Component {*/renderVectorStyles() {const {- setRange,+ setFilterRange,groupName,layer} = this.props;@@ -221,7 +226,7 @@ class LayerSettings extends React.Component {return (<React.Fragment><VectorFilter- setRange={setRange}+ setFilterRange={setFilterRange}min={0}max={max}start={start}@@ -231,6 +236,8 @@ class LayerSettings extends React.Component {index={0}/><VectorStyle+ setStyle={''}+ clearStyle={''}activeVectorStyle={'default_style'}layer={layer}index={0}@@ -303,9 +310,14 @@ function mapStateToProps(state, ownProps) {};}const mapDispatchToProps = dispatch => ({- setRange: (layerId, min, max, squash, index, groupName) => {+ setThresholdRange: (layerId, min, max, squash, index, groupName) => {+ dispatch(+ setThresholdRangeAndSquash(layerId, { min, max, squash }, index, groupName)+ );+ },+ setFilterRange: (layerId, min, max, squash, index, groupName) => {dispatch(- setRangeAndSquash(layerId, { min, max, squash }, index, groupName)+ setFilterRange(layerId, { min, max, squash }, index, groupName));},setCustomPalette: (layerId, paletteId, index, groupName) => {@@ -314,6 +326,12 @@ const mapDispatchToProps = dispatch => ({clearCustomPalette: (layerId, index, groupName) => {dispatch(clearCustomPalette(layerId, index, groupName));},+ setStyle: (layerId, paletteId, index, groupName) => {+ dispatch(setStyle(layerId, paletteId, index, groupName));+ },+ clearStyle: (layerId, index, groupName) => {+ dispatch(clearStyle(layerId, index, groupName));+ },setOpacity: (id, opacity) => {dispatch(setOpacity(id, opacity));}diff --git a/web/js/components/layer/settings/vector-filter.js b/web/js/components/layer/settings/vector-filter.jsindex 8631488b6..bba21d5ea 100644--- a/web/js/components/layer/settings/vector-filter.js+++ b/web/js/components/layer/settings/vector-filter.js@@ -3,7 +3,7 @@ import PropTypes from 'prop-types';import lodashDebounce from 'lodash/debounce';import { Range as RangeInput } from 'rc-slider';-class VectorThresholdSelect extends React.Component {+class VectorFilter extends React.Component {constructor(props) {super(props);this.state = {@@ -11,7 +11,7 @@ class VectorThresholdSelect extends React.Component {end: props.end,activeDragger: 'start'};- this.debounceSetRange = lodashDebounce(props.setRange, 300);+ this.debounceSetRange = lodashDebounce(props.setFilterRange, 300);}/*** Update filter values@@ -79,16 +79,16 @@ class VectorThresholdSelect extends React.Component {);}}-VectorThresholdSelect.propTypes = {+VectorFilter.propTypes = {start: PropTypes.number,end: PropTypes.number,onSlide: PropTypes.func,index: PropTypes.number,min: PropTypes.number,max: PropTypes.number,- setRange: PropTypes.func,+ setFilterRange: PropTypes.func,layerId: PropTypes.string,groupName: PropTypes.string};-export default VectorThresholdSelect;+export default VectorFilter;diff --git a/web/js/components/layer/settings/vector-style.js b/web/js/components/layer/settings/vector-style.jsindex 43a3976e7..7218a1e94 100644--- a/web/js/components/layer/settings/vector-style.js+++ b/web/js/components/layer/settings/vector-style.js@@ -18,10 +18,10 @@ class VectorStyleSelect extends React.Component {renderDefault() {const { layer, index, getDefaultLegend } = this.props;const { activeVectorStyle } = this.state;- const legend = getDefaultLegend(layer.id, index);+ // const legend = getDefaultLegend(layer.id, index);return this.renderSelectorItemSingle(- legend,+ undefined, // should pass vectorStyles here'default_style','Default',activeVectorStyle === 'default_style'@@ -32,16 +32,16 @@ class VectorStyleSelect extends React.Component {* @param {String} id | custom VectorStyle Id*/onChangeVectorStyle(id) {- const { layer, clearCustomStyle, setCustom, index } = this.props;+ const { layer, clearStyle, setStyle, index } = this.props;// Applying customs takes a while and// it looks more natural to make this async// instead of waitingsetTimeout(function() {if (id === 'default_style') {- clearCustomStyle(layer.id, index);+ clearStyle(layer.id, index);} else {- setCustom(layer.id, id, index);+ setStyle(layer.id, id, index);}}, 0);this.setState({ activeVectorStyle: id });@@ -83,9 +83,9 @@ class VectorStyleSelect extends React.Component {* @param {Boolean} isSelected | is this colormap active*/renderSelectorItemSingle(vectorStyle, id, description, isSelected) {- const color = palette.classes- ? palette.classes.colors[0]- : palette.colors[0];+ // const color = palette.classes+ // ? palette.classes.colors[0]+ // : palette.colors[0];const caseDefaultClassName ='wv-palette-selector-row wv-checkbox wv-checkbox-round gray ';const checkedClassName = isSelected ? 'checked' : '';@@ -100,7 +100,6 @@ class VectorStyleSelect extends React.Component {<label htmlFor={'wv-palette-radio-' + id}><spanclassName="wv-palettes-class"- style={{ backgroundColor: util.hexToRGB(color) }}> </span>@@ -119,6 +118,7 @@ class VectorStyleSelect extends React.Component {><h2 className="wv-header">Vector Style</h2><Scrollbar style={{ maxHeight: '200px' }}>+ {this.renderDefault()}{/* Output Color Selects Here */}</Scrollbar></div>@@ -128,8 +128,8 @@ class VectorStyleSelect extends React.Component {VectorStyleSelect.propTypes = {index: PropTypes.number,layer: PropTypes.object,- clearCustomStyle: PropTypes.func,- setCustom: PropTypes.func,+ clearStyle: PropTypes.func,+ setStyle: PropTypes.func,paletteOrder: PropTypes.array,palettesTranslate: PropTypes.func,getDefaultLegend: PropTypes.func,diff --git a/web/js/map/ui.js b/web/js/map/ui.jsindex 8b59a2658..e19e2c675 100644--- a/web/js/map/ui.js+++ b/web/js/map/ui.js@@ -37,6 +37,7 @@ import Cache from 'cachai';import * as layerConstants from '../modules/layers/constants';import * as compareConstants from '../modules/compare/constants';import * as paletteConstants from '../modules/palettes/constants';+import * as vectorStyleConstants from '../modules/vector-styles/constants';import {getLayers,isRenderable as isRenderableLayer@@ -121,11 +122,16 @@ export function mapui(models, config, store, ui) {return reloadLayers();case CHANGE_PROJECTION:return updateProjection();- case paletteConstants.SET_RANGE_AND_SQUASH:+ case paletteConstants.SET_THRESHOLD_RANGE_AND_SQUASH:case paletteConstants.SET_CUSTOM:case paletteConstants.CLEAR_CUSTOM:case paletteConstants.REQUEST_PALETTE_SUCCESS:return updateLookup();+ case vectorStyleConstants.SET_FILTER_RANGE:+ case vectorStyleConstants.SET_VECTORSTYLE:+ case vectorStyleConstants.CLEAR_VECTORSTYLE:+ case vectorStyleConstants.REQUEST_VECTORSTYLE_SUCCESS:+ return updateLookup();case CALCULATE_RESPONSIVE_STATE:return onResize();case SELECT_DATE:diff --git a/web/js/modules/layers/reducers.js b/web/js/modules/layers/reducers.jsindex 7d693dcfa..015e67fb9 100644--- a/web/js/modules/layers/reducers.js+++ b/web/js/modules/layers/reducers.js@@ -14,6 +14,10 @@ import {CLEAR_CUSTOM as CLEAR_CUSTOM_PALETTE,SET_RANGE_AND_SQUASH} from '../palettes/constants';+import {+ SET_VECTORSTYLE,+ SET_FILTER_RANGE+} from '../vector-styles/constants';import { resetLayers } from './selectors';import {cloneDeep as lodashCloneDeep,@@ -65,7 +69,7 @@ export function layerReducer(state = initialState, action) {[action.index]: { visible: { $set: action.visible } }}});- case SET_RANGE_AND_SQUASH:+ case SET_THRESHOLD_RANGE_AND_SQUASH:let layerIndex = lodashFindIndex(state[layerGroupStr], {id: action.layerId});@@ -103,6 +107,30 @@ export function layerReducer(state = initialState, action) {}}});+ case SET_FILTER_RANGE:+ layerIndex = lodashFindIndex(state[layerGroupStr], {+ id: action.layerId+ });+ return update(state, {+ [layerGroupStr]: {+ [layerIndex]: {+ $merge: action.props+ }+ }+ });+ case SET_VECTORSTYLE:+ layerIndex = lodashFindIndex(state[layerGroupStr], {+ id: action.layerId+ });+ return update(state, {+ [layerGroupStr]: {+ [layerIndex]: {+ custom: {+ $set: action.paletteId+ }+ }+ }+ });case REMOVE_LAYER:return update(state, {[layerGroupStr]: { $splice: [[action.index, 1]] }diff --git a/web/js/modules/palettes/actions.js b/web/js/modules/palettes/actions.jsindex 2e3fefa4a..74c3567fb 100644--- a/web/js/modules/palettes/actions.js+++ b/web/js/modules/palettes/actions.js@@ -1,7 +1,7 @@import { requestAction } from '../core/actions';import {REQUEST_PALETTE,- SET_RANGE_AND_SQUASH,+ SET_THRESHOLD_RANGE_AND_SQUASH,CLEAR_CUSTOM,SET_CUSTOM,LOADED_CUSTOM_PALETTES@@ -39,7 +39,7 @@ export function requestPalette(id) {* @param {Number} index | Palette index value for multi-paletted layers* @param {String} groupName | layer group string*/-export function setRangeAndSquash(layerId, props, index, groupName) {+export function setThresholdRangeAndSquash(layerId, props, index, groupName) {return (dispatch, getState) => {const state = getState();const newActivePalettesObj = setRangeSelector(@@ -50,7 +50,7 @@ export function setRangeAndSquash(layerId, props, index, groupName) {state);dispatch({- type: SET_RANGE_AND_SQUASH,+ type: SET_THRESHOLD_RANGE_AND_SQUASH,groupName: groupName,activeString: groupName,layerId,diff --git a/web/js/modules/palettes/constants.js b/web/js/modules/palettes/constants.jsindex a67fb832c..69866e483 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 PALETTE_CHANGE = 'PALETTES/CHANGE_OF_ACTIVE_PALETTE';-export const SET_RANGE_AND_SQUASH = 'PALETTES/SET_RANGE_AND_SQUASH';+export const SET_THRESHOLD_RANGE_AND_SQUASH = 'PALETTES/SET_THRESHOLD_RANGE_AND_SQUASH';export const CLEAR_CUSTOM = 'PALETTES/CLEAR_CUSTOM';export const CLEAR_CUSTOMS = 'PALETTES/CLEAR_CUSTOMS';export const SET_CUSTOM = 'PALETTES/SET_CUSTOM';diff --git a/web/js/modules/palettes/reducers.js b/web/js/modules/palettes/reducers.jsindex b6b3c1191..c2d0c2455 100644--- a/web/js/modules/palettes/reducers.js+++ b/web/js/modules/palettes/reducers.js@@ -8,7 +8,7 @@ import {REQUEST_PALETTE_SUCCESS,SET_CUSTOM,REQUEST_PALETTE_START,- SET_RANGE_AND_SQUASH,+ SET_THRESHOLD_RANGE_AND_SQUASH,LOADED_CUSTOM_PALETTES,BULK_PALETTE_RENDERING_SUCCESS,CLEAR_CUSTOM@@ -60,7 +60,7 @@ export function paletteReducer(state = defaultPaletteState, action) {return lodashAssign({}, state, {activeB: lodashCloneDeep(state.active)});- case SET_RANGE_AND_SQUASH:+ case SET_THRESHOLD_RANGE_AND_SQUASH:case SET_CUSTOM:case CLEAR_CUSTOM:return lodashAssign({}, state, {diff --git a/web/js/modules/vector-styles/actions.js b/web/js/modules/vector-styles/actions.jsindex b94d2dac5..913f94097 100644--- a/web/js/modules/vector-styles/actions.js+++ b/web/js/modules/vector-styles/actions.js@@ -1,9 +1,9 @@import { requestAction } from '../core/actions';import {REQUEST_VECTORSTYLE,- SET_RANGE_AND_SQUASH,- CLEAR_CUSTOM,- SET_CUSTOM,+ SET_FILTER_RANGE,+ CLEAR_VECTORSTYLE,+ SET_VECTORSTYLE,LOADED_CUSTOM_VECTORSTYLES} from './constants';import {@@ -39,7 +39,7 @@ export function requestVectorStyle(id) {* @param {Number} index | VectorStyle index value for multi-vectorStyled layers* @param {String} groupName | layer group string*/-export function setRangeAndSquash(layerId, props, index, groupName) {+export function setFilterRange(layerId, props, index, groupName) {return (dispatch, getState) => {const state = getState();const newActiveVectorStylesObj = setRangeSelector(@@ -50,7 +50,7 @@ export function setRangeAndSquash(layerId, props, index, groupName) {state);dispatch({- type: SET_RANGE_AND_SQUASH,+ type: SET_FILTER_RANGE,groupName: groupName,activeString: groupName,layerId,@@ -67,7 +67,7 @@ export function setRangeAndSquash(layerId, props, index, groupName) {* @param {Number} index | VectorStyle index value for multi-vectorStyled layers* @param {String} groupName | layer group string*/-export function setCustom(layerId, vectorStyleId, index, groupName) {+export function setStyle(layerId, vectorStyleId, index, groupName) {return (dispatch, getState) => {const state = getState();const newActiveVectorStylesObj = setCustomSelector(@@ -78,7 +78,7 @@ export function setCustom(layerId, vectorStyleId, index, groupName) {state);dispatch({- type: SET_CUSTOM,+ type: SET_VECTORSTYLE,layerId: layerId,vectorStyleId: vectorStyleId,groupName: groupName,@@ -94,7 +94,7 @@ export function setCustom(layerId, vectorStyleId, index, groupName) {* @param {Number} index | VectorStyle index value for multi-vectorStyled layers* @param {String} groupName | layer group string*/-export function clearCustomStyle(layerId, index, groupName) {+export function clearStyle(layerId, index, groupName) {return (dispatch, getState) => {const { vectorStyles } = getState();const newActiveVectorStylesObj = clearCustomSelector(@@ -104,7 +104,7 @@ export function clearCustomStyle(layerId, index, groupName) {);dispatch({- type: CLEAR_CUSTOM,+ type: CLEAR_VECTORSTYLE,groupName: groupName,vectorStyles: newActiveVectorStylesObj});diff --git a/web/js/modules/vector-styles/constants.js b/web/js/modules/vector-styles/constants.jsindex ec221134f..c6282fe5d 100644--- a/web/js/modules/vector-styles/constants.js+++ b/web/js/modules/vector-styles/constants.js@@ -4,7 +4,7 @@ export const REQUEST_VECTORSTYLE_SUCCESS = 'VECTORSTYLES/REQUEST_VECTORSTYLE_SUCexport const REQUEST_VECTORSTYLE_FAILURE = 'VECTORSTYLES/REQUEST_VECTORSTYLE_FAILURE';export const VECTORSTYLE_CHANGE = 'VECTORSTYLES/CHANGE_OF_ACTIVE_VECTORSTYLE';-export const SET_RANGE_AND_SQUASH = 'VECTORSTYLES/SET_RANGE_AND_SQUASH';-export const CLEAR_CUSTOM = 'VECTORSTYLES/CLEAR_CUSTOM';-export const SET_CUSTOM = 'VECTORSTYLES/SET_CUSTOM';+export const SET_FILTER_RANGE = 'VECTORSTYLES/SET_FILTER_RANGE';+export const CLEAR_VECTORSTYLE = 'VECTORSTYLES/CLEAR_VECTORSTYLE';+export const SET_VECTORSTYLE = 'VECTORSTYLES/SET_VECTORSTYLE';export const LOADED_CUSTOM_VECTORSTYLES = 'VECTORSTYLES/LOADED_CUSTOM_VECTORSTYLES';diff --git a/web/js/modules/vector-styles/reducers.js b/web/js/modules/vector-styles/reducers.jsindex 779142649..0168970b7 100644--- a/web/js/modules/vector-styles/reducers.js+++ b/web/js/modules/vector-styles/reducers.js@@ -1,9 +1,9 @@import { assign as lodashAssign, get as lodashGet } from 'lodash';import {REQUEST_VECTORSTYLE_SUCCESS,- SET_CUSTOM,+ SET_VECTORSTYLE,REQUEST_VECTORSTYLE_START,- SET_RANGE_AND_SQUASH,+ SET_FILTER_RANGE,LOADED_CUSTOM_VECTORSTYLES} from './constants';import update from 'immutability-helper';@@ -40,11 +40,11 @@ export function vectorStyleReducer(state = defaultVectorStyleState, action) {}),isLoading});- case SET_RANGE_AND_SQUASH:+ case SET_FILTER_RANGE:return lodashAssign({}, state, {[groupName]: action.vectorStyles});- case SET_CUSTOM:+ case SET_VECTORSTYLE:return lodashAssign({}, state, {[groupName]: action.vectorStyles});