Skip to content

Interactive interface for browsing global, full-resolution satellite imagery

fix issues

Jason Kent5deaf92aa1fc
diff --git a/web/js/map/natural-events/util.js b/web/js/map/natural-events/util.js
index 8162c92b1..0b1e5ae86 100644
--- a/web/js/map/natural-events/util.js
+++ b/web/js/map/natural-events/util.js
@@ -4,15 +4,21 @@ import {
import { transform } from 'ol/proj';
import { getCenter, boundingExtent, containsCoordinate } from 'ol/extent';
import moment from 'moment';
+import * as olProj from 'ol/proj';
import util from '../../util/util';
import { LIMIT_EVENT_REQUEST_COUNT } from '../../modules/natural-events/constants';
+const geographicProj = 'EPSG:4326';
+
export function getEventsRequestURL (baseUrl, selectedDates, categories = [], proj, bbox) {
const params = {
status: 'all',
limit: LIMIT_EVENT_REQUEST_COUNT,
};
const { start, end } = selectedDates;
+ const { crs } = proj.selected;
+ const transformCoords = (coords) => olProj.transform(coords, crs, geographicProj);
+
if (start && end) {
params.start = moment.utc(start).format('YYYY-MM-DD');
params.end = moment.utc(end).format('YYYY-MM-DD');
@@ -20,8 +26,8 @@ export function getEventsRequestURL (baseUrl, selectedDates, categories = [], pr
if (categories.length) {
params.category = categories.map(({ id }) => id).join(',');
}
+
let [minLon, maxLat, maxLon, minLat] = [-180, 90, 180, -90];
- const { crs } = proj.selected;
if (crs === 'EPSG:3413') {
[minLon, maxLat, maxLon, minLat] = [-180, 50, 180, 90];
}
@@ -29,7 +35,9 @@ export function getEventsRequestURL (baseUrl, selectedDates, categories = [], pr
[minLon, maxLat, maxLon, minLat] = [-180, -90, 180, -50];
}
if (bbox && bbox.length) {
- [minLon, maxLat, maxLon, minLat] = bbox;
+ const [minLonA, maxLatA, maxLonA, minLatA] = bbox;
+ [minLon, maxLat] = transformCoords([minLonA, maxLatA]);
+ [maxLon, minLat] = transformCoords([maxLonA, minLatA]);
}
params.bbox = [minLon, maxLat, maxLon, minLat];
diff --git a/web/js/modules/natural-events/util.js b/web/js/modules/natural-events/util.js
index 89a87e191..37f38ebde 100644
--- a/web/js/modules/natural-events/util.js
+++ b/web/js/modules/natural-events/util.js
@@ -61,18 +61,20 @@ export function mapLocationToEventFilterState(parameters, stateFromLocation, sta
? []
: selectedIds.map((id) => allCategories.find((c) => c.id === id));
- let [selectedStartDate, selectedEndDate] = parameters.efd
- ? parameters.efd.split(',')
- : [selectedDates.start, selectedDates.end];
+ let [selectedStartDate, selectedEndDate] = (parameters.efd || ',').split(',');
const eventIsSelected = selected.id && selected.date;
const filterDatesAreSet = selectedStartDate && selectedEndDate;
if (eventIsSelected && !filterDatesAreSet) {
selectedStartDate = selected.date;
selectedEndDate = selected.date;
+ } else {
+ selectedStartDate = selectedDates.start;
+ selectedEndDate = selectedDates.end;
}
+
let showAll;
- if (parameters.efs === 'true') {
+ if (parameters.efs === 'true' || !parameters.efs) {
showAll = true;
} else if (parameters.efs === 'false') {
showAll = false;