Support tile sources without configured projection
This change adds a lot of flexibility to working with tile layers: Sources where the server projection or tile grid do not matter can now be constructed without specifying a projection or tile grid. The tileUrlFunction/imageUrlFunction now also creates updated URLs when the params of the layer change, so things like mergeNewParams in ol2 will be possible. A nice side effect of this whole change is that there is no more duplicated code between tiled and single image WMS layers. While I was at it, I also fixed a WMS 1.1.1 axis order issue and incorrect STYLES params (STYLES=& instead of STYLES&).
This commit is contained in:
@@ -61,7 +61,7 @@ describe('ol.TileUrlFunction', function() {
|
||||
});
|
||||
});
|
||||
|
||||
describe('createBboxParam', function() {
|
||||
describe('createWMSParams', function() {
|
||||
var tileGrid;
|
||||
beforeEach(function() {
|
||||
tileGrid = new ol.tilegrid.XYZ({
|
||||
@@ -70,24 +70,26 @@ describe('ol.TileUrlFunction', function() {
|
||||
});
|
||||
it('creates expected URL', function() {
|
||||
var epsg3857 = ol.projection.getFromCode('EPSG:3857');
|
||||
var tileUrlFunction = ol.TileUrlFunction.createBboxParam(
|
||||
'http://wms?foo=bar', tileGrid, epsg3857.getAxisOrientation());
|
||||
var tileUrlFunction = ol.TileUrlFunction.createWMSParams(
|
||||
'http://wms?foo=bar', {});
|
||||
var tileCoord = new ol.TileCoord(1, 0, 0);
|
||||
var tileUrl = tileUrlFunction(tileCoord);
|
||||
var expected = 'http://wms?foo=bar&BBOX=-20037508.342789244' +
|
||||
'%2C20037508.342789244%2C0%2C40075016.68557849' +
|
||||
'&HEIGHT=256&WIDTH=256';
|
||||
var tileUrl = tileUrlFunction(tileCoord, tileGrid, epsg3857);
|
||||
var expected = 'http://wms?foo=bar&SERVICE=WMS&VERSION=1.3.0&' +
|
||||
'REQUEST=GetMap&FORMAT=image%2Fpng&TRANSPARENT=true&WIDTH=256&' +
|
||||
'HEIGHT=256&BBOX=-20037508.342789244%2C20037508.342789244%2C0%2C' +
|
||||
'40075016.68557849&CRS=EPSG%3A3857&STYLES=';
|
||||
expect(tileUrl).toEqual(expected);
|
||||
});
|
||||
it('creates expected URL respecting axis orientation', function() {
|
||||
var epsg4326 = ol.projection.getFromCode('EPSG:4326');
|
||||
var tileUrlFunction = ol.TileUrlFunction.createBboxParam(
|
||||
'http://wms?foo=bar', tileGrid, epsg4326.getAxisOrientation());
|
||||
var tileUrlFunction = ol.TileUrlFunction.createWMSParams(
|
||||
'http://wms?foo=bar', {});
|
||||
var tileCoord = new ol.TileCoord(1, 0, 0);
|
||||
var tileUrl = tileUrlFunction(tileCoord);
|
||||
var expected = 'http://wms?foo=bar&BBOX=20037508.342789244' +
|
||||
'%2C-20037508.342789244%2C40075016.68557849%2C0' +
|
||||
'&HEIGHT=256&WIDTH=256';
|
||||
var tileUrl = tileUrlFunction(tileCoord, tileGrid, epsg4326);
|
||||
var expected = 'http://wms?foo=bar&SERVICE=WMS&VERSION=1.3.0&' +
|
||||
'REQUEST=GetMap&FORMAT=image%2Fpng&TRANSPARENT=true&WIDTH=256&' +
|
||||
'HEIGHT=256&BBOX=20037508.342789244%2C-20037508.342789244%2C' +
|
||||
'40075016.68557849%2C0&CRS=EPSG%3A4326&STYLES=';
|
||||
expect(tileUrl).toEqual(expected);
|
||||
});
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user