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:
@@ -13,7 +13,7 @@ import TileWMS from '../src/ol/source/TileWMS.js';
|
||||
// ol.proj.addProjection to make it available to the library for lookup by its
|
||||
// code.
|
||||
|
||||
var projection = new Projection({
|
||||
const projection = new Projection({
|
||||
code: 'EPSG:21781',
|
||||
// The extent is used to determine zoom level 0. Recommended values for a
|
||||
// projection's validity extent can be found at https://epsg.io/.
|
||||
@@ -27,21 +27,21 @@ addProjection(projection);
|
||||
// for setting the view's initial center (see below).
|
||||
|
||||
addCoordinateTransforms('EPSG:4326', projection,
|
||||
function(coordinate) {
|
||||
return [
|
||||
WGStoCHy(coordinate[1], coordinate[0]),
|
||||
WGStoCHx(coordinate[1], coordinate[0])
|
||||
];
|
||||
},
|
||||
function(coordinate) {
|
||||
return [
|
||||
CHtoWGSlng(coordinate[0], coordinate[1]),
|
||||
CHtoWGSlat(coordinate[0], coordinate[1])
|
||||
];
|
||||
});
|
||||
function(coordinate) {
|
||||
return [
|
||||
WGStoCHy(coordinate[1], coordinate[0]),
|
||||
WGStoCHx(coordinate[1], coordinate[0])
|
||||
];
|
||||
},
|
||||
function(coordinate) {
|
||||
return [
|
||||
CHtoWGSlng(coordinate[0], coordinate[1]),
|
||||
CHtoWGSlat(coordinate[0], coordinate[1])
|
||||
];
|
||||
});
|
||||
|
||||
var extent = [420000, 30000, 900000, 350000];
|
||||
var layers = [
|
||||
const extent = [420000, 30000, 900000, 350000];
|
||||
const layers = [
|
||||
new TileLayer({
|
||||
extent: extent,
|
||||
source: new TileWMS({
|
||||
@@ -69,7 +69,7 @@ var layers = [
|
||||
})
|
||||
];
|
||||
|
||||
var map = new Map({
|
||||
const map = new Map({
|
||||
controls: defaultControls().extend([
|
||||
new ScaleLine({
|
||||
units: 'metric'
|
||||
@@ -103,11 +103,11 @@ function WGStoCHy(lat, lng) {
|
||||
lng = DEGtoSEC(lng);
|
||||
|
||||
// Axiliary values (% Bern)
|
||||
var lat_aux = (lat - 169028.66) / 10000;
|
||||
var lng_aux = (lng - 26782.5) / 10000;
|
||||
const lat_aux = (lat - 169028.66) / 10000;
|
||||
const lng_aux = (lng - 26782.5) / 10000;
|
||||
|
||||
// Process Y
|
||||
var y = 600072.37 +
|
||||
const y = 600072.37 +
|
||||
211455.93 * lng_aux -
|
||||
10938.51 * lng_aux * lat_aux -
|
||||
0.36 * lng_aux * Math.pow(lat_aux, 2) -
|
||||
@@ -128,11 +128,11 @@ function WGStoCHx(lat, lng) {
|
||||
lng = DEGtoSEC(lng);
|
||||
|
||||
// Axiliary values (% Bern)
|
||||
var lat_aux = (lat - 169028.66) / 10000;
|
||||
var lng_aux = (lng - 26782.5) / 10000;
|
||||
const lat_aux = (lat - 169028.66) / 10000;
|
||||
const lng_aux = (lng - 26782.5) / 10000;
|
||||
|
||||
// Process X
|
||||
var x = 200147.07 +
|
||||
const x = 200147.07 +
|
||||
308807.95 * lat_aux +
|
||||
3745.25 * Math.pow(lng_aux, 2) +
|
||||
76.63 * Math.pow(lat_aux, 2) -
|
||||
@@ -149,11 +149,11 @@ function CHtoWGSlat(y, x) {
|
||||
|
||||
// Converts militar to civil and to unit = 1000km
|
||||
// Axiliary values (% Bern)
|
||||
var y_aux = (y - 600000) / 1000000;
|
||||
var x_aux = (x - 200000) / 1000000;
|
||||
const y_aux = (y - 600000) / 1000000;
|
||||
const x_aux = (x - 200000) / 1000000;
|
||||
|
||||
// Process lat
|
||||
var lat = 16.9023892 +
|
||||
let lat = 16.9023892 +
|
||||
3.238272 * x_aux -
|
||||
0.270978 * Math.pow(y_aux, 2) -
|
||||
0.002528 * Math.pow(x_aux, 2) -
|
||||
@@ -172,11 +172,11 @@ function CHtoWGSlng(y, x) {
|
||||
|
||||
// Converts militar to civil and to unit = 1000km
|
||||
// Axiliary values (% Bern)
|
||||
var y_aux = (y - 600000) / 1000000;
|
||||
var x_aux = (x - 200000) / 1000000;
|
||||
const y_aux = (y - 600000) / 1000000;
|
||||
const x_aux = (x - 200000) / 1000000;
|
||||
|
||||
// Process long
|
||||
var lng = 2.6779094 +
|
||||
let lng = 2.6779094 +
|
||||
4.728982 * y_aux +
|
||||
0.791484 * y_aux * x_aux +
|
||||
0.1306 * y_aux * Math.pow(x_aux, 2) -
|
||||
@@ -194,9 +194,9 @@ function CHtoWGSlng(y, x) {
|
||||
function DECtoSEX(angle) {
|
||||
|
||||
// Extract DMS
|
||||
var deg = parseInt(angle, 10);
|
||||
var min = parseInt((angle - deg) * 60, 10);
|
||||
var sec = (((angle - deg) * 60) - min) * 60;
|
||||
const deg = parseInt(angle, 10);
|
||||
const min = parseInt((angle - deg) * 60, 10);
|
||||
const sec = (((angle - deg) * 60) - min) * 60;
|
||||
|
||||
// Result in degrees sex (dd.mmss)
|
||||
return deg + min / 100 + sec / 10000;
|
||||
@@ -207,12 +207,12 @@ function DECtoSEX(angle) {
|
||||
function DEGtoSEC(angle) {
|
||||
|
||||
// Extract DMS
|
||||
var deg = parseInt(angle, 10);
|
||||
var min = parseInt((angle - deg) * 100, 10);
|
||||
var sec = (((angle - deg) * 100) - min) * 100;
|
||||
const deg = parseInt(angle, 10);
|
||||
let min = parseInt((angle - deg) * 100, 10);
|
||||
let sec = (((angle - deg) * 100) - min) * 100;
|
||||
|
||||
// Avoid rounding problems with seconds=0
|
||||
var parts = String(angle).split('.');
|
||||
const parts = String(angle).split('.');
|
||||
if (parts.length == 2 && parts[1].length == 2) {
|
||||
min = Number(parts[1]);
|
||||
sec = 0;
|
||||
|
||||
Reference in New Issue
Block a user