Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 3 additions & 4 deletions web/client/utils/ogc/WMC/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
*/

import { Parser } from 'xml2js';
import { keys, values, get, head, mapValues, uniqWith, findIndex, pick, has, toPairs, castArray } from 'lodash';
import { keys, values, get, head, mapValues, uniqWith, findIndex, pick, has, toPairs, castArray, isEmpty } from 'lodash';
import { v1 as uuidv1 } from 'uuid';

import {
Expand Down Expand Up @@ -391,8 +391,7 @@ export const toWMC = (
})
};
};

const olExtensionsGeneral = assignNamespace([{
const olExtensionsGeneral = isEmpty(maxExtent) ? [] : assignNamespace([{
name: 'maxExtent',
attributes: objectToAttributes({
minx: maxExtent[0],
Expand Down Expand Up @@ -629,7 +628,7 @@ export const toWMC = (
attributes: objectToAttributes(isValidBboxObject(bbox) ? {
...bbox.bounds,
SRS: bbox.crs
} : {
} : isEmpty(maxExtent) ? {} : {
minx: maxExtent[0],
miny: maxExtent[1],
maxx: maxExtent[2],
Expand Down
12 changes: 12 additions & 0 deletions web/client/utils/ogc/__tests__/WMC-test.js
Original file line number Diff line number Diff line change
Expand Up @@ -344,4 +344,16 @@ describe('WMC tests', () => {
expect({text: exportedLine, line: i + 1}).toEqual({text: contextLine, line: i + 1}));
})
);
it('toWMC with empty maxExtent should not fail', () => {
// Only for test coverage.
// BoundingBox cannot be empty as it's derived from the map bbox (preferred) or maxExtent,
// with bbox always available in the map state
Promise.all([
axios.get('base/web/client/test-resources/wmc/config.json')
]).then(([{data: config}]) => {
const _config = omit(config, "map.maxExtent");
const exportedLines = toWMC(_config, {}).split('\n').map(r => r.trim()).filter(e => e);
expect(exportedLines.some(line => ["<BoundingBox/>"].includes(line))).toBeTruthy();
});
});
});
Loading