Skip to content

Interactive interface for browsing global, full-resolution satellite imagery

coordinate order depends on projection

Mike McGann09659596c36e
diff --git a/web/js/image/panel.js b/web/js/image/panel.js
index b645b28f3..654b5bcb8 100644
--- a/web/js/image/panel.js
+++ b/web/js/image/panel.js
@@ -12,7 +12,8 @@ import {
imageUtilGetLayerOpacities,
imageUtilGetCoordsFromPixelValues,
imageUtilGetLayers,
- imageUtilGetConversionFactor
+ imageUtilGetConversionFactor,
+ bboxWMS13
} from './util';
const maxSize = 8200;
@@ -334,11 +335,10 @@ export function imagePanel(models, ui, config, dialogConfig) {
let opacities = imageUtilGetLayerOpacities(layerList);
let crs = models.proj.selected.crs;
- // WMS 1.3 flips the coordinate order from X,Y to Y,X
let params = [
'REQUEST=GetSnapshot',
`TIME=${util.toISOStringDate(time)}`,
- `BBOX=${lonlats[0][1]},${lonlats[0][0]},${lonlats[1][1]},${lonlats[1][0]}`,
+ `BBOX=${bboxWMS13(lonlats, crs)}`,
`CRS=${crs}`,
`LAYERS=${layers.join(',')}`,
`FORMAT=${imgFormat}`,
diff --git a/web/js/image/util.js b/web/js/image/util.js
index badef18fd..fdb8dd64c 100644
--- a/web/js/image/util.js
+++ b/web/js/image/util.js
@@ -134,3 +134,17 @@ export function imageUtilGetCoordsFromPixelValues (pixels, map) {
map.getCoordinateFromPixel([Math.floor(pixels.x2), Math.floor(pixels.y)])
];
};
+
+/**
+ * Given a bounding box as an array of a lower left coordinate pair
+ * and an upper right coordinate pair, return the BBOX parameter value
+ * suitable in a WMS 1.3 call. For EPSG:4326, the coordinates are in
+ * Y,X order, otherwise in X,Y order.
+ */
+export function bboxWMS13(lonlats, crs) {
+ if (crs === 'EPSG:4326') {
+ return `${lonlats[0][1]},${lonlats[0][0]},${lonlats[1][1]},${lonlats[1][0]}`;
+ } else {
+ return `${lonlats[0][0]},${lonlats[0][1]},${lonlats[1][0]},${lonlats[1][1]}`;
+ }
+}
diff --git a/web/js/image/util.test.js b/web/js/image/util.test.js
new file mode 100644
index 000000000..af9ef30de
--- /dev/null
+++ b/web/js/image/util.test.js
@@ -0,0 +1,9 @@
+import { bboxWMS13 } from './util';
+
+test('bboxWMS13', () => {
+ let coords = [[11, 22], [33, 44]];
+ let bboxGeo = bboxWMS13(coords, 'EPSG:4326');
+ expect(bboxGeo).toBe('22,11,44,33');
+ let bboxArctic = bboxWMS13(coords, 'EPSG:3413');
+ expect(bboxArctic).toBe('11,22,33,44');
+});