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.
65 lines
1.6 KiB
JavaScript
65 lines
1.6 KiB
JavaScript
import {calculateSourceResolution} from '../../../../src/ol/reproj.js';
|
|
import {get as getProjection, transform} from '../../../../src/ol/proj.js';
|
|
|
|
describe('ol.reproj', function () {
|
|
describe('#calculateSourceResolution', function () {
|
|
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 () {
|
|
let result;
|
|
const resolution = 500;
|
|
result = calculateSourceResolution(
|
|
proj3857,
|
|
proj3857,
|
|
origin,
|
|
resolution
|
|
);
|
|
expect(result).to.be(resolution);
|
|
|
|
result = calculateSourceResolution(
|
|
proj3857,
|
|
proj3857,
|
|
point3857,
|
|
resolution
|
|
);
|
|
expect(result).to.be(resolution);
|
|
|
|
result = calculateSourceResolution(
|
|
proj4326,
|
|
proj4326,
|
|
point4326,
|
|
resolution
|
|
);
|
|
expect(result).to.be(resolution);
|
|
});
|
|
|
|
it('calculates correctly', function () {
|
|
const resolution4326 = 5;
|
|
|
|
const resolution3857 = calculateSourceResolution(
|
|
proj3857,
|
|
proj4326,
|
|
point4326,
|
|
resolution4326
|
|
);
|
|
expect(resolution3857).not.to.be(resolution4326);
|
|
expect(resolution3857).to.roughlyEqual(
|
|
5 * proj4326.getMetersPerUnit(),
|
|
1e-4
|
|
);
|
|
|
|
const result = calculateSourceResolution(
|
|
proj4326,
|
|
proj3857,
|
|
point3857,
|
|
resolution3857
|
|
);
|
|
expect(result).to.be(resolution4326);
|
|
});
|
|
});
|
|
});
|