Skip to content

Interactive interface for browsing global, full-resolution satellite imagery

add breakpoint capability for polar projections

Benjamin King98c72af9d307
diff --git a/web/js/containers/map-interactions.js b/web/js/containers/map-interactions.js
index 6a7b93a1a..25152cdf0 100644
--- a/web/js/containers/map-interactions.js
+++ b/web/js/containers/map-interactions.js
@@ -7,6 +7,7 @@ import {
get as lodashGet,
includes as lodashIncludes,
} from 'lodash';
+import { transform } from 'ol/proj';
import OlCoordinates from '../components/map/ol-coordinates';
import vectorDialog from './vector-dialog';
import { onMapClickGetVectorFeatures } from '../modules/vector-styles/util';
@@ -37,7 +38,7 @@ export class MapInteractions extends React.Component {
const {
lastSelected, openVectorDiaglog, onCloseModal, selectVectorFeatures,
modalState, getDialogObject, measureIsActive, isMobile, activeLayers,
- activateVectorAlert,
+ activateVectorAlert, proj,
} = this.props;
if (measureIsActive) return;
@@ -54,7 +55,7 @@ export class MapInteractions extends React.Component {
openVectorDiaglog(dialogId, metaArray, offsetLeft, offsetTop, isMobile);
} else {
const mapRes = map.getView().getResolution();
- const hasNonClickableVectorLayerType = hasNonClickableVectorLayer(activeLayers, mapRes);
+ const hasNonClickableVectorLayerType = hasNonClickableVectorLayer(activeLayers, mapRes, proj.id);
if (hasNonClickableVectorLayerType) {
activateVectorAlert();
@@ -71,10 +72,11 @@ export class MapInteractions extends React.Component {
mouseMove(event, map, crs) {
const pixels = map.getEventPixel(event);
const coord = map.getCoordinateFromPixel(pixels);
+
const {
isShowingClick, changeCursor, measureIsActive, compareState, swipeOffset, proj,
} = this.props;
- const [lon, lat] = coord;
+ const [lon, lat] = transform(coord, crs, 'EPSG:4326');
if (lon < -250 || lon > 250 || lat < -90 || lat > 90) {
return;
}
diff --git a/web/js/containers/sidebar/layer.js b/web/js/containers/sidebar/layer.js
index a6bc18b33..48de982e2 100644
--- a/web/js/containers/sidebar/layer.js
+++ b/web/js/containers/sidebar/layer.js
@@ -301,7 +301,7 @@ function mapStateToProps(state, ownProps) {
layerGroupName,
} = ownProps;
const {
- palettes, config, map, layers, compare,
+ palettes, config, map, layers, compare, proj,
} = state;
const hasPalette = !lodashIsEmpty(layer.palette);
const renderedPalettes = palettes.rendered;
@@ -330,7 +330,7 @@ function mapStateToProps(state, ownProps) {
renderedPalette: renderedPalettes[paletteName],
layerGroupName,
isVectorLayer: isVector,
- hasClickableFeature: isVector && isVisible && isVectorLayerClickable(layer, mapRes),
+ hasClickableFeature: isVector && isVisible && isVectorLayerClickable(layer, mapRes, proj.id),
isMobile: state.browser.lessThan.medium,
hasPalette,
getPalette: (layerId, i) => getPalette(layer.id, i, layerGroupName, state),
diff --git a/web/js/map/layerbuilder.js b/web/js/map/layerbuilder.js
index d0acb2155..07d574e2d 100644
--- a/web/js/map/layerbuilder.js
+++ b/web/js/map/layerbuilder.js
@@ -371,7 +371,6 @@ 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}`);
}
@@ -404,7 +403,7 @@ export default function mapLayerBuilder(models, config, cache, ui, store) {
const urlParameters = createVectorUrl(date, layerName, tileMatrixSet);
const wrapX = !!(day === 1 || day === -1);
const breakPointLayerDef = def.breakPointLayer;
- const breakPointResolution = lodashGet(def, 'breakPointLayer.resolutionBreakPoint');
+ const breakPointResolution = lodashGet(def, `breakPointLayer.projections.${proj.id}.resolutionBreakPoint`);
const breakPointType = lodashGet(def, 'breakPointLayer.breakPointType');
const isMaxBreakPoint = breakPointType === 'max';
const isMinBreakPoint = breakPointType === 'min';
@@ -433,6 +432,7 @@ export default function mapLayerBuilder(models, config, cache, ui, store) {
...isMaxBreakPoint && { maxResolution: breakPointResolution },
...isMinBreakPoint && { minResolution: breakPointResolution },
});
+
applyStyle(def, layer, state, options);
layer.wrap = day;
layer.wv = attributes;
@@ -536,10 +536,11 @@ export default function mapLayerBuilder(models, config, cache, ui, store) {
const lookup = getPaletteLookup(def.id, options.group, state);
sourceOptions.tileClass = lookupFactory(lookup, sourceOptions);
}
+ const resolutionBreakPoint = lodashGet(def, `breakPointLayer.projections.${proj.id}.resolutionBreakPoint`);
const layer = new OlLayerTile({
preload: Infinity,
extent,
- ...!!def.resolutionBreakPoint && { minResolution: def.resolutionBreakPoint },
+ ...!!resolutionBreakPoint && { minResolution: resolutionBreakPoint },
source: new OlSourceTileWMS(sourceOptions),
});
return layer;
diff --git a/web/js/modules/layers/util.js b/web/js/modules/layers/util.js
index 96c22ce21..513ff5f15 100644
--- a/web/js/modules/layers/util.js
+++ b/web/js/modules/layers/util.js
@@ -1219,11 +1219,12 @@ export const hasVectorLayers = (activeLayers) => {
*
* @return {Boolean}
*/
-export const isVectorLayerClickable = (layer, mapRes) => {
+export const isVectorLayerClickable = (layer, mapRes, projId) => {
if (!mapRes) return false;
- const { breakPointLayer } = layer;
- if (breakPointLayer) {
- return mapRes < breakPointLayer.resolutionBreakPoint;
+ const resolutionBreakPoint = lodashGet(layer, `breakPointLayer.projections.${projId}.resolutionBreakPoint`);
+
+ if (resolutionBreakPoint) {
+ return mapRes < resolutionBreakPoint;
}
return true;
};
@@ -1237,14 +1238,14 @@ export const isVectorLayerClickable = (layer, mapRes) => {
*
* @return {Boolean}
*/
-export const hasNonClickableVectorLayer = (activeLayers, mapRes) => {
+export const hasNonClickableVectorLayer = (activeLayers, mapRes, projId) => {
if (!mapRes) return false;
let isNonClickableVectorLayer = false;
const len = activeLayers.length;
for (let i = 0; i < len; i += 1) {
const def = activeLayers[i];
if (def.type === 'vector' && def.visible) {
- isNonClickableVectorLayer = !isVectorLayerClickable(def, mapRes);
+ isNonClickableVectorLayer = !isVectorLayerClickable(def, mapRes, projId);
if (isNonClickableVectorLayer) break;
}
}
diff --git a/web/js/modules/vector-styles/selectors.js b/web/js/modules/vector-styles/selectors.js
index aac3ff5ac..656168865 100644
--- a/web/js/modules/vector-styles/selectors.js
+++ b/web/js/modules/vector-styles/selectors.js
@@ -127,6 +127,7 @@ export function setStyleFunction(def, vectorStyleId, vectorStyles, layer, state)
}
const layerArray = layer.getLayers ? layer.getLayers().getArray() : [layer];
lodashEach(layerArray, (layerInLayerGroup) => {
+ if (layerInLayerGroup.type === 'TILE') return; // WMS breakpoint tile
layerInLayerGroup = layerInLayerGroup.getLayers ? lodashFind(layerInLayerGroup.getLayers().getArray(), 'isVector') : layerInLayerGroup;
// Apply mapbox-gl styles
const extentStartX = layerInLayerGroup.getExtent()[0];