Use blocked scoped variables
In addition to using const and let, this also upgrades our linter config and removes lint (mostly whitespace).
This commit is contained in:
@@ -9,9 +9,9 @@ import TileGrid from '../../../../src/ol/tilegrid/TileGrid.js';
|
||||
|
||||
|
||||
describe('ol.tilegrid.TileGrid', function() {
|
||||
var resolutions;
|
||||
var origin;
|
||||
var tileSize;
|
||||
let resolutions;
|
||||
let origin;
|
||||
let tileSize;
|
||||
|
||||
beforeEach(function() {
|
||||
resolutions = [1000, 500, 250, 100];
|
||||
@@ -45,7 +45,7 @@ describe('ol.tilegrid.TileGrid', function() {
|
||||
|
||||
describe('create with out of order resolutions', function() {
|
||||
it('throws an exception', function() {
|
||||
var resolutions = [100, 25, 50, 10];
|
||||
const resolutions = [100, 25, 50, 10];
|
||||
expect(function() {
|
||||
return new TileGrid({
|
||||
resolutions: resolutions,
|
||||
@@ -155,7 +155,7 @@ describe('ol.tilegrid.TileGrid', function() {
|
||||
});
|
||||
|
||||
describe('create with origin', function() {
|
||||
var tileGrid;
|
||||
let tileGrid;
|
||||
beforeEach(function() {
|
||||
tileGrid = new TileGrid({
|
||||
origin: [10, 20],
|
||||
@@ -178,7 +178,7 @@ describe('ol.tilegrid.TileGrid', function() {
|
||||
});
|
||||
|
||||
describe('create with extent', function() {
|
||||
var tileGrid;
|
||||
let tileGrid;
|
||||
beforeEach(function() {
|
||||
tileGrid = new TileGrid({
|
||||
extent: [10, 20, 30, 40],
|
||||
@@ -192,7 +192,7 @@ describe('ol.tilegrid.TileGrid', function() {
|
||||
});
|
||||
|
||||
it('calculates full tile ranges from extent', function() {
|
||||
var fullTileRange = tileGrid.getFullTileRange(0);
|
||||
const fullTileRange = tileGrid.getFullTileRange(0);
|
||||
expect(fullTileRange.minX).to.equal(0);
|
||||
expect(fullTileRange.maxX).to.equal(1);
|
||||
expect(fullTileRange.minY).to.equal(-2);
|
||||
@@ -201,7 +201,7 @@ describe('ol.tilegrid.TileGrid', function() {
|
||||
});
|
||||
|
||||
describe('create with extent and sizes', function() {
|
||||
var tileGrid;
|
||||
let tileGrid;
|
||||
beforeEach(function() {
|
||||
tileGrid = new TileGrid({
|
||||
extent: [10, 20, 30, 40],
|
||||
@@ -216,7 +216,7 @@ describe('ol.tilegrid.TileGrid', function() {
|
||||
});
|
||||
|
||||
it('calculates full tile ranges from sizes', function() {
|
||||
var fullTileRange = tileGrid.getFullTileRange(0);
|
||||
const fullTileRange = tileGrid.getFullTileRange(0);
|
||||
expect(fullTileRange.minX).to.equal(0);
|
||||
expect(fullTileRange.maxX).to.equal(2);
|
||||
expect(fullTileRange.minY).to.equal(-3);
|
||||
@@ -225,7 +225,7 @@ describe('ol.tilegrid.TileGrid', function() {
|
||||
});
|
||||
|
||||
describe('create with top-left origin and sizes', function() {
|
||||
var tileGrid;
|
||||
let tileGrid;
|
||||
beforeEach(function() {
|
||||
tileGrid = new TileGrid({
|
||||
origin: [10, 40],
|
||||
@@ -236,14 +236,14 @@ describe('ol.tilegrid.TileGrid', function() {
|
||||
});
|
||||
|
||||
it('calculates correct minY and maxY for negative heights', function() {
|
||||
var fullTileRange = tileGrid.getFullTileRange(0);
|
||||
const fullTileRange = tileGrid.getFullTileRange(0);
|
||||
expect(fullTileRange.minY).to.equal(-3);
|
||||
expect(fullTileRange.maxY).to.equal(-1);
|
||||
});
|
||||
});
|
||||
|
||||
describe('create with bottom-left origin and sizes', function() {
|
||||
var tileGrid;
|
||||
let tileGrid;
|
||||
beforeEach(function() {
|
||||
tileGrid = new TileGrid({
|
||||
origin: [10, 10],
|
||||
@@ -254,7 +254,7 @@ describe('ol.tilegrid.TileGrid', function() {
|
||||
});
|
||||
|
||||
it('calculates correct minX and maxX for positive heights', function() {
|
||||
var fullTileRange = tileGrid.getFullTileRange(0);
|
||||
const fullTileRange = tileGrid.getFullTileRange(0);
|
||||
expect(fullTileRange.minY).to.equal(0);
|
||||
expect(fullTileRange.maxY).to.equal(2);
|
||||
});
|
||||
@@ -262,7 +262,7 @@ describe('ol.tilegrid.TileGrid', function() {
|
||||
|
||||
describe('create with extent and origin', function() {
|
||||
it('uses both origin and extent', function() {
|
||||
var tileGrid = new TileGrid({
|
||||
const tileGrid = new TileGrid({
|
||||
origin: [0, 0],
|
||||
extent: [10, 20, 30, 40],
|
||||
tileSize: 10,
|
||||
@@ -275,11 +275,11 @@ describe('ol.tilegrid.TileGrid', function() {
|
||||
|
||||
describe('createForExtent', function() {
|
||||
it('allows creation of tile grid from extent', function() {
|
||||
var extent = _ol_extent_.createOrUpdate(-100, -100, 100, 100);
|
||||
var grid = _ol_tilegrid_.createForExtent(extent);
|
||||
const extent = _ol_extent_.createOrUpdate(-100, -100, 100, 100);
|
||||
const grid = _ol_tilegrid_.createForExtent(extent);
|
||||
expect(grid).to.be.a(TileGrid);
|
||||
|
||||
var resolutions = grid.getResolutions();
|
||||
const resolutions = grid.getResolutions();
|
||||
expect(resolutions.length).to.be(DEFAULT_MAX_ZOOM + 1);
|
||||
expect(grid.getOrigin()).to.eql([-100, 100]);
|
||||
});
|
||||
@@ -287,7 +287,7 @@ describe('ol.tilegrid.TileGrid', function() {
|
||||
|
||||
describe('#zoomFactor_', function() {
|
||||
it('is set for a consistent zoom factor', function() {
|
||||
var grid = new TileGrid({
|
||||
const grid = new TileGrid({
|
||||
resolutions: [10, 5, 2.5, 1.25],
|
||||
origin: origin,
|
||||
tileSize: tileSize
|
||||
@@ -296,7 +296,7 @@ describe('ol.tilegrid.TileGrid', function() {
|
||||
});
|
||||
|
||||
it('is not set for an inconsistent zoom factor', function() {
|
||||
var grid = new TileGrid({
|
||||
const grid = new TileGrid({
|
||||
resolutions: [10, 5, 3, 1.25],
|
||||
origin: origin,
|
||||
tileSize: tileSize
|
||||
@@ -308,83 +308,83 @@ describe('ol.tilegrid.TileGrid', function() {
|
||||
describe('createForProjection', function() {
|
||||
|
||||
it('allows easier creation of a tile grid', function() {
|
||||
var projection = getProjection('EPSG:3857');
|
||||
var grid = _ol_tilegrid_.createForProjection(projection);
|
||||
const projection = getProjection('EPSG:3857');
|
||||
const grid = _ol_tilegrid_.createForProjection(projection);
|
||||
expect(grid).to.be.a(TileGrid);
|
||||
|
||||
var resolutions = grid.getResolutions();
|
||||
const resolutions = grid.getResolutions();
|
||||
expect(resolutions.length).to.be(DEFAULT_MAX_ZOOM + 1);
|
||||
});
|
||||
|
||||
it('accepts a number of zoom levels', function() {
|
||||
var projection = getProjection('EPSG:3857');
|
||||
var grid = _ol_tilegrid_.createForProjection(projection, 18);
|
||||
const projection = getProjection('EPSG:3857');
|
||||
const grid = _ol_tilegrid_.createForProjection(projection, 18);
|
||||
expect(grid).to.be.a(TileGrid);
|
||||
|
||||
var resolutions = grid.getResolutions();
|
||||
const resolutions = grid.getResolutions();
|
||||
expect(resolutions.length).to.be(19);
|
||||
});
|
||||
|
||||
it('accepts a big number of zoom levels', function() {
|
||||
var projection = getProjection('EPSG:3857');
|
||||
var grid = _ol_tilegrid_.createForProjection(projection, 23);
|
||||
const projection = getProjection('EPSG:3857');
|
||||
const grid = _ol_tilegrid_.createForProjection(projection, 23);
|
||||
expect(grid).to.be.a(TileGrid);
|
||||
|
||||
var resolutions = grid.getResolutions();
|
||||
const resolutions = grid.getResolutions();
|
||||
expect(resolutions.length).to.be(24);
|
||||
});
|
||||
|
||||
it('works for projections unknown to the client', function() {
|
||||
var projection = new Projection(
|
||||
{code: 'EPSG:31287', units: 'm'});
|
||||
var grid = _ol_tilegrid_.createForProjection(projection);
|
||||
var resolutions = grid.getResolutions();
|
||||
const projection = new Projection(
|
||||
{code: 'EPSG:31287', units: 'm'});
|
||||
const grid = _ol_tilegrid_.createForProjection(projection);
|
||||
const resolutions = grid.getResolutions();
|
||||
expect(resolutions[5]).to.be(
|
||||
360 * METERS_PER_UNIT['degrees'] /
|
||||
360 * METERS_PER_UNIT['degrees'] /
|
||||
DEFAULT_TILE_SIZE / Math.pow(2, 5));
|
||||
});
|
||||
|
||||
it('assumes origin is top-left', function() {
|
||||
var projection = getProjection('EPSG:3857');
|
||||
var grid = _ol_tilegrid_.createForProjection(projection);
|
||||
var origin = grid.getOrigin();
|
||||
var half = _ol_proj_EPSG3857_.HALF_SIZE;
|
||||
const projection = getProjection('EPSG:3857');
|
||||
const grid = _ol_tilegrid_.createForProjection(projection);
|
||||
const origin = grid.getOrigin();
|
||||
const half = _ol_proj_EPSG3857_.HALF_SIZE;
|
||||
expect(origin).to.eql([-half, half]);
|
||||
});
|
||||
|
||||
it('accepts bottom-left as corner', function() {
|
||||
var projection = getProjection('EPSG:3857');
|
||||
var grid = _ol_tilegrid_.createForProjection(
|
||||
projection, undefined, undefined, 'bottom-left');
|
||||
var origin = grid.getOrigin();
|
||||
var half = _ol_proj_EPSG3857_.HALF_SIZE;
|
||||
const projection = getProjection('EPSG:3857');
|
||||
const grid = _ol_tilegrid_.createForProjection(
|
||||
projection, undefined, undefined, 'bottom-left');
|
||||
const origin = grid.getOrigin();
|
||||
const half = _ol_proj_EPSG3857_.HALF_SIZE;
|
||||
expect(origin).to.eql([-half, -half]);
|
||||
});
|
||||
|
||||
it('accepts bottom-right as corner', function() {
|
||||
var projection = getProjection('EPSG:3857');
|
||||
var grid = _ol_tilegrid_.createForProjection(
|
||||
projection, undefined, undefined, 'bottom-right');
|
||||
var origin = grid.getOrigin();
|
||||
var half = _ol_proj_EPSG3857_.HALF_SIZE;
|
||||
const projection = getProjection('EPSG:3857');
|
||||
const grid = _ol_tilegrid_.createForProjection(
|
||||
projection, undefined, undefined, 'bottom-right');
|
||||
const origin = grid.getOrigin();
|
||||
const half = _ol_proj_EPSG3857_.HALF_SIZE;
|
||||
expect(origin).to.eql([half, -half]);
|
||||
});
|
||||
|
||||
it('accepts top-left as corner', function() {
|
||||
var projection = getProjection('EPSG:3857');
|
||||
var grid = _ol_tilegrid_.createForProjection(
|
||||
projection, undefined, undefined, 'top-left');
|
||||
var origin = grid.getOrigin();
|
||||
var half = _ol_proj_EPSG3857_.HALF_SIZE;
|
||||
const projection = getProjection('EPSG:3857');
|
||||
const grid = _ol_tilegrid_.createForProjection(
|
||||
projection, undefined, undefined, 'top-left');
|
||||
const origin = grid.getOrigin();
|
||||
const half = _ol_proj_EPSG3857_.HALF_SIZE;
|
||||
expect(origin).to.eql([-half, half]);
|
||||
});
|
||||
|
||||
it('accepts top-right as corner', function() {
|
||||
var projection = getProjection('EPSG:3857');
|
||||
var grid = _ol_tilegrid_.createForProjection(
|
||||
projection, undefined, undefined, 'top-right');
|
||||
var origin = grid.getOrigin();
|
||||
var half = _ol_proj_EPSG3857_.HALF_SIZE;
|
||||
const projection = getProjection('EPSG:3857');
|
||||
const grid = _ol_tilegrid_.createForProjection(
|
||||
projection, undefined, undefined, 'top-right');
|
||||
const origin = grid.getOrigin();
|
||||
const half = _ol_proj_EPSG3857_.HALF_SIZE;
|
||||
expect(origin).to.eql([half, half]);
|
||||
});
|
||||
|
||||
@@ -393,16 +393,16 @@ describe('ol.tilegrid.TileGrid', function() {
|
||||
describe('createXYZ()', function() {
|
||||
|
||||
it('uses defaults', function() {
|
||||
var tileGrid = _ol_tilegrid_.createXYZ();
|
||||
const tileGrid = _ol_tilegrid_.createXYZ();
|
||||
expect(tileGrid.getExtent()).to.eql(
|
||||
getProjection('EPSG:3857').getExtent());
|
||||
getProjection('EPSG:3857').getExtent());
|
||||
expect(tileGrid.getMinZoom()).to.equal(0);
|
||||
expect(tileGrid.getMaxZoom()).to.equal(DEFAULT_MAX_ZOOM);
|
||||
expect(tileGrid.getTileSize()).to.equal(DEFAULT_TILE_SIZE);
|
||||
});
|
||||
|
||||
it('respects configuration options', function() {
|
||||
var tileGrid = _ol_tilegrid_.createXYZ({
|
||||
const tileGrid = _ol_tilegrid_.createXYZ({
|
||||
extent: [10, 20, 30, 40],
|
||||
minZoom: 1,
|
||||
maxZoom: 2,
|
||||
@@ -419,19 +419,19 @@ describe('ol.tilegrid.TileGrid', function() {
|
||||
describe('getForProjection', function() {
|
||||
|
||||
it('gets the default tile grid for a projection', function() {
|
||||
var projection = getProjection('EPSG:3857');
|
||||
var grid = _ol_tilegrid_.getForProjection(projection);
|
||||
const projection = getProjection('EPSG:3857');
|
||||
const grid = _ol_tilegrid_.getForProjection(projection);
|
||||
expect(grid).to.be.a(TileGrid);
|
||||
|
||||
var resolutions = grid.getResolutions();
|
||||
const resolutions = grid.getResolutions();
|
||||
expect(resolutions.length).to.be(DEFAULT_MAX_ZOOM + 1);
|
||||
expect(grid.getTileSize()).to.eql(256);
|
||||
});
|
||||
|
||||
it('stores the default tile grid on a projection', function() {
|
||||
var projection = getProjection('EPSG:3857');
|
||||
var grid = _ol_tilegrid_.getForProjection(projection);
|
||||
var gridAgain = _ol_tilegrid_.getForProjection(projection);
|
||||
const projection = getProjection('EPSG:3857');
|
||||
const grid = _ol_tilegrid_.getForProjection(projection);
|
||||
const gridAgain = _ol_tilegrid_.getForProjection(projection);
|
||||
|
||||
expect(grid).to.be(gridAgain);
|
||||
});
|
||||
@@ -440,14 +440,14 @@ describe('ol.tilegrid.TileGrid', function() {
|
||||
|
||||
describe('#getTileCoordChildTileRange()', function() {
|
||||
|
||||
var tileGrid;
|
||||
let tileGrid;
|
||||
beforeEach(function() {
|
||||
tileGrid = _ol_tilegrid_.createForExtent(
|
||||
getProjection('EPSG:3857').getExtent(), 22);
|
||||
getProjection('EPSG:3857').getExtent(), 22);
|
||||
});
|
||||
|
||||
it('returns the tile range for one zoom level deeper', function() {
|
||||
var range;
|
||||
let range;
|
||||
|
||||
range = tileGrid.getTileCoordChildTileRange([0, 0, 0]);
|
||||
expect(range.minX).to.be(0);
|
||||
@@ -481,8 +481,8 @@ describe('ol.tilegrid.TileGrid', function() {
|
||||
});
|
||||
|
||||
it('returns null for z > maxZoom', function() {
|
||||
var max = tileGrid.maxZoom;
|
||||
var range = tileGrid.getTileCoordChildTileRange([max + 1, 0, 0]);
|
||||
const max = tileGrid.maxZoom;
|
||||
const range = tileGrid.getTileCoordChildTileRange([max + 1, 0, 0]);
|
||||
expect(range).to.be(null);
|
||||
});
|
||||
|
||||
@@ -490,25 +490,26 @@ describe('ol.tilegrid.TileGrid', function() {
|
||||
|
||||
describe('#forEachTileCoordParentTileRange()', function() {
|
||||
|
||||
var tileGrid;
|
||||
let tileGrid;
|
||||
beforeEach(function() {
|
||||
tileGrid = _ol_tilegrid_.createForExtent(
|
||||
getProjection('EPSG:3857').getExtent(), 22);
|
||||
getProjection('EPSG:3857').getExtent(), 22);
|
||||
});
|
||||
|
||||
it('iterates as expected', function() {
|
||||
|
||||
var tileCoord = [5, 11, 21];
|
||||
var zs = [], tileRanges = [];
|
||||
const tileCoord = [5, 11, 21];
|
||||
const zs = [];
|
||||
const tileRanges = [];
|
||||
tileGrid.forEachTileCoordParentTileRange(
|
||||
tileCoord,
|
||||
function(z, tileRange) {
|
||||
zs.push(z);
|
||||
tileRanges.push(new TileRange(
|
||||
tileRange.minX, tileRange.maxX,
|
||||
tileRange.minY, tileRange.maxY));
|
||||
return false;
|
||||
});
|
||||
tileCoord,
|
||||
function(z, tileRange) {
|
||||
zs.push(z);
|
||||
tileRanges.push(new TileRange(
|
||||
tileRange.minX, tileRange.maxX,
|
||||
tileRange.minY, tileRange.maxY));
|
||||
return false;
|
||||
});
|
||||
|
||||
expect(zs.length).to.eql(5);
|
||||
expect(tileRanges.length).to.eql(5);
|
||||
@@ -549,10 +550,10 @@ describe('ol.tilegrid.TileGrid', function() {
|
||||
|
||||
describe('getResolution', function() {
|
||||
|
||||
var tileGrid;
|
||||
let tileGrid;
|
||||
beforeEach(function() {
|
||||
tileGrid = _ol_tilegrid_.createForExtent(
|
||||
getProjection('EPSG:3857').getExtent(), 22);
|
||||
getProjection('EPSG:3857').getExtent(), 22);
|
||||
});
|
||||
|
||||
it('returns the correct resolution at the equator', function() {
|
||||
@@ -586,12 +587,12 @@ describe('ol.tilegrid.TileGrid', function() {
|
||||
describe('Y North, X East', function() {
|
||||
it('returns the expected TileCoord', function() {
|
||||
origin = [0, 0];
|
||||
var tileGrid = new TileGrid({
|
||||
const tileGrid = new TileGrid({
|
||||
resolutions: resolutions,
|
||||
origin: origin,
|
||||
tileSize: tileSize
|
||||
});
|
||||
var tileCoord;
|
||||
let tileCoord;
|
||||
|
||||
tileCoord = tileGrid.getTileCoordForCoordAndZ([0, 0], 3);
|
||||
expect(tileCoord[0]).to.eql(3);
|
||||
@@ -618,12 +619,12 @@ describe('ol.tilegrid.TileGrid', function() {
|
||||
describe('Y South, X East', function() {
|
||||
it('returns the expected TileCoord', function() {
|
||||
origin = [0, 100000];
|
||||
var tileGrid = new TileGrid({
|
||||
const tileGrid = new TileGrid({
|
||||
resolutions: resolutions,
|
||||
origin: origin,
|
||||
tileSize: tileSize
|
||||
});
|
||||
var tileCoord;
|
||||
let tileCoord;
|
||||
|
||||
tileCoord = tileGrid.getTileCoordForCoordAndZ([0, 0], 3);
|
||||
expect(tileCoord[0]).to.eql(3);
|
||||
@@ -650,15 +651,15 @@ describe('ol.tilegrid.TileGrid', function() {
|
||||
|
||||
describe('getTileCoordForCoordAndResolution', function() {
|
||||
it('returns the expected TileCoord', function() {
|
||||
var tileSize = 256;
|
||||
var tileGrid = new TileGrid({
|
||||
const tileSize = 256;
|
||||
const tileGrid = new TileGrid({
|
||||
resolutions: [10],
|
||||
origin: origin,
|
||||
tileSize: tileSize
|
||||
});
|
||||
|
||||
var coordinate;
|
||||
var tileCoord;
|
||||
let coordinate;
|
||||
let tileCoord;
|
||||
|
||||
// gets the first tile at the origin
|
||||
coordinate = [0, 0];
|
||||
@@ -728,24 +729,24 @@ describe('ol.tilegrid.TileGrid', function() {
|
||||
|
||||
describe('getTileCoordForXYAndResolution_', function() {
|
||||
it('returns higher tile coord for intersections by default', function() {
|
||||
var tileGrid = new TileGrid({
|
||||
const tileGrid = new TileGrid({
|
||||
resolutions: resolutions,
|
||||
origin: origin,
|
||||
tileSize: tileSize
|
||||
});
|
||||
|
||||
var tileCoord;
|
||||
let tileCoord;
|
||||
|
||||
// gets higher tile for edge intersection
|
||||
tileCoord = tileGrid.getTileCoordForXYAndResolution_(
|
||||
0, 0, 100, false);
|
||||
0, 0, 100, false);
|
||||
expect(tileCoord[0]).to.eql(3);
|
||||
expect(tileCoord[1]).to.eql(0);
|
||||
expect(tileCoord[2]).to.eql(0);
|
||||
|
||||
// gets higher tile for edge intersection
|
||||
tileCoord = tileGrid.getTileCoordForXYAndResolution_(
|
||||
100000, 100000, 100, false);
|
||||
100000, 100000, 100, false);
|
||||
expect(tileCoord[0]).to.eql(3);
|
||||
expect(tileCoord[1]).to.eql(10);
|
||||
expect(tileCoord[2]).to.eql(10);
|
||||
@@ -753,24 +754,24 @@ describe('ol.tilegrid.TileGrid', function() {
|
||||
});
|
||||
|
||||
it('handles alt intersection policy', function() {
|
||||
var tileGrid = new TileGrid({
|
||||
const tileGrid = new TileGrid({
|
||||
resolutions: resolutions,
|
||||
origin: origin,
|
||||
tileSize: tileSize
|
||||
});
|
||||
|
||||
var tileCoord;
|
||||
let tileCoord;
|
||||
|
||||
// can get lower tile for edge intersection
|
||||
tileCoord = tileGrid.getTileCoordForXYAndResolution_(
|
||||
0, 0, 100, true);
|
||||
0, 0, 100, true);
|
||||
expect(tileCoord[0]).to.eql(3);
|
||||
expect(tileCoord[1]).to.eql(-1);
|
||||
expect(tileCoord[2]).to.eql(-1);
|
||||
|
||||
// gets higher tile for edge intersection
|
||||
tileCoord = tileGrid.getTileCoordForXYAndResolution_(
|
||||
100000, 100000, 100, true);
|
||||
100000, 100000, 100, true);
|
||||
expect(tileCoord[0]).to.eql(3);
|
||||
expect(tileCoord[1]).to.eql(9);
|
||||
expect(tileCoord[2]).to.eql(9);
|
||||
@@ -781,12 +782,12 @@ describe('ol.tilegrid.TileGrid', function() {
|
||||
|
||||
describe('getTileCoordCenter', function() {
|
||||
it('returns the expected center', function() {
|
||||
var tileGrid = new TileGrid({
|
||||
const tileGrid = new TileGrid({
|
||||
resolutions: resolutions,
|
||||
origin: origin,
|
||||
tileSize: tileSize
|
||||
});
|
||||
var center;
|
||||
let center;
|
||||
|
||||
center = tileGrid.getTileCoordCenter([0, 0, 0]);
|
||||
expect(center[0]).to.eql(50000);
|
||||
@@ -804,12 +805,12 @@ describe('ol.tilegrid.TileGrid', function() {
|
||||
|
||||
describe('getTileCoordExtent', function() {
|
||||
it('returns the expected extend', function() {
|
||||
var tileGrid = new TileGrid({
|
||||
const tileGrid = new TileGrid({
|
||||
resolutions: resolutions,
|
||||
origin: origin,
|
||||
tileSize: tileSize
|
||||
});
|
||||
var tileCoordExtent;
|
||||
let tileCoordExtent;
|
||||
|
||||
tileCoordExtent = tileGrid.getTileCoordExtent([0, 0, 0]);
|
||||
expect(tileCoordExtent[0]).to.eql(0);
|
||||
@@ -833,13 +834,13 @@ describe('ol.tilegrid.TileGrid', function() {
|
||||
|
||||
describe('getTileRangeForExtentAndZ', function() {
|
||||
it('returns the expected TileRange', function() {
|
||||
var tileGrid = new TileGrid({
|
||||
const tileGrid = new TileGrid({
|
||||
resolutions: resolutions,
|
||||
origin: origin,
|
||||
tileSize: tileSize
|
||||
});
|
||||
var e = [45000, 5000, 55000, 15000];
|
||||
var tileRange;
|
||||
const e = [45000, 5000, 55000, 15000];
|
||||
let tileRange;
|
||||
|
||||
tileRange = tileGrid.getTileRangeForExtentAndZ(e, 0);
|
||||
expect(tileRange.minY).to.eql(0);
|
||||
@@ -869,11 +870,11 @@ describe('ol.tilegrid.TileGrid', function() {
|
||||
|
||||
describe('getTileSize', function() {
|
||||
|
||||
var resolutions = [1000, 500, 250, 100];
|
||||
var origin = [0, 0];
|
||||
const resolutions = [1000, 500, 250, 100];
|
||||
const origin = [0, 0];
|
||||
|
||||
it('works with one tile size as number', function() {
|
||||
var tileGrid = new TileGrid({
|
||||
const tileGrid = new TileGrid({
|
||||
tileSize: 256,
|
||||
resolutions: resolutions,
|
||||
origin: origin
|
||||
@@ -883,7 +884,7 @@ describe('ol.tilegrid.TileGrid', function() {
|
||||
});
|
||||
|
||||
it('works with one tile size as array', function() {
|
||||
var tileGrid = new TileGrid({
|
||||
const tileGrid = new TileGrid({
|
||||
tileSize: [512, 256],
|
||||
resolutions: resolutions,
|
||||
origin: origin
|
||||
@@ -893,7 +894,7 @@ describe('ol.tilegrid.TileGrid', function() {
|
||||
});
|
||||
|
||||
it('works with multiple tile sizes as number', function() {
|
||||
var tileGrid = new TileGrid({
|
||||
const tileGrid = new TileGrid({
|
||||
tileSizes: [256, 256, 256, 512],
|
||||
resolutions: resolutions,
|
||||
origin: origin
|
||||
@@ -903,7 +904,7 @@ describe('ol.tilegrid.TileGrid', function() {
|
||||
});
|
||||
|
||||
it('works with multiple tile sizes as array', function() {
|
||||
var tileGrid = new TileGrid({
|
||||
const tileGrid = new TileGrid({
|
||||
tileSizes: [[512, 256], [512, 256], [512, 256], [640, 320]],
|
||||
resolutions: resolutions,
|
||||
origin: origin
|
||||
@@ -916,8 +917,8 @@ describe('ol.tilegrid.TileGrid', function() {
|
||||
|
||||
describe('forEachTileCoord', function() {
|
||||
it('calls the provided function with each tile coordinate', function() {
|
||||
var tileGrid = _ol_tilegrid_.createXYZ({extent: [-180, -90, 180, 90]});
|
||||
var tileCoords = [];
|
||||
const tileGrid = _ol_tilegrid_.createXYZ({extent: [-180, -90, 180, 90]});
|
||||
const tileCoords = [];
|
||||
tileGrid.forEachTileCoord([15, 47, 16, 48], 8, function(tileCoord) {
|
||||
tileCoords.push(tileCoord);
|
||||
});
|
||||
@@ -932,20 +933,21 @@ describe('ol.tilegrid.TileGrid', function() {
|
||||
|
||||
describe('forEachTileCoordParentTileRange', function() {
|
||||
it('iterates as expected', function() {
|
||||
var tileGrid = new TileGrid({
|
||||
const tileGrid = new TileGrid({
|
||||
resolutions: resolutions,
|
||||
origin: origin,
|
||||
tileSize: tileSize
|
||||
});
|
||||
var zs = [], tileRanges = [];
|
||||
const zs = [];
|
||||
const tileRanges = [];
|
||||
|
||||
tileGrid.forEachTileCoordParentTileRange(
|
||||
[3, 7, 3],
|
||||
function(z, tileRange) {
|
||||
zs.push(z);
|
||||
tileRanges.push(tileRange);
|
||||
return false;
|
||||
});
|
||||
[3, 7, 3],
|
||||
function(z, tileRange) {
|
||||
zs.push(z);
|
||||
tileRanges.push(tileRange);
|
||||
return false;
|
||||
});
|
||||
|
||||
expect(zs.length).to.eql(3);
|
||||
expect(tileRanges.length).to.eql(3);
|
||||
@@ -972,7 +974,7 @@ describe('ol.tilegrid.TileGrid', function() {
|
||||
|
||||
describe('getZForResolution (exact)', function() {
|
||||
it('returns the expected z value', function() {
|
||||
var tileGrid = new TileGrid({
|
||||
const tileGrid = new TileGrid({
|
||||
resolutions: resolutions,
|
||||
origin: origin,
|
||||
tileSize: tileSize
|
||||
@@ -987,7 +989,7 @@ describe('ol.tilegrid.TileGrid', function() {
|
||||
|
||||
describe('getZForResolution (approximate)', function() {
|
||||
it('returns the expected z value', function() {
|
||||
var tileGrid = new TileGrid({
|
||||
const tileGrid = new TileGrid({
|
||||
resolutions: resolutions,
|
||||
origin: origin,
|
||||
tileSize: tileSize
|
||||
@@ -1011,7 +1013,7 @@ describe('ol.tilegrid.TileGrid', function() {
|
||||
|
||||
describe('getZForResolution (lower)', function() {
|
||||
it('returns the expected z value', function() {
|
||||
var tileGrid = new TileGrid({
|
||||
const tileGrid = new TileGrid({
|
||||
resolutions: resolutions,
|
||||
origin: origin,
|
||||
tileSize: tileSize
|
||||
@@ -1035,7 +1037,7 @@ describe('ol.tilegrid.TileGrid', function() {
|
||||
|
||||
describe('getZForResolution (higher)', function() {
|
||||
it('returns the expected z value', function() {
|
||||
var tileGrid = new TileGrid({
|
||||
const tileGrid = new TileGrid({
|
||||
resolutions: resolutions,
|
||||
origin: origin,
|
||||
tileSize: tileSize
|
||||
|
||||
+107
-107
@@ -5,8 +5,8 @@ import {createFromCapabilitiesMatrixSet} from '../../../../src/ol/tilegrid/WMTS.
|
||||
describe('ol.tilegrid.WMTS', function() {
|
||||
|
||||
describe('when creating tileGrid from capabilities', function() {
|
||||
var parser = new _ol_format_WMTSCapabilities_();
|
||||
var capabilities;
|
||||
const parser = new _ol_format_WMTSCapabilities_();
|
||||
let capabilities;
|
||||
before(function(done) {
|
||||
afterLoadText('spec/ol/format/wmts/ogcsample.xml', function(xml) {
|
||||
try {
|
||||
@@ -19,9 +19,101 @@ describe('ol.tilegrid.WMTS', function() {
|
||||
});
|
||||
|
||||
it('can create tileGrid for EPSG:3857',
|
||||
function() {
|
||||
const matrixSetObj = capabilities.Contents.TileMatrixSet[0];
|
||||
const tileGrid = createFromCapabilitiesMatrixSet(matrixSetObj);
|
||||
expect(tileGrid.matrixIds_).to.be.an('array');
|
||||
expect(tileGrid.matrixIds_).to.have.length(20);
|
||||
expect(tileGrid.matrixIds_).to.eql([
|
||||
'0', '1', '2', '3', '4', '5', '6', '7', '8', '9', '10', '11',
|
||||
'12', '13', '14', '15', '16', '17', '18', '19'
|
||||
]);
|
||||
|
||||
expect(tileGrid.resolutions_).to.be.an('array');
|
||||
expect(tileGrid.resolutions_).to.have.length(20);
|
||||
expect(tileGrid.resolutions_).to.eql([
|
||||
156543.03392811998, 78271.51696419998, 39135.758481959994,
|
||||
19567.879241008, 9783.939620504, 4891.969810252, 2445.984905126,
|
||||
1222.9924525644, 611.4962262807999, 305.74811314039994,
|
||||
152.87405657047998, 76.43702828523999, 38.21851414248,
|
||||
19.109257071295996, 9.554628535647998, 4.777314267823999,
|
||||
2.3886571339119995, 1.1943285669559998, 0.5971642834779999,
|
||||
0.29858214174039993
|
||||
]);
|
||||
|
||||
expect(tileGrid.origins_).to.be.an('array');
|
||||
expect(tileGrid.origins_).to.have.length(20);
|
||||
expect(tileGrid.origins_).to.eql(
|
||||
Array.apply(null, Array(20)).map(Array.prototype.valueOf,
|
||||
[-20037508.3428, 20037508.3428]));
|
||||
|
||||
expect(tileGrid.tileSizes_).to.be.an('array');
|
||||
expect(tileGrid.tileSizes_).to.have.length(20);
|
||||
expect(tileGrid.tileSizes_).to.eql(
|
||||
Array.apply(null, Array(20)).map(Number.prototype.valueOf, 256));
|
||||
|
||||
});
|
||||
});
|
||||
|
||||
|
||||
describe('when creating tileGrid from capabilities with and without TileMatrixSetLimits',
|
||||
function() {
|
||||
const parser = new _ol_format_WMTSCapabilities_();
|
||||
let capabilities;
|
||||
before(function(done) {
|
||||
afterLoadText('spec/ol/format/wmts/ign.xml', function(xml) {
|
||||
try {
|
||||
capabilities = parser.read(xml);
|
||||
} catch (e) {
|
||||
done(e);
|
||||
}
|
||||
done();
|
||||
});
|
||||
});
|
||||
|
||||
it('can create tileGrid for EPSG:3857 without matrixLimits',
|
||||
function() {
|
||||
var matrixSetObj = capabilities.Contents.TileMatrixSet[0];
|
||||
var tileGrid = createFromCapabilitiesMatrixSet(matrixSetObj);
|
||||
const matrixSetObj = capabilities.Contents.TileMatrixSet[0];
|
||||
const tileGrid = createFromCapabilitiesMatrixSet(matrixSetObj);
|
||||
expect(tileGrid.matrixIds_).to.be.an('array');
|
||||
expect(tileGrid.matrixIds_).to.have.length(22);
|
||||
expect(tileGrid.matrixIds_).to.eql([
|
||||
'0', '1', '2', '3', '4', '5', '6', '7', '8', '9', '10', '11',
|
||||
'12', '13', '14', '15', '16', '17', '18', '19', '20', '21'
|
||||
]);
|
||||
|
||||
expect(tileGrid.resolutions_).to.be.an('array');
|
||||
expect(tileGrid.resolutions_).to.have.length(22);
|
||||
expect(tileGrid.resolutions_).to.eql([
|
||||
156543.033928041, 78271.51696402048, 39135.758482010235,
|
||||
19567.87924100512, 9783.93962050256, 4891.96981025128,
|
||||
2445.98490512564, 1222.99245256282, 611.49622628141,
|
||||
305.7481131407048, 152.8740565703525, 76.43702828517624,
|
||||
38.21851414258813, 19.10925707129406, 9.554628535647032,
|
||||
4.777314267823516, 2.388657133911758, 1.194328566955879,
|
||||
0.5971642834779395, 0.2985821417389697, 0.1492910708694849,
|
||||
0.0746455354347424
|
||||
]);
|
||||
|
||||
expect(tileGrid.origins_).to.be.an('array');
|
||||
expect(tileGrid.origins_).to.have.length(22);
|
||||
expect(tileGrid.origins_).to.eql(
|
||||
Array.apply(null, Array(22)).map(Array.prototype.valueOf,
|
||||
[-20037508, 20037508]));
|
||||
|
||||
expect(tileGrid.tileSizes_).to.be.an('array');
|
||||
expect(tileGrid.tileSizes_).to.have.length(22);
|
||||
expect(tileGrid.tileSizes_).to.eql(
|
||||
Array.apply(null, Array(22)).map(Number.prototype.valueOf, 256));
|
||||
|
||||
});
|
||||
|
||||
it('can create tileGrid for EPSG:3857 with matrixLimits',
|
||||
function() {
|
||||
const matrixSetObj = capabilities.Contents.TileMatrixSet[0];
|
||||
const matrixLimitArray = capabilities.Contents.Layer[0]
|
||||
.TileMatrixSetLink[0].TileMatrixSetLimits;
|
||||
const tileGrid = createFromCapabilitiesMatrixSet(matrixSetObj, undefined, matrixLimitArray);
|
||||
expect(tileGrid.matrixIds_).to.be.an('array');
|
||||
expect(tileGrid.matrixIds_).to.have.length(20);
|
||||
expect(tileGrid.matrixIds_).to.eql([
|
||||
@@ -32,118 +124,26 @@ describe('ol.tilegrid.WMTS', function() {
|
||||
expect(tileGrid.resolutions_).to.be.an('array');
|
||||
expect(tileGrid.resolutions_).to.have.length(20);
|
||||
expect(tileGrid.resolutions_).to.eql([
|
||||
156543.03392811998, 78271.51696419998, 39135.758481959994,
|
||||
19567.879241008, 9783.939620504, 4891.969810252, 2445.984905126,
|
||||
1222.9924525644, 611.4962262807999, 305.74811314039994,
|
||||
152.87405657047998, 76.43702828523999, 38.21851414248,
|
||||
19.109257071295996, 9.554628535647998, 4.777314267823999,
|
||||
2.3886571339119995, 1.1943285669559998, 0.5971642834779999,
|
||||
0.29858214174039993
|
||||
156543.033928041, 78271.51696402048, 39135.758482010235,
|
||||
19567.87924100512, 9783.93962050256, 4891.96981025128,
|
||||
2445.98490512564, 1222.99245256282, 611.49622628141,
|
||||
305.7481131407048, 152.8740565703525, 76.43702828517624,
|
||||
38.21851414258813, 19.10925707129406, 9.554628535647032,
|
||||
4.777314267823516, 2.388657133911758, 1.194328566955879,
|
||||
0.5971642834779395, 0.2985821417389697
|
||||
]);
|
||||
|
||||
expect(tileGrid.origins_).to.be.an('array');
|
||||
expect(tileGrid.origins_).to.have.length(20);
|
||||
expect(tileGrid.origins_).to.eql(
|
||||
Array.apply(null, Array(20)).map(Array.prototype.valueOf,
|
||||
[-20037508.3428, 20037508.3428]));
|
||||
Array.apply(null, Array(20)).map(Array.prototype.valueOf,
|
||||
[-20037508, 20037508]));
|
||||
|
||||
expect(tileGrid.tileSizes_).to.be.an('array');
|
||||
expect(tileGrid.tileSizes_).to.have.length(20);
|
||||
expect(tileGrid.tileSizes_).to.eql(
|
||||
Array.apply(null, Array(20)).map(Number.prototype.valueOf, 256));
|
||||
Array.apply(null, Array(20)).map(Number.prototype.valueOf, 256));
|
||||
|
||||
});
|
||||
});
|
||||
|
||||
|
||||
describe('when creating tileGrid from capabilities with and without TileMatrixSetLimits',
|
||||
function() {
|
||||
var parser = new _ol_format_WMTSCapabilities_();
|
||||
var capabilities;
|
||||
before(function(done) {
|
||||
afterLoadText('spec/ol/format/wmts/ign.xml', function(xml) {
|
||||
try {
|
||||
capabilities = parser.read(xml);
|
||||
} catch (e) {
|
||||
done(e);
|
||||
}
|
||||
done();
|
||||
});
|
||||
});
|
||||
|
||||
it('can create tileGrid for EPSG:3857 without matrixLimits',
|
||||
function() {
|
||||
var matrixSetObj = capabilities.Contents.TileMatrixSet[0];
|
||||
var tileGrid = createFromCapabilitiesMatrixSet(matrixSetObj);
|
||||
expect(tileGrid.matrixIds_).to.be.an('array');
|
||||
expect(tileGrid.matrixIds_).to.have.length(22);
|
||||
expect(tileGrid.matrixIds_).to.eql([
|
||||
'0', '1', '2', '3', '4', '5', '6', '7', '8', '9', '10', '11',
|
||||
'12', '13', '14', '15', '16', '17', '18', '19', '20', '21'
|
||||
]);
|
||||
|
||||
expect(tileGrid.resolutions_).to.be.an('array');
|
||||
expect(tileGrid.resolutions_).to.have.length(22);
|
||||
expect(tileGrid.resolutions_).to.eql([
|
||||
156543.033928041, 78271.51696402048, 39135.758482010235,
|
||||
19567.87924100512, 9783.93962050256, 4891.96981025128,
|
||||
2445.98490512564, 1222.99245256282, 611.49622628141,
|
||||
305.7481131407048, 152.8740565703525, 76.43702828517624,
|
||||
38.21851414258813, 19.10925707129406, 9.554628535647032,
|
||||
4.777314267823516, 2.388657133911758, 1.194328566955879,
|
||||
0.5971642834779395, 0.2985821417389697, 0.1492910708694849,
|
||||
0.0746455354347424
|
||||
]);
|
||||
|
||||
expect(tileGrid.origins_).to.be.an('array');
|
||||
expect(tileGrid.origins_).to.have.length(22);
|
||||
expect(tileGrid.origins_).to.eql(
|
||||
Array.apply(null, Array(22)).map(Array.prototype.valueOf,
|
||||
[-20037508, 20037508]));
|
||||
|
||||
expect(tileGrid.tileSizes_).to.be.an('array');
|
||||
expect(tileGrid.tileSizes_).to.have.length(22);
|
||||
expect(tileGrid.tileSizes_).to.eql(
|
||||
Array.apply(null, Array(22)).map(Number.prototype.valueOf, 256));
|
||||
|
||||
});
|
||||
|
||||
it('can create tileGrid for EPSG:3857 with matrixLimits',
|
||||
function() {
|
||||
var matrixSetObj = capabilities.Contents.TileMatrixSet[0];
|
||||
var matrixLimitArray = capabilities.Contents.Layer[0]
|
||||
.TileMatrixSetLink[0].TileMatrixSetLimits;
|
||||
var tileGrid = createFromCapabilitiesMatrixSet(matrixSetObj, undefined, matrixLimitArray);
|
||||
expect(tileGrid.matrixIds_).to.be.an('array');
|
||||
expect(tileGrid.matrixIds_).to.have.length(20);
|
||||
expect(tileGrid.matrixIds_).to.eql([
|
||||
'0', '1', '2', '3', '4', '5', '6', '7', '8', '9', '10', '11',
|
||||
'12', '13', '14', '15', '16', '17', '18', '19'
|
||||
]);
|
||||
|
||||
expect(tileGrid.resolutions_).to.be.an('array');
|
||||
expect(tileGrid.resolutions_).to.have.length(20);
|
||||
expect(tileGrid.resolutions_).to.eql([
|
||||
156543.033928041, 78271.51696402048, 39135.758482010235,
|
||||
19567.87924100512, 9783.93962050256, 4891.96981025128,
|
||||
2445.98490512564, 1222.99245256282, 611.49622628141,
|
||||
305.7481131407048, 152.8740565703525, 76.43702828517624,
|
||||
38.21851414258813, 19.10925707129406, 9.554628535647032,
|
||||
4.777314267823516, 2.388657133911758, 1.194328566955879,
|
||||
0.5971642834779395, 0.2985821417389697
|
||||
]);
|
||||
|
||||
expect(tileGrid.origins_).to.be.an('array');
|
||||
expect(tileGrid.origins_).to.have.length(20);
|
||||
expect(tileGrid.origins_).to.eql(
|
||||
Array.apply(null, Array(20)).map(Array.prototype.valueOf,
|
||||
[-20037508, 20037508]));
|
||||
|
||||
expect(tileGrid.tileSizes_).to.be.an('array');
|
||||
expect(tileGrid.tileSizes_).to.have.length(20);
|
||||
expect(tileGrid.tileSizes_).to.eql(
|
||||
Array.apply(null, Array(20)).map(Number.prototype.valueOf, 256));
|
||||
|
||||
});
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user