Skip to content

Commit

Permalink
Fixes #2021: limit list of srs saved in layers from catalog to the on…
Browse files Browse the repository at this point in the history
…es supported by the current mapstore2 instance (#2756)
  • Loading branch information
mbarto authored Mar 21, 2018
1 parent 7e66b41 commit fa4c75b
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 1 deletion.
2 changes: 1 addition & 1 deletion web/client/utils/CatalogUtils.js
Original file line number Diff line number Diff line change
Expand Up @@ -216,7 +216,7 @@ const converters = {
}
};
const buildSRSMap = (srs) => {
return srs.reduce((previous, current) => {
return srs.filter(s => CoordinatesUtils.isSRSAllowed(s)).reduce((previous, current) => {
return assign(previous, {[current]: true});
}, {});
};
Expand Down
3 changes: 3 additions & 0 deletions web/client/utils/CoordinatesUtils.js
Original file line number Diff line number Diff line change
Expand Up @@ -675,6 +675,9 @@ const CoordinatesUtils = {
parseFloat(b.$.maxy)
], SRS, 'EPSG:4326')));
return isArray(bbox) && {minx: bbox[0], miny: bbox[1], maxx: bbox[2], maxy: bbox[3]} || null;
},
isSRSAllowed: (srs) => {
return !!Proj4js.defs(srs);
}
};

Expand Down
13 changes: 13 additions & 0 deletions web/client/utils/__tests__/CatalogUtils-test.js
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,19 @@ describe('Test the CatalogUtils', () => {
expect(records[0].dimensions[0].values.length).toBe(2);
});

it('wms limited srs', () => {
const records = CatalogUtils.getCatalogRecords('wms', {
records: [{
SRS: ['EPSG:4326', 'EPSG:3857', 'EPSG:5041']
}]
}, { url: 'http://sample' });
expect(records.length).toBe(1);
const layer = CatalogUtils.recordToLayer(records[0]);
expect(layer.allowedSRS['EPSG:4326']).toBe(true);
expect(layer.allowedSRS['EPSG:3857']).toBe(true);
expect(layer.allowedSRS['EPSG:5041']).toNotExist();
});

it('wmts', () => {
const records = CatalogUtils.getCatalogRecords('wmts', {
records: [{}]
Expand Down

0 comments on commit fa4c75b

Please sign in to comment.