Skip to content

Interactive interface for browsing global, full-resolution satellite imagery

Alternate EIC Approach (#4422)

Ryan Weilera39933148df3
diff --git a/package-lock.json b/package-lock.json
index 19b38b78f..dbcd72d97 100644
--- a/package-lock.json
+++ b/package-lock.json
@@ -7919,7 +7919,8 @@
},
"node_modules/file-saver": {
"version": "2.0.5",
- "license": "MIT"
+ "resolved": "https://registry.npmjs.org/file-saver/-/file-saver-2.0.5.tgz",
+ "integrity": "sha512-P9bmyZ3h/PRG+Nzga+rbdI4OEpNDzAVyy74uVO9ATgzLK6VtAsYybF/+TOCvrc0MO793d6+42lLyZTw7/ArVzA=="
},
"node_modules/fill-range": {
"version": "7.0.1",
@@ -22508,7 +22509,9 @@
}
},
"file-saver": {
- "version": "2.0.5"
+ "version": "2.0.5",
+ "resolved": "https://registry.npmjs.org/file-saver/-/file-saver-2.0.5.tgz",
+ "integrity": "sha512-P9bmyZ3h/PRG+Nzga+rbdI4OEpNDzAVyy74uVO9ATgzLK6VtAsYybF/+TOCvrc0MO793d6+42lLyZTw7/ArVzA=="
},
"fill-range": {
"version": "7.0.1",
diff --git a/web/js/containers/animation-widget/animation-widget.js b/web/js/containers/animation-widget/animation-widget.js
index e8aca2334..510559366 100644
--- a/web/js/containers/animation-widget/animation-widget.js
+++ b/web/js/containers/animation-widget/animation-widget.js
@@ -377,8 +377,6 @@ const mapStateToProps = (state) => {
const hasFutureLayers = activeLayersForProj.filter((layer) => layer.futureTime).length > 0;
const layerDateRange = getDateRange({}, activeLayersForProj);
- const isAntarctic = proj.id === 'arctic';
-
const minDate = new Date(config.startDate);
let maxDate;
if (layerDateRange && layerDateRange.end > appNow) {
@@ -390,7 +388,7 @@ const mapStateToProps = (state) => {
const {
isDistractionFreeModeActive, isKioskModeActive, animationAvailabilityChecked, eic,
} = ui;
- const checkAnimationAvailability = (eic === 'sa' || eic === 'da') && !animationAvailabilityChecked && isKioskModeActive && isPlaying && !isAntarctic;
+ const checkAnimationAvailability = (eic === 'sa' || eic === 'da') && !animationAvailabilityChecked && isKioskModeActive && isPlaying;
const { isEmbedModeActive } = embed;
const animationIsActive = isActive
&& lodashGet(map, 'ui.selected.frameState_')
diff --git a/web/js/map/layerbuilder.js b/web/js/map/layerbuilder.js
index c93d0edcf..7dda8a2f2 100644
--- a/web/js/map/layerbuilder.js
+++ b/web/js/map/layerbuilder.js
@@ -24,12 +24,9 @@ import {
createVectorUrl,
getGeographicResolutionWMS,
mergeBreakpointLayerAttributes,
- formatReduxDate,
- extractDateFromTileErrorURL,
} from './util';
import { datesInDateRanges, prevDateInDateRange } from '../modules/layers/util';
import { updateLayerDateCollection, updateLayerCollection } from '../modules/layers/actions';
-import { setErrorTiles } from '../modules/ui/actions';
import { getCollections } from '../modules/layers/selectors';
import { getSelectedDate } from '../modules/date/selectors';
import {
@@ -42,26 +39,13 @@ import {
getKey as getVectorStyleKeys,
applyStyle,
} from '../modules/vector-styles/selectors';
-import {
- nearestInterval,
-} from '../modules/layers/util';
+import { nearestInterval } from '../modules/layers/util';
import {
LEFT_WING_EXTENT, RIGHT_WING_EXTENT, LEFT_WING_ORIGIN, RIGHT_WING_ORIGIN, CENTER_MAP_ORIGIN,
} from '../modules/map/constants';
export default function mapLayerBuilder(config, cache, store) {
const { getGranuleLayer } = granuleLayerBuilder(cache, store, createLayerWMTS);
- // keep track of each tile that returned an error
- const errorTiles = {
- dailyTiles: [],
- subdailyTiles: [],
- blankTiles: [],
- kioskTileCount: 0,
- lastCheckedDate: null,
- };
-
- // list of layer id's to check for blank tiles in blobs
- const kioskCheckForBlankTilesList = ['VIIRS_SNPP_DayNightBand_At_Sensor_Radiance', 'VIIRS_SNPP_CorrectedReflectance_TrueColor', 'MODIS_Terra_CorrectedReflectance_TrueColor', 'IMERG_Precipitation_Rate', 'GHRSST_L4_MUR_Sea_Surface_Temperature', 'MODIS_Aqua_L3_Land_Surface_Temp_Daily_Day'];
/**
* Return a layer, or layergroup, created with the supplied function
@@ -120,40 +104,6 @@ export default function mapLayerBuilder(config, cache, store) {
store.dispatch(updateLayerCollection(id));
};
- // called from tileLoadFunction() when a tile returns an error
- const handleTileError = async (tile, layer, sourceURL) => {
- const state = store.getState();
- const { isKioskModeActive } = state.ui;
-
- if (isKioskModeActive) {
- const { selected: reduxDate } = state.date;
- const { id, layerPeriod } = layer;
- const isSubdailyLayer = layerPeriod === 'Subdaily';
- const urlDate = extractDateFromTileErrorURL(sourceURL);
- const currentDate = formatReduxDate(reduxDate, urlDate, isSubdailyLayer);
-
- errorTiles.lastCheckedDate = reduxDate;
-
- // we don't want to store cached dates in the error tiles
- if (urlDate === currentDate) {
- const matrixColRow = tile.tileCoord;
- const errorObj = {
- id,
- layerPeriod,
- date: urlDate,
- matrixColRow,
- sourceURL,
- };
-
- if (isSubdailyLayer) {
- errorTiles.subdailyTiles.push(errorObj);
- } else {
- errorTiles.dailyTiles.push(errorObj);
- }
- }
- }
- };
-
/**
* We define our own tile loading function in order to capture custom header values
*
@@ -162,22 +112,9 @@ export default function mapLayerBuilder(config, cache, store) {
*/
const tileLoadFunction = (layer, layerDate) => async function(tile, src) {
const state = store.getState();
- const { ui: { isKioskModeActive } } = state;
const date = layerDate.toISOString().split('T')[0];
- const checkBlobTiles = (headers) => {
- if (isKioskModeActive && kioskCheckForBlankTilesList.includes(layer.id)) {
- errorTiles.kioskTileCount += 1;
- const contentLength = headers.get('content-length');
- const contentType = headers.get('content-type');
- const sizeThreshold = contentType === 'image/png' ? 2000 : 5000;
- if (parseInt(contentLength, 10) < sizeThreshold) {
- errorTiles.blankTiles.push({ id: layer.id, contentLength, date });
- }
- }
- };
-
const updateCollections = (headers) => {
const actualId = headers.get('layer-identifier-actual');
if (!actualId) return;
@@ -199,19 +136,12 @@ export default function mapLayerBuilder(config, cache, store) {
const data = await response.blob();
updateCollections(response.headers);
- // checking for blank tiles in kiosk mode for predefined layers
- if (isKioskModeActive && kioskCheckForBlankTilesList.includes(layer.id)) {
- checkBlobTiles(response.headers);
- }
-
if (data !== undefined) {
tile.getImage().src = URL.createObjectURL(data);
} else {
- handleTileError(tile, layer, src);
tile.setState(TileState.ERROR);
}
} catch (e) {
- handleTileError(tile, layer, src);
tile.setState(TileState.ERROR);
}
};
@@ -306,11 +236,7 @@ export default function mapLayerBuilder(config, cache, store) {
const createLayer = async (def, options = {}) => {
const state = store.getState();
const { compare: { activeString } } = state;
- const {
- ui: { isKioskModeActive, displayStaticMap },
- animation: { isPlaying },
- map: { rendered },
- } = state;
+ const { ui: { isKioskModeActive, displayStaticMap } } = state;
options.group = options.group || activeString;
@@ -333,8 +259,6 @@ export default function mapLayerBuilder(config, cache, store) {
const key = layerKey(def, options, state);
const layer = await createLayerWrapper(def, key, options, dateOptions);
- if (isKioskModeActive && !isPlaying && rendered) store.dispatch(setErrorTiles(errorTiles));
-
return layer;
};
@@ -521,6 +445,7 @@ export default function mapLayerBuilder(config, cache, store) {
return layer;
};
+
/**
* Create a new WMTS Layer
* @method createLayerWMTS
@@ -592,6 +517,7 @@ export default function mapLayerBuilder(config, cache, store) {
sourceOptions.tileClass = lookupFactory(lookup, sourceOptions);
}
const tileSource = new OlSourceWMTS(sourceOptions);
+
const granuleExtent = polygon && getGranuleTileLayerExtent(polygon, extent);
return new OlLayerTile({
diff --git a/web/js/map/util.js b/web/js/map/util.js
index 3dfe1adf1..c6f534f22 100644
--- a/web/js/map/util.js
+++ b/web/js/map/util.js
@@ -274,15 +274,3 @@ export function extractDateFromTileErrorURL(url) {
console.error('Date not found in the URL.');
return null;
}
-
-// Updates the format of the appNow date to a date format of YYYY-MM-DD
-export function formatSelectedDate(date) {
- const dateObj = new Date(date);
-
- const year = dateObj.getFullYear();
- const month = String(dateObj.getMonth() + 1).padStart(2, '0');
- const day = String(dateObj.getDate()).padStart(2, '0');
-
- const formattedDate = `${year}-${month}-${day}`;
- return formattedDate;
-}
diff --git a/web/js/mapUI/components/kiosk/kiosk-animations/kiosk-animations.js b/web/js/mapUI/components/kiosk/kiosk-animations/kiosk-animations.js
index 1ff0c10ab..5c8f758d1 100644
--- a/web/js/mapUI/components/kiosk/kiosk-animations/kiosk-animations.js
+++ b/web/js/mapUI/components/kiosk/kiosk-animations/kiosk-animations.js
@@ -14,25 +14,34 @@ function KioskAnimations({ ui }) {
const selectDate = (date) => { dispatch(selectDateAction(date)); };
const {
- selectedDate, isAnimationPlaying, isKioskModeActive, eic, map, readyForKioskAnimation,
+ selectedDate,
+ isAnimationPlaying,
+ isKioskModeActive,
+ eic,
+ map,
+ eicAnimationMode,
+ eicMeasurementComplete,
+ eicMeasurementAborted,
} = useSelector((state) => ({
selectedDate: state.date.selected,
isAnimationPlaying: state.animation.isPlaying,
isKioskModeActive: state.ui.isKioskModeActive,
eic: state.ui.eic,
+ eicAnimationMode: state.ui.eic === 'sa' || state.ui.eic === 'da',
map: state.map,
- readyForKioskAnimation: state.ui.readyForKioskAnimation,
+ eicMeasurementComplete: state.ui.eicMeasurementComplete,
+ eicMeasurementAborted: state.ui.eicMeasurementAborted,
}));
const [subdailyAnimationDateUpdated, setSubdailyAnimationDateUpdated] = useState(false);
useEffect(() => {
- if (!ui.selected || !isKioskModeActive) return;
- if (eic === 'sa' || eic === 'da') checkAnimationSettings();
- }, [map, readyForKioskAnimation]);
+ if (!ui.selected || !isKioskModeActive || !eicMeasurementComplete || isAnimationPlaying || !eicAnimationMode || eicMeasurementAborted) return;
+ checkAnimationSettings();
+ }, [map, eicMeasurementComplete]);
- const subdailyPlayCheck = eic === 'sa' && subdailyAnimationDateUpdated && readyForKioskAnimation && !isAnimationPlaying;
- const dailyPlayCheck = eic === 'da' && readyForKioskAnimation && !isAnimationPlaying;
+ const subdailyPlayCheck = eic === 'sa' && subdailyAnimationDateUpdated && !isAnimationPlaying;
+ const dailyPlayCheck = eic === 'da' && !isAnimationPlaying;
// if subdaily animation check that date moved back one day otherwise check if animation should play
const checkAnimationSettings = () => {
diff --git a/web/js/mapUI/components/kiosk/tile-errors/tile-error-handler.js b/web/js/mapUI/components/kiosk/tile-errors/tile-error-handler.js
deleted file mode 100644
index 4ae4ed5b2..000000000
--- a/web/js/mapUI/components/kiosk/tile-errors/tile-error-handler.js
+++ /dev/null
@@ -1,155 +0,0 @@
-import { useEffect } from 'react';
-import PropTypes from 'prop-types';
-import { useSelector, useDispatch } from 'react-redux';
-import {
- clearErrorTiles as clearErrorTilesAction,
- toggleStaticMap as toggleStaticMapAction,
- toggleReadyForKioskAnimation as toggleReadyForKioskAnimationAction,
-} from '../../../../modules/ui/actions';
-import {
- selectDate as selectDateAction,
- selectInterval as selectIntervalAction,
-} from '../../../../modules/date/actions';
-import { getNextDateTime } from '../../../../modules/date/util';
-import {
- subdailyLayersActive,
- getActiveLayers,
-} from '../../../../modules/layers/selectors';
-import { toggleGroupVisibility as toggleGroupVisiblityAction } from '../../../../modules/layers/actions';
-import {
- formatDate,
- weekAgo,
- threeHoursAgo,
- twentySevenHoursAgo,
- compareDailyDates,
- compareSubdailyDates,
- formatSelectedDate,
-} from '../../../util/util';
-
-function TileErrorHandler({ action, ui }) {
- const dispatch = useDispatch();
- const clearErrorTiles = () => { dispatch(clearErrorTilesAction()); };
- const selectDate = (date) => { dispatch(selectDateAction(date)); };
- const selectInterval = (delta, timeScale, customSelected) => { dispatch(selectIntervalAction(delta, timeScale, customSelected)); };
- const toggleStaticMap = (isActive) => { dispatch(toggleStaticMapAction(isActive)); };
- const toggleGroupVisibility = (ids, visible) => { dispatch(toggleGroupVisiblityAction(ids, visible)); };
- const toggleReadyForKioskAnimation = (toggleAnimation) => { dispatch(toggleReadyForKioskAnimationAction(toggleAnimation)); };
-
- const {
- displayStaticMap,
- isKioskModeActive,
- errorTiles,
- selectedDate,
- date,
- compare,
- isLoading,
- realTimeDate,
- eic,
- map,
- readyForKioskAnimation,
- } = useSelector((state) => ({
- autoplayAnimation: state.animation.autoplay,
- displayStaticMap: state.ui.displayStaticMap,
- isAnimationPlaying: state.animation.isPlaying,
- isKioskModeActive: state.ui.isKioskModeActive,
- errorTiles: state.ui.errorTiles,
- selectedDate: state.date.selected,
- date: state.date,
- compare: state.compare,
- isLoading: state.loading.isLoading,
- realTimeDate: state.date.appNow,
- eic: state.ui.eic,
- map: state.map,
- readyForKioskAnimation: state.ui.readyForKioskAnimation,
- }));
- const { activeString } = compare;
- const hasSubdailyLayers = useSelector((state) => subdailyLayersActive(state));
- const activeLayerIds = useSelector((state) => getActiveLayers(state, activeString).map((layer) => layer.id));
-
- const {
- dailyTiles, subdailyTiles, blankTiles, kioskTileCount, lastCheckedDate,
- } = errorTiles;
-
- const lastDateToCheck = weekAgo(realTimeDate);
- const lastTimeToCheck = eic === 'sa' ? twentySevenHoursAgo(realTimeDate) : threeHoursAgo(realTimeDate);
-
- const dailySafeguardCheck = compareDailyDates(lastDateToCheck, selectedDate);
- const hourlySafeguardCheck = compareSubdailyDates(lastTimeToCheck, selectedDate);
-
- const errorTileCheck = dailyTiles.length || subdailyTiles.length;
- const blankTileCheck = blankTiles.length;
-
- useEffect(() => {
- if (!ui.selected || !map.rendered || readyForKioskAnimation) return;
-
- if (isKioskModeActive && errorTileCheck && dailySafeguardCheck && !isLoading) {
- handleTileErrors();
- } else if (isKioskModeActive && errorTileCheck && (!dailySafeguardCheck || !hourlySafeguardCheck) && !isLoading) {
- handleStaticMap();
- } else if (isKioskModeActive && blankTileCheck && dailySafeguardCheck && eic !== 'sa' && !isLoading) {
- handleTimeChangeForBlankTiles();
- // reminder: we are NOT checking blank tiles when playing subdaily animations
- } else if ((!errorTileCheck && !blankTileCheck && !readyForKioskAnimation) || (eic === 'sa' && !errorTileCheck && !readyForKioskAnimation)) {
- readyForAnimation();
- } else {
- clearErrorTiles();
- }
- }, [action]);
-
- const handleStaticMap = () => {
- toggleStaticMap(true);
- toggleGroupVisibility(activeLayerIds, false);
- };
-
- const readyForAnimation = () => {
- toggleReadyForKioskAnimation(true);
- clearErrorTiles();
- };
-
- // we don't need to include the readyForAnimation function here until we are checking a tile for blank tiles that we plan on animating
- const handleTimeChangeForBlankTiles = () => {
- const blankTilesOnCurentDate = blankTiles.filter((tile) => tile.date === formatSelectedDate(selectedDate)).length;
- if (!blankTilesOnCurentDate) return clearErrorTiles();
- const blankTilesPercentage = (blankTiles.length / kioskTileCount) * 100;
- if (blankTilesPercentage >= 50) {
- const state = { date, compare };
- const prevDate = getNextDateTime(state, '-1');
- const prevDateObj = new Date(prevDate);
- selectDate(prevDateObj);
- }
- clearErrorTiles();
- };
-
- const handleTimeChangeForErrors = (tiles, isSubdaily) => {
- const currentDate = formatDate(selectedDate, isSubdaily);
- const errorTilesOnCurrentDate = tiles.filter((tile) => currentDate === tile.date).length;
- if (errorTilesOnCurrentDate) {
- const state = { date, compare };
- if (hasSubdailyLayers && !isSubdaily) selectInterval(1, 3, false);
- const prevDate = getNextDateTime(state, '-1');
- const prevDateObj = new Date(prevDate);
- selectDate(prevDateObj);
- } else if ((lastCheckedDate === selectedDate && !readyForKioskAnimation && eic === 'da') || (eic === 'sa')) {
- readyForAnimation();
- } else {
- clearErrorTiles();
- }
-
- if (!hourlySafeguardCheck || !dailySafeguardCheck) return handleStaticMap();
- };
-
- const handleTileErrors = () => {
- if (dailyTiles.length) return handleTimeChangeForErrors(dailyTiles, false);
- if (subdailyTiles.length && hourlySafeguardCheck) return handleTimeChangeForErrors(subdailyTiles, true);
- if ((!hourlySafeguardCheck || !dailySafeguardCheck) && !displayStaticMap) return handleStaticMap();
- };
-
- return null;
-}
-
-export default TileErrorHandler;
-
-TileErrorHandler.propTypes = {
- action: PropTypes.object,
- ui: PropTypes.object,
-};
diff --git a/web/js/mapUI/components/kiosk/tile-measurement/tile-image-test-mode/tile-image-test-dropdown-selection.js b/web/js/mapUI/components/kiosk/tile-measurement/tile-image-test-mode/tile-image-test-dropdown-selection.js
new file mode 100644
index 000000000..79e3678b4
--- /dev/null
+++ b/web/js/mapUI/components/kiosk/tile-measurement/tile-image-test-mode/tile-image-test-dropdown-selection.js
@@ -0,0 +1,34 @@
+import React, { useState } from 'react';
+
+import {
+ Dropdown,
+ DropdownToggle,
+ DropdownMenu,
+ DropdownItem,
+} from 'reactstrap';
+
+function TileImageTestModeDropdown({ activeLayers, layerSelection, setLayerSelection }) {
+ const [dropdownOpen, setDropdownOpen] = useState(false);
+ const toggle = () => setDropdownOpen(!dropdownOpen);
+
+ const handleSelection = (layer) => {
+ setLayerSelection(layer);
+ };
+
+ return (
+ <Dropdown isOpen={dropdownOpen} toggle={toggle}>
+ <DropdownToggle style={{ backgroundColor: '#d54e21' }} caret>
+ {layerSelection.id}
+ </DropdownToggle>
+ <DropdownMenu style={{ transform: 'translate3d(-30px, 0px, 0px)' }}>
+ {activeLayers.map((layer) => (
+ <DropdownItem key={layer.id} onClick={() => handleSelection(layer)}>
+ {layer.id}
+ </DropdownItem>
+ ))}
+ </DropdownMenu>
+ </Dropdown>
+ );
+}
+
+export default TileImageTestModeDropdown;
diff --git a/web/js/mapUI/components/kiosk/tile-measurement/tile-image-test-mode/tile-image-test-mode.js b/web/js/mapUI/components/kiosk/tile-measurement/tile-image-test-mode/tile-image-test-mode.js
new file mode 100644
index 000000000..1b7ec33f8
--- /dev/null
+++ b/web/js/mapUI/components/kiosk/tile-measurement/tile-image-test-mode/tile-image-test-mode.js
@@ -0,0 +1,84 @@
+import React, { useState } from 'react';
+import { useSelector } from 'react-redux';
+import { Button } from 'reactstrap';
+import { getActiveLayers } from '../../../../../modules/layers/selectors';
+import fetchWMSImage from '../utils/image-api-request';
+import calculatePixels from '../utils/calculate-pixels';
+import { layerPixelData } from '../utils/layer-data-eic';
+import DropdownSelector from './tile-image-test-dropdown-selection';
+import { formatReduxDailyDate, formatReduxSubdailyDate } from '../utils/date-util';
+
+// Use this component to test the black pixel ratio of a single image
+// You will need to set the the 'tileImageTestMode' state to true in mapUI
+// Remember to set it back to false when you are done testing
+
+function TileImagePixelTest() {
+ const {
+ activeLayers,
+ selectedDate,
+ } = useSelector((state) => ({
+ activeLayers: getActiveLayers(state, state.compare.activeString).map((layer) => layer),
+ selectedDate: state.date.selected,
+ }));
+
+ const placeHolderLayerSelection = { id: 'Select Layer', period: 'daily' };
+ const [layerSelection, setLayerSelection] = useState(placeHolderLayerSelection);
+
+ const buttonDisabled = layerSelection.id === 'Select Layer';
+
+ const formatDate = () => {
+ if (layerSelection.period === 'daily') {
+ return formatReduxDailyDate(selectedDate);
+ }
+ return formatReduxSubdailyDate(selectedDate);
+ };
+
+ const makeMeasurementRequest = async () => {
+ const formattedDate = formatDate();
+ try {
+ const wmsImage = await fetchWMSImage(layerSelection.id, formattedDate, true);
+
+ // Create an image and handle its loading and error events
+ const img = new Image();
+
+ img.onload = async () => {
+ // Process the loaded image here
+ const blackPixelRatio = parseFloat((await calculatePixels(wmsImage) * 100).toFixed(2));
+ // eslint-disable-next-line no-unsafe-optional-chaining
+ const currentThreshold = layerPixelData?.[layerSelection?.id]?.threshold * 100 ?? null;
+
+ const pixelMessage = `${blackPixelRatio}% of pixels are black for ${layerSelection.id} on ${formattedDate}... `;
+ const thresholdMessage = currentThreshold ? `The current threshold for ${layerSelection.id} is ${currentThreshold}%` : `There is no current threshold for ${layerSelection.id} ...`;
+
+ console.log(pixelMessage + thresholdMessage);
+ };
+
+ img.onerror = (error) => {
+ console.error(`No image available for ${layerSelection.id} on ${formattedDate}: `, error);
+ };
+
+ // Try to load the image
+ img.src = wmsImage;
+ } catch (error) {
+ console.error(`No image available for ${layerSelection.id} on ${formattedDate}: `, error);
+ }
+ };
+
+
+ return (
+ <div id="dev-block" className="d-flex justify-content-center">
+ <Button
+ color="primary"
+ style={{ zIndex: '999' }}
+ disabled={buttonDisabled}
+ onClick={makeMeasurementRequest}
+ >
+ Pixel Test
+ </Button>
+ <DropdownSelector activeLayers={activeLayers} layerSelection={layerSelection} setLayerSelection={setLayerSelection} />
+
+ </div>
+ );
+}
+
+export default TileImagePixelTest;
diff --git a/web/js/mapUI/components/kiosk/tile-measurement/tile-measurement.js b/web/js/mapUI/components/kiosk/tile-measurement/tile-measurement.js
new file mode 100644
index 000000000..8ac31e864
--- /dev/null
+++ b/web/js/mapUI/components/kiosk/tile-measurement/tile-measurement.js
@@ -0,0 +1,192 @@
+/* eslint-disable no-await-in-loop */
+import { useEffect, useState } from 'react';
+import { useSelector, useDispatch } from 'react-redux';
+import { getActiveLayers } from '../../../../modules/layers/selectors';
+import { selectDate as selectDateAction } from '../../../../modules/date/actions';
+import {
+ setEICMeasurementComplete as setEICMeasurementCompleteAction,
+ setEICMeasurementAborted as setEICMeasurementAbortedAction,
+ toggleStaticMap as toggleStaticMapAction,
+} from '../../../../modules/ui/actions';
+import { toggleGroupVisibility as toggleGroupVisiblityAction } from '../../../../modules/layers/actions';
+import { getDates } from './utils/date-util';
+import fetchWMSImage from './utils/image-api-request';
+import calculatePixels from './utils/calculate-pixels';
+import { layersToMeasure, layerPixelData, bestDates } from './utils/layer-data-eic';
+import countTilesForSpecifiedLayers from './utils/verify-map-tiles';
+
+function TileMeasurement({ ui }) {
+ const dispatch = useDispatch();
+ const selectDate = (date) => { dispatch(selectDateAction(date)); };
+ const setEICMeasurementComplete = () => { dispatch(setEICMeasurementCompleteAction()); };
+ const setEICMeasurementAborted = () => { dispatch(setEICMeasurementAbortedAction()); };
+ const toggleStaticMap = (isActive) => { dispatch(toggleStaticMapAction(isActive)); };
+ const toggleGroupVisibility = (ids, visible) => { dispatch(toggleGroupVisiblityAction(ids, visible)); };
+
+ const {
+ activeString,
+ activeLayers,
+ eic,
+ realTime,
+ } = useSelector((state) => ({
+ activeLayers: getActiveLayers(state, state.compare.activeString).map((layer) => layer),
+ eic: state.ui.eic,
+ realTime: state.date.appNow,
+ activeString: state.compare.activeString,
+ }));
+ const activeLayerIds = useSelector((state) => getActiveLayers(state, activeString).map((layer) => layer.id));
+
+ const [measurementsStarted, setMeasurementsStarted] = useState(false);
+
+ useEffect(() => {
+ if (!measurementsStarted && activeLayers && eic) {
+ calculateMeasurements();
+ }
+ });
+
+ // #2 Filter all of the active layers that are also in the layersToMeasure array
+ const findLayersToMeasure = () => {
+ const measurementLayersExtra = activeLayers.filter((layer) => layersToMeasure.includes(layer.id));
+ // condense this step into the above filter later
+ const measurementLayers = measurementLayersExtra.map((layer) => ({ id: layer.id, period: layer.period }));
+ if (measurementLayers.length) console.log(`${measurementLayers.length} EIC layer(s) found to measure...`);
+ return measurementLayers;
+ };
+
+ // #3 Find the date range for each layer depending on the period (daily or subdaily)
+ const findDateRange = (layerPeriod) => {
+ const dates = getDates(realTime, layerPeriod);
+ return dates;
+ };
+
+ // #4 Loop through layers and dates to find the first date that satisfies full imagery thresholds
+ const findFullImageryDate = async (layers, dates) => {
+ console.log('Date range found... Finding date with satisfactory imagery...');
+ for (let i = 0; i < dates.length; i += 1) {
+ let layersMeetingThresholdForDate = 0;
+ console.log(`-----Loop #${i + 1} for date ${dates[i]}-----`);
+ for (let j = 0; j < layers.length; j += 1) {
+ try {
+ const wmsImage = await fetchWMSImage(layers[j].id, dates[i]);
+ const blackPixelRatio = await calculatePixels(wmsImage);
+ const { threshold } = layerPixelData[layers[j].id];
+ if (blackPixelRatio < threshold) {
+ layersMeetingThresholdForDate += 1;
+ console.log(`${layers[j].id} is BELOW the threshold of ${threshold * 100}% for ${dates[i]} with a black pixel ratio of ${blackPixelRatio.toFixed(2) * 100}%. This is ${layersMeetingThresholdForDate} of ${layers.length} checks needed for this date.`);
+ } else {
+ console.log(`${layers[j].id} is BREAKING the threshold of ${threshold * 100}% for -- ${dates[i]} -- with a black ratio of ${blackPixelRatio.toFixed(2) * 100}%.`);
+ break;
+ }
+ } catch (error) {
+ console.error(`Error while processing layer ${layers[j].id} for date ${dates[i]}: `, error);
+ break;
+ }
+ }
+ if (layersMeetingThresholdForDate === layers.length) {
+ console.log(`All layers meet thresholds for ${dates[i]}.`);
+ return dates[i];
+ }
+ layersMeetingThresholdForDate = 0;
+ }
+ // returns the date of the first layer that has a best date
+ const firstLayerWithBestDate = layers.find((layer) => bestDates[layer.id]?.date);
+ if (!firstLayerWithBestDate) {
+ console.error(`No date found that satisfies the full imagery thresholds. There is no best date selected for ${layers[0].id}.`);
+ // display static map??
+ return dates[0];
+ }
+ console.error(`No date found that satisfies imagery thresholds. Returning best date for ${layers[0].id} on ${firstLayerWithBestDate}.`);
+ return firstLayerWithBestDate;
+ };
+
+ // #5 Update the date of the map to the date that satisfies the full imagery threshold
+ const updateDate = (fullImageryDate, layerPeriod) => {
+ console.log('Updating application date...');
+ if (layerPeriod === 'daily') {
+ const parts = fullImageryDate.split('-');
+ const year = parts[0];
+ const month = parts[1] - 1;
+ const day = parts[2];
+
+ const date = new Date(year, month, day, 12, 0, 0);
+ selectDate(date);
+ } else {
+ const [datePart, timePart] = fullImageryDate.split('T');
+
+ const dateParts = datePart.split('-');
+ const year = +dateParts[0];
+ const month = +dateParts[1] - 1;
+ const day = +dateParts[2];
+
+ // eslint-disable-next-line prefer-const
+ let [hour, minute, second] = timePart.split(':');
+ // Remove any fractional seconds if present and the 'Z' at the end
+ second = second.includes('.') ? second.split('.')[0] : second;
+ second = second.includes('Z') ? second.split('Z')[0] : second;
+
+ const date = new Date(Date.UTC(year, month, day, +hour, +minute, +second));
+ selectDate(date);
+ }
+ };
+
+ const verifyTilesAndHandleErrors = (abortProceedure) => {
+ console.log('Verifying tiles on map...');
+ const tileCount = countTilesForSpecifiedLayers(ui, layersToMeasure);
+ const loadedTiles = tileCount.totalLoadedTileCount > 0;
+ if ((eic === 'da' || eic === 'sa') && !abortProceedure) {
+ setEICMeasurementComplete();
+ }
+ if (loadedTiles && !abortProceedure) {
+ setEICMeasurementComplete();
+ console.log('Tile verified... EIC measure process complete...');
+ } else if (loadedTiles && abortProceedure) {
+ console.log('EIC measure process aborted... Loaded map tiles found... Leaving map as is...');
+ setEICMeasurementAborted();
+ } else if (!loadedTiles && abortProceedure) {
+ console.log('EIC measure process aborted... No tiles found on map... Displaying static map...');
+ toggleStaticMap(true);
+ toggleGroupVisibility(activeLayerIds, false);
+ setEICMeasurementAborted();
+ }
+ };
+
+
+ // #1 Parent function that is called from useEffect.
+ const calculateMeasurements = async () => {
+ try {
+ console.log('Entering EIC mode...');
+
+ setMeasurementsStarted(true);
+
+ const measurementLayers = findLayersToMeasure();
+ if (!measurementLayers) {
+ console.error('No layers found to be measured... Aborting...');
+ return verifyTilesAndHandleErrors(true);
+ }
+
+ const layersIncludeSubdaily = measurementLayers.some((layer) => layer.period === 'subdaily');
+ const layerPeriod = layersIncludeSubdaily ? 'subdaily' : 'daily';
+
+ const dateRange = findDateRange(layerPeriod);
+ if (!dateRange) {
+ console.error('No date range found... Aborting..');
+ return verifyTilesAndHandleErrors(true);
+ }
+
+ const fullImageryDate = await findFullImageryDate(measurementLayers, dateRange);
+ if (!fullImageryDate) return verifyTilesAndHandleErrors(true);
+
+ // Format date based on period and dispatch redux action
+ updateDate(fullImageryDate, layerPeriod);
+
+ verifyTilesAndHandleErrors();
+ } catch (error) {
+ console.error('Error calculating measurements:', error);
+ verifyTilesAndHandleErrors(true);
+ }
+ };
+
+ return null;
+}
+
+export default TileMeasurement;
diff --git a/web/js/mapUI/components/kiosk/tile-measurement/utils/calculate-pixels.js b/web/js/mapUI/components/kiosk/tile-measurement/utils/calculate-pixels.js
new file mode 100644
index 000000000..2e6f2dfa0
--- /dev/null
+++ b/web/js/mapUI/components/kiosk/tile-measurement/utils/calculate-pixels.js
@@ -0,0 +1,30 @@
+export default function calculateBlackPixelRatio(blobUrl) {
+ return new Promise((resolve, reject) => {
+ const img = new Image();
+ img.src = blobUrl;
+ img.onload = () => {
+ const canvas = document.createElement('canvas');
+ const ctx = canvas.getContext('2d');
+ canvas.width = img.width;
+ canvas.height = img.height;
+ ctx.drawImage(img, 0, 0, img.width, img.height);
+ const imgData = ctx.getImageData(0, 0, img.width, img.height).data;
+
+ let blackPixelsCount = 0;
+ for (let i = 0; i < imgData.length; i += 4) {
+ // Check if pixel is black
+ if (imgData[i] === 0 && imgData[i + 1] === 0 && imgData[i + 2] === 0 && imgData[i + 3] === 255) {
+ blackPixelsCount += 1;
+ }
+ }
+
+ const totalPixels = img.width * img.height;
+ const blackPixelRatio = blackPixelsCount / totalPixels;
+ resolve(blackPixelRatio);
+ };
+ img.onerror = (e) => {
+ console.error('Image loading error:', e);
+ reject(e);
+ };
+ });
+}
diff --git a/web/js/mapUI/components/kiosk/tile-measurement/utils/date-util.js b/web/js/mapUI/components/kiosk/tile-measurement/utils/date-util.js
new file mode 100644
index 000000000..9d805e30a
--- /dev/null
+++ b/web/js/mapUI/components/kiosk/tile-measurement/utils/date-util.js
@@ -0,0 +1,93 @@
+// Return an array of dates based on the period (daily or subdaily)
+// Accepts redux selectedDate value and period
+export function getDates(selectedDate, period) {
+ if (period === 'daily') {
+ return getDailyDates(selectedDate);
+ }
+ return getSubdailyDates(selectedDate);
+}
+
+// Return an array of daily dates for the past 7 days
+// Accepts redux selectedDate value
+function getDailyDates (selectedDate) {
+ // Get the date as a string in UTC
+ const utcDateString = selectedDate.toLocaleString('en-US', { timeZone: 'UTC' });
+ // Convert the UTC string back to a Date object
+ const currentDate = new Date(utcDateString);
+
+ const prevDates = [formatDailyDate(currentDate)];
+
+ for (let i = 1; i < 7; i += 1) {
+ const previousDate = new Date(currentDate);
+ previousDate.setDate(previousDate.getDate() - i);
+ prevDates.push(formatDailyDate(previousDate));
+ }
+ return prevDates;
+}
+
+// format a single daily date
+// Accepts a date object
+function formatDailyDate (date) {
+ const year = date.getFullYear();
+ const month = (date.getMonth() + 1).toString().padStart(2, '0');
+ const day = date.getDate().toString().padStart(2, '0');
+
+ return `${year}-${month}-${day}`;
+}
+
+// Return an array of subdaily dates for the past 2 hours in ten minute intervals
+// The current date is rounded down to the nearest ten minutes
+// Accepts redux selectedDate value
+function getSubdailyDates (selectedDate) {
+ // Get the date as a string in UTC
+ const utcDateString = selectedDate.toLocaleString('en-US', { timeZone: 'UTC' });
+ // Convert the UTC string back to a Date object
+ const currentDate = new Date(utcDateString);
+
+ // Round minutes down to nearest ten and seconds and milliseconds to zero
+ currentDate.setMinutes(Math.floor(currentDate.getMinutes() / 10) * 10, 0, 0);
+ const prevDates = [formatSubdailyDate(currentDate)];
+
+ // Add 12 more dates in ten-minute intervals (for the past two hours)
+ for (let i = 1; i <= 12; i += 1) {
+ const previousDate = new Date(currentDate.getTime() - i * 10 * 60 * 1000); // subtracts i*10 minutes
+ prevDates.push(formatSubdailyDate(previousDate));
+ }
+ return prevDates;
+}
+
+// format a single subdaily date
+// accepts a date object
+function formatSubdailyDate (date) {
+ const year = date.getFullYear();
+ const month = (date.getMonth() + 1).toString().padStart(2, '0');
+ const day = date.getDate().toString().padStart(2, '0');
+ const hour = date.getHours().toString().padStart(2, '0');
+ const minute = date.getMinutes().toString().padStart(2, '0');
+
+ return `${year}-${month}-${day}T${hour}:${minute}:00Z`;
+}
+
+// Format a daily redux date to be used in the WMS request
+export function formatReduxDailyDate(selectedDate) {
+ const utcDateString = selectedDate.toLocaleString('en-US', { timeZone: 'UTC' });
+ const date = new Date(utcDateString);
+ const year = date.getFullYear();
+ const month = (date.getMonth() + 1).toString().padStart(2, '0');
+ const day = date.getDate().toString().padStart(2, '0');
+
+ return `${year}-${month}-${day}`;
+}
+
+// Format a subdaily redux date rounded down to ten minute interval to be used in the WMS request
+export function formatReduxSubdailyDate(selectedDate) {
+ const utcDateString = selectedDate.toLocaleString('en-US', { timeZone: 'UTC' });
+ const date = new Date(utcDateString);
+ const year = date.getFullYear();
+ const month = (date.getMonth() + 1).toString().padStart(2, '0');
+ const day = date.getDate().toString().padStart(2, '0');
+ const hour = date.getHours().toString().padStart(2, '0');
+ const minute = date.getMinutes().toString().padStart(2, '0');
+
+ return `${year}-${month}-${day}T${hour}:${minute}:00Z`;
+}
diff --git a/web/js/mapUI/components/kiosk/tile-measurement/utils/image-api-request.js b/web/js/mapUI/components/kiosk/tile-measurement/utils/image-api-request.js
new file mode 100644
index 000000000..3f667f1b1
--- /dev/null
+++ b/web/js/mapUI/components/kiosk/tile-measurement/utils/image-api-request.js
@@ -0,0 +1,40 @@
+// eslint-disable-next-line import/no-extraneous-dependencies
+import axios from 'axios';
+import { saveAs } from 'file-saver';
+
+export default async function fetchWMSImage(layer, date, testMode) {
+ const baseUrl = 'https://gibs.earthdata.nasa.gov/wms/epsg4326/best/wms.cgi';
+ const params = {
+ version: '1.3.0',
+ service: 'WMS',
+ request: 'GetMap',
+ format: 'image/png',
+ STYLE: 'default',
+ bbox: '-20037508.34,-20048966.1,20037508.34,20048966.1',
+ CRS: 'EPSG:3857',
+ HEIGHT: '256',
+ WIDTH: '256',
+ TIME: date,
+ layers: layer,
+ };
+
+ try {
+ const response = await axios.get(baseUrl, { params, responseType: 'arraybuffer' });
+
+ // Convert the response data to a Blob which can be used as image src
+ const blob = new Blob([response.data], { type: response.headers['content-type'] });
+ const imageSrc = URL.createObjectURL(blob);
+
+ // Save the file for debugging purposes in test mode
+ // This should open image in a seperate tab in the browser, may have to allow popups
+ if (testMode) {
+ const file = new Blob([response.data], { type: 'image/png' });
+ saveAs(file, `${layer}.png`);
+ }
+
+ return imageSrc;
+ } catch (error) {
+ console.error(error);
+ return null;
+ }
+}
diff --git a/web/js/mapUI/components/kiosk/tile-measurement/utils/layer-data-eic.js b/web/js/mapUI/components/kiosk/tile-measurement/utils/layer-data-eic.js
new file mode 100644
index 000000000..632cd6b9e
--- /dev/null
+++ b/web/js/mapUI/components/kiosk/tile-measurement/utils/layer-data-eic.js
@@ -0,0 +1,45 @@
+// An array of layers that we want to measure in EIC mode
+export const layersToMeasure = [
+ 'MODIS_Terra_CorrectedReflectance_TrueColor',
+ 'VIIRS_SNPP_DayNightBand_At_Sensor_Radiance',
+ 'VIIRS_SNPP_CorrectedReflectance_TrueColor',
+ 'GHRSST_L4_MUR_Sea_Surface_Temperature',
+ 'MODIS_Aqua_Land_Surface_Temp_Day',
+ 'MODIS_Aqua_CorrectedReflectance_TrueColor',
+ 'IMERG_Precipitation_Rate',
+ 'GOES-East_ABI_GeoColor',
+ 'GOES-West_ABI_GeoColor',
+ 'Himawari_AHI_Band3_Red_Visible_1km',
+ 'AMSRU2_Sea_Ice_Concentration_12km',
+];
+
+// Object that contains the black pixel % threshold for each layer
+// Threshold values represent the amount of black pixels as a percentage that CAN be present in an image
+export const layerPixelData = {
+ MODIS_Terra_CorrectedReflectance_TrueColor: { threshold: 0.70 },
+ VIIRS_SNPP_DayNightBand_At_Sensor_Radiance: { threshold: 0.70 },
+ VIIRS_SNPP_CorrectedReflectance_TrueColor: { threshold: 0.65 },
+ IMERG_Precipitation_Rate: { threshold: 0.95 },
+ GHRSST_L4_MUR_Sea_Surface_Temperature: { threshold: 0.65 },
+ MODIS_Aqua_Land_Surface_Temp_Day: { threshold: 0.80 },
+ MODIS_Aqua_CorrectedReflectance_TrueColor: { threshold: 0.50 },
+ 'GOES-East_ABI_GeoColor': { threshold: 0.76 },
+ 'GOES-West_ABI_GeoColor': { threshold: 0.76 },
+ Himawari_AHI_Band3_Red_Visible_1km: { threshold: 0.76 },
+ AMSRU2_Sea_Ice_Concentration_12km: { threshold: 0.85 },
+};
+
+// Back-up dates for each layer in case no date is found that satisfies the full imagery threshold
+// TO DO: These layers will eventually need to be prioritized if a scenario has layers from multiple best dates
+export const bestDates = {
+ 'GOES-East_ABI_GeoColor': { date: '2023-06-10T23:50:00.000Z' },
+ 'GOES-West_ABI_GeoColor': { date: '2023-06-10T23:50:00.000Z' },
+ Himawari_AHI_Band3_Red_Visible_1km: { date: '2023-06-10T23:50:00.000Z' },
+ MODIS_Terra_CorrectedReflectance_TrueColor: { date: '2023-06-10T12:00:00.000Z' },
+ VIIRS_SNPP_DayNightBand_At_Sensor_Radiance: { date: '2023-06-10T12:00:00.000Z' },
+ VIIRS_SNPP_CorrectedReflectance_TrueColor: { date: '2023-06-10T12:00:00.000Z' },
+ IMERG_Precipitation_Rate: { date: '2023-06-10T12:00:00.000Z' },
+ GHRSST_L4_MUR_Sea_Surface_Temperature: { date: '2023-06-10T12:00:00.000Z' },
+ MODIS_Aqua_Land_Surface_Temp_Day: { date: '2023-06-10T12:00:00.000Z' },
+ MODIS_Aqua_CorrectedReflectance_TrueColor: { date: '2023-06-10T12:00:00.000Z' },
+};
diff --git a/web/js/mapUI/components/kiosk/tile-measurement/utils/verify-map-tiles.js b/web/js/mapUI/components/kiosk/tile-measurement/utils/verify-map-tiles.js
new file mode 100644
index 000000000..7a70df60d
--- /dev/null
+++ b/web/js/mapUI/components/kiosk/tile-measurement/utils/verify-map-tiles.js
@@ -0,0 +1,67 @@
+import TileLayer from 'ol/layer/Tile';
+import { transformExtent } from 'ol/proj';
+
+// Helper function to process the tile layer
+const processTileLayer = (layer, map, view) => {
+ const source = layer.getSource();
+ const size = map.getSize();
+ const extent = view.calculateExtent(size);
+ const zoom = view.getZoom();
+ const sourceProjection = source.getProjection() || view.getProjection();
+ const transformedExtent = transformExtent(extent, view.getProjection(), sourceProjection);
+ const tileGrid = source.getTileGridForProjection(sourceProjection);
+ const resolution = view.getResolutionForZoom(zoom);
+ const currentZ = tileGrid.getZForResolution(resolution);
+
+ let expectedTileCount = 0;
+ let loadedTileCount = 0;
+
+ const tileCoordFunction = (tileCoord) => {
+ const tile = source.getTile(tileCoord[0], tileCoord[1], tileCoord[2], 1, sourceProjection);
+ const tileState = tile.getState();
+ if (tileState === 2) {
+ loadedTileCount += 1;
+ expectedTileCount += 1;
+ } else if (tileState === 3) {
+ expectedTileCount += 1;
+ }
+ };
+
+ tileGrid.forEachTileCoord(transformedExtent, currentZ, tileCoordFunction);
+
+ return {
+ expectedTileCount,
+ loadedTileCount,
+ };
+};
+
+export default function countTilesForSpecifiedLayers (ui, layersToCheck) {
+ const map = ui.selected;
+ const view = map.getView();
+ const layers = map.getLayers().getArray();
+ const matchingLayers = layers.filter((layer) => {
+ const layerId = layer.wv.id;
+ return layersToCheck.includes(layerId);
+ });
+
+ let totalExpectedTileCount = 0;
+ let totalLoadedTileCount = 0;
+
+ const processLayer = (layer) => {
+ if (layer instanceof TileLayer) {
+ const { expectedTileCount, loadedTileCount } = processTileLayer(layer, map, view);
+ totalExpectedTileCount += expectedTileCount;
+ totalLoadedTileCount += loadedTileCount;
+ } else if (layer.getLayers) {
+ const subLayers = layer.getLayers().getArray();
+ subLayers.forEach(processLayer);
+ }
+ };
+
+ matchingLayers.forEach(processLayer);
+
+ return {
+ totalExpectedTileCount,
+ totalLoadedTileCount,
+ };
+}
diff --git a/web/js/mapUI/mapUI.js b/web/js/mapUI/mapUI.js
index e11f8993a..faf4fc326 100644
--- a/web/js/mapUI/mapUI.js
+++ b/web/js/mapUI/mapUI.js
@@ -16,8 +16,9 @@ import UpdateOpacity from './components/update-opacity/updateOpacity';
import UpdateProjection from './components/update-projection/updateProjection';
import MouseMoveEvents from './components/mouse-move-events/mouseMoveEvents';
import BufferQuickAnimate from './components/buffer-quick-animate/bufferQuickAnimate';
-import TileErrorHandler from './components/kiosk/tile-errors/tile-error-handler';
import KioskAnimations from './components/kiosk/kiosk-animations/kiosk-animations';
+import TileMeasurement from './components/kiosk/tile-measurement/tile-measurement';
+import TileImagePixelTest from './components/kiosk/tile-measurement/tile-image-test-mode/tile-image-test-mode';
import { LOCATION_POP_ACTION } from '../redux-location-state-customs';
import { CHANGE_PROJECTION } from '../modules/projection/constants';
import { SET_SCREEN_INFO } from '../modules/screen-size/constants';
@@ -46,7 +47,7 @@ import { updateVectorSelection } from '../modules/vector-styles/util';
import { REDUX_ACTION_DISPATCHED } from '../util/constants';
import { updateMapExtent } from '../modules/map/actions';
import { clearPreload, setPreload } from '../modules/date/actions';
-import { SET_ERROR_TILES, DISPLAY_STATIC_MAP } from '../modules/ui/constants';
+import { DISPLAY_STATIC_MAP } from '../modules/ui/constants';
const { events } = util;
@@ -93,7 +94,9 @@ function MapUI(props) {
const [quickAnimateAction, setQuickAnimateAction] = useState({});
const [vectorActions, setVectorActions] = useState({});
const [preloadAction, setPreloadAction] = useState({});
- const [tileErrorAction, setTileErrorAction] = useState({});
+
+ // eslint-disable-next-line no-unused-vars
+ const [tileImageTestMode, setTileImageTestMode] = useState(false);
const subscribeToStore = function(action) {
switch (action.type) {
@@ -159,8 +162,6 @@ function MapUI(props) {
case dateConstants.ARROW_DOWN:
setQuickAnimateAction(action);
break;
- case SET_ERROR_TILES:
- return setTileErrorAction(action);
default:
break;
}
@@ -398,8 +399,10 @@ function MapUI(props) {
<GranuleHover granuleFootprints={granuleFootprints} ui={ui} />
<MouseMoveEvents ui={ui} compareMapUi={compareMapUi} />
<BufferQuickAnimate action={quickAnimateAction} />
- <TileErrorHandler action={tileErrorAction} ui={ui} />
<KioskAnimations ui={ui} />
+ <TileMeasurement ui={ui} />
+ {tileImageTestMode && <TileImagePixelTest />}
+
</>
);
}
diff --git a/web/js/modules/map/util.js b/web/js/modules/map/util.js
index 06d8f533a..5cdb23daa 100644
--- a/web/js/modules/map/util.js
+++ b/web/js/modules/map/util.js
@@ -284,8 +284,8 @@ function promiseLayerGroup(layerGroup, map) {
* @return {object} Promise
*/
export async function promiseImageryForTime(state, date, activeString) {
- const { map } = state;
- if (!map.ui.proj) return;
+ const { map, ui: { eic } } = state;
+ if (!map.ui.proj || eic === 'si') return;
const {
cache, selected, createLayer, layerKey,
} = map.ui;
diff --git a/web/js/modules/ui/actions.js b/web/js/modules/ui/actions.js
index 2b207d702..38fe7e1b0 100644
--- a/web/js/modules/ui/actions.js
+++ b/web/js/modules/ui/actions.js
@@ -3,11 +3,11 @@ import googleTagManager from 'googleTagManager';
import {
TOGGLE_DISTRACTION_FREE_MODE,
TOGGLE_KIOSK_MODE,
- CLEAR_ERROR_TILES,
- SET_ERROR_TILES,
DISPLAY_STATIC_MAP,
READY_FOR_KIOSK_ANIMATION,
CHECK_ANIMATION_AVAILABILITY,
+ SET_EIC_MEASUREMENT_COMPLETE,
+ SET_EIC_MEASUREMENT_ABORTED,
} from './constants';
import { CLOSE as CLOSE_MODAL } from '../modal/constants';
@@ -40,46 +40,6 @@ export function toggleKioskMode(isActive) {
};
}
-// Layerbuilder tracks tile requests that return errors or blank tiles and dispatches this action for specific layers.
-export function setErrorTiles(errorTiles) {
- return {
- type: SET_ERROR_TILES,
- errorTiles: {
- dailyTiles: errorTiles.dailyTiles,
- subdailyTiles: errorTiles.subdailyTiles,
- blankTiles: errorTiles.blankTiles,
- kioskTileCount: errorTiles.kioskTileCount,
- lastCheckedDate: errorTiles.lastCheckedDate,
- },
- };
-}
-
-// After each tile request we call this to clear the error tiles for the current date.
-// We want to preserve the lastCheckedDate value from the previous dispatched setErrorTiles action.
-export function clearErrorTiles() {
- return (dispatch, getState) => {
- const { ui: { errorTiles: { lastCheckedDate } } } = getState();
- const errorTiles = {
- dailyTiles: [],
- subdailyTiles: [],
- blankTiles: [],
- kioskTileCount: 0,
- lastCheckedDate,
- };
-
- dispatch({
- type: CLEAR_ERROR_TILES,
- errorTiles: {
- dailyTiles: errorTiles.dailyTiles,
- subdailyTiles: errorTiles.subdailyTiles,
- blankTiles: errorTiles.blankTiles,
- kioskTileCount: errorTiles.kioskTileCount,
- lastCheckedDate: errorTiles.lastCheckedDate,
- },
- });
- };
-}
-
// Dispatched when maximum date/time threshold is met when checking for error/blank tiles.
// Displays a static image map stored locally in repo.
export function toggleStaticMap(isActive) {
@@ -107,3 +67,17 @@ export function toggleCheckedAnimationAvailability(toggleCheck) {
toggleCheck,
};
}
+
+// This action is dispatched when tile image measurements are complete in TileMeasurement component
+export function setEICMeasurementComplete() {
+ return {
+ type: SET_EIC_MEASUREMENT_COMPLETE,
+ };
+}
+
+// This action is dispatched when the EIC measurement process is aborted in TileMeasurement component
+export function setEICMeasurementAborted() {
+ return {
+ type: SET_EIC_MEASUREMENT_ABORTED,
+ };
+}
diff --git a/web/js/modules/ui/constants.js b/web/js/modules/ui/constants.js
index 8775e42db..8f9291fec 100644
--- a/web/js/modules/ui/constants.js
+++ b/web/js/modules/ui/constants.js
@@ -5,3 +5,5 @@ export const CLEAR_ERROR_TILES = 'UI/CLEAR_ERROR_TILES';
export const DISPLAY_STATIC_MAP = 'UI/DISPLAY_STATIC_MAP';
export const READY_FOR_KIOSK_ANIMATION = 'UI/READY_FOR_KIOSK_ANIMATION';
export const CHECK_ANIMATION_AVAILABILITY = 'UI/CHECK_ANIMATION_AVAILABILITY';
+export const SET_EIC_MEASUREMENT_COMPLETE = 'UI/SET_EIC_MEASUREMENT_COMPLETE';
+export const SET_EIC_MEASUREMENT_ABORTED = 'UI/SET_EIC_MEASUREMENT_ABORTED';
diff --git a/web/js/modules/ui/reducers.js b/web/js/modules/ui/reducers.js
index 5dcab1f08..c27951eb9 100644
--- a/web/js/modules/ui/reducers.js
+++ b/web/js/modules/ui/reducers.js
@@ -6,22 +6,19 @@ import {
CLEAR_ERROR_TILES,
READY_FOR_KIOSK_ANIMATION,
CHECK_ANIMATION_AVAILABILITY,
+ SET_EIC_MEASUREMENT_COMPLETE,
+ SET_EIC_MEASUREMENT_ABORTED,
} from './constants';
export const uiState = {
isDistractionFreeModeActive: false,
isKioskModeActive: false,
displayStaticMap: false,
- eic: '', // 'sa' == subdaily-animation, 'da' == daily-animation
- errorTiles: {
- dailyTiles: [],
- subdailyTiles: [],
- blankTiles: [],
- kioskTileCount: 0,
- lastCheckedDate: null,
- },
+ eic: '', // 'sa' == subdaily-animation, 'da' == daily-animation 'si' == static-imagery
readyForKioskAnimation: false,
animationAvailabilityChecked: false,
+ eicMeasurementComplete: false,
+ eicMeasurementAborted: false,
};
export default function uiReducers(state = uiState, action) {
@@ -65,6 +62,16 @@ export default function uiReducers(state = uiState, action) {
...state,
animationAvailabilityChecked: action.toggleCheck,
};
+ case SET_EIC_MEASUREMENT_COMPLETE:
+ return {
+ ...state,
+ eicMeasurementComplete: true,
+ };
+ case SET_EIC_MEASUREMENT_ABORTED:
+ return {
+ ...state,
+ eicMeasurementAborted: true,
+ };
default:
return state;
}