Use blocked scoped variables
In addition to using const and let, this also upgrades our linter config and removes lint (mostly whitespace).
This commit is contained in:
+12
-12
@@ -5,7 +5,7 @@ import {inherits} from '../index.js';
|
||||
import {cosh} from '../math.js';
|
||||
import Projection from '../proj/Projection.js';
|
||||
import Units from '../proj/Units.js';
|
||||
var _ol_proj_EPSG3857_ = {};
|
||||
const _ol_proj_EPSG3857_ = {};
|
||||
|
||||
|
||||
/**
|
||||
@@ -91,9 +91,9 @@ _ol_proj_EPSG3857_.PROJECTIONS = [
|
||||
* @return {Array.<number>} Output array of coordinate values.
|
||||
*/
|
||||
_ol_proj_EPSG3857_.fromEPSG4326 = function(input, opt_output, opt_dimension) {
|
||||
var length = input.length,
|
||||
dimension = opt_dimension > 1 ? opt_dimension : 2,
|
||||
output = opt_output;
|
||||
const length = input.length;
|
||||
const dimension = opt_dimension > 1 ? opt_dimension : 2;
|
||||
let output = opt_output;
|
||||
if (output === undefined) {
|
||||
if (dimension > 2) {
|
||||
// preserve values beyond second dimension
|
||||
@@ -102,10 +102,10 @@ _ol_proj_EPSG3857_.fromEPSG4326 = function(input, opt_output, opt_dimension) {
|
||||
output = new Array(length);
|
||||
}
|
||||
}
|
||||
var halfSize = _ol_proj_EPSG3857_.HALF_SIZE;
|
||||
for (var i = 0; i < length; i += dimension) {
|
||||
const halfSize = _ol_proj_EPSG3857_.HALF_SIZE;
|
||||
for (let i = 0; i < length; i += dimension) {
|
||||
output[i] = halfSize * input[i] / 180;
|
||||
var y = _ol_proj_EPSG3857_.RADIUS *
|
||||
let y = _ol_proj_EPSG3857_.RADIUS *
|
||||
Math.log(Math.tan(Math.PI * (input[i + 1] + 90) / 360));
|
||||
if (y > halfSize) {
|
||||
y = halfSize;
|
||||
@@ -127,9 +127,9 @@ _ol_proj_EPSG3857_.fromEPSG4326 = function(input, opt_output, opt_dimension) {
|
||||
* @return {Array.<number>} Output array of coordinate values.
|
||||
*/
|
||||
_ol_proj_EPSG3857_.toEPSG4326 = function(input, opt_output, opt_dimension) {
|
||||
var length = input.length,
|
||||
dimension = opt_dimension > 1 ? opt_dimension : 2,
|
||||
output = opt_output;
|
||||
const length = input.length;
|
||||
const dimension = opt_dimension > 1 ? opt_dimension : 2;
|
||||
let output = opt_output;
|
||||
if (output === undefined) {
|
||||
if (dimension > 2) {
|
||||
// preserve values beyond second dimension
|
||||
@@ -138,10 +138,10 @@ _ol_proj_EPSG3857_.toEPSG4326 = function(input, opt_output, opt_dimension) {
|
||||
output = new Array(length);
|
||||
}
|
||||
}
|
||||
for (var i = 0; i < length; i += dimension) {
|
||||
for (let i = 0; i < length; i += dimension) {
|
||||
output[i] = 180 * input[i] / _ol_proj_EPSG3857_.HALF_SIZE;
|
||||
output[i + 1] = 360 * Math.atan(
|
||||
Math.exp(input[i + 1] / _ol_proj_EPSG3857_.RADIUS)) / Math.PI - 90;
|
||||
Math.exp(input[i + 1] / _ol_proj_EPSG3857_.RADIUS)) / Math.PI - 90;
|
||||
}
|
||||
return output;
|
||||
};
|
||||
|
||||
@@ -4,7 +4,7 @@
|
||||
import {inherits} from '../index.js';
|
||||
import Projection from '../proj/Projection.js';
|
||||
import Units from '../proj/Units.js';
|
||||
var _ol_proj_EPSG4326_ = {};
|
||||
const _ol_proj_EPSG4326_ = {};
|
||||
|
||||
|
||||
/**
|
||||
|
||||
@@ -33,7 +33,7 @@ import Units from '../proj/Units.js';
|
||||
* @struct
|
||||
* @api
|
||||
*/
|
||||
var Projection = function(options) {
|
||||
const Projection = function(options) {
|
||||
/**
|
||||
* @private
|
||||
* @type {string}
|
||||
|
||||
@@ -6,7 +6,7 @@
|
||||
* `'us-ft'`.
|
||||
* @enum {string}
|
||||
*/
|
||||
var Units = {
|
||||
const Units = {
|
||||
DEGREES: 'degrees',
|
||||
FEET: 'ft',
|
||||
METERS: 'm',
|
||||
|
||||
+10
-10
@@ -17,13 +17,13 @@ import Projection from './Projection.js';
|
||||
* @api
|
||||
*/
|
||||
export function register(proj4) {
|
||||
var projCodes = Object.keys(proj4.defs);
|
||||
var len = projCodes.length;
|
||||
var i, j;
|
||||
const projCodes = Object.keys(proj4.defs);
|
||||
const len = projCodes.length;
|
||||
let i, j;
|
||||
for (i = 0; i < len; ++i) {
|
||||
var code = projCodes[i];
|
||||
const code = projCodes[i];
|
||||
if (!get(code)) {
|
||||
var def = proj4.defs(code);
|
||||
const def = proj4.defs(code);
|
||||
addProjection(new Projection({
|
||||
code: code,
|
||||
axisOrientation: def.axis,
|
||||
@@ -33,16 +33,16 @@ export function register(proj4) {
|
||||
}
|
||||
}
|
||||
for (i = 0; i < len; ++i) {
|
||||
var code1 = projCodes[i];
|
||||
var proj1 = get(code1);
|
||||
const code1 = projCodes[i];
|
||||
const proj1 = get(code1);
|
||||
for (j = 0; j < len; ++j) {
|
||||
var code2 = projCodes[j];
|
||||
var proj2 = get(code2);
|
||||
const code2 = projCodes[j];
|
||||
const proj2 = get(code2);
|
||||
if (!getTransform(code1, code2)) {
|
||||
if (proj4.defs[code1] === proj4.defs[code2]) {
|
||||
addEquivalentProjections([proj1, proj2]);
|
||||
} else {
|
||||
var transform = proj4(code1, code2);
|
||||
const transform = proj4(code1, code2);
|
||||
addCoordinateTransforms(proj1, proj2, transform.forward, transform.inverse);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
/**
|
||||
* @module ol/proj/projections
|
||||
*/
|
||||
var _ol_proj_projections_ = {};
|
||||
const _ol_proj_projections_ = {};
|
||||
|
||||
|
||||
/**
|
||||
@@ -25,7 +25,7 @@ _ol_proj_projections_.clear = function() {
|
||||
* @return {ol.proj.Projection} The projection (if cached).
|
||||
*/
|
||||
_ol_proj_projections_.get = function(code) {
|
||||
var projections = _ol_proj_projections_.cache_;
|
||||
const projections = _ol_proj_projections_.cache_;
|
||||
return projections[code] || null;
|
||||
};
|
||||
|
||||
@@ -36,7 +36,7 @@ _ol_proj_projections_.get = function(code) {
|
||||
* @param {ol.proj.Projection} projection The projection to cache.
|
||||
*/
|
||||
_ol_proj_projections_.add = function(code, projection) {
|
||||
var projections = _ol_proj_projections_.cache_;
|
||||
const projections = _ol_proj_projections_.cache_;
|
||||
projections[code] = projection;
|
||||
};
|
||||
export default _ol_proj_projections_;
|
||||
|
||||
@@ -8,7 +8,7 @@ import _ol_obj_ from '../obj.js';
|
||||
* @private
|
||||
* @type {Object.<string, Object.<string, ol.TransformFunction>>}
|
||||
*/
|
||||
var transforms = {};
|
||||
let transforms = {};
|
||||
|
||||
|
||||
/**
|
||||
@@ -28,8 +28,8 @@ export function clear() {
|
||||
* @param {ol.TransformFunction} transformFn Transform.
|
||||
*/
|
||||
export function add(source, destination, transformFn) {
|
||||
var sourceCode = source.getCode();
|
||||
var destinationCode = destination.getCode();
|
||||
const sourceCode = source.getCode();
|
||||
const destinationCode = destination.getCode();
|
||||
if (!(sourceCode in transforms)) {
|
||||
transforms[sourceCode] = {};
|
||||
}
|
||||
@@ -47,9 +47,9 @@ export function add(source, destination, transformFn) {
|
||||
* @return {ol.TransformFunction} transformFn The unregistered transform.
|
||||
*/
|
||||
export function remove(source, destination) {
|
||||
var sourceCode = source.getCode();
|
||||
var destinationCode = destination.getCode();
|
||||
var transform = transforms[sourceCode][destinationCode];
|
||||
const sourceCode = source.getCode();
|
||||
const destinationCode = destination.getCode();
|
||||
const transform = transforms[sourceCode][destinationCode];
|
||||
delete transforms[sourceCode][destinationCode];
|
||||
if (_ol_obj_.isEmpty(transforms[sourceCode])) {
|
||||
delete transforms[sourceCode];
|
||||
@@ -65,7 +65,7 @@ export function remove(source, destination) {
|
||||
* @return {ol.TransformFunction|undefined} The transform function (if found).
|
||||
*/
|
||||
export function get(sourceCode, destinationCode) {
|
||||
var transform;
|
||||
let transform;
|
||||
if (sourceCode in transforms && destinationCode in transforms[sourceCode]) {
|
||||
transform = transforms[sourceCode][destinationCode];
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user