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
+23 -4
View File
@@ -20,6 +20,12 @@ goog.require('ol.array');
ol.DEFAULT_TILE_SIZE = 256;
/**
* @define {number} Default maximum zoom for default tile grids.
*/
ol.DEFAULT_MAX_ZOOM = 42;
/**
* @constructor
@@ -89,8 +95,7 @@ ol.tilegrid.TileGrid = function(tileGridOptions) {
/**
* @param {ol.TileCoord} tileCoord Tile coordinate.
* @param {function(this: T, number, ol.TileRange): boolean} callback
* Callback.
* @param {function(this: T, number, ol.TileRange): boolean} callback Callback.
* @param {T=} opt_obj Object.
* @template T
*/
@@ -328,7 +333,21 @@ ol.tilegrid.TileGrid.prototype.getZForResolution = function(resolution) {
/**
* @param {ol.Projection} projection Projection.
* @param {number=} opt_maxZoom Maximum zoom level (optional). Default is 18.
* @return {ol.tilegrid.TileGrid} Default tile grid for the passed projection.
*/
ol.tilegrid.getForProjection = function(projection) {
var tileGrid = projection.getDefaultTileGrid();
if (goog.isNull(tileGrid)) {
tileGrid = ol.tilegrid.createForProjection(projection);
projection.setDefaultTileGrid(tileGrid);
}
return tileGrid;
};
/**
* @param {ol.Projection} projection Projection.
* @param {number=} opt_maxZoom Maximum zoom level.
* @param {ol.Size=} opt_tileSize Tile size.
* @return {ol.tilegrid.TileGrid} TileGrid instance.
*/
@@ -339,7 +358,7 @@ ol.tilegrid.createForProjection =
projectionExtent.maxX - projectionExtent.minX,
projectionExtent.maxY - projectionExtent.minY);
var maxZoom = goog.isDef(opt_maxZoom) ?
opt_maxZoom : 18;
opt_maxZoom : ol.DEFAULT_MAX_ZOOM;
var tileSize = goog.isDef(opt_tileSize) ?
opt_tileSize : new ol.Size(ol.DEFAULT_TILE_SIZE, ol.DEFAULT_TILE_SIZE);
var resolutions = new Array(maxZoom + 1);