Skip to content

Interactive interface for browsing global, full-resolution satellite imagery

add warning for both wings, revise text, refactor out of render, add e2e

Ed Platoaa62b64f50a5
diff --git a/e2e/features/image-download/crosses-dateline-test.js b/e2e/features/image-download/crosses-dateline-test.js
new file mode 100644
index 000000000..de7ebba0f
--- /dev/null
+++ b/e2e/features/image-download/crosses-dateline-test.js
@@ -0,0 +1,55 @@
+const { normalizeViewport } = require('../../reuseables/normalize-viewport');
+const {
+ openImageDownloadPanel,
+} = require('../../reuseables/image-download');
+
+const TIME_LIMIT = 10000;
+
+const datelineAlertIcon = '.snapshot-date-alert-icon';
+const datelineAlertIconTooltipText = '.snapshot-date-warning-tooltip-inner';
+
+const withinMapURLParams = '?v=-67.80916012733559,-56.052180562072095,-30.50743102883792,-30.873513420586164&t=2021-08-08-T0';
+const crossesPrevDayURLParams = '?v=161.16767164758798,-54.46571918482002,198.46940074608565,-29.287052043334096&t=2021-08-08-T0';
+const crossesNextDayURLParams = '?v=-198.76946733086245,-59.504883811673906,-161.46773823236478,-34.326216670187975&t=2021-08-08-T0';
+
+module.exports = {
+ after(client) {
+ client.end();
+ },
+
+ 'No dateline alert icon with message if not crossing dateline(s)': (c) => {
+ normalizeViewport(c, 1024, 768);
+ c.url(c.globals.url + withinMapURLParams);
+ openImageDownloadPanel(c);
+ c.pause(500);
+
+ c.expect.element(datelineAlertIcon).to.not.be.present;
+ },
+
+ 'Dateline alert icon with previous day message if crosses previous day dateline': (c) => {
+ normalizeViewport(c, 1024, 768);
+ c.url(c.globals.url + crossesPrevDayURLParams);
+ openImageDownloadPanel(c);
+ c.pause(500);
+
+ c.expect.element(datelineAlertIcon).to.be.present;
+ c.moveToElement(datelineAlertIcon, 0, 0);
+ c.waitForElementVisible(datelineAlertIconTooltipText, TIME_LIMIT, (e) => {
+ c.assert.containsText(datelineAlertIconTooltipText, 'The selected snapshot area crosses the dateline and uses imagery from the previous day 2021 AUG 07.');
+ });
+ },
+
+ 'Dateline alert icon with next day message if crosses next day dateline': (c) => {
+ normalizeViewport(c, 1024, 768);
+ c.url(c.globals.url + crossesNextDayURLParams);
+ openImageDownloadPanel(c);
+ c.pause(500);
+
+ c.expect.element(datelineAlertIcon).to.be.present;
+ c.moveToElement(datelineAlertIcon, 0, 0);
+ c.waitForElementVisible(datelineAlertIconTooltipText, TIME_LIMIT, (e) => {
+ c.assert.containsText(datelineAlertIconTooltipText, 'The selected snapshot area crosses the dateline and uses imagery from the next day 2021 AUG 09.');
+ });
+ },
+
+};
diff --git a/e2e/features/image-download/resolutions3413-test.js b/e2e/features/image-download/resolutions3413-test.js
index ea0890d4c..0cdc3a55d 100644
--- a/e2e/features/image-download/resolutions3413-test.js
+++ b/e2e/features/image-download/resolutions3413-test.js
@@ -31,12 +31,12 @@ module.exports = {
},
'Next two zooms are 1km': function(c) {
- zoomIn(c, 'arctic');
+ zoomIn(c);
openImageDownloadPanel(c);
c.expect.element('#wv-image-resolution option[value="4"]')
.to.be.selected;
closeImageDownloadPanel(c);
- zoomIn(c, 'arctic');
+ zoomIn(c);
openImageDownloadPanel(c);
c.expect.element('#wv-image-resolution option[value="4"]')
.to.be.selected;
@@ -44,7 +44,7 @@ module.exports = {
},
'Next zoom is 500m': function(c) {
- zoomIn(c, 'arctic');
+ zoomIn(c);
openImageDownloadPanel(c);
c.expect.element('#wv-image-resolution option[value="2"]')
.to.be.selected;
@@ -52,12 +52,12 @@ module.exports = {
},
'Next zoom is 250m': function(c) {
- zoomIn(c, 'arctic');
+ zoomIn(c);
openImageDownloadPanel(c);
c.expect.element('#wv-image-resolution option[value="1"]')
.to.be.selected;
closeImageDownloadPanel(c);
- zoomIn(c, 'arctic');
+ zoomIn(c);
openImageDownloadPanel(c);
c.expect.element('#wv-image-resolution option[value="1"]')
.to.be.selected;
@@ -67,7 +67,7 @@ module.exports = {
'Last zoom level is 250m': function(c) {
// mash the zoom button a bunch of times and see if it changes
for (let i = 0; i < 5; i += 1) {
- zoomIn(c, 'arctic');
+ zoomIn(c);
}
openImageDownloadPanel(c);
c.expect.element('#wv-image-resolution option[value="1"]')
diff --git a/e2e/features/image-download/resolutions4326-test.js b/e2e/features/image-download/resolutions4326-test.js
index 462a247ba..469b8c118 100644
--- a/e2e/features/image-download/resolutions4326-test.js
+++ b/e2e/features/image-download/resolutions4326-test.js
@@ -26,7 +26,7 @@ module.exports = {
openImageDownloadPanel(c);
c.expect.element('#wv-image-resolution option[value="40"]').to.be.selected;
closeImageDownloadPanel(c);
- zoomIn(c, 'geographic');
+ zoomIn(c);
openImageDownloadPanel(c);
c.expect.element('#wv-image-resolution option[value="40"]').to.be.selected;
@@ -34,50 +34,50 @@ module.exports = {
},
'Next zoom is 5km': function(c) {
- zoomIn(c, 'geographic');
+ zoomIn(c);
openImageDownloadPanel(c);
c.expect.element('#wv-image-resolution option[value="20"]').to.be.selected;
closeImageDownloadPanel(c);
},
'Next two zooms are 1km': function(c) {
- zoomIn(c, 'geographic');
+ zoomIn(c);
openImageDownloadPanel(c);
c.expect.element('#wv-image-resolution option[value="4"]').to.be.selected;
closeImageDownloadPanel(c);
- zoomIn(c, 'geographic');
+ zoomIn(c);
openImageDownloadPanel(c);
c.expect.element('#wv-image-resolution option[value="4"]').to.be.selected;
closeImageDownloadPanel(c);
},
'Next zoom is 500m': function(c) {
- zoomIn(c, 'geographic');
+ zoomIn(c);
openImageDownloadPanel(c);
c.expect.element('#wv-image-resolution option[value="2"]').to.be.selected;
closeImageDownloadPanel(c);
},
'Next two zooms are 250m': function(c) {
- zoomIn(c, 'geographic');
+ zoomIn(c);
openImageDownloadPanel(c);
c.expect.element('#wv-image-resolution option[value="1"]').to.be.selected;
closeImageDownloadPanel(c);
- zoomIn(c, 'geographic');
+ zoomIn(c);
openImageDownloadPanel(c);
c.expect.element('#wv-image-resolution option[value="1"]').to.be.selected;
closeImageDownloadPanel(c);
},
'Next zoom is 125m': function(c) {
- zoomIn(c, 'geographic');
+ zoomIn(c);
openImageDownloadPanel(c);
c.expect.element('#wv-image-resolution option[value="0.5"]').to.be.selected;
closeImageDownloadPanel(c);
},
'Next zoom is 60m': function(c) {
- zoomIn(c, 'geographic');
+ zoomIn(c);
openImageDownloadPanel(c);
c.expect.element('#wv-image-resolution option[value="0.25"]').to.be
.selected;
@@ -85,7 +85,7 @@ module.exports = {
},
'Next zoom is 30m': function(c) {
- zoomIn(c, 'geographic');
+ zoomIn(c);
openImageDownloadPanel(c);
c.expect.element('#wv-image-resolution option[value="0.125"]').to.be
.selected;
@@ -95,7 +95,7 @@ module.exports = {
'Last zoom level is 30m': function(c) {
// mash the zoom button a bunch of times and see if it changes
for (let i = 0; i < 5; i += 1) {
- zoomIn(c, 'geographic');
+ zoomIn(c);
}
openImageDownloadPanel(c);
c.expect.element('#wv-image-resolution option[value="0.125"]').to.be
diff --git a/e2e/reuseables/zoom.js b/e2e/reuseables/zoom.js
index 8983ad988..f66820190 100644
--- a/e2e/reuseables/zoom.js
+++ b/e2e/reuseables/zoom.js
@@ -1,5 +1,5 @@
module.exports = {
- zoomIn(c, proj) {
+ zoomIn(c) {
c.click('button.wv-map-zoom-in');
c.pause(300);
},
diff --git a/web/js/components/image-download/panel.js b/web/js/components/image-download/panel.js
index 7e40a49ee..d065647f2 100644
--- a/web/js/components/image-download/panel.js
+++ b/web/js/components/image-download/panel.js
@@ -7,7 +7,6 @@ import {
getDimensions,
getDownloadUrl,
} from '../../modules/image-download/util';
-import util from '../../util/util';
import SelectionList from '../util/selector';
import ResTable from './grid';
import HoverTooltip from '../util/hover-tooltip';
@@ -148,7 +147,7 @@ export default class ImageResSelection extends React.Component {
}
}
- getDatelineMessage() {
+ getDatelineAlertIcon() {
const { datelineMessage } = this.props;
return datelineMessage && (
<div
@@ -174,7 +173,7 @@ export default class ImageResSelection extends React.Component {
render() {
const {
- date, getLayers, hasSubdailyLayers, projection, lonlats, resolutions, maxImageSize, firstLabel,
+ getLayers, projection, lonlats, resolutions, maxImageSize, firstLabel,
} = this.props;
const { resolution, debugUrl } = this.state;
const dimensions = getDimensions(projection.id, lonlats, resolution);
@@ -183,7 +182,6 @@ export default class ImageResSelection extends React.Component {
const filetypeSelect = this._renderFileTypeSelect();
const worldfileSelect = this._renderWorldfileSelect();
const layerList = getLayers();
- const displayDate = util.toISOStringDateMonthAbbrev(date, hasSubdailyLayers);
return (
<div className="wv-re-pick-wrapper wv-image">
@@ -192,12 +190,6 @@ export default class ImageResSelection extends React.Component {
style={{ display: 'none' }}
url={debugUrl}
/>
- <div className="wv-image-header snapshots-date-header">
- <div className="date-text">
- Date:&nbsp;
- {displayDate}
- </div>
- </div>
<div className="wv-image-header">
<SelectionList
id="wv-image-resolution"
@@ -219,7 +211,7 @@ export default class ImageResSelection extends React.Component {
validLayers={layerList.length > 0}
onClick={this.onDownload}
/>
- {this.getDatelineMessage()}
+ {this.getDatelineAlertIcon()}
</div>
);
}
@@ -243,7 +235,6 @@ ImageResSelection.propTypes = {
fileTypes: PropTypes.object,
firstLabel: PropTypes.string,
getLayers: PropTypes.func,
- hasSubdailyLayers: PropTypes.bool,
isWorldfile: PropTypes.bool,
lonlats: PropTypes.array,
maxImageSize: PropTypes.string,
diff --git a/web/js/containers/image-download.js b/web/js/containers/image-download.js
index 5a3084017..9681428ab 100644
--- a/web/js/containers/image-download.js
+++ b/web/js/containers/image-download.js
@@ -8,6 +8,7 @@ import Crop from '../components/util/image-crop';
import { onToggle } from '../modules/modal/actions';
import ErrorBoundary from './error-boundary';
import {
+ getAlertMessageIfCrossesDateline,
imageUtilCalculateResolution,
imageUtilGetCoordsFromPixelValues,
} from '../modules/image-download/util';
@@ -92,7 +93,7 @@ class ImageDownloadContainer extends Component {
boundaries,
map.ui.selected,
);
- const { crs, maxExtent } = proj.selected;
+ const { crs } = proj.selected;
const geolonlat1 = olProj.transform(lonlats[0], crs, 'EPSG:4326');
const geolonlat2 = olProj.transform(lonlats[1], crs, 'EPSG:4326');
@@ -104,22 +105,6 @@ class ImageDownloadContainer extends Component {
);
const boxTopLongitude = Math.abs(geolonlat1[0]) > 180 ? util.normalizeWrappedLongitude(geolonlat1[0]) : geolonlat1[0];
const boxBottomLongitude = Math.abs(geolonlat2[0]) > 180 ? util.normalizeWrappedLongitude(geolonlat2[0]) : geolonlat2[0];
-
- let datelineMessage = '';
- if (isGeoProjection) {
- // min longitude less than maxExtent min longitude (-180 geographic)
- if (geolonlat1[0] < maxExtent[0]) {
- const nextDay = util.toISOStringDateMonthAbbrev(util.dateAdd(util.clearTimeUTC(date), 'day', 1));
- datelineMessage = `Part of the selected snapshot crossed the dateline and uses imagery from the next day ${nextDay}.`;
- }
-
- // max longitude greater than maxExtent max longitude (180 geographic)
- if (geolonlat2[0] > maxExtent[2]) {
- const prevDay = util.toISOStringDateMonthAbbrev(util.dateAdd(util.clearTimeUTC(date), 'day', -1));
- datelineMessage = `Part of the selected snapshot crossed the dateline and uses imagery from the previous day ${prevDay}.`;
- }
- }
-
return (
<ErrorBoundary>
<Panel
@@ -133,7 +118,7 @@ class ImageDownloadContainer extends Component {
hasSubdailyLayers={hasSubdailyLayers}
markerCoordinates={markerCoordinates}
date={date}
- datelineMessage={datelineMessage}
+ datelineMessage={getAlertMessageIfCrossesDateline(date, geolonlat1, geolonlat2, proj)}
url={url}
crs={crs}
getLayers={getLayers}
diff --git a/web/js/modules/image-download/util.js b/web/js/modules/image-download/util.js
index eba7b366c..7596d777f 100644
--- a/web/js/modules/image-download/util.js
+++ b/web/js/modules/image-download/util.js
@@ -50,7 +50,7 @@ const imageUtilProcessKMZOrbitTracks = function(layersArray, layerWraps, opaciti
if (layerId.includes('OrbitTracks')) {
// track index for modifications from splicing
const idx = i + mod;
- // revise OrbitTracks layerId requested to indiviudal 'Lines' and 'Points' layers
+ // revise OrbitTracks layerId requested to individual 'Lines' and 'Points' layers
// ex: 'OrbitTracks_Aqua_Ascending' is revised in the request as:
// 'OrbitTracks_Aqua_Ascending_Points' and 'OrbitTracks_Aqua_Ascending_Lines'
processedLayersArray.splice(idx, 1, `${layerId}_Lines`, `${layerId}_Points`);
@@ -387,7 +387,7 @@ export function getNamesOfNondownloadableLayers(nonDownloadableLayers) {
return names;
}
/**
- * Get warning that shows layers that will be removed if nofication is accepted
+ * Get warning that shows layers that will be removed if notification is accepted
* @param {Array} nonDownloadableLayers
*
* @return {String}
@@ -401,7 +401,7 @@ export function getNonDownloadableLayerWarning(nonDownloadableLayer) {
return `The ${layerStr} ${layerPluralStr} cannot be included in a snapshot. Would you like to temporarily hide ${thisTheseStr} layer?`;
}
/**
- * Get array of layers that will be removed if nofication is accepted
+ * Get array of layers that will be removed if notification is accepted
* @param {Array} visibleLayers
*
* @return {Array}
@@ -409,3 +409,35 @@ export function getNonDownloadableLayerWarning(nonDownloadableLayer) {
export function getNonDownloadableLayers(visibleLayers) {
return visibleLayers.filter(({ disableSnapshot = false }) => disableSnapshot);
}
+/**
+ * Get dateline message for selecting snapshot area
+ * @param {Object} date
+ * @param {Array} geolonlat1
+ * @param {Array} geolonlat2
+ * @param {Object} proj
+ *
+ * @return {String}
+ */
+export function getAlertMessageIfCrossesDateline(date, geolonlat1, geolonlat2, proj) {
+ const { maxExtent, id } = proj.selected;
+ let alertMessage = '';
+ if (id === 'geographic') {
+ const crossesNextDay = geolonlat1[0] < maxExtent[0];
+ const crossesPrevDay = geolonlat2[0] > maxExtent[2];
+ const zeroedDate = util.clearTimeUTC(date);
+ const nextDay = util.toISOStringDateMonthAbbrev(util.dateAdd(zeroedDate, 'day', 1));
+ const prevDay = util.toISOStringDateMonthAbbrev(util.dateAdd(zeroedDate, 'day', -1));
+ const buildString = (lineStr, dateStr) => `The selected snapshot area crosses ${lineStr} and uses imagery from the ${dateStr}.`;
+ if (crossesNextDay && crossesPrevDay) {
+ // snapshot extends over both map wings
+ alertMessage = buildString('both datelines', `previous day ${prevDay} and next day ${nextDay}`);
+ } else if (crossesNextDay) {
+ // min longitude less than maxExtent min longitude (-180 geographic)
+ alertMessage = buildString('the dateline', `next day ${nextDay}`);
+ } else if (crossesPrevDay) {
+ // max longitude greater than maxExtent max longitude (180 geographic)
+ alertMessage = buildString('the dateline', `previous day ${prevDay}`);
+ }
+ }
+ return alertMessage;
+}