Merge pull request #3815 from ahocevar/tilegrid-no-surprises

Simplify tilegrid API and internals
This commit is contained in:
Andreas Hocevar
2015-06-19 19:05:19 +02:00
30 changed files with 1149 additions and 464 deletions

View File

@@ -38,13 +38,22 @@ Note that `ol.FeatureOverlay#getFeatures()` returned an `{ol.Collection.<ol.Feat
#### `ol.TileCoord` changes
Until now, the API exposed two different types of `ol.TileCoord` tile coordinates: the internal ones with bottom-left origin, and transformed ones with an origin that is determined by the tile grid configuration. With this change, the API now only exposes the transformed tile coordinates.
Until now, the API exposed two different types of `ol.TileCoord` tile coordinates: internal ones that increase left to right and upward, and transformed ones that may increase downward, as defined by a transform function on the tile grid. With this change, the API now only exposes tile coordinates that increase left to right and upward.
The first `tileCoord` argument of `ol.TileUrlFunctionType` now expects transformed tile coordinates instead of internal OpenLayers tile coordinates. Accordingly, `ol.tilegrid.TileGrid#getTileCoordForCoordAndZ` and `ol.tilegrid.TileGrid#getTileCoordForCoordAndResolution` now return transformed tile coordinates.
Previously, tile grids created by OpenLayers either had their origin at the top-left or at the bottom-left corner of the extent. To make it easier to for application developers to transform tile coordinates to the common XYZ tiling scheme, all tile grids that OpenLayers creates internally have their origin now at the top-left corner of the extent.
This change affects applications that configure a custom `tileUrlFunction` for an `ol.source.Tile`. Previously, the `tileUrlFunction` was called with bottom-left origin tile coordinates that OpenLayers uses internally. To transform these into tile coordinates supported by the tile source, a custom `tileUrlFunction` had to change the `y` value of the `ol.TileCoord`. Now the `y` value can be used unaltered.
This change affects applications that configure a custom `tileUrlFunction` for an `ol.source.Tile`. Previously, the `tileUrlFunction` was called with rather unpredictable tile coordinates, depending on whether a tile coordinate transform took place before calling the `tileUrlFunction`. Now it is always called with OpenLayers tile coordinates. To transform these into the common XYZ tiling scheme, a custom `tileUrlFunction` has to change the `y` value (tile row) of the `ol.TileCoord`:
```js
function tileUrlFunction = function(tileCoord, pixelRatio, projection) {
var urlTemplate = '{z}/{x}/{y}';
return urlTemplate
.replace('{z}', tileCoord[0].toString())
.replace('{x}', tileCoord[1].toString())
.replace('{y}', (-tileCoord[2] - 1).toString());
}
```
To make it easier for application developers to perform this transform, the API provided an `ol.tilegrid.TileGrid#createTileCoordTransform()` function. This function is no longer available and no longer needed.
The `ol.tilegrid.TileGrid#createTileCoordTransform()` function which could be used to get the tile grid's tile coordinate transform function has been removed. This function was confusing and should no longer be needed now that application developers get tile coordinates in a known layout.
The code snippets below show how your application code needs to be changed:
@@ -72,16 +81,17 @@ var tileUrlFunction = function(tileCoord, pixelRatio, projection) {
};
```
New application code (no transform needed):
New application code (simple -y - 1 transform):
```js
var tileUrlFunction = function(tileCoord, pixelRatio, projection) {
return 'http://mytiles.com/' +
tileCoord[0] + '/' + tileCoord[1] + '/' + tileCoord[2] + '.png';
tileCoord[0] + '/' + tileCoord[1] + '/' + (-tileCoord[2] - 1) + '.png';
};
```
For easier debugging, `ol.source.DebugTile` was changed to display the transformed tile coordinates as well.
Also watch out for sections in your code where you used `ol.tilegrid.TileGrid#getTileCoordForCoordAndZ()` or `ol.tilegrid.TileGrid#getTileCoordForCoordAndResolution()`. When working with the returned tile coordinates, changes equivalent to the ones shown in the above snippets are required.
#### Removal of `ol.tilegrid.Zoomify`
The replacement of `ol.tilegrid.Zoomify` is a plain `ol.tilegrid.TileGrid`, configured with `extent`, `origin` and `resolutions`. If the `size` passed to the `ol.source.Zoomify` source is `[width, height]`, then the extent for the tile grid will be `[0, -height, width, 0]`, and the origin will be `[0, 0]`.
### v3.6.0

View File

@@ -3,7 +3,11 @@ template: example.html
title: Canvas tiles example
shortdesc: Renders tiles with coordinates for debugging.
docs: >
The black grid tiles are generated on the client with an HTML5 canvas. In this example, the `ol.source.TileDebug` source uses the tile grid of the `ol.source.OSM` source, so the displayed tile coordinates are the same as those for OSM tile requests.
The black grid tiles are generated on the client with an HTML5 canvas. The
displayed tile coordinates are OpenLayers tile coordinates. These increase
from bottom to top, but standard XYZ tiling scheme coordinates increase from
top to bottom. To calculate the `y` for a standard XYZ tile coordinate, use
`-y - 1`.
tags: "layers, openstreetmap, canvas"
---
<div class="row-fluid">

View File

@@ -29,7 +29,7 @@ var map = new ol.Map({
tileUrlFunction: function(tileCoord) {
return urlTemplate.replace('{z}', (tileCoord[0] - 1).toString())
.replace('{x}', tileCoord[1].toString())
.replace('{y}', tileCoord[2].toString());
.replace('{y}', (-tileCoord[2] - 1).toString());
},
wrapX: true
})

View File

@@ -4235,7 +4235,8 @@ olx.source.MapQuestOptions.prototype.url;
/**
* @typedef {{projection: ol.proj.ProjectionLike,
* tileGrid: (ol.tilegrid.TileGrid|undefined)}}
* tileGrid: (ol.tilegrid.TileGrid|undefined),
* wrapX: (boolean|undefined)}}
* @api
*/
olx.source.TileDebugOptions;
@@ -4257,6 +4258,14 @@ olx.source.TileDebugOptions.prototype.projection;
olx.source.TileDebugOptions.prototype.tileGrid;
/**
* Whether to wrap the world horizontally. Default is `true`.
* @type {boolean|undefined}
* @api
*/
olx.source.TileDebugOptions.prototype.wrapX;
/**
* @typedef {{attributions: (Array.<ol.Attribution>|undefined),
* crossOrigin: (null|string|undefined),
@@ -6126,8 +6135,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),
@@ -6143,7 +6151,7 @@ olx.tilegrid.TileGridOptions;
/**
* Extent for the tile grid. No tiles outside this extent will be requested by
* {@link ol.source.Tile} sources. When no `origin` or `origins` are
* configured, the `origin` will be set to the bottom-left corner of the extent.
* configured, the `origin` will be set to the top-left corner of the extent.
* @type {ol.Extent|undefined}
* @api
*/
@@ -6160,8 +6168,8 @@ olx.tilegrid.TileGridOptions.prototype.minZoom;
/**
* The tile grid origin, i.e. where the `x` and `y` axes meet (`[z, 0, 0]`).
* Tile coordinates increase from left to right and from bottom to top. If not
* specified, `extent` or `origins` must be provided.
* Tile coordinates increase left to right and upwards. If not specified,
* `extent` or `origins` must be provided.
* @type {ol.Coordinate|undefined}
* @api stable
*/
@@ -6172,8 +6180,8 @@ olx.tilegrid.TileGridOptions.prototype.origin;
* Tile grid origins, i.e. where the `x` and `y` axes meet (`[z, 0, 0]`), for
* each zoom level. If given, the array length should match the length of the
* `resolutions` array, i.e. each resolution can have a different origin. Tile
* coordinates increase from left to right and from bottom to top. If not
* specified, `extent` or `origin` must be provided.
* coordinates increase left to right and upwards. If not specified, `extent`
* or `origin` must be provided.
* @type {Array.<ol.Coordinate>|undefined}
* @api stable
*/
@@ -6190,17 +6198,6 @@ olx.tilegrid.TileGridOptions.prototype.origins;
olx.tilegrid.TileGridOptions.prototype.resolutions;
/**
* Number of tile rows and columns of the grid for each zoom level. This setting
* is only needed for tile coordinate transforms that need to work with origins
* other than the bottom-left corner of the grid. No tiles outside this range
* will be requested by sources. If an `extent` is also configured, it takes
* precedence.
* @type {Array.<ol.Size>|undefined}
*/
olx.tilegrid.TileGridOptions.prototype.sizes;
/**
* Tile size. Default is `[256, 256]`.
* @type {number|ol.Size|undefined}
@@ -6234,9 +6231,8 @@ olx.tilegrid.WMTSOptions;
/**
* Extent for the tile grid. No tiles outside this extent will be requested by
* {@link ol.source.WMTS} sources. When no `origin` or `origins` are
* configured, the `origin` will be calculated from the extent.
* When no `sizes` are configured, they will be calculated from the extent.
* {@link ol.source.Tile} sources. When no `origin` or `origins` are
* configured, the `origin` will be set to the top-left corner of the extent.
* @type {ol.Extent|undefined}
* @api
*/
@@ -6244,19 +6240,23 @@ olx.tilegrid.WMTSOptions.prototype.extent;
/**
* Origin, i.e. the top-left corner of the grid.
* The tile grid origin, i.e. where the `x` and `y` axes meet (`[z, 0, 0]`).
* Tile coordinates increase left to right and upwards. If not specified,
* `extent` or `origins` must be provided.
* @type {ol.Coordinate|undefined}
* @api
* @api stable
*/
olx.tilegrid.WMTSOptions.prototype.origin;
/**
* Origins, i.e. the top-left corners of the grid for each zoom level. The
* length of this array needs to match the length of the
* `resolutions` array.
* Tile grid origins, i.e. where the `x` and `y` axes meet (`[z, 0, 0]`), for
* each zoom level. If given, the array length should match the length of the
* `resolutions` array, i.e. each resolution can have a different origin. Tile
* coordinates increase left to right and upwards. If not specified, `extent` or
* `origin` must be provided.
* @type {Array.<ol.Coordinate>|undefined}
* @api
* @api stable
*/
olx.tilegrid.WMTSOptions.prototype.origins;
@@ -6285,7 +6285,10 @@ olx.tilegrid.WMTSOptions.prototype.matrixIds;
* here are the `TileMatrixWidth` and `TileMatrixHeight` advertised in the
* GetCapabilities response of the WMTS, and define the grid's extent together
* with the `origin`. An `extent` can be configured in addition, and will
* further limit the extent for which tile requests are made by sources.
* further limit the extent for which tile requests are made by sources. Note
* that when the top-left corner of the `extent` is used as `origin` or
* `origins`, then the `y` value must be negative because OpenLayers tile
* coordinates increase upwards.
* @type {Array.<ol.Size>|undefined}
* @api
*/
@@ -6368,21 +6371,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}

