Skip to content

Interactive interface for browsing global, full-resolution satellite imagery

WV-3899 & WV-3900 & WV-3901 & WV-3902 & WV-3903: Variable Time Periods Fixes (#6390)

christof-wittreich5969674a6699
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 a9683c9b3..5f0aec605 100644
--- a/web/js/components/timeline/timeline-controls/timescale-interval-change.js
+++ b/web/js/components/timeline/timeline-controls/timescale-interval-change.js
@@ -128,7 +128,7 @@ class TimeScaleIntervalChange extends PureComponent {
renderTooltip = () => {
const { toolTipHovered, customIntervalText } = this.state;
- const { hasSubdailyLayers } = this.props;
+ const { hasSubdailyLayers, hasTempoProduct } = this.props;
return (
<div
className="wv-tooltip"
@@ -172,15 +172,17 @@ class TimeScaleIntervalChange extends PureComponent {
>
Minute
</span>
- <span
- id="interval-auto"
- className="interval-btn interval-auto"
- onClick={() => this.handleClickInterval('auto')}
- >
- Auto
- </span>
</>
) : null}
+ {hasTempoProduct ? (
+ <span
+ id="interval-auto"
+ className="interval-btn interval-auto"
+ onClick={() => this.handleClickInterval('auto')}
+ >
+ Auto
+ </span>
+ ) : null}
<span
id="interval-custom"
className="interval-btn interval-custom custom-interval-text"
@@ -265,6 +267,7 @@ TimeScaleIntervalChange.propTypes = {
customSelected: PropTypes.bool,
autoSelected: PropTypes.bool,
hasSubdailyLayers: PropTypes.bool,
+ hasTempoProduct: PropTypes.bool,
interval: PropTypes.number,
isDisabled: PropTypes.bool,
selectInterval: PropTypes.func,
diff --git a/web/js/containers/projection.js b/web/js/containers/projection.js
index 388c52fb0..4d9589e5b 100644
--- a/web/js/containers/projection.js
+++ b/web/js/containers/projection.js
@@ -65,7 +65,7 @@ class ProjectionList extends Component {
const enableAuto = layers.filter((layer) => layer.projections && Object.keys(layer.projections).includes(id) && layer.visible && layer.id.includes('TEMPO')).length > 0;
// Defaults to 1 day if new projection has no TEMPO layers present
const timescale = enableAuto ? TIME_SCALE_TO_NUMBER.minute : TIME_SCALE_TO_NUMBER.day;
- changeAutoInterval(1, timescale, enableAuto);
+ changeAutoInterval(enableAuto);
selectInterval(1, timescale, false, enableAuto);
changeTimeScale(enableAuto ? TIME_SCALE_TO_NUMBER.hour : timescale);
}
@@ -118,8 +118,8 @@ const mapDispatchToProps = (dispatch) => ({
changeTimeScale: (val) => {
dispatch(changeTimeScale(val));
},
- changeAutoInterval: (delta, timeScale, autoSelected) => {
- dispatch(changeAutoIntervalAction(delta, timeScale, autoSelected));
+ changeAutoInterval: (autoSelected) => {
+ dispatch(changeAutoIntervalAction(autoSelected));
},
});
diff --git a/web/js/containers/timeline/timeline.js b/web/js/containers/timeline/timeline.js
index b24f33e0b..5f7baf1ec 100644
--- a/web/js/containers/timeline/timeline.js
+++ b/web/js/containers/timeline/timeline.js
@@ -329,22 +329,25 @@ class Timeline extends React.Component {
}
const subdailyRemoved = !hasSubdailyLayers && prevProps.hasSubdailyLayers;
+ const tempoRemoved = !hasTempoProduct && prevProps.hasTempoProduct;
const subDailyCountChanged = subDailyLayersList.length !== prevProps.subDailyLayersList.length;
const subdailyInterval = customInterval > 3 || interval > 3;
+ if (tempoRemoved) {
+ changeAutoInterval();
+ selectInterval(1, TIME_SCALE_TO_NUMBER.day, false, false);
+ }
if (subdailyRemoved && subdailyInterval) {
changeCustomInterval();
- selectInterval(1, TIME_SCALE_TO_NUMBER.day, false);
+ selectInterval(1, TIME_SCALE_TO_NUMBER.day, false, false);
}
const isSubDaily = newCustomDelta < 1440; // 1440 == 1 day in minutes
if (subDailyCountChanged) {
if (hasTempoProduct) {
- changeAutoInterval(1, TIME_SCALE_TO_NUMBER.minute, true);
+ changeAutoInterval(true);
} else if (isSubDaily) {
changeCustomInterval(newCustomDelta, TIME_SCALE_TO_NUMBER.minute);
- } else {
- changeCustomInterval(1, TIME_SCALE_TO_NUMBER.day);
}
}
@@ -616,8 +619,10 @@ class Timeline extends React.Component {
} = this.props;
let delta = customSelected && deltaChangeAmt ? deltaChangeAmt : 1;
+ let timescale = timeScaleChangeUnit;
if (autoSelected && subDailyLayersList && subDailyLayersList.length) {
delta = getNextImageryDelta(subDailyLayersList, dateA, signConstant);
+ timescale = 'minute';
}
if (!timeScaleChangeUnit) { // undefined custom will not allow arrow change
return;
@@ -629,7 +634,7 @@ class Timeline extends React.Component {
const maxDate = new Date(timelineEndDateLimit);
this.onDateChange(getNextTimeSelection(
delta,
- timeScaleChangeUnit,
+ timescale,
selectedDate,
minDate,
maxDate,
@@ -1180,6 +1185,7 @@ class Timeline extends React.Component {
draggerSelected,
hasFutureLayers,
hasSubdailyLayers,
+ hasTempoProduct,
hideTimeline,
isAnimationPlaying,
isAnimatingToEvent,
@@ -1288,6 +1294,7 @@ class Timeline extends React.Component {
<TimeScaleIntervalChange
timeScaleChangeUnit={timeScaleChangeUnit}
hasSubdailyLayers={hasSubdailyLayers}
+ hasTempoProduct={hasTempoProduct}
modalType={customModalType.TIMELINE}
/>
@@ -1578,7 +1585,7 @@ function mapStateToProps(state) {
? [...getSubDaily(layers.active.layers), ...getSubDaily(layers.activeB.layers)]
: subdailyLayers(state);
const newCustomDelta = getSmallestIntervalValue(state);
- const hasTempoProduct = layers.active.layers.filter((layer) => layer.visible && layer.id.includes('TEMPO'));
+ const hasTempoProduct = layers.active.layers.filter((layer) => layer.visible && layer.id.includes('TEMPO')).length > 0;
// if future layers are included, timeline axis end date will extend past appNow
const hasFutureLayers = checkHasFutureLayers(state);
@@ -1716,8 +1723,8 @@ const mapDispatchToProps = (dispatch) => ({
dispatch(changeCustomIntervalAction(delta, timeScale));
},
// changes/sets auto delta and timescale interval
- changeAutoInterval: (delta, timeScale, autoSelected) => {
- dispatch(changeAutoIntervalAction(delta, timeScale, autoSelected));
+ changeAutoInterval: (autoSelected) => {
+ dispatch(changeAutoIntervalAction(autoSelected));
},
// changes timescale (scale of grids vs. what LEFT/RIGHT arrow do)
changeTimeScale: (val) => {
diff --git a/web/js/modules/date/actions.js b/web/js/modules/date/actions.js
index 154789cb4..124c1e60e 100644
--- a/web/js/modules/date/actions.js
+++ b/web/js/modules/date/actions.js
@@ -99,13 +99,11 @@ export function changeCustomInterval(delta, customInterval) {
});
};
}
-export function changeAutoInterval(delta, interval, autoSelected) {
+export function changeAutoInterval(autoSelected) {
return (dispatch, getState) => {
dispatch(clearPreload());
dispatch({
type: CHANGE_AUTO_INTERVAL,
- delta,
- interval,
autoSelected,
});
};
diff --git a/web/js/modules/date/actions.test.js b/web/js/modules/date/actions.test.js
index 33c5653f5..24ce2755b 100644
--- a/web/js/modules/date/actions.test.js
+++ b/web/js/modules/date/actions.test.js
@@ -211,11 +211,9 @@ describe('Date timescale changes', () => {
};
const expectedSecond = {
type: CHANGE_AUTO_INTERVAL,
- delta: 5,
- interval: 3,
autoSelected: true,
};
- store.dispatch(changeAutoInterval(delta, customInterval, true));
+ store.dispatch(changeAutoInterval(true));
expect(store.getActions()[0]).toEqual(expectedFirst);
expect(store.getActions()[1]).toEqual(expectedSecond);
},
diff --git a/web/js/modules/date/reducers.js b/web/js/modules/date/reducers.js
index 6802e33f0..a016061c8 100644
--- a/web/js/modules/date/reducers.js
+++ b/web/js/modules/date/reducers.js
@@ -63,11 +63,9 @@ export function dateReducer(state = dateReducerState, action) {
};
}
case CHANGE_AUTO_INTERVAL: {
- const { interval, delta, autoSelected } = action;
+ const { autoSelected } = action;
return {
...state,
- interval,
- delta,
autoSelected,
};
}
diff --git a/web/js/modules/date/util.js b/web/js/modules/date/util.js
index 0089b45b6..6135c04fc 100644
--- a/web/js/modules/date/util.js
+++ b/web/js/modules/date/util.js
@@ -559,7 +559,14 @@ export function getNextImageryDelta(layers, dateA, signConstant) {
invalidLayerCount += 1;
} else if (signConstant > 0) {
// Forward in time
- for (let j = 0; j < layers[i].dateRanges.length; j += 1) {
+ const foundIndex = layers[i].dateRanges.findIndex(
+ (element) => element.startDate > dateA,
+ );
+ const startingIndex = foundIndex - 5 < 0 ? 0 : foundIndex - 5;
+ // endingIndex gives 10 tries to find a valid next interval
+ const endingIndex = foundIndex + 5 > layers[i].dateRanges.length
+ ? layers[i].dateRanges.length : foundIndex + 5;
+ for (let j = startingIndex; j < endingIndex; j += 1) {
const obj = layers[i].dateRanges[j];
const startDateObj = new Date(obj.startDate);
const endDateObj = new Date(obj.endDate);
@@ -588,7 +595,14 @@ export function getNextImageryDelta(layers, dateA, signConstant) {
}
} else {
// Backward in time
- for (let j = 0; j < layers[i].dateRanges.length; j += 1) {
+ const foundIndex = [...layers[i].dateRanges].reverse().findIndex(
+ (element) => element.startDate < dateA,
+ );
+ const startingIndex = foundIndex - 5 < 0 ? 0 : foundIndex - 5;
+ // endingIndex gives 10 tries to find a valid next interval
+ const endingIndex = foundIndex + 5 > layers[i].dateRanges.length
+ ? layers[i].dateRanges.length : foundIndex + 5;
+ for (let j = startingIndex; j < endingIndex; j += 1) {
const obj = [...layers[i].dateRanges].reverse()[j];
const endDateObj = new Date(obj.endDate);
const startDateObj = new Date(obj.startDate);