Use standard tile coords
This commit is contained in:
@@ -227,14 +227,14 @@ describe('ol.source.Tile', function() {
|
||||
wrapX: true
|
||||
});
|
||||
|
||||
let tileCoord = tileSource.getTileCoordForTileUrlFunction([6, -31, -23]);
|
||||
expect(tileCoord).to.eql([6, 33, -23]);
|
||||
let tileCoord = tileSource.getTileCoordForTileUrlFunction([6, -31, 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, 33, 22]);
|
||||
expect(tileCoord).to.eql([6, 33, 22]);
|
||||
|
||||
tileCoord = tileSource.getTileCoordForTileUrlFunction([6, 97, -23]);
|
||||
expect(tileCoord).to.eql([6, 33, -23]);
|
||||
tileCoord = tileSource.getTileCoordForTileUrlFunction([6, 97, 22]);
|
||||
expect(tileCoord).to.eql([6, 33, 22]);
|
||||
});
|
||||
|
||||
it('returns the expected tile coordinate - {wrapX: false}', function() {
|
||||
@@ -243,13 +243,13 @@ describe('ol.source.Tile', function() {
|
||||
wrapX: false
|
||||
});
|
||||
|
||||
let tileCoord = tileSource.getTileCoordForTileUrlFunction([6, -31, -23]);
|
||||
let tileCoord = tileSource.getTileCoordForTileUrlFunction([6, -31, 22]);
|
||||
expect(tileCoord).to.eql(null);
|
||||
|
||||
tileCoord = tileSource.getTileCoordForTileUrlFunction([6, 33, -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, 97, -23]);
|
||||
tileCoord = tileSource.getTileCoordForTileUrlFunction([6, 97, 22]);
|
||||
expect(tileCoord).to.eql(null);
|
||||
});
|
||||
|
||||
@@ -263,8 +263,8 @@ describe('ol.source.Tile', function() {
|
||||
wrapX: true
|
||||
});
|
||||
|
||||
const tileCoord = tileSource.getTileCoordForTileUrlFunction([6, -31, -23]);
|
||||
expect(tileCoord).to.eql([6, 33, -23]);
|
||||
const tileCoord = tileSource.getTileCoordForTileUrlFunction([6, -31, 22]);
|
||||
expect(tileCoord).to.eql([6, 33, 22]);
|
||||
});
|
||||
});
|
||||
|
||||
|
||||
@@ -17,7 +17,7 @@ describe('ol.source.TileArcGISRest', function() {
|
||||
|
||||
it('returns a tile with the expected URL', function() {
|
||||
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);
|
||||
const uri = new URL(tile.src_);
|
||||
expect(uri.protocol).to.be('http:');
|
||||
@@ -39,7 +39,7 @@ describe('ol.source.TileArcGISRest', function() {
|
||||
|
||||
it('returns a non floating point DPI value', function() {
|
||||
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 queryData = uri.searchParams;
|
||||
expect(queryData.get('DPI')).to.be('101');
|
||||
@@ -48,7 +48,7 @@ describe('ol.source.TileArcGISRest', function() {
|
||||
it('takes DPI from params if specified', function() {
|
||||
options.params.DPI = 96;
|
||||
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 queryData = uri.searchParams;
|
||||
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'];
|
||||
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);
|
||||
const uri = new URL(tile.src_);
|
||||
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() {
|
||||
options.url = 'http://example.com/ImageServer';
|
||||
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);
|
||||
const uri = new URL(tile.src_);
|
||||
expect(uri.protocol).to.be('http:');
|
||||
@@ -106,7 +106,7 @@ describe('ol.source.TileArcGISRest', function() {
|
||||
options.params.FORMAT = 'png';
|
||||
options.params.TRANSPARENT = false;
|
||||
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 queryData = uri.searchParams;
|
||||
expect(queryData.get('FORMAT')).to.be('png');
|
||||
@@ -116,7 +116,7 @@ describe('ol.source.TileArcGISRest', function() {
|
||||
it('allows adding rest option', function() {
|
||||
options.params.LAYERS = 'show:1,3,4';
|
||||
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 queryData = uri.searchParams;
|
||||
expect(queryData.get('LAYERS')).to.be('show:1,3,4');
|
||||
@@ -129,7 +129,7 @@ describe('ol.source.TileArcGISRest', function() {
|
||||
const source = new TileArcGISRest(options);
|
||||
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 queryData = uri.searchParams;
|
||||
expect(queryData.get('TEST')).to.be('value');
|
||||
@@ -141,7 +141,7 @@ describe('ol.source.TileArcGISRest', function() {
|
||||
const source = new TileArcGISRest(options);
|
||||
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 queryData = uri.searchParams;
|
||||
expect(queryData.get('TEST')).to.be('newValue');
|
||||
|
||||
@@ -49,14 +49,13 @@ describe('ol.source.TileImage', function() {
|
||||
beforeEach(function() {
|
||||
source = createSource();
|
||||
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);
|
||||
tile = source.tileCache.get(getKeyZXY(0, 0, -1));
|
||||
tile = source.tileCache.get(getKeyZXY(0, 0, 0));
|
||||
});
|
||||
|
||||
it('gets the tile from the cache', function() {
|
||||
const returnedTile = source.getTileInternal(
|
||||
0, 0, -1, 1, getProjection('EPSG:3857'));
|
||||
const returnedTile = source.getTileInternal(0, 0, 0, 1, getProjection('EPSG:3857'));
|
||||
expect(returnedTile).to.be(tile);
|
||||
});
|
||||
|
||||
@@ -67,8 +66,7 @@ describe('ol.source.TileImage', function() {
|
||||
source.getKey = function() {
|
||||
return 'key0';
|
||||
};
|
||||
const returnedTile = source.getTileInternal(
|
||||
0, 0, -1, 1, getProjection('EPSG:3857'));
|
||||
const returnedTile = source.getTileInternal(0, 0, 0, 1, getProjection('EPSG:3857'));
|
||||
expect(returnedTile).not.to.be(tile);
|
||||
expect(returnedTile.key).to.be('key0');
|
||||
expect(returnedTile.interimTile).to.be(null);
|
||||
@@ -81,8 +79,7 @@ describe('ol.source.TileImage', function() {
|
||||
return 'key0';
|
||||
};
|
||||
tile.state = 2; // LOADED
|
||||
const returnedTile = source.getTileInternal(
|
||||
0, 0, -1, 1, getProjection('EPSG:3857'));
|
||||
const returnedTile = source.getTileInternal(0, 0, 0, 1, getProjection('EPSG:3857'));
|
||||
expect(returnedTile).not.to.be(tile);
|
||||
expect(returnedTile.key).to.be('key0');
|
||||
expect(returnedTile.interimTile).to.be(tile);
|
||||
@@ -97,11 +94,9 @@ describe('ol.source.TileImage', function() {
|
||||
};
|
||||
dynamicParamsKey = 'key0';
|
||||
tile.state = 2; // LOADED
|
||||
returnedTile = source.getTileInternal(
|
||||
0, 0, -1, 1, getProjection('EPSG:3857'));
|
||||
returnedTile = source.getTileInternal(0, 0, 0, 1, getProjection('EPSG:3857'));
|
||||
dynamicParamsKey = 'key1';
|
||||
returnedTile = source.getTileInternal(
|
||||
0, 0, -1, 1, getProjection('EPSG:3857'));
|
||||
returnedTile = source.getTileInternal(0, 0, 0, 1, getProjection('EPSG:3857'));
|
||||
expect(returnedTile).not.to.be(tile);
|
||||
expect(returnedTile.key).to.be('key1');
|
||||
expect(returnedTile.interimTile).to.be(tile);
|
||||
@@ -115,7 +110,7 @@ describe('ol.source.TileImage', function() {
|
||||
describe('#getTile', function() {
|
||||
it('does not do reprojection for identity', function() {
|
||||
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).not.to.be.a(ReprojTile);
|
||||
|
||||
@@ -124,7 +119,7 @@ describe('ol.source.TileImage', function() {
|
||||
units: 'degrees'
|
||||
});
|
||||
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).not.to.be.a(ReprojTile);
|
||||
});
|
||||
@@ -145,7 +140,7 @@ describe('ol.source.TileImage', function() {
|
||||
extent: [-180, -90, 180, 90],
|
||||
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);
|
||||
|
||||
listen(tile, 'change', function() {
|
||||
@@ -164,7 +159,7 @@ describe('ol.source.TileImage', function() {
|
||||
extent: WORLD_EXTENT,
|
||||
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);
|
||||
|
||||
listen(tile, 'change', function() {
|
||||
@@ -194,7 +189,7 @@ describe('ol.source.TileImage', function() {
|
||||
source.on('tileloadstart', startSpy);
|
||||
const endSpy = sinon.spy();
|
||||
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();
|
||||
expect(startSpy.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);
|
||||
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();
|
||||
});
|
||||
|
||||
@@ -230,7 +225,7 @@ describe('ol.source.TileImage', function() {
|
||||
source.on('tileloadstart', startSpy);
|
||||
const endSpy = sinon.spy();
|
||||
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.dispose();
|
||||
expect(startSpy.callCount).to.be(1);
|
||||
|
||||
@@ -58,7 +58,9 @@ describe('ol.source.TileJSON', function() {
|
||||
tilejson: '2.2.0',
|
||||
tiles: [
|
||||
'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',
|
||||
webpage: 'https://a.tiles.mapbox.com/v3/mapbox.geography-class/page.html'
|
||||
@@ -67,7 +69,11 @@ describe('ol.source.TileJSON', function() {
|
||||
tileJSON: tileJSON
|
||||
});
|
||||
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');
|
||||
});
|
||||
});
|
||||
|
||||
|
||||
@@ -38,7 +38,7 @@ describe('ol.source.TileWMS', function() {
|
||||
|
||||
it('returns a tile with the expected URL', function() {
|
||||
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);
|
||||
const uri = new URL(tile.src_);
|
||||
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() {
|
||||
options.gutter = 16;
|
||||
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);
|
||||
const uri = new URL(tile.src_);
|
||||
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() {
|
||||
options.params.VERSION = '1.2';
|
||||
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 queryData = uri.searchParams;
|
||||
expect(queryData.get('CRS')).to.be(null);
|
||||
@@ -95,7 +95,7 @@ describe('ol.source.TileWMS', function() {
|
||||
options.params.FORMAT = 'image/jpeg';
|
||||
options.params.TRANSPARENT = false;
|
||||
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 queryData = uri.searchParams;
|
||||
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() {
|
||||
options.params.STYLES = 'foo';
|
||||
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 queryData = uri.searchParams;
|
||||
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() {
|
||||
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 queryData = uri.searchParams;
|
||||
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() {
|
||||
options.params.VERSION = '1.1.0';
|
||||
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 queryData = uri.searchParams;
|
||||
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() {
|
||||
options.serverType = 'geoserver';
|
||||
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 queryData = uri.searchParams;
|
||||
expect(queryData.get('FORMAT_OPTIONS')).to.be('dpi:180');
|
||||
@@ -141,7 +141,7 @@ describe('ol.source.TileWMS', function() {
|
||||
options.serverType = 'geoserver';
|
||||
const source = new TileWMS(options);
|
||||
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 queryData = uri.searchParams;
|
||||
expect(queryData.get('FORMAT_OPTIONS')).to.be('param1:value1;dpi:180');
|
||||
@@ -151,7 +151,7 @@ describe('ol.source.TileWMS', function() {
|
||||
function() {
|
||||
options.serverType = 'geoserver';
|
||||
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 queryData = uri.searchParams;
|
||||
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() {
|
||||
options.extent = [-80, -40, -50, -10];
|
||||
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 uri = new URL(url);
|
||||
const queryData = uri.searchParams;
|
||||
@@ -174,7 +174,7 @@ describe('ol.source.TileWMS', function() {
|
||||
it('returns a tile if it intersects layers extent', function() {
|
||||
options.extent = [-80, -40, -40, -10];
|
||||
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 uri = new URL(url);
|
||||
const queryData = uri.searchParams;
|
||||
@@ -188,7 +188,7 @@ describe('ol.source.TileWMS', function() {
|
||||
origin: [-180, -90]
|
||||
});
|
||||
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 uri = new URL(url);
|
||||
const queryData = uri.searchParams;
|
||||
|
||||
@@ -118,18 +118,15 @@ describe('ol.source.UrlTile', function() {
|
||||
it('returns the expected URL', function() {
|
||||
const projection = tileSource.getProjection();
|
||||
let tileUrl = tileSource.tileUrlFunction(
|
||||
tileSource.getTileCoordForTileUrlFunction(
|
||||
[6, -31, -23], projection));
|
||||
tileSource.getTileCoordForTileUrlFunction([6, -31, 22], projection));
|
||||
expect(tileUrl).to.eql('6/33/22');
|
||||
|
||||
tileUrl = tileSource.tileUrlFunction(
|
||||
tileSource.getTileCoordForTileUrlFunction(
|
||||
[6, 33, -23], projection));
|
||||
tileSource.getTileCoordForTileUrlFunction([6, 33, 22], projection));
|
||||
expect(tileUrl).to.eql('6/33/22');
|
||||
|
||||
tileUrl = tileSource.tileUrlFunction(
|
||||
tileSource.getTileCoordForTileUrlFunction(
|
||||
[6, 97, -23], projection));
|
||||
tileSource.getTileCoordForTileUrlFunction([6, 97, 22], projection));
|
||||
expect(tileUrl).to.eql('6/33/22');
|
||||
});
|
||||
|
||||
@@ -140,18 +137,15 @@ describe('ol.source.UrlTile', function() {
|
||||
it('returns the expected URL', function() {
|
||||
const projection = tileSource.getProjection();
|
||||
let tileUrl = tileSource.tileUrlFunction(
|
||||
tileSource.getTileCoordForTileUrlFunction(
|
||||
[6, 33, 0], projection));
|
||||
tileSource.getTileCoordForTileUrlFunction([6, 33, -1], projection));
|
||||
expect(tileUrl).to.be(undefined);
|
||||
|
||||
tileUrl = tileSource.tileUrlFunction(
|
||||
tileSource.getTileCoordForTileUrlFunction(
|
||||
[6, 33, -23], projection));
|
||||
tileSource.getTileCoordForTileUrlFunction([6, 33, 22], projection));
|
||||
expect(tileUrl).to.eql('6/33/22');
|
||||
|
||||
tileUrl = tileSource.tileUrlFunction(
|
||||
tileSource.getTileCoordForTileUrlFunction(
|
||||
[6, 33, -65], projection));
|
||||
tileSource.getTileCoordForTileUrlFunction([6, 33, 64], projection));
|
||||
expect(tileUrl).to.be(undefined);
|
||||
});
|
||||
|
||||
|
||||
@@ -222,9 +222,9 @@ describe('ol.source.UTFGrid', function() {
|
||||
|
||||
// Override getTile method to not depend on the external service. The
|
||||
// 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) {
|
||||
const tileCoord = [1, 1, -1]; // overwritten to match our stored JSON
|
||||
const tileCoord = [1, 1, 0]; // overwritten to match our stored JSON
|
||||
const urlTileCoord =
|
||||
this.getTileCoordForTileUrlFunction(tileCoord, projection);
|
||||
const tileUrl = this.tileUrlFunction_(urlTileCoord, pixelRatio, projection);
|
||||
|
||||
@@ -58,7 +58,7 @@ describe('ol.source.VectorTile', function() {
|
||||
|
||||
describe('Tile load events', function() {
|
||||
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;
|
||||
source.on('tileloadstart', function() {
|
||||
started = true;
|
||||
@@ -82,10 +82,10 @@ describe('ol.source.VectorTile', function() {
|
||||
loaded = [];
|
||||
requested = 0;
|
||||
|
||||
function tileUrlFunction(tileUrl) {
|
||||
function tileUrlFunction(tileCoord) {
|
||||
++requested;
|
||||
if (tileUrl.toString() == '6,27,55') {
|
||||
return tileUrl.join('/');
|
||||
if (tileCoord.toString() == '6,27,-57') {
|
||||
return tileCoord.join('/');
|
||||
}
|
||||
}
|
||||
|
||||
@@ -133,7 +133,7 @@ describe('ol.source.VectorTile', function() {
|
||||
map.renderSync();
|
||||
setTimeout(function() {
|
||||
expect(requested).to.be.greaterThan(1);
|
||||
expect(loaded).to.eql(['6/27/55']);
|
||||
expect(loaded).to.eql(['6/27/-57']);
|
||||
done();
|
||||
}, 0);
|
||||
});
|
||||
|
||||
@@ -198,7 +198,7 @@ describe('ol.source.WMTS', function() {
|
||||
|
||||
const projection = getProjection('EPSG:3857');
|
||||
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');
|
||||
});
|
||||
|
||||
@@ -215,7 +215,7 @@ describe('ol.source.WMTS', function() {
|
||||
|
||||
const projection = getProjection('EPSG:3857');
|
||||
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');
|
||||
});
|
||||
|
||||
@@ -233,7 +233,7 @@ describe('ol.source.WMTS', function() {
|
||||
|
||||
const projection = getProjection('EPSG:3857');
|
||||
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');
|
||||
});
|
||||
});
|
||||
@@ -334,7 +334,7 @@ describe('ol.source.WMTS', function() {
|
||||
'https://b.example.com/{TileMatrix}/{TileRow}/{TileCol}.jpg'
|
||||
];
|
||||
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/);
|
||||
});
|
||||
});
|
||||
|
||||
@@ -93,18 +93,15 @@ describe('ol.source.XYZ', function() {
|
||||
it('returns the expected URL', function() {
|
||||
const projection = xyzTileSource.getProjection();
|
||||
let tileUrl = xyzTileSource.tileUrlFunction(
|
||||
xyzTileSource.getTileCoordForTileUrlFunction(
|
||||
[6, -31, -23], projection));
|
||||
xyzTileSource.getTileCoordForTileUrlFunction([6, -31, 22], projection));
|
||||
expect(tileUrl).to.eql('6/33/22');
|
||||
|
||||
tileUrl = xyzTileSource.tileUrlFunction(
|
||||
xyzTileSource.getTileCoordForTileUrlFunction(
|
||||
[6, 33, -23], projection));
|
||||
xyzTileSource.getTileCoordForTileUrlFunction([6, 33, 22], projection));
|
||||
expect(tileUrl).to.eql('6/33/22');
|
||||
|
||||
tileUrl = xyzTileSource.tileUrlFunction(
|
||||
xyzTileSource.getTileCoordForTileUrlFunction(
|
||||
[6, 97, -23], projection));
|
||||
xyzTileSource.getTileCoordForTileUrlFunction([6, 97, 22], projection));
|
||||
expect(tileUrl).to.eql('6/33/22');
|
||||
});
|
||||
|
||||
@@ -115,18 +112,15 @@ describe('ol.source.XYZ', function() {
|
||||
it('returns the expected URL', function() {
|
||||
const projection = xyzTileSource.getProjection();
|
||||
let tileUrl = xyzTileSource.tileUrlFunction(
|
||||
xyzTileSource.getTileCoordForTileUrlFunction(
|
||||
[6, 33, 0], projection));
|
||||
xyzTileSource.getTileCoordForTileUrlFunction([6, 33, -1], projection));
|
||||
expect(tileUrl).to.be(undefined);
|
||||
|
||||
tileUrl = xyzTileSource.tileUrlFunction(
|
||||
xyzTileSource.getTileCoordForTileUrlFunction(
|
||||
[6, 33, -23], projection));
|
||||
xyzTileSource.getTileCoordForTileUrlFunction([6, 33, 22], projection));
|
||||
expect(tileUrl).to.eql('6/33/22');
|
||||
|
||||
tileUrl = xyzTileSource.tileUrlFunction(
|
||||
xyzTileSource.getTileCoordForTileUrlFunction(
|
||||
[6, 33, -65], projection));
|
||||
xyzTileSource.getTileCoordForTileUrlFunction([6, 33, 64], projection));
|
||||
expect(tileUrl).to.be(undefined);
|
||||
});
|
||||
|
||||
|
||||
@@ -234,23 +234,23 @@ describe('ol.source.Zoomify', function() {
|
||||
const source = getZoomifySource();
|
||||
const tileUrlFunction = source.getTileUrlFunction();
|
||||
// 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
|
||||
expect(tileUrlFunction([1, 0, -1])).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, 0, -2])).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, 0, 0])).to.eql('spec/ol/source/images/zoomify/TileGroup0/1-0-0.jpg');
|
||||
expect(tileUrlFunction([1, 1, 0])).to.eql('spec/ol/source/images/zoomify/TileGroup0/1-1-0.jpg');
|
||||
expect(tileUrlFunction([1, 0, 1])).to.eql('spec/ol/source/images/zoomify/TileGroup0/1-0-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() {
|
||||
const source = getIIPSource();
|
||||
const tileUrlFunction = source.getTileUrlFunction();
|
||||
// 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
|
||||
expect(tileUrlFunction([1, 0, -1])).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, 0, -2])).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, 0, 0])).to.eql('spec/ol/source/images/zoomify?JTL=1,0');
|
||||
expect(tileUrlFunction([1, 1, 0])).to.eql('spec/ol/source/images/zoomify?JTL=1,1');
|
||||
expect(tileUrlFunction([1, 0, 1])).to.eql('spec/ol/source/images/zoomify?JTL=1,2');
|
||||
expect(tileUrlFunction([1, 1, 1])).to.eql('spec/ol/source/images/zoomify?JTL=1,3');
|
||||
});
|
||||
|
||||
it('creates an expected tileUrlFunction without template', function() {
|
||||
@@ -260,12 +260,12 @@ describe('ol.source.Zoomify', function() {
|
||||
});
|
||||
const tileUrlFunction = source.getTileUrlFunction();
|
||||
// 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
|
||||
expect(tileUrlFunction([1, 0, -1])).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, 0, -2])).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, 0, 0])).to.eql('spec/ol/source/images/zoomify/TileGroup0/1-0-0.jpg');
|
||||
expect(tileUrlFunction([1, 1, 0])).to.eql('spec/ol/source/images/zoomify/TileGroup0/1-1-0.jpg');
|
||||
expect(tileUrlFunction([1, 0, 1])).to.eql('spec/ol/source/images/zoomify/TileGroup0/1-0-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() {
|
||||
const source = getZoomifySource();
|
||||
@@ -279,17 +279,17 @@ describe('ol.source.Zoomify', function() {
|
||||
|
||||
it('returns expected tileClass instances via "getTile"', function() {
|
||||
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);
|
||||
});
|
||||
|
||||
it('"tile.getImage" returns and caches an unloaded image', function() {
|
||||
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 tile2 = source.getTile(0, 0, -1, 1, proj);
|
||||
const tile2 = source.getTile(0, 0, 0, 1, proj);
|
||||
const img2 = tile2.getImage();
|
||||
|
||||
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) {
|
||||
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() {
|
||||
if (tile.getState() == 2) { // LOADED
|
||||
const img = tile.getImage();
|
||||
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
|
||||
const img2 = tile2.getImage();
|
||||
expect(img).to.be(img2);
|
||||
|
||||
Reference in New Issue
Block a user