Interactive interface for browsing global, full-resolution satellite imagery
disallow bbox filtering in polar projections
Jason Kentdf28b5d379af
diff --git a/web/js/components/sidebar/events-filter.js b/web/js/components/sidebar/events-filter.jsindex 8d734f9c9..c7f07f7fc 100644--- a/web/js/components/sidebar/events-filter.js+++ b/web/js/components/sidebar/events-filter.js@@ -23,6 +23,7 @@ function EventFilterModalBody (props) {closeModal,showAll,parentId,+ isPolarProj,} = props;const [allNone, setAllNone] = useState(!!selectedCategories.length);@@ -120,12 +121,14 @@ function EventFilterModalBody (props) {})}</div>- <Checkbox- id="events-footer-checkbox"- label="Only list events in current map view"- onCheck={() => setListAll(!listAll)}- checked={!listAll}- />+ {!isPolarProj && (+ <Checkbox+ id="events-footer-checkbox"+ label="Only list events in current map view"+ onCheck={() => setListAll(!listAll)}+ checked={!listAll}+ />+ )}<Portal node={document.querySelector(`#${parentId} .modal-footer`)}><Button@@ -151,6 +154,7 @@ function EventFilterModalBody (props) {EventFilterModalBody.propTypes = {closeModal: PropTypes.func,eventCategories: PropTypes.array,+ isPolarProj: PropTypes.bool,parentId: PropTypes.string,selectedCategories: PropTypes.array,selectedStartDate: PropTypes.string,@@ -160,11 +164,15 @@ EventFilterModalBody.propTypes = {};const mapStateToProps = (state) => {- const { events } = state;+ const { events, proj } = state;const {selectedCategories, selectedDates, allCategories, showAll,} = events;++ const isPolarProj = proj.selected.crs === 'EPSG:3031' || proj.selected.crs === 'EPSG:3413';+return {+ isPolarProj,eventCategories: allCategories,selectedCategories,selectedStartDate: selectedDates.start,diff --git a/web/js/containers/sidebar/events.js b/web/js/containers/sidebar/events.jsindex d818f2a18..717746287 100644--- a/web/js/containers/sidebar/events.js+++ b/web/js/containers/sidebar/events.js@@ -1,7 +1,6 @@import React from 'react';import PropTypes from 'prop-types';import { connect } from 'react-redux';-import { get as lodashGet } from 'lodash';import moment from 'moment';import {Button,@@ -216,33 +215,31 @@ const mapStateToProps = (state, ownProps) => {selected, showAll, selectedDates, selectedCategories,} = events;let visibleEventsInProjection = {};- const mapExtent = lodashGet(state, 'map.extent');-const { isEmbedModeActive } = embed;- if (eventsData && mapExtent) {- const extent = showAll ? proj.selected.maxExtent : mapExtent;++ if (eventsData) {+ // TODO don't check this in mapStateToProps or memoize itvisibleEventsInProjection = getEventsWithinExtent(eventsData,selected,- extent,proj.selected,- showAll,+ proj.selected.maxExtent,);}return {- showAll,- selected,- visibleEventsInProjection,isPlaying: animation.isPlaying,isMobile: browser.lessThan.medium,isEmbedModeActive,isAnimatingToEvent: events.isAnimatingToEvent,- selectedCategories,+ showAll,showDates: !!(selectedDates.start && selectedDates.end),+ selected,+ selectedCategories,selectedStartDate: selectedDates.start,selectedEndDate: selectedDates.end,selectedDate: util.toISOStringDate(getSelectedDate(state)),+ visibleEventsInProjection,};};export default connect(diff --git a/web/js/map/natural-events/natural-events.js b/web/js/map/natural-events/natural-events.jsindex 37327d925..f4031fdb2 100644--- a/web/js/map/natural-events/natural-events.js+++ b/web/js/map/natural-events/natural-events.js@@ -65,11 +65,15 @@ class NaturalEvents extends React.Component {filterEventList() {const {- map, proj, eventsData, selectedEvent,+ proj, eventsData, selectedEvent,} = this.props;- const extent = map.getView().calculateExtent();- const eventsInExtentMap = getEventsWithinExtent(eventsData, selectedEvent, extent, proj.selected);+ const eventsInExtentMap = getEventsWithinExtent(+ eventsData,+ selectedEvent,+ proj.selected,+ proj.selected.maxExtent,+ );return eventsData.filter((e) => eventsInExtentMap[e.id]);}diff --git a/web/js/map/natural-events/util.js b/web/js/map/natural-events/util.jsindex 0b1e5ae86..7e63fa6a4 100644--- a/web/js/map/natural-events/util.js+++ b/web/js/map/natural-events/util.js@@ -6,17 +6,19 @@ 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';+import {+ LIMIT_EVENT_REQUEST_COUNT,+} from '../../modules/natural-events/constants';const geographicProj = 'EPSG:4326';export function getEventsRequestURL (baseUrl, selectedDates, categories = [], proj, bbox) {+ const { crs } = proj.selected;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) {@@ -34,8 +36,8 @@ export function getEventsRequestURL (baseUrl, selectedDates, categories = [], prif (crs === 'EPSG:3031') {[minLon, maxLat, maxLon, minLat] = [-180, -90, 180, -50];}- if (bbox && bbox.length) {- const [minLonA, maxLatA, maxLonA, minLatA] = bbox;+ if (bbox && bbox.length && crs === 'EPSG:4326') {+ const [minLonA, minLatA, maxLonA, maxLatA] = bbox;[minLon, maxLat] = transformCoords([minLonA, maxLatA]);[maxLon, minLat] = transformCoords([maxLonA, minLatA]);}@@ -72,14 +74,13 @@ export function getDefaultEventDate(event) {export function getEventsWithinExtent(events,selected,- currentExtent,selectedProj,+ maxExtent,) {- const { maxExtent, crs } = selectedProj;+ const { crs } = selectedProj;const visibleListEvents = {};events.forEach((naturalEvent) => {- const isSelectedEvent = selected.id === naturalEvent.id;let date = getDefaultEventDate(naturalEvent);if (selected && selected.date) {date = selected.date;@@ -106,10 +107,9 @@ export function getEventsWithinExtent(coordinates = getCenter(geomExtent);}- const visibleInProj = containsCoordinate(maxExtent, coordinates);- const visibleInExtent = containsCoordinate(currentExtent, coordinates) && visibleInProj;+ const visibleInExtent = containsCoordinate(maxExtent, coordinates);- if (visibleInExtent || (isSelectedEvent && visibleInProj)) {+ if (visibleInExtent) {visibleListEvents[naturalEvent.id] = true;}});diff --git a/web/js/modules/natural-events/actions.js b/web/js/modules/natural-events/actions.jsindex c707fcd82..5ace850c7 100644--- a/web/js/modules/natural-events/actions.js+++ b/web/js/modules/natural-events/actions.js@@ -2,6 +2,9 @@ import {get as lodashGet,isEqual as lodashEqual,} from 'lodash';+import {+ getEventsRequestURL,+} from '../../map/natural-events/util';import {REQUEST_EVENTS,@@ -12,7 +15,7 @@ import {FINISHED_ANIMATING_TO_EVENT,} from './constants';import { requestAction } from '../core/actions';-import { getEventsRequestURL } from '../../map/natural-events/util';+export function requestEvents(location) {return (dispatch) => requestAction(