Transformed
This commit is contained in:
@@ -1,25 +1,25 @@
|
||||
goog.require('ol.ImageTile');
|
||||
goog.require('ol.TileState');
|
||||
goog.require('ol.TileUrlFunction');
|
||||
goog.require('ol.events');
|
||||
goog.require('ol.proj');
|
||||
goog.require('ol.proj.EPSG3857');
|
||||
goog.require('ol.proj.Projection');
|
||||
goog.require('ol.reproj.Tile');
|
||||
goog.require('ol.source.TileImage');
|
||||
goog.require('ol.tilecoord');
|
||||
goog.require('ol.tilegrid');
|
||||
import _ol_ImageTile_ from '../../../../src/ol/ImageTile.js';
|
||||
import _ol_TileState_ from '../../../../src/ol/TileState.js';
|
||||
import _ol_TileUrlFunction_ from '../../../../src/ol/TileUrlFunction.js';
|
||||
import _ol_events_ from '../../../../src/ol/events.js';
|
||||
import _ol_proj_ from '../../../../src/ol/proj.js';
|
||||
import _ol_proj_EPSG3857_ from '../../../../src/ol/proj/EPSG3857.js';
|
||||
import _ol_proj_Projection_ from '../../../../src/ol/proj/Projection.js';
|
||||
import _ol_reproj_Tile_ from '../../../../src/ol/reproj/Tile.js';
|
||||
import _ol_source_TileImage_ from '../../../../src/ol/source/TileImage.js';
|
||||
import _ol_tilecoord_ from '../../../../src/ol/tilecoord.js';
|
||||
import _ol_tilegrid_ from '../../../../src/ol/tilegrid.js';
|
||||
|
||||
|
||||
describe('ol.source.TileImage', function() {
|
||||
function createSource(opt_proj, opt_tileGrid, opt_cacheSize) {
|
||||
var proj = opt_proj || 'EPSG:3857';
|
||||
return new ol.source.TileImage({
|
||||
return new _ol_source_TileImage_({
|
||||
cacheSize: opt_cacheSize,
|
||||
projection: proj,
|
||||
tileGrid: opt_tileGrid ||
|
||||
ol.tilegrid.createForProjection(proj, undefined, [2, 2]),
|
||||
tileUrlFunction: ol.TileUrlFunction.createFromTemplate(
|
||||
_ol_tilegrid_.createForProjection(proj, undefined, [2, 2]),
|
||||
tileUrlFunction: _ol_TileUrlFunction_.createFromTemplate(
|
||||
'data:image/gif;base64,R0lGODlhAQABAIAAAP///wAAACwAAAAAAQABAAACAkQBADs=')
|
||||
});
|
||||
}
|
||||
@@ -27,7 +27,7 @@ describe('ol.source.TileImage', function() {
|
||||
describe('#getTileCacheForProjection', function() {
|
||||
it('uses the cacheSize for reprojected tile caches', function() {
|
||||
var source = createSource(undefined, undefined, 42);
|
||||
var tileCache = source.getTileCacheForProjection(ol.proj.get('EPSG:4326'));
|
||||
var tileCache = source.getTileCacheForProjection(_ol_proj_.get('EPSG:4326'));
|
||||
expect(tileCache.highWaterMark).to.be(42);
|
||||
expect(tileCache).to.not.equal(source.getTileCacheForProjection(source.getProjection()));
|
||||
});
|
||||
@@ -36,9 +36,9 @@ describe('ol.source.TileImage', function() {
|
||||
describe('#setTileGridForProjection', function() {
|
||||
it('uses the tilegrid for given projection', function() {
|
||||
var source = createSource();
|
||||
var tileGrid = ol.tilegrid.createForProjection('EPSG:4326', 3, [10, 20]);
|
||||
var tileGrid = _ol_tilegrid_.createForProjection('EPSG:4326', 3, [10, 20]);
|
||||
source.setTileGridForProjection('EPSG:4326', tileGrid);
|
||||
var retrieved = source.getTileGridForProjection(ol.proj.get('EPSG:4326'));
|
||||
var retrieved = source.getTileGridForProjection(_ol_proj_.get('EPSG:4326'));
|
||||
expect(retrieved).to.be(tileGrid);
|
||||
});
|
||||
});
|
||||
@@ -49,14 +49,14 @@ describe('ol.source.TileImage', function() {
|
||||
beforeEach(function() {
|
||||
source = createSource();
|
||||
expect(source.getKey()).to.be('');
|
||||
source.getTileInternal(0, 0, -1, 1, ol.proj.get('EPSG:3857'));
|
||||
source.getTileInternal(0, 0, -1, 1, _ol_proj_.get('EPSG:3857'));
|
||||
expect(source.tileCache.getCount()).to.be(1);
|
||||
tile = source.tileCache.get(ol.tilecoord.getKeyZXY(0, 0, -1));
|
||||
tile = source.tileCache.get(_ol_tilecoord_.getKeyZXY(0, 0, -1));
|
||||
});
|
||||
|
||||
it('gets the tile from the cache', function() {
|
||||
var returnedTile = source.getTileInternal(
|
||||
0, 0, -1, 1, ol.proj.get('EPSG:3857'));
|
||||
0, 0, -1, 1, _ol_proj_.get('EPSG:3857'));
|
||||
expect(returnedTile).to.be(tile);
|
||||
});
|
||||
|
||||
@@ -68,7 +68,7 @@ describe('ol.source.TileImage', function() {
|
||||
return 'key0';
|
||||
};
|
||||
var returnedTile = source.getTileInternal(
|
||||
0, 0, -1, 1, ol.proj.get('EPSG:3857'));
|
||||
0, 0, -1, 1, _ol_proj_.get('EPSG:3857'));
|
||||
expect(returnedTile).not.to.be(tile);
|
||||
expect(returnedTile.key).to.be('key0');
|
||||
expect(returnedTile.interimTile).to.be(null);
|
||||
@@ -82,7 +82,7 @@ describe('ol.source.TileImage', function() {
|
||||
};
|
||||
tile.state = 2; // LOADED
|
||||
var returnedTile = source.getTileInternal(
|
||||
0, 0, -1, 1, ol.proj.get('EPSG:3857'));
|
||||
0, 0, -1, 1, _ol_proj_.get('EPSG:3857'));
|
||||
expect(returnedTile).not.to.be(tile);
|
||||
expect(returnedTile.key).to.be('key0');
|
||||
expect(returnedTile.interimTile).to.be(tile);
|
||||
@@ -98,10 +98,10 @@ describe('ol.source.TileImage', function() {
|
||||
dynamicParamsKey = 'key0';
|
||||
tile.state = 2; // LOADED
|
||||
returnedTile = source.getTileInternal(
|
||||
0, 0, -1, 1, ol.proj.get('EPSG:3857'));
|
||||
0, 0, -1, 1, _ol_proj_.get('EPSG:3857'));
|
||||
dynamicParamsKey = 'key1';
|
||||
returnedTile = source.getTileInternal(
|
||||
0, 0, -1, 1, ol.proj.get('EPSG:3857'));
|
||||
0, 0, -1, 1, _ol_proj_.get('EPSG:3857'));
|
||||
expect(returnedTile).not.to.be(tile);
|
||||
expect(returnedTile.key).to.be('key1');
|
||||
expect(returnedTile.interimTile).to.be(tile);
|
||||
@@ -115,18 +115,18 @@ describe('ol.source.TileImage', function() {
|
||||
describe('#getTile', function() {
|
||||
it('does not do reprojection for identity', function() {
|
||||
var source3857 = createSource('EPSG:3857');
|
||||
var tile3857 = source3857.getTile(0, 0, -1, 1, ol.proj.get('EPSG:3857'));
|
||||
expect(tile3857).to.be.a(ol.ImageTile);
|
||||
expect(tile3857).not.to.be.a(ol.reproj.Tile);
|
||||
var tile3857 = source3857.getTile(0, 0, -1, 1, _ol_proj_.get('EPSG:3857'));
|
||||
expect(tile3857).to.be.a(_ol_ImageTile_);
|
||||
expect(tile3857).not.to.be.a(_ol_reproj_Tile_);
|
||||
|
||||
var projXXX = new ol.proj.Projection({
|
||||
var projXXX = new _ol_proj_Projection_({
|
||||
code: 'XXX',
|
||||
units: 'degrees'
|
||||
});
|
||||
var sourceXXX = createSource(projXXX);
|
||||
var tileXXX = sourceXXX.getTile(0, 0, -1, 1, projXXX);
|
||||
expect(tileXXX).to.be.a(ol.ImageTile);
|
||||
expect(tileXXX).not.to.be.a(ol.reproj.Tile);
|
||||
expect(tileXXX).to.be.a(_ol_ImageTile_);
|
||||
expect(tileXXX).not.to.be.a(_ol_reproj_Tile_);
|
||||
});
|
||||
|
||||
beforeEach(function() {
|
||||
@@ -138,14 +138,14 @@ describe('ol.source.TileImage', function() {
|
||||
});
|
||||
|
||||
it('can handle source projection without extent and units', function(done) {
|
||||
var source = createSource('4326_noextentnounits', ol.tilegrid.createXYZ({
|
||||
var source = createSource('4326_noextentnounits', _ol_tilegrid_.createXYZ({
|
||||
extent: [-180, -90, 180, 90],
|
||||
tileSize: [2, 2]
|
||||
}));
|
||||
var tile = source.getTile(0, 0, -1, 1, ol.proj.get('EPSG:3857'));
|
||||
expect(tile).to.be.a(ol.reproj.Tile);
|
||||
var tile = source.getTile(0, 0, -1, 1, _ol_proj_.get('EPSG:3857'));
|
||||
expect(tile).to.be.a(_ol_reproj_Tile_);
|
||||
|
||||
ol.events.listen(tile, 'change', function() {
|
||||
_ol_events_.listen(tile, 'change', function() {
|
||||
if (tile.getState() == 2) { // LOADED
|
||||
done();
|
||||
}
|
||||
@@ -154,17 +154,17 @@ describe('ol.source.TileImage', function() {
|
||||
});
|
||||
|
||||
it('can handle target projection without extent and units', function(done) {
|
||||
var proj = ol.proj.get('4326_noextentnounits');
|
||||
var proj = _ol_proj_.get('4326_noextentnounits');
|
||||
var source = createSource();
|
||||
source.setTileGridForProjection(proj,
|
||||
ol.tilegrid.createXYZ({
|
||||
extent: ol.proj.EPSG3857.WORLD_EXTENT,
|
||||
_ol_tilegrid_.createXYZ({
|
||||
extent: _ol_proj_EPSG3857_.WORLD_EXTENT,
|
||||
tileSize: [2, 2]
|
||||
}));
|
||||
var tile = source.getTile(0, 0, -1, 1, proj);
|
||||
expect(tile).to.be.a(ol.reproj.Tile);
|
||||
expect(tile).to.be.a(_ol_reproj_Tile_);
|
||||
|
||||
ol.events.listen(tile, 'change', function() {
|
||||
_ol_events_.listen(tile, 'change', function() {
|
||||
if (tile.getState() == 2) { // LOADED
|
||||
done();
|
||||
}
|
||||
@@ -178,20 +178,20 @@ describe('ol.source.TileImage', function() {
|
||||
var source;
|
||||
|
||||
beforeEach(function() {
|
||||
source = new ol.source.TileImage({
|
||||
source = new _ol_source_TileImage_({
|
||||
url: '{z}/{x}/{y}'
|
||||
});
|
||||
});
|
||||
|
||||
it('dispatches tileloadstart and tileloadend events', function() {
|
||||
source.setTileLoadFunction(function(tile) {
|
||||
tile.setState(ol.TileState.LOADED);
|
||||
tile.setState(_ol_TileState_.LOADED);
|
||||
});
|
||||
var startSpy = sinon.spy();
|
||||
source.on('tileloadstart', startSpy);
|
||||
var endSpy = sinon.spy();
|
||||
source.on('tileloadend', endSpy);
|
||||
var tile = source.getTile(0, 0, -1, 1, ol.proj.get('EPSG:3857'));
|
||||
var tile = source.getTile(0, 0, -1, 1, _ol_proj_.get('EPSG:3857'));
|
||||
tile.load();
|
||||
expect(startSpy.callCount).to.be(1);
|
||||
expect(endSpy.callCount).to.be(1);
|
||||
@@ -200,15 +200,15 @@ describe('ol.source.TileImage', function() {
|
||||
it('works for loading-error-loading-loaded sequences', function(done) {
|
||||
source.setTileLoadFunction(function(tile) {
|
||||
tile.setState(
|
||||
tile.state == ol.TileState.ERROR ? ol.TileState.LOADED : ol.TileState.ERROR);
|
||||
tile.state == _ol_TileState_.ERROR ? _ol_TileState_.LOADED : _ol_TileState_.ERROR);
|
||||
});
|
||||
var startSpy = sinon.spy();
|
||||
source.on('tileloadstart', startSpy);
|
||||
var errorSpy = sinon.spy();
|
||||
source.on('tileloaderror', function(e) {
|
||||
setTimeout(function() {
|
||||
e.tile.setState(ol.TileState.LOADING);
|
||||
e.tile.setState(ol.TileState.LOADED);
|
||||
e.tile.setState(_ol_TileState_.LOADING);
|
||||
e.tile.setState(_ol_TileState_.LOADED);
|
||||
}, 0);
|
||||
errorSpy();
|
||||
});
|
||||
@@ -217,7 +217,7 @@ describe('ol.source.TileImage', function() {
|
||||
expect(errorSpy.callCount).to.be(1);
|
||||
done();
|
||||
});
|
||||
var tile = source.getTile(0, 0, -1, 1, ol.proj.get('EPSG:3857'));
|
||||
var tile = source.getTile(0, 0, -1, 1, _ol_proj_.get('EPSG:3857'));
|
||||
tile.load();
|
||||
});
|
||||
|
||||
@@ -227,7 +227,7 @@ describe('ol.source.TileImage', function() {
|
||||
source.on('tileloadstart', startSpy);
|
||||
var endSpy = sinon.spy();
|
||||
source.on('tileloadend', endSpy);
|
||||
var tile = source.getTile(0, 0, -1, 1, ol.proj.get('EPSG:3857'));
|
||||
var tile = source.getTile(0, 0, -1, 1, _ol_proj_.get('EPSG:3857'));
|
||||
tile.load();
|
||||
tile.dispose();
|
||||
expect(startSpy.callCount).to.be(1);
|
||||
|
||||
Reference in New Issue
Block a user