Add pixelRatio to ol.TileUrlFunction

This commit is contained in:
Tom Payne
2014-01-14 15:34:37 +01:00
parent f3349fbf87
commit 33f0024747
6 changed files with 23 additions and 11 deletions

View File

@@ -101,10 +101,11 @@ ol.source.BingMaps.prototype.handleImageryMetadataResponse =
/** /**
* @this {ol.source.BingMaps} * @this {ol.source.BingMaps}
* @param {ol.TileCoord} tileCoord Tile coordinate. * @param {ol.TileCoord} tileCoord Tile coordinate.
* @param {number} pixelRatio Pixel ratio.
* @param {ol.proj.Projection} projection Projection. * @param {ol.proj.Projection} projection Projection.
* @return {string|undefined} Tile URL. * @return {string|undefined} Tile URL.
*/ */
function(tileCoord, projection) { function(tileCoord, pixelRatio, projection) {
goog.asserts.assert(ol.proj.equivalent( goog.asserts.assert(ol.proj.equivalent(
projection, this.getProjection())); projection, this.getProjection()));
if (goog.isNull(tileCoord)) { if (goog.isNull(tileCoord)) {

View File

@@ -126,7 +126,7 @@ ol.source.TileImage.prototype.getTile = function(z, x, y, projection) {
} else { } else {
goog.asserts.assert(projection); goog.asserts.assert(projection);
var tileCoord = new ol.TileCoord(z, x, y); var tileCoord = new ol.TileCoord(z, x, y);
var tileUrl = this.tileUrlFunction(tileCoord, projection); var tileUrl = this.tileUrlFunction(tileCoord, 1, projection);
var tile = new this.tileClass( var tile = new this.tileClass(
tileCoord, tileCoord,
goog.isDef(tileUrl) ? ol.TileState.IDLE : ol.TileState.EMPTY, goog.isDef(tileUrl) ? ol.TileState.IDLE : ol.TileState.EMPTY,

View File

@@ -132,11 +132,13 @@ ol.source.TileWMS.prototype.resetCoordKeyPrefix_ = function() {
/** /**
* @param {ol.TileCoord} tileCoord Tile coordinate. * @param {ol.TileCoord} tileCoord Tile coordinate.
* @param {number} pixelRatio Pixel ratio.
* @param {ol.proj.Projection} projection Projection. * @param {ol.proj.Projection} projection Projection.
* @private * @private
* @return {string|undefined} Tile URL. * @return {string|undefined} Tile URL.
*/ */
ol.source.TileWMS.prototype.tileUrlFunction_ = function(tileCoord, projection) { ol.source.TileWMS.prototype.tileUrlFunction_ =
function(tileCoord, pixelRatio, projection) {
var urls = this.urls_; var urls = this.urls_;
if (!goog.isDef(urls) || goog.array.isEmpty(urls)) { if (!goog.isDef(urls) || goog.array.isEmpty(urls)) {

View File

@@ -96,10 +96,11 @@ ol.source.WMTS = function(options) {
/** /**
* @this {ol.source.WMTS} * @this {ol.source.WMTS}
* @param {ol.TileCoord} tileCoord Tile coordinate. * @param {ol.TileCoord} tileCoord Tile coordinate.
* @param {number} pixelRatio Pixel ratio.
* @param {ol.proj.Projection} projection Projection. * @param {ol.proj.Projection} projection Projection.
* @return {string|undefined} Tile URL. * @return {string|undefined} Tile URL.
*/ */
function(tileCoord, projection) { function(tileCoord, pixelRatio, projection) {
if (goog.isNull(tileCoord)) { if (goog.isNull(tileCoord)) {
return undefined; return undefined;
} else { } else {

View File

@@ -61,10 +61,11 @@ ol.source.Zoomify = function(opt_options) {
/** /**
* @this {ol.source.TileImage} * @this {ol.source.TileImage}
* @param {ol.TileCoord} tileCoord Tile Coordinate. * @param {ol.TileCoord} tileCoord Tile Coordinate.
* @param {number} pixelRatio Pixel ratio.
* @param {ol.proj.Projection} projection Projection. * @param {ol.proj.Projection} projection Projection.
* @return {string|undefined} Tile URL. * @return {string|undefined} Tile URL.
*/ */
function(tileCoord, projection) { function(tileCoord, pixelRatio, projection) {
if (goog.isNull(tileCoord)) { if (goog.isNull(tileCoord)) {
return undefined; return undefined;
} else { } else {

View File

@@ -8,7 +8,7 @@ goog.require('ol.TileCoord');
/** /**
* @typedef {function(this: ol.source.TileImage, ol.TileCoord, * @typedef {function(this: ol.source.TileImage, ol.TileCoord,
* ol.proj.Projection): (string|undefined)} * number, ol.proj.Projection): (string|undefined)}
*/ */
ol.TileUrlFunctionType; ol.TileUrlFunctionType;
@@ -29,10 +29,11 @@ ol.TileUrlFunction.createFromTemplate = function(template) {
/** /**
* @this {ol.source.TileImage} * @this {ol.source.TileImage}
* @param {ol.TileCoord} tileCoord Tile Coordinate. * @param {ol.TileCoord} tileCoord Tile Coordinate.
* @param {number} pixelRatio Pixel ratio.
* @param {ol.proj.Projection} projection Projection. * @param {ol.proj.Projection} projection Projection.
* @return {string|undefined} Tile URL. * @return {string|undefined} Tile URL.
*/ */
function(tileCoord, projection) { function(tileCoord, pixelRatio, projection) {
if (goog.isNull(tileCoord)) { if (goog.isNull(tileCoord)) {
return undefined; return undefined;
} else { } else {
@@ -66,16 +67,18 @@ ol.TileUrlFunction.createFromTileUrlFunctions = function(tileUrlFunctions) {
/** /**
* @this {ol.source.TileImage} * @this {ol.source.TileImage}
* @param {ol.TileCoord} tileCoord Tile Coordinate. * @param {ol.TileCoord} tileCoord Tile Coordinate.
* @param {number} pixelRatio Pixel ratio.
* @param {ol.proj.Projection} projection Projection. * @param {ol.proj.Projection} projection Projection.
* @return {string|undefined} Tile URL. * @return {string|undefined} Tile URL.
*/ */
function(tileCoord, projection) { function(tileCoord, pixelRatio, projection) {
if (goog.isNull(tileCoord)) { if (goog.isNull(tileCoord)) {
return undefined; return undefined;
} else { } else {
var index = var index =
goog.math.modulo(tileCoord.hash(), tileUrlFunctions.length); goog.math.modulo(tileCoord.hash(), tileUrlFunctions.length);
return tileUrlFunctions[index].call(this, tileCoord, projection); return tileUrlFunctions[index].call(
this, tileCoord, pixelRatio, projection);
} }
}); });
}; };
@@ -84,10 +87,12 @@ ol.TileUrlFunction.createFromTileUrlFunctions = function(tileUrlFunctions) {
/** /**
* @this {ol.source.TileImage} * @this {ol.source.TileImage}
* @param {ol.TileCoord} tileCoord Tile coordinate. * @param {ol.TileCoord} tileCoord Tile coordinate.
* @param {number} pixelRatio Pixel ratio.
* @param {ol.proj.Projection} projection Projection. * @param {ol.proj.Projection} projection Projection.
* @return {string|undefined} Tile URL. * @return {string|undefined} Tile URL.
*/ */
ol.TileUrlFunction.nullTileUrlFunction = function(tileCoord, projection) { ol.TileUrlFunction.nullTileUrlFunction =
function(tileCoord, pixelRatio, projection) {
return undefined; return undefined;
}; };
@@ -104,16 +109,18 @@ ol.TileUrlFunction.withTileCoordTransform =
/** /**
* @this {ol.source.TileImage} * @this {ol.source.TileImage}
* @param {ol.TileCoord} tileCoord Tile Coordinate. * @param {ol.TileCoord} tileCoord Tile Coordinate.
* @param {number} pixelRatio Pixel ratio.
* @param {ol.proj.Projection} projection Projection. * @param {ol.proj.Projection} projection Projection.
* @return {string|undefined} Tile URL. * @return {string|undefined} Tile URL.
*/ */
function(tileCoord, projection) { function(tileCoord, pixelRatio, projection) {
if (goog.isNull(tileCoord)) { if (goog.isNull(tileCoord)) {
return undefined; return undefined;
} else { } else {
return tileUrlFunction.call( return tileUrlFunction.call(
this, this,
transformFn.call(this, tileCoord, projection, tmpTileCoord), transformFn.call(this, tileCoord, projection, tmpTileCoord),
pixelRatio,
projection); projection);
} }
}); });