View File

@@ -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;

View File

@@ -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));
}
});
}));

View File

@@ -91,7 +91,8 @@ ol.source.TileDebug = function(options) {
goog.base(this, {
opaque: false,
projection: options.projection,
tileGrid: options.tileGrid
tileGrid: options.tileGrid,
wrapX: goog.isDef(options.wrapX) ? options.wrapX : true
});
};
@@ -108,8 +109,9 @@ ol.source.TileDebug.prototype.getTile = function(z, x, y) {
} else {
var tileSize = ol.size.toSize(this.tileGrid.getTileSize(z));
var tileCoord = [z, x, y];
var text = ol.tilecoord.toString(
this.getTileCoordForTileUrlFunction(tileCoord));
var textTileCoord = this.getTileCoordForTileUrlFunction(tileCoord);
var text = goog.isNull(textTileCoord) ? '' : ol.tilecoord.toString(
this.getTileCoordForTileUrlFunction(textTileCoord));
var tile = new ol.DebugTile_(tileCoord, tileSize, text);
this.tileCache.set(tileCoordKey, tile);
return tile;

View File

@@ -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;
};

View File

@@ -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()));

View File

@@ -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;
};

View File

@@ -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]) {

View File

@@ -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;

View File

@@ -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] +

View File

@@ -26,33 +26,6 @@ ol.QuadKeyCharCode = {
};
/**
* @param {string} quadKey Quad key.
* @return {ol.TileCoord} Tile coordinate.
*/
ol.tilecoord.createFromQuadKey = function(quadKey) {
var z = quadKey.length, x = 0, y = 0;
var mask = 1 << (z - 1);
var i;
for (i = 0; i < z; ++i) {
switch (quadKey.charCodeAt(i)) {
case ol.QuadKeyCharCode.ONE:
x += mask;
break;
case ol.QuadKeyCharCode.TWO:
y += mask;
break;
case ol.QuadKeyCharCode.THREE:
x += mask;
y += mask;
break;
}
mask >>= 1;
}
return [z, x, y];
};
/**
* @param {string} str String that follows pattern “z/x/y” where x, y and z are
* numbers.
@@ -155,7 +128,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;
}

View File

@@ -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');
@@ -75,7 +74,7 @@ ol.tilegrid.TileGrid = function(options) {
if (goog.isDef(extent) &&
goog.isNull(this.origin_) && goog.isNull(this.origins_)) {
this.origin_ = ol.extent.getBottomLeft(extent);
this.origin_ = ol.extent.getTopLeft(extent);
}
goog.asserts.assert(
@@ -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);
@@ -427,9 +391,10 @@ ol.tilegrid.TileGrid.prototype.getTileCoordForXYAndResolution_ = function(
var origin = this.getOrigin(z);
var tileSize = ol.size.toSize(this.getTileSize(z), this.tmpSize_);
var adjust = reverseIntersectionPolicy ? 0.5 : 0;
var xFromOrigin = ((x - origin[0]) / resolution + adjust) | 0;
var yFromOrigin = ((y - origin[1]) / resolution + adjust) | 0;
var adjustX = reverseIntersectionPolicy ? 0.5 : 0;
var adjustY = reverseIntersectionPolicy ? 0 : 0.5;
var xFromOrigin = Math.floor((x - origin[0]) / resolution + adjustX);
var yFromOrigin = Math.floor((y - origin[1]) / resolution + adjustY);
var tileCoordX = scale * xFromOrigin / tileSize[0];
var tileCoordY = scale * yFromOrigin / tileSize[1];
@@ -453,24 +418,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_(
@@ -544,15 +492,10 @@ ol.tilegrid.TileGrid.prototype.getZForResolution = function(resolution) {
* @private
*/
ol.tilegrid.TileGrid.prototype.calculateTileRanges_ = function(extent) {
var extentWidth = ol.extent.getWidth(extent);
var extentHeight = ol.extent.getHeight(extent);
var fullTileRanges = new Array(this.resolutions_.length);
var tileSize;
for (var z = 0, zz = fullTileRanges.length; z < zz; ++z) {
tileSize = ol.size.toSize(this.getTileSize(z), this.tmpSize_);
fullTileRanges[z] = new ol.TileRange(
0, Math.ceil(extentWidth / tileSize[0] / this.resolutions_[z]) - 1,
0, Math.ceil(extentHeight / tileSize[1] / this.resolutions_[z]) - 1);
var length = this.resolutions_.length;
var fullTileRanges = new Array(length);
for (var z = this.minZoom; z < length; ++z) {
fullTileRanges[z] = this.getTileRangeForExtentAndZ(extent, z);
}
this.fullTileRanges_ = fullTileRanges;
};
@@ -579,13 +522,13 @@ ol.tilegrid.getForProjection = function(projection) {
* @param {number|ol.Size=} opt_tileSize Tile size (default uses
* ol.DEFAULT_TILE_SIZE).
* @param {ol.extent.Corner=} opt_corner Extent corner (default is
* ol.extent.Corner.BOTTOM_LEFT).
* ol.extent.Corner.TOP_LEFT).
* @return {ol.tilegrid.TileGrid} TileGrid instance.
*/
ol.tilegrid.createForExtent =
function(extent, opt_maxZoom, opt_tileSize, opt_corner) {
var corner = goog.isDef(opt_corner) ?
opt_corner : ol.extent.Corner.BOTTOM_LEFT;
opt_corner : ol.extent.Corner.TOP_LEFT;
var resolutions = ol.tilegrid.resolutionsFromExtent(
extent, opt_maxZoom, opt_tileSize);
@@ -616,8 +559,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 +627,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);
};

View File

@@ -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
});
};
@@ -116,7 +115,6 @@ ol.tilegrid.WMTS.createFromCapabilitiesMatrixSet =
metersPerUnit;
var tileWidth = elt[tileWidthPropName];
var tileHeight = elt[tileHeightPropName];
var matrixHeight = elt['MatrixHeight'];
if (switchOriginXY) {
origins.push([elt[topLeftCornerPropName][1],
elt[topLeftCornerPropName][0]]);
@@ -127,7 +125,7 @@ ol.tilegrid.WMTS.createFromCapabilitiesMatrixSet =
tileSizes.push(tileWidth == tileHeight ?
tileWidth : [tileWidth, tileHeight]);
// top-left origin, so height is negative
sizes.push([elt['MatrixWidth'], -matrixHeight]);
sizes.push([elt['MatrixWidth'], -elt['MatrixHeight']]);
});
return new ol.tilegrid.WMTS({

View File

@@ -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);

View File

@@ -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();
});
}

View File

