Skip to content

Interactive interface for browsing global, full-resolution satellite imagery

WIP

Jason Kentc2d2b55cd052
diff --git a/web/js/components/date-selector/date-input-column.js b/web/js/components/date-selector/date-input-column.js
index 783338839..57706613f 100644
--- a/web/js/components/date-selector/date-input-column.js
+++ b/web/js/components/date-selector/date-input-column.js
@@ -8,8 +8,8 @@ import {
dayValidation,
hourValidation,
minuteValidation,
- monthStringArray,
} from './util';
+import { MONTH_STRING_ARRAY } from '../../modules/date/constants';
/*
* DateInputColumn used in DateSelector within
@@ -191,7 +191,7 @@ class DateInputColumn extends Component {
// transform month number to string (e.g., 3 -> 'MAR')
// eslint-disable-next-line no-restricted-globals
if (newDate !== null && !isNaN(value)) {
- value = monthStringArray[value - 1];
+ value = MONTH_STRING_ARRAY[value - 1];
}
break;
case 'day':
@@ -254,7 +254,7 @@ class DateInputColumn extends Component {
// eslint-disable-next-line no-restricted-globals
if (type === 'month' && !isNaN(newValue)) {
- newValue = monthStringArray[newValue - 1];
+ newValue = MONTH_STRING_ARRAY[newValue - 1];
} else if (newValue.length === 1) {
newValue = `0${newValue}`;
}
diff --git a/web/js/components/date-selector/date-selector.js b/web/js/components/date-selector/date-selector.js
index 063645af9..23dbcb8cc 100644
--- a/web/js/components/date-selector/date-selector.js
+++ b/web/js/components/date-selector/date-selector.js
@@ -3,7 +3,7 @@ import React, { Component } from 'react';
import PropTypes from 'prop-types';
import DateInputColumn from './date-input-column';
import util from '../../util/util';
-import { monthStringArray } from './util';
+import { MONTH_STRING_ARRAY } from '../../modules/date/constants';
/*
* DateSelector used within Timeline and AnimationWidget.
@@ -168,7 +168,7 @@ class DateSelector extends Component {
}
if (month) {
- const realMonth = util.stringInArray(monthStringArray, month);
+ const realMonth = util.stringInArray(dAY, month);
const maxDatePrev = new Date(
date.getUTCFullYear(),
date.getUTCMonth() + 1,
@@ -221,7 +221,7 @@ class DateSelector extends Component {
let dateCheck;
if (day <= maxDayDate) {
- const realMonth = util.stringInArray(monthStringArray, month);
+ const realMonth = util.stringInArray(MONTH_STRING_ARRAY, month);
date = new Date(new Date(date).setUTCDate(day));
dateCheck = new Date(inputDate);
dateCheck = new Date(new Date(date).setUTCDate(1));
@@ -370,7 +370,7 @@ class DateSelector extends Component {
};
const yearValue = year || date.getUTCFullYear();
- const monthValue = month || monthStringArray[date.getUTCMonth()];
+ const monthValue = month || MONTH_STRING_ARRAY[date.getUTCMonth()];
const dayValue = day || util.pad(date.getUTCDate(), 2, '0');
const hourValue = hour || util.pad(date.getUTCHours(), 2, '0');
const minuteValue = minute || util.pad(date.getUTCMinutes(), 2, '0');
diff --git a/web/js/components/date-selector/util.js b/web/js/components/date-selector/util.js
index 6565c02df..876f80249 100644
--- a/web/js/components/date-selector/util.js
+++ b/web/js/components/date-selector/util.js
@@ -1,19 +1,5 @@
import util from '../../util/util';
-
-export const monthStringArray = [
- 'JAN',
- 'FEB',
- 'MAR',
- 'APR',
- 'MAY',
- 'JUN',
- 'JUL',
- 'AUG',
- 'SEP',
- 'OCT',
- 'NOV',
- 'DEC',
-];
+import { MONTH_STRING_ARRAY } from '../../modules/date/constants';
/**
*
@@ -47,7 +33,7 @@ export const monthValidation = (value, dateParam, validate) => {
}
return null;
}
- const realMonth = util.stringInArray(monthStringArray, value);
+ const realMonth = util.stringInArray(MONTH_STRING_ARRAY, value);
if (realMonth !== false) {
const day = date.getUTCDate();
const zeroDay = new Date(date.setUTCDate(1));
diff --git a/web/js/components/sidebar/event.js b/web/js/components/sidebar/event.js
index 7a262d754..676fdaf6c 100644
--- a/web/js/components/sidebar/event.js
+++ b/web/js/components/sidebar/event.js
@@ -66,7 +66,7 @@ function Event (props) {
style={!isSelected ? { display: 'none' } : { display: 'block' }}
>
{event.geometry.map((geometry, index) => {
- const date = geometry.date.split('T')[0];
+ const date = util.toISOStringDateMonthAbbrev(new Date(geometry.date));
return (
<li key={`${event.id}-${date}`} className="dates">
<a
diff --git a/web/js/components/timeline/custom-interval-selector/custom-interval-selector.js b/web/js/components/timeline/custom-interval-selector/custom-interval-selector.js
index 2a76999c4..4845da120 100644
--- a/web/js/components/timeline/custom-interval-selector/custom-interval-selector.js
+++ b/web/js/components/timeline/custom-interval-selector/custom-interval-selector.js
@@ -5,8 +5,8 @@ import { FontAwesomeIcon } from '@fortawesome/react-fontawesome';
import DeltaInput from './delta-input';
import IntervalSelect from './interval-select';
import {
- timeScaleFromNumberKey,
- timeScaleToNumberKey,
+ TIME_SCALE_FROM_NUMBER,
+ TIME_SCALE_TO_NUMBER,
} from '../../../modules/date/constants';
import {
toggleCustomModal,
@@ -42,11 +42,11 @@ class CustomIntervalSelector extends PureComponent {
if (subdailyRemoved && subdailyInterval) {
changeCustomInterval();
- selectInterval(1, timeScaleToNumberKey.day, false);
+ selectInterval(1, TIME_SCALE_TO_NUMBER.day, false);
}
if (subdailyAdded && !customSelected) {
- changeCustomInterval(10, timeScaleToNumberKey.minute);
+ changeCustomInterval(10, TIME_SCALE_TO_NUMBER.minute);
}
}
@@ -61,7 +61,7 @@ class CustomIntervalSelector extends PureComponent {
changeZoomLevel = (zoomLevel) => {
const { changeCustomInterval, customDelta } = this.props;
- changeCustomInterval(customDelta, timeScaleToNumberKey[zoomLevel]);
+ changeCustomInterval(customDelta, TIME_SCALE_TO_NUMBER[zoomLevel]);
}
handleKeyPress= (e) => {
@@ -94,7 +94,7 @@ class CustomIntervalSelector extends PureComponent {
/>
<IntervalSelect
hasSubdailyLayers={hasSubdailyLayers}
- zoomLevel={timeScaleFromNumberKey[customInterval]}
+ zoomLevel={TIME_SCALE_FROM_NUMBER[customInterval]}
changeZoomLevel={this.changeZoomLevel}
/>
</div>
diff --git a/web/js/components/timeline/mobile-date-picker.js b/web/js/components/timeline/mobile-date-picker.js
index 4dbeaa616..afcd34d69 100644
--- a/web/js/components/timeline/mobile-date-picker.js
+++ b/web/js/components/timeline/mobile-date-picker.js
@@ -2,7 +2,7 @@ import React, { Component } from 'react';
import PropTypes from 'prop-types';
import DatePicker from 'react-mobile-datepicker';
import { getDisplayDate, getISODateFormatted } from './date-util';
-import { monthMap } from '../../modules/date/constants';
+import { MONTH_STRING_ARRAY } from '../../modules/date/constants';
import HoverTooltip from '../util/hover-tooltip';
// https://www.npmjs.com/package/react-mobile-datepicker
@@ -14,7 +14,7 @@ const defaultDateConfig = {
step: 1,
},
month: {
- format: (value) => monthMap[value.getMonth() + 1],
+ format: (value) => MONTH_STRING_ARRAY[value.getMonth()],
caption: 'Mon',
step: 1,
},
@@ -32,7 +32,7 @@ const subDailyDateConfig = {
step: 1,
},
month: {
- format: (value) => monthMap[value.getMonth() + 1],
+ format: (value) => MONTH_STRING_ARRAY[value.getMonth()],
caption: 'Mon',
step: 1,
},
diff --git a/web/js/components/timeline/timeline-axis/timeline-axis.js b/web/js/components/timeline/timeline-axis/timeline-axis.js
index 1544bc64b..429d00224 100644
--- a/web/js/components/timeline/timeline-axis/timeline-axis.js
+++ b/web/js/components/timeline/timeline-axis/timeline-axis.js
@@ -11,7 +11,7 @@ import GridRange from './grid-range/grid-range';
import getTimeRange from './date-calc';
import {
timeScaleOptions,
- timeScaleToNumberKey,
+ TIME_SCALE_TO_NUMBER,
} from '../../../modules/date/constants';
import {
getIsBetween,
@@ -346,7 +346,7 @@ class TimelineAxis extends Component {
if (!isYearOrMonth) {
// determine if changing timeScale from greater to lesser (e.g., 'year' to 'month')
const greaterToLesserTimescale = timeScale && previousTimeScale
- ? timeScaleToNumberKey[timeScale] < timeScaleToNumberKey[previousTimeScale]
+ ? TIME_SCALE_TO_NUMBER[timeScale] < TIME_SCALE_TO_NUMBER[previousTimeScale]
: null;
if (greaterToLesserTimescale) {
diff --git a/web/js/components/timeline/timeline-controls/axis-timescale-change.js b/web/js/components/timeline/timeline-controls/axis-timescale-change.js
index c64e6cffc..23696deae 100644
--- a/web/js/components/timeline/timeline-controls/axis-timescale-change.js
+++ b/web/js/components/timeline/timeline-controls/axis-timescale-change.js
@@ -2,7 +2,7 @@
import React, { PureComponent } from 'react';
import PropTypes from 'prop-types';
import AxisTimeScaleChangeControls from './axis-timescale-change-controls';
-import { timeScaleToNumberKey } from '../../../modules/date/constants';
+import { TIME_SCALE_TO_NUMBER } from '../../../modules/date/constants';
/*
* Parent element for timeScale change controls and tooltip
@@ -58,7 +58,7 @@ class AxisTimeScaleChange extends PureComponent {
hasSubdailyLayers,
timeScale,
} = this.props;
- const timeScaleNumber = timeScaleToNumberKey[timeScale];
+ const timeScaleNumber = TIME_SCALE_TO_NUMBER[timeScale];
const maxTimeScaleNumber = hasSubdailyLayers ? 5 : 3;
if (timeScaleNumber < maxTimeScaleNumber) {
changeTimeScale(timeScaleNumber + 1);
@@ -71,7 +71,7 @@ class AxisTimeScaleChange extends PureComponent {
changeTimeScale,
timeScale,
} = this.props;
- const timeScaleNumber = timeScaleToNumberKey[timeScale];
+ const timeScaleNumber = TIME_SCALE_TO_NUMBER[timeScale];
if (timeScaleNumber > 1) {
changeTimeScale(timeScaleNumber - 1);
}
diff --git a/web/js/components/timeline/timeline-controls/timescale-interval-change.js b/web/js/components/timeline/timeline-controls/timescale-interval-change.js
index 212bee8a3..280bb718f 100644
--- a/web/js/components/timeline/timeline-controls/timescale-interval-change.js
+++ b/web/js/components/timeline/timeline-controls/timescale-interval-change.js
@@ -2,8 +2,8 @@ import React, { PureComponent } from 'react';
import PropTypes from 'prop-types';
import { connect } from 'react-redux';
import {
- timeScaleToNumberKey,
- timeScaleFromNumberKey,
+ TIME_SCALE_TO_NUMBER,
+ TIME_SCALE_FROM_NUMBER,
} from '../../../modules/date/constants';
import {
toggleCustomModal as toggleCustomModalAction,
@@ -105,7 +105,7 @@ class TimeScaleIntervalChange extends PureComponent {
newTimeScale = customInterval;
delta = customDelta;
} else {
- newTimeScale = Number(timeScaleToNumberKey[newTimeScale]);
+ newTimeScale = Number(TIME_SCALE_TO_NUMBER[newTimeScale]);
delta = 1;
}
selectInterval(delta, newTimeScale, customSelected);
@@ -115,7 +115,7 @@ class TimeScaleIntervalChange extends PureComponent {
setCustomIntervalText = () => {
const { customDelta, customInterval } = this.props;
this.setState({
- customIntervalText: `${customDelta} ${timeScaleFromNumberKey[customInterval]}`,
+ customIntervalText: `${customDelta} ${TIME_SCALE_FROM_NUMBER[customInterval]}`,
});
}
@@ -150,7 +150,7 @@ class TimeScaleIntervalChange extends PureComponent {
id="current-interval"
className={`no-drag interval-btn interval-btn-active${customSelected ? ' custom-interval-text' : ''}`}
>
- {customSelected ? customIntervalText : `${1} ${timeScaleFromNumberKey[interval]}`}
+ {customSelected ? customIntervalText : `${1} ${TIME_SCALE_FROM_NUMBER[interval]}`}
</span>
{/* hover timeScale unit dialog / entry point to Custom selector */}
diff --git a/web/js/components/timeline/timeline-coverage/coverage-item-list.js b/web/js/components/timeline/timeline-coverage/coverage-item-list.js
index b56c64f1d..204adcca0 100644
--- a/web/js/components/timeline/timeline-coverage/coverage-item-list.js
+++ b/web/js/components/timeline/timeline-coverage/coverage-item-list.js
@@ -5,7 +5,7 @@ import { FontAwesomeIcon } from '@fortawesome/react-fontawesome';
import { datesInDateRanges } from '../../../modules/layers/util';
import util from '../../../util/util';
import {
- timeScaleToNumberKey,
+ TIME_SCALE_TO_NUMBER,
} from '../../../modules/date/constants';
import CoverageItemContainer from './coverage-item-container';
@@ -380,8 +380,8 @@ class CoverageItemList extends Component {
let layerPeriod = this.getFormattedTimePeriod(period);
// get layer scale number to determine relation to current axis zoom level
- const timeScaleNumber = timeScaleToNumberKey[timeScale];
- const layerScaleNumber = timeScaleToNumberKey[layerPeriod];
+ const timeScaleNumber = TIME_SCALE_TO_NUMBER[timeScale];
+ const layerScaleNumber = TIME_SCALE_TO_NUMBER[layerPeriod];
const isLayerGreaterIncrementThanZoom = layerScaleNumber < timeScaleNumber;
const isLayerEqualIncrementThanZoom = layerScaleNumber === timeScaleNumber;
diff --git a/web/js/containers/animation-widget.js b/web/js/containers/animation-widget.js
index 534a72159..f1de33bce 100644
--- a/web/js/containers/animation-widget.js
+++ b/web/js/containers/animation-widget.js
@@ -29,8 +29,8 @@ import {
toggleCustomModal,
} from '../modules/date/actions';
import {
- timeScaleFromNumberKey,
- timeScaleToNumberKey,
+ TIME_SCALE_FROM_NUMBER,
+ TIME_SCALE_TO_NUMBER,
customModalType,
} from '../modules/date/constants';
import {
@@ -39,7 +39,7 @@ import {
snapToIntervalDelta,
} from '../modules/animation/util';
import {
- hasSubDaily as hasSubDailySelector,
+ subdailyLayersActive,
getActiveLayers,
getAllActiveLayers,
dateRange as getDateRange,
@@ -274,7 +274,7 @@ class AnimationWidget extends React.Component {
timeScale = customInterval;
delta = customDelta;
} else {
- timeScale = Number(timeScaleToNumberKey[timeScale]);
+ timeScale = Number(TIME_SCALE_TO_NUMBER[timeScale]);
delta = 1;
}
onIntervalSelect(delta, timeScale, customSelected);
@@ -651,7 +651,7 @@ function mapStateToProps(state) {
customInterval,
} = date;
const activeLayers = getActiveLayers(state);
- const hasSubdailyLayers = hasSubDailySelector(activeLayers);
+ const hasSubdailyLayers = subdailyLayersActive(state);
const activeLayersForProj = getAllActiveLayers(state);
const hasFutureLayers = activeLayersForProj.filter((layer) => layer.futureTime).length > 0;
const layerDateRange = getDateRange({}, activeLayersForProj);
@@ -687,7 +687,7 @@ function mapStateToProps(state) {
const numberOfFrames = util.getNumberOfDays(
startDate,
endDate,
- timeScaleFromNumberKey[useInterval],
+ TIME_SCALE_FROM_NUMBER[useInterval],
customSelected && customDelta ? customDelta : delta,
maxFrames,
);
@@ -710,7 +710,7 @@ function mapStateToProps(state) {
hasSubdailyLayers,
subDailyMode,
delta: customSelected && customDelta ? customDelta : delta,
- interval: timeScaleFromNumberKey[useInterval] || 'day',
+ interval: TIME_SCALE_FROM_NUMBER[useInterval] || 'day',
customDelta: customDelta || 1,
customInterval: customInterval || 3,
numberOfFrames,
diff --git a/web/js/containers/gif.js b/web/js/containers/gif.js
index 8a0c54550..3b04f946c 100644
--- a/web/js/containers/gif.js
+++ b/web/js/containers/gif.js
@@ -20,11 +20,12 @@ import {
imageUtilCalculateResolution,
imageUtilGetCoordsFromPixelValues,
} from '../modules/image-download/util';
-import { timeScaleFromNumberKey } from '../modules/date/constants';
+import { TIME_SCALE_FROM_NUMBER } from '../modules/date/constants';
import GifResults from '../components/animation-widget/gif-post-creation';
import getImageArray from '../modules/animation/selectors';
import { getStampProps, svgToPng } from '../modules/animation/util';
import { changeCropBounds } from '../modules/animation/actions';
+import { subdailyLayersActive } from '../modules/layers/selectors';
const DEFAULT_URL = 'http://localhost:3002/api/v1/snapshot';
const gifStream = new GifStream();
@@ -385,8 +386,8 @@ function mapStateToProps(state) {
customSelected, interval, customInterval, customDelta,
} = date;
const increment = customSelected
- ? `${customDelta} ${timeScaleFromNumberKey[customInterval]}`
- : `1 ${timeScaleFromNumberKey[interval]}`;
+ ? `${customDelta} ${TIME_SCALE_FROM_NUMBER[customInterval]}`
+ : `1 ${TIME_SCALE_FROM_NUMBER[interval]}`;
let url = DEFAULT_URL;
if (config.features.imageDownload && config.features.imageDownload.url) {
url = config.features.imageDownload.url;
@@ -402,8 +403,8 @@ function mapStateToProps(state) {
boundaries,
proj: proj.selected,
isActive: animation.gifActive,
- startDate: util.toISOStringMinutes(startDate),
- endDate: util.toISOStringMinutes(endDate),
+ startDate: util.toISOStringDateMonthAbbrev(startDate, subdailyLayersActive(state)),
+ endDate: util.toISOStringDateMonthAbbrev(endDate, subdailyLayersActive(state)),
increment: `${increment} Between Frames`,
speed,
map,
@@ -412,8 +413,8 @@ function mapStateToProps(state) {
startDate,
endDate,
customSelected
- ? timeScaleFromNumberKey[customInterval]
- : timeScaleFromNumberKey[interval],
+ ? TIME_SCALE_FROM_NUMBER[customInterval]
+ : TIME_SCALE_FROM_NUMBER[interval],
customSelected ? customDelta : 1,
),
getImageArray: (gifComponentProps, gifComponentState, dimensions) => getImageArray(
diff --git a/web/js/containers/image-download.js b/web/js/containers/image-download.js
index 9681428ab..e81d247c6 100644
--- a/web/js/containers/image-download.js
+++ b/web/js/containers/image-download.js
@@ -14,9 +14,8 @@ import {
} from '../modules/image-download/util';
import util from '../util/util';
import {
- hasSubDaily as hasSubDailySelector,
getLayers,
- getActiveLayers,
+ subdailyLayersActive,
} from '../modules/layers/selectors';
import { getSelectedDate } from '../modules/date/selectors';
import {
@@ -168,8 +167,7 @@ function mapStateToProps(state) {
} = imageDownload;
const { screenWidth, screenHeight } = browser;
const markerCoordinates = locationSearch.coordinates;
- const activeLayers = getActiveLayers(state);
- const hasSubdailyLayers = hasSubDailySelector(activeLayers);
+ const hasSubdailyLayers = subdailyLayersActive(state);
let url = DEFAULT_URL;
if (config.features.imageDownload && config.features.imageDownload.url) {
url = config.features.imageDownload.url;
diff --git a/web/js/containers/sidebar/events.js b/web/js/containers/sidebar/events.js
index 632f77b2e..12d00717d 100644
--- a/web/js/containers/sidebar/events.js
+++ b/web/js/containers/sidebar/events.js
@@ -1,3 +1,4 @@
+
import React from 'react';
import PropTypes from 'prop-types';
import { connect } from 'react-redux';
diff --git a/web/js/containers/timeline/timeline.js b/web/js/containers/timeline/timeline.js
index aeae5ae72..8bfc9c35b 100644
--- a/web/js/containers/timeline/timeline.js
+++ b/web/js/containers/timeline/timeline.js
@@ -34,7 +34,7 @@ import {
} from '../../components/timeline/date-util';
import {
dateRange as getDateRange,
- hasSubDaily,
+ subdailyLayersActive,
getActiveLayers,
} from '../../modules/layers/selectors';
import { getSelectedDate, getDeltaIntervalUnit } from '../../modules/date/selectors';
@@ -61,8 +61,8 @@ import {
changeEndDate,
} from '../../modules/animation/actions';
import {
- timeScaleFromNumberKey,
- timeScaleToNumberKey,
+ TIME_SCALE_FROM_NUMBER,
+ TIME_SCALE_TO_NUMBER,
timeScaleOptions,
customModalType,
} from '../../modules/date/constants';
@@ -492,7 +492,7 @@ class Timeline extends React.Component {
const { hasSubdailyLayers, timeScale } = this.props;
// prevent left/right arrows changing date within inputs
if (e.target.tagName !== 'INPUT' && e.target.className !== 'rc-slider-handle' && !e.ctrlKey && !e.metaKey && !isTimelineDragging) {
- const timeScaleNumber = Number(timeScaleToNumberKey[timeScale]);
+ const timeScaleNumber = Number(TIME_SCALE_TO_NUMBER[timeScale]);
const maxTimeScaleNumber = hasSubdailyLayers ? 5 : 3;
if (e.keyCode === 38) {
e.preventDefault();
@@ -544,7 +544,7 @@ class Timeline extends React.Component {
timeScale,
hasSubdailyLayers,
} = this.props;
- const timeScaleNumber = Number(timeScaleToNumberKey[timeScale]);
+ const timeScaleNumber = Number(TIME_SCALE_TO_NUMBER[timeScale]);
const maxTimeScaleNumber = hasSubdailyLayers ? 5 : 3;
// handle time scale change on y axis wheel event
@@ -1303,9 +1303,10 @@ function mapStateToProps(state) {
const activeLayers = getActiveLayers(state);
const projection = proj.id;
const activeLayersFiltered = filterProjLayersWithStartDate(activeLayers, projection);
- const hasSubdailyLayers = isCompareModeActive
- ? hasSubDaily(layers.active.layers) || hasSubDaily(layers.activeB.layers)
- : hasSubDaily(activeLayers);
+ // const hasSubdailyLayers = isCompareModeActive
+ // ? hasSubDaily(layers.active.layers) || hasSubDaily(layers.activeB.layers)
+ // : hasSubDaily(activeLayers);
+ const hasSubdailyLayers = subdailyLayersActive(state);
// if future layers are included, timeline axis end date will extend past appNow
const hasFutureLayers = checkHasFutureLayers(state);
@@ -1378,7 +1379,7 @@ function mapStateToProps(state) {
animEndLocationDate: animation.endDate,
axisWidth: dimensionsAndOffsetValues.width,
selectedDate,
- timeScale: timeScaleFromNumberKey[updatedSelectedZoom.toString()],
+ timeScale: TIME_SCALE_FROM_NUMBER[updatedSelectedZoom.toString()],
timeScaleChangeUnit: unit,
customIntervalValue: customDelta || 1,
customIntervalZoomLevel: updatedCustomInterval || 3,
diff --git a/web/js/location.js b/web/js/location.js
index c4c90c294..88c07cc73 100644
--- a/web/js/location.js
+++ b/web/js/location.js
@@ -33,7 +33,7 @@ import {
serializeGroupOverlays,
mapLocationToLayerState,
} from './modules/layers/util';
-import { resetLayers, hasSubDaily, getActiveLayers } from './modules/layers/selectors';
+import { resetLayers, subdailyLayersActive } from './modules/layers/selectors';
import { getInitialEventsState } from './modules/natural-events/reducers';
import { mapLocationToPaletteState } from './modules/palettes/util';
import { mapLocationToEmbedState } from './modules/embed/util';
@@ -177,8 +177,7 @@ const getParameters = function(config, parameters) {
let zoom = currentItemState;
// check if subdaily timescale zoom to determine if reset is needed
if (zoom > 3) {
- const hasSubdailyLayers = hasSubDaily(getActiveLayers(state));
- if (!hasSubdailyLayers) {
+ if (!subdailyLayersActive(state)) {
zoom = 3; // reset to day
}
}
@@ -196,8 +195,7 @@ const getParameters = function(config, parameters) {
let interval = currentItemState;
// check if subdaily timescale zoom to determine if reset is needed
if (interval > 3) {
- const hasSubdailyLayers = hasSubDaily(getActiveLayers(state));
- if (!hasSubdailyLayers) {
+ if (!subdailyLayersActive(state)) {
interval = 3; // reset to day
}
}
@@ -233,8 +231,7 @@ const getParameters = function(config, parameters) {
let customInterval = currentItemState;
// check if subdaily customInterval to determine if reset is needed
if (customInterval > 3) {
- const hasSubdailyLayers = hasSubDaily(getActiveLayers(state));
- if (!hasSubdailyLayers) {
+ if (!subdailyLayersActive(state)) {
customInterval = 3; // reset to day
}
}
diff --git a/web/js/modules/animation/actions.js b/web/js/modules/animation/actions.js
index e6fbee57a..dc693d611 100644
--- a/web/js/modules/animation/actions.js
+++ b/web/js/modules/animation/actions.js
@@ -12,7 +12,7 @@ import {
TOGGLE_GIF,
} from './constants';
import util from '../../util/util';
-import { timeScaleFromNumberKey } from '../date/constants';
+import { TIME_SCALE_FROM_NUMBER } from '../date/constants';
import { getSelectedDate } from '../date/selectors';
export function onActivate() {
@@ -24,8 +24,8 @@ export function onActivate() {
const activeDate = getSelectedDate(getState());
if (!animation.startDate || !animation.endDate) {
const timeScaleChangeUnit = customSelected
- ? timeScaleFromNumberKey[customInterval]
- : timeScaleFromNumberKey[interval];
+ ? TIME_SCALE_FROM_NUMBER[customInterval]
+ : TIME_SCALE_FROM_NUMBER[interval];
const deltaChangeAmt = customSelected ? customDelta : delta;
const tenFrameDelta = 10 * deltaChangeAmt;
const tenFramesBefore = util.dateAdd(activeDate, timeScaleChangeUnit, -tenFrameDelta);
diff --git a/web/js/modules/animation/selectors.js b/web/js/modules/animation/selectors.js
index abcbd8d1c..9fc468c44 100644
--- a/web/js/modules/animation/selectors.js
+++ b/web/js/modules/animation/selectors.js
@@ -4,8 +4,8 @@ import {
imageUtilGetCoordsFromPixelValues,
getDownloadUrl,
} from '../image-download/util';
-import { getActiveLayers, getLayers, hasSubDaily } from '../layers/selectors';
-import { timeScaleFromNumberKey } from '../date/constants';
+import { subdailyLayersActive, getLayers } from '../layers/selectors';
+import { TIME_SCALE_FROM_NUMBER } from '../date/constants';
/*
* loops through dates and created image
* download urls and pushs them to an
@@ -35,7 +35,7 @@ export default function getImageArray(
const fromDate = new Date(startDate);
const toDate = new Date(endDate);
const markerCoordinates = locationSearch.coordinates;
- const isSubDaily = hasSubDaily(getActiveLayers(state));
+ const isSubDaily = subdailyLayersActive(state);
let current = fromDate;
let j = 0;
let src;
@@ -43,8 +43,8 @@ export default function getImageArray(
let products;
const useDelta = customSelected && customDelta ? customDelta : delta;
const increment = customSelected
- ? timeScaleFromNumberKey[customInterval]
- : timeScaleFromNumberKey[interval];
+ ? TIME_SCALE_FROM_NUMBER[customInterval]
+ : TIME_SCALE_FROM_NUMBER[interval];
while (current <= toDate) {
j += 1;
diff --git a/web/js/modules/date/constants.js b/web/js/modules/date/constants.js
index af5a27350..274e64746 100644
--- a/web/js/modules/date/constants.js
+++ b/web/js/modules/date/constants.js
@@ -10,21 +10,21 @@ export const ARROW_UP = 'DATE/ARROW_UP';
export const SET_PRELOAD = 'DATE/SET_PRELOAD';
export const CLEAR_PRELOAD = 'DATE/CLEAR_PRELOAD';
-export const monthMap = {
- 1: 'Jan',
- 2: 'Feb',
- 3: 'Mar',
- 4: 'Apr',
- 5: 'May',
- 6: 'Jun',
- 7: 'Jul',
- 8: 'Aug',
- 9: 'Sep',
- 10: 'Oct',
- 11: 'Nov',
- 12: 'Dec',
-};
-export const timeScaleFromNumberKey = {
+export const MONTH_STRING_ARRAY = [
+ 'JAN',
+ 'FEB',
+ 'MAR',
+ 'APR',
+ 'MAY',
+ 'JUN',
+ 'JUL',
+ 'AUG',
+ 'SEP',
+ 'OCT',
+ 'NOV',
+ 'DEC',
+];
+export const TIME_SCALE_FROM_NUMBER = {
0: 'custom',
1: 'year',
2: 'month',
@@ -32,7 +32,7 @@ export const timeScaleFromNumberKey = {
4: 'hour',
5: 'minute',
};
-export const timeScaleToNumberKey = {
+export const TIME_SCALE_TO_NUMBER = {
custom: 0,
year: 1,
month: 2,
diff --git a/web/js/modules/date/selectors.js b/web/js/modules/date/selectors.js
index 562417a16..e59b581c5 100644
--- a/web/js/modules/date/selectors.js
+++ b/web/js/modules/date/selectors.js
@@ -1,4 +1,4 @@
-import { timeScaleFromNumberKey } from './constants';
+import { TIME_SCALE_FROM_NUMBER } from './constants';
export function getDates (state) {
const { date } = state;
@@ -20,7 +20,7 @@ export function getDeltaIntervalUnit (state) {
} = state.date;
const useDelta = customSelected ? customDelta : delta;
const useInterval = customSelected ? customInterval : interval;
- const changeUnit = timeScaleFromNumberKey[useInterval];
+ const changeUnit = TIME_SCALE_FROM_NUMBER[useInterval];
return {
delta: useDelta,
diff --git a/web/js/modules/layers/selectors.js b/web/js/modules/layers/selectors.js
index 02e13b1cf..09436d56e 100644
--- a/web/js/modules/layers/selectors.js
+++ b/web/js/modules/layers/selectors.js
@@ -214,6 +214,11 @@ export function hasSubDaily(layers) {
return false;
}
+export const subdailyLayersActive = () => createSelector(
+ [getActiveLayers],
+ (layers) => hasSubDaily(layers),
+);
+
export function addLayer(id, spec = {}, layersParam, layerConfig, overlayLength, projection, groupOverlays) {
let layers = lodashCloneDeep(layersParam);
if (projection) {
diff --git a/web/js/util/util.js b/web/js/util/util.js
index de1c17c7f..0f50f1a87 100644
--- a/web/js/util/util.js
+++ b/web/js/util/util.js
@@ -7,6 +7,7 @@ import browser from './browser';
import events from './events';
import load from './load';
import safeLocalStorage from './local-storage';
+import { MONTH_STRING_ARRAY } from '../modules/date/constants';
const { COORDINATE_FORMAT } = safeLocalStorage.keys;
@@ -34,6 +35,7 @@ export default (function(self) {
}
return value;
};
+
/**
* Creates an object representation of a query string.
*
@@ -232,7 +234,7 @@ export default (function(self) {
const parsedDate = this.parseDate(date);
switch (period) {
case 'subdaily':
- dateString = `${moment(parsedDate).format('DD MMMM YYYY HH:mm')}Z`;
+ dateString = `${moment(parsedDate).format('YYYY MMMM DD HH:mm')}Z`;
break;
case 'yearly':
@@ -242,11 +244,11 @@ export default (function(self) {
case 'monthly':
if (dateType === 'END-DATE') parsedDate.setMonth(parsedDate.getMonth() - 1);
- dateString = moment(parsedDate).format('MMMM YYYY');
+ dateString = moment(parsedDate).format('YYYY MMM');
break;
default:
- dateString = moment(parsedDate).format('DD MMMM YYYY');
+ dateString = moment(parsedDate).format('YYYY MMM DD ');
break;
}
@@ -279,25 +281,9 @@ export default (function(self) {
* @return {string} ISO string in the form of ``YYYY-MM-DD``.
*/
self.toISOStringDate = function(date) {
- return date.toISOString()
- .split('T')[0];
+ return date.toISOString().split('T')[0];
};
- self.monthStringArray = [
- 'JAN',
- 'FEB',
- 'MAR',
- 'APR',
- 'MAY',
- 'JUN',
- 'JUL',
- 'AUG',
- 'SEP',
- 'OCT',
- 'NOV',
- 'DEC',
- ];
-
/**
* Converts a date into an ISO string with only the date portion and month abbreviation.
*
@@ -313,7 +299,7 @@ export default (function(self) {
const month = stringDate[1];
const day = stringDate[2];
- const monthAbbrev = self.monthStringArray[Number(month) - 1];
+ const monthAbbrev = MONTH_STRING_ARRAY[Number(month) - 1];
if (hasSubdaily) {
return `${year} ${monthAbbrev} ${day} ${self.toHourMinutes(date)}Z`;