Skip to content

Interactive interface for browsing global, full-resolution satellite imagery

Revert "WV-2870 Allow users to create image snapshots of modified classificat…" (#5600)

Patrick Moulden8c1dbb102b8e
diff --git a/e2e/features/image-download/unsupported-test.spec.js b/e2e/features/image-download/unsupported-test.spec.js
index 2ca858547..cce0c6a18 100644
--- a/e2e/features/image-download/unsupported-test.spec.js
+++ b/e2e/features/image-download/unsupported-test.spec.js
@@ -1,7 +1,7 @@
// @ts-check
const { test, expect } = require('@playwright/test')
const createSelectors = require('../../test-utils/global-variables/selectors')
-const { closeModal } = require('../../test-utils/hooks/wvHooks')
+const { closeImageDownloadPanel, closeModal } = require('../../test-utils/hooks/wvHooks')
const { joinUrl } = require('../../test-utils/hooks/basicHooks')
let page
@@ -28,6 +28,31 @@ test.afterAll(async () => {
await page.close()
})
+test('Custom palettes are not supported dialog', async () => {
+ const { snapshotToolbarButton } = selectors
+ const url = await joinUrl(startParams, '&l=MODIS_Terra_Aerosol(palette=red_1)')
+ await page.goto(url)
+ await closeModal(page)
+ await snapshotToolbarButton.click()
+ await expect(notify).toBeVisible()
+})
+
+test('Custom palettes: Cancel button', async () => {
+ await cancelNotify.click()
+ await expect(notify).not.toBeVisible()
+ await expect(toolbarSnapshot).not.toBeVisible()
+})
+
+test('Custom palettes: OK button brings up download panel', async () => {
+ const { snapshotToolbarButton } = selectors
+ await snapshotToolbarButton.click()
+ await expect(notify).toBeVisible()
+ await acceptNotify.click()
+ await expect(notify).not.toBeVisible()
+ await expect(toolbarSnapshot).toBeVisible()
+ await closeImageDownloadPanel(page)
+})
+
test('Rotation is not supported dialog', async () => {
const { snapshotToolbarButton } = selectors
const url = await joinUrl(startParams, '&p=arctic&r=18')
diff --git a/web/js/components/image-download/image-download-panel.js b/web/js/components/image-download/image-download-panel.js
index 75b0f29a9..8dc415a73 100644
--- a/web/js/components/image-download/image-download-panel.js
+++ b/web/js/components/image-download/image-download-panel.js
@@ -1,8 +1,6 @@
import React, { useState, useEffect } from 'react';
-import { useSelector } from 'react-redux';
import PropTypes from 'prop-types';
import googleTagManager from 'googleTagManager';
-import { getActivePalettes } from '../../modules/palettes/selectors';
import {
imageSizeValid,
getDimensions,
@@ -59,7 +57,6 @@ function ImageDownloadPanel(props) {
const [currResolution, setResolution] = useState(resolution);
const [debugUrl, setDebugUrl] = useState('');
const [showGranuleWarning, setShowGranuleWarning] = useState(false);
- const activePalettes = useSelector((state) => getActivePalettes(state, state.compare.activeString));
useEffect(() => {
const layerList = getLayers();
@@ -86,7 +83,6 @@ function ImageDownloadPanel(props) {
currFileType,
currFileType === 'application/vnd.google-earth.kmz' ? false : currIsWorldfile,
markerCoordinates,
- activePalettes,
);
window.open(dlURL, '_blank');
diff --git a/web/js/containers/toolbar.js b/web/js/containers/toolbar.js
index f55953e5f..816fd9cd4 100644
--- a/web/js/containers/toolbar.js
+++ b/web/js/containers/toolbar.js
@@ -21,7 +21,7 @@ import {
requestNotifications,
setNotifications,
} from '../modules/notifications/actions';
-import { refreshPalettes } from '../modules/palettes/actions';
+import { clearCustoms, refreshPalettes } from '../modules/palettes/actions';
import { clearRotate, refreshRotation } from '../modules/map/actions';
import {
showLayers, hideLayers,
@@ -136,6 +136,7 @@ class toolbarContainer extends Component {
const nonDownloadableLayers = hasNonDownloadableLayer ? getNonDownloadableLayers(visibleLayersForProj) : null;
const paletteStore = lodashCloneDeep(activePalettes);
toggleDialogVisible(false);
+ await this.getPromise(hasCustomPalette, 'palette', clearCustoms, 'Notice');
await this.getPromise(isRotated, 'rotate', clearRotate, 'Reset rotation');
await this.getPromise(hasNonDownloadableLayer, 'layers', hideLayers, 'Remove Layers?');
await openModal(
diff --git a/web/js/modules/image-download/util.js b/web/js/modules/image-download/util.js
index 14c143f07..c975bb458 100644
--- a/web/js/modules/image-download/util.js
+++ b/web/js/modules/image-download/util.js
@@ -1,4 +1,5 @@
import {
+ each as lodashEach,
get as lodashGet,
} from 'lodash';
import { transform } from 'ol/proj';
@@ -178,21 +179,18 @@ export function imageUtilCalculateResolution(
* @returns {array} array of layer ids
*
*/
-export function imageUtilGetLayers(products, proj, activePalettes) {
- const layers = products.map((layer) => {
- let layerId = layer.id;
+export function imageUtilGetLayers(products, proj) {
+ const layers = [];
+ lodashEach(products, (layer) => {
if (layer.downloadId) {
- layerId = layer.downloadId;
+ layers.push(layer.downloadId);
} else if (layer.projections[proj].id) {
- layerId = layer.projections[proj].id;
+ layers.push(layer.projections[proj].id);
} else if (layer.projections[proj].layer) {
- layerId = layer.projections[proj].layer;
- }
- const disabled = activePalettes?.[layer.id]?.maps?.[0]?.disabled;
- if (Array.isArray(disabled)) {
- return `${layerId}(disabled=${disabled.join('-')})`;
+ layers.push(layer.projections[proj].layer);
+ } else {
+ layers.push(layer.id);
}
- return layerId;
});
return layers;
}
@@ -308,7 +306,7 @@ export function getTruncatedGranuleDates(layerDefs) {
* @param {Boolean} isWorldfile
* @param {Array} markerCoordinates
*/
-export function getDownloadUrl(url, proj, layerDefs, bbox, dimensions, dateTime, fileType, isWorldfile, markerCoordinates, activePalettes) {
+export function getDownloadUrl(url, proj, layerDefs, bbox, dimensions, dateTime, fileType, isWorldfile, markerCoordinates) {
const { crs } = proj.selected;
const {
layersArray,
@@ -316,7 +314,7 @@ export function getDownloadUrl(url, proj, layerDefs, bbox, dimensions, dateTime,
opacities,
} = imageUtilProcessWrap(
fileType,
- imageUtilGetLayers(layerDefs, proj.id, activePalettes),
+ imageUtilGetLayers(layerDefs, proj.id),
imageUtilGetLayerWrap(layerDefs),
imageUtilGetLayerOpacities(layerDefs),
);
@@ -325,7 +323,6 @@ export function getDownloadUrl(url, proj, layerDefs, bbox, dimensions, dateTime,
const { height, width } = dimensions;
const snappedDateTime = getLatestIntervalTime(layerDefs, dateTime);
const granuleDates = getTruncatedGranuleDates(layerDefs).value;
- const colormaps = layerDefs.map((layer) => layer.palette?.id);
const params = [
'REQUEST=GetSnapshot',
`TIME=${util.toISOStringSeconds(snappedDateTime)}`,
@@ -337,9 +334,6 @@ export function getDownloadUrl(url, proj, layerDefs, bbox, dimensions, dateTime,
`WIDTH=${width}`,
`HEIGHT=${height}`,
];
- if (Array.isArray(colormaps) && colormaps.length > 0) {
- params.push(`colormaps=${colormaps.join(',')}`);
- }
if (granuleDates.length > 0) {
params.push(`granule_dates=${granuleDates}`);
}
diff --git a/web/js/modules/image-download/util.test.js b/web/js/modules/image-download/util.test.js
index e422b96b9..f791c7a49 100644
--- a/web/js/modules/image-download/util.test.js
+++ b/web/js/modules/image-download/util.test.js
@@ -218,7 +218,7 @@ test('Download URL [imagedownload-url]', () => {
{ id: 1, longitude: 2.7117, latitude: -19.1609 },
{ id: 2, longitude: 71.173, latitude: -39.0961 },
];
- const dlURL = getDownloadUrl(url, proj, mockLayerDefs, lonlats, dimensions, dateTime, false, false, locationMarkers, undefined);
+ const dlURL = getDownloadUrl(url, proj, mockLayerDefs, lonlats, dimensions, dateTime, false, false, locationMarkers);
const expectedURL = 'http://localhost:3002/api/v1/snapshot'
+ '?REQUEST=GetSnapshot'
+ '&TIME=2019-06-24T00:00:00Z'
@@ -228,7 +228,6 @@ test('Download URL [imagedownload-url]', () => {
+ '&WRAP=day'
+ '&FORMAT=image/jpeg'
+ '&WIDTH=300&HEIGHT=300'
- + '&colormaps='
+ '&MARKER=2.7117,-19.1609,71.173,-39.0961';
expect(dlURL.includes(expectedURL)).toBe(true);
});
diff --git a/web/js/modules/palettes/selectors.js b/web/js/modules/palettes/selectors.js
index bc37141fe..e3962bdba 100644
--- a/web/js/modules/palettes/selectors.js
+++ b/web/js/modules/palettes/selectors.js
@@ -504,7 +504,3 @@ export function isPaletteAllowed(layerId, config) {
}
return Boolean(config.layers[layerId].palette);
}
-
-export function getActivePalettes (state, activeString) {
- return state.palettes[activeString];
-}