@@ -0,0 +1,842 @@
{
"authenticationResultCode": "ValidCredentials",
"brandLogoUri": "http:\/\/dev.virtualearth.net\/Branding\/logo_powered_by.png",
"copyright": "Copyright © 2015 Microsoft and its suppliers. All rights reserved. This API cannot be accessed and the content and any results may not be used, reproduced or transmitted in any manner without express written permission from Microsoft Corporation.",
"resourceSets": [{
"estimatedTotal": 1,
"resources": [{
"__type": "ImageryMetadata:http:\/\/schemas.microsoft.com\/search\/local\/ws\/rest\/v1",
"imageHeight": 256,
"imageUrl": "https:\/\/ecn.{subdomain}.tiles.virtualearth.net\/tiles\/h{quadkey}.jpeg?g=3542&mkt={culture}",
"imageUrlSubdomains": ["t0", "t1", "t2", "t3"],
"imageWidth": 256,
"imageryProviders": [{
"attribution": "© 2015 DigitalGlobe",
"coverageAreas": [{
"bbox": [ -67, -179.99, 27, 0],
"zoomMax": 21,
"zoomMin": 14
}, {
"bbox": [27, -179.99, 87, -126.5],
"zoomMax": 21,
"zoomMin": 14
}, {
"bbox": [48.4, -126.5, 87, -5.75],
"zoomMax": 21,
"zoomMin": 14
}, {
"bbox": [ -67, 28, 86.5, 179.99],
"zoomMax": 21,
"zoomMin": 14
}, {
"bbox": [ -67, 0, 37.8, 28],
"zoomMax": 21,
"zoomMin": 14
}, {
"bbox": [37.7, 18.5, 59.8, 28],
"zoomMax": 21,
"zoomMin": 14
}, {
"bbox": [43, -81.6, 48.4, -10],
"zoomMax": 21,
"zoomMin": 14
}, {
"bbox": [27, -70, 43, -10],
"zoomMax": 21,
"zoomMin": 14
}, {
"bbox": [27, -10, 35.8, 0],
"zoomMax": 21,
"zoomMin": 14
}, {
"bbox": [27, -120, 32.3, -105.8],
"zoomMax": 21,
"zoomMin": 14
}, {
"bbox": [43.4, 13.78, 54.9, 18.5],
"zoomMax": 21,
"zoomMin": 14
}
]
}, {
"attribution": "Image courtesy of NASA",
"coverageAreas": [{
"bbox": [ -90, -180, 90, 180],
"zoomMax": 8,
"zoomMin": 1
}
]
}, {
"attribution": "© Harris Corp, Earthstar Geographics LLC",
"coverageAreas": [{
"bbox": [ -90, -180, 90, 180],
"zoomMax": 13,
"zoomMin": 9
}
]
}, {
"attribution": "Image courtesy of USGS",
"coverageAreas": [{
"bbox": [17.99, -150.11, 61.39, -65.57],
"zoomMax": 17,
"zoomMin": 14
}
]
}, {
"attribution": "© Getmapping plc",
"coverageAreas": [{
"bbox": [49.94, -6.82, 60.17, 1.78],
"zoomMax": 21,
"zoomMin": 14
}
]
}, {
"attribution": "© 2015 GeoEye",
"coverageAreas": [{
"bbox": [48.95, -152, 65.5, -95.4],
"zoomMax": 21,
"zoomMin": 14
}, {
"bbox": [45.15, -73.2, 48.9, -70.2],
"zoomMax": 21,
"zoomMin": 14
}, {
"bbox": [31.87, -67.56, 49, -50.46],
"zoomMax": 21,
"zoomMin": 14
}, {
"bbox": [ -23, -180, 30, -145],
"zoomMax": 21,
"zoomMin": 14
}, {
"bbox": [ -37.7, -110, 26.5, -33],
"zoomMax": 21,
"zoomMin": 14
}, {
"bbox": [ -46, -20, 67, 180],
"zoomMax": 21,
"zoomMin": 14
}
]
}, {
"attribution": "© 2015 Pasco",
"coverageAreas": [{
"bbox": [23.5, 122.5, 46.65, 151.66],
"zoomMax": 21,
"zoomMin": 14
}
]
}, {
"attribution": "© GeoContent \/ (p) Intergraph",
"coverageAreas": [{
"bbox": [47, 5, 55.5, 16],
"zoomMax": 21,
"zoomMin": 14
}, {
"bbox": [46.25, 9.4, 49.2, 17.3],
"zoomMax": 21,
"zoomMin": 14
}
]
}, {
"attribution": "© 2015 Intermap",
"coverageAreas": [{
"bbox": [49, -11, 60, 2],
"zoomMax": 21,
"zoomMin": 1
}
]
}, {
"attribution": "Image courtesy of the IndianaMap",
"coverageAreas": [{
"bbox": [37.7, -88.2, 41.9, -84.7],
"zoomMax": 21,
"zoomMin": 14
}
]
}, {
"attribution": "Image courtesy of the Nevada State Mapping Advisory Committee",
"coverageAreas": [{
"bbox": [34.85, -120.2, 42.12, -113.91],
"zoomMax": 21,
"zoomMin": 14
}
]
}, {
"attribution": "© 2015 InterAtlas",
"coverageAreas": [{
"bbox": [48.37, 1.4, 49.28, 3.37],
"zoomMax": 21,
"zoomMin": 14
}, {
"bbox": [47.72, 1.67, 48.05, 2.18],
"zoomMax": 21,
"zoomMin": 14
}, {
"bbox": [45.55, 4.57, 45.95, 5.33],
"zoomMax": 21,
"zoomMin": 14
}, {
"bbox": [43.18, 4.92, 43.77, 5.82],
"zoomMax": 21,
"zoomMin": 14
}
]
}, {
"attribution": "© 2015 Eurosense",
"coverageAreas": [{
"bbox": [51, 3, 53.65, 7.67],
"zoomMax": 21,
"zoomMin": 14
}, {
"bbox": [50.58, 5.42, 51, 5.47],
"zoomMax": 21,
"zoomMin": 14
}
]
}, {
"attribution": "© 2015 IGP",
"coverageAreas": [{
"bbox": [36.88, -9.6, 42.27, -6],
"zoomMax": 21,
"zoomMin": 14
}
]
}, {
"attribution": "© 2015 IGN",
"coverageAreas": [{
"bbox": [42, -5, 51.25, 8.5],
"zoomMax": 21,
"zoomMin": 14
}, {
"bbox": [41.25, 8.3, 43.1, 9.65],
"zoomMax": 21,
"zoomMin": 14
}, {
"bbox": [17.85, -63.17, 18.15, -62.77],
"zoomMax": 21,
"zoomMin": 14
}, {
"bbox": [15.75, -61.9, 16.55, -60.9],
"zoomMax": 21,
"zoomMin": 14
}, {
"bbox": [14.35, -61.25, 14.95, -60.75],
"zoomMax": 21,
"zoomMin": 14
}, {
"bbox": [2.25, -54.65, 6, -51.4],
"zoomMax": 21,
"zoomMin": 14
}, {
"bbox": [ -21.5, 55, -20.75, 56],
"zoomMax": 21,
"zoomMin": 14
}, {
"bbox": [46.7, -56.5, 47.2, -56.1],
"zoomMax": 21,
"zoomMin": 14
}
]
}, {
"attribution": "© Province of British Columbia",
"coverageAreas": [{
"bbox": [48.99, -139.05, 60, -114.05],
"zoomMax": 18,
"zoomMin": 14
}
]
}, {
"attribution": "© 2015 Blom",
"coverageAreas": [{
"bbox": [36.1, -9.51, 51.04, 11.67],
"zoomMax": 21,
"zoomMin": 14
}, {
"bbox": [55.69, 9.8, 61.17, 13.23],
"zoomMax": 21,
"zoomMin": 14
}, {
"bbox": [62.2, 25.82, 62.24, 25.89],
"zoomMax": 21,
"zoomMin": 14
}
]
}, {
"attribution": "© 2015 Aerials Express",
"coverageAreas": [{
"bbox": [34.63, -90.41, 35.52, -89.48],
"zoomMax": 21,
"zoomMin": 14
}
]
}, {
"attribution": "Image courtesy of LAR-IAC",
"coverageAreas": [{
"bbox": [33.27, -119.02, 34.9, -117.59],
"zoomMax": 21,
"zoomMin": 14
}
]
}, {
"attribution": "Image courtesy of ImagePatch.com",
"coverageAreas": [{
"bbox": [25.74, -106.76, 36.63, -93.97],
"zoomMax": 21,
"zoomMin": 14
}, {
"bbox": [34.36, -93.14, 35.44, -92],
"zoomMax": 21,
"zoomMin": 14
}
]
}, {
"attribution": "State of Michigan",
"coverageAreas": [{
"bbox": [41.68, -86.87, 45.89, -82.91],
"zoomMax": 21,
"zoomMin": 14
}
]
}, {
"attribution": "Earthstar Geographics SIO",
"coverageAreas": [{
"bbox": [ -90, -180, 90, 180],
"zoomMax": 8,
"zoomMin": 1
}, {
"bbox": [70.61, 78.75, 71.52, 81.56],
"zoomMax": 13,
"zoomMin": 10
}, {
"bbox": [68.66, 135, 69.66, 137.81],
"zoomMax": 13,
"zoomMin": 10
}, {
"bbox": [67.61, 171.56, 68.66, 174.38],
"zoomMax": 13,
"zoomMin": 10
}, {
"bbox": [67.61, 70.31, 68.66, 73.13],
"zoomMax": 13,
"zoomMin": 10
}, {
"bbox": [66.51, -180, 67.61, -177.19],
"zoomMax": 13,
"zoomMin": 10
}, {
"bbox": [65.37, 36.56, 66.51, 39.38],
"zoomMax": 13,
"zoomMin": 10
}, {
"bbox": [64.17, -171.56, 65.37, -168.75],
"zoomMax": 13,
"zoomMin": 10
}, {
"bbox": [54.16, -70.31, 55.78, -67.5],
"zoomMax": 13,
"zoomMin": 10
}, {
"bbox": [52.48, -180, 65.37, -163.13],
"zoomMax": 13,
"zoomMin": 10
}, {
"bbox": [47.04, 140.63, 58.81, 154.69],
"zoomMax": 13,
"zoomMin": 10
}, {
"bbox": [36.6, 132.19, 40.98, 137.81],
"zoomMax": 13,
"zoomMin": 10
}, {
"bbox": [31.95, 64.69, 34.31, 67.5],
"zoomMax": 13,
"zoomMin": 10
}, {
"bbox": [31.95, 28.13, 34.31, 33.75],
"zoomMax": 13,
"zoomMin": 10
}, {
"bbox": [31.95, 16.88, 38.82, 19.69],
"zoomMax": 13,
"zoomMin": 10
}, {
"bbox": [29.54, 61.88, 31.95, 64.69],
"zoomMax": 13,
"zoomMin": 10
}, {
"bbox": [27.06, 123.75, 31.95, 129.38],
"zoomMax": 13,
"zoomMin": 10
}, {
"bbox": [24.53, 2.81, 27.06, 5.63],
"zoomMax": 13,
"zoomMin": 10
}, {
"bbox": [19.31, 16.88, 27.06, 22.5],
"zoomMax": 13,
"zoomMin": 10
}, {
"bbox": [19.31, -8.44, 27.06, -2.81],
"zoomMax": 13,
"zoomMin": 10
}, {
"bbox": [19.31, -95.63, 29.54, -84.38],
"zoomMax": 13,
"zoomMin": 10
}, {
"bbox": [16.64, -87.19, 19.31, -81.56],
"zoomMax": 13,
"zoomMin": 10
}, {
"bbox": [11.18, -81.56, 16.64, -61.88],
"zoomMax": 13,
"zoomMin": 10
}, {
"bbox": [5.62, 106.88, 21.94, 118.13],
"zoomMax": 13,
"zoomMin": 10
}, {
"bbox": [ -11.18, 143.44, -8.41, 146.25],
"zoomMax": 13,
"zoomMin": 10
}, {
"bbox": [ -13.92, 177.19, -11.18, 180],
"zoomMax": 13,
"zoomMin": 10
}, {
"bbox": [ -13.92, 137.81, -11.18, 140.63],
"zoomMax": 13,
"zoomMin": 10
}, {
"bbox": [ -85.05, -180, 85.05, 180],
"zoomMax": 13,
"zoomMin": 10
}, {
"bbox": [76.18, 67.5, 77.47, 70.31],
"zoomMax": 17,
"zoomMin": 10
}, {
"bbox": [74.02, 59.06, 75.5, 61.88],
"zoomMax": 17,
"zoomMin": 10
}, {
"bbox": [71.52, 118.13, 73.23, 120.94],
"zoomMax": 17,
"zoomMin": 10
}, {
"bbox": [70.61, 154.69, 71.52, 157.5],
"zoomMax": 17,
"zoomMin": 10
}, {
"bbox": [70.61, 146.25, 72.4, 151.88],
"zoomMax": 17,
"zoomMin": 10
}, {
"bbox": [70.61, 50.63, 74.78, 56.25],
"zoomMax": 17,
"zoomMin": 10
}, {
"bbox": [70.61, -11.25, 71.52, -5.63],
"zoomMax": 17,
"zoomMin": 10
}, {
"bbox": [70.61, -180, 72.4, -177.19],
"zoomMax": 17,
"zoomMin": 10
}, {
"bbox": [67.61, -180, 69.66, -177.19],
"zoomMax": 17,
"zoomMin": 10
}, {
"bbox": [62.92, -25.31, 67.61, -11.25],
"zoomMax": 17,
"zoomMin": 10
}, {
"bbox": [62.92, -56.25, 70.61, -50.63],
"zoomMax": 17,
"zoomMin": 10
}, {
"bbox": [62.92, -70.31, 64.17, -67.5],
"zoomMax": 17,
"zoomMin": 10
}, {
"bbox": [58.81, -47.81, 61.61, -42.19],
"zoomMax": 17,
"zoomMin": 10
}, {
"bbox": [52.48, 171.56, 54.16, 174.38],
"zoomMax": 17,
"zoomMin": 10
}, {
"bbox": [50.74, 0, 54.16, 5.63],
"zoomMax": 17,
"zoomMin": 10
}, {
"bbox": [47.04, -11.25, 61.61, 0],
"zoomMax": 17,
"zoomMin": 10
}, {
"bbox": [38.82, -33.75, 40.98, -30.94],
"zoomMax": 17,
"zoomMin": 10
}, {
"bbox": [38.82, -73.13, 40.98, -70.31],
"zoomMax": 17,
"zoomMin": 10
}, {
"bbox": [36.6, -11.25, 45.09, -2.81],
"zoomMax": 17,
"zoomMin": 10
}, {
"bbox": [36.6, -30.94, 40.98, -22.5],
"zoomMax": 17,
"zoomMin": 10
}, {
"bbox": [34.31, -75.94, 38.82, -73.13],
"zoomMax": 17,
"zoomMin": 10
}, {
"bbox": [34.31, -123.75, 36.6, -120.94],
"zoomMax": 17,
"zoomMin": 10
}, {
"bbox": [31.95, -67.5, 34.31, -64.69],
"zoomMax": 17,
"zoomMin": 10
}, {
"bbox": [31.95, -78.75, 34.31, -75.94],
"zoomMax": 17,
"zoomMin": 10
}, {
"bbox": [31.95, -120.94, 34.31, -118.13],
"zoomMax": 17,
"zoomMin": 10
}, {
"bbox": [27.06, -95.63, 29.54, -87.19],
"zoomMax": 17,
"zoomMin": 10
}, {
"bbox": [27.06, -180, 29.54, -177.19],
"zoomMax": 17,
"zoomMin": 10
}, {
"bbox": [24.53, -174.38, 27.06, -171.56],
"zoomMax": 17,
"zoomMin": 10
}, {
"bbox": [16.64, -163.13, 24.53, -154.69],
"zoomMax": 17,
"zoomMin": 10
}, {
"bbox": [13.92, -25.31, 19.31, -22.5],
"zoomMax": 17,
"zoomMin": 10
}, {
"bbox": [13.92, -171.56, 19.31, -168.75],
"zoomMax": 17,
"zoomMin": 10
}, {
"bbox": [11.18, 143.44, 21.94, 146.25],
"zoomMax": 17,
"zoomMin": 10
}, {
"bbox": [8.41, 137.81, 11.18, 140.63],
"zoomMax": 17,
"zoomMin": 10
}, {
"bbox": [8.41, -109.69, 11.18, -106.88],
"zoomMax": 17,
"zoomMin": 10
}, {
"bbox": [5.62, 157.5, 8.41, 160.31],
"zoomMax": 17,
"zoomMin": 10
}, {
"bbox": [5.62, 149.06, 11.18, 154.69],
"zoomMax": 17,
"zoomMin": 10
}, {
"bbox": [5.62, 132.19, 8.41, 135],
"zoomMax": 17,
"zoomMin": 10
}, {
"bbox": [0, -177.19, 2.81, -174.38],
"zoomMax": 17,
"zoomMin": 10
}, {
"bbox": [ -2.81, 165.94, 0, 168.75],
"zoomMax": 17,
"zoomMin": 10
}, {
"bbox": [ -2.81, -92.81, 2.81, -87.19],
"zoomMax": 17,
"zoomMin": 10
}, {
"bbox": [ -2.81, -163.13, 8.41, -154.69],
"zoomMax": 17,
"zoomMin": 10
}, {
"bbox": [ -5.62, 53.44, -2.81, 56.25],
"zoomMax": 17,
"zoomMin": 10
}, {
"bbox": [ -8.41, 70.31, -5.62, 73.13],
"zoomMax": 17,
"zoomMin": 10
}, {
"bbox": [ -11.18, 160.31, 21.94, 180],
"zoomMax": 17,
"zoomMin": 10
}, {
"bbox": [ -11.18, -140.63, -5.62, -137.81],
"zoomMax": 17,
"zoomMin": 10
}, {
"bbox": [ -13.92, 174.38, -11.18, 177.19],
"zoomMax": 17,
"zoomMin": 10
}, {
"bbox": [ -13.92, 95.63, -11.18, 98.44],
"zoomMax": 17,
"zoomMin": 10
}, {
"bbox": [ -16.64, -8.44, -13.92, -5.63],
"zoomMax": 17,
"zoomMin": 10
}, {
"bbox": [ -19.31, -154.69, -13.92, -140.63],
"zoomMax": 17,
"zoomMin": 10
}, {
"bbox": [ -21.94, 174.38, -13.92, 180],
"zoomMax": 17,
"zoomMin": 10
}, {
"bbox": [ -21.94, 61.88, -19.31, 64.69],
"zoomMax": 17,
"zoomMin": 10
}, {
"bbox": [ -21.94, 53.44, -19.31, 59.06],
"zoomMax": 17,
"zoomMin": 10
}, {
"bbox": [ -24.53, -140.63, -19.31, -132.19],
"zoomMax": 17,
"zoomMin": 10
}, {
"bbox": [38.82, -180, 71.52, -50.63],
"zoomMax": 17,
"zoomMin": 10
}, {
"bbox": [ -24.53, -151.88, -21.94, -146.25],
"zoomMax": 17,
"zoomMin": 10
}, {
"bbox": [ -24.53, -160.31, -16.64, -157.5],
"zoomMax": 17,
"zoomMin": 10
}, {
"bbox": [ -24.53, -180, 0, -160.31],
"zoomMax": 17,
"zoomMin": 10
}, {
"bbox": [ -27.06, -81.56, -24.53, -78.75],
"zoomMax": 17,
"zoomMin": 10
}, {
"bbox": [ -27.06, -132.19, -21.94, -126.56],
"zoomMax": 17,
"zoomMin": 10
}, {
"bbox": [ -29.54, 165.94, -27.06, 168.75],
"zoomMax": 17,
"zoomMin": 10
}, {
"bbox": [ -29.54, -109.69, -24.53, -106.88],
"zoomMax": 17,
"zoomMin": 10
}, {
"bbox": [ -29.54, -146.25, -27.06, -143.44],
"zoomMax": 17,
"zoomMin": 10
}, {
"bbox": [ -31.95, 157.5, -29.54, 160.31],
"zoomMax": 17,
"zoomMin": 10
}, {
"bbox": [ -34.31, -81.56, -31.95, -78.75],
"zoomMax": 17,
"zoomMin": 10
}, {
"bbox": [ -45.09, -19.69, 74.02, 180],
"zoomMax": 17,
"zoomMin": 10
}, {
"bbox": [ -45.09, -177.19, -43.07, -174.38],
"zoomMax": 17,
"zoomMin": 10
}, {
"bbox": [ -47.04, 50.63, -45.09, 53.44],
"zoomMax": 17,
"zoomMin": 10
}, {
"bbox": [ -47.04, 36.56, -45.09, 39.38],
"zoomMax": 17,
"zoomMin": 10
}, {
"bbox": [ -48.92, 177.19, -47.04, 180],
"zoomMax": 17,
"zoomMin": 10
}, {
"bbox": [ -50.74, 67.5, -47.04, 73.13],
"zoomMax": 17,
"zoomMin": 10
}, {
"bbox": [ -54.16, 165.94, -34.31, 180],
"zoomMax": 17,
"zoomMin": 10
}, {
"bbox": [ -54.16, 73.13, -52.48, 75.94],
"zoomMax": 17,
"zoomMin": 10
}, {
"bbox": [ -54.16, -61.88, -50.74, -56.25],
"zoomMax": 17,
"zoomMin": 10
}, {
"bbox": [ -55.78, 157.5, -54.16, 160.31],
"zoomMax": 17,
"zoomMin": 10
}, {
"bbox": [ -55.78, -39.38, -52.48, -33.75],
"zoomMax": 17,
"zoomMin": 10
}, {
"bbox": [ -57.33, -120.94, 31.95, -30.94],
"zoomMax": 17,
"zoomMin": 10
}, {
"bbox": [ -58.81, -28.13, -57.33, -25.31],
"zoomMax": 17,
"zoomMin": 10
}, {
"bbox": [ -61.61, -47.81, -60.24, -42.19],
"zoomMax": 17,
"zoomMin": 10
}
]
}, {
"attribution": "© 2012 DigitalGlobe",
"coverageAreas": [{
"bbox": [47.04, 67.5, 48.92, 70.31],
"zoomMax": 17,
"zoomMin": 10
}, {
"bbox": [21.94, 45, 24.53, 47.81],
"zoomMax": 17,
"zoomMin": 10
}, {
"bbox": [ -19.31, 14.06, -16.64, 16.88],
"zoomMax": 17,
"zoomMin": 10
}, {
"bbox": [ -38.82, -64.69, -36.6, -61.88],
"zoomMax": 17,
"zoomMin": 10
}, {
"bbox": [ -47.04, -70.31, -45.09, -67.5],
"zoomMax": 17,
"zoomMin": 10
}
]
}, {
"attribution": "© 2015 Microsoft Corporation",
"coverageAreas": [{
"bbox": [ -90, -180, 90, 180],
"zoomMax": 21,
"zoomMin": 1
}
]
}, {
"attribution": "© 2015 HERE",
"coverageAreas": [{
"bbox": [ -90, -180, 90, 180],
"zoomMax": 9,
"zoomMin": 1
}, {
"bbox": [14, -180, 90, -50],
"zoomMax": 21,
"zoomMin": 10
}, {
"bbox": [27, -32, 40, -13],
"zoomMax": 21,
"zoomMin": 10
}, {
"bbox": [35, -11, 72, 20],
"zoomMax": 21,
"zoomMin": 10
}, {
"bbox": [21, 20, 72, 32],
"zoomMax": 21,
"zoomMin": 10
}, {
"bbox": [21.92, 113.14, 22.79, 114.52],
"zoomMax": 21,
"zoomMin": 10
}, {
"bbox": [21.73, 119.7, 25.65, 122.39],
"zoomMax": 21,
"zoomMin": 10
}, {
"bbox": [0, 98.7, 8, 120.17],
"zoomMax": 21,
"zoomMin": 10
}, {
"bbox": [0.86, 103.2, 1.92, 104.45],
"zoomMax": 21,
"zoomMin": 10
}
]
}, {
"attribution": "© AND",
"coverageAreas": [{
"bbox": [ -90, -180, 90, 180],
"zoomMax": 21,
"zoomMin": 10
}
]
}, {
"attribution": "© 2015 MapData Sciences Pty Ltd, PSMA",
"coverageAreas": [{
"bbox": [ -45, 111, -9, 156],
"zoomMax": 21,
"zoomMin": 5
}, {
"bbox": [ -49.7, 164.42, -30.82, 180],
"zoomMax": 21,
"zoomMin": 5
}
]
}, {
"attribution": "© 2015 Zenrin",
"coverageAreas": [{
"bbox": [23.5, 122.5, 46.65, 151.66],
"zoomMax": 21,
"zoomMin": 4
}
]
}
],
"vintageEnd": null,
"vintageStart": null,
"zoomMax": 21,
"zoomMin": 1
}
]
}
],
"statusCode": 200,
"statusDescription": "OK",
"traceId": "510519adad2f4977a0ce328eafbf702c|DB40190745|02.00.163.2700|"
}

