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,37 +1,48 @@
|
||||
import MultiPolygon from '../../../../../src/ol/geom/MultiPolygon.js';
|
||||
import {transformGeom2D} from '../../../../../src/ol/geom/SimpleGeometry.js';
|
||||
import {rotate, translate} from '../../../../../src/ol/geom/flat/transform.js';
|
||||
import {transformGeom2D} from '../../../../../src/ol/geom/SimpleGeometry.js';
|
||||
|
||||
|
||||
describe('ol.geom.flat.transform', function() {
|
||||
|
||||
describe('ol.geom.flat.transform.transform2D', function() {
|
||||
|
||||
it('transforms a Simple Geometry to 2D', function() {
|
||||
|
||||
describe('ol.geom.flat.transform', function () {
|
||||
describe('ol.geom.flat.transform.transform2D', function () {
|
||||
it('transforms a Simple Geometry to 2D', function () {
|
||||
const multiPolygonGeometry = new MultiPolygon([
|
||||
[[[-80.736061, 28.788576000000006, 0],
|
||||
[-80.763557, 28.821799999999996, 0],
|
||||
[-80.817406, 28.895123999999996, 0],
|
||||
[-80.891304, 29.013130000000004, 0],
|
||||
[-80.916512, 29.071560000000005, 0],
|
||||
[-80.899323, 29.061249000000004, 0],
|
||||
[-80.862663, 28.991361999999995, 0],
|
||||
[-80.736061, 28.788576000000006, 0]]], [[
|
||||
[-82.102127, 26.585724, 0],
|
||||
[-82.067139, 26.497208, 0],
|
||||
[-82.097641, 26.493585999999993, 0],
|
||||
[-82.135895, 26.642279000000002, 0],
|
||||
[-82.183495, 26.683082999999996, 0],
|
||||
[-82.128838, 26.693342, 0],
|
||||
[-82.102127, 26.585724, 0]]]
|
||||
[
|
||||
[
|
||||
[-80.736061, 28.788576000000006, 0],
|
||||
[-80.763557, 28.821799999999996, 0],
|
||||
[-80.817406, 28.895123999999996, 0],
|
||||
[-80.891304, 29.013130000000004, 0],
|
||||
[-80.916512, 29.071560000000005, 0],
|
||||
[-80.899323, 29.061249000000004, 0],
|
||||
[-80.862663, 28.991361999999995, 0],
|
||||
[-80.736061, 28.788576000000006, 0],
|
||||
],
|
||||
],
|
||||
[
|
||||
[
|
||||
[-82.102127, 26.585724, 0],
|
||||
[-82.067139, 26.497208, 0],
|
||||
[-82.097641, 26.493585999999993, 0],
|
||||
[-82.135895, 26.642279000000002, 0],
|
||||
[-82.183495, 26.683082999999996, 0],
|
||||
[-82.128838, 26.693342, 0],
|
||||
[-82.102127, 26.585724, 0],
|
||||
],
|
||||
],
|
||||
]).transform('EPSG:4326', 'EPSG:3857');
|
||||
const transform = [
|
||||
0.0004088332670837288, 0,
|
||||
0, -0.0004088332670837288,
|
||||
4480.991370439071, 1529.5752568707105
|
||||
0.0004088332670837288,
|
||||
0,
|
||||
0,
|
||||
-0.0004088332670837288,
|
||||
4480.991370439071,
|
||||
1529.5752568707105,
|
||||
];
|
||||
const pixelCoordinates = transformGeom2D(multiPolygonGeometry, transform, []);
|
||||
const pixelCoordinates = transformGeom2D(
|
||||
multiPolygonGeometry,
|
||||
transform,
|
||||
[]
|
||||
);
|
||||
expect(pixelCoordinates[0]).to.roughlyEqual(806.6035275946265, 1e-9);
|
||||
expect(pixelCoordinates[1]).to.roughlyEqual(160.48916296287916, 1e-9);
|
||||
expect(pixelCoordinates[2]).to.roughlyEqual(805.3521540835154, 1e-9);
|
||||
@@ -63,37 +74,111 @@ describe('ol.geom.flat.transform', function() {
|
||||
expect(pixelCoordinates[28]).to.roughlyEqual(744.4323460835158, 1e-9);
|
||||
expect(pixelCoordinates[29]).to.roughlyEqual(273.7179168205373, 1e-9);
|
||||
});
|
||||
|
||||
});
|
||||
|
||||
describe('ol.geom.flat.transform.translate', function() {
|
||||
it('translates the coordinates array', function() {
|
||||
describe('ol.geom.flat.transform.translate', function () {
|
||||
it('translates the coordinates array', function () {
|
||||
const multiPolygon = new MultiPolygon([
|
||||
[[[0, 0, 2], [0, 1, 2], [1, 1, 2], [1, 0, 2], [0, 0, 2]]],
|
||||
[[[2, 2, 3], [2, 3, 3], [3, 3, 3], [3, 2, 3], [2, 2, 3]]]]);
|
||||
[
|
||||
[
|
||||
[0, 0, 2],
|
||||
[0, 1, 2],
|
||||
[1, 1, 2],
|
||||
[1, 0, 2],
|
||||
[0, 0, 2],
|
||||
],
|
||||
],
|
||||
[
|
||||
[
|
||||
[2, 2, 3],
|
||||
[2, 3, 3],
|
||||
[3, 3, 3],
|
||||
[3, 2, 3],
|
||||
[2, 2, 3],
|
||||
],
|
||||
],
|
||||
]);
|
||||
const flatCoordinates = multiPolygon.getFlatCoordinates();
|
||||
const deltaX = 1;
|
||||
const deltaY = 2;
|
||||
translate(flatCoordinates, 0,
|
||||
flatCoordinates.length, multiPolygon.getStride(),
|
||||
deltaX, deltaY, flatCoordinates);
|
||||
translate(
|
||||
flatCoordinates,
|
||||
0,
|
||||
flatCoordinates.length,
|
||||
multiPolygon.getStride(),
|
||||
deltaX,
|
||||
deltaY,
|
||||
flatCoordinates
|
||||
);
|
||||
expect(flatCoordinates).to.eql([
|
||||
1, 2, 2, 1, 3, 2, 2, 3, 2, 2, 2, 2, 1, 2, 2,
|
||||
3, 4, 3, 3, 5, 3, 4, 5, 3, 4, 4, 3, 3, 4, 3]);
|
||||
1,
|
||||
2,
|
||||
2,
|
||||
1,
|
||||
3,
|
||||
2,
|
||||
2,
|
||||
3,
|
||||
2,
|
||||
2,
|
||||
2,
|
||||
2,
|
||||
1,
|
||||
2,
|
||||
2,
|
||||
3,
|
||||
4,
|
||||
3,
|
||||
3,
|
||||
5,
|
||||
3,
|
||||
4,
|
||||
5,
|
||||
3,
|
||||
4,
|
||||
4,
|
||||
3,
|
||||
3,
|
||||
4,
|
||||
3,
|
||||
]);
|
||||
});
|
||||
});
|
||||
|
||||
describe('ol.geom.flat.transform.rotate', function() {
|
||||
it('rotates the coordinates array', function() {
|
||||
describe('ol.geom.flat.transform.rotate', function () {
|
||||
it('rotates the coordinates array', function () {
|
||||
const multiPolygon = new MultiPolygon([
|
||||
[[[0, 0, 2], [0, 1, 2], [1, 1, 2], [1, 0, 2], [0, 0, 2]]],
|
||||
[[[2, 2, 3], [2, 3, 3], [3, 3, 3], [3, 2, 3], [2, 2, 3]]]]);
|
||||
[
|
||||
[
|
||||
[0, 0, 2],
|
||||
[0, 1, 2],
|
||||
[1, 1, 2],
|
||||
[1, 0, 2],
|
||||
[0, 0, 2],
|
||||
],
|
||||
],
|
||||
[
|
||||
[
|
||||
[2, 2, 3],
|
||||
[2, 3, 3],
|
||||
[3, 3, 3],
|
||||
[3, 2, 3],
|
||||
[2, 2, 3],
|
||||
],
|
||||
],
|
||||
]);
|
||||
const flatCoordinates = multiPolygon.getFlatCoordinates();
|
||||
const angle = Math.PI / 2;
|
||||
const anchor = [0, 1];
|
||||
rotate(flatCoordinates, 0,
|
||||
flatCoordinates.length, multiPolygon.getStride(),
|
||||
angle, anchor, flatCoordinates);
|
||||
rotate(
|
||||
flatCoordinates,
|
||||
0,
|
||||
flatCoordinates.length,
|
||||
multiPolygon.getStride(),
|
||||
angle,
|
||||
anchor,
|
||||
flatCoordinates
|
||||
);
|
||||
expect(flatCoordinates[0]).to.roughlyEqual(1, 1e-9);
|
||||
expect(flatCoordinates[1]).to.roughlyEqual(1, 1e-9);
|
||||
expect(flatCoordinates[2]).to.roughlyEqual(2, 1e-9);
|
||||
@@ -125,7 +210,5 @@ describe('ol.geom.flat.transform', function() {
|
||||
expect(flatCoordinates[28]).to.roughlyEqual(3, 1e-9);
|
||||
expect(flatCoordinates[29]).to.roughlyEqual(3, 1e-9);
|
||||
});
|
||||
|
||||
});
|
||||
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user