From 05de4ba13dd02859766c31d6baf0a6390460da44 Mon Sep 17 00:00:00 2001 From: Lorenzo Natali Date: Mon, 15 Jul 2024 06:45:12 +0200 Subject: [PATCH] Fix #10470 when CRS is only 1 (#10471) --- web/client/api/WMS.js | 2 +- web/client/api/__tests__/WMS-test.js | 17 ++++++ .../wms/GetCapabilities-1.3.0-minimal.xml | 55 +++++++++++++++++++ 3 files changed, 73 insertions(+), 1 deletion(-) create mode 100644 web/client/test-resources/wms/GetCapabilities-1.3.0-minimal.xml diff --git a/web/client/api/WMS.js b/web/client/api/WMS.js index eabd755dcf..6f680ff988 100644 --- a/web/client/api/WMS.js +++ b/web/client/api/WMS.js @@ -106,7 +106,7 @@ export const searchAndPaginate = (json = {}, startPosition, maxRecords, text) => const root = json.Capability; const service = json.Service; const onlineResource = getOnlineResource(root); - const SRSList = root.Layer && (root.Layer.SRS || root.Layer.CRS)?.map((crs) => crs.toUpperCase()) || []; + const SRSList = root.Layer && castArray(root.Layer.SRS || root.Layer.CRS)?.map((crs) => crs.toUpperCase()) || []; const credits = root.Layer && root.Layer.Attribution && extractCredits(root.Layer.Attribution); const getMapFormats = castArray(root?.Request?.GetMap?.Format || []); const getFeatureInfoFormats = castArray(root?.Request?.GetFeatureInfo?.Format || []); diff --git a/web/client/api/__tests__/WMS-test.js b/web/client/api/__tests__/WMS-test.js index 8ee0a3cd91..b179318cf8 100644 --- a/web/client/api/__tests__/WMS-test.js +++ b/web/client/api/__tests__/WMS-test.js @@ -108,6 +108,23 @@ describe('Test correctness of the WMS APIs', () => { expect(result.service).toBeTruthy(); expect(result.records[0].getMapFormats.length).toBe(20); expect(result.numberOfRecordsMatched).toBe(5); + expect(result.records[0].SRS.length).toBe(3); + expect(result.layerOptions).toBeTruthy(); + expect(result.layerOptions.version).toBe('1.3.0'); + done(); + } catch (ex) { + done(ex); + } + }); + }); + it('GetRecords', (done) => { + API.getRecords('base/web/client/test-resources/wms/GetCapabilities-1.3.0-minimal.xml', 0, 2, '').then((result) => { + try { + expect(result).toBeTruthy(); + expect(result.service).toBeTruthy(); + expect(result.records[0].getMapFormats.length).toBe(1); + expect(result.records[0].SRS.length).toBe(1); + expect(result.numberOfRecordsMatched).toBe(1); expect(result.layerOptions).toBeTruthy(); expect(result.layerOptions.version).toBe('1.3.0'); done(); diff --git a/web/client/test-resources/wms/GetCapabilities-1.3.0-minimal.xml b/web/client/test-resources/wms/GetCapabilities-1.3.0-minimal.xml new file mode 100644 index 0000000000..75806d3cc7 --- /dev/null +++ b/web/client/test-resources/wms/GetCapabilities-1.3.0-minimal.xml @@ -0,0 +1,55 @@ + + + + WMS + Map + + 4096 + 4096 + + + + + text/xml + + + + + + + + + + application/json + + + + + + + + + + image/png + + + + + + + + + + + XML + + + Map + Map + EPSG:3857 + + + +