Interactive interface for browsing global, full-resolution satellite imagery
Apply zots -- redux
Benjamin Kingdc292c03d0b4
diff --git a/web/js/containers/sidebar/layer-list.js b/web/js/containers/sidebar/layer-list.jsindex 240f6bc93..eb3bab3aa 100644--- a/web/js/containers/sidebar/layer-list.js+++ b/web/js/containers/sidebar/layer-list.js@@ -175,14 +175,14 @@ function mapStateToProps(state, ownProps) {checkerBoardPattern,layerSplit} = ownProps;- const { proj, compare } = state;+ const { proj, compare, config, legacy } = state;const { runningLayers } = state.layers;const { id } = proj;- const zoom = state.models.map.getZoom();- const zots = getZotsForActiveLayers(layers, zoom) || {};const activeDateString = compare.isCompareA ? 'selected' : 'selectedB';const activeLayers = state.layers[layerGroupName];-+ const zots = legacy.map.ui+ ? getZotsForActiveLayers(config, proj, legacy.map, activeLayers)+ : {};return {zots,layers,diff --git a/web/js/containers/sidebar/layer.js b/web/js/containers/sidebar/layer.jsindex 50bd094de..5d544c7b1 100644--- a/web/js/containers/sidebar/layer.js+++ b/web/js/containers/sidebar/layer.js@@ -28,11 +28,9 @@ const getItemStyle = (isDragging, draggableStyle) => ({class Layer extends React.Component {constructor(props) {super(props);- const { zot, index, isInProjection } = props;+ const { index } = props;this.state = {- zot: zot,- index: index,- isInProjection: isInProjection+ index: index};}getLegend() {@@ -103,7 +101,6 @@ class Layer extends React.Component {}}render() {- const { zot, isInProjection } = this.state;const {layerGroupName,onRemoveClick,@@ -118,7 +115,9 @@ class Layer extends React.Component {isMobile,index,onOptionsClick,- hasPalette+ hasPalette,+ zot,+ isInProjection} = this.props;return (diff --git a/web/js/modules/layers/selectors.js b/web/js/modules/layers/selectors.jsindex b239a057b..73152e98b 100644--- a/web/js/modules/layers/selectors.js+++ b/web/js/modules/layers/selectors.js@@ -460,20 +460,35 @@ export function activateLayersForEventCategory(activeLayers, state) {});return newLayers;}-export function getZotsForActiveLayers(config, models, ui) {- // var zotObj = {};- // var sources = config.sources;- // var proj = models.proj.selected.id;- // var layerGroupStr = models.layers.activeLayers;- // var layers = models.layers[layerGroupStr];- // var zoom = ui.map.selected.getView().getZoom();- // lodashEach(layers, layer => {- // if (layer.projections[proj]) {- // let overZoomValue = getZoomLevel(layer, zoom, proj, sources);- // if (overZoomValue) {- // zotObj[layer.id] = { value: overZoomValue };- // }- // }- // });- // return zotObj;+export function getZotsForActiveLayers(config, projection, map, activeLayers) {+ var zotObj = {};+ var sources = config.sources;+ var proj = projection.selected.id;+ var zoom = map.ui.selected.getView().getZoom();+ lodashEach(activeLayers, layer => {+ if (layer.projections[proj]) {+ let overZoomValue = getZoomLevel(layer, zoom, proj, sources);+ if (overZoomValue) {+ zotObj[layer.id] = { value: overZoomValue };+ }+ }+ });+ return zotObj;+}+function getZoomLevel(layer, zoom, proj, sources) {+ // Account for offset between the map's top zoom level and the+ // lowest-resolution TileMatrix in polar layers+ var zoomOffset = proj === 'arctic' || proj === 'antarctic' ? 1 : 0;+ var matrixSet = layer.projections[proj].matrixSet;++ if (matrixSet !== undefined && layer.type !== 'vector') {+ var source = layer.projections[proj].source;+ var zoomLimit =+ sources[source].matrixSets[matrixSet].resolutions.length - 1 + zoomOffset;+ if (zoom > zoomLimit) {+ var overZoomValue = Math.round((zoom - zoomLimit) * 100) / 100;+ return overZoomValue;+ }+ }+ return null;}