Interactive interface for browsing global, full-resolution satellite imagery
Change vectorStyle to style in URL and cleanup files
ZachTRice66f576b007f3
diff --git a/web/js/components/layer/settings/settings.js b/web/js/components/layer/settings/settings.jsindex 9b07fd461..c7f87d69d 100644--- a/web/js/components/layer/settings/settings.js+++ b/web/js/components/layer/settings/settings.js@@ -211,19 +211,13 @@ class LayerSettings extends React.Component {*/renderVectorStyles() {const {- setFilterRange,+setStyle,clearStyle,groupName,layer,vectorStyles} = this.props;- // const vectorStyle = getVectorStyle(layer.id, 0);- const max = 100; // Placeholder- // const start = vectorStyle.min || 0;- const start = 0; // Placeholder- // const end = vectorStyle.max || max;- const end = max; // Placeholdervar customStyle;if (layer.custom && layer.custom[0]) {customStyle = layer.custom[0];diff --git a/web/js/components/layer/settings/vector-style.js b/web/js/components/layer/settings/vector-style.jsindex 0292a04ab..1d15eca6a 100644--- a/web/js/components/layer/settings/vector-style.js+++ b/web/js/components/layer/settings/vector-style.js@@ -11,7 +11,7 @@ class VectorStyleSelect extends React.Component {}/**- * Pass palette to model after selection+ * Pass vector style to model after selection* @param {String} id | custom VectorStyle Id*/onChangeVectorStyle(vectorStyleId) {@@ -29,7 +29,7 @@ class VectorStyleSelect extends React.Component {this.setState({ activeVectorStyle: vectorStyleId });}/**- * Apply logic to render correct palette selection+ * Apply logic to render correct vectorStyle selection* @param {String} id | Legend Id*/customLegend(styleLayerObject) {@@ -47,7 +47,7 @@ class VectorStyleSelect extends React.Component {/*** Render classification customs when there is only one* Color in colormap- * @param {Object} palette | VectorStyle object+ * @param {Object} vectorStyle | VectorStyle object* @param {String} id | colormap Id* @param {String} description | Colormap name* @param {Boolean} isSelected | is this colormap activediff --git a/web/js/components/vector-metadata/tooltip.js b/web/js/components/vector-metadata/tooltip.jsindex 37c2a7c1f..b93429ea1 100644--- a/web/js/components/vector-metadata/tooltip.js+++ b/web/js/components/vector-metadata/tooltip.js@@ -22,7 +22,7 @@ export default class VectorMetaTooltip extends React.Component {return (<Fragment key={this.props.index}><span href="#" id={'tooltip-' + this.props.index}><i className="fa fa-info vector-info-icon"></i></span>- <Tooltip boundariesElement="window" placement="top" isOpen={this.state.tooltipOpen} target={'tooltip-' + this.props.index} toggle={this.toggle} flip={false} fade={false}>+ <Tooltip boundariesElement="window" placement="top" isOpen={this.state.tooltipOpen} target={'tooltip-' + this.props.index} toggle={this.toggle} fade={false}>{this.props.description}</Tooltip></Fragment>diff --git a/web/js/containers/sidebar/layer.js b/web/js/containers/sidebar/layer.jsindex 47cf8f1a4..4a42ec4ef 100644--- a/web/js/containers/sidebar/layer.js+++ b/web/js/containers/sidebar/layer.js@@ -281,7 +281,6 @@ function mapStateToProps(state, ownProps) {const hasPalette = !lodashIsEmpty(layer.palette);const renderedPalettes = palettes.rendered;const paletteName = lodashGet(config, `layers.${layer.id}.palette.id`);- const vectorStyleName = lodashGet(config, `layers.${layer.id}.vectorStyle.id`);const paletteLegends =hasPalette && renderedPalettes[paletteName]? getPaletteLegends(layer.id, layerGroupName, state)diff --git a/web/js/containers/sidebar/sidebar.js b/web/js/containers/sidebar/sidebar.jsindex f1978beee..3c48b533a 100644--- a/web/js/containers/sidebar/sidebar.js+++ b/web/js/containers/sidebar/sidebar.js@@ -12,7 +12,6 @@ import NavCase from '../../components/sidebar/nav/nav-case';import googleTagManager from 'googleTagManager';import { getCheckerboard, loadCustom as loadCustomPalette } from '../../modules/palettes/util';import { loadedCustomPalettes } from '../../modules/palettes/actions';-import { loadedDefaultVectorStyles } from '../../modules/vector-styles/actions';import { getLayers } from '../../modules/layers/selectors';import ErrorBoundary from '../error-boundary';import util from '../../util/util';@@ -262,9 +261,6 @@ const mapDispatchToProps = dispatch => ({},loadedCustomPalettes: customs => {dispatch(loadedCustomPalettes(customs));- },- loadedDefaultVectorStyles: customs => {- dispatch(loadedDefaultVectorStyles(customs));}});diff --git a/web/js/map/layerbuilder.js b/web/js/map/layerbuilder.jsindex 9505ce514..84f9662d2 100644--- a/web/js/map/layerbuilder.js+++ b/web/js/map/layerbuilder.js@@ -8,8 +8,6 @@ import OlTileGridTileGrid from 'ol/tilegrid/TileGrid';import MVT from 'ol/format/MVT';import LayerVectorTile from 'ol/layer/VectorTile';import SourceVectorTile from 'ol/source/VectorTile';-// import { applyStyle } from 'ol-mapbox-style';-// import stylefunction from 'ol-mapbox-style/stylefunction';import lodashCloneDeep from 'lodash/cloneDeep';import lodashMerge from 'lodash/merge';import lodashEach from 'lodash/each';diff --git a/web/js/map/ui.js b/web/js/map/ui.jsindex 11d4022ec..044e5ddc1 100644--- a/web/js/map/ui.js+++ b/web/js/map/ui.js@@ -103,7 +103,6 @@ export function mapui(models, config, store, ui) {if (newState.v && !newState.e && extent) {flyToNewExtent(extent, rotate);}- // ''}return;case layerConstants.REMOVE_LAYER:return removeLayer(action);diff --git a/web/js/modules/layers/util.js b/web/js/modules/layers/util.jsindex 29b97c0bb..7765ddfa1 100644--- a/web/js/modules/layers/util.js+++ b/web/js/modules/layers/util.js@@ -335,7 +335,7 @@ const createLayerArrayFromState = function(state, config) {let values = util.toArray(attr.value.split(';'));custom = values;}- if (attr.id === 'vectorStyle') {+ if (attr.id === 'style') {let values = util.toArray(attr.value.split(';'));custom = values;}diff --git a/web/js/modules/vector-styles/actions.js b/web/js/modules/vector-styles/actions.jsindex 804270ed6..bd37956fd 100644--- a/web/js/modules/vector-styles/actions.js+++ b/web/js/modules/vector-styles/actions.js@@ -1,13 +1,11 @@import {SET_FILTER_RANGE,CLEAR_VECTORSTYLE,- SET_VECTORSTYLE,- LOADED_CUSTOM_VECTORSTYLES+ SET_VECTORSTYLE} from './constants';import {setRange as setRangeSelector,setStyleFunction- // clearCustomSelector} from './selectors';/**@@ -91,14 +89,3 @@ export function clearStyle(layer, vectorStyleId, groupName) {});};}-/**- * Action signifying custom vectorStyles have been loaded- *- * @param {Object} customs | Custom VectorStyles from Config- */-export function loadedDefaultVectorStyles(customs) {- return {- type: LOADED_CUSTOM_VECTORSTYLES,- custom: customs- };-}diff --git a/web/js/modules/vector-styles/constants.js b/web/js/modules/vector-styles/constants.jsindex cc6f20a7b..693e1ab69 100644--- a/web/js/modules/vector-styles/constants.js+++ b/web/js/modules/vector-styles/constants.js@@ -2,4 +2,3 @@ export const VECTORSTYLE_CHANGE = 'VECTORSTYLES/CHANGE_OF_ACTIVE_VECTORSTYLE';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 1d3dfe918..aa5b9f4ef 100644--- a/web/js/modules/vector-styles/reducers.js+++ b/web/js/modules/vector-styles/reducers.js@@ -2,11 +2,8 @@ import { assign as lodashAssign, get as lodashGet } from 'lodash';import {CLEAR_VECTORSTYLE,SET_VECTORSTYLE,- SET_FILTER_RANGE,- LOADED_CUSTOM_VECTORSTYLES+ SET_FILTER_RANGE} from './constants';-// import update from 'immutability-helper';-// import util from '../../util/util';export const defaultVectorStyleState = {custom: {},active: {},@@ -34,10 +31,6 @@ export function vectorStyleReducer(state = defaultVectorStyleState, action) {return lodashAssign({}, state, {[groupName]: action.vectorStyles});- case LOADED_CUSTOM_VECTORSTYLES:- return lodashAssign({}, state, {- custom: action.custom- });default:return state;}diff --git a/web/js/modules/vector-styles/selectors.js b/web/js/modules/vector-styles/selectors.jsindex fcc9bc8be..7df71c699 100644--- a/web/js/modules/vector-styles/selectors.js+++ b/web/js/modules/vector-styles/selectors.js@@ -50,130 +50,6 @@ export function getAllVectorStyles(layerId, index, state) {return vectorStyle;}-export function getCount(layerId, state) {- const renderedVectorStyle = getAllVectorStyles(layerId, undefined, state);- if (renderedVectorStyle && renderedVectorStyle.layers) {- return renderedVectorStyle.layers.length;- } else {- return 0;- }-}--// export function getCustomVectorStyle(vectorStyleId, customsVectorStyleConfig) {-// var vectorStyle = customsVectorStyleConfig[vectorStyleId];-// if (!vectorStyle) {-// throw new Error('Invalid vectorStyle: ' + vectorStyleId);-// }-// return vectorStyle;-// }-// var useLookup = function(layerId, vectorStylesObj, state) {-// var use = false;-// var active = vectorStylesObj[layerId].maps;--// lodashEach(active, function(vectorStyle, index) {-// if (vectorStyle.custom) {-// use = true;-// return false;-// }-// var rendered = getAllVectorStyles(layerId, index, state);-// console.log(rendered);-// if (vectorStyle.min <= 0) {-// delete vectorStyle.min;-// }-// if (vectorStyle.max >= rendered.entries.values.length) {-// delete vectorStyle.max;-// }-// if (!lodashIsUndefined(vectorStyle.min) || !lodashIsUndefined(vectorStyle.max)) {-// use = true;-// return false;-// }-// });-// return use;-// };-// Looks up options/colormaps/layer.xml colormap entry-export function getLookup(layerId, groupstr, state) {- groupstr = groupstr || state.compare.activeString;- return state.vectorStyles[groupstr][layerId].lookup;-}-// var updateLookup = function(layerId, vectorStylesObj, state) {-// let newVectorStyles = vectorStylesObj;-// if (!useLookup(layerId, newVectorStyles, state)) {-// delete newVectorStyles[layerId];-// return newVectorStyles;-// }-// var lookup = {};-// var active = newVectorStyles[layerId].maps;-// lodashEach(active, function(vectorStyle, index) {-// var oldLegend = vectorStyle.legend;-// var entries = vectorStyle.entries;-// var legend = {-// colors: [],-// minLabel: oldLegend.minLabel,-// maxLabel: oldLegend.maxLabel,-// tooltips: oldLegend.tooltips,-// units: oldLegend.units,-// type: entries.type,-// title: entries.title,-// id: oldLegend.id-// };-// var source = entries.colors;-// var target = vectorStyle.custom-// ? getCustomVectorStyle(vectorStyle.custom, state.vectorStyles.custom).colors-// : source;--// var min = vectorStyle.min || 0;-// var max = vectorStyle.max || source.length;--// var sourceCount = source.length;-// var targetCount = target.length;-// lodashEach(source, function(color, index) {-// var targetColor;-// if (index < min || index > max) {-// targetColor = '00000000';-// } else {-// var sourcePercent, targetIndex;-// if (vectorStyle.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);-// var lookupSource =-// lodashParseInt(color.substring(0, 2), 16) +-// ',' +-// lodashParseInt(color.substring(2, 4), 16) +-// ',' +-// lodashParseInt(color.substring(4, 6), 16) +-// ',' +-// lodashParseInt(color.substring(6, 8), 16);-// var lookupTarget = {-// r: lodashParseInt(targetColor.substring(0, 2), 16),-// g: lodashParseInt(targetColor.substring(2, 4), 16),-// b: lodashParseInt(targetColor.substring(4, 6), 16),-// a: lodashParseInt(targetColor.substring(6, 8), 16)-// };-// lookup[lookupSource] = lookupTarget;-// });--// newVectorStyles = update(newVectorStyles, {-// [layerId]: {-// maps: { [index]: { legend: { $set: legend } } }-// }-// });-// });-// return update(newVectorStyles, { [layerId]: { lookup: { $set: lookup } } });-// };-export function findIndex(layerId, type, value, index, groupStr, state) {index = index || 0;var values = getVectorStyle(layerId, index, groupStr, state).entries.values;@@ -192,23 +68,6 @@ export function findIndex(layerId, type, value, index, groupStr, state) {});return result;}-// export function setCustomSelector(def, vectorStyleId, vectorStyles, layer, state, groupName) {-// const { config } = state;-// if (!config.layers[def.id]) {-// throw new Error('Invalid layer: ' + def.id);-// }-// let newVectorStyles = prepare(def.id, vectorStyles[groupName], state);-// def = lodashIsUndefined(def) ? 0 : def;-// var active = newVectorStyles[def.id];-// var vectorStyle = active.maps[def];-// if (vectorStyle.custom === vectorStyleId) {-// return;-// }-// vectorStyle.custom = vectorStyleId;-// setStyleFunction(def, vectorStyleId, vectorStyles, layer, state);--// return updateLookup(def.id, newVectorStyles, state);-// }export function setStyleFunction(def, vectorStyleId, vectorStyles, layer, state) {var styleFunction;@@ -287,7 +146,7 @@ export function getKey(layerId, groupStr, state) {var def = getVectorStyle(layerId, undefined, groupStr, state);var keys = [];if (def.custom) {- keys.push('vectorStyle=' + def.custom);+ keys.push('style=' + def.custom);}if (def.min) {keys.push('min=' + def.min);@@ -303,53 +162,6 @@ export function isActive(layerId, group, state) {return state.vectorStyles[group][layerId];}}-export function setRange(layerId, props, index, vectorStyles, state) {- let min = props.min;- let max = props.max;- // let squash = props.squash;- // let newVectorStyles = prepare(layerId, vectorStyles, state);- index = lodashIsUndefined(index) ? 0 : index;- if (min === 0) {- min = undefined;- }- const legend = getVectorStyle(layerId, index, undefined, state);- if (- legend.entries &&- legend.entries.values &&- max === legend.entries.values.length - 1- ) {- max = undefined;- }-- // Merge custom vectorStyle props with correct colormap- // newVectorStyles = update(newVectorStyles, {- // [layerId]: {- // maps: {- // [index]: {- // $merge: {- // max,- // min,- // squash- // }- // }- // }- // }- // });-- // return updateLookup(layerId, newVectorStyles, state);-}-export function clearCustomSelector(layerId, index, vectorStyles) {- index = lodashIsUndefined(index) ? 0 : index;- var active = vectorStyles[layerId];- if (!active) {- return vectorStyles;- }- var vectorStyle = active.maps[index];- if (!vectorStyle.custom) {- return vectorStyles;- }- return update(vectorStyles, { layerId: { maps: { $unset: ['custom'] } } }); // remove custom key-}export function clearStyleFunction(def, vectorStyleId, vectorStyles, layer, state) {var styleFunction;@@ -380,21 +192,3 @@ export function clearStyleFunction(def, vectorStyleId, vectorStyles, layer, stat}return update(vectorStyles, { layerId: { maps: { $unset: ['custom'] } } });}--// var prepare = function(layerId, vectorStylesObj, state) {-// var newVectorStyles = lodashCloneDeep(vectorStylesObj);-// if (!newVectorStyles[layerId]) newVectorStyles[layerId] = {};-// var active = newVectorStyles[layerId];-// active.maps = active.maps || [];-// lodashEach(getAllVectorStyles(layerId, undefined, state).maps, function(-// vectorStyle,-// index-// ) {-// if (!active.maps[index]) {-// newVectorStyles = update(newVectorStyles, {-// [layerId]: { maps: { [index]: { $set: vectorStyle } } }-// });-// }-// });-// return newVectorStyles;-// };diff --git a/web/js/modules/vector-styles/util.js b/web/js/modules/vector-styles/util.jsindex 51ae1ef7f..cc79f5da6 100644--- a/web/js/modules/vector-styles/util.js+++ b/web/js/modules/vector-styles/util.js@@ -1,7 +1,6 @@import update from 'immutability-helper';import {each as lodashEach,- // find as lodashFind,assign as lodashAssign} from 'lodash';import {@@ -10,7 +9,6 @@ import {setRange as setRangeSelector,findIndex as findVectorStyleExtremeIndex} from './selectors';-// import util from '../../util/util';export function getVectorStyleAttributeArray(layer) {var isCustomActive = false;@@ -27,13 +25,13 @@ export function getVectorStyleAttributeArray(layer) {[styleObj, minObj, maxObj].forEach(obj => {if (obj.isActive) {attrArray.push({- id: obj.key === 'custom' ? 'vectorStyle' : obj.key,+ id: obj.key === 'custom' ? 'style' : obj.key,value: obj.value});} else {if (obj.isActive) {attrArray.push({- id: obj.key === 'custom' ? 'vectorStyle' : obj.key,+ id: obj.key === 'custom' ? 'style' : obj.key,value: ''});}@@ -56,6 +54,7 @@ export function loadVectorStyles(permlinkState, state) {var min = [];var max = [];var count = 0;+ // TODO this try block never worksif (layerDef.custom && layerDef.custom[0]) {let vectorStyleId = layerDef.custom[0];try {