Skip to content

Interactive interface for browsing global, full-resolution satellite imagery

open dialog on init add marker, add warning if coordinates outside extent, revise util selectors

Ed Platoc0105ae09674
diff --git a/doc/features.md b/doc/features.md
index 3b881878d..a01635484 100644
--- a/doc/features.md
+++ b/doc/features.md
@@ -26,6 +26,11 @@ to disable, set:
This feature uses CGI scripts to query the CMR API on the server. To enable,
edit `config/default/common/features.json` and set `"dataDownload": true`.
+## GeocodeSearch
+
+This feature uses the [ArcGIS World Geocoding Service](https://developers.arcgis.com/rest/geocode/api-reference/overview-world-geocoding-service.htm) to find addresses based on input text, coordinates, and by clicking a spot on the map. To enable,
+edit `config/default/common/features.json` and set `"geocodeSearch": true`.
+
## URL Shortening
This feature uses
diff --git a/web/css/geosearch.css b/web/css/geosearch.css
index f79bea539..f6525ccf4 100644
--- a/web/css/geosearch.css
+++ b/web/css/geosearch.css
@@ -54,6 +54,12 @@
top: 13px;
}
}
+ & svg.svg-inline--fa.fa-exclamation-triangle {
+ color: #d54e21;
+ position: absolute;
+ left: 8px;
+ top: 13px;
+ }
}
/* Geosearch Component */
diff --git a/web/js/components/geosearch/geosearch-input.js b/web/js/components/geosearch/geosearch-input.js
index 0b5d8a18b..cadded013 100644
--- a/web/js/components/geosearch/geosearch-input.js
+++ b/web/js/components/geosearch/geosearch-input.js
@@ -3,7 +3,7 @@ import PropTypes from 'prop-types';
import Autocomplete from 'react-autocomplete';
import { Button, InputGroupAddon } from 'reactstrap';
import { FontAwesomeIcon } from '@fortawesome/react-fontawesome';
-import { faSearchLocation } from '@fortawesome/free-solid-svg-icons';
+import { faExclamationTriangle, faSearchLocation } from '@fortawesome/free-solid-svg-icons';
class SearchBox extends Component {
constructor(props) {
@@ -114,15 +114,50 @@ class SearchBox extends Component {
);
}
+ // render alert icon
+ renderAlertIcon = () => {
+ const {
+ coordinates, isMobile, showExtentAlert,
+ } = this.props;
+ const hasCoordinates = coordinates.length > 0;
+ // eslint-disable-next-line no-nested-ternary
+ const buttonContainerRight = hasCoordinates
+ ? isMobile ? '121px' : '121px'
+ : '92px';
+
+ return (
+ showExtentAlert && (
+ <InputGroupAddon
+ className="geosearch-submit-input-group-addon"
+ addonType="append"
+ style={{
+ right: buttonContainerRight,
+ }}
+ title="The entered coordinates are outside of the current map extent."
+ >
+ <FontAwesomeIcon icon={faExclamationTriangle} size="1x" />
+ </InputGroupAddon>
+ )
+ );
+ }
+
render() {
const {
- coordinates, inputValue, isMobile, onChange, onSelect, searchResults,
+ coordinates,
+ inputValue,
+ isMobile,
+ onChange,
+ onSelect,
+ searchResults,
+ showExtentAlert,
} = this.props;
const hasCoordinates = coordinates.length > 0;
const wrapperStyleWidth = hasCoordinates ? '268px' : '299px';
const wrapperStyle = {
width: isMobile ? '90%' : wrapperStyleWidth,
- paddingRight: isMobile ? '0' : '26px',
+ paddingRight: isMobile
+ ? '0'
+ : showExtentAlert ? '48px' : '26px',
};
const placeHolderText = isMobile
? 'Enter place name or coordinates'
@@ -150,6 +185,7 @@ class SearchBox extends Component {
renderMenu={this.renderMenu}
renderItem={this.renderItem}
/>
+ {this.renderAlertIcon()}
{this.renderSubmitButton()}
</div>
);
@@ -167,6 +203,7 @@ SearchBox.propTypes = {
isMobile: PropTypes.bool,
onSelect: PropTypes.func,
onChange: PropTypes.func,
+ showExtentAlert: PropTypes.bool,
};
export default SearchBox;
diff --git a/web/js/components/geosearch/geosearch-modal.js b/web/js/components/geosearch/geosearch-modal.js
index 025313809..d05defcb6 100644
--- a/web/js/components/geosearch/geosearch-modal.js
+++ b/web/js/components/geosearch/geosearch-modal.js
@@ -24,6 +24,7 @@ class SearchComponent extends Component {
searchResults: [],
coordinatesPending: [],
showAlert: false,
+ showExtentAlert: false,
};
this.requestTimer = null;
}
@@ -53,25 +54,36 @@ class SearchComponent extends Component {
// dismiss message instruction alert
dismissAlert = () => this.setState({ showAlert: false });
+ // dismiss extent message error alert
+ dismissExtentAlert = () => this.setState({ showExtentAlert: false });
+
// handle submitting search after inputing coordinates
onCoordinateInputSelect = () => {
- const { selectCoordinatesToFly } = this.props;
+ const { isCoordinatePairWithinExtent, selectCoordinatesToFly } = this.props;
const { coordinatesPending } = this.state;
- const [longitude, latitude] = coordinatesPending;
- reverseGeocode([longitude, latitude]).then((results) => {
- selectCoordinatesToFly([longitude, latitude], results);
- });
- this.setState({
- inputValue: '',
- coordinatesPending: [],
- searchResults: [],
- });
+ const coordinatesWithinExtent = isCoordinatePairWithinExtent(coordinatesPending);
+ if (coordinatesWithinExtent === false) {
+ this.setState({
+ showExtentAlert: true,
+ });
+ } else {
+ const [longitude, latitude] = coordinatesPending;
+ reverseGeocode([longitude, latitude]).then((results) => {
+ selectCoordinatesToFly([longitude, latitude], results);
+ });
+ this.setState({
+ inputValue: '',
+ coordinatesPending: [],
+ showExtentAlert: false,
+ searchResults: [],
+ });
+ }
}
// handle selecting menu item in search results
onSelect=(value, item) => {
- const { selectCoordinatesToFly } = this.props;
+ const { isCoordinatePairWithinExtent, selectCoordinatesToFly } = this.props;
this.setState({
inputValue: value,
searchResults: [item],
@@ -89,7 +101,15 @@ class SearchComponent extends Component {
const { x, y } = location;
const parsedX = parseFloat(x.toPrecision(9));
const parsedY = parseFloat(y.toPrecision(9));
- selectCoordinatesToFly([parsedX, parsedY], addressAttributes);
+
+ const coordinatesWithinExtent = isCoordinatePairWithinExtent([parsedX, parsedY]);
+ if (coordinatesWithinExtent === false) {
+ this.setState({
+ showExtentAlert: true,
+ });
+ } else {
+ selectCoordinatesToFly([parsedX, parsedY], addressAttributes);
+ }
}
});
}
@@ -107,6 +127,7 @@ class SearchComponent extends Component {
this.setState({
searchResults: [],
coordinatesPending: [longitude, latitude],
+ showExtentAlert: false,
});
} else {
clearTimeout(this.requestTimer);
@@ -133,6 +154,7 @@ class SearchComponent extends Component {
this.setState({
isTouchDevice,
showAlert: true,
+ showExtentAlert: false,
inputValue: '',
});
}
@@ -159,10 +181,12 @@ class SearchComponent extends Component {
isTouchDevice,
searchResults,
showAlert,
+ showExtentAlert,
} = this.state;
const hasCoordinates = coordinates.length > 0;
const alertMessage = `${isTouchDevice ? 'Tap' : 'Click'} on map to identify a point on the map.`;
+ const extentAlertMessage = 'Provided location is outside of the map extent. Revise or try a different projection.';
const coordinateButtonGroupContainerClassName = `geosearch-coordinate-group-container ${hasCoordinates ? 'grouped' : ''}`;
return (
<>
@@ -177,6 +201,16 @@ class SearchComponent extends Component {
onDismiss={this.dismissAlert}
/>
)}
+ {showExtentAlert && (
+ <Alert
+ id="geosearch-select-coordinates-extent-alert"
+ isOpen
+ title="Selected Coordinates Outside Current Map Projection"
+ timeout={15000}
+ message={extentAlertMessage}
+ onDismiss={this.dismissExtentAlert}
+ />
+ )}
<div className="geosearch-component">
<InputGroup className="geosearch-search-input-group">
@@ -203,6 +237,7 @@ class SearchComponent extends Component {
geosearchMobileModalOpen={geosearchMobileModalOpen}
isExpanded={isExpanded}
isMobile={isMobile}
+ showExtentAlert={showExtentAlert}
/>
<InputGroupAddon
addonType="append"
@@ -242,6 +277,7 @@ class SearchComponent extends Component {
}
SearchComponent.propTypes = {
+ isCoordinatePairWithinExtent: PropTypes.func,
clearCoordinates: PropTypes.func,
coordinates: PropTypes.array,
geosearchMobileModalOpen: PropTypes.bool,
diff --git a/web/js/components/geosearch/geosearch.js b/web/js/components/geosearch/geosearch.js
index 8e126ef58..42444fe60 100644
--- a/web/js/components/geosearch/geosearch.js
+++ b/web/js/components/geosearch/geosearch.js
@@ -9,6 +9,9 @@ import {
toggleShowGeosearch,
toggleReverseGeocodeActive,
} from '../../modules/geosearch/actions';
+import {
+ areCoordinatesWithinExtent,
+} from '../../modules/geosearch/selectors';
class Geosearch extends React.Component {
constructor(props) {
@@ -26,6 +29,7 @@ class Geosearch extends React.Component {
renderSearchComponent = (isMobile) => {
const {
+ isCoordinatePairWithinExtent,
clearCoordinates,
coordinates,
geosearchMobileModalOpen,
@@ -37,6 +41,7 @@ class Geosearch extends React.Component {
return (
<GeosearchModal
+ isCoordinatePairWithinExtent={isCoordinatePairWithinExtent}
coordinates={coordinates}
geosearchMobileModalOpen={geosearchMobileModalOpen}
isExpanded={isExpanded}
@@ -75,6 +80,7 @@ const mapStateToProps = (state) => {
const {
browser,
config,
+ map,
modal,
measure,
animation,
@@ -96,6 +102,7 @@ const mapStateToProps = (state) => {
coordinates,
isExpanded,
geosearchMobileModalOpen,
+ isCoordinatePairWithinExtent: (targetCoordinates) => areCoordinatesWithinExtent(map, config, targetCoordinates),
isMobile,
shouldCollapseFromOtherUI,
isFeatureEnabled,
@@ -118,6 +125,7 @@ const mapDispatchToProps = (dispatch) => ({
});
Geosearch.propTypes = {
+ isCoordinatePairWithinExtent: PropTypes.func,
isFeatureEnabled: PropTypes.bool,
clearCoordinates: PropTypes.func,
coordinates: PropTypes.array,
diff --git a/web/js/components/geosearch/ol-coordinates-marker-util.js b/web/js/components/geosearch/ol-coordinates-marker-util.js
index 62da61607..782c3c11a 100644
--- a/web/js/components/geosearch/ol-coordinates-marker-util.js
+++ b/web/js/components/geosearch/ol-coordinates-marker-util.js
@@ -31,7 +31,7 @@ function getCoordinateDisplayPrecision(coordinate) {
*
* @returns {Void}
*/
-function renderTooltip(map, config, coordinates, coordinatesMetadata) {
+export function renderTooltip(map, config, coordinates, coordinatesMetadata) {
const { projections } = config;
const { proj } = map;
const { crs } = projections[proj];
@@ -73,6 +73,52 @@ function renderTooltip(map, config, coordinates, coordinatesMetadata) {
), tooltipOverlay.getElement());
}
+/**
+ * getCoordinatesMetadata for tooltip display
+ *
+ * @param {Object} geocodeProperties
+ *
+ * @returns {Object} coordinatesMetadata
+ */
+export function getCoordinatesMetadata(geocodeProperties) {
+ const { latitude, longitude, reverseGeocodeResults } = geocodeProperties;
+ const { address, error } = reverseGeocodeResults;
+
+ const parsedLatitude = getCoordinateDisplayPrecision(latitude);
+ const parsedLongitude = getCoordinateDisplayPrecision(longitude);
+
+ // build title and metadata based on available parameters
+ let title;
+ if (error) {
+ title = `${parsedLatitude}, ${parsedLongitude}`;
+ } else if (address) {
+ /* eslint-disable camelcase */
+ const {
+ Addr_type,
+ Match_addr,
+ ShortLabel,
+ City,
+ Region,
+ } = address;
+ if (Addr_type === 'PointAddress') {
+ title = `${ShortLabel}, ${City}, ${Region}`;
+ } else if (City && Region) {
+ title = `${City}, ${Region}`;
+ } else {
+ title = `${Match_addr}`;
+ }
+ }
+ const coordinatesMetadata = {
+ features: {
+ latitude: parsedLatitude,
+ longitude: parsedLongitude,
+ },
+ title,
+ };
+
+ return coordinatesMetadata;
+}
+
/**
* Get coordinate dialog feature at clicked map pixel
*
@@ -81,7 +127,7 @@ function renderTooltip(map, config, coordinates, coordinatesMetadata) {
*
* @returns {Void}
*/
-export default function getCoordinatesDialogAtMapPixel(pixels, map, config) {
+export function getCoordinatesDialogAtMapPixel(pixels, map, config) {
// check for existing coordinate marker tooltip overlay and prevent multiple renders
const mapOverlays = map.getOverlays().getArray();
const coordinatesTooltipOverlay = mapOverlays.filter((overlay) => {
@@ -96,41 +142,10 @@ export default function getCoordinatesDialogAtMapPixel(pixels, map, config) {
const featureId = feature.getId();
if (featureId === 'coordinates-map-marker') {
const featureProperties = feature.getProperties();
+ const { latitude, longitude } = featureProperties;
- const { latitude, longitude, reverseGeocodeResults } = featureProperties;
- const { address, error } = reverseGeocodeResults;
-
- const parsedLatitude = getCoordinateDisplayPrecision(latitude);
- const parsedLongitude = getCoordinateDisplayPrecision(longitude);
-
- // build title and metadata based on available parameters
- let title;
- if (error) {
- title = `${parsedLatitude}, ${parsedLongitude}`;
- } else if (address) {
- /* eslint-disable camelcase */
- const {
- Addr_type,
- Match_addr,
- ShortLabel,
- City,
- Region,
- } = address;
- if (Addr_type === 'PointAddress') {
- title = `${ShortLabel}, ${City}, ${Region}`;
- } else if (City && Region) {
- title = `${City}, ${Region}`;
- } else {
- title = `${Match_addr}`;
- }
- }
- const coordinatesMetadata = {
- features: {
- latitude: parsedLatitude,
- longitude: parsedLongitude,
- },
- title,
- };
+ // get metadata for tooltip
+ const coordinatesMetadata = getCoordinatesMetadata(featureProperties);
// create tooltip overlay React DOM element
renderTooltip(map, config, [latitude, longitude], coordinatesMetadata);
diff --git a/web/js/components/geosearch/ol-coordinates-marker.js b/web/js/components/geosearch/ol-coordinates-marker.js
index 187199922..2f4f5c0a0 100644
--- a/web/js/components/geosearch/ol-coordinates-marker.js
+++ b/web/js/components/geosearch/ol-coordinates-marker.js
@@ -6,7 +6,7 @@ import React from 'react';
import PropTypes from 'prop-types';
import { transform } from 'ol/proj';
import { changeCursor as changeCursorActionCreator } from '../../modules/map/actions';
-import getCoordinatesDialogAtMapPixel from './ol-coordinates-marker-util';
+import { getCoordinatesDialogAtMapPixel } from './ol-coordinates-marker-util';
export class CoordinatesInteractions extends React.Component {
constructor(props) {
diff --git a/web/js/components/image-download/panel.js b/web/js/components/image-download/panel.js
index ad8e553fe..3c3aa691b 100644
--- a/web/js/components/image-download/panel.js
+++ b/web/js/components/image-download/panel.js
@@ -44,7 +44,7 @@ export default class ImageResSelection extends React.Component {
onDownload(width, height) {
const {
- getLayers, url, lonlats, projection, date,
+ getLayers, url, lonlats, projection, date, markerCoordinates,
} = this.props;
const { fileType, isWorldfile, resolution } = this.state;
const time = new Date(date.getTime());
@@ -59,6 +59,7 @@ export default class ImageResSelection extends React.Component {
time,
fileType,
fileType === 'application/vnd.google-earth.kmz' ? false : isWorldfile,
+ markerCoordinates,
);
if (url) {
@@ -209,6 +210,7 @@ ImageResSelection.propTypes = {
isWorldfile: PropTypes.bool,
lonlats: PropTypes.array,
maxImageSize: PropTypes.string,
+ markerCoordinates: PropTypes.array,
onPanelChange: PropTypes.func,
projection: PropTypes.object,
resolution: PropTypes.string,
diff --git a/web/js/containers/image-download.js b/web/js/containers/image-download.js
index ec10cc00b..ed833e439 100644
--- a/web/js/containers/image-download.js
+++ b/web/js/containers/image-download.js
@@ -74,6 +74,7 @@ class ImageDownloadContainer extends Component {
date,
getLayers,
hasSubdailyLayers,
+ markerCoordinates,
onPanelChange,
} = this.props;
const {
@@ -112,6 +113,7 @@ class ImageDownloadContainer extends Component {
resolution={newResolution}
isWorldfile={isWorldfile}
hasSubdailyLayers={hasSubdailyLayers}
+ markerCoordinates={markerCoordinates}
date={date}
url={url}
crs={crs}
@@ -153,6 +155,7 @@ function mapStateToProps(state) {
config,
proj,
browser,
+ geosearch,
layers,
compare,
date,
@@ -163,6 +166,7 @@ function mapStateToProps(state) {
isWorldfile, fileType, resolution, boundaries,
} = imageDownload;
const { screenWidth, screenHeight } = browser;
+ const markerCoordinates = geosearch.coordinates;
const activeDateStr = compare.isCompareA ? 'selected' : 'selectedB';
const activeStr = compare.activeString;
const hasSubdailyLayers = hasSubDailySelector(layers[activeStr]);
@@ -186,6 +190,7 @@ function mapStateToProps(state) {
resolution,
boundaries,
hasSubdailyLayers,
+ markerCoordinates,
date: date[activeDateStr],
getLayers: () => getLayers(
layers[compare.activeString],
@@ -230,6 +235,7 @@ ImageDownloadContainer.propTypes = {
getLayers: PropTypes.func,
hasSubdailyLayers: PropTypes.bool,
isWorldfile: PropTypes.bool,
+ markerCoordinates: PropTypes.array,
resolution: PropTypes.string,
screenHeight: PropTypes.number,
screenWidth: PropTypes.number,
diff --git a/web/js/location.js b/web/js/location.js
index 1c62bd77e..933344852 100644
--- a/web/js/location.js
+++ b/web/js/location.js
@@ -446,7 +446,7 @@ const getParameters = function(config, parameters) {
serialize: (coordinates, state) => {
const { map } = state;
if (map.ui.selected) {
- const { coordinatesWithinExtent } = areCoordinatesWithinExtent(map, config, coordinates);
+ const coordinatesWithinExtent = areCoordinatesWithinExtent(map, config, coordinates);
if (!coordinatesWithinExtent) {
return;
}
diff --git a/web/js/modules/animation/selectors.js b/web/js/modules/animation/selectors.js
index 2edeb6c76..40ae9c399 100644
--- a/web/js/modules/animation/selectors.js
+++ b/web/js/modules/animation/selectors.js
@@ -24,7 +24,7 @@ export default function getImageArray(
state,
) {
const {
- animation, proj, map, date, layers, compare,
+ animation, proj, map, date, layers, compare, geosearch,
} = state;
const { startDate, endDate, url } = gifComponentProps;
const { boundaries, showDates } = gifComponentState;
@@ -36,6 +36,7 @@ export default function getImageArray(
const fromDate = new Date(startDate);
const toDate = new Date(endDate);
const isSubDaily = hasSubDaily(layers[activeString]);
+ const markerCoordinates = geosearch.coordinates;
let current = fromDate;
let j = 0;
let src;
@@ -56,7 +57,7 @@ export default function getImageArray(
products = getProducts(layers[activeString], current, state);
const lonlats = imageUtilGetCoordsFromPixelValues(boundaries, map.ui.selected);
- const dlURL = getDownloadUrl(url, proj, products, lonlats, dimensions, current);
+ const dlURL = getDownloadUrl(url, proj, products, lonlats, dimensions, current, false, false, markerCoordinates);
src = util.format(dlURL, strDate);
a.push({
diff --git a/web/js/modules/geosearch/actions.js b/web/js/modules/geosearch/actions.js
index 20f257978..4cf318fa4 100644
--- a/web/js/modules/geosearch/actions.js
+++ b/web/js/modules/geosearch/actions.js
@@ -12,6 +12,7 @@ import {
} from './selectors';
import { getMaxZoomLevelLayerCollection } from '../layers/selectors';
import { setLocalStorageCollapseState } from './util';
+import { getCoordinatesMetadata, renderTooltip } from '../../components/geosearch/ol-coordinates-marker-util';
export function toggleShowGeosearch() {
return (dispatch, getState) => {
@@ -70,6 +71,12 @@ export function selectCoordinatesToFly(coordinates, reverseGeocodeResults) {
animateCoordinates(map, config, coordinates, maxZoom);
+ // handle render initial tooltip
+ const [longitude, latitude] = coordinates;
+ const geocodeProperties = { latitude, longitude, reverseGeocodeResults };
+ const coordinatesMetadata = getCoordinatesMetadata(geocodeProperties);
+ renderTooltip(map.ui.selected, config, [latitude, longitude], coordinatesMetadata);
+
dispatch({
type: SELECT_COORDINATES_TO_FLY,
value: false,
diff --git a/web/js/modules/geosearch/selectors.js b/web/js/modules/geosearch/selectors.js
index 62fcda07e..46ee6231a 100644
--- a/web/js/modules/geosearch/selectors.js
+++ b/web/js/modules/geosearch/selectors.js
@@ -29,29 +29,33 @@ export function areCoordinatesWithinExtent(map, config, coordinates) {
const { maxExtent, crs } = projections[proj];
let coordinatesWithinExtent;
- let transformedCoordinates;
if (proj !== 'geographic') {
- transformedCoordinates = coordinatesCRSTransform(coordinates, 'EPSG:4326', crs);
+ const transformedCoordinates = coordinatesCRSTransform(coordinates, 'EPSG:4326', crs);
coordinatesWithinExtent = containsXY(maxExtent, transformedCoordinates[0], transformedCoordinates[1]);
} else {
coordinatesWithinExtent = containsXY(maxExtent, coordinates[0], coordinates[1]);
}
- return {
- coordinatesWithinExtent,
- transformedCoordinates,
- };
+ return coordinatesWithinExtent;
}
export function addCoordinatesMarker(activeMarker, config, map, coordinates, reverseGeocodeResults) {
+ const { projections } = config;
const { selected } = map.ui;
+ const { proj } = selected;
+ const { crs } = projections[proj];
removeCoordinatesMarker(activeMarker, map);
- const { coordinatesWithinExtent, transformedCoordinates } = areCoordinatesWithinExtent(map, config, coordinates);
+ const coordinatesWithinExtent = areCoordinatesWithinExtent(map, config, coordinates);
if (!coordinatesWithinExtent) {
return false;
}
+ let transformedCoordinates = false;
+ if (proj !== 'geographic') {
+ transformedCoordinates = coordinatesCRSTransform(coordinates, 'EPSG:4326', crs);
+ }
+
const marker = createPin(coordinates, transformedCoordinates, reverseGeocodeResults);
selected.addLayer(marker);
selected.renderSync();
diff --git a/web/js/modules/image-download/util.js b/web/js/modules/image-download/util.js
index 59f63d0f3..59c77bb74 100644
--- a/web/js/modules/image-download/util.js
+++ b/web/js/modules/image-download/util.js
@@ -1,7 +1,11 @@
-import lodashEach from 'lodash/each';
-import lodashGet from 'lodash/get';
+import {
+ each as lodashEach,
+ get as lodashGet,
+} from 'lodash';
+import { boundingExtent, containsCoordinate } from 'ol/extent';
import util from '../../util/util';
import { nearestInterval } from '../layers/util';
+import { coordinatesCRSTransform } from '../projection/util';
const GEO_ESTIMATION_CONSTANT = 256.0;
const POLAR_ESTIMATION_CONSTANT = 0.002197265625;
@@ -35,8 +39,9 @@ export function getLatestIntervalTime(layerDefs, dateTime) {
* @param {Object} dimensions
* @param {Date} dateTime
* @param {Boolean} isWorldfile
+ * @param {Array} markerCoordinates
*/
-export function getDownloadUrl(url, proj, layerDefs, lonlats, dimensions, dateTime, fileType, isWorldfile) {
+export function getDownloadUrl(url, proj, layerDefs, lonlats, dimensions, dateTime, fileType, isWorldfile, markerCoordinates) {
const { crs } = proj.selected;
const layersArray = imageUtilGetLayers(layerDefs, proj.id);
const layerWraps = imageUtilGetLayerWrap(layerDefs);
@@ -61,6 +66,18 @@ export function getDownloadUrl(url, proj, layerDefs, lonlats, dimensions, dateTi
if (isWorldfile) {
params.push('WORLDFILE=true');
}
+ // handle adding coordinates marker
+ if (markerCoordinates.length > 0) {
+ // transform for WVS
+ const coordinates = coordinatesCRSTransform(markerCoordinates, 'EPSG:4326', crs);
+ const [longitude, latitude] = coordinates;
+ // prevent marker requests outside selected bounding box
+ const bboxExtent = boundingExtent([lonlats[0], lonlats[1]]);
+ const coordinatesWithinBbox = containsCoordinate(bboxExtent, coordinates);
+ if (coordinatesWithinBbox) {
+ params.push(`MARKER=${longitude},${latitude}`);
+ }
+ }
return `${url}?${params.join('&')}&ts=${Date.now()}`;
}
diff --git a/web/js/modules/image-download/util.test.js b/web/js/modules/image-download/util.test.js
index 77680e270..3e030a967 100644
--- a/web/js/modules/image-download/util.test.js
+++ b/web/js/modules/image-download/util.test.js
@@ -214,7 +214,8 @@ test('Download URL', () => {
height: 300,
};
const dateTime = new Date('2019-06-24T19:04:00Z');
- const dlURL = getDownloadUrl(url, proj, mockLayerDefs, lonlats, dimensions, dateTime);
+ const geosearchCoordinates = [37.7771, -122.4196];
+ const dlURL = getDownloadUrl(url, proj, mockLayerDefs, lonlats, dimensions, dateTime, false, false, geosearchCoordinates);
const expectedURL = 'http://localhost:3002/api/v1/snapshot'
+ '?REQUEST=GetSnapshot'
+ '&TIME=2019-06-24T00:00:00Z'
@@ -223,6 +224,7 @@ test('Download URL', () => {
+ '&LAYERS=VIIRS_SNPP_CorrectedReflectance_TrueColor'
+ '&WRAP=day'
+ '&FORMAT=image/jpeg'
- + '&WIDTH=300&HEIGHT=300';
+ + '&WIDTH=300&HEIGHT=300'
+ + '&MARKER=37.7771,-122.4196';
expect(dlURL.includes(expectedURL)).toBe(true);
});