Do not transform tile coordinates for tileUrlFunction
This commit is contained in:
@@ -6126,8 +6126,7 @@ olx.tilegrid;
|
||||
|
||||
|
||||
/**
|
||||
* @typedef {{transformTileCoord: (undefined|function(ol.TileCoord, ol.TileCoord=):ol.TileCoord),
|
||||
* extent: (ol.Extent|undefined),
|
||||
* @typedef {{extent: (ol.Extent|undefined),
|
||||
* minZoom: (number|undefined),
|
||||
* origin: (ol.Coordinate|undefined),
|
||||
* origins: (Array.<ol.Coordinate>|undefined),
|
||||
@@ -6368,21 +6367,6 @@ olx.tilegrid.XYZOptions.prototype.minZoom;
|
||||
olx.tilegrid.XYZOptions.prototype.tileSize;
|
||||
|
||||
|
||||
/**
|
||||
* @typedef {{resolutions: !Array.<number>}}
|
||||
* @api
|
||||
*/
|
||||
olx.tilegrid.ZoomifyOptions;
|
||||
|
||||
|
||||
/**
|
||||
* Resolutions.
|
||||
* @type {!Array.<number>}
|
||||
* @api
|
||||
*/
|
||||
olx.tilegrid.ZoomifyOptions.prototype.resolutions;
|
||||
|
||||
|
||||
/**
|
||||
* Namespace.
|
||||
* @type {Object}
|
||||
|
||||
@@ -192,7 +192,7 @@ ol.renderer.dom.TileLayer.prototype.prepareFrame =
|
||||
tileLayerZ = this.tileLayerZs_[tileLayerZKey];
|
||||
} else {
|
||||
tileCoordOrigin =
|
||||
tileGrid.getTileCoordForCoordAndZInternal(center, tileLayerZKey);
|
||||
tileGrid.getTileCoordForCoordAndZ(center, tileLayerZKey);
|
||||
tileLayerZ = new ol.renderer.dom.TileLayerZ_(tileGrid, tileCoordOrigin);
|
||||
newTileLayerZKeys[tileLayerZKey] = true;
|
||||
this.tileLayerZs_[tileLayerZKey] = tileLayerZ;
|
||||
|
||||
@@ -118,6 +118,7 @@ ol.source.BingMaps.prototype.handleImageryMetadataResponse =
|
||||
goog.array.map(
|
||||
resource.imageUrlSubdomains,
|
||||
function(subdomain) {
|
||||
var quadKeyTileCoord = [0, 0, 0];
|
||||
var imageUrl = resource.imageUrl
|
||||
.replace('{subdomain}', subdomain)
|
||||
.replace('{culture}', culture);
|
||||
@@ -135,8 +136,10 @@ ol.source.BingMaps.prototype.handleImageryMetadataResponse =
|
||||
if (goog.isNull(tileCoord)) {
|
||||
return undefined;
|
||||
} else {
|
||||
return imageUrl.replace(
|
||||
'{quadkey}', ol.tilecoord.quadKey(tileCoord));
|
||||
ol.tilecoord.createOrUpdate(tileCoord[0], tileCoord[1],
|
||||
-tileCoord[2] - 1, quadKeyTileCoord);
|
||||
return imageUrl.replace('{quadkey}', ol.tilecoord.quadKey(
|
||||
quadKeyTileCoord));
|
||||
}
|
||||
});
|
||||
}));
|
||||
|
||||
@@ -217,8 +217,7 @@ ol.source.Tile.prototype.getTilePixelSize =
|
||||
|
||||
|
||||
/**
|
||||
* Handles x-axis wrapping and returns a tile coordinate transformed from the
|
||||
* internal tile scheme to the tile grid's tile scheme. When the tile coordinate
|
||||
* Returns a tile coordinate wrapped around the x-axis. When the tile coordinate
|
||||
* is outside the resolution and extent range of the tile grid, `null` will be
|
||||
* returned.
|
||||
* @param {ol.TileCoord} tileCoord Tile coordinate.
|
||||
@@ -235,8 +234,7 @@ ol.source.Tile.prototype.getTileCoordForTileUrlFunction =
|
||||
if (this.getWrapX()) {
|
||||
tileCoord = ol.tilecoord.wrapX(tileCoord, tileGrid, projection);
|
||||
}
|
||||
return ol.tilecoord.withinExtentAndZ(tileCoord, tileGrid) ?
|
||||
tileGrid.transformTileCoord(tileCoord) : null;
|
||||
return ol.tilecoord.withinExtentAndZ(tileCoord, tileGrid) ? tileCoord : null;
|
||||
};
|
||||
|
||||
|
||||
|
||||
@@ -82,7 +82,7 @@ ol.source.TileUTFGrid.prototype.getTemplate = function() {
|
||||
ol.source.TileUTFGrid.prototype.forDataAtCoordinateAndResolution = function(
|
||||
coordinate, resolution, callback, opt_this, opt_request) {
|
||||
if (!goog.isNull(this.tileGrid)) {
|
||||
var tileCoord = this.tileGrid.getTileCoordForCoordAndResolutionInternal(
|
||||
var tileCoord = this.tileGrid.getTileCoordForCoordAndResolution(
|
||||
coordinate, resolution);
|
||||
var tile = /** @type {!ol.source.TileUTFGridTile_} */(this.getTile(
|
||||
tileCoord[0], tileCoord[1], tileCoord[2], 1, this.getProjection()));
|
||||
|
||||
@@ -116,7 +116,7 @@ ol.source.TileVector.prototype.forEachFeatureAtCoordinateAndResolution =
|
||||
|
||||
var tileGrid = this.tileGrid_;
|
||||
var tiles = this.tiles_;
|
||||
var tileCoord = tileGrid.getTileCoordForCoordAndResolutionInternal(coordinate,
|
||||
var tileCoord = tileGrid.getTileCoordForCoordAndResolution(coordinate,
|
||||
resolution);
|
||||
|
||||
var tileKey = this.getTileKeyZXY_(tileCoord[0], tileCoord[1], tileCoord[2]);
|
||||
@@ -250,7 +250,7 @@ ol.source.TileVector.prototype.getTileCoordForTileUrlFunction =
|
||||
tileCoord = ol.tilecoord.wrapX(tileCoord, tileGrid, projection);
|
||||
}
|
||||
return ol.tilecoord.withinExtentAndZ(tileCoord, tileGrid) ?
|
||||
tileGrid.transformTileCoord(tileCoord) : null;
|
||||
tileCoord : null;
|
||||
};
|
||||
|
||||
|
||||
|
||||
@@ -140,7 +140,7 @@ ol.source.TileWMS.prototype.getGetFeatureInfoUrl =
|
||||
tileGrid = this.getTileGridForProjection(projectionObj);
|
||||
}
|
||||
|
||||
var tileCoord = tileGrid.getTileCoordForCoordAndResolutionInternal(
|
||||
var tileCoord = tileGrid.getTileCoordForCoordAndResolution(
|
||||
coordinate, resolution);
|
||||
|
||||
if (tileGrid.getResolutions().length <= tileCoord[0]) {
|
||||
|
||||
@@ -159,7 +159,7 @@ ol.source.WMTS = function(options) {
|
||||
var localContext = {
|
||||
'TileMatrix': tileGrid.getMatrixId(tileCoord[0]),
|
||||
'TileCol': tileCoord[1],
|
||||
'TileRow': tileCoord[2]
|
||||
'TileRow': -tileCoord[2] - 1
|
||||
};
|
||||
goog.object.extend(localContext, dimensions);
|
||||
var url = template;
|
||||
|
||||
@@ -6,9 +6,10 @@ goog.require('ol.ImageTile');
|
||||
goog.require('ol.TileCoord');
|
||||
goog.require('ol.TileState');
|
||||
goog.require('ol.dom');
|
||||
goog.require('ol.extent');
|
||||
goog.require('ol.proj');
|
||||
goog.require('ol.source.TileImage');
|
||||
goog.require('ol.tilegrid.Zoomify');
|
||||
goog.require('ol.tilegrid.TileGrid');
|
||||
|
||||
|
||||
/**
|
||||
@@ -86,8 +87,10 @@ ol.source.Zoomify = function(opt_options) {
|
||||
}
|
||||
resolutions.reverse();
|
||||
|
||||
var tileGrid = new ol.tilegrid.Zoomify({
|
||||
extent: [0, 0, size[0], size[1]],
|
||||
var extent = [0, -size[1], size[0], 0];
|
||||
var tileGrid = new ol.tilegrid.TileGrid({
|
||||
extent: extent,
|
||||
origin: ol.extent.getTopLeft(extent),
|
||||
resolutions: resolutions
|
||||
});
|
||||
|
||||
@@ -106,7 +109,7 @@ ol.source.Zoomify = function(opt_options) {
|
||||
} else {
|
||||
var tileCoordZ = tileCoord[0];
|
||||
var tileCoordX = tileCoord[1];
|
||||
var tileCoordY = tileCoord[2];
|
||||
var tileCoordY = -tileCoord[2] - 1;
|
||||
var tileIndex =
|
||||
tileCoordX +
|
||||
tileCoordY * tierSizeInTiles[tileCoordZ][0] +
|
||||
|
||||
@@ -155,7 +155,7 @@ ol.tilecoord.wrapX = function(tileCoord, tileGrid, projection) {
|
||||
var worldWidth = ol.extent.getWidth(projectionExtent);
|
||||
var worldsAway = Math.ceil((projectionExtent[0] - center[0]) / worldWidth);
|
||||
center[0] += worldWidth * worldsAway;
|
||||
return tileGrid.getTileCoordForCoordAndZInternal(center, z);
|
||||
return tileGrid.getTileCoordForCoordAndZ(center, z);
|
||||
} else {
|
||||
return tileCoord;
|
||||
}
|
||||
|
||||
@@ -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);
|
||||
@@ -54,9 +54,12 @@ ol.TileUrlFunction.createFromTemplate = function(template) {
|
||||
} else {
|
||||
return template.replace(zRegEx, tileCoord[0].toString())
|
||||
.replace(xRegEx, tileCoord[1].toString())
|
||||
.replace(yRegEx, tileCoord[2].toString())
|
||||
.replace(yRegEx, function() {
|
||||
var y = -tileCoord[2] - 1;
|
||||
return y.toString();
|
||||
})
|
||||
.replace(dashYRegEx, function() {
|
||||
var y = (1 << tileCoord[0]) - tileCoord[2] - 1;
|
||||
var y = (1 << tileCoord[0]) + tileCoord[2];
|
||||
return y.toString();
|
||||
});
|
||||
}
|
||||
|
||||
@@ -20,10 +20,10 @@ describe('ol.source.TileVector', function() {
|
||||
var projection = ol.proj.get('EPSG:3857');
|
||||
source.loadFeatures(
|
||||
[-8238854, 4969777, -8237854, 4970777], 4.8, projection);
|
||||
expect(tileCoords[0]).to.eql([15, 9647, 12320]);
|
||||
expect(tileCoords[1]).to.eql([15, 9647, 12319]);
|
||||
expect(tileCoords[2]).to.eql([15, 9648, 12320]);
|
||||
expect(tileCoords[3]).to.eql([15, 9648, 12319]);
|
||||
expect(tileCoords[0]).to.eql([15, 9647, -12321]);
|
||||
expect(tileCoords[1]).to.eql([15, 9647, -12320]);
|
||||
expect(tileCoords[2]).to.eql([15, 9648, -12321]);
|
||||
expect(tileCoords[3]).to.eql([15, 9648, -12320]);
|
||||
});
|
||||
|
||||
});
|
||||
@@ -41,16 +41,16 @@ describe('ol.source.TileVector', function() {
|
||||
var projection = ol.proj.get('EPSG:3857');
|
||||
|
||||
var tileCoord = tileSource.getTileCoordForTileUrlFunction(
|
||||
[6, -31, 41], projection);
|
||||
expect(tileCoord).to.eql([6, 33, 22]);
|
||||
[6, -31, -23], projection);
|
||||
expect(tileCoord).to.eql([6, 33, -23]);
|
||||
|
||||
tileCoord = tileSource.getTileCoordForTileUrlFunction(
|
||||
[6, 33, 41], projection);
|
||||
expect(tileCoord).to.eql([6, 33, 22]);
|
||||
[6, 33, -23], projection);
|
||||
expect(tileCoord).to.eql([6, 33, -23]);
|
||||
|
||||
tileCoord = tileSource.getTileCoordForTileUrlFunction(
|
||||
[6, 97, 41], projection);
|
||||
expect(tileCoord).to.eql([6, 33, 22]);
|
||||
[6, 97, -23], projection);
|
||||
expect(tileCoord).to.eql([6, 33, -23]);
|
||||
});
|
||||
|
||||
it('returns the expected tile coordinate - {wrapX: false}', function() {
|
||||
@@ -64,15 +64,15 @@ describe('ol.source.TileVector', function() {
|
||||
var projection = ol.proj.get('EPSG:3857');
|
||||
|
||||
var tileCoord = tileSource.getTileCoordForTileUrlFunction(
|
||||
[6, -31, 41], projection);
|
||||
[6, -31, -23], projection);
|
||||
expect(tileCoord).to.eql(null);
|
||||
|
||||
tileCoord = tileSource.getTileCoordForTileUrlFunction(
|
||||
[6, 33, 41], projection);
|
||||
expect(tileCoord).to.eql([6, 33, 22]);
|
||||
[6, 33, -23], projection);
|
||||
expect(tileCoord).to.eql([6, 33, -23]);
|
||||
|
||||
tileCoord = tileSource.getTileCoordForTileUrlFunction(
|
||||
[6, 97, 41], projection);
|
||||
[6, 97, -23], projection);
|
||||
expect(tileCoord).to.eql(null);
|
||||
});
|
||||
});
|
||||
|
||||
@@ -67,17 +67,17 @@ describe('ol.source.XYZ', function() {
|
||||
var projection = xyzTileSource.getProjection();
|
||||
var tileUrl = xyzTileSource.tileUrlFunction(
|
||||
xyzTileSource.getTileCoordForTileUrlFunction(
|
||||
[6, -31, 41], projection));
|
||||
[6, -31, -23], projection));
|
||||
expect(tileUrl).to.eql('6/33/22');
|
||||
|
||||
tileUrl = xyzTileSource.tileUrlFunction(
|
||||
xyzTileSource.getTileCoordForTileUrlFunction(
|
||||
[6, 33, 41], projection));
|
||||
[6, 33, -23], projection));
|
||||
expect(tileUrl).to.eql('6/33/22');
|
||||
|
||||
tileUrl = xyzTileSource.tileUrlFunction(
|
||||
xyzTileSource.getTileCoordForTileUrlFunction(
|
||||
[6, 97, 41], projection));
|
||||
[6, 97, -23], projection));
|
||||
expect(tileUrl).to.eql('6/33/22');
|
||||
});
|
||||
|
||||
@@ -89,17 +89,17 @@ describe('ol.source.XYZ', function() {
|
||||
var projection = xyzTileSource.getProjection();
|
||||
var tileUrl = xyzTileSource.tileUrlFunction(
|
||||
xyzTileSource.getTileCoordForTileUrlFunction(
|
||||
[6, 33, 150], projection));
|
||||
[6, 33, 0], projection));
|
||||
expect(tileUrl).to.be(undefined);
|
||||
|
||||
tileUrl = xyzTileSource.tileUrlFunction(
|
||||
xyzTileSource.getTileCoordForTileUrlFunction(
|
||||
[6, 33, 41], projection));
|
||||
[6, 33, -23], projection));
|
||||
expect(tileUrl).to.eql('6/33/22');
|
||||
|
||||
tileUrl = xyzTileSource.tileUrlFunction(
|
||||
xyzTileSource.getTileCoordForTileUrlFunction(
|
||||
[6, 33, -23], projection));
|
||||
[6, 33, -65], projection));
|
||||
expect(tileUrl).to.be(undefined);
|
||||
});
|
||||
|
||||
|
||||
@@ -370,78 +370,6 @@ describe('ol.tilegrid.TileGrid', function() {
|
||||
|
||||
});
|
||||
|
||||
describe('createOriginTopLeftTileCoordTransform', function() {
|
||||
|
||||
it('transforms y to -y-1 for top-left origins', function() {
|
||||
var tileGrid = new ol.tilegrid.TileGrid({
|
||||
origin: [10, 40],
|
||||
sizes: [[2, -2], [4, -4]],
|
||||
resolutions: [1, 0.5],
|
||||
tileSize: 10
|
||||
});
|
||||
var transformFn = goog.bind(
|
||||
ol.tilegrid.originTopLeftTileCoordTransform, tileGrid);
|
||||
expect(transformFn([0, 0, -2])).to.eql([0, 0, 1]);
|
||||
expect(transformFn([0, 0, -1])).to.eql([0, 0, 0]);
|
||||
expect(transformFn([1, 0, -4])).to.eql([1, 0, 3]);
|
||||
expect(transformFn([1, 0, -1])).to.eql([1, 0, 0]);
|
||||
});
|
||||
|
||||
it('transforms y to -y-1 when origin corner is not specified', function() {
|
||||
var tileGrid1 = new ol.tilegrid.TileGrid({
|
||||
origin: [10, 20],
|
||||
resolutions: [1, 0.5],
|
||||
tileSize: 10
|
||||
});
|
||||
var tileGrid = new ol.tilegrid.TileGrid({
|
||||
origin: [10, 40],
|
||||
resolutions: [1, 0.5],
|
||||
tileSize: 10
|
||||
});
|
||||
var transformFn1 = goog.bind(
|
||||
ol.tilegrid.originTopLeftTileCoordTransform, tileGrid);
|
||||
var transformFn2 = goog.bind(
|
||||
ol.tilegrid.originTopLeftTileCoordTransform, tileGrid1);
|
||||
expect(transformFn1([0, 0, -2])).to.eql([0, 0, 1]);
|
||||
expect(transformFn2([0, 0, -2])).to.eql([0, 0, 1]);
|
||||
expect(transformFn1([0, 0, -1])).to.eql([0, 0, 0]);
|
||||
expect(transformFn2([0, 0, -1])).to.eql([0, 0, 0]);
|
||||
expect(transformFn1([1, 0, -4])).to.eql([1, 0, 3]);
|
||||
expect(transformFn2([1, 0, -4])).to.eql([1, 0, 3]);
|
||||
expect(transformFn1([1, 0, -1])).to.eql([1, 0, 0]);
|
||||
expect(transformFn2([1, 0, -1])).to.eql([1, 0, 0]);
|
||||
});
|
||||
|
||||
it('transforms y to height-y-1 for bottom-left origins', function() {
|
||||
var tileGrid1 = new ol.tilegrid.TileGrid({
|
||||
extent: [10, 20, 30, 40],
|
||||
resolutions: [1, 0.5],
|
||||
tileSize: 10
|
||||
});
|
||||
var tileGrid2 = new ol.tilegrid.TileGrid({
|
||||
origin: [10, 20],
|
||||
sizes: [[2, 2], [4, 4]],
|
||||
resolutions: [1, 0.5],
|
||||
tileSize: 10
|
||||
});
|
||||
var transformFn1 = goog.bind(
|
||||
ol.tilegrid.originTopLeftTileCoordTransform, tileGrid1);
|
||||
var transformFn2 = goog.bind(
|
||||
ol.tilegrid.originTopLeftTileCoordTransform, tileGrid2);
|
||||
expect(tileGrid1.getFullTileRange(0).getHeight()).to.equal(2);
|
||||
expect(transformFn1([0, 0, 0])).to.eql([0, 0, 1]);
|
||||
expect(transformFn2([0, 0, 0])).to.eql([0, 0, 1]);
|
||||
expect(transformFn1([0, 0, 1])).to.eql([0, 0, 0]);
|
||||
expect(transformFn2([0, 0, 1])).to.eql([0, 0, 0]);
|
||||
expect(tileGrid1.getFullTileRange(1).getHeight()).to.equal(4);
|
||||
expect(transformFn1([1, 0, 0])).to.eql([1, 0, 3]);
|
||||
expect(transformFn2([1, 0, 0])).to.eql([1, 0, 3]);
|
||||
expect(transformFn1([1, 0, 3])).to.eql([1, 0, 0]);
|
||||
expect(transformFn2([1, 0, 3])).to.eql([1, 0, 0]);
|
||||
});
|
||||
|
||||
});
|
||||
|
||||
describe('createXYZ()', function() {
|
||||
|
||||
it('uses defaults', function() {
|
||||
|
||||
@@ -1,21 +0,0 @@
|
||||
goog.provide('ol.test.tilegrid.Zoomify');
|
||||
|
||||
describe('ol.tilegrid.Zoomify', function() {
|
||||
|
||||
describe('constructor', function() {
|
||||
|
||||
it('can be constructed with minimal arguments', function() {
|
||||
var instance = new ol.tilegrid.Zoomify({
|
||||
resolutions: [],
|
||||
extent: [],
|
||||
origin: [],
|
||||
tileSize: []
|
||||
});
|
||||
expect(instance).to.be.an(ol.tilegrid.Zoomify);
|
||||
});
|
||||
|
||||
});
|
||||
|
||||
});
|
||||
|
||||
goog.require('ol.tilegrid.Zoomify');
|
||||
@@ -30,16 +30,16 @@ describe('ol.TileUrlFunction', function() {
|
||||
describe('createFromTemplate', function() {
|
||||
it('creates expected URL', function() {
|
||||
var tileUrl = ol.TileUrlFunction.createFromTemplate('{z}/{x}/{y}');
|
||||
expect(tileUrl([3, 2, 1])).to.eql('3/2/1');
|
||||
expect(tileUrl([3, 2, -2])).to.eql('3/2/1');
|
||||
expect(tileUrl(null)).to.be(undefined);
|
||||
});
|
||||
it('accepts {-y} placeholder', function() {
|
||||
var tileUrl = ol.TileUrlFunction.createFromTemplate('{z}/{x}/{-y}');
|
||||
expect(tileUrl([3, 2, 2])).to.eql('3/2/5');
|
||||
expect(tileUrl([3, 2, -3])).to.eql('3/2/5');
|
||||
});
|
||||
it('replaces multiple placeholder occurrences', function() {
|
||||
var tileUrl = ol.TileUrlFunction.createFromTemplate('{z}/{z}{x}{y}');
|
||||
expect(tileUrl([3, 2, 1])).to.eql('3/321');
|
||||
expect(tileUrl([3, 2, -2])).to.eql('3/321');
|
||||
});
|
||||
});
|
||||
|
||||
@@ -51,7 +51,7 @@ describe('ol.TileUrlFunction', function() {
|
||||
'http://tile-3/{z}/{x}/{y}'
|
||||
];
|
||||
var tileUrlFunction = ol.TileUrlFunction.createFromTemplates(templates);
|
||||
var tileCoord = [3, 2, 1];
|
||||
var tileCoord = [3, 2, -2];
|
||||
|
||||
sinon.stub(ol.tilecoord, 'hash', function() { return 3; });
|
||||
expect(tileUrlFunction(tileCoord)).to.eql('http://tile-1/3/2/1');
|
||||
|
||||
Reference in New Issue
Block a user