Skip to content

Interactive interface for browsing global, full-resolution satellite imagery

implement wms/vector approach #2884

Benjamin Kingd646db7d9852
diff --git a/config/default/common/config/wv.json/layers/sedac/GRanD_Dams.json b/config/default/common/config/wv.json/layers/sedac/GRanD_Dams.json
index 3d9f8b2c5..18a3b8a01 100644
--- a/config/default/common/config/wv.json/layers/sedac/GRanD_Dams.json
+++ b/config/default/common/config/wv.json/layers/sedac/GRanD_Dams.json
@@ -21,7 +21,19 @@
"immutable": true,
"styleProperty": "MAIN_USE",
"unclassified": "Not Classified"
+ },
+ "breakPointLayer": {
+ "id": "GRanD_Dams",
+ "type": "wms",
+ "format": "image/png",
+ "resolutionBreakPoint": 0.03515625,
+ "breakPointType": "max",
+ "projections": {
+ "geographic": {
+ "source": "GIBS:wms"
+ }
+ }
}
}
}
-}
\ No newline at end of file
+}
diff --git a/web/js/app.js b/web/js/app.js
index 03a3adbe4..4a6e3f5cc 100644
--- a/web/js/app.js
+++ b/web/js/app.js
@@ -17,10 +17,11 @@ import Sidebar from './containers/sidebar/sidebar';
// Modal
import Modal from './containers/modal';
-// Other
+// Other/MISC
import Brand from './brand';
import MeasureButton from './components/measure-tool/measure-button';
import FeatureAlert from './components/feature-alert/alert';
+import Alerts from './containers/alerts';
// actions
import Tour from './containers/tour';
@@ -28,6 +29,7 @@ import Timeline from './containers/timeline/timeline';
import AnimationWidget from './containers/animation-widget';
import ErrorBoundary from './containers/error-boundary';
import Debug from './components/util/debug';
+import keyPress from './modules/key-press/actions';
// Dependency CSS
import '../../node_modules/bootstrap/dist/css/bootstrap.min.css';
@@ -83,7 +85,7 @@ import '../css/geostationary-modal.css';
import '../css/orbitTracks.css';
import '../css/facets.css';
import '../pages/css/document.css';
-import keyPress from './modules/key-press/actions';
+
class App extends React.Component {
constructor(props) {
@@ -182,6 +184,7 @@ class App extends React.Component {
<MapInteractions mouseEvents={mapMouseEvents} />
<div id="wv-alert-container" className="wv-alert-container">
<FeatureAlert />
+ <Alerts />
</div>
<Sidebar />
{isTourActive ? <Tour /> : null}
@@ -195,7 +198,6 @@ class App extends React.Component {
{isAnimationWidgetActive ? <AnimationWidget key={locationKey || '2'} /> : null}
</div>
<MeasureButton />
-
<Modal key={modalId} />
<ErrorBoundary>
<Debug parameters={parameters} />
diff --git a/web/js/components/layer/vector/alert.js b/web/js/components/layer/vector/alert.js
new file mode 100644
index 000000000..19b0086dd
--- /dev/null
+++ b/web/js/components/layer/vector/alert.js
@@ -0,0 +1,14 @@
+import React from 'react';
+
+const VectorAlertModalBody = () => (
+ <div className="event-alert-modal-body">
+ <h3 className="wv-data-unavailable-header">
+ Why can’t I click on a feature in a vector layer?
+ </h3>
+ <p>
+ Some vector layers require zooming in order to click.
+ </p>
+ </div>
+);
+
+export default VectorAlertModalBody;
diff --git a/web/js/containers/alerts.js b/web/js/containers/alerts.js
new file mode 100644
index 000000000..b415c9653
--- /dev/null
+++ b/web/js/containers/alerts.js
@@ -0,0 +1,139 @@
+/* eslint-disable no-restricted-syntax */
+import React from 'react';
+import { connect } from 'react-redux';
+import PropTypes from 'prop-types';
+import AlertUtil from '../components/util/alert';
+import EventsAlertModalBody from '../components/events/alert-body';
+import CompareAlertModalBody from '../components/compare/alert';
+import VectorAlertModalBody from '../components/layer/vector/alert';
+import { openCustomContent } from '../modules/modal/actions';
+import util from '../util/util';
+import { hasVectorLayers } from '../modules/layers/util';
+
+const MODAL_PROPERTIES = {
+ eventModalProps: {
+ id: 'event_visibility_info',
+ props: {
+ headerText: 'Events may not be visible at all times.',
+ backdrop: false,
+ size: 'lg',
+ clickableBehindModal: true,
+ bodyComponent: EventsAlertModalBody,
+ desktopOnly: true,
+ },
+ },
+ compareModalProps: {
+ id: 'compare_mode_info',
+ props: {
+ headerText: 'You are now in comparison mode',
+ backdrop: false,
+ size: 'lg',
+ clickableBehindModal: true,
+ bodyComponent: CompareAlertModalBody,
+ desktopOnly: true,
+ },
+ },
+ vectorModalProps: {
+ id: 'vector_layer_info',
+ props: {
+ headerText: 'Vector features may not be clickable at all times.',
+ backdrop: false,
+ size: 'lg',
+ clickableBehindModal: true,
+ bodyComponent: VectorAlertModalBody,
+ desktopOnly: true,
+ },
+ },
+};
+class Alerts extends React.Component {
+ constructor(props) {
+ super(props);
+ const hasLocalStorage = util.browser.localStorage;
+ this.state = {
+ hasDismissedEvents: hasLocalStorage && !!localStorage.getItem('dismissedEventVisibilityAlert'),
+ hasDismissedVectors: hasLocalStorage && !!localStorage.getItem('dismissedVectorAlert'),
+ hasDismissedCompare: hasLocalStorage && !!localStorage.getItem('dismissedCompareAlert'),
+ };
+ }
+
+ /**
+ * Update state and local storage when
+ * alert is dismissed
+ *
+ * @param {String} storageKey
+ * @param {String} stateKey
+ */
+ dismissAlert(storageKey, stateKey) {
+ localStorage.setItem(storageKey, true);
+ this.setState({ [stateKey]: false });
+ }
+
+ render() {
+ const {
+ isEventsActive, isCompareActive, isVectorLayerPresent, openAlertModal, isSmall,
+ } = this.props;
+ const { hasDismissedEvents, hasDismissedVectors, hasDismissedCompare } = this.state;
+ const { eventModalProps, compareModalProps, vectorModalProps } = MODAL_PROPERTIES;
+ if (isSmall) return null;
+ return (
+ <>
+ {!hasDismissedEvents && isEventsActive ? (
+ <AlertUtil
+ id="event-alert"
+ isOpen
+ noPortal
+ onClick={() => openAlertModal(eventModalProps)}
+ onDismiss={() => this.dismissAlert('dismissedEventVisibilityAlert', 'hasDismissedEvents')}
+ message="Events may not be visible at all times."
+ />
+ ) : null}
+ {!hasDismissedCompare && isCompareActive ? (
+ <AlertUtil
+ isOpen
+ noPortal
+ onClick={() => openAlertModal(compareModalProps)}
+ onDismiss={() => this.dismissAlert('dismissedCompareAlert', 'hasDismissedCompare')}
+ message="You are now in comparison mode."
+ />
+ ) : null}
+ {!hasDismissedVectors && isVectorLayerPresent ? (
+ <AlertUtil
+ isOpen
+ noPortal
+ onClick={() => openAlertModal(vectorModalProps)}
+ onDismiss={() => this.dismissAlert('dismissedVectorAlert', 'hasDismissedVectors')}
+ message="Vector features may not be clickable at all times."
+ />
+ ) : null}
+ </>
+ );
+ }
+}
+const mapDispatchToProps = (dispatch) => ({
+ openAlertModal: ({ id, props }) => {
+ dispatch(openCustomContent(id, props));
+ },
+});
+const mapStateToProps = (state) => {
+ const {
+ browser, events, sidebar, compare, layers,
+ } = state;
+ return {
+ isSmall: browser.lessThan.small,
+ isEventsActive: !!(events.selected.id && sidebar.activeTab === 'events'),
+ isCompareActive: compare.active,
+ isVectorLayerPresent: hasVectorLayers(layers, compare),
+ };
+};
+export default connect(
+ mapStateToProps,
+ mapDispatchToProps,
+)(Alerts);
+
+Alerts.propTypes = {
+ isEventsActive: PropTypes.bool,
+ isCompareActive: PropTypes.bool,
+ isVectorLayerPresent: PropTypes.bool,
+ openAlertModal: PropTypes.func,
+ isSmall: PropTypes.bool,
+};
diff --git a/web/js/containers/sidebar/compare.js b/web/js/containers/sidebar/compare.js
index 6a340abf9..463eece6e 100644
--- a/web/js/containers/sidebar/compare.js
+++ b/web/js/containers/sidebar/compare.js
@@ -8,133 +8,92 @@ import Layers from './layers';
import { getLayers } from '../../modules/layers/selectors';
import { toggleActiveCompareState } from '../../modules/compare/actions';
import util from '../../util/util';
-import AlertUtil from '../../components/util/alert';
-import CompareAlertModalBody from '../../components/compare/alert';
-import { openCustomContent } from '../../modules/modal/actions';
-const tabHeight = 32;
-class CompareCase extends React.Component {
- constructor(props) {
- super(props);
- this.state = {
- showAlert: props.showAlert,
- };
- this.dismissAlert = this.dismissAlert.bind(this);
- }
-
- dismissAlert() {
- localStorage.setItem('dismissedCompareAlert', true);
- this.setState({ showAlert: false });
- }
- render() {
- const {
- isActive,
- dateStringA,
- dateStringB,
- toggleActiveCompareState,
- isCompareA,
- height,
- layersA,
- layersB,
- openAlertModal,
- checkerBoardPattern,
- } = this.props;
- const { showAlert } = this.state;
+const tabHeight = 32;
+const CompareCase = (props) => {
+ const {
+ isActive,
+ dateStringA,
+ dateStringB,
+ toggleActiveCompareState,
+ isCompareA,
+ height,
+ layersA,
+ layersB,
+ checkerBoardPattern,
+ } = props;
- const outerClass = 'layer-container sidebar-panel';
- const tabClasses = 'ab-tab';
- return (
- <div className={isActive ? '' : 'hidden '}>
- {showAlert ? (
- <AlertUtil
- isOpen
- onClick={openAlertModal}
- onDismiss={this.dismissAlert}
- message="You are now in comparison mode."
- />
- )
- : ''}
- <div className={outerClass}>
- <div className="ab-tabs-case">
- <Nav tabs>
- <NavItem>
- <NavLink
- className={
+ const outerClass = 'layer-container sidebar-panel';
+ const tabClasses = 'ab-tab';
+ return (
+ <div className={isActive ? '' : 'hidden '}>
+ <div className={outerClass}>
+ <div className="ab-tabs-case">
+ <Nav tabs>
+ <NavItem>
+ <NavLink
+ className={
isCompareA
? `${tabClasses} first-tab active`
: `${tabClasses} first-tab`
}
- onClick={toggleActiveCompareState}
- >
- <i className="productsIcon selected icon-layers" />
- {` A: ${dateStringA}`}
- </NavLink>
- </NavItem>
- <NavItem>
- <NavLink
- className={
+ onClick={toggleActiveCompareState}
+ >
+ <i className="productsIcon selected icon-layers" />
+ {` A: ${dateStringA}`}
+ </NavLink>
+ </NavItem>
+ <NavItem>
+ <NavLink
+ className={
!isCompareA
? `${tabClasses} second-tab active`
: `${tabClasses} second-tab`
}
- onClick={toggleActiveCompareState}
- >
- <i className="productsIcon selected icon-layers" />
- {` B: ${dateStringB}`}
- </NavLink>
- </NavItem>
- </Nav>
- <TabContent activeTab={isCompareA ? '1' : '2'}>
- <TabPane tabId="1">
- <Layers
- isActive={isCompareA}
- activeOverlays={layersA}
- layerGroupName="active"
- height={height - tabHeight}
- checkerBoardPattern={checkerBoardPattern}
- />
- </TabPane>
- <TabPane tabId="2">
- <Layers
- isActive={!isCompareA}
- activeOverlays={layersB}
- layerGroupName="activeB"
- height={height - tabHeight}
- checkerBoardPattern={checkerBoardPattern}
- />
- </TabPane>
- </TabContent>
- </div>
+ onClick={toggleActiveCompareState}
+ >
+ <i className="productsIcon selected icon-layers" />
+ {` B: ${dateStringB}`}
+ </NavLink>
+ </NavItem>
+ </Nav>
+ <TabContent activeTab={isCompareA ? '1' : '2'}>
+ <TabPane tabId="1">
+ <Layers
+ isActive={isCompareA}
+ activeOverlays={layersA}
+ layerGroupName="active"
+ height={height - tabHeight}
+ checkerBoardPattern={checkerBoardPattern}
+ />
+ </TabPane>
+ <TabPane tabId="2">
+ <Layers
+ isActive={!isCompareA}
+ activeOverlays={layersB}
+ layerGroupName="activeB"
+ height={height - tabHeight}
+ checkerBoardPattern={checkerBoardPattern}
+ />
+ </TabPane>
+ </TabContent>
</div>
</div>
- );
- }
-}
+ </div>
+ );
+};
+
const mapDispatchToProps = (dispatch) => ({
toggleActiveCompareState: () => {
dispatch(toggleActiveCompareState());
},
- openAlertModal: () => {
- dispatch(
- openCustomContent('compare_mode_info', {
- headerText: 'You are now in comparison mode',
- backdrop: false,
- size: 'lg',
- clickableBehindModal: true,
- bodyComponent: CompareAlertModalBody,
- desktopOnly: true,
- }),
- );
- },
});
function mapStateToProps(state, ownProps) {
const {
- layers, compare, date, browser,
+ layers, compare, date,
} = state;
- const showAlert = util.browser.localStorage
- && browser.greaterThan.small
- && !localStorage.getItem('dismissedCompareAlert');
+
return {
isCompareA: compare.isCompareA,
@@ -144,7 +103,6 @@ function mapStateToProps(state, ownProps) {
dateStringB: util.toISOStringDate(date.selectedB),
isActive: compare.active,
height: ownProps.height,
- showAlert,
};
}
CompareCase.propTypes = {
@@ -156,8 +114,6 @@ CompareCase.propTypes = {
isCompareA: PropTypes.bool,
layersA: PropTypes.object,
layersB: PropTypes.object,
- openAlertModal: PropTypes.func,
- showAlert: PropTypes.bool,
toggleActiveCompareState: PropTypes.func,
};
export default connect(
diff --git a/web/js/containers/sidebar/events.js b/web/js/containers/sidebar/events.js
index e625ac112..a7e0a3354 100644
--- a/web/js/containers/sidebar/events.js
+++ b/web/js/containers/sidebar/events.js
@@ -4,8 +4,6 @@ import { connect } from 'react-redux';
import { get as lodashGet } from 'lodash';
import Event from '../../components/sidebar/event';
import Scrollbars from '../../components/util/scrollbar';
-import AlertUtil from '../../components/util/alert';
-import { openCustomContent } from '../../modules/modal/actions';
import {
requestEvents,
requestCategories,
@@ -13,8 +11,6 @@ import {
selectEvent,
deselectEvent,
} from '../../modules/natural-events/actions';
-import util from '../../util/util';
-import EventsAlertModalBody from '../../components/events/alert-body';
import { getEventsWithinExtent } from '../../modules/natural-events/selectors';
import { collapseSidebar } from '../../modules/sidebar/actions';
import { selectDate } from '../../modules/date/actions';
@@ -23,10 +19,6 @@ class Events extends React.Component {
constructor(props) {
super(props);
this.initRequests();
- this.state = {
- showAlert: util.browser.localStorage && !localStorage.getItem('dismissedEventVisibilityAlert'),
- };
- this.dismissAlert = this.dismissAlert.bind(this);
}
initRequests() {
@@ -65,11 +57,6 @@ class Events extends React.Component {
requestSources(sourceRequestURL);
}
- dismissAlert() {
- localStorage.setItem('dismissedEventVisibilityAlert', true);
- this.setState({ showAlert: false });
- }
-
render() {
const {
events,
@@ -83,7 +70,6 @@ class Events extends React.Component {
deselectEvent,
hasRequestError,
isMobile,
- openAlertModal,
showAlert,
selectedDate,
} = this.props;
@@ -107,20 +93,6 @@ class Events extends React.Component {
return (
<>
- {
- // eslint-disable-next-line react/destructuring-assignment
- showAlert && this.state.showAlert
- ? (
- <AlertUtil
- id="event-alert"
- isOpen
- onClick={openAlertModal}
- onDismiss={this.dismissAlert}
- message="Events may not be visible at all times."
- />
- )
- : ''
- }
<Scrollbars
style={{ maxHeight: `${height}px` }}
scrollBarVerticalTop={scrollBarVerticalTop}
@@ -177,18 +149,6 @@ const mapDispatchToProps = (dispatch) => ({
dispatch(selectDate(new Date(dateStr)));
}
},
- openAlertModal: () => {
- dispatch(
- openCustomContent('event_visibility_info', {
- headerText: 'Events may not be visible at all times.',
- backdrop: false,
- size: 'lg',
- clickableBehindModal: true,
- bodyComponent: EventsAlertModalBody,
- desktopOnly: true,
- }),
- );
- },
deselectEvent: (id, date) => {
dispatch(deselectEvent());
},
@@ -210,7 +170,6 @@ function mapStateToProps(state) {
config,
proj,
browser,
- sidebar,
date,
compare,
} = state;
@@ -246,13 +205,6 @@ function mapStateToProps(state) {
);
}
- const showAlert = Boolean(
- util.browser.localStorage
- && selected.id
- && sidebar.activeTab === 'events'
- && browser.greaterThan.small
- && !localStorage.getItem('dismissedEventVisibilityAlert'),
- );
return {
events,
showAll,
@@ -265,7 +217,6 @@ function mapStateToProps(state) {
apiURL,
config,
isMobile: browser.lessThan.medium,
- showAlert,
selectedDate: date[activeDatestr].toISOString().split('T')[0],
};
}
@@ -283,7 +234,6 @@ Events.propTypes = {
height: PropTypes.number,
isLoading: PropTypes.bool,
isMobile: PropTypes.bool,
- openAlertModal: PropTypes.func,
requestCategories: PropTypes.func,
requestEvents: PropTypes.func,
requestSources: PropTypes.func,
diff --git a/web/js/map/layerbuilder.js b/web/js/map/layerbuilder.js
index 2b2bfadf4..776653661 100644
--- a/web/js/map/layerbuilder.js
+++ b/web/js/map/layerbuilder.js
@@ -11,8 +11,10 @@ import SourceVectorTile from 'ol/source/VectorTile';
import lodashCloneDeep from 'lodash/cloneDeep';
import lodashMerge from 'lodash/merge';
import lodashEach from 'lodash/each';
+import lodashGet from 'lodash/get';
import util from '../util/util';
import lookupFactory from '../ol/lookupimagetile';
+import { createVectorUrl, mergeBreakpointLayerAttributes } from './util';
import { datesinDateRanges, prevDateInDateRange } from '../modules/layers/util';
import {
isActive as isPaletteActive,
@@ -22,7 +24,7 @@ import {
import {
isActive as isVectorStyleActive,
getKey as getVectorStyleKeys,
- setStyleFunction,
+ applyStyle,
} from '../modules/vector-styles/selectors';
import {
nearestInterval,
@@ -45,12 +47,12 @@ export default function mapLayerBuilder(models, config, cache, ui, store) {
*/
const getLayer = (createLayerFunc, def, options, attributes, wrapLayer) => {
const state = store.getState();
- const layer = createLayerFunc(def, options, null, state);
+ const layer = createLayerFunc(def, options, null, state, attributes);
if (!wrapLayer) {
return layer;
}
- const layerNext = createLayerFunc(def, options, 1, state);
- const layerPrior = createLayerFunc(def, options, -1, state);
+ const layerNext = createLayerFunc(def, options, 1, state, attributes);
+ const layerPrior = createLayerFunc(def, options, -1, state, attributes);
layer.wv = attributes;
layerPrior.wv = attributes;
layerNext.wv = attributes;
@@ -115,6 +117,7 @@ export default function mapLayerBuilder(models, config, cache, ui, store) {
};
def = lodashCloneDeep(def);
lodashMerge(def, def.projections[proj.id]);
+ if (def.breakPointLayer) def = mergeBreakpointLayerAttributes(def, proj.id);
const wrapLayer = proj.id === 'geographic' && (def.wrapadjacentdays === true || def.wrapX);
switch (def.type) {
@@ -351,7 +354,16 @@ export default function mapLayerBuilder(models, config, cache, ui, store) {
* @param {object} options - Layer options
* @returns {object} OpenLayers Vector layer
*/
- const createLayerVector = function(def, options, day, state) {
+/**
+ * Create a new Vector Layer
+ *
+ * @method createLayerVector
+ * @static
+ * @param {object} def - Layer Specs
+ * @param {object} options - Layer options
+ * @returns {object} OpenLayers Vector layer
+ */
+ const createLayerVector = function(def, options, day, state, attributes) {
const { proj, compare } = state;
let date;
let gridExtent;
@@ -360,8 +372,6 @@ export default function mapLayerBuilder(models, config, cache, ui, store) {
let layerExtent;
const selectedProj = proj.selected;
const activeDateStr = compare.isCompareA ? 'selected' : 'selectedB';
- const activeGroupStr = options.group ? options.group : compare.activeString;
-
const source = config.sources[def.source];
gridExtent = selectedProj.maxExtent;
layerExtent = gridExtent;
@@ -371,6 +381,7 @@ export default function mapLayerBuilder(models, config, cache, ui, store) {
throw new Error(`${def.id}: Invalid source: ${def.source}`);
}
const matrixSet = source.matrixSets[def.matrixSet];
+
if (!matrixSet) {
throw new Error(`${def.id}: Undefined matrix set: ${def.matrixSet}`);
}
@@ -396,63 +407,53 @@ export default function mapLayerBuilder(models, config, cache, ui, store) {
}
const layerName = def.layer || def.id;
- const tms = def.matrixSet;
-
+ const tileMatrixSet = def.matrixSet;
date = options.date || state.date[activeDateStr];
- if (day && def.wrapadjacentdays) {
- date = util.dateAdd(date, 'day', day);
- }
- const urlParameters = `${'?'
- + 'TIME='}${
- util.toISOStringSeconds(util.roundTimeOneMinute(date))
- }&layer=${
- layerName
- }&tilematrixset=${
- tms
- }&Service=WMTS`
- + '&Request=GetTile'
- + '&Version=1.0.0'
- + '&FORMAT=application%2Fvnd.mapbox-vector-tile'
- + '&TileMatrix={z}&TileCol={x}&TileRow={y}';
+ if (day && def.wrapadjacentdays) date = util.dateAdd(date, 'day', day);
+ const urlParameters = createVectorUrl(date, layerName, tileMatrixSet);
const wrapX = !!(day === 1 || day === -1);
+ const breakPointLayerDef = def.breakPointLayer;
+ const breakPointResolution = lodashGet(def, 'breakPointLayer.resolutionBreakPoint');
+ const breakPointType = lodashGet(def, 'breakPointLayer.breakPointType');
+ const isMaxBreakPoint = breakPointType === 'max';
+ const isMinBreakPoint = breakPointType === 'min';
+
const sourceOptions = new SourceVectorTile({
url: source.url + urlParameters,
layer: layerName,
day,
format: new MVT(),
- matrixSet: tms,
+ matrixSet: tileMatrixSet,
wrapX,
tileGrid: new OlTileGridTileGrid({
extent: gridExtent,
resolutions: matrixSet.resolutions,
tileSize: matrixSet.tileSize,
origin: start,
+ sizes: matrixSet.tileMatrices,
+
}),
});
-
const layer = new LayerVectorTile({
extent: layerExtent,
source: sourceOptions,
renderMode: 'image',
+ preload: 10,
+ ...isMaxBreakPoint && { maxResolution: breakPointResolution },
+ ...isMinBreakPoint && { minResolution: breakPointResolution },
});
-
- if (config.vectorStyles && def.vectorStyle && def.vectorStyle.id) {
- const { vectorStyles } = config;
- let vectorStyleId;
-
- vectorStyleId = def.vectorStyle.id;
- if (state.layers[activeGroupStr]) {
- const layers = state.layers[activeGroupStr];
- layers.forEach((layer) => {
- if (layer.id === layerName && layer.custom) {
- vectorStyleId = layer.custom;
- }
- });
- }
- setStyleFunction(def, vectorStyleId, vectorStyles, layer, state);
- }
+ applyStyle(def, layer, state, options);
layer.wrap = day;
+ layer.wv = attributes;
+ layer.isVector = true;
+ const newDef = { ...def, ...breakPointLayerDef };
+ if (breakPointLayerDef) {
+ const layerGroup = new OlLayerGroup({
+ layers: [layer, createLayerWMS(newDef, options, day, state)],
+ });
+ return layerGroup;
+ }
return layer;
};
@@ -546,6 +547,7 @@ export default function mapLayerBuilder(models, config, cache, ui, store) {
const layer = new OlLayerTile({
preload: Infinity,
extent,
+ ...!!def.resolutionBreakPoint && { minResolution: def.resolutionBreakPoint },
source: new OlSourceTileWMS(sourceOptions),
});
return layer;
diff --git a/web/js/map/util.js b/web/js/map/util.js
index f1455b127..55233d024 100644
--- a/web/js/map/util.js
+++ b/web/js/map/util.js
@@ -1,3 +1,5 @@
+import util from '../util/util';
+
const ZOOM_DURATION = 250;
/*
@@ -37,3 +39,37 @@ export function getActiveLayerGroup(map, layerGroupString) {
}
return group;
}
+/**
+ * Create x/y/z vectortile requester url
+ * @param {Date} date
+ * @param {string} layerName
+ * @param {String} tileMatrixSet
+ *
+ * @return {String} URL
+ */
+export function createVectorUrl(date, layerName, tileMatrixSet) {
+ return `${'?'
+ + 'TIME='}${
+ util.toISOStringSeconds(util.roundTimeOneMinute(date))
+ }&layer=${
+ layerName
+ }&tilematrixset=${
+ tileMatrixSet
+ }&Service=WMTS`
+ + '&Request=GetTile'
+ + '&Version=1.0.0'
+ + '&FORMAT=application%2Fvnd.mapbox-vector-tile'
+ + '&TileMatrix={z}&TileCol={x}&TileRow={y}';
+}
+/**
+ *
+ * @param {Object} def
+ * @param {String} projId
+ */
+export function mergeBreakpointLayerAttributes(def, projId) {
+ const { breakPointLayer } = def;
+ if (breakPointLayer) {
+ const updatedBreakPointLayer = { ...breakPointLayer, ...breakPointLayer.projections[projId] };
+ return { ...def, breakPointLayer: updatedBreakPointLayer };
+ } return def;
+}
diff --git a/web/js/modules/layers/util.js b/web/js/modules/layers/util.js
index 700bc1f39..f355ee2c4 100644
--- a/web/js/modules/layers/util.js
+++ b/web/js/modules/layers/util.js
@@ -1225,3 +1225,27 @@ export function mapLocationToLayerState(
}
return newStateFromLocation;
}
+/**
+ * Determine if active layers have a vector layer
+ * @param {Object} layersState
+ * @param {Object} compareState
+ *
+ * @return {Boolean}
+ */
+export const hasVectorLayers = (layersState, compareState) => {
+ const { activeString } = compareState;
+ const { active, activeB } = layersState;
+ const layersArray = compareState.active ? active.concat(activeB) : layersState[activeString];
+ const len = layersArray.length;
+ // Used for loop
+ // so break could be used
+ let hasVectorTypeLayer = false;
+ for (let i = 0; i < len; i += 1) {
+ const def = layersArray[i];
+ if (def.type === 'vector' && def.visible) {
+ hasVectorTypeLayer = true;
+ break;
+ }
+ }
+ return hasVectorTypeLayer;
+};
diff --git a/web/js/modules/vector-styles/selectors.js b/web/js/modules/vector-styles/selectors.js
index 0b4f6972c..b24630037 100644
--- a/web/js/modules/vector-styles/selectors.js
+++ b/web/js/modules/vector-styles/selectors.js
@@ -126,6 +126,7 @@ export function setStyleFunction(def, vectorStyleId, vectorStyles, layer, state)
}
const layerArray = layer.getLayers ? layer.getLayers().getArray() : [layer];
lodashEach(layerArray, (layerInLayerGroup) => {
+ layerInLayerGroup = layerInLayerGroup.getLayers ? lodashFind(layerInLayerGroup.getLayers().getArray(), 'isVector') : layerInLayerGroup;
// Apply mapbox-gl styles
const extentStartX = layerInLayerGroup.getExtent()[0];
const acceptableExtent = extentStartX === 180 ? [-180, -90, -110, 90] : extentStartX === -250 ? [110, -90, 180, 90] : null;
@@ -150,7 +151,7 @@ export function setStyleFunction(def, vectorStyleId, vectorStyles, layer, state)
}
return styleFunction(feature, resolution);
});
- } else if ((glStyle.name === 'SEDAC')
+ } else if ((glStyle.name !== 'Orbit Tracks')
&& (selected[layerId] && selected[layerId].length)) {
const selectedFeatures = selected[layerId];
@@ -229,3 +230,32 @@ export function clearStyleFunction(def, vectorStyleId, vectorStyles, layer, stat
}
return update(vectorStyles, { layerId: { maps: { $unset: ['custom'] } } });
}
+
+/** Apply style to new layer
+ *
+ * @param {Object} def
+ * @param {Object} olVectorLayer
+ * @param {Object} state
+ * @param {Object} options
+ *
+ * @return {undefined}
+ */
+export const applyStyle = (def, olVectorLayer, state, options) => {
+ const { config, layers, compare } = state;
+ const activeGroupStr = options.group ? options.group : compare.activeString;
+ const activeLayers = layers[activeGroupStr];
+ const layerName = def.layer || def.id;
+ if (config.vectorStyles && def.vectorStyle && def.vectorStyle.id) {
+ const { vectorStyles } = config;
+ let vectorStyleId;
+ vectorStyleId = def.vectorStyle.id;
+ if (activeLayers) {
+ activeLayers.forEach((layer) => {
+ if (layer.id === layerName && layer.custom) {
+ vectorStyleId = layer.custom;
+ }
+ });
+ }
+ setStyleFunction(def, vectorStyleId, vectorStyles, olVectorLayer, state);
+ }
+};
\ No newline at end of file
diff --git a/web/js/modules/vector-styles/util.js b/web/js/modules/vector-styles/util.js
index fc1a3f1df..e0891a7ed 100644
--- a/web/js/modules/vector-styles/util.js
+++ b/web/js/modules/vector-styles/util.js
@@ -217,7 +217,7 @@ export function onMapClickGetVectorFeatures(pixels, map, state, swipeOffset) {
const data = config.vectorData[vectorDataId];
const properties = data.mvt_properties;
const uniqueIdentifierKey = lodashFind(properties, { Function: 'Identify' }).Identifier;
- const titleObj = lodashFind(properties, { IsLabel: 'True' });
+ const titleObj = lodashFind(properties, 'IsLabel');
const titleKey = titleObj.Identifier;
const uniqueIdentifier = features[uniqueIdentifierKey];