Skip to content

Commit

Permalink
#351: Keep the resource WMS url params when creating the map with Map…
Browse files Browse the repository at this point in the history
…Store (#461)
  • Loading branch information
allyoucanmap authored Aug 24, 2021
1 parent de00615 commit e940f7d
Show file tree
Hide file tree
Showing 2 changed files with 38 additions and 5 deletions.
13 changes: 8 additions & 5 deletions geonode_mapstore_client/client/js/utils/ResourceUtils.js
Original file line number Diff line number Diff line change
Expand Up @@ -41,19 +41,21 @@ export const resourceToLayerConfig = (resource) => {
alternate,
links = [],
featureinfo_custom_template: template,
title
title,
perms,
pk
} = resource;

const bbox = getExtentFromResource(resource);

const { url: wfsUrl } = links.find(({ link_type: linkType }) => linkType === 'OGC:WFS') || {};
const { url: wmsUrl } = links.find(({ link_type: linkType }) => linkType === 'OGC:WMS') || {};

const params = wmsUrl && url.parse(wmsUrl, true).query;
const format = getConfigProp('defaultLayerFormat') || 'image/png';
return {
perms: resource.perms,
perms,
id: uuid(),
pk: resource.pk,
pk,
type: 'wms',
name: alternate,
url: wmsUrl,
Expand All @@ -73,7 +75,8 @@ export const resourceToLayerConfig = (resource) => {
}),
style: '',
title,
visibility: true
visibility: true,
...(params && { params })
};
};

Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@

/*
* Copyright 2021, GeoSolutions Sas.
* All rights reserved.
*
* This source code is licensed under the BSD-style license found in the
* LICENSE file in the root directory of this source tree.
*/

import expect from 'expect';
import { resourceToLayerConfig } from '../ResourceUtils';

describe('Test Resource Utils', () => {
it('should keep the wms params from the url if available', () => {
const newLayer = resourceToLayerConfig({
alternate: 'geonode:layer_name',
links: [{
extension: 'html',
link_type: 'OGC:WMS',
name: 'OGC WMS Service',
mime: 'text/html',
url: 'http://localhost:8080/geoserver/wms?map=name&map_resolution=91'
}],
title: 'Layer title',
perms: [],
pk: 1
});
expect(newLayer.params).toEqual({ map: 'name', map_resolution: '91' } );
});
});

0 comments on commit e940f7d

Please sign in to comment.