Interactive interface for browsing global, full-resolution satellite imagery
replace hasSecondLayerGroup with key in compare reducer that will init layers and dates #1965
Benjamin King88b366d6bfa7
diff --git a/doc/url_parameters.md b/doc/url_parameters.mdindex 1e3826dba..ebe0d5d76 100644--- a/doc/url_parameters.md+++ b/doc/url_parameters.md@@ -7,28 +7,28 @@| `l (l1 for B state)` | string | _`layer_id1,layer_id2,..,layerIdN`_ | Active layer list where `layer_id` is the identifier of the layer as defined in the configuration file. Any number of baselayers or overlays may be specified (separated by a `,`). || | boolean | _`layer_id(`**`hidden`**`)`_ | If present, this layer will appear in the layer list but not shown on the map. || | 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(`**`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(`**`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. |+| | 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(`**`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. || `l` | date | _`YYYY-MM-DD-Thh:mm:ssZ`_ | Selected UTC day and time. _\*Time fields will only be shown when subdaily layers are active._ || `t (t1 for B state)` | date | _`YYYY-MM-DD-Thh:mm:ssZ`_ | Selected UTC day and time. _\*Time fields will only be shown when subdaily layers are active._ |-| `z` | number | **`1`** to **`5`** | The timescale axis zoom value from 1 to 5. 1 = yearly, 2 = monthly, 3 = daily, 4 = hourly, and 5 = minutely. _\*The subdaily zoom level will only be available when subdaily layers are active._ |-| `ics` | boolean | _`true`_ or _`false`_ | If `custom selected` is `true`, a `custom interval` and `custom delta` will be active and allow custom intervals in time changes. |-| `ici` | number | **`1`** to **`5`** | The `custom interval` value from 1 to 5 identifies which time unit is changed by the date change arrows and optionally animation. 1 = yearly, 2 = monthly, 3 = daily, 4 = hourly, and 5 = minutely. _\*Only active and saved in url if `custom selected` is true._ |-| `icd` | number | **`1`** to **`999`** | The `custom delta` value for how many `custom interval` time units are added or subtracted when using the date change arrows and optionally animation. _\*Only active and saved in url if `custom selected` is true._ |+| `z` | number | **`1`** to **`5`** | The timescale axis zoom value from 1 to 5. 1 = yearly, 2 = monthly, 3 = daily, 4 = hourly, and 5 = minutely. _\*The subdaily zoom level will only be available when subdaily layers are active._ |+| `ics` | boolean | _`true`_ or _`false`_ | If `custom selected` is `true`, a `custom interval` and `custom delta` will be active and allow custom intervals in time changes. |+| `ici` | number | **`1`** to **`5`** | The `custom interval` value from 1 to 5 identifies which time unit is changed by the date change arrows and optionally animation. 1 = yearly, 2 = monthly, 3 = daily, 4 = hourly, and 5 = minutely. _\*Only active and saved in url if `custom selected` is true._ |+| `icd` | number | **`1`** to **`999`** | The `custom delta` value for how many `custom interval` time units are added or subtracted when using the date change arrows and optionally animation. _\*Only active and saved in url if `custom selected` is true._ || `e` | string,date | _`event_id,yyyy-mm-dd`_ | If any value is present, the events tab will be activated. If the value is a valid event_id, the corresponding event will be highlighted in the event list. If a date (YYYY-MM-DD) is added to the event_id, then the selected event for the specified date will be shown. || `ab` | boolean | **`on`** | If set to "on", the animation widget will be shown. || `as` | date | _`YYYY-MM-DDThh:mm:ssZ`_ | The animation start day & time. _\*Time fields will only be shown when subdaily layers are active._ || `ae` | date | _`YYYY-MM-DDThh:mm:ssZ`_ | The animation end day & time _\*Time fields will only be shown when subdaily layers are active._ || `av` | number | **`1`** to **`10`** | The animation speed value from 1 to 10. 1 = slowest, 10 = fastest. || `al` | boolean | _`true`_ or _`false`_ | If any value is set, the animation loop will be turned on. Animation looping is disabled by default. |-| `ca` | boolean | _`true`_ or _`false`_ | If `ca=true`, the comparison feature will be active |-| `cm` | string | _`swipe`_ , _`spy`_ or _`opacity`_ | If comparison mode is active (`ca=true`) the `cm` parameter will determine which comparision mode to use. Default mode is `swipe` |-| `cv` | Number | **`0`** to **`100`** | If `ca=true`, The `cv` parameter is used to determine the location of the swiper or the value of opacity depending on the selected mode. Default is `50` which will place the swiper on the middle of any screen. This parameter is irrelevant when the `spy` mode is active (`cm=spy`) |+| `ca` | boolean | _`true`_ or _`false`_ | Determines if the A or B state is active. If this parameter exists at all, compare mode will be active. If `ca=true`, Compare mode will be active in the A state. |+| `cm` | string | _`swipe`_ , _`spy`_ or _`opacity`_ | If comparison mode is active (`ca=true|false`) the `cm` parameter will determine which comparision mode to use. Default mode is `swipe` |+| `cv` | Number | **`0`** to **`100`** | If `ca='true|false'`, The `cv` parameter is used to determine the location of the swiper or the value of opacity depending on the selected mode. Default is `50` which will place the swiper on the middle of any screen. This parameter is irrelevant when the `spy` mode is active (`cm=spy`) || `download` | string | _`product_id`_ | If any value is set, the data download tab will be activated. If a product identifier is set, the corresponding will be selected. || `r` | number | **`-180.0000`** to **`180.0000`** | The degree of map rotation. Only applies when `arctic` or `antarctic` projection is selected. |-| `tr` | string | _`tour_id`_ | The id of the tour story to load. Stories will load from step 1. |+| `tr` | string | _`tour_id`_ | The id of the tour story to load. Stories will load from step 1. |For debugging with URL parameters, see: [Testing / Debug Parameters](testing.md#debug-parameters)diff --git a/web/js/modules/compare/actions.js b/web/js/modules/compare/actions.jsindex 59e95811c..8a63c3841 100644--- a/web/js/modules/compare/actions.js+++ b/web/js/modules/compare/actions.js@@ -1,4 +1,5 @@import { initSecondLayerGroup } from '../layers/actions';+import {initSecondDate} from '../date/actions';import {CHANGE_STATE,TOGGLE_ON_OFF,@@ -13,8 +14,9 @@ export function toggleActiveCompareState(str) {}export function toggleCompareOnOff() {return (dispatch, getState) => {- if (!getState().layers.hasSecondLayerGroup) {+ if (!getState().compare.bStatesInitiated) {dispatch(initSecondLayerGroup());+ dispatch(initSecondDate());}dispatch({type: TOGGLE_ON_OFFdiff --git a/web/js/modules/compare/reducers.js b/web/js/modules/compare/reducers.jsindex 9be206a2d..df5f70d61 100644--- a/web/js/modules/compare/reducers.js+++ b/web/js/modules/compare/reducers.js@@ -10,7 +10,8 @@ export const initialCompareState = {isCompareA: true,mode: 'swipe',value: 50,- activeString: 'active'+ activeString: 'active',+ bStatesInitiated: false};export function compareReducer(state = initialCompareState, action) {switch (action.type) {diff --git a/web/js/modules/compare/util.js b/web/js/modules/compare/util.jsindex baf920f4a..9b61834e9 100644--- a/web/js/modules/compare/util.js+++ b/web/js/modules/compare/util.js@@ -11,16 +11,13 @@ export function mapLocationToCompareState(parameters, stateFromLocation) {compare: { activeString: { $set: 'activeB' } }});stateFromLocation = update(stateFromLocation, {- layers: { hasSecondLayerGroup: { $set: true } }+ compare: { bStatesInitiated: { $set: true } }});}} else {stateFromLocation = update(stateFromLocation, {compare: { $set: initialCompareState }});- stateFromLocation = update(stateFromLocation, {- layers: { hasSecondLayerGroup: { $set: false } }- });}return stateFromLocation;}diff --git a/web/js/modules/date/actions.js b/web/js/modules/date/actions.jsindex aa8ab8c07..3e07aef01 100644--- a/web/js/modules/date/actions.js+++ b/web/js/modules/date/actions.js@@ -4,7 +4,8 @@ import {CHANGE_INTERVAL,SELECT_DATE,UPDATE_APP_NOW,- TOGGLE_CUSTOM_MODAL+ TOGGLE_CUSTOM_MODAL,+ INIT_SECOND_DATE} from './constants';export function changeTimeScale(num) {@@ -19,6 +20,12 @@ export function updateAppNow(date) {value: date};}+export function initSecondDate() {+ return {+ type: INIT_SECOND_DATE,++ };+}export function selectDate(value) {return (dispatch, getState) => {const compareState = getState().compare;diff --git a/web/js/modules/date/constants.js b/web/js/modules/date/constants.jsindex 44c5a9e24..f262bb161 100644--- a/web/js/modules/date/constants.js+++ b/web/js/modules/date/constants.js@@ -4,7 +4,7 @@ export const CHANGE_TIME_SCALE = 'DATE/CHANGE_TIME_SCALE';export const SELECT_DATE = 'DATE/SELECT_DATE';export const UPDATE_APP_NOW = 'DATE/UPDATE_APP_NOW';export const TOGGLE_CUSTOM_MODAL = 'DATE/TOGGLE_CUSTOM_MODAL';-+export const INIT_SECOND_DATE = 'DATE/INIT_SECOND_DATE';export const timeScaleFromNumberKey = {0: 'custom',1: 'year',diff --git a/web/js/modules/date/reducers.js b/web/js/modules/date/reducers.jsindex 6bf91d085..710d5c084 100644--- a/web/js/modules/date/reducers.js+++ b/web/js/modules/date/reducers.js@@ -5,7 +5,8 @@ import {SELECT_DATE,UPDATE_APP_NOW,TOGGLE_CUSTOM_MODAL,- customModalType+ customModalType,+ INIT_SECOND_DATE} from './constants';import util from '../../util/util';import { assign as lodashAssign } from 'lodash';@@ -36,6 +37,10 @@ export function dateReducer(state = dateReducerState, action) {return lodashAssign({}, state, {selectedZoom: action.value});+ case INIT_SECOND_DATE:+ return lodashAssign({}, state, {+ selectedB: util.dateAdd(state.selected, 'day', -7),+ });case CHANGE_CUSTOM_INTERVAL:return lodashAssign({}, state, {customInterval: action.value,diff --git a/web/js/modules/layers/reducers.js b/web/js/modules/layers/reducers.jsindex c4046034b..55becb994 100644--- a/web/js/modules/layers/reducers.js+++ b/web/js/modules/layers/reducers.js@@ -33,8 +33,7 @@ export const initialState = {layersConfig: {},hoveredLayer: '',layerConfig: {},- startingLayers: [],- hasSecondLayerGroup: false+ startingLayers: []};export function getInitialState(config) {return lodashAssign({}, initialState, {@@ -55,10 +54,8 @@ export function layerReducer(state = initialState, action) {[layerGroupStr]: action.layers});case INIT_SECOND_LAYER_GROUP:- if (state.hasSecondLayerGroup) return state;return lodashAssign({}, state, {- activeB: lodashCloneDeep(state.active),- hasSecondLayerGroup: true+ activeB: lodashCloneDeep(state.active)});case ON_LAYER_HOVER:return lodashAssign({}, state, {