Do not pass tile grid to getTile and tileUrlFunc

getTile and the tileUrlFunc are functions of the source, so they do need to be passed the tile grid. The tile source knows its tile grid, and can get the projection's tile grid if it doesn't have a tile grid.
This commit is contained in:
Éric Lemoine
2013-04-02 11:00:39 +02:00
parent 676bcc6cc7
commit e128bab625
12 changed files with 54 additions and 48 deletions

View File

@@ -5,35 +5,32 @@ describe('ol.source.wms', function() {
describe('ol.source.wms.getUrl', function() {
it('creates expected URL', function() {
var epsg3857 = ol.projection.get('EPSG:3857');
var tileGrid = ol.tilegrid.getForProjection(epsg3857);
var tileUrlFunction = ol.TileUrlFunction.createFromParamsFunction(
'http://wms', {'foo': 'bar'}, ol.source.wms.getUrl);
var tileCoord = new ol.TileCoord(1, 0, 0);
var tileUrl = tileUrlFunction(tileCoord, tileGrid, epsg3857);
var extent = new ol.Extent(
-20037508.342789244, -20037508.342789244, 0, 0);
var expected = 'http://wms?SERVICE=WMS&VERSION=1.3.0&REQUEST=' +
'GetMap&FORMAT=image%2Fpng&TRANSPARENT=true&WIDTH=256&HEIGHT=256&' +
'foo=bar&STYLES=&CRS=EPSG%3A3857&BBOX=' +
'-20037508.342789244%2C-20037508.342789244%2C0%2C0';
expect(tileUrl).to.eql(expected);
var url = ol.source.wms.getUrl('http://wms', {'foo': 'bar'},
extent, new ol.Size(256, 256), epsg3857);
expect(url).to.eql(expected);
});
it('creates expected URL respecting axis orientation', function() {
var epsg4326 = ol.projection.get('EPSG:4326');
var tileGrid = ol.tilegrid.getForProjection(epsg4326);
var tileUrlFunction = ol.TileUrlFunction.createFromParamsFunction(
'http://wms', {'foo': 'bar'}, ol.source.wms.getUrl);
var tileCoord = new ol.TileCoord(1, 0, 0);
var tileUrl = tileUrlFunction(tileCoord, tileGrid, epsg4326);
var extent = new ol.Extent(-180, -90, 0, 90);
var expected = 'http://wms?SERVICE=WMS&VERSION=1.3.0&REQUEST=' +
'GetMap&FORMAT=image%2Fpng&TRANSPARENT=true&WIDTH=256&HEIGHT=256&' +
'foo=bar&STYLES=&CRS=EPSG%3A4326&BBOX=-90%2C-180%2C90%2C0';
expect(tileUrl).to.eql(expected);
var url = ol.source.wms.getUrl('http://wms', {'foo': 'bar'},
extent, new ol.Size(256, 256), epsg4326);
expect(url).to.eql(expected);
});
});
});
goog.require('ol.TileCoord');
goog.require('ol.TileUrlFunction');
goog.require('ol.Extent');
goog.require('ol.Size');
goog.require('ol.projection');
goog.require('ol.source.wms');