From bd9d4bce7436ba442d329ae54a4ada4ef3c14f2a Mon Sep 17 00:00:00 2001 From: Quincy Morgan <2046746+quincylvania@users.noreply.github.com> Date: Fri, 24 Jul 2020 17:43:52 -0400 Subject: [PATCH] Fix issue with reversed bounding box coordinate order in WMS 1.3 for EPSG:4326 CRS (close #7557) --- modules/renderer/background_source.js | 27 +++++++++++++++++---------- 1 file changed, 17 insertions(+), 10 deletions(-) diff --git a/modules/renderer/background_source.js b/modules/renderer/background_source.js index 6d39bb270..b3bf00701 100644 --- a/modules/renderer/background_source.js +++ b/modules/renderer/background_source.js @@ -112,7 +112,7 @@ export function rendererBackgroundSource(data) { // Guess a type based on the tokens present in the template // (This is for 'custom' source, where we don't know) if (!source.type) { - if (/\{(proj|wkid|bbox)\}/.test(_template)) { + if (/SERVICE=WMS|\{(proj|wkid|bbox)\}/.test(_template)) { source.type = 'wms'; source.projection = 'EPSG:3857'; // guess } else if (/\{(x|y)\}/.test(_template)) { @@ -159,23 +159,30 @@ export function rendererBackgroundSource(data) { switch (key) { case 'width': case 'height': - return tileSize; + return tileSize; case 'proj': - return projection; + return projection; case 'wkid': - return projection.replace(/^EPSG:/, ''); + return projection.replace(/^EPSG:/, ''); case 'bbox': - return minXmaxY.x + ',' + maxXminY.y + ',' + maxXminY.x + ',' + minXmaxY.y; + // WMS 1.3 flips x/y for some coordinate systems including EPSG:4326 - #7557 + if (projection === 'EPSG:4326' && + // The CRS parameter implies version 1.3 (prior versions use SRS) + /VERSION=1.3|CRS={proj}/.test(source.template())) { + return maxXminY.y + ',' + minXmaxY.x + ',' + minXmaxY.y + ',' + maxXminY.x; + } else { + return minXmaxY.x + ',' + maxXminY.y + ',' + maxXminY.x + ',' + minXmaxY.y; + } case 'w': - return minXmaxY.x; + return minXmaxY.x; case 's': - return maxXminY.y; + return maxXminY.y; case 'n': - return maxXminY.x; + return maxXminY.x; case 'e': - return minXmaxY.y; + return minXmaxY.y; default: - return token; + return token; } });