Make code prettier
This updates ESLint and our shared eslint-config-openlayers to use Prettier. Most formatting changes were automatically applied with this:
npm run lint -- --fix
A few manual changes were required:
* In `examples/offscreen-canvas.js`, the `//eslint-disable-line` comment needed to be moved to the appropriate line to disable the error about the `'worker-loader!./offscreen-canvas.worker.js'` import.
* In `examples/webpack/exapmle-builder.js`, spaces could not be added after a couple `function`s for some reason. While editing this, I reworked `ExampleBuilder` to be a class.
* In `src/ol/format/WMSGetFeatureInfo.js`, the `// @ts-ignore` comment needed to be moved down one line so it applied to the `parsersNS` argument.
This commit is contained in:
@@ -1,84 +1,116 @@
|
||||
import ImageTile from '../../../../src/ol/ImageTile.js';
|
||||
import {listen} from '../../../../src/ol/events.js';
|
||||
import {addCommon, clearAllProjections, get as getProjection} from '../../../../src/ol/proj.js';
|
||||
import {register} from '../../../../src/ol/proj/proj4.js';
|
||||
import ReprojTile from '../../../../src/ol/reproj/Tile.js';
|
||||
import {
|
||||
addCommon,
|
||||
clearAllProjections,
|
||||
get as getProjection,
|
||||
} from '../../../../src/ol/proj.js';
|
||||
import {createForProjection} from '../../../../src/ol/tilegrid.js';
|
||||
import {listen} from '../../../../src/ol/events.js';
|
||||
import {register} from '../../../../src/ol/proj/proj4.js';
|
||||
|
||||
|
||||
describe('ol.reproj.Tile', function() {
|
||||
beforeEach(function() {
|
||||
proj4.defs('EPSG:27700', '+proj=tmerc +lat_0=49 +lon_0=-2 ' +
|
||||
describe('ol.reproj.Tile', function () {
|
||||
beforeEach(function () {
|
||||
proj4.defs(
|
||||
'EPSG:27700',
|
||||
'+proj=tmerc +lat_0=49 +lon_0=-2 ' +
|
||||
'+k=0.9996012717 +x_0=400000 +y_0=-100000 +ellps=airy ' +
|
||||
'+towgs84=446.448,-125.157,542.06,0.15,0.247,0.842,-20.489 ' +
|
||||
'+units=m +no_defs');
|
||||
'+units=m +no_defs'
|
||||
);
|
||||
register(proj4);
|
||||
const proj27700 = getProjection('EPSG:27700');
|
||||
proj27700.setExtent([0, 0, 700000, 1300000]);
|
||||
});
|
||||
|
||||
afterEach(function() {
|
||||
afterEach(function () {
|
||||
delete proj4.defs['EPSG:27700'];
|
||||
clearAllProjections();
|
||||
addCommon();
|
||||
});
|
||||
|
||||
|
||||
function createTile(pixelRatio, opt_tileSize) {
|
||||
const proj4326 = getProjection('EPSG:4326');
|
||||
const proj3857 = getProjection('EPSG:3857');
|
||||
return new ReprojTile(
|
||||
proj3857, createForProjection(proj3857), proj4326,
|
||||
proj3857,
|
||||
createForProjection(proj3857),
|
||||
proj4326,
|
||||
createForProjection(proj4326, 3, opt_tileSize),
|
||||
[3, 2, 1], null, pixelRatio, 0, function(z, x, y, pixelRatio) {
|
||||
return new ImageTile([z, x, y], 0, // IDLE
|
||||
[3, 2, 1],
|
||||
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) {
|
||||
'R0lGODlhAQABAIAAAP///wAAACwAAAAAAQABAAACAkQBADs=',
|
||||
null,
|
||||
function (tile, src) {
|
||||
tile.getImage().src = src;
|
||||
});
|
||||
});
|
||||
}
|
||||
);
|
||||
}
|
||||
);
|
||||
}
|
||||
|
||||
it('changes state as expected', function(done) {
|
||||
it('changes state as expected', function (done) {
|
||||
const tile = createTile(1);
|
||||
expect(tile.getState()).to.be(0); // IDLE
|
||||
listen(tile, 'change', function() {
|
||||
if (tile.getState() == 2) { // LOADED
|
||||
listen(tile, 'change', function () {
|
||||
if (tile.getState() == 2) {
|
||||
// LOADED
|
||||
done();
|
||||
}
|
||||
});
|
||||
tile.load();
|
||||
});
|
||||
|
||||
it('is empty when outside target tile grid', function() {
|
||||
it('is empty when outside target tile grid', function () {
|
||||
const proj4326 = getProjection('EPSG:4326');
|
||||
const proj3857 = getProjection('EPSG:3857');
|
||||
const tile = new ReprojTile(
|
||||
proj3857, createForProjection(proj3857),
|
||||
proj4326, createForProjection(proj4326),
|
||||
[0, -1, 0], null, 1, 0, function() {
|
||||
proj3857,
|
||||
createForProjection(proj3857),
|
||||
proj4326,
|
||||
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() {
|
||||
it('is empty when outside source tile grid', function () {
|
||||
const proj4326 = getProjection('EPSG:4326');
|
||||
const proj27700 = getProjection('EPSG:27700');
|
||||
const tile = new ReprojTile(
|
||||
proj27700, createForProjection(proj27700),
|
||||
proj4326, createForProjection(proj4326),
|
||||
[3, 2, -2], null, 1, 0, function() {
|
||||
proj27700,
|
||||
createForProjection(proj27700),
|
||||
proj4326,
|
||||
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) {
|
||||
it('respects tile size of target tile grid', function (done) {
|
||||
const tile = createTile(1, [100, 40]);
|
||||
listen(tile, 'change', function() {
|
||||
if (tile.getState() == 2) { // LOADED
|
||||
listen(tile, 'change', function () {
|
||||
if (tile.getState() == 2) {
|
||||
// LOADED
|
||||
const canvas = tile.getImage();
|
||||
expect(canvas.width).to.be(100);
|
||||
expect(canvas.height).to.be(40);
|
||||
@@ -88,10 +120,11 @@ describe('ol.reproj.Tile', function() {
|
||||
tile.load();
|
||||
});
|
||||
|
||||
it('respects pixelRatio', function(done) {
|
||||
it('respects pixelRatio', function (done) {
|
||||
const tile = createTile(3, [60, 20]);
|
||||
listen(tile, 'change', function() {
|
||||
if (tile.getState() == 2) { // LOADED
|
||||
listen(tile, 'change', function () {
|
||||
if (tile.getState() == 2) {
|
||||
// LOADED
|
||||
const canvas = tile.getImage();
|
||||
expect(canvas.width).to.be(180);
|
||||
expect(canvas.height).to.be(60);
|
||||
|
||||
Reference in New Issue
Block a user