Transformed
This commit is contained in:
@@ -1,7 +1,7 @@
|
||||
goog.require('ol.TileUrlFunction');
|
||||
goog.require('ol.tilecoord');
|
||||
goog.require('ol.tilegrid');
|
||||
goog.require('ol.tilegrid.TileGrid');
|
||||
import _ol_TileUrlFunction_ from '../../../src/ol/TileUrlFunction.js';
|
||||
import _ol_tilecoord_ from '../../../src/ol/tilecoord.js';
|
||||
import _ol_tilegrid_ from '../../../src/ol/tilegrid.js';
|
||||
import _ol_tilegrid_TileGrid_ from '../../../src/ol/tilegrid/TileGrid.js';
|
||||
|
||||
describe('ol.TileUrlFunction', function() {
|
||||
|
||||
@@ -9,7 +9,7 @@ describe('ol.TileUrlFunction', function() {
|
||||
describe('with number range', function() {
|
||||
it('creates expected URLs', function() {
|
||||
var template = 'http://tile-{1-3}/{z}/{x}/{y}';
|
||||
var urls = ol.TileUrlFunction.expandUrl(template);
|
||||
var urls = _ol_TileUrlFunction_.expandUrl(template);
|
||||
expect(urls).to.eql([
|
||||
'http://tile-1/{z}/{x}/{y}',
|
||||
'http://tile-2/{z}/{x}/{y}',
|
||||
@@ -18,7 +18,7 @@ describe('ol.TileUrlFunction', function() {
|
||||
});
|
||||
it('creates expected URLs', function() {
|
||||
var template = 'http://tile-{9-11}/{z}/{x}/{y}';
|
||||
var urls = ol.TileUrlFunction.expandUrl(template);
|
||||
var urls = _ol_TileUrlFunction_.expandUrl(template);
|
||||
expect(urls).to.eql([
|
||||
'http://tile-9/{z}/{x}/{y}',
|
||||
'http://tile-10/{z}/{x}/{y}',
|
||||
@@ -29,7 +29,7 @@ describe('ol.TileUrlFunction', function() {
|
||||
describe('with character range', function() {
|
||||
it('creates expected URLs', function() {
|
||||
var template = 'http://tile-{c-e}/{z}/{x}/{y}';
|
||||
var urls = ol.TileUrlFunction.expandUrl(template);
|
||||
var urls = _ol_TileUrlFunction_.expandUrl(template);
|
||||
expect(urls).to.eql([
|
||||
'http://tile-c/{z}/{x}/{y}',
|
||||
'http://tile-d/{z}/{x}/{y}',
|
||||
@@ -40,7 +40,7 @@ describe('ol.TileUrlFunction', function() {
|
||||
describe('without range', function() {
|
||||
it('creates expected URLs', function() {
|
||||
var template = 'http://tiles.example.com/{z}/{x}/{y}';
|
||||
var urls = ol.TileUrlFunction.expandUrl(template);
|
||||
var urls = _ol_TileUrlFunction_.expandUrl(template);
|
||||
expect(urls).to.eql([
|
||||
'http://tiles.example.com/{z}/{x}/{y}'
|
||||
]);
|
||||
@@ -49,75 +49,75 @@ describe('ol.TileUrlFunction', function() {
|
||||
});
|
||||
|
||||
describe('createFromTemplate', function() {
|
||||
var tileGrid = ol.tilegrid.createXYZ();
|
||||
var tileGrid = _ol_tilegrid_.createXYZ();
|
||||
it('creates expected URL', function() {
|
||||
var tileUrl = ol.TileUrlFunction.createFromTemplate(
|
||||
var tileUrl = _ol_TileUrlFunction_.createFromTemplate(
|
||||
'{z}/{x}/{y}', tileGrid);
|
||||
expect(tileUrl([3, 2, -2])).to.eql('3/2/1');
|
||||
expect(tileUrl(null)).to.be(undefined);
|
||||
});
|
||||
it('accepts {-y} placeholder', function() {
|
||||
var tileUrl = ol.TileUrlFunction.createFromTemplate(
|
||||
var tileUrl = _ol_TileUrlFunction_.createFromTemplate(
|
||||
'{z}/{x}/{-y}', tileGrid);
|
||||
expect(tileUrl([3, 2, -3])).to.eql('3/2/5');
|
||||
});
|
||||
it('returns correct value for {-y} with custom tile grids', function() {
|
||||
var customTileGrid = new ol.tilegrid.TileGrid({
|
||||
var customTileGrid = new _ol_tilegrid_TileGrid_({
|
||||
extent: [-180, -90, 180, 90],
|
||||
origin: [-180, -90],
|
||||
resolutions: [360 / 256, 360 / 512, 360 / 1024, 360 / 2048]
|
||||
});
|
||||
var tileUrl = ol.TileUrlFunction.createFromTemplate(
|
||||
var tileUrl = _ol_TileUrlFunction_.createFromTemplate(
|
||||
'{z}/{x}/{-y}', customTileGrid);
|
||||
expect(tileUrl([3, 2, -3])).to.eql('3/2/1');
|
||||
});
|
||||
it('replaces multiple placeholder occurrences', function() {
|
||||
var tileUrl = ol.TileUrlFunction.createFromTemplate(
|
||||
var tileUrl = _ol_TileUrlFunction_.createFromTemplate(
|
||||
'{z}/{z}{x}{y}', tileGrid);
|
||||
expect(tileUrl([3, 2, -2])).to.eql('3/321');
|
||||
});
|
||||
});
|
||||
|
||||
describe('createFromTemplates', function() {
|
||||
var tileGrid = ol.tilegrid.createXYZ();
|
||||
var tileGrid = _ol_tilegrid_.createXYZ();
|
||||
it('creates expected URL', function() {
|
||||
var templates = [
|
||||
'http://tile-1/{z}/{x}/{y}',
|
||||
'http://tile-2/{z}/{x}/{y}',
|
||||
'http://tile-3/{z}/{x}/{y}'
|
||||
];
|
||||
var tileUrlFunction = ol.TileUrlFunction.createFromTemplates(
|
||||
var tileUrlFunction = _ol_TileUrlFunction_.createFromTemplates(
|
||||
templates, tileGrid);
|
||||
var tileCoord = [3, 2, -2];
|
||||
|
||||
/* eslint-disable openlayers-internal/no-missing-requires */
|
||||
sinon.stub(ol.tilecoord, 'hash').callsFake(function() {
|
||||
sinon.stub(_ol_tilecoord_, 'hash').callsFake(function() {
|
||||
return 3;
|
||||
});
|
||||
expect(tileUrlFunction(tileCoord)).to.eql('http://tile-1/3/2/1');
|
||||
ol.tilecoord.hash.restore();
|
||||
_ol_tilecoord_.hash.restore();
|
||||
|
||||
sinon.stub(ol.tilecoord, 'hash').callsFake(function() {
|
||||
sinon.stub(_ol_tilecoord_, 'hash').callsFake(function() {
|
||||
return 2;
|
||||
});
|
||||
expect(tileUrlFunction(tileCoord)).to.eql('http://tile-3/3/2/1');
|
||||
ol.tilecoord.hash.restore();
|
||||
_ol_tilecoord_.hash.restore();
|
||||
|
||||
sinon.stub(ol.tilecoord, 'hash').callsFake(function() {
|
||||
sinon.stub(_ol_tilecoord_, 'hash').callsFake(function() {
|
||||
return 1;
|
||||
});
|
||||
expect(tileUrlFunction(tileCoord)).to.eql('http://tile-2/3/2/1');
|
||||
ol.tilecoord.hash.restore();
|
||||
_ol_tilecoord_.hash.restore();
|
||||
/* eslint-enable */
|
||||
});
|
||||
});
|
||||
|
||||
describe('createFromTileUrlFunctions', function() {
|
||||
var tileGrid = ol.tilegrid.createXYZ();
|
||||
var tileGrid = _ol_tilegrid_.createXYZ();
|
||||
it('creates expected URL', function() {
|
||||
var tileUrl = ol.TileUrlFunction.createFromTileUrlFunctions([
|
||||
ol.TileUrlFunction.createFromTemplate('a', tileGrid),
|
||||
ol.TileUrlFunction.createFromTemplate('b', tileGrid)
|
||||
var tileUrl = _ol_TileUrlFunction_.createFromTileUrlFunctions([
|
||||
_ol_TileUrlFunction_.createFromTemplate('a', tileGrid),
|
||||
_ol_TileUrlFunction_.createFromTemplate('b', tileGrid)
|
||||
]);
|
||||
var tileUrl1 = tileUrl([1, 0, 0]);
|
||||
var tileUrl2 = tileUrl([1, 0, 1]);
|
||||
|
||||
Reference in New Issue
Block a user