Skip to content

Commit

Permalink
Merge pull request #3024 from camptocamp/imageType
Browse files Browse the repository at this point in the history
Take the imageType into account for WMS layers
  • Loading branch information
fredj authored Oct 26, 2017
2 parents 374fb05 + 4ff7fc9 commit a8822f2
Show file tree
Hide file tree
Showing 5 changed files with 20 additions and 6 deletions.
1 change: 1 addition & 0 deletions contribs/gmf/src/directives/print.js
Original file line number Diff line number Diff line change
Expand Up @@ -698,6 +698,7 @@ gmf.PrintController.prototype.print = function(format) {
layer = this.ngeoLayerHelper_.createBasicWMSLayer(
server.url,
layer_names,
server.imageType,
server.type
);
} else {
Expand Down
6 changes: 4 additions & 2 deletions contribs/gmf/src/services/syncLayertreeMap.js
Original file line number Diff line number Diff line change
Expand Up @@ -197,8 +197,9 @@ gmf.SyncLayertreeMap.prototype.createLayerFromGroup_ = function(treeCtrl,
goog.asserts.assert(ogcServer);
goog.asserts.assert(ogcServer.url);
goog.asserts.assert(ogcServer.type);
goog.asserts.assert(ogcServer.imageType);
layer = this.layerHelper_.createBasicWMSLayer(
ogcServer.url, '', ogcServer.type, timeParam
ogcServer.url, '', ogcServer.imageType, ogcServer.type, timeParam
);
var hasActiveChildren = false;
treeCtrl.traverseDepthFirst(function(ctrl) {
Expand Down Expand Up @@ -238,8 +239,9 @@ gmf.SyncLayertreeMap.prototype.createLeafInAMixedGroup_ = function(treeCtrl, map
goog.asserts.assert(ogcServer.url);
goog.asserts.assert(ogcServer.type);
goog.asserts.assert(gmfLayerWMS.layers);
goog.asserts.assert(ogcServer.imageType);
layer = this.layerHelper_.createBasicWMSLayer(ogcServer.url,
gmfLayerWMS.layers, ogcServer.type, timeParam);
gmfLayerWMS.layers, ogcServer.imageType, ogcServer.type, timeParam);
}
// Update layer information and tree state.
layer.set('layerNodeName', gmfLayer.name); // Really useful ?
Expand Down
2 changes: 2 additions & 0 deletions contribs/gmf/src/services/themesservice.js
Original file line number Diff line number Diff line change
Expand Up @@ -289,9 +289,11 @@ gmf.Themes.prototype.getBgLayers = function(appDimensions) {
var server = ogcServers[gmfLayerWMS.ogcServer];
goog.asserts.assert(server, 'The OGC server was not found');
goog.asserts.assert(server.url, 'The server URL is required');
goog.asserts.assert(server.imageType, 'The server image type is required');
return callback(gmfLayer, layerHelper.createBasicWMSLayer(
server.url,
gmfLayerWMS.layers || '',
server.imageType,
server.type,
undefined, // time
gmfLayer.dimensions
Expand Down
8 changes: 6 additions & 2 deletions src/services/layerHelper.js
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,7 @@ ngeo.LayerHelper.REFRESH_PARAM = 'random';
*
* @param {string} sourceURL The source URL.
* @param {string} sourceLayersName A comma separated names string.
* @param {string} sourceFormat Image format, for example 'image/png'.
* @param {string=} opt_serverType Type of the server ("mapserver",
* "geoserver", "qgisserver", …).
* @param {string=} opt_time time parameter for layer queryable by time/periode
Expand All @@ -65,9 +66,12 @@ ngeo.LayerHelper.REFRESH_PARAM = 'random';
* @export
*/
ngeo.LayerHelper.prototype.createBasicWMSLayer = function(sourceURL,
sourceLayersName, opt_serverType, opt_time, opt_params) {
sourceLayersName, sourceFormat, opt_serverType, opt_time, opt_params) {

var params = {'LAYERS': sourceLayersName};
var params = {
'FORMAT': sourceFormat,
'LAYERS': sourceLayersName
};
var olServerType;
if (opt_time) {
params['TIME'] = opt_time;
Expand Down
9 changes: 7 additions & 2 deletions test/spec/services/layerHelper.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -23,9 +23,14 @@ describe('ngeo.LayerHelper', function() {
});

it('Create a basic WMS layer', function() {
layer = ngeoLayerHelper.createBasicWMSLayer('', '');
layer = ngeoLayerHelper.createBasicWMSLayer('http://example.com/', 'a,b,c', 'image/jpeg');
expect(layer.constructor).toBe(ol.layer.Image);
expect(layer.getSource().constructor).toBe(ol.source.ImageWMS);
var source = layer.getSource();
expect(source.constructor).toBe(ol.source.ImageWMS);
expect(source.getUrl()).toBe('http://example.com/');
var params = source.getParams();
expect(params.LAYERS).toBe('a,b,c');
expect(params.FORMAT).toBe('image/jpeg');
});

it('Create a WMTS layer from capabilitites', function() {
Expand Down

0 comments on commit a8822f2

Please sign in to comment.