Interactive interface for browsing global, full-resolution satellite imagery
Variable Time Periods (#6386)
christof-wittreichb1fd67fed38a
diff --git a/config/default/common/config/wv.json/layers/tempo/TEMPO_L3_Cloud_Cloud_Fraction_Total.json b/config/default/common/config/wv.json/layers/tempo/TEMPO_L3_Cloud_Cloud_Fraction_Total.jsonindex 62c478b85..07eb7eb7d 100644--- a/config/default/common/config/wv.json/layers/tempo/TEMPO_L3_Cloud_Cloud_Fraction_Total.json+++ b/config/default/common/config/wv.json/layers/tempo/TEMPO_L3_Cloud_Cloud_Fraction_Total.json@@ -10,7 +10,8 @@"layergroup": "Cloud Fraction","dataAvailability": "dd","startDate": "2023-08-02T15:00:00Z",- "shiftadjacentdays": false+ "shiftadjacentdays": false,+ "hasVariablePeriod": "30M"}}}\ No newline at end of filediff --git a/config/default/common/config/wv.json/layers/tempo/TEMPO_L3_Cloud_Cloud_Pressure_Total.json b/config/default/common/config/wv.json/layers/tempo/TEMPO_L3_Cloud_Cloud_Pressure_Total.jsonindex 7091c8723..1b1c20fe0 100644--- a/config/default/common/config/wv.json/layers/tempo/TEMPO_L3_Cloud_Cloud_Pressure_Total.json+++ b/config/default/common/config/wv.json/layers/tempo/TEMPO_L3_Cloud_Cloud_Pressure_Total.json@@ -10,7 +10,8 @@"layergroup": "Cloud Pressure","dataAvailability": "dd","startDate": "2023-08-02T15:00:00Z",- "shiftadjacentdays": false+ "shiftadjacentdays": false,+ "hasVariablePeriod": "30M"}}}\ No newline at end of filediff --git a/config/default/common/config/wv.json/layers/tempo/TEMPO_L3_Formaldehyde_Vertical_Column.json b/config/default/common/config/wv.json/layers/tempo/TEMPO_L3_Formaldehyde_Vertical_Column.jsonindex cda0b45b9..8fb76516c 100644--- a/config/default/common/config/wv.json/layers/tempo/TEMPO_L3_Formaldehyde_Vertical_Column.json+++ b/config/default/common/config/wv.json/layers/tempo/TEMPO_L3_Formaldehyde_Vertical_Column.json@@ -10,7 +10,8 @@"layergroup": "Formaldehyde","dataAvailability": "dd","startDate": "2023-08-02T15:00:00Z",- "shiftadjacentdays": false+ "shiftadjacentdays": false,+ "hasVariablePeriod": "30M"}}}\ No newline at end of filediff --git a/config/default/common/config/wv.json/layers/tempo/TEMPO_L3_NO2_Vertical_Column_Stratosphere.json b/config/default/common/config/wv.json/layers/tempo/TEMPO_L3_NO2_Vertical_Column_Stratosphere.jsonindex 14d3ac950..d7fe5685d 100644--- a/config/default/common/config/wv.json/layers/tempo/TEMPO_L3_NO2_Vertical_Column_Stratosphere.json+++ b/config/default/common/config/wv.json/layers/tempo/TEMPO_L3_NO2_Vertical_Column_Stratosphere.json@@ -10,7 +10,8 @@"layergroup": "Nitrogen Dioxide","dataAvailability": "dd","startDate": "2023-08-02T15:00:00Z",- "shiftadjacentdays": false+ "shiftadjacentdays": false,+ "hasVariablePeriod": "30M"}}}diff --git a/config/default/common/config/wv.json/layers/tempo/TEMPO_L3_NO2_Vertical_Column_Troposphere.json b/config/default/common/config/wv.json/layers/tempo/TEMPO_L3_NO2_Vertical_Column_Troposphere.jsonindex 3028098c7..cf7f1a1b4 100644--- a/config/default/common/config/wv.json/layers/tempo/TEMPO_L3_NO2_Vertical_Column_Troposphere.json+++ b/config/default/common/config/wv.json/layers/tempo/TEMPO_L3_NO2_Vertical_Column_Troposphere.json@@ -10,7 +10,8 @@"layergroup": "Nitrogen Dioxide","dataAvailability": "dd","startDate": "2023-08-02T15:00:00Z",- "shiftadjacentdays": false+ "shiftadjacentdays": false,+ "hasVariablePeriod": "30M"}}}\ No newline at end of filediff --git a/config/default/common/config/wv.json/layers/tempo/TEMPO_L3_Ozone_Cloud_Fraction.json b/config/default/common/config/wv.json/layers/tempo/TEMPO_L3_Ozone_Cloud_Fraction.jsonindex 937ae153e..e8e0a8af1 100644--- a/config/default/common/config/wv.json/layers/tempo/TEMPO_L3_Ozone_Cloud_Fraction.json+++ b/config/default/common/config/wv.json/layers/tempo/TEMPO_L3_Ozone_Cloud_Fraction.json@@ -10,7 +10,8 @@"layergroup": "Ozone","dataAvailability": "dd","startDate": "2023-08-02T15:00:00Z",- "shiftadjacentdays": false+ "shiftadjacentdays": false,+ "hasVariablePeriod": "30M"}}}\ No newline at end of filediff --git a/config/default/common/config/wv.json/layers/tempo/TEMPO_L3_Ozone_Column_Amount.json b/config/default/common/config/wv.json/layers/tempo/TEMPO_L3_Ozone_Column_Amount.jsonindex b60e75e4a..faa0e985c 100644--- a/config/default/common/config/wv.json/layers/tempo/TEMPO_L3_Ozone_Column_Amount.json+++ b/config/default/common/config/wv.json/layers/tempo/TEMPO_L3_Ozone_Column_Amount.json@@ -10,7 +10,8 @@"layergroup": "Ozone","dataAvailability": "dd","startDate": "2023-08-02T15:00:00Z",- "shiftadjacentdays": false+ "shiftadjacentdays": false,+ "hasVariablePeriod": "30M"}}}\ No newline at end of filediff --git a/config/default/common/config/wv.json/layers/tempo/TEMPO_L3_Ozone_UV_Aerosol_Index.json b/config/default/common/config/wv.json/layers/tempo/TEMPO_L3_Ozone_UV_Aerosol_Index.jsonindex 3ed34c4b9..d6f6df006 100644--- a/config/default/common/config/wv.json/layers/tempo/TEMPO_L3_Ozone_UV_Aerosol_Index.json+++ b/config/default/common/config/wv.json/layers/tempo/TEMPO_L3_Ozone_UV_Aerosol_Index.json@@ -10,7 +10,8 @@"layergroup": "Aerosol Index","dataAvailability": "dd","startDate": "2023-08-02T15:00:00Z",- "shiftadjacentdays": false+ "shiftadjacentdays": false,+ "hasVariablePeriod": "30M"}}}\ No newline at end of filediff --git a/config/default/common/features.json b/config/default/common/features.jsonindex 50fb369b4..ac8903bde 100644--- a/config/default/common/features.json+++ b/config/default/common/features.json@@ -40,6 +40,9 @@"cmr": {"url": "https://cmr.earthdata.nasa.gov/search/"},+ "describeDomains": {+ "url": "https://gibs.earthdata.nasa.gov"+ },"smartHandoffs": [{"toolName": "EARTHDATA_SEARCH",diff --git a/e2e/features/share/share-test.spec.js b/e2e/features/share/share-test.spec.jsindex 3dc630f5d..b356d253d 100644--- a/e2e/features/share/share-test.spec.js+++ b/e2e/features/share/share-test.spec.js@@ -1,4 +1,3 @@-// @ts-checkconst { test, expect } = require('@playwright/test')const createSelectors = require('../../test-utils/global-variables/selectors')const { skipTour } = require('../../test-utils/global-variables/querystrings')diff --git a/web/js/components/animation-widget/play-queue.js b/web/js/components/animation-widget/play-queue.jsindex 276e36426..17cdbd754 100644--- a/web/js/components/animation-widget/play-queue.js+++ b/web/js/components/animation-widget/play-queue.js@@ -6,6 +6,9 @@ import PQueue, { TimeoutError } from 'p-queue';import { Progress } from 'reactstrap';import LoadingIndicator from './loading-indicator';import util from '../../util/util';+import {+ getNextImageryDelta,+} from '../../modules/date/util';// We assume anything this fast or faster is a frame that was pulled from the cacheconst MIN_REQUEST_TIME_MS = 200;@@ -262,7 +265,15 @@ class PlayQueue extends React.Component {};nextDate(date) {- const { interval, delta } = this.props;+ const {+ interval,+ delta,+ autoSelected,+ layers,+ } = this.props;+ if (autoSelected) {+ return util.dateAdd(date, 'minute', getNextImageryDelta(layers, date, 1));+ }return util.dateAdd(date, interval, delta);}@@ -481,6 +492,8 @@ PlayQueue.propTypes = {snappedCurrentDate: PropTypes.oneOfType([PropTypes.object, PropTypes.oneOf(['null'])]),isKioskModeActive: PropTypes.bool,map: PropTypes.oneOfType([PropTypes.object, PropTypes.oneOf(['null'])]),+ autoSelected: PropTypes.bool,+ layers: PropTypes.oneOfType([PropTypes.array, PropTypes.oneOf(['null'])]),};export default PlayQueue;diff --git a/web/js/components/layer/info/date-ranges.js b/web/js/components/layer/info/date-ranges.jsindex 87115887b..49f57b636 100644--- a/web/js/components/layer/info/date-ranges.js+++ b/web/js/components/layer/info/date-ranges.js@@ -9,7 +9,7 @@ const formatDateRanges = (dateRanges = []) => dateRanges.map(({endDate,}) => [startDate, endDate]);-export default function DateRanges ({ layer }) {+export default function DateRanges ({ layer, describeDomainsUrl }) {const [showRanges, setShowRanges] = useState(false);const [dateRanges, setDateRanges] = useState([]);const { ongoing } = layer;@@ -47,6 +47,7 @@ export default function DateRanges ({ layer }) {endDate,id: layer.id,proj: 'EPSG:4326',+ baseUrl: describeDomainsUrl,};return worker.postMessage({ operation: 'requestDescribeDomains', args: [params] });};@@ -104,4 +105,5 @@ export default function DateRanges ({ layer }) {DateRanges.propTypes = {layer: PropTypes.oneOfType([PropTypes.object, PropTypes.oneOf(['null'])]),+ describeDomainsUrl: PropTypes.string,};diff --git a/web/js/components/layer/info/info.js b/web/js/components/layer/info/info.jsindex 1f1aaff2b..4383208ac 100644--- a/web/js/components/layer/info/info.js+++ b/web/js/components/layer/info/info.js@@ -4,7 +4,7 @@ import { dateOverlap } from '../../../modules/layers/util';import DateRanges from './date-ranges';import { coverageDateFormatter } from '../../../modules/date/util';-export default function LayerInfo ({ layer, measurementDescriptionPath }) {+export default function LayerInfo ({ layer, measurementDescriptionPath, describeDomainsUrl }) {const {dateRanges,endDate,@@ -76,7 +76,7 @@ export default function LayerInfo ({ layer, measurementDescriptionPath }) {</>) : startDate && ' - Present'}</span>- {needDateRanges && <DateRanges layer={layer} />}+ {needDateRanges && <DateRanges layer={layer} describeDomainsUrl={describeDomainsUrl} />}</div>)}{layerMetadata ? (@@ -104,4 +104,5 @@ export default function LayerInfo ({ layer, measurementDescriptionPath }) {LayerInfo.propTypes = {layer: PropTypes.oneOfType([PropTypes.object, PropTypes.oneOf(['null'])]),measurementDescriptionPath: PropTypes.string,+ describeDomainsUrl: PropTypes.string,};diff --git a/web/js/components/layer/product-picker/browse/measurement-metadata-detail.js b/web/js/components/layer/product-picker/browse/measurement-metadata-detail.jsindex 984fae3c6..d1036d9b6 100644--- a/web/js/components/layer/product-picker/browse/measurement-metadata-detail.js+++ b/web/js/components/layer/product-picker/browse/measurement-metadata-detail.js@@ -7,7 +7,13 @@ import LayerInfo from '../../info/info';function MeasurementMetadataDetail (props) {const {- isMobile, source, layers, categoryTitle, showPreviewImage, selectedProjection,+ isMobile,+ source,+ layers,+ categoryTitle,+ showPreviewImage,+ selectedProjection,+ describeDomainsUrl,} = props;const [isMetadataExpanded, setMetadataExpansion] = useState(false);const [metadata, setMetadata] = useState({});@@ -66,7 +72,7 @@ function MeasurementMetadataDetail (props) {</a></div>)}- <LayerInfo key={l.id} layer={l} />+ <LayerInfo key={l.id} layer={l} describeDomainsUrl={describeDomainsUrl} /></div>));};@@ -152,6 +158,7 @@ MeasurementMetadataDetail.propTypes = {source: PropTypes.oneOfType([PropTypes.object, PropTypes.oneOf(['null'])]),showPreviewImage: PropTypes.bool,selectedProjection: PropTypes.string,+ describeDomainsUrl: PropTypes.string,};const mapStateToProps = (state) => {@@ -165,6 +172,7 @@ const mapStateToProps = (state) => {const { layerConfig } = layers;const settings = source ? source.settings : [];const layersForSource = settings.map((id) => layerConfig[id]);+ const describeDomainsUrl = config?.features?.describeDomains?.url || 'https://gibs.earthdata.nasa.gov';return {categoryTitle: category && category.title,@@ -172,6 +180,7 @@ const mapStateToProps = (state) => {layers: layersForSource,selectedProjection: proj.id,showPreviewImage: config.features.previewSnapshots,+ describeDomainsUrl,};};diff --git a/web/js/components/layer/product-picker/search/layer-metadata-detail.js b/web/js/components/layer/product-picker/search/layer-metadata-detail.jsindex 70ffa5032..b303ef715 100644--- a/web/js/components/layer/product-picker/search/layer-metadata-detail.js+++ b/web/js/components/layer/product-picker/search/layer-metadata-detail.js@@ -47,7 +47,12 @@ class LayerMetadataDetail extends React.Component {render() {const {- layer, selectedProjection, isActive, showPreviewImage, measurementDescriptionPath,+ layer,+ selectedProjection,+ isActive,+ showPreviewImage,+ measurementDescriptionPath,+ describeDomainsUrl,} = this.props;if (!layer) {return this.renderNoSelection();@@ -79,6 +84,7 @@ class LayerMetadataDetail extends React.Component {<LayerInfolayer={layer}measurementDescriptionPath={measurementDescriptionPath}+ describeDomainsUrl={describeDomainsUrl}/></div></div>@@ -95,6 +101,7 @@ LayerMetadataDetail.propTypes = {removeLayer: PropTypes.func,selectedProjection: PropTypes.string,showPreviewImage: PropTypes.bool,+ describeDomainsUrl: PropTypes.string,};const makeMapStateToProps = () => {@@ -109,6 +116,7 @@ const makeMapStateToProps = () => {const activeLayers = getActiveLayersMap(state);const isActive = selectedLayer && !!activeLayers[selectedLayer.id];const measurementDescriptionPath = getDescriptionPath(state, ownProps);+ const describeDomainsUrl = config?.features?.describeDomains?.url || 'https://gibs.earthdata.nasa.gov';return {isActive,@@ -116,6 +124,7 @@ const makeMapStateToProps = () => {measurementDescriptionPath,selectedProjection: proj.id,showPreviewImage: config.features.previewSnapshots,+ describeDomainsUrl,};};};diff --git a/web/js/components/timeline/timeline-axis/timeline-axis.js b/web/js/components/timeline/timeline-axis/timeline-axis.jsindex dcce84034..81c198dcd 100644--- a/web/js/components/timeline/timeline-axis/timeline-axis.js+++ b/web/js/components/timeline/timeline-axis/timeline-axis.js@@ -1426,6 +1426,7 @@ class TimelineAxis extends Component {addTimeRanges = (def, proj, dateRange) => {const {addGranuleDateRanges,+ describeDomainsUrl,} = this.props;const {cmrAvailability,@@ -1469,6 +1470,7 @@ class TimelineAxis extends Component {endDate,id,proj: proj.crs,+ baseUrl: describeDomainsUrl,};worker.postMessage({ operation: 'requestDescribeDomains', args: [params] });}@@ -1702,6 +1704,7 @@ TimelineAxis.propTypes = {updatePositioningOnAxisStopDrag: PropTypes.func,updatePositioningOnSimpleDrag: PropTypes.func,updateTimelineMoveAndDrag: PropTypes.func,+ describeDomainsUrl: PropTypes.string,};export default TimelineAxis;diff --git a/web/js/components/timeline/timeline-controls/timescale-interval-change.js b/web/js/components/timeline/timeline-controls/timescale-interval-change.jsindex f2f2505d6..a9683c9b3 100644--- a/web/js/components/timeline/timeline-controls/timescale-interval-change.js+++ b/web/js/components/timeline/timeline-controls/timescale-interval-change.js@@ -89,6 +89,7 @@ class TimeScaleIntervalChange extends PureComponent {customInterval, customDelta, selectInterval, toggleCustomModal, modalType,} = this.props;const customSelected = timeScale === 'custom';+ const autoSelected = timeScale === 'auto';let delta;let newTimeScale = timeScale;@@ -100,11 +101,14 @@ class TimeScaleIntervalChange extends PureComponent {if (customSelected && customInterval && customDelta) {newTimeScale = customInterval;delta = customDelta;+ } else if (autoSelected) {+ newTimeScale = 5;+ delta = 1;} else {newTimeScale = Number(TIME_SCALE_TO_NUMBER[newTimeScale]);delta = 1;}- selectInterval(delta, newTimeScale, customSelected);+ selectInterval(delta, newTimeScale, customSelected, autoSelected);};// set custom text for custom interval@@ -168,6 +172,13 @@ class TimeScaleIntervalChange extends PureComponent {>Minute</span>+ <span+ id="interval-auto"+ className="interval-btn interval-auto"+ onClick={() => this.handleClickInterval('auto')}+ >+ Auto+ </span></>) : null}<span@@ -196,6 +207,7 @@ class TimeScaleIntervalChange extends PureComponent {} = this.state;const {customSelected,+ autoSelected,interval,isDisabled,} = this.props;@@ -214,7 +226,7 @@ class TimeScaleIntervalChange extends PureComponent {id="current-interval"className={className}>- {customSelected ? customIntervalText : `${1} ${TIME_SCALE_FROM_NUMBER[interval]}`}+ {customSelected ? customIntervalText : autoSelected ? 'AUTO' : `${1} ${TIME_SCALE_FROM_NUMBER[interval]}`}</span>{!isDisabled ? this.renderTooltip() : null}@@ -228,21 +240,22 @@ const mapDispatchToProps = (dispatch) => ({toggleCustomModal: (isOpen, modalType) => {dispatch(toggleCustomModalAction(isOpen, modalType));},- selectInterval: (delta, timeScale, customSelected) => {- dispatch(selectIntervalAction(delta, timeScale, customSelected));+ selectInterval: (delta, timeScale, customSelected, autoSelected) => {+ dispatch(selectIntervalAction(delta, timeScale, customSelected, autoSelected));},});const mapStateToProps = (state) => {const { date } = state;const {- interval, customInterval, customDelta, customSelected,+ interval, customInterval, customDelta, customSelected, autoSelected,} = date;return {interval,customInterval,customDelta,customSelected,+ autoSelected,};};@@ -250,6 +263,7 @@ TimeScaleIntervalChange.propTypes = {customDelta: PropTypes.number,customInterval: PropTypes.number,customSelected: PropTypes.bool,+ autoSelected: PropTypes.bool,hasSubdailyLayers: PropTypes.bool,interval: PropTypes.number,isDisabled: PropTypes.bool,diff --git a/web/js/containers/animation-widget/animation-widget.js b/web/js/containers/animation-widget/animation-widget.jsindex b45562e55..6cccf69f2 100644--- a/web/js/containers/animation-widget/animation-widget.js+++ b/web/js/containers/animation-widget/animation-widget.js@@ -90,6 +90,8 @@ function AnimationWidget (props) {startDate,subDailyMode,map,+ autoSelected,+ layers,} = props;const widgetWidth = 334;@@ -196,10 +198,14 @@ function AnimationWidget (props) {// for subdaily, zero start and end dates to UTC HH:MM:00:00const startMinutes = startDateZeroed.getMinutes();const endMinutes = endDateZeroed.getMinutes();- startDateZeroed.setUTCMinutes(Math.floor(startMinutes / 10) * 10);+ if (!autoSelected) {+ startDateZeroed.setUTCMinutes(Math.floor(startMinutes / 10) * 10);+ }startDateZeroed.setUTCSeconds(0);startDateZeroed.setUTCMilliseconds(0);- endDateZeroed.setUTCMinutes(Math.floor(endMinutes / 10) * 10);+ if (!autoSelected) {+ endDateZeroed.setUTCMinutes(Math.floor(endMinutes / 10) * 10);+ }endDateZeroed.setUTCSeconds(0);endDateZeroed.setUTCMilliseconds(0);} else {@@ -252,6 +258,8 @@ function AnimationWidget (props) {promiseImageryForTime={promiseImageryForTime}onClose={onPushPause}map={map}+ autoSelected={autoSelected}+ layers={layers}/>) : null}@@ -359,12 +367,14 @@ const mapStateToProps = (state) => {screenSize,ui,proj,+ layers,} = state;const {startDate, endDate, speed, loop, isPlaying, isActive, isCollapsed, autoplay,} = animation;const {customSelected,+ autoSelected,delta,customDelta,appNow,@@ -416,6 +426,8 @@ const mapStateToProps = (state) => {TIME_SCALE_FROM_NUMBER[useInterval],useDelta,frameLimit,+ autoSelected,+ layers.active.layers,);const currentDate = getSelectedDate(state);let snappedCurrentDate;@@ -477,6 +489,8 @@ const mapStateToProps = (state) => {isEmbedModeActive,playDisabled: !screenSize.isMobileDevice ? numberOfFrames >= maxFrames || numberOfFrames === 1: numberOfFrames >= mobileMaxFrames || numberOfFrames === 1,+ autoSelected,+ layers: layers.active.layers,};};@@ -566,6 +580,8 @@ AnimationWidget.propTypes = {speedRedux: PropTypes.number,startDate: PropTypes.oneOfType([PropTypes.object, PropTypes.oneOf(['null'])]),subDailyMode: PropTypes.bool,+ autoSelected: PropTypes.bool,+ layers: PropTypes.oneOfType([PropTypes.array, PropTypes.oneOf(['null'])]),};export default connect(diff --git a/web/js/containers/gif.js b/web/js/containers/gif.jsindex 999a08614..79dabe90c 100644--- a/web/js/containers/gif.js+++ b/web/js/containers/gif.js@@ -408,18 +408,21 @@ class GIF extends Component {function mapStateToProps(state) {const {- screenSize, proj, animation, map, date, config,+ screenSize, proj, animation, map, date, config, layers,} = state;const {speed, startDate, endDate, boundaries,} = animation;const { screenWidth, screenHeight } = screenSize;const {- customSelected, interval, customInterval, customDelta,+ customSelected, autoSelected, interval, customInterval, customDelta,} = date;- const increment = customSelected+ const customIncrement = customSelected? `${customDelta} ${TIME_SCALE_FROM_NUMBER[customInterval]}`: `1 ${TIME_SCALE_FROM_NUMBER[interval]}`;+ const increment = autoSelected+ ? 'Auto Interval'+ : customIncrement;let url = DEFAULT_URL;if (config.features.imageDownload && config.features.imageDownload.url) {url = config.features.imageDownload.url;@@ -450,6 +453,9 @@ function mapStateToProps(state) {? TIME_SCALE_FROM_NUMBER[customInterval]: TIME_SCALE_FROM_NUMBER[interval],customSelected ? customDelta : 1,+ null,+ autoSelected,+ layers.active.layers,),getImageArray: (options, dimensions) => getImageArray(options,diff --git a/web/js/containers/map-interactions/ol-vector-interactions.js b/web/js/containers/map-interactions/ol-vector-interactions.jsindex f282e6473..94a30e801 100644--- a/web/js/containers/map-interactions/ol-vector-interactions.js+++ b/web/js/containers/map-interactions/ol-vector-interactions.js@@ -127,7 +127,7 @@ export class VectorInteractions extends React.Component {map.forEachFeatureAtPixel(pixel, (feature, layer) => {if (!layer) return;const def = lodashGet(layer, 'wv.def');- if (def.layergroup === 'Reference') isReferenceLayer = true;+ if (def?.layergroup === 'Reference') isReferenceLayer = true;const layerExtent = layer.get('extent');const pixelCoords = map.getCoordinateFromPixel(pixel);const featureOutsideExtent = layerExtentdiff --git a/web/js/containers/projection.js b/web/js/containers/projection.jsindex d7b47cae1..388c52fb0 100644--- a/web/js/containers/projection.js+++ b/web/js/containers/projection.js@@ -6,6 +6,14 @@ import googleTagManager from 'googleTagManager';import changeProjection from '../modules/projection/actions';import { onToggle } from '../modules/modal/actions';import IconList from '../components/util/icon-list';+import {+ changeTimeScale,+ selectInterval,+ changeAutoInterval as changeAutoIntervalAction,+} from '../modules/date/actions';+import {+ TIME_SCALE_TO_NUMBER,+} from '../modules/date/constants';const DEFAULT_PROJ_ARRAY = [{@@ -49,11 +57,17 @@ class ProjectionList extends Component {onClick(id) {const {- updateProjection, projection, onCloseModal,+ updateProjection, projection, onCloseModal, changeTimeScale, changeAutoInterval, layers,} = this.props;if (id !== projection) {updateProjection(id);+ 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);+ selectInterval(1, timescale, false, enableAuto);+ changeTimeScale(enableAuto ? TIME_SCALE_TO_NUMBER.hour : timescale);}googleTagManager.pushEvent({@@ -78,7 +92,7 @@ class ProjectionList extends Component {const mapStateToProps = (state) => {const {- config, models, proj, screenSize,+ config, models, proj, screenSize, layers,} = state;const projArray = lodashGet(config, 'ui.projections');const projectionArray = projArray@@ -90,6 +104,7 @@ const mapStateToProps = (state) => {isMobile,projection: proj.id,projectionArray,+ layers: layers.active.layers,};};@@ -100,6 +115,12 @@ const mapDispatchToProps = (dispatch) => ({onCloseModal: () => {dispatch(onToggle());},+ changeTimeScale: (val) => {+ dispatch(changeTimeScale(val));+ },+ changeAutoInterval: (delta, timeScale, autoSelected) => {+ dispatch(changeAutoIntervalAction(delta, timeScale, autoSelected));+ },});export default connect(@@ -113,4 +134,7 @@ ProjectionList.propTypes = {projection: PropTypes.string,projectionArray: PropTypes.oneOfType([PropTypes.array, PropTypes.oneOf(['null'])]),updateProjection: PropTypes.func,+ changeTimeScale: PropTypes.func,+ changeAutoInterval: PropTypes.func,+ layers: PropTypes.oneOfType([PropTypes.array, PropTypes.oneOf(['null'])]),};diff --git a/web/js/containers/sidebar/layer-row.js b/web/js/containers/sidebar/layer-row.jsindex a7d6bafca..353e2f645 100644--- a/web/js/containers/sidebar/layer-row.js+++ b/web/js/containers/sidebar/layer-row.js@@ -103,6 +103,7 @@ function LayerRow (props) {disableDDVZoomAlert,map,selectedDate,+ describeDomainsUrl,} = props;const encodedLayerId = util.encodeId(layer.id);@@ -332,7 +333,7 @@ function LayerRow (props) {id={layerInfoBtnId}aria-label={layerInfoBtnTitle}className="button wv-layers-info layer-options-dropdown-item"- onClick={() => onInfoClick(layer, title, measurementDescriptionPath)}+ onClick={() => onInfoClick(layer, title, measurementDescriptionPath, describeDomainsUrl)}>{layerInfoBtnTitle}</DropdownItem>@@ -388,7 +389,7 @@ function LayerRow (props) {aria-label={layerInfoBtnTitle}className={isMobile ? 'hidden wv-layers-info' : 'button wv-layers-info'}onMouseDown={stopPropagation}- onClick={() => onInfoClick(layer, title, measurementDescriptionPath)}+ onClick={() => onInfoClick(layer, title, measurementDescriptionPath, describeDomainsUrl)}><UncontrolledTooltip id="center-align-tooltip" placement="top" target={layerInfoBtnId}>{layerInfoBtnTitle}@@ -697,6 +698,7 @@ const makeMapStateToProps = () => {const collections = getCollections(layers, dailyDate, subdailyDate, layer, proj.id);const measurementDescriptionPath = getDescriptionPath(state, ownProps);const { ddvZoomAlerts, ddvLocationAlerts } = state.alerts;+ const describeDomainsUrl = config?.features?.describeDomains?.url || 'https://gibs.earthdata.nasa.gov';return {compare,@@ -724,6 +726,7 @@ const makeMapStateToProps = () => {map,selectedDate,renderedPalette: renderedPalettes[paletteName],+ describeDomainsUrl,};};};@@ -769,7 +772,7 @@ const mapDispatchToProps = (dispatch) => ({}),);},- onInfoClick: (layer, title, measurementDescriptionPath) => {+ onInfoClick: (layer, title, measurementDescriptionPath, describeDomainsUrl) => {const key = `LAYER_INFO_MODAL-${layer.id}`;googleTagManager.pushEvent({event: 'sidebar_layer_info',@@ -788,6 +791,7 @@ const mapDispatchToProps = (dispatch) => ({bodyComponentProps: {layer,measurementDescriptionPath,+ describeDomainsUrl,},}),);@@ -872,4 +876,5 @@ LayerRow.propTypes = {disableDDVZoomAlert: PropTypes.func,map: PropTypes.oneOfType([PropTypes.object, PropTypes.oneOf(['null'])]),selectedDate: PropTypes.instanceOf(Date),+ describeDomainsUrl: PropTypes.string,};diff --git a/web/js/containers/timeline/timeline.js b/web/js/containers/timeline/timeline.jsindex 046726529..b24f33e0b 100644--- a/web/js/containers/timeline/timeline.js+++ b/web/js/containers/timeline/timeline.js@@ -44,6 +44,7 @@ import {changeTimeScale,selectInterval,changeCustomInterval as changeCustomIntervalAction,+ changeAutoInterval as changeAutoIntervalAction,updateAppNow,toggleCustomModal,triggerTodayButton,@@ -52,6 +53,7 @@ import {checkHasFutureLayers,filterProjLayersWithStartDate,getNextTimeSelection,+ getNextImageryDelta,} from '../../modules/date/util';import { toggleActiveCompareState } from '../../modules/compare/actions';import { addGranuleDateRanges } from '../../modules/layers/actions';@@ -290,6 +292,7 @@ class Timeline extends React.Component {animStartLocationDate,animEndLocationDate,changeCustomInterval,+ changeAutoInterval,customInterval,dateA,dateB,@@ -298,6 +301,7 @@ class Timeline extends React.Component {isAnimationWidgetOpen,isGifActive,hasSubdailyLayers,+ hasTempoProduct,subDailyLayersList,newCustomDelta,} = this.props;@@ -335,7 +339,9 @@ class Timeline extends React.Component {const isSubDaily = newCustomDelta < 1440; // 1440 == 1 day in minutesif (subDailyCountChanged) {- if (isSubDaily) {+ if (hasTempoProduct) {+ changeAutoInterval(1, TIME_SCALE_TO_NUMBER.minute, true);+ } else if (isSubDaily) {changeCustomInterval(newCustomDelta, TIME_SCALE_TO_NUMBER.minute);} else {changeCustomInterval(1, TIME_SCALE_TO_NUMBER.day);@@ -597,6 +603,7 @@ class Timeline extends React.Component {handleArrowDateChange(signConstant) {const {customSelected,+ autoSelected,deltaChangeAmt,timeScaleChangeUnit,selectedDate,@@ -604,9 +611,14 @@ class Timeline extends React.Component {leftArrowDisabled,timelineEndDateLimit,timelineStartDateLimit,+ subDailyLayersList,+ dateA,} = this.props;let delta = customSelected && deltaChangeAmt ? deltaChangeAmt : 1;+ if (autoSelected && subDailyLayersList && subDailyLayersList.length) {+ delta = getNextImageryDelta(subDailyLayersList, dateA, signConstant);+ }if (!timeScaleChangeUnit) { // undefined custom will not allow arrow changereturn;}@@ -1190,6 +1202,7 @@ class Timeline extends React.Component {timeScaleChangeUnit,toggleActiveCompareState,proj,+ describeDomainsUrl,} = this.props;const {animationEndLocation,@@ -1351,6 +1364,7 @@ class Timeline extends React.Component {isTimelineDragging={isTimelineDragging}matchingTimelineCoverage={matchingTimelineCoverage}proj={proj}+ describeDomainsUrl={describeDomainsUrl}/><AxisHoverLine@@ -1531,6 +1545,7 @@ function mapStateToProps(state) {customDelta,customInterval,customSelected,+ autoSelected,interval,selected,selectedB,@@ -1563,6 +1578,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'));// if future layers are included, timeline axis end date will extend past appNowconst hasFutureLayers = checkHasFutureLayers(state);@@ -1615,6 +1631,8 @@ function mapStateToProps(state) {nowOverride,appNow,);+ const describeDomainsUrl = config?.features?.describeDomains?.url || 'https://gibs.earthdata.nasa.gov';+return {appNow,activeLayers: activeLayersFiltered,@@ -1631,10 +1649,12 @@ function mapStateToProps(state) {hasSubdailyLayers,subDailyLayersList,customSelected,+ autoSelected,isCompareModeActive,isChartingActive,isAnimatingToEvent,hasFutureLayers,+ hasTempoProduct,dateA: getISODateFormatted(selected),dateB: getISODateFormatted(selectedB),timelineStartDateLimit: config.startDate, // same as startDate@@ -1674,6 +1694,7 @@ function mapStateToProps(state) {displayStaticMap,newCustomDelta,proj: proj.selected,+ describeDomainsUrl,};}@@ -1694,6 +1715,10 @@ const mapDispatchToProps = (dispatch) => ({changeCustomInterval: (delta, timeScale) => {dispatch(changeCustomIntervalAction(delta, timeScale));},+ // changes/sets auto delta and timescale interval+ changeAutoInterval: (delta, timeScale, autoSelected) => {+ dispatch(changeAutoIntervalAction(delta, timeScale, autoSelected));+ },// changes timescale (scale of grids vs. what LEFT/RIGHT arrow do)changeTimeScale: (val) => {dispatch(changeTimeScale(val));@@ -1753,16 +1778,19 @@ Timeline.propTypes = {axisWidth: PropTypes.number,breakpoints: PropTypes.oneOfType([PropTypes.object, PropTypes.oneOf(['null'])]),changeCustomInterval: PropTypes.func,+ changeAutoInterval: PropTypes.func,changeTimeScale: PropTypes.func,closeAnimation: PropTypes.func,customInterval: PropTypes.number,customSelected: PropTypes.bool,+ autoSelected: PropTypes.bool,dateA: PropTypes.string,dateB: PropTypes.string,deltaChangeAmt: PropTypes.number,displayStaticMap: PropTypes.bool,draggerSelected: PropTypes.string,hasFutureLayers: PropTypes.bool,+ hasTempoProduct: PropTypes.bool,hasSubdailyLayers: PropTypes.bool,subDailyLayersList: PropTypes.oneOfType([PropTypes.array, PropTypes.oneOf(['null'])]),hideTimeline: PropTypes.bool,@@ -1807,4 +1835,5 @@ Timeline.propTypes = {triggerTodayButton: PropTypes.func,updateAppNow: PropTypes.func,proj: PropTypes.oneOfType([PropTypes.object, PropTypes.oneOf(['null'])]),+ describeDomainsUrl: PropTypes.string,};diff --git a/web/js/location.js b/web/js/location.jsindex f93c51a18..ad82f5ea1 100644--- a/web/js/location.js+++ b/web/js/location.js@@ -227,6 +227,13 @@ const getParameters = function(config, parameters) {parse: (val) => val === 'true',},},+ ias: {+ stateKey: 'date.autoSelected',+ initialState: false,+ options: {+ parse: (val) => val === 'true',+ },+ },ici: {stateKey: 'date.customInterval',initialState: undefined,diff --git a/web/js/map/layerbuilder.js b/web/js/map/layerbuilder.jsindex 8a7368f42..833432aeb 100644--- a/web/js/map/layerbuilder.js+++ b/web/js/map/layerbuilder.js@@ -197,7 +197,10 @@ export default function mapLayerBuilder(config, cache, store) {}if (def.period === 'subdaily') {- closestDate = def.id.includes('TEMPO_L2') ? closestDate : nearestInterval(def, closestDate);+ // Skip interval snapping for non-variable subdaily products+ const directIntervalProducts = ['TEMPO', 'PREFIRE'];+ const useDirectInterval = directIntervalProducts.some((key) => def.id.includes(key));+ closestDate = useDirectInterval ? closestDate : nearestInterval(def, closestDate);} else if (previousDateFromRange) {closestDate = util.clearTimeUTC(previousDateFromRange);} else {@@ -378,6 +381,9 @@ export default function mapLayerBuilder(config, cache, store) {tileSize: tileSize[0],};+ // force currently selected time to be 59 seconds.+ // This is to compensate for the inability to select seconds in the timeline+ layerDate.setSeconds(59);const urlParameters = `?TIME=${util.toISOStringSeconds(layerDate, !isSubdaily)}`;const sourceURL = def.sourceOverride || configSource.url;const sourceOptions = {@@ -1242,40 +1248,41 @@ export default function mapLayerBuilder(config, cache, store) {const wrapDefined = wrapadjacentdays === true || wrapX;const wrapLayer = proj.id === 'geographic' && !isDataDownloadTabActive && wrapDefined;- if (!isGranule) {- switch (def.type) {- case 'wmts':- layer = await getLayer(createLayerWMTS, def, options, attributes, wrapLayer);- break;- case 'vector':- layer = await getLayer(createLayerVector, def, options, attributes, wrapLayer);- break;- case 'wms':- layer = await getLayer(createLayerWMS, def, options, attributes, wrapLayer);- break;- case 'titiler':- layer = await getLayer(createTitilerLayer, def, options, attributes, wrapLayer);- break;- case 'xyz':- layer = await getLayer(createXYZLayer, def, options, attributes, wrapLayer);- break;- case 'indexedVector':- layer = await getLayer(createIndexedVectorLayer, def, options, attributes, wrapLayer);- break;- case 'composite:wmts':- layer = await getLayer(createLayerCompositeWMTS, def, options, attributes, wrapLayer);- break;- case 'esriMapServer':- layer = await getLayer(createLayerEsri, def, options, attributes, wrapLayer);- break;- default:- throw new Error(`Unknown layer type: ${type}`);- }+ switch (def.type) {+ case 'wmts':+ layer = await getLayer(createLayerWMTS, def, options, attributes, wrapLayer);+ break;+ case 'vector':+ layer = await getLayer(createLayerVector, def, options, attributes, wrapLayer);+ break;+ case 'wms':+ layer = await getLayer(createLayerWMS, def, options, attributes, wrapLayer);+ break;+ case 'titiler':+ layer = await getLayer(createTitilerLayer, def, options, attributes, wrapLayer);+ break;+ case 'xyz':+ layer = await getLayer(createXYZLayer, def, options, attributes, wrapLayer);+ break;+ case 'indexedVector':+ layer = await getLayer(createIndexedVectorLayer, def, options, attributes, wrapLayer);+ break;+ case 'composite:wmts':+ layer = await getLayer(createLayerCompositeWMTS, def, options, attributes, wrapLayer);+ break;+ case 'esriMapServer':+ layer = await getLayer(createLayerEsri, def, options, attributes, wrapLayer);+ break;+ case 'granule':+ layer = await getGranuleLayer(def, attributes, options);+ break;+ default:+ throw new Error(`Unknown layer type: ${type}`);+ }+ if (def.type !== 'granule') {layer.wv = attributes;cache.setItem(key, layer, cacheOptions);if (def.type !== 'titiler') layer.setVisible(false);- } else {- layer = await getGranuleLayer(def, attributes, options);}}layer.setOpacity(opacity || 1.0);diff --git a/web/js/mapUI/components/update-collections/updateCollections.js b/web/js/mapUI/components/update-collections/updateCollections.jsindex 60b4157b2..9810f50d3 100644--- a/web/js/mapUI/components/update-collections/updateCollections.js+++ b/web/js/mapUI/components/update-collections/updateCollections.js@@ -15,6 +15,8 @@ function UpdateCollections () {const sources = useSelector((state) => state.config.sources);const layerConfig = useSelector((state) => state.layers.layerConfig);const projId = useSelector((state) => state.proj.id);+ const map = useSelector((state) => state.map?.ui?.selected);+ const mapLayersLength = map?.getAllLayers()?.length || 0;// Finds the correct subdomain to query headers from based on the layer source and GIBS/GITC envconst lookupLayerSource = (layerId) => {@@ -25,42 +27,44 @@ function UpdateCollections () {return sourceDomain;};- const getHeaders = async (def, date) => {- if (def.layergroup === 'Reference') return undefined; // Don't query static layers+ const getHeaders = async (def, date, signal, baseUrl) => {+ if (def.layergroup === 'Reference') throw new Error('Reference layers do not require header fetching'); // Don't query static layersconst { id, period } = def;const { matrixSet } = def.projections[proj.id];+ if (period === 'subdaily') selectedDate.setSeconds?.(59); // ensure seconds are set to 59 for subdaily layersconst isoStringDate = util.toISOStringSeconds(util.roundTimeOneMinute(selectedDate));const sourceDomain = lookupLayerSource(id);- const sourceUrl = `${sourceDomain}?TIME=${isoStringDate}&layer=${id}&style=default&tilematrixset=${matrixSet}&Service=WMTS&Request=GetTile&Version=1.0.0&Format=${encodeURIComponent(def.format)}&TileMatrix=0&TileCol=0&TileRow=0`;+ const timeUrl = baseUrl || `${sourceDomain}?TIME=${isoStringDate}`;++ const sourceUrl = `${timeUrl}&layer=${id}&style=default&tilematrixset=${matrixSet}&Service=WMTS&Request=GetTile&Version=1.0.0&Format=${encodeURIComponent(def.format)}&TileMatrix=0&TileCol=0&TileRow=0`;try {- const response = await fetch(sourceUrl);+ const response = await fetch(sourceUrl, { method: 'HEAD', signal }); // HEAD request to only fetch headers (faster than the previous GET request) and pass in abort signalconst { headers } = response;const actualId = headers.get('layer-identifier-actual');- if (!actualId) return undefined;+ if (!actualId) throw new Error(`No layer-identifier-actual header found for ${id} on ${sourceUrl}`); // reject the promise if no actualId foundconst parts = actualId.split('_');- const type = parts[parts.length - 1];- const version = parts[parts.length - 2];+ const type = parts.at(-1);+ const version = parts.at(-2);const formattedDate = period === 'daily' ? formatDailyDate(date) : formatSubdailyDate(date);- if (type !== 'NRT' && type !== 'STD') return undefined;+ if (type !== 'NRT' && type !== 'STD') throw new Error(`Invalid imagery type ${type} for ${id} on ${sourceUrl}`); // reject the promise if not NRT or STDreturn {id, date: formattedDate, type, version, projection: proj.id,};} catch (error) {- // errors will clutter console, turn this on for debugging- // console.error(error);- throw new Error('Failed to query headers');+ return Promise.reject(new Error(`Error fetching headers for ${id} on ${sourceUrl}: ${error.message}`));}};- const findLayerCollections = (layers, dailyDate, subdailyDate, forceUpdate) => {- const wmtsLayers = layers.filter((layer) => {- if (layer.type !== 'wmts' || !layer.visible) return false;+ const findLayerCollections = (dailyDate, subdailyDate, forceUpdate) => {+ const layersToUpdate = layers.filter((layer) => {+ const layerTypeEnabled = layer.type !== 'wmts' && layer.type !== 'granule';+ if (layer.layergroup === 'Reference' || layerTypeEnabled || !layer.visible) return false; // Reference and non-wmts/granule layers don't need collections, skip invisible layersconst date = layer.period === 'daily' ? dailyDate : subdailyDate;@@ -73,21 +77,53 @@ function UpdateCollections () {// If date exists in layer collection, don't query layerreturn !collectionDate || forceUpdate;});- return wmtsLayers;+ return layersToUpdate;+ };++ const getAllHeaders = (defs) => {+ const headerRequests = defs.map(async (def) => {+ const abortController = new AbortController();+ const { signal } = abortController;+ const requestSelectedDateHeaders = () => getHeaders(def, selectedDate, signal);+ if (def.type !== 'granule') return requestSelectedDateHeaders(); // non-granule layers only need one header request+ const layerGroup = map?.getLayers()?.getArray()?.find((l) => l?.wv?.id === def.id);+ // if we can't find the layer in the map, just do a single request+ if (!layerGroup) return requestSelectedDateHeaders();+ const granuleLayerArray = layerGroup.getLayersArray() || [];+ // granule layers don't necessarily use the selected date,+ // rather they create one layer for each granule and each has their own date+ const granuleHeaders = granuleLayerArray.map(async (layer) => {+ const urls = layer.getSource?.()?.getUrls?.() || [];+ // each layer has multiple urls to try+ const urlRequests = urls.map(async (url) => getHeaders(def, selectedDate, signal, url));+ // we just want the first response that works and only fail if they all fail+ const firstResponse = await Promise.any(urlRequests);+ return firstResponse;+ });++ // Right now we don't handle the possibility of multiple imagery versions in granule layers,+ // so just return the first valid response+ const firstGranuleHeaderResponse = await Promise.any(granuleHeaders);+ abortController.abort(); // abort any other requests once promise.any settles++ return firstGranuleHeaderResponse;+ });++ return headerRequests;};const updateLayerCollections = async (forceUpdate = false) => {const formattedDailyDate = formatDailyDate(selectedDate);const formattedSubdailyDate = formatSubdailyDate(selectedDate);const layersToUpdate = findLayerCollections(- layers,formattedDailyDate,formattedSubdailyDate,forceUpdate,);- const headerPromises = layersToUpdate.map((layer) => getHeaders(layer, selectedDate));+ const headerPromises = getAllHeaders(layersToUpdate);try {+ // perform all header requests and wait for them to settleconst results = await Promise.allSettled(headerPromises);const validCollections = results.filter(({ status, value }) => status === 'fulfilled' && value).map(({ value }) => value);updateCollection(validCollections);@@ -105,7 +141,7 @@ function UpdateCollections () {useEffect(() => {if (!layers.length) return;updateLayerCollections(true);- }, [projId]);+ }, [projId, mapLayersLength]);return null;}diff --git a/web/js/mapUI/mapUI.js b/web/js/mapUI/mapUI.jsindex 701cd0654..baa18ec3d 100644--- a/web/js/mapUI/mapUI.js+++ b/web/js/mapUI/mapUI.js@@ -164,6 +164,7 @@ function MapUI(props) {case vectorStyleConstants.SET_SELECTED_VECTORS:return setVectorActions(action);case dateConstants.CHANGE_CUSTOM_INTERVAL:+ case dateConstants.CHANGE_AUTO_INTERVAL:case dateConstants.CHANGE_INTERVAL:return setPreloadAction(action);case dateConstants.ARROW_DOWN:diff --git a/web/js/modules/animation/actions.js b/web/js/modules/animation/actions.jsindex d68a11ccd..66c74a60e 100644--- a/web/js/modules/animation/actions.js+++ b/web/js/modules/animation/actions.js@@ -17,22 +17,43 @@ import {import util from '../../util/util';import { TIME_SCALE_FROM_NUMBER } from '../date/constants';import { getSelectedDate } from '../date/selectors';+import {+ getNextImageryDelta,+} from '../date/util';export function onActivate() {return (dispatch, getState) => {- const { date, animation } = getState();+ const { date, animation, layers } = getState();const {- customSelected, customDelta, delta, customInterval, interval,+ customSelected, customDelta, delta, customInterval, interval, selected, autoSelected,} = date;const activeDate = getSelectedDate(getState());if (!animation.startDate || !animation.endDate) {+ let autoTenFramesBefore;+ let autoTenFramesAfter;+ if (autoSelected) {+ let tempDeltaBefore = 0;+ let tempDateBefore = new Date(selected);+ let tempDeltaAfter = 0;+ let tempDateAfter = new Date(selected);+ for (let i = 0; i < 10; i += 1) {+ tempDateBefore = util.dateAdd(tempDateAfter, 'minute', -tempDeltaBefore);+ tempDeltaBefore = getNextImageryDelta(layers.active.layers, tempDateBefore, -1);+ tempDateAfter = util.dateAdd(tempDateAfter, 'minute', tempDeltaAfter);+ tempDeltaAfter = getNextImageryDelta(layers.active.layers, tempDateAfter, 1);+ }+ autoTenFramesBefore = tempDateBefore;+ autoTenFramesAfter = tempDateAfter;+ }const timeScaleChangeUnit = customSelected? 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);- const tenFramesAfter = util.dateAdd(activeDate, timeScaleChangeUnit, tenFrameDelta);+ const tenFramesBefore = autoSelected+ ? autoTenFramesBefore : util.dateAdd(activeDate, timeScaleChangeUnit, -tenFrameDelta);+ const tenFramesAfter = autoSelected+ ? autoTenFramesAfter : util.dateAdd(activeDate, timeScaleChangeUnit, tenFrameDelta);const startDate = animation.startDate? animation.startDate: date.appNow < tenFramesAfterdiff --git a/web/js/modules/animation/selectors.js b/web/js/modules/animation/selectors.jsindex e4787ac5b..b5819f87d 100644--- a/web/js/modules/animation/selectors.js+++ b/web/js/modules/animation/selectors.js@@ -6,7 +6,7 @@ import {} from '../image-download/util';import { subdailyLayersActive, getLayers } from '../layers/selectors';import { TIME_SCALE_FROM_NUMBER } from '../date/constants';-import { formatDisplayDate } from '../date/util';+import { formatDisplayDate, getNextImageryDelta } from '../date/util';/** retrieves renderable layers@@ -58,13 +58,13 @@ export default function getImageArray(state,) {const {- animation, proj, map, date, locationSearch,+ animation, proj, map, date, locationSearch, layers,} = state;const {boundaries, showDates, startDate, endDate, url,} = options;const {- customInterval, interval, customDelta, delta, customSelected,+ customInterval, interval, customDelta, delta, customSelected, autoSelected,} = date;const a = [];const fromDate = new Date(startDate);@@ -105,7 +105,8 @@ export default function getImageArray(text: showDates ? strDate : '',delay: 1000 / animation.speed,});- current = util.dateAdd(current, increment, useDelta);+ current = util.dateAdd(current, increment, autoSelected+ ? getNextImageryDelta(layers.active.layers, current, 1) : useDelta);if (j > 40) {// too many framesreturn false;diff --git a/web/js/modules/animation/util.js b/web/js/modules/animation/util.jsindex 99646f0f5..a329e412e 100644--- a/web/js/modules/animation/util.js+++ b/web/js/modules/animation/util.js@@ -3,6 +3,9 @@ import update from 'immutability-helper';import moment from 'moment';import canvg from '../../util/canvg';import util from '../../util/util';+import {+ getNextImageryDelta,+} from '../date/util';/*** Snap the value for the date/time to the closest previous playback step so that@@ -38,15 +41,29 @@ export function snapToIntervalDelta(currDate, startDate, endDate, interval, delt/*** Calculate the required number of steps (frames) required for the animation- * @param {Date} start | The date of the first frame of animation- * @param {Date} end | The date of the last frame of animation- * @param {String} interval | The animation step value (Year/Month/Day/Custom) separating frames- * @param {Number} delta | Rate of change between states; defaults to 1 second- * @param {Number} maxToCheck | The limit on the total number of frames to be used+ * @param {Date} start | The date of the first frame of animation+ * @param {Date} end | The date of the last frame of animation+ * @param {String} interval | The animation step value (Year/Month/Day/Custom)+ * separating frames+ * @param {Number} delta | Rate of change between states; defaults to 1 second+ * @param {Number} maxToCheck | The limit on the total number of frames to be used+ * @param {Boolean} autoSelected | Is auto interval selected+ * @param {Array} layers | List of layers** @return {Number} | The total number of frames required*/-export function getNumberOfSteps(start, end, interval, delta = 1, maxToCheck) {+export function getNumberOfSteps(+ start,+ end,+ interval,+ delta = 1,+ maxToCheck,+ autoSelected,+ layers,+) {+ if (autoSelected) {+ delta = getNextImageryDelta(layers, start, 1);+ }let i = 1;let currentDate = start;let nextDate = util.dateAdd(start, interval, delta);@@ -56,7 +73,13 @@ export function getNumberOfSteps(start, end, interval, delta = 1, maxToCheck) {}while (currentDate < end) {i += 1;+ if (autoSelected) {+ delta = getNextImageryDelta(layers, currentDate, 1);+ }currentDate = util.dateAdd(currentDate, interval, delta);+ if (autoSelected) {+ delta = getNextImageryDelta(layers, currentDate, 1);+ }nextDate = util.dateAdd(currentDate, interval, delta);// checking to see if next date is after end date to prevent creation of extra frameif (nextDate > end) {diff --git a/web/js/modules/date/actions.js b/web/js/modules/date/actions.jsindex 17eb81499..154789cb4 100644--- a/web/js/modules/date/actions.js+++ b/web/js/modules/date/actions.js@@ -2,6 +2,7 @@ import googleTagManager from 'googleTagManager';import {CHANGE_TIME_SCALE,CHANGE_CUSTOM_INTERVAL,+ CHANGE_AUTO_INTERVAL,CHANGE_INTERVAL,SELECT_DATE,UPDATE_APP_NOW,@@ -98,7 +99,18 @@ export function changeCustomInterval(delta, customInterval) {});};}-export function selectInterval(delta, interval, customSelected) {+export function changeAutoInterval(delta, interval, autoSelected) {+ return (dispatch, getState) => {+ dispatch(clearPreload());+ dispatch({+ type: CHANGE_AUTO_INTERVAL,+ delta,+ interval,+ autoSelected,+ });+ };+}+export function selectInterval(delta, interval, customSelected, autoSelected) {return (dispatch, getState) => {dispatch(clearPreload());dispatch({@@ -106,6 +118,7 @@ export function selectInterval(delta, interval, customSelected) {interval,delta,customSelected,+ autoSelected,});};}diff --git a/web/js/modules/date/actions.test.js b/web/js/modules/date/actions.test.jsindex a3735c285..33c5653f5 100644--- a/web/js/modules/date/actions.test.js+++ b/web/js/modules/date/actions.test.js@@ -5,11 +5,13 @@ import {updateAppNow,selectDate,changeCustomInterval,+ changeAutoInterval,selectInterval,} from './actions';import {CHANGE_TIME_SCALE,CHANGE_CUSTOM_INTERVAL,+ CHANGE_AUTO_INTERVAL,CHANGE_INTERVAL,SELECT_DATE,UPDATE_APP_NOW,@@ -191,6 +193,34 @@ describe('Date timescale changes', () => {},);+ test(+ `changeAutoInterval action returns ${CHANGE_AUTO_INTERVAL} as type and true as autoSelected [date-action-auto-interval]`,+ () => {+ const store = mockStore({+ date: {},+ compare: {+ isCompareA: false,+ activeString: 'activeB',+ },+ proj: {+ id: 'geographic',+ },+ });+ const expectedFirst = {+ type: CLEAR_PRELOAD,+ };+ const expectedSecond = {+ type: CHANGE_AUTO_INTERVAL,+ delta: 5,+ interval: 3,+ autoSelected: true,+ };+ store.dispatch(changeAutoInterval(delta, customInterval, true));+ expect(store.getActions()[0]).toEqual(expectedFirst);+ expect(store.getActions()[1]).toEqual(expectedSecond);+ },+ );+test(`selectInterval action returns ${CHANGE_INTERVAL} as type and ${interval} as value and ${delta} as delta and true as customSelected [date-action-interval]`,() => {diff --git a/web/js/modules/date/constants.js b/web/js/modules/date/constants.jsindex 274e64746..5611be381 100644--- a/web/js/modules/date/constants.js+++ b/web/js/modules/date/constants.js@@ -1,4 +1,5 @@export const CHANGE_CUSTOM_INTERVAL = 'DATE/CHANGE_CUSTOM_INTERVAL';+export const CHANGE_AUTO_INTERVAL = 'DATE/CHANGE_AUTO_INTERVAL';export const CHANGE_INTERVAL = 'DATE/CHANGE_INTERVAL';export const CHANGE_TIME_SCALE = 'DATE/CHANGE_TIME_SCALE';export const SELECT_DATE = 'DATE/SELECT_DATE';diff --git a/web/js/modules/date/reducers.js b/web/js/modules/date/reducers.jsindex e20bf1a41..6802e33f0 100644--- a/web/js/modules/date/reducers.js+++ b/web/js/modules/date/reducers.js@@ -1,6 +1,7 @@import {CHANGE_TIME_SCALE,CHANGE_CUSTOM_INTERVAL,+ CHANGE_AUTO_INTERVAL,CHANGE_INTERVAL,SELECT_DATE,UPDATE_APP_NOW,@@ -23,6 +24,7 @@ export const dateReducerState = {interval: 3,delta: 1,customSelected: false,+ autoSelected: false,customDelta: undefined,customInterval: undefined,timelineCustomModalOpen: false,@@ -60,12 +62,22 @@ export function dateReducer(state = dateReducerState, action) {customSelected: !(!interval && !delta),};}+ case CHANGE_AUTO_INTERVAL: {+ const { interval, delta, autoSelected } = action;+ return {+ ...state,+ interval,+ delta,+ autoSelected,+ };+ }case CHANGE_INTERVAL:return {...state,interval: action.interval,delta: action.delta,customSelected: action.customSelected,+ autoSelected: action.autoSelected,};case SELECT_DATE:return {diff --git a/web/js/modules/date/reducers.test.js b/web/js/modules/date/reducers.test.jsindex 91c652e20..4f13f12b6 100644--- a/web/js/modules/date/reducers.test.js+++ b/web/js/modules/date/reducers.test.js@@ -5,6 +5,7 @@ import {import {CHANGE_TIME_SCALE,CHANGE_CUSTOM_INTERVAL,+ CHANGE_AUTO_INTERVAL,CHANGE_INTERVAL,SELECT_DATE,UPDATE_APP_NOW,@@ -56,6 +57,24 @@ describe('dateReducer', () => {});},);+ test(+ `${CHANGE_AUTO_INTERVAL+ }action type and true as autoSelected `+ + 'should return new state [date-reducer-auto-interval]',+ () => {+ expect(+ dateReducer(dateReducerState, {+ type: CHANGE_AUTO_INTERVAL,+ interval: 3,+ delta: 1,+ autoSelected: true,+ }),+ ).toEqual({+ ...dateReducerState,+ autoSelected: true,+ });+ },+ );test(`${CHANGE_INTERVAL}action type and 1 as delta and 2 as interval `@@ -67,12 +86,14 @@ describe('dateReducer', () => {interval: 2,delta: 1,customSelected: false,+ autoSelected: false,}),).toEqual({...dateReducerState,interval: 2,delta: 1,customSelected: false,+ autoSelected: false,});},);diff --git a/web/js/modules/date/util.js b/web/js/modules/date/util.jsindex 675ac2ead..0089b45b6 100644--- a/web/js/modules/date/util.js+++ b/web/js/modules/date/util.js@@ -539,3 +539,87 @@ export const rollDate = function(date, interval, amount, minDate, maxDate) {newDate = new Date(util.clamp(newDate, newMinDate, newMaxDate));return newDate;};++/**+ * Gets the next imagery delta for auto increments+ *+ * @method getNextImageryDelta+ * @param {Array} layers+ * @param {object} date Selected date+ * @param {Number} signConstant Direction of increment+ * @returns {array} Array of visible layers within the date.+ */+export function getNextImageryDelta(layers, dateA, signConstant) {+ let delta = 0;+ let invalidLayerCount = 0;+ const dateAObj = new Date(dateA);+ let hasDeltaChanged = false;+ for (let i = 0; i < layers.length; i += 1) {+ if (!Object.prototype.hasOwnProperty.call(layers[i], 'dateRanges') || !layers[i].visible) {+ invalidLayerCount += 1;+ } else if (signConstant > 0) {+ // Forward in time+ for (let j = 0; j < layers[i].dateRanges.length; j += 1) {+ const obj = layers[i].dateRanges[j];+ const startDateObj = new Date(obj.startDate);+ const endDateObj = new Date(obj.endDate);+ const minDelta = Number(obj.dateInterval) === 1 ? 60 : Number(obj.dateInterval);+ if (dateAObj < startDateObj) {+ const possibleDelta = Math.ceil(((startDateObj - dateAObj) / 1000) / 60);+ if (possibleDelta >= 1) {+ delta = possibleDelta;+ hasDeltaChanged = true;+ break;+ }+ }+ if (dateAObj < endDateObj) {+ const possibleDate = new Date(dateAObj.getTime() + (minDelta * 60000));+ const possibleDelta = possibleDate > endDateObj+ ? Math.floor(((endDateObj - dateAObj) / 1000) / 60) : minDelta;+ if (possibleDelta >= minDelta) {+ delta = possibleDelta;+ hasDeltaChanged = true;+ break;+ }+ }+ }+ if (hasDeltaChanged) {+ break;+ }+ } else {+ // Backward in time+ for (let j = 0; j < layers[i].dateRanges.length; j += 1) {+ const obj = [...layers[i].dateRanges].reverse()[j];+ const endDateObj = new Date(obj.endDate);+ const startDateObj = new Date(obj.startDate);+ const minDelta = Number(obj.dateInterval) === 1 ? 60 : Number(obj.dateInterval);+ if (dateAObj > endDateObj) {+ const possibleDelta = Math.floor(((dateAObj - endDateObj) / 1000) / 60);+ if (possibleDelta >= minDelta) {+ delta = possibleDelta;+ hasDeltaChanged = true;+ break;+ }+ }+ if (dateAObj > startDateObj) {+ const possibleDate = new Date(dateAObj.getTime() - (minDelta * 60000));+ const possibleDelta = possibleDate < startDateObj+ ? Math.floor(((dateAObj - startDateObj) / 1000) / 60) : minDelta;+ if (possibleDelta >= minDelta) {+ delta = possibleDelta;+ hasDeltaChanged = true;+ break;+ }+ }+ }+ if (hasDeltaChanged) {+ break;+ }+ }+ }+ // If all layers are hidden/invalid, make delta 1+ if (invalidLayerCount === layers.length) {+ delta = 1;+ }+ return delta;+}diff --git a/web/js/modules/image-download/util.js b/web/js/modules/image-download/util.jsindex 2a7e22849..29b057fd4 100644--- a/web/js/modules/image-download/util.js+++ b/web/js/modules/image-download/util.js@@ -20,6 +20,10 @@ export const GRANULE_LIMIT = 30;*/export function getLatestIntervalTime(layerDefs, dateTime) {const subDailyDefs = layerDefs.filter((def) => def.period === 'subdaily') || [];+ const tempoDefs = subDailyDefs.filter((def) => def.id.includes('TEMPO')) || [];+ if (tempoDefs.length > 0) {+ return dateTime;+ }const defsSortedByInterval = subDailyDefs.sort((defA, defB) => {const intervalA = Number(lodashGet(defA, 'dateRanges[0].dateInterval'));const intervalB = Number(lodashGet(defB, 'dateRanges[0].dateInterval'));diff --git a/web/js/modules/layers/selectors.js b/web/js/modules/layers/selectors.jsindex 303054499..e2d5a4c09 100644--- a/web/js/modules/layers/selectors.js+++ b/web/js/modules/layers/selectors.js@@ -637,11 +637,36 @@ export const subdailyLayers = createSelector(* @param {Object} state*/export function getSmallestIntervalValue(state) {+ const oneMinute = 1;+ const oneHour = 60;+ const oneDay = 1440;+ const timeUnitLookup = {+ S: oneMinute / 60,+ M: oneMinute,+ H: oneHour,+ D: oneDay,+ };const layers = getActiveLayers(state);- let smallestDelta = 1440; // 1 day in minutes+ let smallestDelta = timeUnitLookup.D; // 1 day in minutesif (layers && layers.length) {for (let i = 0; i < layers.length; i += 1) {- const interval = lodashGet(layers[i], 'dateRanges[0].dateInterval');+ let interval = lodashGet(layers[i], 'dateRanges[0].dateInterval');+ const variablePeriod = layers[i]?.hasVariablePeriod;+ if (variablePeriod) {+ const numberMatch = variablePeriod.match(/[0-9]+/g);+ const unitMatch = variablePeriod.match(/[a-zA-Z]+/g);+ const time = numberMatch.reduce((acc, val, idx) => {+ const number = Number(val);+ const unit = unitMatch[idx];+ const minutes = number * timeUnitLookup[unit?.toUpperCase?.()];+ const invalid = Number.isNaN(minutes);+ const valueToAdd = invalid ? (console.warn(`Invalid period: ${variablePeriod}`), 0) : minutes; // eslint-disable-line no-console++ return acc + valueToAdd;+ }, 0);++ interval = time;+ }if (layers[i].period === 'subdaily' && interval < smallestDelta) {smallestDelta = Number(interval);}diff --git a/web/js/workers/describe-domains.worker.js b/web/js/workers/describe-domains.worker.jsindex b96b9a704..3d1dd982c 100644--- a/web/js/workers/describe-domains.worker.js+++ b/web/js/workers/describe-domains.worker.js@@ -17,12 +17,13 @@ async function requestDescribeDomains(params) {startDate,endDate,proj,+ baseUrl,} = params;const start = `${new Date(startDate).toISOString().split('.')[0]}Z`;const end = `${new Date(endDate).toISOString().split('.')[0]}Z`;- const describeDomainsUrl = `https://gibs.earthdata.nasa.gov/wmts/${projDict[proj]}/best/1.0.0/${id}/default/250m/all/${start}--${end}.xml`;+ const describeDomainsUrl = `${baseUrl}/wmts/${projDict[proj]}/best/1.0.0/${id}/default/250m/all/${start}--${end}.xml`;const describeDomainsResponse = await fetch(describeDomainsUrl);const describeDomainsText = await describeDomainsResponse.text();@@ -59,22 +60,29 @@ function makeDateString(time) {* Convert period to time*/function periodToTime(period) {+ const oneSecond = 1_000;const oneMinute = 60_000;const oneHour = 3_600_000;const oneDay = 86_400_000;const lookup = {+ S: oneSecond,M: oneMinute,H: oneHour,D: oneDay,};- const match = period.match(/[0-9]+/i);- const number = Number(match[0]);- const unit = period.at(-1);- const time = number * lookup[unit];-- if (Number.isNaN(time)) return 360_000;-- return time;+ const processedPeriod = period.replace('PT', '');+ const numberMatch = processedPeriod.match(/[0-9]+/g);+ const unitMatch = processedPeriod.match(/[a-zA-Z]+/g);+ const time = numberMatch.reduce((acc, val, idx) => {+ const number = Number(val);+ const unit = unitMatch[idx];+ const milliseconds = number * lookup[unit?.toUpperCase?.()];+ const invalid = Number.isNaN(milliseconds);+ const valueToAdd = invalid ? (console.warn(`Invalid period: ${period}`), 0) : milliseconds;+ return acc + valueToAdd;+ }, 0);++ return time || 360_000;}/**