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:
ahocevar
2013-03-05 00:46:58 +01:00
parent cad215e0cc
commit 586f393492
24 changed files with 320 additions and 206 deletions

View File

@@ -2,7 +2,7 @@ goog.provide('ol.test.source.XYZ');
describe('ol.source.XYZ', function() {
describe('getTileCoordUrl', function() {
describe('tileUrlFunction', function() {
var xyzTileSource, tileGrid;
@@ -18,59 +18,59 @@ describe('ol.source.XYZ', function() {
var coordinate = new ol.Coordinate(829330.2064098881, 5933916.615134273);
var tileUrl;
tileUrl = xyzTileSource.getTileCoordUrl(
tileUrl = xyzTileSource.tileUrlFunction(
tileGrid.getTileCoordForCoordAndZ(coordinate, 0));
expect(tileUrl).toEqual('0/0/0');
tileUrl = xyzTileSource.getTileCoordUrl(
tileUrl = xyzTileSource.tileUrlFunction(
tileGrid.getTileCoordForCoordAndZ(coordinate, 1));
expect(tileUrl).toEqual('1/1/0');
tileUrl = xyzTileSource.getTileCoordUrl(
tileUrl = xyzTileSource.tileUrlFunction(
tileGrid.getTileCoordForCoordAndZ(coordinate, 2));
expect(tileUrl).toEqual('2/2/1');
tileUrl = xyzTileSource.getTileCoordUrl(
tileUrl = xyzTileSource.tileUrlFunction(
tileGrid.getTileCoordForCoordAndZ(coordinate, 3));
expect(tileUrl).toEqual('3/4/2');
tileUrl = xyzTileSource.getTileCoordUrl(
tileUrl = xyzTileSource.tileUrlFunction(
tileGrid.getTileCoordForCoordAndZ(coordinate, 4));
expect(tileUrl).toEqual('4/8/5');
tileUrl = xyzTileSource.getTileCoordUrl(
tileUrl = xyzTileSource.tileUrlFunction(
tileGrid.getTileCoordForCoordAndZ(coordinate, 5));
expect(tileUrl).toEqual('5/16/11');
tileUrl = xyzTileSource.getTileCoordUrl(
tileUrl = xyzTileSource.tileUrlFunction(
tileGrid.getTileCoordForCoordAndZ(coordinate, 6));
expect(tileUrl).toEqual('6/33/22');
});
describe('wrap x', function() {
it('returns the expected URL', function() {
var tileUrl = xyzTileSource.getTileCoordUrl(
var tileUrl = xyzTileSource.tileUrlFunction(
new ol.TileCoord(6, -31, -23));
expect(tileUrl).toEqual('6/33/22');
tileUrl = xyzTileSource.getTileCoordUrl(new ol.TileCoord(6, 33, -23));
tileUrl = xyzTileSource.tileUrlFunction(new ol.TileCoord(6, 33, -23));
expect(tileUrl).toEqual('6/33/22');
tileUrl = xyzTileSource.getTileCoordUrl(new ol.TileCoord(6, 97, -23));
tileUrl = xyzTileSource.tileUrlFunction(new ol.TileCoord(6, 97, -23));
expect(tileUrl).toEqual('6/33/22');
});
});
describe('crop y', function() {
it('returns the expected URL', function() {
var tileUrl = xyzTileSource.getTileCoordUrl(
var tileUrl = xyzTileSource.tileUrlFunction(
new ol.TileCoord(6, 33, -87));
expect(tileUrl).toBeUndefined();
tileUrl = xyzTileSource.getTileCoordUrl(new ol.TileCoord(6, 33, -23));
tileUrl = xyzTileSource.tileUrlFunction(new ol.TileCoord(6, 33, -23));
expect(tileUrl).toEqual('6/33/22');
tileUrl = xyzTileSource.getTileCoordUrl(new ol.TileCoord(6, 33, 41));
tileUrl = xyzTileSource.tileUrlFunction(new ol.TileCoord(6, 33, 41));
expect(tileUrl).toBeUndefined();
});
});