Do not transform tile coordinates for tileUrlFunction
This commit is contained in:
@@ -2,7 +2,6 @@ goog.provide('ol.tilegrid.TileGrid');
|
||||
|
||||
goog.require('goog.array');
|
||||
goog.require('goog.asserts');
|
||||
goog.require('goog.functions');
|
||||
goog.require('goog.math');
|
||||
goog.require('goog.object');
|
||||
goog.require('ol');
|
||||
@@ -113,17 +112,6 @@ ol.tilegrid.TileGrid = function(options) {
|
||||
this.extent_ = goog.isDef(extent) ? extent : null;
|
||||
|
||||
|
||||
/**
|
||||
* TileCoord transform function for use with this tile grid. Transforms the
|
||||
* internal tile coordinates with bottom-left origin to the tile coordinates
|
||||
* used by the source's {@link ol.TileUrlFunction}.
|
||||
* @param {ol.TileCoord} tileCoord Tile coordinate.
|
||||
* @param {ol.TileCoord=} opt_tileCoord Destination tile coordinate.
|
||||
* @return {ol.TileCoord} Tile coordinate.
|
||||
*/
|
||||
this.transformTileCoord = goog.isDef(options.transformTileCoord) ?
|
||||
options.transformTileCoord : goog.functions.identity;
|
||||
|
||||
/**
|
||||
* @private
|
||||
* @type {Array.<ol.TileRange>}
|
||||
@@ -134,13 +122,11 @@ ol.tilegrid.TileGrid = function(options) {
|
||||
goog.asserts.assert(options.sizes.length == this.resolutions_.length,
|
||||
'number of sizes and resolutions must be equal');
|
||||
this.fullTileRanges_ = goog.array.map(options.sizes, function(size, z) {
|
||||
goog.asserts.assert(size[0] > 0, 'width must be > 0');
|
||||
goog.asserts.assert(size[0] !== 0, 'width must not be 0');
|
||||
goog.asserts.assert(size[1] !== 0, 'height must not be 0');
|
||||
var tileRange = new ol.TileRange(0, size[0] - 1, 0, size[1] - 1);
|
||||
if (tileRange.maxY < tileRange.minY) {
|
||||
tileRange.minY = size[1];
|
||||
tileRange.maxY = -1;
|
||||
}
|
||||
var tileRange = new ol.TileRange(
|
||||
Math.min(0, size[0]), Math.max(size[0] - 1, -1),
|
||||
Math.min(0, size[1]), Math.max(size[1] - 1, -1));
|
||||
if (this.minZoom <= z && z <= this.maxZoom && goog.isDef(extent)) {
|
||||
goog.asserts.assert(tileRange.containsTileRange(
|
||||
this.getTileRangeForExtentAndZ(extent, z)),
|
||||
@@ -380,29 +366,7 @@ ol.tilegrid.TileGrid.prototype.getTileCoordExtent =
|
||||
* @return {ol.TileCoord} Tile coordinate.
|
||||
* @api
|
||||
*/
|
||||
ol.tilegrid.TileGrid.prototype.getTileCoordForCoordAndResolution = function(
|
||||
coordinate, resolution, opt_tileCoord) {
|
||||
var tileCoord = this.getTileCoordForCoordAndResolutionInternal(
|
||||
coordinate, resolution, opt_tileCoord);
|
||||
this.transformTileCoord(tileCoord, tileCoord);
|
||||
return tileCoord;
|
||||
};
|
||||
|
||||
|
||||
/**
|
||||
* Get the tile coordinate for the given map coordinate and resolution. This
|
||||
* method considers that coordinates that intersect tile boundaries should be
|
||||
* assigned the higher tile coordinate.
|
||||
*
|
||||
* The returned tile coordinate is the internal, untransformed one with
|
||||
* bottom-left origin.
|
||||
*
|
||||
* @param {ol.Coordinate} coordinate Coordinate.
|
||||
* @param {number} resolution Resolution.
|
||||
* @param {ol.TileCoord=} opt_tileCoord Destination ol.TileCoord object.
|
||||
* @return {ol.TileCoord} Internal, untransformed tile coordinate.
|
||||
*/
|
||||
ol.tilegrid.TileGrid.prototype.getTileCoordForCoordAndResolutionInternal =
|
||||
ol.tilegrid.TileGrid.prototype.getTileCoordForCoordAndResolution =
|
||||
function(coordinate, resolution, opt_tileCoord) {
|
||||
return this.getTileCoordForXYAndResolution_(
|
||||
coordinate[0], coordinate[1], resolution, false, opt_tileCoord);
|
||||
@@ -453,24 +417,7 @@ ol.tilegrid.TileGrid.prototype.getTileCoordForXYAndResolution_ = function(
|
||||
* @return {ol.TileCoord} Tile coordinate.
|
||||
* @api
|
||||
*/
|
||||
ol.tilegrid.TileGrid.prototype.getTileCoordForCoordAndZ = function(
|
||||
coordinate, z, opt_tileCoord) {
|
||||
var tileCoord = this.getTileCoordForCoordAndZInternal(
|
||||
coordinate, z, opt_tileCoord);
|
||||
this.transformTileCoord(tileCoord, tileCoord);
|
||||
return tileCoord;
|
||||
};
|
||||
|
||||
|
||||
/**
|
||||
* Get a tile coordinate given a map coordinate and zoom level. The returned
|
||||
* tile coordinate is the internal one, untransformed with bottom-left origin.
|
||||
* @param {ol.Coordinate} coordinate Coordinate.
|
||||
* @param {number} z Zoom level.
|
||||
* @param {ol.TileCoord=} opt_tileCoord Destination ol.TileCoord object.
|
||||
* @return {ol.TileCoord} Internal, untransformed tile coordinate.
|
||||
*/
|
||||
ol.tilegrid.TileGrid.prototype.getTileCoordForCoordAndZInternal =
|
||||
ol.tilegrid.TileGrid.prototype.getTileCoordForCoordAndZ =
|
||||
function(coordinate, z, opt_tileCoord) {
|
||||
var resolution = this.getResolution(z);
|
||||
return this.getTileCoordForXYAndResolution_(
|
||||
@@ -616,8 +563,6 @@ ol.tilegrid.createXYZ = function(opt_options) {
|
||||
options.extent, options.maxZoom, options.tileSize);
|
||||
delete options.maxZoom;
|
||||
|
||||
options.transformTileCoord = ol.tilegrid.originTopLeftTileCoordTransform;
|
||||
|
||||
return new ol.tilegrid.TileGrid(options);
|
||||
};
|
||||
|
||||
@@ -686,23 +631,3 @@ ol.tilegrid.extentFromProjection = function(projection) {
|
||||
}
|
||||
return extent;
|
||||
};
|
||||
|
||||
|
||||
/**
|
||||
* @param {ol.TileCoord} tileCoord Tile coordinate.
|
||||
* @param {ol.TileCoord=} opt_tileCoord Destination tile coordinate.
|
||||
* @return {ol.TileCoord} Tile coordinate.
|
||||
* @this {ol.tilegrid.TileGrid}
|
||||
*/
|
||||
ol.tilegrid.originTopLeftTileCoordTransform =
|
||||
function(tileCoord, opt_tileCoord) {
|
||||
if (goog.isNull(tileCoord)) {
|
||||
return null;
|
||||
}
|
||||
var z = tileCoord[0];
|
||||
var fullTileRange = this.getFullTileRange(z);
|
||||
var height = (goog.isNull(fullTileRange) || fullTileRange.minY < 0) ?
|
||||
0 : fullTileRange.getHeight();
|
||||
return ol.tilecoord.createOrUpdate(
|
||||
z, tileCoord[1], height - tileCoord[2] - 1, opt_tileCoord);
|
||||
};
|
||||
|
||||
@@ -38,8 +38,7 @@ ol.tilegrid.WMTS = function(options) {
|
||||
resolutions: options.resolutions,
|
||||
tileSize: options.tileSize,
|
||||
tileSizes: options.tileSizes,
|
||||
sizes: options.sizes,
|
||||
transformTileCoord: ol.tilegrid.originTopLeftTileCoordTransform
|
||||
sizes: options.sizes
|
||||
});
|
||||
|
||||
};
|
||||
|
||||
@@ -1,72 +0,0 @@
|
||||
goog.provide('ol.tilegrid.Zoomify');
|
||||
|
||||
goog.require('goog.math');
|
||||
goog.require('ol.TileCoord');
|
||||
goog.require('ol.tilecoord');
|
||||
goog.require('ol.tilegrid.TileGrid');
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* @classdesc
|
||||
* Set the grid pattern for sources accessing Zoomify tiled-image servers.
|
||||
*
|
||||
* @constructor
|
||||
* @extends {ol.tilegrid.TileGrid}
|
||||
* @param {olx.tilegrid.ZoomifyOptions=} opt_options Options.
|
||||
* @api
|
||||
*/
|
||||
ol.tilegrid.Zoomify = function(opt_options) {
|
||||
var options = goog.isDef(opt_options) ? opt_options : options;
|
||||
|
||||
/** @type {Array.<ol.TileRange>} */
|
||||
var tileRangeByZ = goog.isDef(options.extent) ? [] : null;
|
||||
|
||||
/**
|
||||
* @param {ol.TileCoord} tileCoord Tile coordinate.
|
||||
* @param {ol.TileCoord=} opt_tileCoord Destination tile coordinate.
|
||||
* @return {ol.TileCoord} Tile coordinate.
|
||||
*/
|
||||
function transformTileCoord(tileCoord, opt_tileCoord) {
|
||||
var z = tileCoord[0];
|
||||
if (z < minZ || maxZ < z) {
|
||||
return null;
|
||||
}
|
||||
var n = Math.pow(2, z);
|
||||
var x = tileCoord[1];
|
||||
if (x < 0 || n <= x) {
|
||||
return null;
|
||||
}
|
||||
var y = tileCoord[2];
|
||||
if (y < -n || -1 < y) {
|
||||
return null;
|
||||
}
|
||||
if (!goog.isNull(tileRangeByZ)) {
|
||||
if (!tileRangeByZ[z].containsXY(x, -y - 1)) {
|
||||
return null;
|
||||
}
|
||||
}
|
||||
return ol.tilecoord.createOrUpdate(z, x, -y - 1, opt_tileCoord);
|
||||
}
|
||||
|
||||
goog.base(this, {
|
||||
origin: [0, 0],
|
||||
resolutions: options.resolutions,
|
||||
transformTileCoord: transformTileCoord
|
||||
});
|
||||
|
||||
if (goog.isDef(options.extent)) {
|
||||
var minZ = this.minZoom;
|
||||
var maxZ = this.maxZoom;
|
||||
tileRangeByZ = [];
|
||||
var z;
|
||||
for (z = 0; z <= maxZ; ++z) {
|
||||
if (z < minZ) {
|
||||
tileRangeByZ[z] = null;
|
||||
} else {
|
||||
tileRangeByZ[z] = this.getTileRangeForExtentAndZ(options.extent, z);
|
||||
}
|
||||
}
|
||||
}
|
||||
};
|
||||
goog.inherits(ol.tilegrid.Zoomify, ol.tilegrid.TileGrid);
|
||||
Reference in New Issue
Block a user