Do not overwrite FORMAT_OPTIONS if it is present already

This commit is contained in:
Bart van den Eijnden
2015-04-23 20:03:33 +02:00
parent 70b0406c50
commit f0bef58ba3
4 changed files with 51 additions and 2 deletions

View File

@@ -105,6 +105,35 @@ describe('ol.source.TileWMS', function() {
expect(queryData.get('BBOX')).to.be('-90,-45,-45,0');
});
it('sets FORMAT_OPTIONS when the server is GeoServer', function() {
options.serverType = ol.source.wms.ServerType.GEOSERVER;
var source = new ol.source.TileWMS(options);
var tile = source.getTile(3, 2, 1, 2, ol.proj.get('CRS:84'));
var uri = new goog.Uri(tile.src_);
var queryData = uri.getQueryData();
expect(queryData.get('FORMAT_OPTIONS')).to.be('dpi:180');
});
it('extends FORMAT_OPTIONS if it is already present', function() {
options.serverType = ol.source.wms.ServerType.GEOSERVER;
var source = new ol.source.TileWMS(options);
options.params.FORMAT_OPTIONS = 'param1:value1';
var tile = source.getTile(3, 2, 1, 2, ol.proj.get('CRS:84'));
var uri = new goog.Uri(tile.src_);
var queryData = uri.getQueryData();
expect(queryData.get('FORMAT_OPTIONS')).to.be('param1:value1;dpi:180');
});
it('rounds FORMAT_OPTIONS to an integer when the server is GeoServer',
function() {
options.serverType = ol.source.wms.ServerType.GEOSERVER;
var source = new ol.source.TileWMS(options);
var tile = source.getTile(3, 2, 1, 1.325, ol.proj.get('CRS:84'));
var uri = new goog.Uri(tile.src_);
var queryData = uri.getQueryData();
expect(queryData.get('FORMAT_OPTIONS')).to.be('dpi:119');
});
});
describe('#tileUrlFunction', function() {
@@ -219,5 +248,6 @@ describe('ol.source.TileWMS', function() {
goog.require('goog.Uri');
goog.require('ol.ImageTile');
goog.require('ol.source.TileWMS');
goog.require('ol.source.wms.ServerType');
goog.require('ol.proj');
goog.require('ol.tilegrid.TileGrid');