Skip to content

Interactive interface for browsing global, full-resolution satellite imagery

Add different array of WMS res for 512px tiles #3177

Ben King0154fe7c3364
diff --git a/web/js/map/layerbuilder.js b/web/js/map/layerbuilder.js
index d2b73972e..b187f0ce0 100644
--- a/web/js/map/layerbuilder.js
+++ b/web/js/map/layerbuilder.js
@@ -18,7 +18,7 @@ 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 { createVectorUrl, getGeographicResolutionWMS, mergeBreakpointLayerAttributes } from './util';
import { datesinDateRanges, prevDateInDateRange } from '../modules/layers/util';
import {
isActive as isPaletteActive,
@@ -514,19 +514,7 @@ export default function mapLayerBuilder(models, config, cache, ui, store) {
const transparent = def.format === 'image/png';
if (selectedProj.id === 'geographic') {
- res = [
- 0.28125,
- 0.140625,
- 0.0703125,
- 0.03515625,
- 0.017578125,
- 0.0087890625,
- 0.00439453125,
- 0.002197265625,
- 0.0010986328125,
- 0.00054931640625,
- 0.00027465820313,
- ];
+ res = getGeographicResolutionWMS(def.tileSize);
}
if (day) {
if (day === 1) {
diff --git a/web/js/map/util.js b/web/js/map/util.js
index 76d8a78b1..5028241fe 100644
--- a/web/js/map/util.js
+++ b/web/js/map/util.js
@@ -1,3 +1,4 @@
+import { RESOLUTION_FOR_LARGE_WMS_TILES, RESOLUTION_FOR_SMALL_WMS_TILES } from '../modules/map/constants';
import util from '../util/util';
const ZOOM_DURATION = 250;
@@ -27,7 +28,6 @@ export function mapUtilZoomAction(map, amount, duration, center) {
let newZoom = zoom + amount;
const newZoomBelowMin = newZoom < minZoom;
const newZoomExceedsMax = newZoom > maxZoom;
-
// if newZoom is animating, it may not be an integer
// and will require revising to within min/max zoom constraints
if (zoom < maxZoom && newZoomExceedsMax) {
@@ -46,6 +46,16 @@ export function mapUtilZoomAction(map, amount, duration, center) {
});
}
+/**
+ *
+ * @param {Array} tileSize Size of tile to be returned in pixels
+ *
+ * @returns {Array} WMS Layer resolutions
+ */
+export function getGeographicResolutionWMS(tileSize) {
+ if (!tileSize || !tileSize.length) return RESOLUTION_FOR_LARGE_WMS_TILES;
+ return tileSize[0] === 256 ? RESOLUTION_FOR_SMALL_WMS_TILES : RESOLUTION_FOR_LARGE_WMS_TILES;
+}
/**
* getActiveLayerGroup
* @param {Object} map
diff --git a/web/js/modules/map/constants.js b/web/js/modules/map/constants.js
index 8d21dc78f..0435265f1 100644
--- a/web/js/modules/map/constants.js
+++ b/web/js/modules/map/constants.js
@@ -8,3 +8,31 @@ export const RENDERED = 'MAP/RENDERED';
export const FITTED_TO_LEADING_EXTENT = 'MAP/FITTED_TO_LEADING_EXTENT';
export const CHANGE_CURSOR = 'MAP/CHANGE_CURSOR';
export const REFRESH_ROTATE = 'MAP/REFRESH_ROTATE';
+
+export const RESOLUTION_FOR_LARGE_WMS_TILES = [
+ 0.3515625,
+ 0.17578125,
+ 0.08789062,
+ 0.04394531,
+ 0.02197266,
+ 0.01098533,
+ 0.00549316,
+ 0.00274658,
+ 0.00137329,
+ 0.00068665,
+ 0.00034332,
+ 0.00017166,
+];
+export const RESOLUTION_FOR_SMALL_WMS_TILES = [
+ 0.28125,
+ 0.140625,
+ 0.0703125,
+ 0.03515625,
+ 0.017578125,
+ 0.0087890625,
+ 0.00439453125,
+ 0.002197265625,
+ 0.0010986328125,
+ 0.00054931640625,
+ 0.00027465820313,
+];