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:
@@ -7,20 +7,20 @@ import ReprojImage from '../../../../src/ol/reproj/Image.js';
|
||||
describe('ol.reproj.Image', function() {
|
||||
function createImage(pixelRatio) {
|
||||
return new ReprojImage(
|
||||
getProjection('EPSG:3857'), getProjection('EPSG:4326'),
|
||||
[-180, -85, 180, 85], 10, pixelRatio,
|
||||
function(extent, resolution, pixelRatio) {
|
||||
return new _ol_Image_(extent, resolution, pixelRatio,
|
||||
'data:image/gif;base64,' +
|
||||
getProjection('EPSG:3857'), getProjection('EPSG:4326'),
|
||||
[-180, -85, 180, 85], 10, pixelRatio,
|
||||
function(extent, resolution, pixelRatio) {
|
||||
return new _ol_Image_(extent, resolution, pixelRatio,
|
||||
'data:image/gif;base64,' +
|
||||
'R0lGODlhAQABAIAAAP///wAAACwAAAAAAQABAAACAkQBADs=', null,
|
||||
function(image, src) {
|
||||
image.getImage().src = src;
|
||||
});
|
||||
});
|
||||
function(image, src) {
|
||||
image.getImage().src = src;
|
||||
});
|
||||
});
|
||||
}
|
||||
|
||||
it('changes state as expected', function(done) {
|
||||
var image = createImage(1);
|
||||
const image = createImage(1);
|
||||
expect(image.getState()).to.be(0); // IDLE
|
||||
_ol_events_.listen(image, 'change', function() {
|
||||
if (image.getState() == 2) { // LOADED
|
||||
@@ -31,10 +31,10 @@ describe('ol.reproj.Image', function() {
|
||||
});
|
||||
|
||||
it('returns correct canvas size', function(done) {
|
||||
var image = createImage(1);
|
||||
const image = createImage(1);
|
||||
_ol_events_.listen(image, 'change', function() {
|
||||
if (image.getState() == 2) { // LOADED
|
||||
var canvas = image.getImage();
|
||||
const canvas = image.getImage();
|
||||
expect(canvas.width).to.be(36);
|
||||
expect(canvas.height).to.be(17);
|
||||
done();
|
||||
@@ -44,10 +44,10 @@ describe('ol.reproj.Image', function() {
|
||||
});
|
||||
|
||||
it('respects pixelRatio', function(done) {
|
||||
var image = createImage(2);
|
||||
const image = createImage(2);
|
||||
_ol_events_.listen(image, 'change', function() {
|
||||
if (image.getState() == 2) { // LOADED
|
||||
var canvas = image.getImage();
|
||||
const canvas = image.getImage();
|
||||
expect(canvas.width).to.be(72);
|
||||
expect(canvas.height).to.be(34);
|
||||
done();
|
||||
|
||||
@@ -5,39 +5,39 @@ import {get as getProjection, transform} from '../../../../src/ol/proj.js';
|
||||
describe('ol.reproj', function() {
|
||||
|
||||
describe('#calculateSourceResolution', function() {
|
||||
var proj3857 = getProjection('EPSG:3857');
|
||||
var proj4326 = getProjection('EPSG:4326');
|
||||
var origin = [0, 0];
|
||||
var point3857 = [50, 40];
|
||||
var point4326 = transform(point3857, proj3857, proj4326);
|
||||
const proj3857 = getProjection('EPSG:3857');
|
||||
const proj4326 = getProjection('EPSG:4326');
|
||||
const origin = [0, 0];
|
||||
const point3857 = [50, 40];
|
||||
const point4326 = transform(point3857, proj3857, proj4326);
|
||||
|
||||
it('is identity for identical projection', function() {
|
||||
var result;
|
||||
var resolution = 500;
|
||||
let result;
|
||||
const resolution = 500;
|
||||
result = _ol_reproj_.calculateSourceResolution(
|
||||
proj3857, proj3857, origin, resolution);
|
||||
proj3857, proj3857, origin, resolution);
|
||||
expect(result).to.be(resolution);
|
||||
|
||||
result = _ol_reproj_.calculateSourceResolution(
|
||||
proj3857, proj3857, point3857, resolution);
|
||||
proj3857, proj3857, point3857, resolution);
|
||||
expect(result).to.be(resolution);
|
||||
|
||||
result = _ol_reproj_.calculateSourceResolution(
|
||||
proj4326, proj4326, point4326, resolution);
|
||||
proj4326, proj4326, point4326, resolution);
|
||||
expect(result).to.be(resolution);
|
||||
});
|
||||
|
||||
it('calculates correctly', function() {
|
||||
var resolution4326 = 5;
|
||||
const resolution4326 = 5;
|
||||
|
||||
var resolution3857 = _ol_reproj_.calculateSourceResolution(
|
||||
proj3857, proj4326, point4326, resolution4326);
|
||||
const resolution3857 = _ol_reproj_.calculateSourceResolution(
|
||||
proj3857, proj4326, point4326, resolution4326);
|
||||
expect(resolution3857).not.to.be(resolution4326);
|
||||
expect(resolution3857).to.roughlyEqual(
|
||||
5 * proj4326.getMetersPerUnit(), 1e-4);
|
||||
5 * proj4326.getMetersPerUnit(), 1e-4);
|
||||
|
||||
var result = _ol_reproj_.calculateSourceResolution(
|
||||
proj4326, proj3857, point3857, resolution3857);
|
||||
const result = _ol_reproj_.calculateSourceResolution(
|
||||
proj4326, proj3857, point3857, resolution3857);
|
||||
expect(result).to.be(resolution4326);
|
||||
});
|
||||
});
|
||||
|
||||
@@ -13,7 +13,7 @@ describe('ol.reproj.Tile', function() {
|
||||
'+towgs84=446.448,-125.157,542.06,0.15,0.247,0.842,-20.489 ' +
|
||||
'+units=m +no_defs');
|
||||
register(proj4);
|
||||
var proj27700 = getProjection('EPSG:27700');
|
||||
const proj27700 = getProjection('EPSG:27700');
|
||||
proj27700.setExtent([0, 0, 700000, 1300000]);
|
||||
});
|
||||
|
||||
@@ -25,23 +25,23 @@ describe('ol.reproj.Tile', function() {
|
||||
|
||||
|
||||
function createTile(pixelRatio, opt_tileSize) {
|
||||
var proj4326 = getProjection('EPSG:4326');
|
||||
var proj3857 = getProjection('EPSG:3857');
|
||||
const proj4326 = getProjection('EPSG:4326');
|
||||
const proj3857 = getProjection('EPSG:3857');
|
||||
return new ReprojTile(
|
||||
proj3857, _ol_tilegrid_.createForProjection(proj3857), proj4326,
|
||||
_ol_tilegrid_.createForProjection(proj4326, 3, opt_tileSize),
|
||||
[3, 2, -2], null, pixelRatio, 0, function(z, x, y, pixelRatio) {
|
||||
return new ImageTile([z, x, y], 0, // IDLE
|
||||
'data:image/gif;base64,' +
|
||||
proj3857, _ol_tilegrid_.createForProjection(proj3857), proj4326,
|
||||
_ol_tilegrid_.createForProjection(proj4326, 3, opt_tileSize),
|
||||
[3, 2, -2], null, pixelRatio, 0, function(z, x, y, pixelRatio) {
|
||||
return new ImageTile([z, x, y], 0, // IDLE
|
||||
'data:image/gif;base64,' +
|
||||
'R0lGODlhAQABAIAAAP///wAAACwAAAAAAQABAAACAkQBADs=', null,
|
||||
function(tile, src) {
|
||||
tile.getImage().src = src;
|
||||
});
|
||||
});
|
||||
function(tile, src) {
|
||||
tile.getImage().src = src;
|
||||
});
|
||||
});
|
||||
}
|
||||
|
||||
it('changes state as expected', function(done) {
|
||||
var tile = createTile(1);
|
||||
const tile = createTile(1);
|
||||
expect(tile.getState()).to.be(0); // IDLE
|
||||
_ol_events_.listen(tile, 'change', function() {
|
||||
if (tile.getState() == 2) { // LOADED
|
||||
@@ -52,34 +52,34 @@ describe('ol.reproj.Tile', function() {
|
||||
});
|
||||
|
||||
it('is empty when outside target tile grid', function() {
|
||||
var proj4326 = getProjection('EPSG:4326');
|
||||
var proj3857 = getProjection('EPSG:3857');
|
||||
var tile = new ReprojTile(
|
||||
proj3857, _ol_tilegrid_.createForProjection(proj3857),
|
||||
proj4326, _ol_tilegrid_.createForProjection(proj4326),
|
||||
[0, -1, 0], null, 1, 0, function() {
|
||||
expect().fail('No tiles should be required');
|
||||
});
|
||||
const proj4326 = getProjection('EPSG:4326');
|
||||
const proj3857 = getProjection('EPSG:3857');
|
||||
const tile = new ReprojTile(
|
||||
proj3857, _ol_tilegrid_.createForProjection(proj3857),
|
||||
proj4326, _ol_tilegrid_.createForProjection(proj4326),
|
||||
[0, -1, 0], null, 1, 0, function() {
|
||||
expect().fail('No tiles should be required');
|
||||
});
|
||||
expect(tile.getState()).to.be(4); // EMPTY
|
||||
});
|
||||
|
||||
it('is empty when outside source tile grid', function() {
|
||||
var proj4326 = getProjection('EPSG:4326');
|
||||
var proj27700 = getProjection('EPSG:27700');
|
||||
var tile = new ReprojTile(
|
||||
proj27700, _ol_tilegrid_.createForProjection(proj27700),
|
||||
proj4326, _ol_tilegrid_.createForProjection(proj4326),
|
||||
[3, 2, -2], null, 1, 0, function() {
|
||||
expect().fail('No tiles should be required');
|
||||
});
|
||||
const proj4326 = getProjection('EPSG:4326');
|
||||
const proj27700 = getProjection('EPSG:27700');
|
||||
const tile = new ReprojTile(
|
||||
proj27700, _ol_tilegrid_.createForProjection(proj27700),
|
||||
proj4326, _ol_tilegrid_.createForProjection(proj4326),
|
||||
[3, 2, -2], null, 1, 0, function() {
|
||||
expect().fail('No tiles should be required');
|
||||
});
|
||||
expect(tile.getState()).to.be(4); // EMPTY
|
||||
});
|
||||
|
||||
it('respects tile size of target tile grid', function(done) {
|
||||
var tile = createTile(1, [100, 40]);
|
||||
const tile = createTile(1, [100, 40]);
|
||||
_ol_events_.listen(tile, 'change', function() {
|
||||
if (tile.getState() == 2) { // LOADED
|
||||
var canvas = tile.getImage();
|
||||
const canvas = tile.getImage();
|
||||
expect(canvas.width).to.be(100);
|
||||
expect(canvas.height).to.be(40);
|
||||
done();
|
||||
@@ -89,10 +89,10 @@ describe('ol.reproj.Tile', function() {
|
||||
});
|
||||
|
||||
it('respects pixelRatio', function(done) {
|
||||
var tile = createTile(3, [60, 20]);
|
||||
const tile = createTile(3, [60, 20]);
|
||||
_ol_events_.listen(tile, 'change', function() {
|
||||
if (tile.getState() == 2) { // LOADED
|
||||
var canvas = tile.getImage();
|
||||
const canvas = tile.getImage();
|
||||
expect(canvas.width).to.be(180);
|
||||
expect(canvas.height).to.be(60);
|
||||
done();
|
||||
|
||||
@@ -10,7 +10,7 @@ describe('ol.reproj.Triangulation', function() {
|
||||
'+towgs84=446.448,-125.157,542.06,0.15,0.247,0.842,-20.489 ' +
|
||||
'+units=m +no_defs');
|
||||
register(proj4);
|
||||
var proj27700 = getProjection('EPSG:27700');
|
||||
const proj27700 = getProjection('EPSG:27700');
|
||||
proj27700.setExtent([0, 0, 700000, 1300000]);
|
||||
});
|
||||
|
||||
@@ -22,24 +22,24 @@ describe('ol.reproj.Triangulation', function() {
|
||||
|
||||
describe('constructor', function() {
|
||||
it('is trivial for identity', function() {
|
||||
var proj4326 = getProjection('EPSG:4326');
|
||||
var triangulation = new Triangulation(proj4326, proj4326,
|
||||
[20, 20, 30, 30], [-180, -90, 180, 90], 0);
|
||||
const proj4326 = getProjection('EPSG:4326');
|
||||
const triangulation = new Triangulation(proj4326, proj4326,
|
||||
[20, 20, 30, 30], [-180, -90, 180, 90], 0);
|
||||
expect(triangulation.getTriangles().length).to.be(2);
|
||||
});
|
||||
|
||||
it('is empty when outside source extent', function() {
|
||||
var proj4326 = getProjection('EPSG:4326');
|
||||
var proj27700 = getProjection('EPSG:27700');
|
||||
var triangulation = new Triangulation(proj27700, proj4326,
|
||||
[0, 0, 10, 10], proj27700.getExtent(), 0);
|
||||
const proj4326 = getProjection('EPSG:4326');
|
||||
const proj27700 = getProjection('EPSG:27700');
|
||||
const triangulation = new Triangulation(proj27700, proj4326,
|
||||
[0, 0, 10, 10], proj27700.getExtent(), 0);
|
||||
expect(triangulation.getTriangles().length).to.be(0);
|
||||
});
|
||||
|
||||
it('can handle null source extent', function() {
|
||||
var proj4326 = getProjection('EPSG:4326');
|
||||
var triangulation = new Triangulation(proj4326, proj4326,
|
||||
[20, 20, 30, 30], null, 0);
|
||||
const proj4326 = getProjection('EPSG:4326');
|
||||
const triangulation = new Triangulation(proj4326, proj4326,
|
||||
[20, 20, 30, 30], null, 0);
|
||||
expect(triangulation.getTriangles().length).to.be(2);
|
||||
});
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user