Skip to content

Interactive interface for browsing global, full-resolution satellite imagery

WV-2318 (#3924)

Jason Kent30494b74b9fc
diff --git a/web/js/components/smart-handoffs/granule-count.js b/web/js/components/smart-handoffs/granule-count.js
index 73e33642c..d20a33fad 100644
--- a/web/js/components/smart-handoffs/granule-count.js
+++ b/web/js/components/smart-handoffs/granule-count.js
@@ -8,8 +8,9 @@ export default function GranuleCount (props) {
currentExtent,
getGranulesUrl,
displayDate,
+ startDate,
+ endDate,
showGranuleHelpModal,
- selectedLayer,
selectedCollection,
selectedDate,
} = props;
@@ -46,14 +47,15 @@ export default function GranuleCount (props) {
let newTotalGranules = 0;
let newSelectedGranules;
let newGranuleDownloadSize = 0;
- const { dateRanges } = selectedLayer;
+
const params = {
conceptId: selectedCollection.value,
pageSize: 500,
};
- if (dateRanges) {
- params.startDate = `${selectedDate}T00:00:00.000Z`;
- params.endDate = `${selectedDate}T23:59:59.999Z`;
+
+ if (startDate && endDate) {
+ params.startDate = startDate;
+ params.endDate = endDate;
}
const granulesRequestUrl = getGranulesUrl(params);
@@ -155,7 +157,8 @@ GranuleCount.propTypes = {
getGranulesUrl: PropTypes.func,
currentExtent: PropTypes.object,
displayDate: PropTypes.string,
- selectedLayer: PropTypes.object,
+ startDate: PropTypes.string,
+ endDate: PropTypes.string,
selectedDate: PropTypes.string,
selectedCollection: PropTypes.object,
showGranuleHelpModal: PropTypes.func,
diff --git a/web/js/containers/sidebar/smart-handoff.js b/web/js/containers/sidebar/smart-handoff.js
index 7d94cdaf9..3b036f9ad 100644
--- a/web/js/containers/sidebar/smart-handoff.js
+++ b/web/js/containers/sidebar/smart-handoff.js
@@ -19,6 +19,7 @@ import GranuleAlertModalBody from '../../components/smart-handoffs/smart-handoff
import GranuleCount from '../../components/smart-handoffs/granule-count';
import { imageUtilGetCoordsFromPixelValues } from '../../modules/image-download/util';
import { onClose, openCustomContent } from '../../modules/modal/actions';
+import { getActiveGranuleLayers } from '../../modules/layers/selectors';
import {
getValidLayersForHandoffs,
getConceptUrl as getConceptUrlSelector,
@@ -26,7 +27,7 @@ import {
} from '../../modules/smart-handoff/selectors';
import { getSelectedDate } from '../../modules/date/selectors';
import safeLocalStorage from '../../util/local-storage';
-import openEarthDataSearch from '../../modules/smart-handoff/util';
+import openEarthDataSearch, { getStartEndDates } from '../../modules/smart-handoff/util';
import {
selectCollection as selectCollectionAction,
fetchAvailableTools as fetchAvailableToolsAction,
@@ -253,10 +254,12 @@ class SmartHandoff extends Component {
const {
availableTools,
displayDate,
+ isGranuleLayer,
proj,
- selectedDate,
selectedLayer,
selectedCollection,
+ startDate,
+ endDate,
showWarningModal,
} = this.props;
const {
@@ -264,27 +267,31 @@ class SmartHandoff extends Component {
showBoundingBox,
} = this.state;
- // Used to determine if the added smart-handoff modal should be shown
+ // Used to determine if the smart-handoff modal should be shown
const { HIDE_EDS_WARNING } = safeLocalStorage.keys;
const hideModal = safeLocalStorage.getItem(HIDE_EDS_WARNING);
- const { dateRanges } = selectedLayer;
- const includeDates = dateRanges && dateRanges.length;
+ let useDisplayDate = displayDate;
+
+ if (isGranuleLayer) {
+ const formatGranuleStart = formatDisplayDate(startDate, isGranuleLayer);
+ const formatGranuleEnd = formatDisplayDate(endDate, isGranuleLayer);
+ useDisplayDate = `${formatGranuleStart} - ${formatGranuleEnd}`;
+ }
const continueToEDS = () => {
const options = {
projection: proj.crs,
conceptId: selectedCollection.value,
currentExtent,
- includeDates,
- selectedDate,
- selectedCollection,
showBoundingBox,
+ startDate,
+ endDate,
};
return openEarthDataSearch(availableTools, options);
};
if (!hideModal) {
- showWarningModal(displayDate, selectedLayer, selectedCollection, continueToEDS);
+ showWarningModal(useDisplayDate, selectedLayer, selectedCollection, continueToEDS);
} else {
continueToEDS();
}
@@ -540,11 +547,14 @@ class SmartHandoff extends Component {
displayDate,
getGranulesUrl,
isLoading,
+ granuleLayers,
showNotAvailableModal,
selectedLayer,
selectedCollection,
selectedDate,
showGranuleHelpModal,
+ startDate,
+ endDate,
validatedLayers,
} = this.props;
const {
@@ -584,9 +594,11 @@ class SmartHandoff extends Component {
{isValidDownload && (
<GranuleCount
displayDate={displayDate}
+ granuleLayers={granuleLayers}
currentExtent={isValidDownload && showBoundingBox ? currentExtent : undefined}
selectedDate={selectedDate}
- selectedLayer={selectedLayer}
+ startDate={startDate}
+ endDate={endDate}
selectedCollection={selectedCollection}
showGranuleHelpModal={showGranuleHelpModal}
getGranulesUrl={getGranulesUrl}
@@ -613,12 +625,17 @@ const mapStateToProps = (state) => {
} = smartHandoffs;
const { screenWidth, screenHeight } = browser;
+ const granuleLayers = getActiveGranuleLayers(state);
const selectedDate = getSelectedDate(state);
const selectedDateFormatted = moment.utc(selectedDate).format('YYYY-MM-DD'); // 2020-01-01
const availableLayers = getValidLayersForHandoffs(state);
const selectedLayer = availableLayers.find(({ id }) => id === layerId);
const selectedCollection = selectedLayer && (selectedLayer.conceptIds || []).find(({ value }) => value === conceptId);
const isLoading = isLoadingTools || isValidatingCollections;
+ const isGranuleLayer = selectedLayer && selectedLayer.type === 'granule';
+ const { startDate, endDate } = selectedLayer
+ ? getStartEndDates(selectedLayer, selectedDate, granuleLayers)
+ : {};
return {
availableLayers,
@@ -626,6 +643,8 @@ const mapStateToProps = (state) => {
getConceptUrl: getConceptUrlSelector(state),
getGranulesUrl: getGranulesUrlSelector(state),
isLoading,
+ isGranuleLayer,
+ granuleLayers,
map,
proj: proj.selected,
requestFailed,
@@ -634,6 +653,8 @@ const mapStateToProps = (state) => {
selectedDate: selectedDateFormatted,
selectedLayer,
selectedCollection,
+ startDate,
+ endDate,
availableTools,
validatedConceptIds,
validatedLayers,
@@ -704,8 +725,11 @@ SmartHandoff.propTypes = {
availableTools: PropTypes.array,
displayDate: PropTypes.string,
isLoading: PropTypes.bool,
+ isGranuleLayer: PropTypes.bool,
+ endDate: PropTypes.string,
getConceptUrl: PropTypes.func,
getGranulesUrl: PropTypes.func,
+ granuleLayers: PropTypes.object,
map: PropTypes.object.isRequired,
proj: PropTypes.object,
fetchAvailableTools: PropTypes.func,
@@ -719,6 +743,7 @@ SmartHandoff.propTypes = {
showWarningModal: PropTypes.func,
showGranuleHelpModal: PropTypes.func,
showNotAvailableModal: PropTypes.func,
+ startDate: PropTypes.string,
validatedLayers: PropTypes.array,
validatedConceptIds: PropTypes.object,
validateLayersConceptIds: PropTypes.func,
diff --git a/web/js/modules/layers/selectors.js b/web/js/modules/layers/selectors.js
index fd35b2cae..6795b6dcf 100644
--- a/web/js/modules/layers/selectors.js
+++ b/web/js/modules/layers/selectors.js
@@ -23,9 +23,6 @@ const getLayerId = (state, { layer }) => layer && layer.id;
export const getStartingLayers = createSelector([getConfig], (config) => resetLayers(config));
-/**
- * Is overlay grouping currently enabled?
- */
export const isGroupingEnabled = ({ compare, layers }) => layers[compare.activeString].groupOverlays;
/**
diff --git a/web/js/modules/smart-handoff/util.js b/web/js/modules/smart-handoff/util.js
index 66e1a32eb..cf5ba8aa5 100644
--- a/web/js/modules/smart-handoff/util.js
+++ b/web/js/modules/smart-handoff/util.js
@@ -2,18 +2,48 @@
import { get } from 'lodash';
import googleTagManager from 'googleTagManager';
import { parseTemplate } from 'url-template';
+import moment from 'moment';
+
import { TOOLS_EARTHDATA_SEARCH } from './constants';
+/**
+ * Get startDate and endDate used for granule count query and handoff to EDS
+ *
+ * @param {*} layer
+ * @param {*} selectedDate
+ * @param {*} granuleLayers
+ * @returns
+ */
+export const getStartEndDates = (layer, selectedDate, granuleLayers) => {
+ const { type, id } = layer;
+ let startDate;
+ let endDate;
+
+ if (type === 'granule' && Object.keys(granuleLayers).length > 0) {
+ const granuleDates = granuleLayers[id] && granuleLayers[id].dates;
+ const start = granuleDates[0];
+ const end = granuleDates[granuleDates.length - 1];
+ startDate = `${moment.utc(start).format('YYYY-MM-DDTHH:mm:ss.SSS')}Z`;
+ endDate = `${moment.utc(end).format('YYYY-MM-DDTHH:mm:ss.SSS')}Z`;
+ } else {
+ startDate = `${moment.utc(selectedDate).format('YYYY-MM-DD')}T00:00:00.000Z`;
+ endDate = `${moment.utc(selectedDate).format('YYYY-MM-DD')}T23:59:59.999Z`;
+ }
+
+ return {
+ startDate,
+ endDate,
+ };
+};
+
function getHandoffParams (queryInput, options) {
const {
- projection, conceptId, includeDates, selectedDate, currentExtent, showBoundingBox,
+ projection, conceptId, startDate, endDate, currentExtent, showBoundingBox,
} = options;
const getParam = ({ ValueType, ValueName }) => {
if (ValueType === 'temporalRange') {
- if (includeDates) {
- const startDate = `${selectedDate}T00:00:00.000Z`;
- const endDate = `${selectedDate}T23:59:59.999Z`;
+ if (startDate && endDate) {
return {
[ValueName]: `${startDate},${endDate}`,
};
@@ -55,6 +85,7 @@ export function parseSmartHandoff(state) {
conceptId,
};
}
+
export function serializeSmartHandoff(currentItemState, state) {
const activeTab = get(state, 'sidebar.activeTab');
const { layerId, conceptId } = currentItemState;