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,31 +1,40 @@
|
||||
import {getPointResolution, transform, get as getProjection, clearAllProjections, addCommon} from '../../../../src/ol/proj.js';
|
||||
import {fromEPSG4326, HALF_SIZE} from '../../../../src/ol/proj/epsg3857.js';
|
||||
import {HALF_SIZE, fromEPSG4326} from '../../../../src/ol/proj/epsg3857.js';
|
||||
import {
|
||||
addCommon,
|
||||
clearAllProjections,
|
||||
getPointResolution,
|
||||
get as getProjection,
|
||||
transform,
|
||||
} from '../../../../src/ol/proj.js';
|
||||
|
||||
describe('ol/proj/epsg3857', function() {
|
||||
|
||||
afterEach(function() {
|
||||
describe('ol/proj/epsg3857', function () {
|
||||
afterEach(function () {
|
||||
clearAllProjections();
|
||||
addCommon();
|
||||
});
|
||||
|
||||
describe('fromEPSG4326()', function() {
|
||||
|
||||
it('transforms from geographic to Web Mercator', function() {
|
||||
describe('fromEPSG4326()', function () {
|
||||
it('transforms from geographic to Web Mercator', function () {
|
||||
const tolerance = 1e-5;
|
||||
|
||||
const cases = [{
|
||||
g: [0, 0],
|
||||
m: [0, 0]
|
||||
}, {
|
||||
g: [-180, -90],
|
||||
m: [-HALF_SIZE, -HALF_SIZE]
|
||||
}, {
|
||||
g: [180, 90],
|
||||
m: [HALF_SIZE, HALF_SIZE]
|
||||
}, {
|
||||
g: [-111.0429, 45.6770],
|
||||
m: [-12361239.084208, 5728738.469095]
|
||||
}];
|
||||
const cases = [
|
||||
{
|
||||
g: [0, 0],
|
||||
m: [0, 0],
|
||||
},
|
||||
{
|
||||
g: [-180, -90],
|
||||
m: [-HALF_SIZE, -HALF_SIZE],
|
||||
},
|
||||
{
|
||||
g: [180, 90],
|
||||
m: [HALF_SIZE, HALF_SIZE],
|
||||
},
|
||||
{
|
||||
g: [-111.0429, 45.677],
|
||||
m: [-12361239.084208, 5728738.469095],
|
||||
},
|
||||
];
|
||||
|
||||
for (let i = 0, ii = cases.length; i < ii; ++i) {
|
||||
const point = cases[i].g;
|
||||
@@ -35,37 +44,38 @@ describe('ol/proj/epsg3857', function() {
|
||||
}
|
||||
});
|
||||
|
||||
it('does not produce unexpected results for string coordinates', function() {
|
||||
it('does not produce unexpected results for string coordinates', function () {
|
||||
const transformed = fromEPSG4326(['180', '90']);
|
||||
expect(transformed[0]).to.roughlyEqual(HALF_SIZE, 1e-5);
|
||||
expect(transformed[1]).to.roughlyEqual(HALF_SIZE, 1e-5);
|
||||
});
|
||||
|
||||
});
|
||||
|
||||
describe('getPointResolution', function() {
|
||||
|
||||
it('returns the correct point scale at the equator', function() {
|
||||
describe('getPointResolution', function () {
|
||||
it('returns the correct point scale at the equator', function () {
|
||||
// @see http://msdn.microsoft.com/en-us/library/aa940990.aspx
|
||||
const epsg3857 = getProjection('EPSG:3857');
|
||||
const resolution = 19.11;
|
||||
const point = [0, 0];
|
||||
expect(getPointResolution(epsg3857, resolution, point)).
|
||||
to.roughlyEqual(19.11, 1e-1);
|
||||
expect(getPointResolution(epsg3857, resolution, point)).to.roughlyEqual(
|
||||
19.11,
|
||||
1e-1
|
||||
);
|
||||
});
|
||||
|
||||
it('returns the correct point scale at the latitude of Toronto',
|
||||
function() {
|
||||
// @see http://msdn.microsoft.com/en-us/library/aa940990.aspx
|
||||
const epsg3857 = getProjection('EPSG:3857');
|
||||
const epsg4326 = getProjection('EPSG:4326');
|
||||
const resolution = 19.11;
|
||||
const point = transform([0, 43.65], epsg4326, epsg3857);
|
||||
expect(getPointResolution(epsg3857, resolution, point)).
|
||||
to.roughlyEqual(19.11 * Math.cos(Math.PI * 43.65 / 180), 1e-9);
|
||||
});
|
||||
it('returns the correct point scale at the latitude of Toronto', function () {
|
||||
// @see http://msdn.microsoft.com/en-us/library/aa940990.aspx
|
||||
const epsg3857 = getProjection('EPSG:3857');
|
||||
const epsg4326 = getProjection('EPSG:4326');
|
||||
const resolution = 19.11;
|
||||
const point = transform([0, 43.65], epsg4326, epsg3857);
|
||||
expect(getPointResolution(epsg3857, resolution, point)).to.roughlyEqual(
|
||||
19.11 * Math.cos((Math.PI * 43.65) / 180),
|
||||
1e-9
|
||||
);
|
||||
});
|
||||
|
||||
it('returns the correct point scale at various latitudes', function() {
|
||||
it('returns the correct point scale at various latitudes', function () {
|
||||
// @see http://msdn.microsoft.com/en-us/library/aa940990.aspx
|
||||
const epsg3857 = getProjection('EPSG:3857');
|
||||
const epsg4326 = getProjection('EPSG:4326');
|
||||
@@ -73,11 +83,11 @@ describe('ol/proj/epsg3857', function() {
|
||||
let latitude;
|
||||
for (latitude = 0; latitude <= 85; ++latitude) {
|
||||
const point = transform([0, latitude], epsg4326, epsg3857);
|
||||
expect(getPointResolution(epsg3857, resolution, point)).
|
||||
to.roughlyEqual(19.11 * Math.cos(Math.PI * latitude / 180), 1e-9);
|
||||
expect(getPointResolution(epsg3857, resolution, point)).to.roughlyEqual(
|
||||
19.11 * Math.cos((Math.PI * latitude) / 180),
|
||||
1e-9
|
||||
);
|
||||
}
|
||||
});
|
||||
|
||||
});
|
||||
|
||||
});
|
||||
|
||||
@@ -1,24 +1,22 @@
|
||||
import Projection from '../../../../src/ol/proj/Projection.js';
|
||||
import * as transforms from '../../../../src/ol/proj/transforms.js';
|
||||
import Projection from '../../../../src/ol/proj/Projection.js';
|
||||
|
||||
|
||||
describe('transforms.remove()', function() {
|
||||
|
||||
describe('transforms.remove()', function () {
|
||||
const extent = [180, -90, 180, 90];
|
||||
const units = 'degrees';
|
||||
|
||||
it('removes functions cached by transforms.add()', function() {
|
||||
it('removes functions cached by transforms.add()', function () {
|
||||
const foo = new Projection({
|
||||
code: 'foo',
|
||||
units: units,
|
||||
extent: extent
|
||||
extent: extent,
|
||||
});
|
||||
const bar = new Projection({
|
||||
code: 'bar',
|
||||
units: units,
|
||||
extent: extent
|
||||
extent: extent,
|
||||
});
|
||||
const transform = function(input, output, dimension) {
|
||||
const transform = function (input, output, dimension) {
|
||||
return input;
|
||||
};
|
||||
transforms.add(foo, bar, transform);
|
||||
@@ -28,5 +26,4 @@ describe('transforms.remove()', function() {
|
||||
expect(removed).to.be(transform);
|
||||
expect(transforms.get('foo', 'bar')).to.be(undefined);
|
||||
});
|
||||
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user