View File

@@ -0,0 +1,81 @@
goog.provide('ol.test.source.BingMaps');
describe('ol.source.BingMaps', function() {
describe('#tileUrlFunction()', function() {
var source, tileGrid;
beforeEach(function(done) {
var googNetJsonp = goog.net.Jsonp;
// mock goog.net.Jsonp (used in the ol.source.TileJSON constructor)
goog.net.Jsonp = function() {
this.send = function() {
var callback = arguments[1];
var client = new XMLHttpRequest();
client.open('GET', 'spec/ol/data/bing_aerialwithlabels.json', true);
client.onload = function() {
callback(JSON.parse(client.responseText));
};
client.send();
};
};
source = new ol.source.BingMaps({
imagerySet: 'AerialWithLabels',
key: ''
});
goog.net.Jsonp = googNetJsonp;
var key = source.on('change', function() {
if (source.getState() === 'ready') {
source.unByKey(key);
tileGrid = source.getTileGrid();
done();
}
});
});
it('returns the expected URL', function() {
var coordinate = [829330.2064098881, 5933916.615134273];
var projection = source.getProjection();
var regex = /\/tiles\/h(.*)\.jpeg/;
var tileUrl;
tileUrl = source.tileUrlFunction(
tileGrid.getTileCoordForCoordAndZ(coordinate, 1), 1, projection);
expect(tileUrl.match(regex)[1]).to.equal(ol.tilecoord.quadKey([1, 1, 0]));
tileUrl = source.tileUrlFunction(
tileGrid.getTileCoordForCoordAndZ(coordinate, 2), 1, projection);
expect(tileUrl.match(regex)[1]).to.equal(ol.tilecoord.quadKey([2, 2, 1]));
tileUrl = source.tileUrlFunction(
tileGrid.getTileCoordForCoordAndZ(coordinate, 3), 1, projection);
expect(tileUrl.match(regex)[1]).to.equal(ol.tilecoord.quadKey([3, 4, 2]));
tileUrl = source.tileUrlFunction(
tileGrid.getTileCoordForCoordAndZ(coordinate, 4), 1, projection);
expect(tileUrl.match(regex)[1]).to.equal(ol.tilecoord.quadKey([4, 8, 5]));
tileUrl = source.tileUrlFunction(
tileGrid.getTileCoordForCoordAndZ(coordinate, 5), 1, projection);
expect(tileUrl.match(regex)[1]).to.equal(ol.tilecoord.quadKey(
[5, 16, 11]));
tileUrl = source.tileUrlFunction(
tileGrid.getTileCoordForCoordAndZ(coordinate, 6), 1, projection);
expect(tileUrl.match(regex)[1]).to.equal(ol.tilecoord.quadKey(
[6, 33, 22]));
});
});
});
goog.require('goog.net.Jsonp');
goog.require('ol.source.BingMaps');
goog.require('ol.tilecoord');

