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:
@@ -3,7 +3,6 @@
|
||||
*/
|
||||
import {METERS_PER_UNIT} from './Units.js';
|
||||
|
||||
|
||||
/**
|
||||
* @typedef {Object} Options
|
||||
* @property {string} code The SRS identifier code, e.g. `EPSG:4326`.
|
||||
@@ -23,7 +22,6 @@ import {METERS_PER_UNIT} from './Units.js';
|
||||
* the default {@link module:ol/proj#getPointResolution} function will be used.
|
||||
*/
|
||||
|
||||
|
||||
/**
|
||||
* @classdesc
|
||||
* Projection definition class. One of these is created for each projection
|
||||
@@ -52,7 +50,6 @@ import {METERS_PER_UNIT} from './Units.js';
|
||||
* @api
|
||||
*/
|
||||
class Projection {
|
||||
|
||||
/**
|
||||
* @param {Options} options Projection options.
|
||||
*/
|
||||
@@ -88,15 +85,15 @@ class Projection {
|
||||
* @private
|
||||
* @type {import("../extent.js").Extent}
|
||||
*/
|
||||
this.worldExtent_ = options.worldExtent !== undefined ?
|
||||
options.worldExtent : null;
|
||||
this.worldExtent_ =
|
||||
options.worldExtent !== undefined ? options.worldExtent : null;
|
||||
|
||||
/**
|
||||
* @private
|
||||
* @type {string}
|
||||
*/
|
||||
this.axisOrientation_ = options.axisOrientation !== undefined ?
|
||||
options.axisOrientation : 'enu';
|
||||
this.axisOrientation_ =
|
||||
options.axisOrientation !== undefined ? options.axisOrientation : 'enu';
|
||||
|
||||
/**
|
||||
* @private
|
||||
|
||||
@@ -13,10 +13,9 @@ const Units = {
|
||||
METERS: 'm',
|
||||
PIXELS: 'pixels',
|
||||
TILE_PIXELS: 'tile-pixels',
|
||||
USFEET: 'us-ft'
|
||||
USFEET: 'us-ft',
|
||||
};
|
||||
|
||||
|
||||
/**
|
||||
* Meters per unit lookup table.
|
||||
* @const
|
||||
@@ -25,7 +24,7 @@ const Units = {
|
||||
*/
|
||||
export const METERS_PER_UNIT = {};
|
||||
// use the radius of the Normal sphere
|
||||
METERS_PER_UNIT[Units.DEGREES] = 2 * Math.PI * 6370997 / 360;
|
||||
METERS_PER_UNIT[Units.DEGREES] = (2 * Math.PI * 6370997) / 360;
|
||||
METERS_PER_UNIT[Units.FEET] = 0.3048;
|
||||
METERS_PER_UNIT[Units.METERS] = 1;
|
||||
METERS_PER_UNIT[Units.USFEET] = 1200 / 3937;
|
||||
|
||||
+10
-25
@@ -1,10 +1,9 @@
|
||||
/**
|
||||
* @module ol/proj/epsg3857
|
||||
*/
|
||||
import {cosh} from '../math.js';
|
||||
import Projection from './Projection.js';
|
||||
import Units from './Units.js';
|
||||
|
||||
import {cosh} from '../math.js';
|
||||
|
||||
/**
|
||||
* Radius of WGS84 sphere
|
||||
@@ -14,23 +13,17 @@ import Units from './Units.js';
|
||||
*/
|
||||
export const RADIUS = 6378137;
|
||||
|
||||
|
||||
/**
|
||||
* @const
|
||||
* @type {number}
|
||||
*/
|
||||
export const HALF_SIZE = Math.PI * RADIUS;
|
||||
|
||||
|
||||
/**
|
||||
* @const
|
||||
* @type {import("../extent.js").Extent}
|
||||
*/
|
||||
export const EXTENT = [
|
||||
-HALF_SIZE, -HALF_SIZE,
|
||||
HALF_SIZE, HALF_SIZE
|
||||
];
|
||||
|
||||
export const EXTENT = [-HALF_SIZE, -HALF_SIZE, HALF_SIZE, HALF_SIZE];
|
||||
|
||||
/**
|
||||
* @const
|
||||
@@ -38,13 +31,11 @@ export const EXTENT = [
|
||||
*/
|
||||
export const WORLD_EXTENT = [-180, -85, 180, 85];
|
||||
|
||||
|
||||
/**
|
||||
* @classdesc
|
||||
* Projection object for web/spherical Mercator (EPSG:3857).
|
||||
*/
|
||||
class EPSG3857Projection extends Projection {
|
||||
|
||||
/**
|
||||
* @param {string} code Code.
|
||||
*/
|
||||
@@ -55,16 +46,13 @@ class EPSG3857Projection extends Projection {
|
||||
extent: EXTENT,
|
||||
global: true,
|
||||
worldExtent: WORLD_EXTENT,
|
||||
getPointResolution: function(resolution, point) {
|
||||
getPointResolution: function (resolution, point) {
|
||||
return resolution / cosh(point[1] / RADIUS);
|
||||
}
|
||||
},
|
||||
});
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Projections equal to EPSG:3857.
|
||||
*
|
||||
@@ -78,10 +66,9 @@ export const PROJECTIONS = [
|
||||
new EPSG3857Projection('EPSG:900913'),
|
||||
new EPSG3857Projection('urn:ogc:def:crs:EPSG:6.18:3:3857'),
|
||||
new EPSG3857Projection('urn:ogc:def:crs:EPSG::3857'),
|
||||
new EPSG3857Projection('http://www.opengis.net/gml/srs/epsg.xml#3857')
|
||||
new EPSG3857Projection('http://www.opengis.net/gml/srs/epsg.xml#3857'),
|
||||
];
|
||||
|
||||
|
||||
/**
|
||||
* Transformation from EPSG:4326 to EPSG:3857.
|
||||
*
|
||||
@@ -104,9 +91,8 @@ export function fromEPSG4326(input, opt_output, opt_dimension) {
|
||||
}
|
||||
const halfSize = HALF_SIZE;
|
||||
for (let i = 0; i < length; i += dimension) {
|
||||
output[i] = halfSize * input[i] / 180;
|
||||
let y = RADIUS *
|
||||
Math.log(Math.tan(Math.PI * (+input[i + 1] + 90) / 360));
|
||||
output[i] = (halfSize * input[i]) / 180;
|
||||
let y = RADIUS * Math.log(Math.tan((Math.PI * (+input[i + 1] + 90)) / 360));
|
||||
if (y > halfSize) {
|
||||
y = halfSize;
|
||||
} else if (y < -halfSize) {
|
||||
@@ -117,7 +103,6 @@ export function fromEPSG4326(input, opt_output, opt_dimension) {
|
||||
return output;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Transformation from EPSG:3857 to EPSG:4326.
|
||||
*
|
||||
@@ -139,9 +124,9 @@ export function toEPSG4326(input, opt_output, opt_dimension) {
|
||||
}
|
||||
}
|
||||
for (let i = 0; i < length; i += dimension) {
|
||||
output[i] = 180 * input[i] / HALF_SIZE;
|
||||
output[i + 1] = 360 * Math.atan(
|
||||
Math.exp(input[i + 1] / RADIUS)) / Math.PI - 90;
|
||||
output[i] = (180 * input[i]) / HALF_SIZE;
|
||||
output[i + 1] =
|
||||
(360 * Math.atan(Math.exp(input[i + 1] / RADIUS))) / Math.PI - 90;
|
||||
}
|
||||
return output;
|
||||
}
|
||||
|
||||
+3
-11
@@ -4,7 +4,6 @@
|
||||
import Projection from './Projection.js';
|
||||
import Units from './Units.js';
|
||||
|
||||
|
||||
/**
|
||||
* Semi-major radius of the WGS84 ellipsoid.
|
||||
*
|
||||
@@ -13,7 +12,6 @@ import Units from './Units.js';
|
||||
*/
|
||||
export const RADIUS = 6378137;
|
||||
|
||||
|
||||
/**
|
||||
* Extent of the EPSG:4326 projection which is the whole world.
|
||||
*
|
||||
@@ -22,13 +20,11 @@ export const RADIUS = 6378137;
|
||||
*/
|
||||
export const EXTENT = [-180, -90, 180, 90];
|
||||
|
||||
|
||||
/**
|
||||
* @const
|
||||
* @type {number}
|
||||
*/
|
||||
export const METERS_PER_UNIT = Math.PI * RADIUS / 180;
|
||||
|
||||
export const METERS_PER_UNIT = (Math.PI * RADIUS) / 180;
|
||||
|
||||
/**
|
||||
* @classdesc
|
||||
@@ -39,7 +35,6 @@ export const METERS_PER_UNIT = Math.PI * RADIUS / 180;
|
||||
* OpenLayers treats EPSG:4326 as a pseudo-projection, with x,y coordinates.
|
||||
*/
|
||||
class EPSG4326Projection extends Projection {
|
||||
|
||||
/**
|
||||
* @param {string} code Code.
|
||||
* @param {string=} opt_axisOrientation Axis orientation.
|
||||
@@ -52,14 +47,11 @@ class EPSG4326Projection extends Projection {
|
||||
axisOrientation: opt_axisOrientation,
|
||||
global: true,
|
||||
metersPerUnit: METERS_PER_UNIT,
|
||||
worldExtent: EXTENT
|
||||
worldExtent: EXTENT,
|
||||
});
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Projections equal to EPSG:4326.
|
||||
*
|
||||
@@ -74,5 +66,5 @@ export const PROJECTIONS = [
|
||||
new EPSG4326Projection('urn:ogc:def:crs:OGC:1.3:CRS84'),
|
||||
new EPSG4326Projection('urn:ogc:def:crs:OGC:2:84'),
|
||||
new EPSG4326Projection('http://www.opengis.net/gml/srs/epsg.xml#4326', 'neu'),
|
||||
new EPSG4326Projection('urn:x-ogc:def:crs:EPSG:4326', 'neu')
|
||||
new EPSG4326Projection('urn:x-ogc:def:crs:EPSG:4326', 'neu'),
|
||||
];
|
||||
|
||||
+21
-9
@@ -1,9 +1,14 @@
|
||||
/**
|
||||
* @module ol/proj/proj4
|
||||
*/
|
||||
import {addCoordinateTransforms, addProjection, addEquivalentProjections, get} from '../proj.js';
|
||||
import {get as getTransform} from './transforms.js';
|
||||
import Projection from './Projection.js';
|
||||
import {
|
||||
addCoordinateTransforms,
|
||||
addEquivalentProjections,
|
||||
addProjection,
|
||||
get,
|
||||
} from '../proj.js';
|
||||
import {get as getTransform} from './transforms.js';
|
||||
|
||||
/**
|
||||
* Make projections defined in proj4 (with `proj4.defs()`) available in
|
||||
@@ -24,12 +29,14 @@ export function register(proj4) {
|
||||
const code = projCodes[i];
|
||||
if (!get(code)) {
|
||||
const def = proj4.defs(code);
|
||||
addProjection(new Projection({
|
||||
code: code,
|
||||
axisOrientation: def.axis,
|
||||
metersPerUnit: def.to_meter,
|
||||
units: def.units
|
||||
}));
|
||||
addProjection(
|
||||
new Projection({
|
||||
code: code,
|
||||
axisOrientation: def.axis,
|
||||
metersPerUnit: def.to_meter,
|
||||
units: def.units,
|
||||
})
|
||||
);
|
||||
}
|
||||
}
|
||||
for (i = 0; i < len; ++i) {
|
||||
@@ -43,7 +50,12 @@ export function register(proj4) {
|
||||
addEquivalentProjections([proj1, proj2]);
|
||||
} else {
|
||||
const transform = proj4(code1, code2);
|
||||
addCoordinateTransforms(proj1, proj2, transform.forward, transform.inverse);
|
||||
addCoordinateTransforms(
|
||||
proj1,
|
||||
proj2,
|
||||
transform.forward,
|
||||
transform.inverse
|
||||
);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -2,13 +2,11 @@
|
||||
* @module ol/proj/projections
|
||||
*/
|
||||
|
||||
|
||||
/**
|
||||
* @type {Object<string, import("./Projection.js").default>}
|
||||
*/
|
||||
let cache = {};
|
||||
|
||||
|
||||
/**
|
||||
* Clear the projections cache.
|
||||
*/
|
||||
@@ -16,7 +14,6 @@ export function clear() {
|
||||
cache = {};
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Get a cached projection by code.
|
||||
* @param {string} code The code for the projection.
|
||||
@@ -26,7 +23,6 @@ export function get(code) {
|
||||
return cache[code] || null;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Add a projection to the cache.
|
||||
* @param {string} code The projection code.
|
||||
|
||||
@@ -3,14 +3,12 @@
|
||||
*/
|
||||
import {isEmpty} from '../obj.js';
|
||||
|
||||
|
||||
/**
|
||||
* @private
|
||||
* @type {!Object<string, Object<string, import("../proj.js").TransformFunction>>}
|
||||
*/
|
||||
let transforms = {};
|
||||
|
||||
|
||||
/**
|
||||
* Clear the transform cache.
|
||||
*/
|
||||
@@ -18,7 +16,6 @@ export function clear() {
|
||||
transforms = {};
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Registers a conversion function to convert coordinates from the source
|
||||
* projection to the destination projection.
|
||||
@@ -36,7 +33,6 @@ export function add(source, destination, transformFn) {
|
||||
transforms[sourceCode][destinationCode] = transformFn;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Unregisters the conversion function to convert coordinates from the source
|
||||
* projection to the destination projection. This method is used to clean up
|
||||
@@ -57,7 +53,6 @@ export function remove(source, destination) {
|
||||
return transform;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Get a transform given a source code and a destination code.
|
||||
* @param {string} sourceCode The code for the source projection.
|
||||
|
||||
Reference in New Issue
Block a user