Merge pull request #8992 from tschaub/tilecoord

Use standard tile coords
This commit is contained in:
Tim Schaub
2018-11-21 15:18:51 -07:00
committed by GitHub
31 changed files with 324 additions and 266 deletions
+47
View File
@@ -4,6 +4,53 @@
#### Backwards incompatible changes #### Backwards incompatible changes
##### New internal tile coordinates
Previously, the internal tile coordinates used in the library had an unusual row order the origin of the tile coordinate system was at the top left as expected, but the rows increased upwards. This meant that all tile coordinates within a tile grid's extent had negative `y` values.
Now, the internal tile coordinates used in the library have the same row order as standard (e.g. XYZ) tile coordinates. The origin is at the top left (as before), and rows or `y` values increase downward. So the top left tile of a tile grid is now `0, 0`, whereas it was `0, -1` before.
```
x, y values for tile coordinates
origin
*__________________________
| | | |
| 0, 0 | 1, 0 | 2, 0 |
|________|________|________|
| | | |
| 0, 1 | 1, 1 | 2, 1 |
|________|________|________|
| | | |
| 0, 2 | 1, 2 | 2, 2 |
|________|________|________|
```
This change should only affect you if you were using a custom `tileLoadFunction` or `tileUrlFunction`. For example, if you used to have a `tileUrlFunction` that looked like this:
```js
// before
function tileUrlFunction(tileCoord) {
const z = tileCoord[0];
const x = tileCoord[1];
const y = -tileCoord[2] - 1;
// do something with z, x, y
}
```
You would now do something like this:
```js
// after
function tileUrlFunction(tileCoord) {
const z = tileCoord[0];
const x = tileCoord[1];
const y = tileCoord[2];
// do something with z, x, y
}
```
In addition (this should be exceedingly rare), if you previously created a `ol/tilegrid/WMTS` by hand and you were providing an array of `sizes`, you no longer have to provide a negative height if your tile origin is the top-left corner (the common case). On the other hand, if you are providing a custom array of `sizes` and your origin is the bottom of the grid (this is uncommon), your height values must now be negative.
##### Removal of the "vector" render mode for vector tile layers ##### Removal of the "vector" render mode for vector tile layers
If you were previously using `VectorTile` layers with `renderMode: 'vector'`, you have to remove this configuration option. That mode was removed. `'hybrid'` (default) and `'image'` are still available. If you were previously using `VectorTile` layers with `renderMode: 'vector'`, you have to remove this configuration option. That mode was removed. `'hybrid'` (default) and `'image'` are still available.
+1 -1
View File
@@ -77,7 +77,7 @@ fetch(url).then(function(response) {
tileLoadFunction: function(tile) { tileLoadFunction: function(tile) {
const format = tile.getFormat(); const format = tile.getFormat();
const tileCoord = tile.getTileCoord(); const tileCoord = tile.getTileCoord();
const data = tileIndex.getTile(tileCoord[0], tileCoord[1], -tileCoord[2] - 1); const data = tileIndex.getTile(tileCoord[0], tileCoord[1], tileCoord[2]);
const features = format.readFeatures( const features = format.readFeatures(
JSON.stringify({ JSON.stringify({
+1 -1
View File
@@ -21,7 +21,7 @@ function tileUrlFunction(tileCoord) {
'{z}/{x}/{y}.vector.pbf?access_token=' + key) '{z}/{x}/{y}.vector.pbf?access_token=' + key)
.replace('{z}', String(tileCoord[0] * 2 - 1)) .replace('{z}', String(tileCoord[0] * 2 - 1))
.replace('{x}', String(tileCoord[1])) .replace('{x}', String(tileCoord[1]))
.replace('{y}', String(-tileCoord[2] - 1)) .replace('{y}', String(tileCoord[2]))
.replace('{a-d}', 'abcd'.substr( .replace('{a-d}', 'abcd'.substr(
((tileCoord[1] << tileCoord[0]) + tileCoord[2]) % 4, 1)); ((tileCoord[1] << tileCoord[0]) + tileCoord[2]) % 4, 1));
} }
+1 -1
View File
@@ -21,7 +21,7 @@ const map = new Map({
tileUrlFunction: function(tileCoord) { tileUrlFunction: function(tileCoord) {
return urlTemplate.replace('{z}', (tileCoord[0] - 1).toString()) return urlTemplate.replace('{z}', (tileCoord[0] - 1).toString())
.replace('{x}', tileCoord[1].toString()) .replace('{x}', tileCoord[1].toString())
.replace('{y}', (-tileCoord[2] - 1).toString()); .replace('{y}', tileCoord[2].toString());
}, },
wrapX: true wrapX: true
}) })
+1 -1
View File
@@ -274,7 +274,7 @@ class CanvasTileLayerRenderer extends CanvasLayerRenderer {
// Calculate integer positions and sizes so that tiles align // Calculate integer positions and sizes so that tiles align
const floatX = (origin[0] - (originTileCoord[1] - tileCoord[1]) * dx); const floatX = (origin[0] - (originTileCoord[1] - tileCoord[1]) * dx);
const nextX = Math.round(floatX + dx); const nextX = Math.round(floatX + dx);
const floatY = (origin[1] + (originTileCoord[2] - tileCoord[2]) * dy); const floatY = (origin[1] - (originTileCoord[2] - tileCoord[2]) * dy);
const nextY = Math.round(floatY + dy); const nextY = Math.round(floatY + dy);
const x = Math.round(floatX); const x = Math.round(floatX);
const y = Math.round(floatY); const y = Math.round(floatY);
+28 -2
View File
@@ -8,10 +8,35 @@ import {jsonp as requestJSONP} from '../net.js';
import {get as getProjection, getTransformFromProjections} from '../proj.js'; import {get as getProjection, getTransformFromProjections} from '../proj.js';
import SourceState from './State.js'; import SourceState from './State.js';
import TileImage from './TileImage.js'; import TileImage from './TileImage.js';
import {createOrUpdate, quadKey} from '../tilecoord.js'; import {createOrUpdate} from '../tilecoord.js';
import {createXYZ, extentFromProjection} from '../tilegrid.js'; import {createXYZ, extentFromProjection} from '../tilegrid.js';
/**
* @param {import('../tilecoord.js').TileCoord} tileCoord Tile coord.
* @return {string} Quad key.
*/
export function quadKey(tileCoord) {
const z = tileCoord[0];
const digits = new Array(z);
let mask = 1 << (z - 1);
let i, charCode;
for (i = 0; i < z; ++i) {
// 48 is charCode for 0 - '0'.charCodeAt(0)
charCode = 48;
if (tileCoord[1] & mask) {
charCode += 1;
}
if (tileCoord[2] & mask) {
charCode += 2;
}
digits[i] = String.fromCharCode(charCode);
mask >>= 1;
}
return digits.join('');
}
/** /**
* The attribution containing a link to the Microsoft® Bing™ Maps Platform APIs * The attribution containing a link to the Microsoft® Bing™ Maps Platform APIs
* Terms Of Use. * Terms Of Use.
@@ -209,6 +234,7 @@ class BingMaps extends TileImage {
const hidpi = this.hidpi_; const hidpi = this.hidpi_;
this.tileUrlFunction = createFromTileUrlFunctions( this.tileUrlFunction = createFromTileUrlFunctions(
resource.imageUrlSubdomains.map(function(subdomain) { resource.imageUrlSubdomains.map(function(subdomain) {
/** @type {import('../tilecoord.js').TileCoord} */
const quadKeyTileCoord = [0, 0, 0]; const quadKeyTileCoord = [0, 0, 0];
const imageUrl = resource.imageUrl const imageUrl = resource.imageUrl
.replace('{subdomain}', subdomain) .replace('{subdomain}', subdomain)
@@ -224,7 +250,7 @@ class BingMaps extends TileImage {
if (!tileCoord) { if (!tileCoord) {
return undefined; return undefined;
} else { } else {
createOrUpdate(tileCoord[0], tileCoord[1], -tileCoord[2] - 1, quadKeyTileCoord); createOrUpdate(tileCoord[0], tileCoord[1], tileCoord[2], quadKeyTileCoord);
let url = imageUrl; let url = imageUrl;
if (hidpi) { if (hidpi) {
url += '&dpi=d1&device=mobile'; url += '&dpi=d1&device=mobile';
+1 -1
View File
@@ -121,7 +121,7 @@ class TileDebug extends XYZ {
const textTileCoord = this.getTileCoordForTileUrlFunction(tileCoord); const textTileCoord = this.getTileCoordForTileUrlFunction(tileCoord);
let text; let text;
if (textTileCoord) { if (textTileCoord) {
text = 'z:' + textTileCoord[0] + ' x:' + textTileCoord[1] + ' y:' + (-textTileCoord[2] - 1); text = 'z:' + textTileCoord[0] + ' x:' + textTileCoord[1] + ' y:' + textTileCoord[2];
} else { } else {
text = 'none'; text = 'none';
} }
+1 -1
View File
@@ -507,7 +507,7 @@ function createFromWMTSTemplate(template) {
const localContext = { const localContext = {
'TileMatrix': tileGrid.getMatrixId(tileCoord[0]), 'TileMatrix': tileGrid.getMatrixId(tileCoord[0]),
'TileCol': tileCoord[1], 'TileCol': tileCoord[1],
'TileRow': -tileCoord[2] - 1 'TileRow': tileCoord[2]
}; };
assign(localContext, dimensions); assign(localContext, dimensions);
let url = template; let url = template;
+1 -1
View File
@@ -213,7 +213,7 @@ class Zoomify extends TileImage {
} else { } else {
const tileCoordZ = tileCoord[0]; const tileCoordZ = tileCoord[0];
const tileCoordX = tileCoord[1]; const tileCoordX = tileCoord[1];
const tileCoordY = -tileCoord[2] - 1; const tileCoordY = tileCoord[2];
const tileIndex = const tileIndex =
tileCoordX + tileCoordX +
tileCoordY * tierSizeInTiles[tileCoordZ][0]; tileCoordY * tierSizeInTiles[tileCoordZ][0];
+1 -26
View File
@@ -5,7 +5,7 @@
/** /**
* An array of three numbers representing the location of a tile in a tile * An array of three numbers representing the location of a tile in a tile
* grid. The order is `z`, `x`, and `y`. `z` is the zoom level. * grid. The order is `z` (zoom level), `x` (column), and `y` (row).
* @typedef {Array<number>} TileCoord * @typedef {Array<number>} TileCoord
* @api * @api
*/ */
@@ -70,31 +70,6 @@ export function hash(tileCoord) {
} }
/**
* @param {TileCoord} tileCoord Tile coord.
* @return {string} Quad key.
*/
export function quadKey(tileCoord) {
const z = tileCoord[0];
const digits = new Array(z);
let mask = 1 << (z - 1);
let i, charCode;
for (i = 0; i < z; ++i) {
// 48 is charCode for 0 - '0'.charCodeAt(0)
charCode = 48;
if (tileCoord[1] & mask) {
charCode += 1;
}
if (tileCoord[2] & mask) {
charCode += 2;
}
digits[i] = String.fromCharCode(charCode);
mask >>= 1;
}
return digits.join('');
}
/** /**
* @param {TileCoord} tileCoord Tile coordinate. * @param {TileCoord} tileCoord Tile coordinate.
* @param {!import("./tilegrid/TileGrid.js").default} tileGrid Tile grid. * @param {!import("./tilegrid/TileGrid.js").default} tileGrid Tile grid.
+8 -8
View File
@@ -342,10 +342,10 @@ class TileGrid {
*/ */
getTileRangeForExtentAndZ(extent, z, opt_tileRange) { getTileRangeForExtentAndZ(extent, z, opt_tileRange) {
const tileCoord = tmpTileCoord; const tileCoord = tmpTileCoord;
this.getTileCoordForXYAndZ_(extent[0], extent[1], z, false, tileCoord); this.getTileCoordForXYAndZ_(extent[0], extent[3], z, false, tileCoord);
const minX = tileCoord[1]; const minX = tileCoord[1];
const minY = tileCoord[2]; const minY = tileCoord[2];
this.getTileCoordForXYAndZ_(extent[2], extent[3], z, true, tileCoord); this.getTileCoordForXYAndZ_(extent[2], extent[1], z, true, tileCoord);
return createOrUpdateTileRange(minX, tileCoord[1], minY, tileCoord[2], opt_tileRange); return createOrUpdateTileRange(minX, tileCoord[1], minY, tileCoord[2], opt_tileRange);
} }
@@ -359,7 +359,7 @@ class TileGrid {
const tileSize = toSize(this.getTileSize(tileCoord[0]), this.tmpSize_); const tileSize = toSize(this.getTileSize(tileCoord[0]), this.tmpSize_);
return [ return [
origin[0] + (tileCoord[1] + 0.5) * tileSize[0] * resolution, origin[0] + (tileCoord[1] + 0.5) * tileSize[0] * resolution,
origin[1] + (tileCoord[2] + 0.5) * tileSize[1] * resolution origin[1] - (tileCoord[2] + 0.5) * tileSize[1] * resolution
]; ];
} }
@@ -376,7 +376,7 @@ class TileGrid {
const resolution = this.getResolution(tileCoord[0]); const resolution = this.getResolution(tileCoord[0]);
const tileSize = toSize(this.getTileSize(tileCoord[0]), this.tmpSize_); const tileSize = toSize(this.getTileSize(tileCoord[0]), this.tmpSize_);
const minX = origin[0] + tileCoord[1] * tileSize[0] * resolution; const minX = origin[0] + tileCoord[1] * tileSize[0] * resolution;
const minY = origin[1] + tileCoord[2] * tileSize[1] * resolution; const minY = origin[1] - (tileCoord[2] + 1) * tileSize[1] * resolution;
const maxX = minX + tileSize[0] * resolution; const maxX = minX + tileSize[0] * resolution;
const maxY = minY + tileSize[1] * resolution; const maxY = minY + tileSize[1] * resolution;
return createOrUpdate(minX, minY, maxX, maxY, opt_extent); return createOrUpdate(minX, minY, maxX, maxY, opt_extent);
@@ -418,9 +418,9 @@ class TileGrid {
const tileSize = toSize(this.getTileSize(z), this.tmpSize_); const tileSize = toSize(this.getTileSize(z), this.tmpSize_);
const adjustX = reverseIntersectionPolicy ? 0.5 : 0; const adjustX = reverseIntersectionPolicy ? 0.5 : 0;
const adjustY = reverseIntersectionPolicy ? 0 : 0.5; const adjustY = reverseIntersectionPolicy ? 0.5 : 0;
const xFromOrigin = Math.floor((x - origin[0]) / resolution + adjustX); const xFromOrigin = Math.floor((x - origin[0]) / resolution + adjustX);
const yFromOrigin = Math.floor((y - origin[1]) / resolution + adjustY); const yFromOrigin = Math.floor((origin[1] - y) / resolution + adjustY);
let tileCoordX = scale * xFromOrigin / tileSize[0]; let tileCoordX = scale * xFromOrigin / tileSize[0];
let tileCoordY = scale * yFromOrigin / tileSize[1]; let tileCoordY = scale * yFromOrigin / tileSize[1];
@@ -456,9 +456,9 @@ class TileGrid {
const tileSize = toSize(this.getTileSize(z), this.tmpSize_); const tileSize = toSize(this.getTileSize(z), this.tmpSize_);
const adjustX = reverseIntersectionPolicy ? 0.5 : 0; const adjustX = reverseIntersectionPolicy ? 0.5 : 0;
const adjustY = reverseIntersectionPolicy ? 0 : 0.5; const adjustY = reverseIntersectionPolicy ? 0.5 : 0;
const xFromOrigin = Math.floor((x - origin[0]) / resolution + adjustX); const xFromOrigin = Math.floor((x - origin[0]) / resolution + adjustX);
const yFromOrigin = Math.floor((y - origin[1]) / resolution + adjustY); const yFromOrigin = Math.floor((origin[1] - y) / resolution + adjustY);
let tileCoordX = xFromOrigin / tileSize[0]; let tileCoordX = xFromOrigin / tileSize[0];
let tileCoordY = yFromOrigin / tileSize[1]; let tileCoordY = yFromOrigin / tileSize[1];
+3 -4
View File
@@ -31,9 +31,9 @@ import TileGrid from './TileGrid.js';
* `TileMatrixHeight` advertised in the GetCapabilities response of the WMTS, and * `TileMatrixHeight` advertised in the GetCapabilities response of the WMTS, and
* define the grid's extent together with the `origin`. * define the grid's extent together with the `origin`.
* An `extent` can be configured in addition, and will further limit the extent for * An `extent` can be configured in addition, and will further limit the extent for
* which tile requests are made by sources. Note that when the top-left corner of * which tile requests are made by sources. If the bottom-left corner of
* the `extent` is used as `origin` or `origins`, then the `y` value must be * the `extent` is used as `origin` or `origins`, then the `y` value must be
* negative because OpenLayers tile coordinates increase upwards. * negative because OpenLayers tile coordinates use the top left as the origin.
* @property {number|import("../size.js").Size} [tileSize] Tile size. * @property {number|import("../size.js").Size} [tileSize] Tile size.
* @property {Array<import("../size.js").Size>} [tileSizes] Tile sizes. The length of * @property {Array<import("../size.js").Size>} [tileSizes] Tile sizes. The length of
* this array needs to match the length of the `resolutions` array. * this array needs to match the length of the `resolutions` array.
@@ -174,8 +174,7 @@ export function createFromCapabilitiesMatrixSet(matrixSet, opt_extent, opt_matri
resolutions.push(resolution); resolutions.push(resolution);
tileSizes.push(tileWidth == tileHeight ? tileSizes.push(tileWidth == tileHeight ?
tileWidth : [tileWidth, tileHeight]); tileWidth : [tileWidth, tileHeight]);
// top-left origin, so height is negative sizes.push([elt['MatrixWidth'], elt['MatrixHeight']]);
sizes.push([elt['MatrixWidth'], -elt['MatrixHeight']]);
} }
}); });
+2 -5
View File
@@ -29,15 +29,12 @@ export function createFromTemplate(template, tileGrid) {
} else { } else {
return template.replace(zRegEx, tileCoord[0].toString()) return template.replace(zRegEx, tileCoord[0].toString())
.replace(xRegEx, tileCoord[1].toString()) .replace(xRegEx, tileCoord[1].toString())
.replace(yRegEx, function() { .replace(yRegEx, tileCoord[2].toString())
const y = -tileCoord[2] - 1;
return y.toString();
})
.replace(dashYRegEx, function() { .replace(dashYRegEx, function() {
const z = tileCoord[0]; const z = tileCoord[0];
const range = tileGrid.getFullTileRange(z); const range = tileGrid.getFullTileRange(z);
assert(range, 55); // The {-y} placeholder requires a tile grid with extent assert(range, 55); // The {-y} placeholder requires a tile grid with extent
const y = range.getHeight() + tileCoord[2]; const y = range.getHeight() - tileCoord[2] - 1;
return y.toString(); return y.toString();
}); });
} }
@@ -242,9 +242,10 @@ describe('ol.renderer.canvas.VectorTileLayer', function() {
sourceTile.getImage = function() { sourceTile.getImage = function() {
return document.createElement('canvas'); return document.createElement('canvas');
}; };
const tileUrlFunction = function() {};
const tile = new VectorImageTile([0, 0, 0], undefined, undefined, undefined, const tile = new VectorImageTile([0, 0, 0], undefined, undefined, undefined,
undefined, [0, 0, 0], undefined, createXYZ(), createXYZ(), undefined, undefined, undefined, [0, 0, 0], tileUrlFunction, createXYZ(), createXYZ(), {}, undefined,
undefined, undefined, undefined, 0); undefined, VectorTile, undefined, 0);
tile.transition_ = 0; tile.transition_ = 0;
tile.wrappedTileCoord = [0, 0, 0]; tile.wrappedTileCoord = [0, 0, 0];
tile.setState(TileState.LOADED); tile.setState(TileState.LOADED);
+1 -1
View File
@@ -30,7 +30,7 @@ describe('ol.reproj.Tile', function() {
return new ReprojTile( return new ReprojTile(
proj3857, createForProjection(proj3857), proj4326, proj3857, createForProjection(proj3857), proj4326,
createForProjection(proj4326, 3, opt_tileSize), createForProjection(proj4326, 3, opt_tileSize),
[3, 2, -2], null, pixelRatio, 0, function(z, x, y, pixelRatio) { [3, 2, 1], null, pixelRatio, 0, function(z, x, y, pixelRatio) {
return new ImageTile([z, x, y], 0, // IDLE return new ImageTile([z, x, y], 0, // IDLE
'data:image/gif;base64,' + 'data:image/gif;base64,' +
'R0lGODlhAQABAIAAAP///wAAACwAAAAAAQABAAACAkQBADs=', null, 'R0lGODlhAQABAIAAAP///wAAACwAAAAAAQABAAACAkQBADs=', null,
+9 -2
View File
@@ -1,10 +1,17 @@
import BingMaps from '../../../../src/ol/source/BingMaps.js'; import BingMaps, {quadKey} from '../../../../src/ol/source/BingMaps.js';
import {quadKey} from '../../../../src/ol/tilecoord.js';
import {unByKey} from '../../../../src/ol/Observable.js'; import {unByKey} from '../../../../src/ol/Observable.js';
describe('ol.source.BingMaps', function() { describe('ol.source.BingMaps', function() {
describe('quadKey()', function() {
it('returns expected string', function() {
const tileCoord = [3, 3, 5];
const s = quadKey(tileCoord);
expect(s).to.eql('213');
});
});
describe('#tileUrlFunction()', function() { describe('#tileUrlFunction()', function() {
let source, tileGrid; let source, tileGrid;
+12 -12
View File
@@ -227,14 +227,14 @@ describe('ol.source.Tile', function() {
wrapX: true wrapX: true
}); });
let tileCoord = tileSource.getTileCoordForTileUrlFunction([6, -31, -23]); let tileCoord = tileSource.getTileCoordForTileUrlFunction([6, -31, 22]);
expect(tileCoord).to.eql([6, 33, -23]); expect(tileCoord).to.eql([6, 33, 22]);
tileCoord = tileSource.getTileCoordForTileUrlFunction([6, 33, -23]); tileCoord = tileSource.getTileCoordForTileUrlFunction([6, 33, 22]);
expect(tileCoord).to.eql([6, 33, -23]); expect(tileCoord).to.eql([6, 33, 22]);
tileCoord = tileSource.getTileCoordForTileUrlFunction([6, 97, -23]); tileCoord = tileSource.getTileCoordForTileUrlFunction([6, 97, 22]);
expect(tileCoord).to.eql([6, 33, -23]); expect(tileCoord).to.eql([6, 33, 22]);
}); });
it('returns the expected tile coordinate - {wrapX: false}', function() { it('returns the expected tile coordinate - {wrapX: false}', function() {
@@ -243,13 +243,13 @@ describe('ol.source.Tile', function() {
wrapX: false wrapX: false
}); });
let tileCoord = tileSource.getTileCoordForTileUrlFunction([6, -31, -23]); let tileCoord = tileSource.getTileCoordForTileUrlFunction([6, -31, 22]);
expect(tileCoord).to.eql(null); expect(tileCoord).to.eql(null);
tileCoord = tileSource.getTileCoordForTileUrlFunction([6, 33, -23]); tileCoord = tileSource.getTileCoordForTileUrlFunction([6, 33, 22]);
expect(tileCoord).to.eql([6, 33, -23]); expect(tileCoord).to.eql([6, 33, 22]);
tileCoord = tileSource.getTileCoordForTileUrlFunction([6, 97, -23]); tileCoord = tileSource.getTileCoordForTileUrlFunction([6, 97, 22]);
expect(tileCoord).to.eql(null); expect(tileCoord).to.eql(null);
}); });
@@ -263,8 +263,8 @@ describe('ol.source.Tile', function() {
wrapX: true wrapX: true
}); });
const tileCoord = tileSource.getTileCoordForTileUrlFunction([6, -31, -23]); const tileCoord = tileSource.getTileCoordForTileUrlFunction([6, -31, 22]);
expect(tileCoord).to.eql([6, 33, -23]); expect(tileCoord).to.eql([6, 33, 22]);
}); });
}); });
+9 -9
View File
@@ -17,7 +17,7 @@ describe('ol.source.TileArcGISRest', function() {
it('returns a tile with the expected URL', function() { it('returns a tile with the expected URL', function() {
const source = new TileArcGISRest(options); const source = new TileArcGISRest(options);
const tile = source.getTile(3, 2, -7, 1, getProjection('EPSG:3857')); const tile = source.getTile(3, 2, 6, 1, getProjection('EPSG:3857'));
expect(tile).to.be.an(ImageTile); expect(tile).to.be.an(ImageTile);
const uri = new URL(tile.src_); const uri = new URL(tile.src_);
expect(uri.protocol).to.be('http:'); expect(uri.protocol).to.be('http:');
@@ -39,7 +39,7 @@ describe('ol.source.TileArcGISRest', function() {
it('returns a non floating point DPI value', function() { it('returns a non floating point DPI value', function() {
const source = new TileArcGISRest(options); const source = new TileArcGISRest(options);
const tile = source.getTile(3, 2, -7, 1.12, getProjection('EPSG:3857')); const tile = source.getTile(3, 2, 6, 1.12, getProjection('EPSG:3857'));
const uri = new URL(tile.src_); const uri = new URL(tile.src_);
const queryData = uri.searchParams; const queryData = uri.searchParams;
expect(queryData.get('DPI')).to.be('101'); expect(queryData.get('DPI')).to.be('101');
@@ -48,7 +48,7 @@ describe('ol.source.TileArcGISRest', function() {
it('takes DPI from params if specified', function() { it('takes DPI from params if specified', function() {
options.params.DPI = 96; options.params.DPI = 96;
const source = new TileArcGISRest(options); const source = new TileArcGISRest(options);
const tile = source.getTile(3, 2, -7, 1.12, getProjection('EPSG:3857')); const tile = source.getTile(3, 2, 6, 1.12, getProjection('EPSG:3857'));
const uri = new URL(tile.src_); const uri = new URL(tile.src_);
const queryData = uri.searchParams; const queryData = uri.searchParams;
expect(queryData.get('DPI')).to.be('108'); expect(queryData.get('DPI')).to.be('108');
@@ -60,7 +60,7 @@ describe('ol.source.TileArcGISRest', function() {
options.urls = ['http://test1.com/MapServer', 'http://test2.com/MapServer']; options.urls = ['http://test1.com/MapServer', 'http://test2.com/MapServer'];
const source = new TileArcGISRest(options); const source = new TileArcGISRest(options);
const tile = source.getTile(3, 2, -7, 1, getProjection('EPSG:3857')); const tile = source.getTile(3, 2, 6, 1, getProjection('EPSG:3857'));
expect(tile).to.be.an(ImageTile); expect(tile).to.be.an(ImageTile);
const uri = new URL(tile.src_); const uri = new URL(tile.src_);
expect(uri.protocol).to.be('http:'); expect(uri.protocol).to.be('http:');
@@ -83,7 +83,7 @@ describe('ol.source.TileArcGISRest', function() {
it('returns a tile with the expected URL for ImageServer', function() { it('returns a tile with the expected URL for ImageServer', function() {
options.url = 'http://example.com/ImageServer'; options.url = 'http://example.com/ImageServer';
const source = new TileArcGISRest(options); const source = new TileArcGISRest(options);
const tile = source.getTile(3, 2, -7, 1, getProjection('EPSG:3857')); const tile = source.getTile(3, 2, 6, 1, getProjection('EPSG:3857'));
expect(tile).to.be.an(ImageTile); expect(tile).to.be.an(ImageTile);
const uri = new URL(tile.src_); const uri = new URL(tile.src_);
expect(uri.protocol).to.be('http:'); expect(uri.protocol).to.be('http:');
@@ -106,7 +106,7 @@ describe('ol.source.TileArcGISRest', function() {
options.params.FORMAT = 'png'; options.params.FORMAT = 'png';
options.params.TRANSPARENT = false; options.params.TRANSPARENT = false;
const source = new TileArcGISRest(options); const source = new TileArcGISRest(options);
const tile = source.getTile(3, 2, -3, 1, getProjection('EPSG:4326')); const tile = source.getTile(3, 2, 2, 1, getProjection('EPSG:4326'));
const uri = new URL(tile.src_); const uri = new URL(tile.src_);
const queryData = uri.searchParams; const queryData = uri.searchParams;
expect(queryData.get('FORMAT')).to.be('png'); expect(queryData.get('FORMAT')).to.be('png');
@@ -116,7 +116,7 @@ describe('ol.source.TileArcGISRest', function() {
it('allows adding rest option', function() { it('allows adding rest option', function() {
options.params.LAYERS = 'show:1,3,4'; options.params.LAYERS = 'show:1,3,4';
const source = new TileArcGISRest(options); const source = new TileArcGISRest(options);
const tile = source.getTile(3, 2, -3, 1, getProjection('EPSG:4326')); const tile = source.getTile(3, 2, 2, 1, getProjection('EPSG:4326'));
const uri = new URL(tile.src_); const uri = new URL(tile.src_);
const queryData = uri.searchParams; const queryData = uri.searchParams;
expect(queryData.get('LAYERS')).to.be('show:1,3,4'); expect(queryData.get('LAYERS')).to.be('show:1,3,4');
@@ -129,7 +129,7 @@ describe('ol.source.TileArcGISRest', function() {
const source = new TileArcGISRest(options); const source = new TileArcGISRest(options);
source.updateParams({'TEST': 'value'}); source.updateParams({'TEST': 'value'});
const tile = source.getTile(3, 2, -7, 1, getProjection('EPSG:3857')); const tile = source.getTile(3, 2, 6, 1, getProjection('EPSG:3857'));
const uri = new URL(tile.src_); const uri = new URL(tile.src_);
const queryData = uri.searchParams; const queryData = uri.searchParams;
expect(queryData.get('TEST')).to.be('value'); expect(queryData.get('TEST')).to.be('value');
@@ -141,7 +141,7 @@ describe('ol.source.TileArcGISRest', function() {
const source = new TileArcGISRest(options); const source = new TileArcGISRest(options);
source.updateParams({'TEST': 'newValue'}); source.updateParams({'TEST': 'newValue'});
const tile = source.getTile(3, 2, -7, 1, getProjection('EPSG:3857')); const tile = source.getTile(3, 2, 6, 1, getProjection('EPSG:3857'));
const uri = new URL(tile.src_); const uri = new URL(tile.src_);
const queryData = uri.searchParams; const queryData = uri.searchParams;
expect(queryData.get('TEST')).to.be('newValue'); expect(queryData.get('TEST')).to.be('newValue');
+14 -19
View File
@@ -49,14 +49,13 @@ describe('ol.source.TileImage', function() {
beforeEach(function() { beforeEach(function() {
source = createSource(); source = createSource();
expect(source.getKey()).to.be(''); expect(source.getKey()).to.be('');
source.getTileInternal(0, 0, -1, 1, getProjection('EPSG:3857')); source.getTileInternal(0, 0, 0, 1, getProjection('EPSG:3857'));
expect(source.tileCache.getCount()).to.be(1); expect(source.tileCache.getCount()).to.be(1);
tile = source.tileCache.get(getKeyZXY(0, 0, -1)); tile = source.tileCache.get(getKeyZXY(0, 0, 0));
}); });
it('gets the tile from the cache', function() { it('gets the tile from the cache', function() {
const returnedTile = source.getTileInternal( const returnedTile = source.getTileInternal(0, 0, 0, 1, getProjection('EPSG:3857'));
0, 0, -1, 1, getProjection('EPSG:3857'));
expect(returnedTile).to.be(tile); expect(returnedTile).to.be(tile);
}); });
@@ -67,8 +66,7 @@ describe('ol.source.TileImage', function() {
source.getKey = function() { source.getKey = function() {
return 'key0'; return 'key0';
}; };
const returnedTile = source.getTileInternal( const returnedTile = source.getTileInternal(0, 0, 0, 1, getProjection('EPSG:3857'));
0, 0, -1, 1, getProjection('EPSG:3857'));
expect(returnedTile).not.to.be(tile); expect(returnedTile).not.to.be(tile);
expect(returnedTile.key).to.be('key0'); expect(returnedTile.key).to.be('key0');
expect(returnedTile.interimTile).to.be(null); expect(returnedTile.interimTile).to.be(null);
@@ -81,8 +79,7 @@ describe('ol.source.TileImage', function() {
return 'key0'; return 'key0';
}; };
tile.state = 2; // LOADED tile.state = 2; // LOADED
const returnedTile = source.getTileInternal( const returnedTile = source.getTileInternal(0, 0, 0, 1, getProjection('EPSG:3857'));
0, 0, -1, 1, getProjection('EPSG:3857'));
expect(returnedTile).not.to.be(tile); expect(returnedTile).not.to.be(tile);
expect(returnedTile.key).to.be('key0'); expect(returnedTile.key).to.be('key0');
expect(returnedTile.interimTile).to.be(tile); expect(returnedTile.interimTile).to.be(tile);
@@ -97,11 +94,9 @@ describe('ol.source.TileImage', function() {
}; };
dynamicParamsKey = 'key0'; dynamicParamsKey = 'key0';
tile.state = 2; // LOADED tile.state = 2; // LOADED
returnedTile = source.getTileInternal( returnedTile = source.getTileInternal(0, 0, 0, 1, getProjection('EPSG:3857'));
0, 0, -1, 1, getProjection('EPSG:3857'));
dynamicParamsKey = 'key1'; dynamicParamsKey = 'key1';
returnedTile = source.getTileInternal( returnedTile = source.getTileInternal(0, 0, 0, 1, getProjection('EPSG:3857'));
0, 0, -1, 1, getProjection('EPSG:3857'));
expect(returnedTile).not.to.be(tile); expect(returnedTile).not.to.be(tile);
expect(returnedTile.key).to.be('key1'); expect(returnedTile.key).to.be('key1');
expect(returnedTile.interimTile).to.be(tile); expect(returnedTile.interimTile).to.be(tile);
@@ -115,7 +110,7 @@ describe('ol.source.TileImage', function() {
describe('#getTile', function() { describe('#getTile', function() {
it('does not do reprojection for identity', function() { it('does not do reprojection for identity', function() {
const source3857 = createSource('EPSG:3857'); const source3857 = createSource('EPSG:3857');
const tile3857 = source3857.getTile(0, 0, -1, 1, getProjection('EPSG:3857')); const tile3857 = source3857.getTile(0, 0, 0, 1, getProjection('EPSG:3857'));
expect(tile3857).to.be.a(ImageTile); expect(tile3857).to.be.a(ImageTile);
expect(tile3857).not.to.be.a(ReprojTile); expect(tile3857).not.to.be.a(ReprojTile);
@@ -124,7 +119,7 @@ describe('ol.source.TileImage', function() {
units: 'degrees' units: 'degrees'
}); });
const sourceXXX = createSource(projXXX); const sourceXXX = createSource(projXXX);
const tileXXX = sourceXXX.getTile(0, 0, -1, 1, projXXX); const tileXXX = sourceXXX.getTile(0, 0, 0, 1, projXXX);
expect(tileXXX).to.be.a(ImageTile); expect(tileXXX).to.be.a(ImageTile);
expect(tileXXX).not.to.be.a(ReprojTile); expect(tileXXX).not.to.be.a(ReprojTile);
}); });
@@ -145,7 +140,7 @@ describe('ol.source.TileImage', function() {
extent: [-180, -90, 180, 90], extent: [-180, -90, 180, 90],
tileSize: [2, 2] tileSize: [2, 2]
})); }));
const tile = source.getTile(0, 0, -1, 1, getProjection('EPSG:3857')); const tile = source.getTile(0, 0, 0, 1, getProjection('EPSG:3857'));
expect(tile).to.be.a(ReprojTile); expect(tile).to.be.a(ReprojTile);
listen(tile, 'change', function() { listen(tile, 'change', function() {
@@ -164,7 +159,7 @@ describe('ol.source.TileImage', function() {
extent: WORLD_EXTENT, extent: WORLD_EXTENT,
tileSize: [2, 2] tileSize: [2, 2]
})); }));
const tile = source.getTile(0, 0, -1, 1, proj); const tile = source.getTile(0, 0, 0, 1, proj);
expect(tile).to.be.a(ReprojTile); expect(tile).to.be.a(ReprojTile);
listen(tile, 'change', function() { listen(tile, 'change', function() {
@@ -194,7 +189,7 @@ describe('ol.source.TileImage', function() {
source.on('tileloadstart', startSpy); source.on('tileloadstart', startSpy);
const endSpy = sinon.spy(); const endSpy = sinon.spy();
source.on('tileloadend', endSpy); source.on('tileloadend', endSpy);
const tile = source.getTile(0, 0, -1, 1, getProjection('EPSG:3857')); const tile = source.getTile(0, 0, 0, 1, getProjection('EPSG:3857'));
tile.load(); tile.load();
expect(startSpy.callCount).to.be(1); expect(startSpy.callCount).to.be(1);
expect(endSpy.callCount).to.be(1); expect(endSpy.callCount).to.be(1);
@@ -220,7 +215,7 @@ describe('ol.source.TileImage', function() {
expect(errorSpy.callCount).to.be(1); expect(errorSpy.callCount).to.be(1);
done(); done();
}); });
const tile = source.getTile(0, 0, -1, 1, getProjection('EPSG:3857')); const tile = source.getTile(0, 0, 0, 1, getProjection('EPSG:3857'));
tile.load(); tile.load();
}); });
@@ -230,7 +225,7 @@ describe('ol.source.TileImage', function() {
source.on('tileloadstart', startSpy); source.on('tileloadstart', startSpy);
const endSpy = sinon.spy(); const endSpy = sinon.spy();
source.on('tileloadend', endSpy); source.on('tileloadend', endSpy);
const tile = source.getTile(0, 0, -1, 1, getProjection('EPSG:3857')); const tile = source.getTile(0, 0, 0, 1, getProjection('EPSG:3857'));
tile.load(); tile.load();
tile.dispose(); tile.dispose();
expect(startSpy.callCount).to.be(1); expect(startSpy.callCount).to.be(1);
+8 -2
View File
@@ -58,7 +58,9 @@ describe('ol.source.TileJSON', function() {
tilejson: '2.2.0', tilejson: '2.2.0',
tiles: [ tiles: [
'https://a.tiles.mapbox.com/v3/mapbox.geography-class/{z}/{x}/{y}.png', 'https://a.tiles.mapbox.com/v3/mapbox.geography-class/{z}/{x}/{y}.png',
'https://b.tiles.mapbox.com/v3/mapbox.geography-class/{z}/{x}/{y}.png' 'https://b.tiles.mapbox.com/v3/mapbox.geography-class/{z}/{x}/{y}.png',
'https://c.tiles.mapbox.com/v3/mapbox.geography-class/{z}/{x}/{y}.png',
'https://d.tiles.mapbox.com/v3/mapbox.geography-class/{z}/{x}/{y}.png'
], ],
version: '1.0.0', version: '1.0.0',
webpage: 'https://a.tiles.mapbox.com/v3/mapbox.geography-class/page.html' webpage: 'https://a.tiles.mapbox.com/v3/mapbox.geography-class/page.html'
@@ -67,7 +69,11 @@ describe('ol.source.TileJSON', function() {
tileJSON: tileJSON tileJSON: tileJSON
}); });
expect(source.getState()).to.be('ready'); expect(source.getState()).to.be('ready');
expect(source.getTileUrlFunction()([0, 0, -1])).to.be('https://b.tiles.mapbox.com/v3/mapbox.geography-class/0/0/0.png'); expect(source.getTileUrlFunction()([0, 0, 0])).to.be('https://a.tiles.mapbox.com/v3/mapbox.geography-class/0/0/0.png');
expect(source.getTileUrlFunction()([1, 0, 0])).to.be('https://a.tiles.mapbox.com/v3/mapbox.geography-class/1/0/0.png');
expect(source.getTileUrlFunction()([1, 0, 1])).to.be('https://b.tiles.mapbox.com/v3/mapbox.geography-class/1/0/1.png');
expect(source.getTileUrlFunction()([1, 1, 0])).to.be('https://c.tiles.mapbox.com/v3/mapbox.geography-class/1/1/0.png');
expect(source.getTileUrlFunction()([1, 1, 1])).to.be('https://d.tiles.mapbox.com/v3/mapbox.geography-class/1/1/1.png');
}); });
}); });
+13 -13
View File
@@ -38,7 +38,7 @@ describe('ol.source.TileWMS', function() {
it('returns a tile with the expected URL', function() { it('returns a tile with the expected URL', function() {
const source = new TileWMS(options); const source = new TileWMS(options);
const tile = source.getTile(3, 2, -7, 1, getProjection('EPSG:3857')); const tile = source.getTile(3, 2, 6, 1, getProjection('EPSG:3857'));
expect(tile).to.be.an(ImageTile); expect(tile).to.be.an(ImageTile);
const uri = new URL(tile.src_); const uri = new URL(tile.src_);
expect(uri.protocol).to.be('http:'); expect(uri.protocol).to.be('http:');
@@ -67,7 +67,7 @@ describe('ol.source.TileWMS', function() {
it('returns a larger tile when a gutter is specified', function() { it('returns a larger tile when a gutter is specified', function() {
options.gutter = 16; options.gutter = 16;
const source = new TileWMS(options); const source = new TileWMS(options);
const tile = source.getTile(3, 2, -7, 1, getProjection('EPSG:3857')); const tile = source.getTile(3, 2, 6, 1, getProjection('EPSG:3857'));
expect(tile).to.be.an(ImageTile); expect(tile).to.be.an(ImageTile);
const uri = new URL(tile.src_); const uri = new URL(tile.src_);
const queryData = uri.searchParams; const queryData = uri.searchParams;
@@ -84,7 +84,7 @@ describe('ol.source.TileWMS', function() {
it('sets the SRS query value instead of CRS if version < 1.3', function() { it('sets the SRS query value instead of CRS if version < 1.3', function() {
options.params.VERSION = '1.2'; options.params.VERSION = '1.2';
const source = new TileWMS(options); const source = new TileWMS(options);
const tile = source.getTile(3, 2, -3, 1, getProjection('EPSG:4326')); const tile = source.getTile(3, 2, 2, 1, getProjection('EPSG:4326'));
const uri = new URL(tile.src_); const uri = new URL(tile.src_);
const queryData = uri.searchParams; const queryData = uri.searchParams;
expect(queryData.get('CRS')).to.be(null); expect(queryData.get('CRS')).to.be(null);
@@ -95,7 +95,7 @@ describe('ol.source.TileWMS', function() {
options.params.FORMAT = 'image/jpeg'; options.params.FORMAT = 'image/jpeg';
options.params.TRANSPARENT = false; options.params.TRANSPARENT = false;
const source = new TileWMS(options); const source = new TileWMS(options);
const tile = source.getTile(3, 2, -3, 1, getProjection('EPSG:4326')); const tile = source.getTile(3, 2, 2, 1, getProjection('EPSG:4326'));
const uri = new URL(tile.src_); const uri = new URL(tile.src_);
const queryData = uri.searchParams; const queryData = uri.searchParams;
expect(queryData.get('FORMAT')).to.be('image/jpeg'); expect(queryData.get('FORMAT')).to.be('image/jpeg');
@@ -105,7 +105,7 @@ describe('ol.source.TileWMS', function() {
it('does not add a STYLES= option if one is specified', function() { it('does not add a STYLES= option if one is specified', function() {
options.params.STYLES = 'foo'; options.params.STYLES = 'foo';
const source = new TileWMS(options); const source = new TileWMS(options);
const tile = source.getTile(3, 2, -3, 1, getProjection('EPSG:4326')); const tile = source.getTile(3, 2, 2, 1, getProjection('EPSG:4326'));
const uri = new URL(tile.src_); const uri = new URL(tile.src_);
const queryData = uri.searchParams; const queryData = uri.searchParams;
expect(queryData.get('STYLES')).to.be('foo'); expect(queryData.get('STYLES')).to.be('foo');
@@ -113,7 +113,7 @@ describe('ol.source.TileWMS', function() {
it('changes the BBOX order for EN axis orientations', function() { it('changes the BBOX order for EN axis orientations', function() {
const source = new TileWMS(options); const source = new TileWMS(options);
const tile = source.getTile(3, 2, -3, 1, getProjection('EPSG:4326')); const tile = source.getTile(3, 2, 2, 1, getProjection('EPSG:4326'));
const uri = new URL(tile.src_); const uri = new URL(tile.src_);
const queryData = uri.searchParams; const queryData = uri.searchParams;
expect(queryData.get('BBOX')).to.be('-45,-90,0,-45'); expect(queryData.get('BBOX')).to.be('-45,-90,0,-45');
@@ -122,7 +122,7 @@ describe('ol.source.TileWMS', function() {
it('uses EN BBOX order if version < 1.3', function() { it('uses EN BBOX order if version < 1.3', function() {
options.params.VERSION = '1.1.0'; options.params.VERSION = '1.1.0';
const source = new TileWMS(options); const source = new TileWMS(options);
const tile = source.getTile(3, 2, -3, 1, getProjection('CRS:84')); const tile = source.getTile(3, 2, 2, 1, getProjection('CRS:84'));
const uri = new URL(tile.src_); const uri = new URL(tile.src_);
const queryData = uri.searchParams; const queryData = uri.searchParams;
expect(queryData.get('BBOX')).to.be('-90,-45,-45,0'); expect(queryData.get('BBOX')).to.be('-90,-45,-45,0');
@@ -131,7 +131,7 @@ describe('ol.source.TileWMS', function() {
it('sets FORMAT_OPTIONS when the server is GeoServer', function() { it('sets FORMAT_OPTIONS when the server is GeoServer', function() {
options.serverType = 'geoserver'; options.serverType = 'geoserver';
const source = new TileWMS(options); const source = new TileWMS(options);
const tile = source.getTile(3, 2, -3, 2, getProjection('CRS:84')); const tile = source.getTile(3, 2, 2, 2, getProjection('CRS:84'));
const uri = new URL(tile.src_); const uri = new URL(tile.src_);
const queryData = uri.searchParams; const queryData = uri.searchParams;
expect(queryData.get('FORMAT_OPTIONS')).to.be('dpi:180'); expect(queryData.get('FORMAT_OPTIONS')).to.be('dpi:180');
@@ -141,7 +141,7 @@ describe('ol.source.TileWMS', function() {
options.serverType = 'geoserver'; options.serverType = 'geoserver';
const source = new TileWMS(options); const source = new TileWMS(options);
options.params.FORMAT_OPTIONS = 'param1:value1'; options.params.FORMAT_OPTIONS = 'param1:value1';
const tile = source.getTile(3, 2, -3, 2, getProjection('CRS:84')); const tile = source.getTile(3, 2, 2, 2, getProjection('CRS:84'));
const uri = new URL(tile.src_); const uri = new URL(tile.src_);
const queryData = uri.searchParams; const queryData = uri.searchParams;
expect(queryData.get('FORMAT_OPTIONS')).to.be('param1:value1;dpi:180'); expect(queryData.get('FORMAT_OPTIONS')).to.be('param1:value1;dpi:180');
@@ -151,7 +151,7 @@ describe('ol.source.TileWMS', function() {
function() { function() {
options.serverType = 'geoserver'; options.serverType = 'geoserver';
const source = new TileWMS(options); const source = new TileWMS(options);
const tile = source.getTile(3, 2, -3, 1.325, getProjection('CRS:84')); const tile = source.getTile(3, 2, 2, 1.325, getProjection('CRS:84'));
const uri = new URL(tile.src_); const uri = new URL(tile.src_);
const queryData = uri.searchParams; const queryData = uri.searchParams;
expect(queryData.get('FORMAT_OPTIONS')).to.be('dpi:119'); expect(queryData.get('FORMAT_OPTIONS')).to.be('dpi:119');
@@ -164,7 +164,7 @@ describe('ol.source.TileWMS', function() {
it('returns a tile if it is contained within layers extent', function() { it('returns a tile if it is contained within layers extent', function() {
options.extent = [-80, -40, -50, -10]; options.extent = [-80, -40, -50, -10];
const source = new TileWMS(options); const source = new TileWMS(options);
const tileCoord = [3, 2, -3]; const tileCoord = [3, 2, 2];
const url = source.tileUrlFunction(tileCoord, 1, getProjection('EPSG:4326')); const url = source.tileUrlFunction(tileCoord, 1, getProjection('EPSG:4326'));
const uri = new URL(url); const uri = new URL(url);
const queryData = uri.searchParams; const queryData = uri.searchParams;
@@ -174,7 +174,7 @@ describe('ol.source.TileWMS', function() {
it('returns a tile if it intersects layers extent', function() { it('returns a tile if it intersects layers extent', function() {
options.extent = [-80, -40, -40, -10]; options.extent = [-80, -40, -40, -10];
const source = new TileWMS(options); const source = new TileWMS(options);
const tileCoord = [3, 3, -3]; const tileCoord = [3, 3, 2];
const url = source.tileUrlFunction(tileCoord, 1, getProjection('EPSG:4326')); const url = source.tileUrlFunction(tileCoord, 1, getProjection('EPSG:4326'));
const uri = new URL(url); const uri = new URL(url);
const queryData = uri.searchParams; const queryData = uri.searchParams;
@@ -188,7 +188,7 @@ describe('ol.source.TileWMS', function() {
origin: [-180, -90] origin: [-180, -90]
}); });
const source = new TileWMS(options); const source = new TileWMS(options);
const tileCoord = [3, 3, -3]; const tileCoord = [3, 3, 2];
const url = source.tileUrlFunction(tileCoord, 1, getProjection('EPSG:4326')); const url = source.tileUrlFunction(tileCoord, 1, getProjection('EPSG:4326'));
const uri = new URL(url); const uri = new URL(url);
const queryData = uri.searchParams; const queryData = uri.searchParams;
+6 -12
View File
@@ -118,18 +118,15 @@ describe('ol.source.UrlTile', function() {
it('returns the expected URL', function() { it('returns the expected URL', function() {
const projection = tileSource.getProjection(); const projection = tileSource.getProjection();
let tileUrl = tileSource.tileUrlFunction( let tileUrl = tileSource.tileUrlFunction(
tileSource.getTileCoordForTileUrlFunction( tileSource.getTileCoordForTileUrlFunction([6, -31, 22], projection));
[6, -31, -23], projection));
expect(tileUrl).to.eql('6/33/22'); expect(tileUrl).to.eql('6/33/22');
tileUrl = tileSource.tileUrlFunction( tileUrl = tileSource.tileUrlFunction(
tileSource.getTileCoordForTileUrlFunction( tileSource.getTileCoordForTileUrlFunction([6, 33, 22], projection));
[6, 33, -23], projection));
expect(tileUrl).to.eql('6/33/22'); expect(tileUrl).to.eql('6/33/22');
tileUrl = tileSource.tileUrlFunction( tileUrl = tileSource.tileUrlFunction(
tileSource.getTileCoordForTileUrlFunction( tileSource.getTileCoordForTileUrlFunction([6, 97, 22], projection));
[6, 97, -23], projection));
expect(tileUrl).to.eql('6/33/22'); expect(tileUrl).to.eql('6/33/22');
}); });
@@ -140,18 +137,15 @@ describe('ol.source.UrlTile', function() {
it('returns the expected URL', function() { it('returns the expected URL', function() {
const projection = tileSource.getProjection(); const projection = tileSource.getProjection();
let tileUrl = tileSource.tileUrlFunction( let tileUrl = tileSource.tileUrlFunction(
tileSource.getTileCoordForTileUrlFunction( tileSource.getTileCoordForTileUrlFunction([6, 33, -1], projection));
[6, 33, 0], projection));
expect(tileUrl).to.be(undefined); expect(tileUrl).to.be(undefined);
tileUrl = tileSource.tileUrlFunction( tileUrl = tileSource.tileUrlFunction(
tileSource.getTileCoordForTileUrlFunction( tileSource.getTileCoordForTileUrlFunction([6, 33, 22], projection));
[6, 33, -23], projection));
expect(tileUrl).to.eql('6/33/22'); expect(tileUrl).to.eql('6/33/22');
tileUrl = tileSource.tileUrlFunction( tileUrl = tileSource.tileUrlFunction(
tileSource.getTileCoordForTileUrlFunction( tileSource.getTileCoordForTileUrlFunction([6, 33, 64], projection));
[6, 33, -65], projection));
expect(tileUrl).to.be(undefined); expect(tileUrl).to.be(undefined);
}); });
+2 -2
View File
@@ -222,9 +222,9 @@ describe('ol.source.UTFGrid', function() {
// Override getTile method to not depend on the external service. The // Override getTile method to not depend on the external service. The
// signature of the method is kept the same, but the returned tile will // signature of the method is kept the same, but the returned tile will
// always be for [1, 1 -1]. // always be for [1, 1, 0].
source.getTile = function(z, x, y, pixelRatio, projection) { source.getTile = function(z, x, y, pixelRatio, projection) {
const tileCoord = [1, 1, -1]; // overwritten to match our stored JSON const tileCoord = [1, 1, 0]; // overwritten to match our stored JSON
const urlTileCoord = const urlTileCoord =
this.getTileCoordForTileUrlFunction(tileCoord, projection); this.getTileCoordForTileUrlFunction(tileCoord, projection);
const tileUrl = this.tileUrlFunction_(urlTileCoord, pixelRatio, projection); const tileUrl = this.tileUrlFunction_(urlTileCoord, pixelRatio, projection);
+5 -5
View File
@@ -58,7 +58,7 @@ describe('ol.source.VectorTile', function() {
describe('Tile load events', function() { describe('Tile load events', function() {
it('triggers tileloadstart and tileloadend with ol.VectorTile', function(done) { it('triggers tileloadstart and tileloadend with ol.VectorTile', function(done) {
tile = source.getTile(14, 8938, -5681, 1, getProjection('EPSG:3857')); tile = source.getTile(14, 8938, 5680, 1, getProjection('EPSG:3857'));
let started = false; let started = false;
source.on('tileloadstart', function() { source.on('tileloadstart', function() {
started = true; started = true;
@@ -82,10 +82,10 @@ describe('ol.source.VectorTile', function() {
loaded = []; loaded = [];
requested = 0; requested = 0;
function tileUrlFunction(tileUrl) { function tileUrlFunction(tileCoord) {
++requested; ++requested;
if (tileUrl.toString() == '6,27,55') { if (tileCoord.toString() == '6,27,-57') {
return tileUrl.join('/'); return tileCoord.join('/');
} }
} }
@@ -133,7 +133,7 @@ describe('ol.source.VectorTile', function() {
map.renderSync(); map.renderSync();
setTimeout(function() { setTimeout(function() {
expect(requested).to.be.greaterThan(1); expect(requested).to.be.greaterThan(1);
expect(loaded).to.eql(['6/27/55']); expect(loaded).to.eql(['6/27/-57']);
done(); done();
}, 0); }, 0);
}); });
+4 -4
View File
@@ -198,7 +198,7 @@ describe('ol.source.WMTS', function() {
const projection = getProjection('EPSG:3857'); const projection = getProjection('EPSG:3857');
const url = source.tileUrlFunction( const url = source.tileUrlFunction(
source.getTileCoordForTileUrlFunction([1, 1, -2]), 1, projection); source.getTileCoordForTileUrlFunction([1, 1, 1]), 1, projection);
expect(url).to.be.eql('http://host/layer/default/EPSG:3857/1/1/1.jpg'); expect(url).to.be.eql('http://host/layer/default/EPSG:3857/1/1/1.jpg');
}); });
@@ -215,7 +215,7 @@ describe('ol.source.WMTS', function() {
const projection = getProjection('EPSG:3857'); const projection = getProjection('EPSG:3857');
const url = source.tileUrlFunction( const url = source.tileUrlFunction(
source.getTileCoordForTileUrlFunction([1, 1, -2]), 1, projection); source.getTileCoordForTileUrlFunction([1, 1, 1]), 1, projection);
expect(url).to.be.eql('http://host/layer/default/EPSG:3857/1/1/1.jpg'); expect(url).to.be.eql('http://host/layer/default/EPSG:3857/1/1/1.jpg');
}); });
@@ -233,7 +233,7 @@ describe('ol.source.WMTS', function() {
const projection = getProjection('EPSG:3857'); const projection = getProjection('EPSG:3857');
const url = source.tileUrlFunction( const url = source.tileUrlFunction(
source.getTileCoordForTileUrlFunction([1, 1, -2]), 1, projection); source.getTileCoordForTileUrlFunction([1, 1, 1]), 1, projection);
expect(url).to.be.eql('http://host/layer/default/42/EPSG:3857/1/1/1.jpg'); expect(url).to.be.eql('http://host/layer/default/42/EPSG:3857/1/1/1.jpg');
}); });
}); });
@@ -334,7 +334,7 @@ describe('ol.source.WMTS', function() {
'https://b.example.com/{TileMatrix}/{TileRow}/{TileCol}.jpg' 'https://b.example.com/{TileMatrix}/{TileRow}/{TileCol}.jpg'
]; ];
source.setUrls(urls); source.setUrls(urls);
const tileUrl1 = source.tileUrlFunction([2, 9, 4], 1, projection); const tileUrl1 = source.tileUrlFunction([2, 9, -5], 1, projection);
expect(tileUrl1).to.match(/https\:\/\/[ab]\.example\.com\/2\/-5\/9\.jpg/); expect(tileUrl1).to.match(/https\:\/\/[ab]\.example\.com\/2\/-5\/9\.jpg/);
}); });
}); });
+6 -12
View File
@@ -93,18 +93,15 @@ describe('ol.source.XYZ', function() {
it('returns the expected URL', function() { it('returns the expected URL', function() {
const projection = xyzTileSource.getProjection(); const projection = xyzTileSource.getProjection();
let tileUrl = xyzTileSource.tileUrlFunction( let tileUrl = xyzTileSource.tileUrlFunction(
xyzTileSource.getTileCoordForTileUrlFunction( xyzTileSource.getTileCoordForTileUrlFunction([6, -31, 22], projection));
[6, -31, -23], projection));
expect(tileUrl).to.eql('6/33/22'); expect(tileUrl).to.eql('6/33/22');
tileUrl = xyzTileSource.tileUrlFunction( tileUrl = xyzTileSource.tileUrlFunction(
xyzTileSource.getTileCoordForTileUrlFunction( xyzTileSource.getTileCoordForTileUrlFunction([6, 33, 22], projection));
[6, 33, -23], projection));
expect(tileUrl).to.eql('6/33/22'); expect(tileUrl).to.eql('6/33/22');
tileUrl = xyzTileSource.tileUrlFunction( tileUrl = xyzTileSource.tileUrlFunction(
xyzTileSource.getTileCoordForTileUrlFunction( xyzTileSource.getTileCoordForTileUrlFunction([6, 97, 22], projection));
[6, 97, -23], projection));
expect(tileUrl).to.eql('6/33/22'); expect(tileUrl).to.eql('6/33/22');
}); });
@@ -115,18 +112,15 @@ describe('ol.source.XYZ', function() {
it('returns the expected URL', function() { it('returns the expected URL', function() {
const projection = xyzTileSource.getProjection(); const projection = xyzTileSource.getProjection();
let tileUrl = xyzTileSource.tileUrlFunction( let tileUrl = xyzTileSource.tileUrlFunction(
xyzTileSource.getTileCoordForTileUrlFunction( xyzTileSource.getTileCoordForTileUrlFunction([6, 33, -1], projection));
[6, 33, 0], projection));
expect(tileUrl).to.be(undefined); expect(tileUrl).to.be(undefined);
tileUrl = xyzTileSource.tileUrlFunction( tileUrl = xyzTileSource.tileUrlFunction(
xyzTileSource.getTileCoordForTileUrlFunction( xyzTileSource.getTileCoordForTileUrlFunction([6, 33, 22], projection));
[6, 33, -23], projection));
expect(tileUrl).to.eql('6/33/22'); expect(tileUrl).to.eql('6/33/22');
tileUrl = xyzTileSource.tileUrlFunction( tileUrl = xyzTileSource.tileUrlFunction(
xyzTileSource.getTileCoordForTileUrlFunction( xyzTileSource.getTileCoordForTileUrlFunction([6, 33, 64], projection));
[6, 33, -65], projection));
expect(tileUrl).to.be(undefined); expect(tileUrl).to.be(undefined);
}); });
+20 -20
View File
@@ -234,23 +234,23 @@ describe('ol.source.Zoomify', function() {
const source = getZoomifySource(); const source = getZoomifySource();
const tileUrlFunction = source.getTileUrlFunction(); const tileUrlFunction = source.getTileUrlFunction();
// zoomlevel 0 // zoomlevel 0
expect(tileUrlFunction([0, 0, -1])).to.eql('spec/ol/source/images/zoomify/TileGroup0/0-0-0.jpg'); expect(tileUrlFunction([0, 0, 0])).to.eql('spec/ol/source/images/zoomify/TileGroup0/0-0-0.jpg');
// zoomlevel 1 // zoomlevel 1
expect(tileUrlFunction([1, 0, -1])).to.eql('spec/ol/source/images/zoomify/TileGroup0/1-0-0.jpg'); expect(tileUrlFunction([1, 0, 0])).to.eql('spec/ol/source/images/zoomify/TileGroup0/1-0-0.jpg');
expect(tileUrlFunction([1, 1, -1])).to.eql('spec/ol/source/images/zoomify/TileGroup0/1-1-0.jpg'); expect(tileUrlFunction([1, 1, 0])).to.eql('spec/ol/source/images/zoomify/TileGroup0/1-1-0.jpg');
expect(tileUrlFunction([1, 0, -2])).to.eql('spec/ol/source/images/zoomify/TileGroup0/1-0-1.jpg'); expect(tileUrlFunction([1, 0, 1])).to.eql('spec/ol/source/images/zoomify/TileGroup0/1-0-1.jpg');
expect(tileUrlFunction([1, 1, -2])).to.eql('spec/ol/source/images/zoomify/TileGroup0/1-1-1.jpg'); expect(tileUrlFunction([1, 1, 1])).to.eql('spec/ol/source/images/zoomify/TileGroup0/1-1-1.jpg');
}); });
it('creates an expected tileUrlFunction with IIP template', function() { it('creates an expected tileUrlFunction with IIP template', function() {
const source = getIIPSource(); const source = getIIPSource();
const tileUrlFunction = source.getTileUrlFunction(); const tileUrlFunction = source.getTileUrlFunction();
// zoomlevel 0 // zoomlevel 0
expect(tileUrlFunction([0, 0, -1])).to.eql('spec/ol/source/images/zoomify?JTL=0,0'); expect(tileUrlFunction([0, 0, 0])).to.eql('spec/ol/source/images/zoomify?JTL=0,0');
// zoomlevel 1 // zoomlevel 1
expect(tileUrlFunction([1, 0, -1])).to.eql('spec/ol/source/images/zoomify?JTL=1,0'); expect(tileUrlFunction([1, 0, 0])).to.eql('spec/ol/source/images/zoomify?JTL=1,0');
expect(tileUrlFunction([1, 1, -1])).to.eql('spec/ol/source/images/zoomify?JTL=1,1'); expect(tileUrlFunction([1, 1, 0])).to.eql('spec/ol/source/images/zoomify?JTL=1,1');
expect(tileUrlFunction([1, 0, -2])).to.eql('spec/ol/source/images/zoomify?JTL=1,2'); expect(tileUrlFunction([1, 0, 1])).to.eql('spec/ol/source/images/zoomify?JTL=1,2');
expect(tileUrlFunction([1, 1, -2])).to.eql('spec/ol/source/images/zoomify?JTL=1,3'); expect(tileUrlFunction([1, 1, 1])).to.eql('spec/ol/source/images/zoomify?JTL=1,3');
}); });
it('creates an expected tileUrlFunction without template', function() { it('creates an expected tileUrlFunction without template', function() {
@@ -260,12 +260,12 @@ describe('ol.source.Zoomify', function() {
}); });
const tileUrlFunction = source.getTileUrlFunction(); const tileUrlFunction = source.getTileUrlFunction();
// zoomlevel 0 // zoomlevel 0
expect(tileUrlFunction([0, 0, -1])).to.eql('spec/ol/source/images/zoomify/TileGroup0/0-0-0.jpg'); expect(tileUrlFunction([0, 0, 0])).to.eql('spec/ol/source/images/zoomify/TileGroup0/0-0-0.jpg');
// zoomlevel 1 // zoomlevel 1
expect(tileUrlFunction([1, 0, -1])).to.eql('spec/ol/source/images/zoomify/TileGroup0/1-0-0.jpg'); expect(tileUrlFunction([1, 0, 0])).to.eql('spec/ol/source/images/zoomify/TileGroup0/1-0-0.jpg');
expect(tileUrlFunction([1, 1, -1])).to.eql('spec/ol/source/images/zoomify/TileGroup0/1-1-0.jpg'); expect(tileUrlFunction([1, 1, 0])).to.eql('spec/ol/source/images/zoomify/TileGroup0/1-1-0.jpg');
expect(tileUrlFunction([1, 0, -2])).to.eql('spec/ol/source/images/zoomify/TileGroup0/1-0-1.jpg'); expect(tileUrlFunction([1, 0, 1])).to.eql('spec/ol/source/images/zoomify/TileGroup0/1-0-1.jpg');
expect(tileUrlFunction([1, 1, -2])).to.eql('spec/ol/source/images/zoomify/TileGroup0/1-1-1.jpg'); expect(tileUrlFunction([1, 1, 1])).to.eql('spec/ol/source/images/zoomify/TileGroup0/1-1-1.jpg');
}); });
it('returns undefined if no tileCoord passed', function() { it('returns undefined if no tileCoord passed', function() {
const source = getZoomifySource(); const source = getZoomifySource();
@@ -279,17 +279,17 @@ describe('ol.source.Zoomify', function() {
it('returns expected tileClass instances via "getTile"', function() { it('returns expected tileClass instances via "getTile"', function() {
const source = getZoomifySource(); const source = getZoomifySource();
const tile = source.getTile(0, 0, -1, 1, proj); const tile = source.getTile(0, 0, 0, 1, proj);
expect(tile).to.be.a(CustomTile); expect(tile).to.be.a(CustomTile);
}); });
it('"tile.getImage" returns and caches an unloaded image', function() { it('"tile.getImage" returns and caches an unloaded image', function() {
const source = getZoomifySource(); const source = getZoomifySource();
const tile = source.getTile(0, 0, -1, 1, proj); const tile = source.getTile(0, 0, 0, 1, proj);
const img = tile.getImage(); const img = tile.getImage();
const tile2 = source.getTile(0, 0, -1, 1, proj); const tile2 = source.getTile(0, 0, 0, 1, proj);
const img2 = tile2.getImage(); const img2 = tile2.getImage();
expect(img).to.be.a(HTMLImageElement); expect(img).to.be.a(HTMLImageElement);
@@ -299,14 +299,14 @@ describe('ol.source.Zoomify', function() {
it('"tile.getImage" returns and caches a loaded canvas', function(done) { it('"tile.getImage" returns and caches a loaded canvas', function(done) {
const source = getZoomifySource(); const source = getZoomifySource();
const tile = source.getTile(0, 0, -1, 1, proj); const tile = source.getTile(0, 0, 0, 1, proj);
listen(tile, 'change', function() { listen(tile, 'change', function() {
if (tile.getState() == 2) { // LOADED if (tile.getState() == 2) { // LOADED
const img = tile.getImage(); const img = tile.getImage();
expect(img).to.be.a(HTMLCanvasElement); expect(img).to.be.a(HTMLCanvasElement);
const tile2 = source.getTile(0, 0, -1, 1, proj); const tile2 = source.getTile(0, 0, 0, 1, proj);
expect(tile2.getState()).to.be(2); // LOADED expect(tile2.getState()).to.be(2); // LOADED
const img2 = tile2.getImage(); const img2 = tile2.getImage();
expect(img).to.be(img2); expect(img).to.be(img2);
+46 -27
View File
@@ -1,5 +1,4 @@
import { import {
quadKey,
getKey, getKey,
fromKey, fromKey,
hash, hash,
@@ -19,14 +18,6 @@ describe('ol.TileCoord', function() {
}); });
}); });
describe('call quadKey', function() {
it('returns expected string', function() {
const tileCoord = [3, 3, 5];
const s = quadKey(tileCoord);
expect(s).to.eql('213');
});
});
describe('getKey()', function() { describe('getKey()', function() {
it('returns a key for a tile coord', function() { it('returns a key for a tile coord', function() {
const key = getKey([1, 2, 3]); const key = getKey([1, 2, 3]);
@@ -62,9 +53,9 @@ describe('ol.TileCoord', function() {
resolutions: [2, 1], resolutions: [2, 1],
minZoom: 1 minZoom: 1
}); });
expect(withinExtentAndZ([0, 0, -1], tileGrid)).to.be(false); expect(withinExtentAndZ([0, 0, 0], tileGrid)).to.be(false);
expect(withinExtentAndZ([1, 0, -1], tileGrid)).to.be(true); expect(withinExtentAndZ([1, 0, 0], tileGrid)).to.be(true);
expect(withinExtentAndZ([2, 0, -1], tileGrid)).to.be(false); expect(withinExtentAndZ([2, 0, 0], tileGrid)).to.be(false);
}); });
it('restricts by extent when extent defines tile ranges', function() { it('restricts by extent when extent defines tile ranges', function() {
@@ -74,9 +65,9 @@ describe('ol.TileCoord', function() {
tileSize: 10, tileSize: 10,
resolutions: [1] resolutions: [1]
}); });
expect(withinExtentAndZ([0, 1, -2], tileGrid)).to.be(true); expect(withinExtentAndZ([0, 1, 1], tileGrid)).to.be(true);
expect(withinExtentAndZ([0, 2, -1], tileGrid)).to.be(false); expect(withinExtentAndZ([0, 2, 0], tileGrid)).to.be(false);
expect(withinExtentAndZ([0, 0, -3], tileGrid)).to.be(false); expect(withinExtentAndZ([0, 0, 2], tileGrid)).to.be(false);
}); });
it('restricts by extent when sizes define tile ranges', function() { it('restricts by extent when sizes define tile ranges', function() {
@@ -87,11 +78,27 @@ describe('ol.TileCoord', function() {
resolutions: [1] resolutions: [1]
}); });
expect(withinExtentAndZ([0, 0, 0], tileGrid)).to.be(true); expect(withinExtentAndZ([0, 0, 0], tileGrid)).to.be(true);
expect(withinExtentAndZ([0, -1, 0], tileGrid)).to.be(false); expect(withinExtentAndZ([0, 1, 0], tileGrid)).to.be(true);
expect(withinExtentAndZ([0, 0, -1], tileGrid)).to.be(false); expect(withinExtentAndZ([0, 2, 0], tileGrid)).to.be(true);
expect(withinExtentAndZ([0, 0, 1], tileGrid)).to.be(true);
expect(withinExtentAndZ([0, 1, 1], tileGrid)).to.be(true);
expect(withinExtentAndZ([0, 2, 1], tileGrid)).to.be(true);
expect(withinExtentAndZ([0, 0, 2], tileGrid)).to.be(true);
expect(withinExtentAndZ([0, 1, 2], tileGrid)).to.be(true);
expect(withinExtentAndZ([0, 2, 2], tileGrid)).to.be(true); expect(withinExtentAndZ([0, 2, 2], tileGrid)).to.be(true);
expect(withinExtentAndZ([0, 0, -1], tileGrid)).to.be(false);
expect(withinExtentAndZ([0, 1, -1], tileGrid)).to.be(false);
expect(withinExtentAndZ([0, 2, -1], tileGrid)).to.be(false);
expect(withinExtentAndZ([0, -1, 0], tileGrid)).to.be(false);
expect(withinExtentAndZ([0, 3, 0], tileGrid)).to.be(false); expect(withinExtentAndZ([0, 3, 0], tileGrid)).to.be(false);
expect(withinExtentAndZ([0, -1, 1], tileGrid)).to.be(false);
expect(withinExtentAndZ([0, 3, 1], tileGrid)).to.be(false);
expect(withinExtentAndZ([0, -1, 2], tileGrid)).to.be(false);
expect(withinExtentAndZ([0, 3, 2], tileGrid)).to.be(false);
expect(withinExtentAndZ([0, 0, 3], tileGrid)).to.be(false); expect(withinExtentAndZ([0, 0, 3], tileGrid)).to.be(false);
expect(withinExtentAndZ([0, 1, 3], tileGrid)).to.be(false);
expect(withinExtentAndZ([0, 2, 3], tileGrid)).to.be(false);
}); });
it('restricts by extent when sizes (neg y) define tile ranges', function() { it('restricts by extent when sizes (neg y) define tile ranges', function() {
@@ -102,11 +109,27 @@ describe('ol.TileCoord', function() {
resolutions: [1] resolutions: [1]
}); });
expect(withinExtentAndZ([0, 0, -1], tileGrid)).to.be(true); expect(withinExtentAndZ([0, 0, -1], tileGrid)).to.be(true);
expect(withinExtentAndZ([0, -1, -1], tileGrid)).to.be(false); expect(withinExtentAndZ([0, 1, -1], tileGrid)).to.be(true);
expect(withinExtentAndZ([0, 0, 0], tileGrid)).to.be(false); expect(withinExtentAndZ([0, 2, -1], tileGrid)).to.be(true);
expect(withinExtentAndZ([0, 0, -2], tileGrid)).to.be(true);
expect(withinExtentAndZ([0, 1, -2], tileGrid)).to.be(true);
expect(withinExtentAndZ([0, 2, -2], tileGrid)).to.be(true);
expect(withinExtentAndZ([0, 0, -3], tileGrid)).to.be(true);
expect(withinExtentAndZ([0, 1, -3], tileGrid)).to.be(true);
expect(withinExtentAndZ([0, 2, -3], tileGrid)).to.be(true); expect(withinExtentAndZ([0, 2, -3], tileGrid)).to.be(true);
expect(withinExtentAndZ([0, 0, 0], tileGrid)).to.be(false);
expect(withinExtentAndZ([0, 1, 0], tileGrid)).to.be(false);
expect(withinExtentAndZ([0, 2, 0], tileGrid)).to.be(false);
expect(withinExtentAndZ([0, -1, -1], tileGrid)).to.be(false);
expect(withinExtentAndZ([0, 3, -1], tileGrid)).to.be(false); expect(withinExtentAndZ([0, 3, -1], tileGrid)).to.be(false);
expect(withinExtentAndZ([0, -1, -2], tileGrid)).to.be(false);
expect(withinExtentAndZ([0, 3, -2], tileGrid)).to.be(false);
expect(withinExtentAndZ([0, -1, -3], tileGrid)).to.be(false);
expect(withinExtentAndZ([0, 3, -3], tileGrid)).to.be(false);
expect(withinExtentAndZ([0, 0, -4], tileGrid)).to.be(false); expect(withinExtentAndZ([0, 0, -4], tileGrid)).to.be(false);
expect(withinExtentAndZ([0, 1, -4], tileGrid)).to.be(false);
expect(withinExtentAndZ([0, 2, -4], tileGrid)).to.be(false);
}); });
it('does not restrict by extent with no extent or sizes', function() { it('does not restrict by extent with no extent or sizes', function() {
@@ -115,14 +138,10 @@ describe('ol.TileCoord', function() {
tileSize: 10, tileSize: 10,
resolutions: [1] resolutions: [1]
}); });
expect(withinExtentAndZ([0, Infinity, 0], tileGrid)) expect(withinExtentAndZ([0, Infinity, -1], tileGrid)).to.be(true);
.to.be(true); expect(withinExtentAndZ([0, 0, Infinity], tileGrid)).to.be(true);
expect(withinExtentAndZ([0, 0, Infinity], tileGrid)) expect(withinExtentAndZ([0, -Infinity, -1], tileGrid)).to.be(true);
.to.be(true); expect(withinExtentAndZ([0, 0, Infinity], tileGrid)).to.be(true);
expect(withinExtentAndZ([0, -Infinity, 0], tileGrid))
.to.be(true);
expect(withinExtentAndZ([0, 0, Infinity], tileGrid))
.to.be(true);
}); });
}); });
+52 -54
View File
@@ -195,8 +195,8 @@ describe('ol.tilegrid.TileGrid', function() {
const fullTileRange = tileGrid.getFullTileRange(0); const fullTileRange = tileGrid.getFullTileRange(0);
expect(fullTileRange.minX).to.equal(0); expect(fullTileRange.minX).to.equal(0);
expect(fullTileRange.maxX).to.equal(1); expect(fullTileRange.maxX).to.equal(1);
expect(fullTileRange.minY).to.equal(-2); expect(fullTileRange.minY).to.equal(0);
expect(fullTileRange.maxY).to.equal(-1); expect(fullTileRange.maxY).to.equal(1);
}); });
}); });
@@ -205,7 +205,7 @@ describe('ol.tilegrid.TileGrid', function() {
beforeEach(function() { beforeEach(function() {
tileGrid = new TileGrid({ tileGrid = new TileGrid({
extent: [10, 20, 30, 40], extent: [10, 20, 30, 40],
sizes: [[3, -3]], sizes: [[3, 3]],
tileSize: 10, tileSize: 10,
resolutions: [1] resolutions: [1]
}); });
@@ -219,8 +219,8 @@ describe('ol.tilegrid.TileGrid', function() {
const fullTileRange = tileGrid.getFullTileRange(0); const fullTileRange = tileGrid.getFullTileRange(0);
expect(fullTileRange.minX).to.equal(0); expect(fullTileRange.minX).to.equal(0);
expect(fullTileRange.maxX).to.equal(2); expect(fullTileRange.maxX).to.equal(2);
expect(fullTileRange.minY).to.equal(-3); expect(fullTileRange.minY).to.equal(0);
expect(fullTileRange.maxY).to.equal(-1); expect(fullTileRange.maxY).to.equal(2);
}); });
}); });
@@ -229,16 +229,16 @@ describe('ol.tilegrid.TileGrid', function() {
beforeEach(function() { beforeEach(function() {
tileGrid = new TileGrid({ tileGrid = new TileGrid({
origin: [10, 40], origin: [10, 40],
sizes: [[3, -3]], sizes: [[3, 3]],
tileSize: 10, tileSize: 10,
resolutions: [1] resolutions: [1]
}); });
}); });
it('calculates correct minY and maxY for negative heights', function() { it('calculates correct minY and maxY for positive heights', function() {
const fullTileRange = tileGrid.getFullTileRange(0); const fullTileRange = tileGrid.getFullTileRange(0);
expect(fullTileRange.minY).to.equal(-3); expect(fullTileRange.minY).to.equal(0);
expect(fullTileRange.maxY).to.equal(-1); expect(fullTileRange.maxY).to.equal(2);
}); });
}); });
@@ -247,16 +247,16 @@ describe('ol.tilegrid.TileGrid', function() {
beforeEach(function() { beforeEach(function() {
tileGrid = new TileGrid({ tileGrid = new TileGrid({
origin: [10, 10], origin: [10, 10],
sizes: [[3, 3]], sizes: [[3, -3]],
tileSize: 10, tileSize: 10,
resolutions: [1] resolutions: [1]
}); });
}); });
it('calculates correct minX and maxX for positive heights', function() { it('calculates correct minX and maxX for negative heights', function() {
const fullTileRange = tileGrid.getFullTileRange(0); const fullTileRange = tileGrid.getFullTileRange(0);
expect(fullTileRange.minY).to.equal(0); expect(fullTileRange.minY).to.equal(-3);
expect(fullTileRange.maxY).to.equal(2); expect(fullTileRange.maxY).to.equal(-1);
}); });
}); });
@@ -602,7 +602,7 @@ describe('ol.tilegrid.TileGrid', function() {
tileCoord = tileGrid.getTileCoordForCoordAndZ([0, 100000], 3); tileCoord = tileGrid.getTileCoordForCoordAndZ([0, 100000], 3);
expect(tileCoord[0]).to.eql(3); expect(tileCoord[0]).to.eql(3);
expect(tileCoord[1]).to.eql(0); expect(tileCoord[1]).to.eql(0);
expect(tileCoord[2]).to.eql(10); expect(tileCoord[2]).to.eql(-10);
tileCoord = tileGrid.getTileCoordForCoordAndZ([100000, 0], 3); tileCoord = tileGrid.getTileCoordForCoordAndZ([100000, 0], 3);
expect(tileCoord[0]).to.eql(3); expect(tileCoord[0]).to.eql(3);
@@ -612,7 +612,7 @@ describe('ol.tilegrid.TileGrid', function() {
tileCoord = tileGrid.getTileCoordForCoordAndZ([100000, 100000], 3); tileCoord = tileGrid.getTileCoordForCoordAndZ([100000, 100000], 3);
expect(tileCoord[0]).to.eql(3); expect(tileCoord[0]).to.eql(3);
expect(tileCoord[1]).to.eql(10); expect(tileCoord[1]).to.eql(10);
expect(tileCoord[2]).to.eql(10); expect(tileCoord[2]).to.eql(-10);
}); });
}); });
@@ -629,7 +629,7 @@ describe('ol.tilegrid.TileGrid', function() {
tileCoord = tileGrid.getTileCoordForCoordAndZ([0, 0], 3); tileCoord = tileGrid.getTileCoordForCoordAndZ([0, 0], 3);
expect(tileCoord[0]).to.eql(3); expect(tileCoord[0]).to.eql(3);
expect(tileCoord[1]).to.eql(0); expect(tileCoord[1]).to.eql(0);
expect(tileCoord[2]).to.eql(-10); expect(tileCoord[2]).to.eql(10);
tileCoord = tileGrid.getTileCoordForCoordAndZ([0, 100000], 3); tileCoord = tileGrid.getTileCoordForCoordAndZ([0, 100000], 3);
expect(tileCoord[0]).to.eql(3); expect(tileCoord[0]).to.eql(3);
@@ -639,7 +639,7 @@ describe('ol.tilegrid.TileGrid', function() {
tileCoord = tileGrid.getTileCoordForCoordAndZ([100000, 0], 3); tileCoord = tileGrid.getTileCoordForCoordAndZ([100000, 0], 3);
expect(tileCoord[0]).to.eql(3); expect(tileCoord[0]).to.eql(3);
expect(tileCoord[1]).to.eql(10); expect(tileCoord[1]).to.eql(10);
expect(tileCoord[2]).to.eql(-10); expect(tileCoord[2]).to.eql(10);
tileCoord = tileGrid.getTileCoordForCoordAndZ([100000, 100000], 3); tileCoord = tileGrid.getTileCoordForCoordAndZ([100000, 100000], 3);
expect(tileCoord[0]).to.eql(3); expect(tileCoord[0]).to.eql(3);
@@ -673,56 +673,56 @@ describe('ol.tilegrid.TileGrid', function() {
tileCoord = tileGrid.getTileCoordForCoordAndResolution(coordinate, 10); tileCoord = tileGrid.getTileCoordForCoordAndResolution(coordinate, 10);
expect(tileCoord[0]).to.eql(0); expect(tileCoord[0]).to.eql(0);
expect(tileCoord[1]).to.eql(-1); expect(tileCoord[1]).to.eql(-1);
expect(tileCoord[2]).to.eql(0); expect(tileCoord[2]).to.eql(-1);
// gets one tile northeast of the origin // gets one tile northeast of the origin
coordinate = [1280, 1280]; coordinate = [1280, 1280];
tileCoord = tileGrid.getTileCoordForCoordAndResolution(coordinate, 10); tileCoord = tileGrid.getTileCoordForCoordAndResolution(coordinate, 10);
expect(tileCoord[0]).to.eql(0); expect(tileCoord[0]).to.eql(0);
expect(tileCoord[1]).to.eql(0); expect(tileCoord[1]).to.eql(0);
expect(tileCoord[2]).to.eql(0); expect(tileCoord[2]).to.eql(-1);
// gets one tile southeast of the origin // gets one tile southeast of the origin
coordinate = [1280, -1280]; coordinate = [1280, -1280];
tileCoord = tileGrid.getTileCoordForCoordAndResolution(coordinate, 10); tileCoord = tileGrid.getTileCoordForCoordAndResolution(coordinate, 10);
expect(tileCoord[0]).to.eql(0); expect(tileCoord[0]).to.eql(0);
expect(tileCoord[1]).to.eql(0); expect(tileCoord[1]).to.eql(0);
expect(tileCoord[2]).to.eql(-1); expect(tileCoord[2]).to.eql(0);
// gets one tile southwest of the origin // gets one tile southwest of the origin
coordinate = [-1280, -1280]; coordinate = [-1280, -1280];
tileCoord = tileGrid.getTileCoordForCoordAndResolution(coordinate, 10); tileCoord = tileGrid.getTileCoordForCoordAndResolution(coordinate, 10);
expect(tileCoord[0]).to.eql(0); expect(tileCoord[0]).to.eql(0);
expect(tileCoord[1]).to.eql(-1); expect(tileCoord[1]).to.eql(-1);
expect(tileCoord[2]).to.eql(-1); expect(tileCoord[2]).to.eql(0);
// gets the tile to the east when on the edge // gets the tile to the east when on the edge
coordinate = [2560, -1280]; coordinate = [2560, -1280];
tileCoord = tileGrid.getTileCoordForCoordAndResolution(coordinate, 10); tileCoord = tileGrid.getTileCoordForCoordAndResolution(coordinate, 10);
expect(tileCoord[0]).to.eql(0); expect(tileCoord[0]).to.eql(0);
expect(tileCoord[1]).to.eql(1); expect(tileCoord[1]).to.eql(1);
expect(tileCoord[2]).to.eql(-1); expect(tileCoord[2]).to.eql(0);
// gets the tile to the north when on the edge // gets the tile to the south when on the edge
coordinate = [1280, -2560]; coordinate = [1280, -2560];
tileCoord = tileGrid.getTileCoordForCoordAndResolution(coordinate, 10); tileCoord = tileGrid.getTileCoordForCoordAndResolution(coordinate, 10);
expect(tileCoord[0]).to.eql(0); expect(tileCoord[0]).to.eql(0);
expect(tileCoord[1]).to.eql(0); expect(tileCoord[1]).to.eql(0);
expect(tileCoord[2]).to.eql(-1); expect(tileCoord[2]).to.eql(1);
// pixels are top aligned to the origin // pixels are top aligned to the origin
coordinate = [1280, -2559.999]; coordinate = [1280, -2559.999];
tileCoord = tileGrid.getTileCoordForCoordAndResolution(coordinate, 10); tileCoord = tileGrid.getTileCoordForCoordAndResolution(coordinate, 10);
expect(tileCoord[0]).to.eql(0); expect(tileCoord[0]).to.eql(0);
expect(tileCoord[1]).to.eql(0); expect(tileCoord[1]).to.eql(0);
expect(tileCoord[2]).to.eql(-1); expect(tileCoord[2]).to.eql(0);
// pixels are left aligned to the origin // pixels are left aligned to the origin
coordinate = [2559.999, -1280]; coordinate = [2559.999, -1280];
tileCoord = tileGrid.getTileCoordForCoordAndResolution(coordinate, 10); tileCoord = tileGrid.getTileCoordForCoordAndResolution(coordinate, 10);
expect(tileCoord[0]).to.eql(0); expect(tileCoord[0]).to.eql(0);
expect(tileCoord[1]).to.eql(0); expect(tileCoord[1]).to.eql(0);
expect(tileCoord[2]).to.eql(-1); expect(tileCoord[2]).to.eql(0);
}); });
}); });
@@ -749,7 +749,7 @@ describe('ol.tilegrid.TileGrid', function() {
100000, 100000, 100, false); 100000, 100000, 100, false);
expect(tileCoord[0]).to.eql(3); expect(tileCoord[0]).to.eql(3);
expect(tileCoord[1]).to.eql(10); expect(tileCoord[1]).to.eql(10);
expect(tileCoord[2]).to.eql(10); expect(tileCoord[2]).to.eql(-10);
}); });
@@ -763,18 +763,16 @@ describe('ol.tilegrid.TileGrid', function() {
let tileCoord; let tileCoord;
// can get lower tile for edge intersection // can get lower tile for edge intersection
tileCoord = tileGrid.getTileCoordForXYAndResolution_( tileCoord = tileGrid.getTileCoordForXYAndResolution_(0, 0, 100, true);
0, 0, 100, true);
expect(tileCoord[0]).to.eql(3); expect(tileCoord[0]).to.eql(3);
expect(tileCoord[1]).to.eql(-1); expect(tileCoord[1]).to.eql(-1);
expect(tileCoord[2]).to.eql(-1); expect(tileCoord[2]).to.eql(-1);
// gets higher tile for edge intersection // can get lower tile for edge intersection
tileCoord = tileGrid.getTileCoordForXYAndResolution_( tileCoord = tileGrid.getTileCoordForXYAndResolution_(100000, 100000, 100, true);
100000, 100000, 100, true);
expect(tileCoord[0]).to.eql(3); expect(tileCoord[0]).to.eql(3);
expect(tileCoord[1]).to.eql(9); expect(tileCoord[1]).to.eql(9);
expect(tileCoord[2]).to.eql(9); expect(tileCoord[2]).to.eql(-11);
}); });
@@ -791,15 +789,15 @@ describe('ol.tilegrid.TileGrid', function() {
center = tileGrid.getTileCoordCenter([0, 0, 0]); center = tileGrid.getTileCoordCenter([0, 0, 0]);
expect(center[0]).to.eql(50000); expect(center[0]).to.eql(50000);
expect(center[1]).to.eql(50000); expect(center[1]).to.eql(-50000);
center = tileGrid.getTileCoordCenter([3, 0, 0]); center = tileGrid.getTileCoordCenter([3, 0, 0]);
expect(center[0]).to.eql(5000); expect(center[0]).to.eql(5000);
expect(center[1]).to.eql(5000); expect(center[1]).to.eql(-5000);
center = tileGrid.getTileCoordCenter([3, 9, 9]); center = tileGrid.getTileCoordCenter([3, 9, 9]);
expect(center[0]).to.eql(95000); expect(center[0]).to.eql(95000);
expect(center[1]).to.eql(95000); expect(center[1]).to.eql(-95000);
}); });
}); });
@@ -814,21 +812,21 @@ describe('ol.tilegrid.TileGrid', function() {
tileCoordExtent = tileGrid.getTileCoordExtent([0, 0, 0]); tileCoordExtent = tileGrid.getTileCoordExtent([0, 0, 0]);
expect(tileCoordExtent[0]).to.eql(0); expect(tileCoordExtent[0]).to.eql(0);
expect(tileCoordExtent[1]).to.eql(0); expect(tileCoordExtent[1]).to.eql(-100000);
expect(tileCoordExtent[2]).to.eql(100000); expect(tileCoordExtent[2]).to.eql(100000);
expect(tileCoordExtent[3]).to.eql(100000); expect(tileCoordExtent[3]).to.eql(0);
tileCoordExtent = tileGrid.getTileCoordExtent([3, 9, 0]); tileCoordExtent = tileGrid.getTileCoordExtent([3, 9, 0]);
expect(tileCoordExtent[0]).to.eql(90000); expect(tileCoordExtent[0]).to.eql(90000);
expect(tileCoordExtent[1]).to.eql(0); expect(tileCoordExtent[1]).to.eql(-10000);
expect(tileCoordExtent[2]).to.eql(100000); expect(tileCoordExtent[2]).to.eql(100000);
expect(tileCoordExtent[3]).to.eql(10000); expect(tileCoordExtent[3]).to.eql(0);
tileCoordExtent = tileGrid.getTileCoordExtent([3, 0, 9]); tileCoordExtent = tileGrid.getTileCoordExtent([3, 0, 9]);
expect(tileCoordExtent[0]).to.eql(0); expect(tileCoordExtent[0]).to.eql(0);
expect(tileCoordExtent[1]).to.eql(90000); expect(tileCoordExtent[1]).to.eql(-100000);
expect(tileCoordExtent[2]).to.eql(10000); expect(tileCoordExtent[2]).to.eql(10000);
expect(tileCoordExtent[3]).to.eql(100000); expect(tileCoordExtent[3]).to.eql(-90000);
}); });
}); });
@@ -843,28 +841,28 @@ describe('ol.tilegrid.TileGrid', function() {
let tileRange; let tileRange;
tileRange = tileGrid.getTileRangeForExtentAndZ(e, 0); tileRange = tileGrid.getTileRangeForExtentAndZ(e, 0);
expect(tileRange.minY).to.eql(0); expect(tileRange.minY).to.eql(-1);
expect(tileRange.minX).to.eql(0); expect(tileRange.minX).to.eql(0);
expect(tileRange.maxX).to.eql(0); expect(tileRange.maxX).to.eql(0);
expect(tileRange.maxY).to.eql(0); expect(tileRange.maxY).to.eql(-1);
tileRange = tileGrid.getTileRangeForExtentAndZ(e, 1); tileRange = tileGrid.getTileRangeForExtentAndZ(e, 1);
expect(tileRange.minX).to.eql(0); expect(tileRange.minX).to.eql(0);
expect(tileRange.minY).to.eql(0); expect(tileRange.minY).to.eql(-1);
expect(tileRange.maxX).to.eql(1); expect(tileRange.maxX).to.eql(1);
expect(tileRange.maxY).to.eql(0); expect(tileRange.maxY).to.eql(-1);
tileRange = tileGrid.getTileRangeForExtentAndZ(e, 2); tileRange = tileGrid.getTileRangeForExtentAndZ(e, 2);
expect(tileRange.minX).to.eql(1); expect(tileRange.minX).to.eql(1);
expect(tileRange.minY).to.eql(0); expect(tileRange.minY).to.eql(-1);
expect(tileRange.maxX).to.eql(2); expect(tileRange.maxX).to.eql(2);
expect(tileRange.maxY).to.eql(0); expect(tileRange.maxY).to.eql(-1);
tileRange = tileGrid.getTileRangeForExtentAndZ(e, 3); tileRange = tileGrid.getTileRangeForExtentAndZ(e, 3);
expect(tileRange.minX).to.eql(4); expect(tileRange.minX).to.eql(4);
expect(tileRange.minY).to.eql(0); expect(tileRange.minY).to.eql(-2);
expect(tileRange.maxX).to.eql(5); expect(tileRange.maxX).to.eql(5);
expect(tileRange.maxY).to.eql(1); expect(tileRange.maxY).to.eql(-1);
}); });
}); });
@@ -923,10 +921,10 @@ describe('ol.tilegrid.TileGrid', function() {
tileCoords.push(tileCoord); tileCoords.push(tileCoord);
}); });
expect(tileCoords).to.eql([ expect(tileCoords).to.eql([
[8, 138, -31], [8, 138, 29],
[8, 138, -30], [8, 138, 30],
[8, 139, -31], [8, 139, 29],
[8, 139, -30] [8, 139, 30]
]); ]);
}); });
}); });
+5 -5
View File
@@ -51,12 +51,12 @@ describe('ol.TileUrlFunction', function() {
const tileGrid = createXYZ(); const tileGrid = createXYZ();
it('creates expected URL', function() { it('creates expected URL', function() {
const tileUrl = createFromTemplate('{z}/{x}/{y}', tileGrid); const tileUrl = createFromTemplate('{z}/{x}/{y}', tileGrid);
expect(tileUrl([3, 2, -2])).to.eql('3/2/1'); expect(tileUrl([3, 2, 1])).to.eql('3/2/1');
expect(tileUrl(null)).to.be(undefined); expect(tileUrl(null)).to.be(undefined);
}); });
it('accepts {-y} placeholder', function() { it('accepts {-y} placeholder', function() {
const tileUrl = createFromTemplate('{z}/{x}/{-y}', tileGrid); const tileUrl = createFromTemplate('{z}/{x}/{-y}', tileGrid);
expect(tileUrl([3, 2, -3])).to.eql('3/2/5'); expect(tileUrl([3, 2, 2])).to.eql('3/2/5');
}); });
it('returns correct value for {-y} with custom tile grids', function() { it('returns correct value for {-y} with custom tile grids', function() {
const customTileGrid = new TileGrid({ const customTileGrid = new TileGrid({
@@ -65,11 +65,11 @@ describe('ol.TileUrlFunction', function() {
resolutions: [360 / 256, 360 / 512, 360 / 1024, 360 / 2048] resolutions: [360 / 256, 360 / 512, 360 / 1024, 360 / 2048]
}); });
const tileUrl = createFromTemplate('{z}/{x}/{-y}', customTileGrid); const tileUrl = createFromTemplate('{z}/{x}/{-y}', customTileGrid);
expect(tileUrl([3, 2, -3])).to.eql('3/2/1'); expect(tileUrl([3, 2, 2])).to.eql('3/2/1');
}); });
it('replaces multiple placeholder occurrences', function() { it('replaces multiple placeholder occurrences', function() {
const tileUrl = createFromTemplate('{z}/{z}{x}{y}', tileGrid); const tileUrl = createFromTemplate('{z}/{z}{x}{y}', tileGrid);
expect(tileUrl([3, 2, -2])).to.eql('3/321'); expect(tileUrl([3, 2, 1])).to.eql('3/321');
}); });
}); });
@@ -80,7 +80,7 @@ describe('ol.TileUrlFunction', function() {
'http://tile-1/{z}/{x}/{y}' 'http://tile-1/{z}/{x}/{y}'
]; ];
const tileUrlFunction = createFromTemplates(templates, tileGrid); const tileUrlFunction = createFromTemplates(templates, tileGrid);
const tileCoord = [3, 2, -2]; const tileCoord = [3, 2, 1];
expect(tileUrlFunction(tileCoord)).to.eql('http://tile-1/3/2/1'); expect(tileUrlFunction(tileCoord)).to.eql('http://tile-1/3/2/1');
}); });
+13 -13
View File
@@ -13,8 +13,8 @@ describe('ol.VectorImageTile', function() {
it('configures loader that sets features on the source tile', function(done) { it('configures loader that sets features on the source tile', function(done) {
const format = new GeoJSON(); const format = new GeoJSON();
const url = 'spec/ol/data/point.json'; const url = 'spec/ol/data/point.json';
const tile = new VectorImageTile([0, 0, -1], 0, url, format, const tile = new VectorImageTile([0, 0, 0], 0, url, format,
defaultLoadFunction, [0, 0, -1], function() { defaultLoadFunction, [0, 0, 0], function() {
return url; return url;
}, createXYZ(), createXYZ(), {}, }, createXYZ(), createXYZ(), {},
1, getProjection('EPSG:3857'), VectorTile, function() {}, 0); 1, getProjection('EPSG:3857'), VectorTile, function() {}, 0);
@@ -38,7 +38,7 @@ describe('ol.VectorImageTile', function() {
function(tile, url) { function(tile, url) {
sourceTile = tile; sourceTile = tile;
defaultLoadFunction(tile, url); defaultLoadFunction(tile, url);
}, [0, 0, -1], function() { }, [0, 0, 0], function() {
return url; return url;
}, createXYZ(), createXYZ(), {}, }, createXYZ(), createXYZ(), {},
1, getProjection('EPSG:3857'), VectorTile, function() {}, 0); 1, getProjection('EPSG:3857'), VectorTile, function() {}, 0);
@@ -61,8 +61,8 @@ describe('ol.VectorImageTile', function() {
it('sets ERROR state when source tiles fail to load', function(done) { it('sets ERROR state when source tiles fail to load', function(done) {
const format = new GeoJSON(); const format = new GeoJSON();
const url = 'spec/ol/data/unavailable.json'; const url = 'spec/ol/data/unavailable.json';
const tile = new VectorImageTile([0, 0, -1], 0, url, format, const tile = new VectorImageTile([0, 0, 0], 0, url, format,
defaultLoadFunction, [0, 0, -1], function() { defaultLoadFunction, [0, 0, 0], function() {
return url; return url;
}, createXYZ(), createXYZ(), {}, }, createXYZ(), createXYZ(), {},
1, getProjection('EPSG:3857'), VectorTile, function() {}, 0); 1, getProjection('EPSG:3857'), VectorTile, function() {}, 0);
@@ -78,8 +78,8 @@ describe('ol.VectorImageTile', function() {
it('sets EMPTY state when tile has only empty source tiles', function(done) { it('sets EMPTY state when tile has only empty source tiles', function(done) {
const format = new GeoJSON(); const format = new GeoJSON();
const url = ''; const url = '';
const tile = new VectorImageTile([0, 0, -1], 0, url, format, const tile = new VectorImageTile([0, 0, 0], 0, url, format,
defaultLoadFunction, [0, 0, -1], function() {}, defaultLoadFunction, [0, 0, 0], function() {},
createXYZ(), createXYZ(), {}, createXYZ(), createXYZ(), {},
1, getProjection('EPSG:3857'), VectorTile, function() {}, 0); 1, getProjection('EPSG:3857'), VectorTile, function() {}, 0);
@@ -100,22 +100,22 @@ describe('ol.VectorImageTile', function() {
extent: [-88, 35, -87, 36] extent: [-88, 35, -87, 36]
}); });
const sourceTiles = {}; const sourceTiles = {};
const tile = new VectorImageTile([1, 0, -1], 0, url, format, const tile = new VectorImageTile([1, 0, 0], 0, url, format,
defaultLoadFunction, [1, 0, -1], function(zxy) { defaultLoadFunction, [1, 0, 0], function(zxy) {
return url; return url;
}, tileGrid, }, tileGrid,
createXYZ({extent: [-180, -90, 180, 90], tileSize: 512}), createXYZ({extent: [-180, -90, 180, 90], tileSize: 512}),
sourceTiles, 1, getProjection('EPSG:4326'), VectorTile, function() {}, 1); sourceTiles, 1, getProjection('EPSG:4326'), VectorTile, function() {}, 1);
tile.load(); tile.load();
expect(tile.tileKeys.length).to.be(1); expect(tile.tileKeys.length).to.be(1);
expect(tile.getTile(tile.tileKeys[0]).tileCoord).to.eql([0, 16, -10]); expect(tile.getTile(tile.tileKeys[0]).tileCoord).to.eql([0, 16, 9]);
}); });
it('#dispose() while loading', function() { it('#dispose() while loading', function() {
const format = new GeoJSON(); const format = new GeoJSON();
const url = 'spec/ol/data/point.json'; const url = 'spec/ol/data/point.json';
const tile = new VectorImageTile([0, 0, 0] /* one world away */, 0, url, format, const tile = new VectorImageTile([0, 0, 0] /* one world away */, 0, url, format,
defaultLoadFunction, [0, 0, -1], function() { defaultLoadFunction, [0, 0, 0], function() {
return url; return url;
}, createXYZ(), createXYZ({tileSize: 512}), {}, }, createXYZ(), createXYZ({tileSize: 512}), {},
1, getProjection('EPSG:3857'), VectorTile, function() {}, 0); 1, getProjection('EPSG:3857'), VectorTile, function() {}, 0);
@@ -134,8 +134,8 @@ describe('ol.VectorImageTile', function() {
it('#dispose() when loaded', function(done) { it('#dispose() when loaded', function(done) {
const format = new GeoJSON(); const format = new GeoJSON();
const url = 'spec/ol/data/point.json'; const url = 'spec/ol/data/point.json';
const tile = new VectorImageTile([0, 0, -1], 0, url, format, const tile = new VectorImageTile([0, 0, 0], 0, url, format,
defaultLoadFunction, [0, 0, -1], function() { defaultLoadFunction, [0, 0, 0], function() {
return url; return url;
}, createXYZ(), createXYZ({tileSize: 512}), {}, }, createXYZ(), createXYZ({tileSize: 512}), {},
1, getProjection('EPSG:3857'), VectorTile, function() {}, 0); 1, getProjection('EPSG:3857'), VectorTile, function() {}, 0);