View File

@@ -15,7 +15,7 @@ describe('ol.source.TileArcGISRest', function() {
it('returns a tile with the expected URL', function() {
var source = new ol.source.TileArcGISRest(options);
var tile = source.getTile(3, 2, 1, 1, ol.proj.get('EPSG:3857'));
var tile = source.getTile(3, 2, -7, 1, ol.proj.get('EPSG:3857'));
expect(tile).to.be.an(ol.ImageTile);
var uri = new goog.Uri(tile.src_);
expect(uri.getScheme()).to.be('http');
@@ -23,8 +23,8 @@ describe('ol.source.TileArcGISRest', function() {
expect(uri.getPath()).to.be('/MapServer/export');
var queryData = uri.getQueryData();
expect(queryData.get('BBOX')).to.be(
'-10018754.171394622,-15028131.257091932,' +
'-5009377.085697311,-10018754.17139462');
'-10018754.171394622,-15028131.257091936,' +
'-5009377.085697311,-10018754.171394624');
expect(queryData.get('FORMAT')).to.be('PNG32');
expect(queryData.get('SIZE')).to.be('256,256');
expect(queryData.get('IMAGESR')).to.be('3857');
@@ -39,7 +39,7 @@ describe('ol.source.TileArcGISRest', function() {
'http://test2.com/MapServer'];
var source = new ol.source.TileArcGISRest(options);
var tile = source.getTile(3, 2, 1, 1, ol.proj.get('EPSG:3857'));
var tile = source.getTile(3, 2, -7, 1, ol.proj.get('EPSG:3857'));
expect(tile).to.be.an(ol.ImageTile);
var uri = new goog.Uri(tile.src_);
expect(uri.getScheme()).to.be('http');
@@ -47,8 +47,8 @@ describe('ol.source.TileArcGISRest', function() {
expect(uri.getPath()).to.be('/MapServer/export');
var queryData = uri.getQueryData();
expect(queryData.get('BBOX')).to.be(
'-10018754.171394622,-15028131.257091932,' +
'-5009377.085697311,-10018754.17139462');
'-10018754.171394622,-15028131.257091936,' +
'-5009377.085697311,-10018754.171394624');
expect(queryData.get('FORMAT')).to.be('PNG32');
expect(queryData.get('SIZE')).to.be('256,256');
expect(queryData.get('IMAGESR')).to.be('3857');
@@ -60,7 +60,7 @@ describe('ol.source.TileArcGISRest', function() {
it('returns a tile with the expected URL for ImageServer', function() {
options.url = 'http://example.com/ImageServer';
var source = new ol.source.TileArcGISRest(options);
var tile = source.getTile(3, 2, 1, 1, ol.proj.get('EPSG:3857'));
var tile = source.getTile(3, 2, -7, 1, ol.proj.get('EPSG:3857'));
expect(tile).to.be.an(ol.ImageTile);
var uri = new goog.Uri(tile.src_);
expect(uri.getScheme()).to.be('http');
@@ -68,8 +68,8 @@ describe('ol.source.TileArcGISRest', function() {
expect(uri.getPath()).to.be('/ImageServer/exportImage');
var queryData = uri.getQueryData();
expect(queryData.get('BBOX')).to.be(
'-10018754.171394622,-15028131.257091932,' +
'-5009377.085697311,-10018754.17139462');
'-10018754.171394622,-15028131.257091936,' +
'-5009377.085697311,-10018754.171394624');
expect(queryData.get('FORMAT')).to.be('PNG32');
expect(queryData.get('SIZE')).to.be('256,256');
expect(queryData.get('IMAGESR')).to.be('3857');
@@ -81,7 +81,7 @@ describe('ol.source.TileArcGISRest', function() {
options.params.FORMAT = 'png';
options.params.TRANSPARENT = false;
var source = new ol.source.TileArcGISRest(options);
var tile = source.getTile(3, 2, 1, 1, ol.proj.get('EPSG:4326'));
var tile = source.getTile(3, 2, -3, 1, ol.proj.get('EPSG:4326'));
var uri = new goog.Uri(tile.src_);
var queryData = uri.getQueryData();
expect(queryData.get('FORMAT')).to.be('png');
@@ -91,7 +91,7 @@ describe('ol.source.TileArcGISRest', function() {
it('allows adding rest option', function() {
options.params.LAYERS = 'show:1,3,4';
var source = new ol.source.TileArcGISRest(options);
var tile = source.getTile(3, 2, 1, 1, ol.proj.get('EPSG:4326'));
var tile = source.getTile(3, 2, -3, 1, ol.proj.get('EPSG:4326'));
var uri = new goog.Uri(tile.src_);
var queryData = uri.getQueryData();
expect(queryData.get('LAYERS')).to.be('show:1,3,4');
@@ -104,7 +104,7 @@ describe('ol.source.TileArcGISRest', function() {
var source = new ol.source.TileArcGISRest(options);
source.updateParams({ 'TEST': 'value' });
var tile = source.getTile(3, 2, 1, 1, ol.proj.get('EPSG:3857'));
var tile = source.getTile(3, 2, -7, 1, ol.proj.get('EPSG:3857'));
var uri = new goog.Uri(tile.src_);
var queryData = uri.getQueryData();
@@ -117,7 +117,7 @@ describe('ol.source.TileArcGISRest', function() {
var source = new ol.source.TileArcGISRest(options);
source.updateParams({ 'TEST': 'newValue' });
var tile = source.getTile(3, 2, 1, 1, ol.proj.get('EPSG:3857'));
var tile = source.getTile(3, 2, -7, 1, ol.proj.get('EPSG:3857'));
var uri = new goog.Uri(tile.src_);
var queryData = uri.getQueryData();

View File

@@ -123,14 +123,14 @@ describe('ol.source.Tile', function() {
wrapX: true
});
var tileCoord = tileSource.getTileCoordForTileUrlFunction([6, -31, 22]);
expect(tileCoord).to.eql([6, 33, 22]);
var tileCoord = tileSource.getTileCoordForTileUrlFunction([6, -31, -23]);
expect(tileCoord).to.eql([6, 33, -23]);
tileCoord = tileSource.getTileCoordForTileUrlFunction([6, 33, 22]);
expect(tileCoord).to.eql([6, 33, 22]);
tileCoord = tileSource.getTileCoordForTileUrlFunction([6, 33, -23]);
expect(tileCoord).to.eql([6, 33, -23]);
tileCoord = tileSource.getTileCoordForTileUrlFunction([6, 97, 22]);
expect(tileCoord).to.eql([6, 33, 22]);
tileCoord = tileSource.getTileCoordForTileUrlFunction([6, 97, -23]);
expect(tileCoord).to.eql([6, 33, -23]);
});
it('returns the expected tile coordinate - {wrapX: false}', function() {
@@ -139,13 +139,13 @@ describe('ol.source.Tile', function() {
wrapX: false
});
var tileCoord = tileSource.getTileCoordForTileUrlFunction([6, -31, 22]);
var tileCoord = tileSource.getTileCoordForTileUrlFunction([6, -31, -23]);
expect(tileCoord).to.eql(null);
tileCoord = tileSource.getTileCoordForTileUrlFunction([6, 33, 22]);
expect(tileCoord).to.eql([6, 33, 22]);
tileCoord = tileSource.getTileCoordForTileUrlFunction([6, 33, -23]);
expect(tileCoord).to.eql([6, 33, -23]);
tileCoord = tileSource.getTileCoordForTileUrlFunction([6, 97, 22]);
tileCoord = tileSource.getTileCoordForTileUrlFunction([6, 97, -23]);
expect(tileCoord).to.eql(null);
});
});

View File

@@ -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);
});
});

View File

@@ -17,7 +17,7 @@ describe('ol.source.TileWMS', function() {
it('returns a tile with the expected URL', function() {
var source = new ol.source.TileWMS(options);
var tile = source.getTile(3, 2, 1, 1, ol.proj.get('EPSG:3857'));
var tile = source.getTile(3, 2, -7, 1, ol.proj.get('EPSG:3857'));
expect(tile).to.be.an(ol.ImageTile);
var uri = new goog.Uri(tile.src_);
expect(uri.getScheme()).to.be('http');
@@ -25,8 +25,8 @@ describe('ol.source.TileWMS', function() {
expect(uri.getPath()).to.be('/wms');
var queryData = uri.getQueryData();
expect(queryData.get('BBOX')).to.be(
'-10018754.171394622,-15028131.257091932,' +
'-5009377.085697311,-10018754.17139462');
'-10018754.171394622,-15028131.257091936,' +
'-5009377.085697311,-10018754.171394624');
expect(queryData.get('CRS')).to.be('EPSG:3857');
expect(queryData.get('FORMAT')).to.be('image/png');
expect(queryData.get('HEIGHT')).to.be('256');
@@ -44,13 +44,13 @@ describe('ol.source.TileWMS', function() {
it('returns a larger tile when a gutter is specified', function() {
options.gutter = 16;
var source = new ol.source.TileWMS(options);
var tile = source.getTile(3, 2, 1, 1, ol.proj.get('EPSG:3857'));
var tile = source.getTile(3, 2, -7, 1, ol.proj.get('EPSG:3857'));
expect(tile).to.be.an(ol.ImageTile);
var uri = new goog.Uri(tile.src_);
var queryData = uri.getQueryData();
var bbox = queryData.get('BBOX').split(',');
var expected = [-10331840.239250705, -15341217.324948015,
-4696291.017841229, -9705668.103538537];
var expected = [-10331840.239250705, -15341217.324948018,
-4696291.017841229, -9705668.103538541];
for (var i = 0, ii = bbox.length; i < ii; ++i) {
expect(parseFloat(bbox[i])).to.roughlyEqual(expected[i], 1e-9);
}
@@ -61,7 +61,7 @@ describe('ol.source.TileWMS', function() {
it('sets the SRS query value instead of CRS if version < 1.3', function() {
options.params.VERSION = '1.2';
var source = new ol.source.TileWMS(options);
var tile = source.getTile(3, 2, 1, 1, ol.proj.get('EPSG:4326'));
var tile = source.getTile(3, 2, -3, 1, ol.proj.get('EPSG:4326'));
var uri = new goog.Uri(tile.src_);
var queryData = uri.getQueryData();
expect(queryData.get('CRS')).to.be(undefined);
@@ -72,7 +72,7 @@ describe('ol.source.TileWMS', function() {
options.params.FORMAT = 'image/jpeg';
options.params.TRANSPARENT = false;
var source = new ol.source.TileWMS(options);
var tile = source.getTile(3, 2, 1, 1, ol.proj.get('EPSG:4326'));
var tile = source.getTile(3, 2, -3, 1, ol.proj.get('EPSG:4326'));
var uri = new goog.Uri(tile.src_);
var queryData = uri.getQueryData();
expect(queryData.get('FORMAT')).to.be('image/jpeg');
@@ -82,7 +82,7 @@ describe('ol.source.TileWMS', function() {
it('does not add a STYLES= option if one is specified', function() {
options.params.STYLES = 'foo';
var source = new ol.source.TileWMS(options);
var tile = source.getTile(3, 2, 1, 1, ol.proj.get('EPSG:4326'));
var tile = source.getTile(3, 2, -3, 1, ol.proj.get('EPSG:4326'));
var uri = new goog.Uri(tile.src_);
var queryData = uri.getQueryData();
expect(queryData.get('STYLES')).to.be('foo');
@@ -90,7 +90,7 @@ describe('ol.source.TileWMS', function() {
it('changes the BBOX order for EN axis orientations', function() {
var source = new ol.source.TileWMS(options);
var tile = source.getTile(3, 2, 1, 1, ol.proj.get('EPSG:4326'));
var tile = source.getTile(3, 2, -3, 1, ol.proj.get('EPSG:4326'));
var uri = new goog.Uri(tile.src_);
var queryData = uri.getQueryData();
expect(queryData.get('BBOX')).to.be('-45,-90,0,-45');
@@ -99,7 +99,7 @@ describe('ol.source.TileWMS', function() {
it('uses EN BBOX order if version < 1.3', function() {
options.params.VERSION = '1.1.0';
var source = new ol.source.TileWMS(options);
var tile = source.getTile(3, 2, 1, 1, ol.proj.get('CRS:84'));
var tile = source.getTile(3, 2, -3, 1, ol.proj.get('CRS:84'));
var uri = new goog.Uri(tile.src_);
var queryData = uri.getQueryData();
expect(queryData.get('BBOX')).to.be('-90,-45,-45,0');
@@ -108,7 +108,7 @@ describe('ol.source.TileWMS', function() {
it('sets FORMAT_OPTIONS when the server is GeoServer', function() {
options.serverType = ol.source.wms.ServerType.GEOSERVER;
var source = new ol.source.TileWMS(options);
var tile = source.getTile(3, 2, 1, 2, ol.proj.get('CRS:84'));
var tile = source.getTile(3, 2, -3, 2, ol.proj.get('CRS:84'));
var uri = new goog.Uri(tile.src_);
var queryData = uri.getQueryData();
expect(queryData.get('FORMAT_OPTIONS')).to.be('dpi:180');
@@ -118,7 +118,7 @@ describe('ol.source.TileWMS', function() {
options.serverType = ol.source.wms.ServerType.GEOSERVER;
var source = new ol.source.TileWMS(options);
options.params.FORMAT_OPTIONS = 'param1:value1';
var tile = source.getTile(3, 2, 1, 2, ol.proj.get('CRS:84'));
var tile = source.getTile(3, 2, -3, 2, ol.proj.get('CRS:84'));
var uri = new goog.Uri(tile.src_);
var queryData = uri.getQueryData();
expect(queryData.get('FORMAT_OPTIONS')).to.be('param1:value1;dpi:180');
@@ -128,7 +128,7 @@ describe('ol.source.TileWMS', function() {
function() {
options.serverType = ol.source.wms.ServerType.GEOSERVER;
var source = new ol.source.TileWMS(options);
var tile = source.getTile(3, 2, 1, 1.325, ol.proj.get('CRS:84'));
var tile = source.getTile(3, 2, -3, 1.325, ol.proj.get('CRS:84'));
var uri = new goog.Uri(tile.src_);
var queryData = uri.getQueryData();
expect(queryData.get('FORMAT_OPTIONS')).to.be('dpi:119');
@@ -141,7 +141,7 @@ describe('ol.source.TileWMS', function() {
it('returns a tile if it is contained within layers extent', function() {
options.extent = [-80, -40, -50, -10];
var source = new ol.source.TileWMS(options);
var tileCoord = [3, 2, 1];
var tileCoord = [3, 2, -3];
var url = source.tileUrlFunction(tileCoord, 1, ol.proj.get('EPSG:4326'));
var uri = new goog.Uri(url);
var queryData = uri.getQueryData();
@@ -151,7 +151,7 @@ describe('ol.source.TileWMS', function() {
it('returns a tile if it intersects layers extent', function() {
options.extent = [-80, -40, -40, -10];
var source = new ol.source.TileWMS(options);
var tileCoord = [3, 3, 1];
var tileCoord = [3, 3, -3];
var url = source.tileUrlFunction(tileCoord, 1, ol.proj.get('EPSG:4326'));
var uri = new goog.Uri(url);
var queryData = uri.getQueryData();
@@ -165,7 +165,7 @@ describe('ol.source.TileWMS', function() {
origin: [-180, -90]
});
var source = new ol.source.TileWMS(options);
var tileCoord = [3, 3, 1];
var tileCoord = [3, 3, -3];
var url = source.tileUrlFunction(tileCoord, 1, ol.proj.get('EPSG:4326'));
var uri = new goog.Uri(url);
var queryData = uri.getQueryData();
@@ -190,8 +190,8 @@ describe('ol.source.TileWMS', function() {
expect(uri.getPath()).to.be('/wms');
var queryData = uri.getQueryData();
expect(queryData.get('BBOX')).to.be(
'-10018754.171394622,-15028131.257091932,' +
'-5009377.085697311,-10018754.17139462');
'-10018754.171394622,-15028131.257091936,' +
'-5009377.085697311,-10018754.171394624');
expect(queryData.get('CRS')).to.be('EPSG:3857');
expect(queryData.get('FORMAT')).to.be('image/png');
expect(queryData.get('HEIGHT')).to.be('256');
@@ -222,8 +222,8 @@ describe('ol.source.TileWMS', function() {
expect(uri.getPath()).to.be('/wms');
var queryData = uri.getQueryData();
expect(queryData.get('BBOX')).to.be(
'-10018754.171394622,-15028131.257091932,' +
'-5009377.085697311,-10018754.17139462');
'-10018754.171394622,-15028131.257091936,' +
'-5009377.085697311,-10018754.171394624');
expect(queryData.get('CRS')).to.be('EPSG:3857');
expect(queryData.get('FORMAT')).to.be('image/png');
expect(queryData.get('HEIGHT')).to.be('256');

View File

@@ -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);
});

View File

@@ -11,15 +11,6 @@ describe('ol.TileCoord', function() {
});
});
describe('create from quad key', function() {
it('sets x y z properties as expected', function() {
var tileCoord = ol.tilecoord.createFromQuadKey('213');
expect(tileCoord[0]).to.eql(3);
expect(tileCoord[1]).to.eql(3);
expect(tileCoord[2]).to.eql(5);
});
});
describe('create from string', function() {
it('sets x y z properties as expected', function() {
var str = '1/2/3';
@@ -56,21 +47,21 @@ describe('ol.TileCoord', function() {
resolutions: [2, 1],
minZoom: 1
});
expect(ol.tilecoord.withinExtentAndZ([0, 0, 0], tileGrid)).to.be(false);
expect(ol.tilecoord.withinExtentAndZ([1, 0, 0], tileGrid)).to.be(true);
expect(ol.tilecoord.withinExtentAndZ([2, 0, 0], tileGrid)).to.be(false);
expect(ol.tilecoord.withinExtentAndZ([0, 0, -1], tileGrid)).to.be(false);
expect(ol.tilecoord.withinExtentAndZ([1, 0, -1], tileGrid)).to.be(true);
expect(ol.tilecoord.withinExtentAndZ([2, 0, -1], tileGrid)).to.be(false);
});
it('restricts by extent when extent defines tile ranges', function() {
var tileGrid = new ol.tilegrid.TileGrid({
extent: [10, 20, 30, 40],
sizes: [[3, 3]],
sizes: [[3, -3]],
tileSize: 10,
resolutions: [1]
});
expect(ol.tilecoord.withinExtentAndZ([0, 1, 1], tileGrid)).to.be(true);
expect(ol.tilecoord.withinExtentAndZ([0, 2, 0], tileGrid)).to.be(false);
expect(ol.tilecoord.withinExtentAndZ([0, 0, 2], tileGrid)).to.be(false);
expect(ol.tilecoord.withinExtentAndZ([0, 1, -2], tileGrid)).to.be(true);
expect(ol.tilecoord.withinExtentAndZ([0, 2, -1], tileGrid)).to.be(false);
expect(ol.tilecoord.withinExtentAndZ([0, 0, -3], tileGrid)).to.be(false);
});
it('restricts by extent when sizes define tile ranges', function() {
@@ -88,6 +79,21 @@ describe('ol.TileCoord', function() {
expect(ol.tilecoord.withinExtentAndZ([0, 0, 3], tileGrid)).to.be(false);
});
it('restricts by extent when sizes (neg y) define tile ranges', function() {
var tileGrid = new ol.tilegrid.TileGrid({
origin: [10, 40],
sizes: [[3, -3]],
tileSize: 10,
resolutions: [1]
});
expect(ol.tilecoord.withinExtentAndZ([0, 0, -1], tileGrid)).to.be(true);
expect(ol.tilecoord.withinExtentAndZ([0, -1, -1], tileGrid)).to.be(false);
expect(ol.tilecoord.withinExtentAndZ([0, 0, 0], tileGrid)).to.be(false);
expect(ol.tilecoord.withinExtentAndZ([0, 2, -3], tileGrid)).to.be(true);
expect(ol.tilecoord.withinExtentAndZ([0, 3, -1], tileGrid)).to.be(false);
expect(ol.tilecoord.withinExtentAndZ([0, 0, -4], tileGrid)).to.be(false);
});
it('does not restrict by extent with no extent or sizes', function() {
var tileGrid = new ol.tilegrid.TileGrid({
origin: [10, 20],

View File

@@ -205,16 +205,16 @@ describe('ol.tilegrid.TileGrid', function() {
});
});
it('assumes bottom left corner of extent as origin', function() {
expect(tileGrid.getOrigin()).to.eql([10, 20]);
it('assumes top left corner of extent as origin', function() {
expect(tileGrid.getOrigin()).to.eql([10, 40]);
});
it('calculates full tile ranges from extent', function() {
var fullTileRange = tileGrid.getFullTileRange(0);
expect(fullTileRange.minX).to.equal(0);
expect(fullTileRange.maxX).to.equal(1);
expect(fullTileRange.minY).to.equal(0);
expect(fullTileRange.maxY).to.equal(1);
expect(fullTileRange.minY).to.equal(-2);
expect(fullTileRange.maxY).to.equal(-1);
});
});
@@ -223,7 +223,7 @@ describe('ol.tilegrid.TileGrid', function() {
beforeEach(function() {
tileGrid = new ol.tilegrid.TileGrid({
extent: [10, 20, 30, 40],
sizes: [[3, 3]],
sizes: [[3, -3]],
tileSize: 10,
resolutions: [1]
});
@@ -237,8 +237,8 @@ describe('ol.tilegrid.TileGrid', function() {
var fullTileRange = tileGrid.getFullTileRange(0);
expect(fullTileRange.minX).to.equal(0);
expect(fullTileRange.maxX).to.equal(2);
expect(fullTileRange.minY).to.equal(0);
expect(fullTileRange.maxY).to.equal(2);
expect(fullTileRange.minY).to.equal(-3);
expect(fullTileRange.maxY).to.equal(-1);
});
});
@@ -253,13 +253,31 @@ describe('ol.tilegrid.TileGrid', function() {
});
});
it('calculates correct minX and maxX for negative heights', function() {
it('calculates correct minY and maxY for negative heights', function() {
var fullTileRange = tileGrid.getFullTileRange(0);
expect(fullTileRange.minY).to.equal(-3);
expect(fullTileRange.maxY).to.equal(-1);
});
});
describe('create with bottom-left origin and sizes', function() {
var tileGrid;
beforeEach(function() {
tileGrid = new ol.tilegrid.TileGrid({
origin: [10, 10],
sizes: [[3, 3]],
tileSize: 10,
resolutions: [1]
});
});
it('calculates correct minX and maxX for positive heights', function() {
var fullTileRange = tileGrid.getFullTileRange(0);
expect(fullTileRange.minY).to.equal(0);
expect(fullTileRange.maxY).to.equal(2);
});
});
describe('create with extent and origin', function() {
it('uses both origin and extent', function() {
var tileGrid = new ol.tilegrid.TileGrid({
@@ -281,7 +299,7 @@ describe('ol.tilegrid.TileGrid', function() {
var resolutions = grid.getResolutions();
expect(resolutions.length).to.be(ol.DEFAULT_MAX_ZOOM + 1);
expect(grid.getOrigin()).to.eql([-100, -100]);
expect(grid.getOrigin()).to.eql([-100, 100]);
});
});
@@ -324,12 +342,12 @@ describe('ol.tilegrid.TileGrid', function() {
ol.DEFAULT_TILE_SIZE / Math.pow(2, 5));
});
it('assumes origin is bottom-left', function() {
it('assumes origin is top-left', function() {
var projection = ol.proj.get('EPSG:3857');
var grid = ol.tilegrid.createForProjection(projection);
var origin = grid.getOrigin();
var half = ol.proj.EPSG3857.HALF_SIZE;
expect(origin).to.eql([-half, -half]);
expect(origin).to.eql([-half, half]);
});
it('accepts bottom-left as corner', function() {
@@ -370,78 +388,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() {

View File

@@ -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');

View File

@@ -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');

View File

@@ -56,7 +56,7 @@ describe('ol.rendering.layer.Image', function() {
source = new ol.source.ImageStatic({
url: 'spec/ol/data/tiles/osm/5/5/12.png',
imageExtent: ol.tilegrid.createXYZ().getTileCoordExtent(
[5, 5, 32 - 12 - 1]),
[5, 5, -12 - 1]),
projection: ol.proj.get('EPSG:3857')
});
});