Interactive interface for browsing global, full-resolution satellite imagery
Get image download, animation, and gif export working with sub-daily layers at a basic level. Show time in date/time stamp shown in exported gifs. Don't zero out hours/minutes during gif creation when intervals < 1 day selected. Don't show hours/minutes selection in animation widget when interval >= 1 day
Jason Kentddb98cf666f5
diff --git a/web/js/components/animation-widget/animation-widget.js b/web/js/components/animation-widget/animation-widget.jsdeleted file mode 100644index 3632c84b6..000000000--- a/web/js/components/animation-widget/animation-widget.js+++ /dev/null@@ -1,233 +0,0 @@-import React from 'react';-import PropTypes from 'prop-types';-import Slider, { Handle } from 'rc-slider';-import TimeSelector from '../date-selector/date-selector';-import LoopButton from './loop-button';-import PlayButton from './play-button';-import AnimWidgetHeader from './header';--const RangeHandle = props => {- const { value, offset, dragging, ...restProps } = props;-- const positionStyle = {- position: 'absolute',- left: `${(offset - 5).toFixed(2)}%`- };-- return (- <React.Fragment>- <span className="anim-frame-rate-label" style={positionStyle}>- {value < 10 ? value.toFixed(1) : value}- </span>- <Handle- dragging={dragging.toString()}- value={value}- offset={offset}- {...restProps}- />- </React.Fragment>- );-};-/*- * A react component, Builds a rather specific- * interactive widget- *- * @class AnimationWidget- * @extends React.Component- */-class AnimationWidget extends React.Component {- constructor(props) {- super(props);- this.state = {- value: props.sliderSpeed,- looping: props.looping,- startDate: props.startDate,- endDate: props.endDate,- hasSubdailyLayers: props.hasSubdailyLayers,- header: props.header,- incrementArray: props.incrementArray,- increment: props.increment- };- }-- /*- * Sets a new state value when a- * when the slider is adjusted- *- * @method onSlide- *- * @param {number} value - Value of the slider- * selection- *- * @return {void}- */- onSlide(value) {- this.props.onSlide(value);- this.setState({- value: value- });- }-- /*- * calls the callback, passing the- * current state elements as parameters- *- * @method play- *- * @return {void}- */- play() {- this.props.onPushPlay();- this.setState({- playing: true- });- }- pause() {- this.props.onPushPause();- this.setState({- playing: false- });- }- /*- * Sets a new state to say whether or not- * the animation should loop- *- * @method onLoop- *- * @param {Object} component - slider react- * component- * @param {number} value - Value of the slider- * selection- *- * @return {void}- */- onLoop() {- var loop = true;- if (this.state.looping) {- loop = false;- }- this.setState({- looping: loop- });- this.props.onPushLoop(loop);- }- onDateChange(date, id) {- const { endDate, startDate } = this.state;- if (id === 'start') {- this.setState({- startDate: date- });- this.props.onDateChange(date, endDate);- } else {- this.setState({- endDate: date- });- this.props.onDateChange(startDate, date);- }- }- render() {- return (- <div- id="wv-animation-widget"- className={- 'wv-animation-widget' +- (this.state.hasSubdailyLayers ? ' subdaily' : '')- }- >- <AnimWidgetHeader- text={this.state.increment}- toolTipTextArray={this.state.incrementArray}- onClick={this.props.onZoomSelect}- />-- <PlayButton- playing={this.state.playing}- play={this.play.bind(this)}- pause={this.pause.bind(this)}- />- <LoopButton- looping={this.state.looping}- onLoop={this.onLoop.bind(this)}- />- <div className="wv-slider-case">- <Slider- className="input-range"- step={0.5}- max={10}- min={0.5}- value={this.state.value}- onChange={this.onSlide.bind(this)}- handle={RangeHandle}- />- <span className="wv-slider-label">{this.props.sliderLabel}</span>- </div>-- <a- href="javascript:void(null)"- title="Create Animated GIF"- className="wv-icon-case"- onClick={this.props.onPushGIF}- >- <i- id="wv-animation-widget-file-video-icon"- className="fas fa-file-video wv-animation-widget-icon"- />- </a>- <div className="wv-anim-dates-case">- <TimeSelector- width="120"- height="30"- date={this.state.startDate}- id="start"- idSuffix="animation-widget-start"- onDateChange={this.onDateChange.bind(this)}- maxDate={this.state.endDate}- minDate={this.props.minDate}- hasSubdailyLayers={this.state.hasSubdailyLayers}- />- <div className="thru-label">To</div>- <TimeSelector- width="120"- height="30"- date={this.state.endDate}- id="end"- idSuffix="animation-widget-end"- onDateChange={this.onDateChange.bind(this)}- maxDate={this.props.maxDate}- minDate={this.state.startDate}- hasSubdailyLayers={this.state.hasSubdailyLayers}- />- </div>- <i className="fa fa-times wv-close" onClick={this.props.onClose} />- </div>- );- }-}-RangeHandle.propTypes = {- dragging: PropTypes.object,- offset: PropTypes.number,- value: PropTypes.number-};-AnimationWidget.propTypes = {- endDate: PropTypes.object,- hasSubdailyLayers: PropTypes.bool,- header: PropTypes.element,- increment: PropTypes.string,- incrementArray: PropTypes.array,- looping: PropTypes.bool,- maxDate: PropTypes.object,- minDate: PropTypes.object,- onClose: PropTypes.func,- onDateChange: PropTypes.func,- onPushGIF: PropTypes.func,- onPushLoop: PropTypes.func,- onPushPause: PropTypes.func,- onPushPlay: PropTypes.func,- onSlide: PropTypes.func,- onZoomSelect: PropTypes.func,- sliderLabel: PropTypes.string,- sliderSpeed: PropTypes.number,- startDate: PropTypes.object-};--export default AnimationWidget;diff --git a/web/js/components/date-selector/date-selector.js b/web/js/components/date-selector/date-selector.jsindex f4c7177fc..55019e3f5 100644--- a/web/js/components/date-selector/date-selector.js+++ b/web/js/components/date-selector/date-selector.js@@ -56,7 +56,7 @@ class DateSelector extends Component {shouldComponentUpdate(prevProps, prevState) {let {date,- hasSubdailyLayers,+ subDailyMode,maxDate,minDate} = this.props;@@ -64,59 +64,61 @@ class DateSelector extends Component {let updateCheck = (this.state.tab === prevState.tab &&date.getTime() === prevProps.date.getTime() &&- hasSubdailyLayers === prevProps.hasSubdailyLayers &&+ subDailyMode === prevProps.subDailyMode &&maxDate.getTime() === prevProps.maxDate.getTime() &&minDate.getTime() === prevProps.minDate.getTime());- if (updateCheck) {- return false;- }- return true;+ return !updateCheck;}renderSubdaily() {- const { date } = this.props;- if (this.props.hasSubdailyLayers) {- return (- <React.Fragment>- <DateInputColumn- step={1}- startDate={new Date(2000)}- date={date}- type="hour"- inputId={this.props.idSuffix ? 'hour-' + this.props.idSuffix : ''}- updateDate={this.updateDate}- value={util.pad(date.getUTCHours(), 2, '0')}- tabIndex={4}- focused={this.state.tab === 4}- setFocusedTab={this.setFocusedTab}- changeTab={this.changeTab}- maxDate={this.props.maxDate}- minDate={this.props.minDate}- blur={this.blur}- fontSize={this.props.fontSize}- />- <div className="input-time-divider">:</div>- <DateInputColumn- step={10}- startDate={new Date(2000)}- date={date}- type="minute"- updateDate={this.updateDate}- value={util.pad(date.getUTCMinutes(), 2, '0')}- inputId={this.props.idSuffix ? 'minute-' + this.props.idSuffix : ''}- tabIndex={5}- focused={this.state.tab === 5}- setFocusedTab={this.setFocusedTab}- changeTab={this.changeTab}- maxDate={this.props.maxDate}- minDate={this.props.minDate}- blur={this.blur}- fontSize={this.props.fontSize}- />- <div className="input-time-zmark">Z</div>- </React.Fragment>- );- }+ const {+ date,+ idSuffix,+ fontSize,+ minDate,+ maxDate,+ subDailyMode+ } = this.props;+ return subDailyMode && (+ <React.Fragment>+ <DateInputColumn+ step={1}+ startDate={new Date(2000)}+ date={date}+ type="hour"+ inputId={idSuffix ? 'hour-' + idSuffix : ''}+ updateDate={this.updateDate}+ value={util.pad(date.getUTCHours(), 2, '0')}+ tabIndex={4}+ focused={this.state.tab === 4}+ setFocusedTab={this.setFocusedTab}+ changeTab={this.changeTab}+ maxDate={maxDate}+ minDate={minDate}+ blur={this.blur}+ fontSize={fontSize}+ />+ <div className="input-time-divider">:</div>+ <DateInputColumn+ step={10}+ startDate={new Date(2000)}+ date={date}+ type="minute"+ updateDate={this.updateDate}+ value={util.pad(date.getUTCMinutes(), 2, '0')}+ inputId={idSuffix ? 'minute-' + idSuffix : ''}+ tabIndex={5}+ focused={this.state.tab === 5}+ setFocusedTab={this.setFocusedTab}+ changeTab={this.changeTab}+ maxDate={maxDate}+ minDate={minDate}+ blur={this.blur}+ fontSize={fontSize}+ />+ <div className="input-time-zmark">Z</div>+ </React.Fragment>+ );}render() {const {@@ -193,7 +195,8 @@ DateSelector.propTypes = {idSuffix: PropTypes.string,maxDate: PropTypes.object,minDate: PropTypes.object,- onDateChange: PropTypes.func+ onDateChange: PropTypes.func,+ subDailyMode: PropTypes.bool};export default DateSelector;diff --git a/web/js/components/image-download/panel.js b/web/js/components/image-download/panel.jsindex 9d97e58b0..361523bb4 100644--- a/web/js/components/image-download/panel.js+++ b/web/js/components/image-download/panel.js@@ -57,7 +57,7 @@ export default class ImageResSelection extends React.Component {let params = ['REQUEST=GetSnapshot',- `TIME=${util.toISOStringDate(time)}`,+ `TIME=${util.toISOStringSeconds(time)}`,`BBOX=${bboxWMS13(lonlats, crs)}`,`CRS=${crs}`,`LAYERS=${layers.join(',')}`,diff --git a/web/js/containers/animation-widget.js b/web/js/containers/animation-widget.jsindex e162214ed..f72a9f38f 100644--- a/web/js/containers/animation-widget.js+++ b/web/js/containers/animation-widget.js@@ -84,7 +84,7 @@ class AnimationWidget extends React.Component {isGifActive: false};this.onDateChange = this.onDateChange.bind(this);- this.onZoomSelect = this.onZoomSelect.bind(this);+ this.onIntervalSelect = this.onIntervalSelect.bind(this);this.onLoop = this.onLoop.bind(this);this.openGif = this.openGif.bind(this);}@@ -171,20 +171,20 @@ class AnimationWidget extends React.Component {* Changes selected default or custom interval in header and* changes left/right date arrow increments*- * @method onZoomSelect+ * @method onIntervalSelect** @param {string} zoom - clicked header string (ex: 'day', 'year', '12 day')* component** @return {void}*/- onZoomSelect(zoom) {- let { customDelta, customInterval, onZoomSelect } = this.props;+ onIntervalSelect(zoom) {+ let { customDelta, customInterval, onIntervalSelect } = this.props;let zoomToNumber = timeScaleToNumberKey[zoom]; // undefined if customif (zoomToNumber) {- onZoomSelect(1, zoomToNumber, false);+ onIntervalSelect(1, zoomToNumber, false);} else {- onZoomSelect(customDelta, customInterval, true);+ onIntervalSelect(customDelta, customInterval, true);}}@@ -220,11 +220,11 @@ class AnimationWidget extends React.Component {*/zeroDates = () => {let {- interval,+ subDailyMode,startDate,endDate} = this.props;- if (interval === 'minute' || interval === 'hour') {+ if (subDailyMode) {// for subdaily, zero start and end dates to UTC XX:YY:00:00startDate.setUTCSeconds(0);startDate.setUTCMilliseconds(0);@@ -243,7 +243,6 @@ class AnimationWidget extends React.Component {render() {const {- hasSubdailyLayers,increment,incrementArray,looping,@@ -265,7 +264,8 @@ class AnimationWidget extends React.Component {currentDate,toggleGif,isGifActive,- isCompareActive+ isCompareActive,+ subDailyMode} = this.props;if (!isActive) {return '';@@ -280,6 +280,7 @@ class AnimationWidget extends React.Component {interval,delta);+return (<ErrorBoundary>{isPlaying ? (@@ -307,13 +308,13 @@ class AnimationWidget extends React.Component {<divid="wv-animation-widget"className={- 'wv-animation-widget' + (hasSubdailyLayers ? ' subdaily' : '')+ 'wv-animation-widget' + (subDailyMode ? ' subdaily' : '')}><AnimWidgetHeadertext={increment}toolTipTextArray={incrementArray}- onClick={this.onZoomSelect}+ onClick={this.onIntervalSelect}/><PlayButton@@ -360,28 +361,28 @@ class AnimationWidget extends React.Component {</a><div className="wv-anim-dates-case"><TimeSelector+ id="start"+ idSuffix="animation-widget-start"width="120"height="30"date={startDate}- id="start"- idSuffix="animation-widget-start"onDateChange={this.onDateChange}maxDate={endDate}minDate={minDate}- hasSubdailyLayers={hasSubdailyLayers}+ subDailyMode={subDailyMode}/><div className="thru-label">To</div><TimeSelector+ id="end"+ idSuffix="animation-widget-end"width="120"height="30"date={endDate}- id="end"- idSuffix="animation-widget-end"onDateChange={this.onDateChange}maxDate={maxDate}minDate={startDate}- hasSubdailyLayers={hasSubdailyLayers}+ subDailyMode={subDailyMode}/></div><i className="fa fa-times wv-close" onClick={this.props.onClose} />@@ -435,15 +436,18 @@ function mapStateToProps(state) {activeLayersForProj,palettes[activeStr]);- let minDate = new Date(config.startDate);- let maxDate = appNow;+ const useInterval = customSelected ? customInterval : interval;+ const subDailyInterval = useInterval > 3;+ const subDailyMode = subDailyInterval && hasSubdailyLayers;+ const minDate = new Date(config.startDate);+ const maxDate = appNow;return {startDate,endDate,currentDate: date[activeDateStr],- minDate: minDate,- maxDate: maxDate,+ minDate,+ maxDate,isActive:isActive &&browser.greaterThan.small &&@@ -451,7 +455,7 @@ function mapStateToProps(state) {sidebar.activeTab !== 'download' && // No Animation when data download is active!compare.active &&!(modal.isOpen && modal.id === 'TOOLBAR_SNAPSHOT'), // No Animation when Image download is open- hasSubdailyLayers,+ subDailyMode,incrementArray: zoomObj.array,increment: zoomObj.increment,customDelta: zoomObj.customDelta,@@ -462,9 +466,7 @@ function mapStateToProps(state) {isPlaying,looping: loop,delta: customSelected && customDelta ? customDelta : delta || 1,- interval: customSelected- ? timeScaleFromNumberKey[customInterval] || 'day'- : timeScaleFromNumberKey[interval] || 'day',+ interval: timeScaleFromNumberKey[useInterval] || 'day',hasCustomPalettes,map,promiseImageryForTime: (date, layers) => {@@ -527,7 +529,7 @@ const mapDispatchToProps = dispatch => ({onSlide: num => {dispatch(changeFrameRate(num));},- onZoomSelect: (delta, zoom, customSelected) => {+ onIntervalSelect: (delta, zoom, customSelected) => {dispatch(selectInterval(delta, zoom, customSelected));},onUpdateStartDate(date) {@@ -558,7 +560,6 @@ AnimationWidget.propTypes = {endDate: PropTypes.object,hasCustomPalettes: PropTypes.bool,hasGraticule: PropTypes.bool,- hasSubdailyLayers: PropTypes.bool,increment: PropTypes.string,incrementArray: PropTypes.array,interval: PropTypes.string,@@ -575,6 +576,7 @@ AnimationWidget.propTypes = {notify: PropTypes.func,onClose: PropTypes.func,onDateChange: PropTypes.func,+ onIntervalSelect: PropTypes.func,onPushLoop: PropTypes.func,onPushPause: PropTypes.func,onPushPlay: PropTypes.func,@@ -582,12 +584,12 @@ AnimationWidget.propTypes = {onUpdateEndDate: PropTypes.func,onUpdateStartAndEndDate: PropTypes.func,onUpdateStartDate: PropTypes.func,- onZoomSelect: PropTypes.func,promiseImageryForTime: PropTypes.func,selectDate: PropTypes.func,sliderLabel: PropTypes.string,speed: PropTypes.number,startDate: PropTypes.object,+ subDailyMode: PropTypes.bool,toggleGif: PropTypes.func};diff --git a/web/js/containers/gif.js b/web/js/containers/gif.jsindex 89f3c4506..270f90175 100644--- a/web/js/containers/gif.js+++ b/web/js/containers/gif.js@@ -160,12 +160,12 @@ class GIF extends Component {h: boundaries.x2 - boundaries.x};var stampWidth;- var build;var stampProps;var newImage;var breakPointOne = 300;var stampWidthRatio = 4.889;- build = (stamp, dateStamp, stampHeight) => {++ const build = (stamp, dateStamp, stampHeight) => {let imageArray = getImageArray(this.state, this.props, { width, height });if (!imageArray) return; // won't be true if there are too many frames@@ -374,8 +374,8 @@ function mapStateToProps(state, ownProps) {boundaries,proj: proj.selected,isActive: animation.gifActive,- startDate: startDate.toISOString(),- endDate: endDate.toISOString(),+ startDate: util.toISOStringMinutes(startDate),+ endDate: util.toISOStringMinutes(endDate),increment: `${increment} Between Frames`,speed,map,diff --git a/web/js/containers/timeline/timeline.js b/web/js/containers/timeline/timeline.jsindex c1c73c49c..910bd5665 100644--- a/web/js/containers/timeline/timeline.js+++ b/web/js/containers/timeline/timeline.js@@ -858,7 +858,7 @@ class Timeline extends React.Component {onDateChange={this.onDateChange}maxDate={new Date(timelineEndDateLimit)}minDate={new Date(timelineStartDateLimit)}- hasSubdailyLayers={hasSubdailyLayers}+ subDailyMode={hasSubdailyLayers}fontSize={24}/></div>diff --git a/web/js/modules/animation/selectors.js b/web/js/modules/animation/selectors.jsindex 7a7522805..29b7c761d 100644--- a/web/js/modules/animation/selectors.js+++ b/web/js/modules/animation/selectors.js@@ -45,15 +45,17 @@ export function getImageArray(let crs = proj.selected.crs;let imgFormat = 'image/jpeg';let products = getProducts(layers[activeString], fromDate, state);- let intervalAmount = customSelected ? customDelta : delta;+ const useDelta = customSelected && customDelta ? customDelta : delta;+ const useInterval = customSelected ? customInterval : interval;let increment = customSelected? timeScaleFromNumberKey[customInterval]: timeScaleFromNumberKey[interval];const height = dimensions.height;const width = dimensions.width;+while (current <= toDate) {j++;- if (state.date.maxZoom > 3) {+ if (useInterval > 3) {strDate = util.toISOStringSeconds(current);} else {strDate = util.toISOStringDate(current);@@ -66,7 +68,7 @@ export function getImageArray(let params = ['REQUEST=GetSnapshot',- `TIME=${util.toISOStringDate(current)}`,+ `TIME=${util.toISOStringSeconds(current)}`,`BBOX=${bboxWMS13(lonlats, crs)}`,`CRS=${crs}`,`LAYERS=${layersArray.join(',')}`,@@ -87,7 +89,7 @@ export function getImageArray(text: showDates ? strDate : '',delay: 1000 / animation.speed});- current = util.dateAdd(current, increment, intervalAmount);+ current = util.dateAdd(current, increment, useDelta);if (j > 40) {// too many framesreturn false;diff --git a/web/js/util/util.js b/web/js/util/util.jsindex d7bf4d1b4..94acab46a 100644--- a/web/js/util/util.js+++ b/web/js/util/util.js@@ -355,6 +355,19 @@ export default (function (self) {return date.toISOString().split('.')[0] + 'Z';};+ /**+ * Converts a time into an ISO string without seconds.+ *+ * @method toISOStringMinutes+ * @static+ * @param {Date} date the date to convert+ * @return {string} ISO string in the form of `YYYY-MM-DDThh:mmZ`.+ */+ self.toISOStringMinutes = function (date) {+ const parts = date.toISOString().split(':');+ return parts[0] + ':' + parts[1] + 'Z';+ };+/*** Converts a time into a HH:MM string*