@ulrik.ek/wgs84 1.0.3 → 1.0.5
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +8 -8
- package/dist/index.js +11 -12
- package/dist/index.js.map +1 -1
- package/dist/tsconfig.tsbuildinfo +1 -0
- package/eslint.config.mjs +336 -0
- package/package.json +27 -22
package/README.md
CHANGED
|
@@ -4,11 +4,11 @@
|
|
|
4
4
|
|
|
5
5
|
A tiny library fully implemented in Typescript to handle WGS84 coordinates in GeoJson and "small" distances between them with very high accuracy (~1 cm), based on a local, flat earth approximation.
|
|
6
6
|
|
|
7
|
-
-
|
|
8
|
-
-
|
|
9
|
-
-
|
|
10
|
-
-
|
|
11
|
-
-
|
|
7
|
+
- All functions uses degrees for latitude and longitude, and meters for distances.
|
|
8
|
+
- Parses and gives output in GeoJson using the [Point definition](https://en.wikipedia.org/wiki/GeoJSON). If you already have imported the typescript definition for Point in the geojson package you can use that (that is what I do in unit testing). Otherwise you can import `Point` from this package.
|
|
9
|
+
- No dependencies to other NPM modules.
|
|
10
|
+
- The math is based on [Aviation Formulary V1.47 by Ed Williams](https://edwilliams.org/avform147.htm#flat).
|
|
11
|
+
- Functions will throw `Error` if fed impossible values, e.g. incorrectly formatted GeoJSON or lat >= 90 degrees (math will not work!). _Make sure to handle that!_
|
|
12
12
|
|
|
13
13
|
## Getting Started
|
|
14
14
|
|
|
@@ -26,7 +26,7 @@ const lat = 15;
|
|
|
26
26
|
const lon = 25;
|
|
27
27
|
const p: wgs84.Point = wgs84.point(lat, lon);
|
|
28
28
|
|
|
29
|
-
// Getting a new point
|
|
29
|
+
// Getting a new point 300m north and 400m east of the first point
|
|
30
30
|
const p1: wgs84.Point = wgs84.pointEastOf(wgs84.pointNorthOf(p, 300), 400);
|
|
31
31
|
const newLat = p1.coordinates[1]; // GeoJSON uses [lon, lat] order!
|
|
32
32
|
const newLon = p1.coordinates[0];
|
|
@@ -45,7 +45,7 @@ This will produce the following output
|
|
|
45
45
|
> Distance along east=400.00504064747975
|
|
46
46
|
> Total distance=500.0040325271862
|
|
47
47
|
|
|
48
|
-
##
|
|
48
|
+
## Documentation
|
|
49
49
|
|
|
50
50
|
The following functions are available:
|
|
51
51
|
|
|
@@ -63,7 +63,7 @@ pointEastOf(origin: Point, dE: number): Point;
|
|
|
63
63
|
pointAbove(origin: Point, dH: number): Point;
|
|
64
64
|
```
|
|
65
65
|
|
|
66
|
-
[Full Typedoc documentation](https://github.com/UEk/wgs84/blob/main/doc/
|
|
66
|
+
[Full Typedoc documentation](https://github.com/UEk/wgs84/blob/main/doc/globals.md)
|
|
67
67
|
|
|
68
68
|
# Build and Test
|
|
69
69
|
|
package/dist/index.js
CHANGED
|
@@ -1,6 +1,16 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.
|
|
3
|
+
exports.point = point;
|
|
4
|
+
exports.R1 = R1;
|
|
5
|
+
exports.R2 = R2;
|
|
6
|
+
exports.distanceNorth = distanceNorth;
|
|
7
|
+
exports.distanceEast = distanceEast;
|
|
8
|
+
exports.distanceUp = distanceUp;
|
|
9
|
+
exports.distance = distance;
|
|
10
|
+
exports.bearing = bearing;
|
|
11
|
+
exports.pointNorthOf = pointNorthOf;
|
|
12
|
+
exports.pointEastOf = pointEastOf;
|
|
13
|
+
exports.pointAbove = pointAbove;
|
|
4
14
|
function point(lat, lon, height) {
|
|
5
15
|
const result = height
|
|
6
16
|
? { coordinates: [lon, lat, height], type: 'Point' }
|
|
@@ -8,7 +18,6 @@ function point(lat, lon, height) {
|
|
|
8
18
|
validCoord(result);
|
|
9
19
|
return result;
|
|
10
20
|
}
|
|
11
|
-
exports.point = point;
|
|
12
21
|
const R = 6378.137 * 1000;
|
|
13
22
|
const f = 1 / 298.257_223_563;
|
|
14
23
|
const eSquared = f * (2 - f);
|
|
@@ -17,13 +26,11 @@ function R1(position) {
|
|
|
17
26
|
const lat = degToRad(position.coordinates[1]);
|
|
18
27
|
return (R * (1 - eSquared)) / Math.pow(1 - eSquared * Math.pow(Math.sin(lat), 2), 3 / 2);
|
|
19
28
|
}
|
|
20
|
-
exports.R1 = R1;
|
|
21
29
|
function R2(position) {
|
|
22
30
|
validCoord(position);
|
|
23
31
|
const lat = degToRad(position.coordinates[1]);
|
|
24
32
|
return R / Math.sqrt(1 - eSquared * Math.pow(Math.sin(lat), 2));
|
|
25
33
|
}
|
|
26
|
-
exports.R2 = R2;
|
|
27
34
|
function distanceNorth(origin, target) {
|
|
28
35
|
validCoord(origin);
|
|
29
36
|
validCoord(target);
|
|
@@ -31,7 +38,6 @@ function distanceNorth(origin, target) {
|
|
|
31
38
|
const targetLat = degToRad(target.coordinates[1]);
|
|
32
39
|
return R1(origin) * (targetLat - originLat);
|
|
33
40
|
}
|
|
34
|
-
exports.distanceNorth = distanceNorth;
|
|
35
41
|
function distanceEast(origin, target) {
|
|
36
42
|
validCoord(origin);
|
|
37
43
|
validCoord(target);
|
|
@@ -47,7 +53,6 @@ function distanceEast(origin, target) {
|
|
|
47
53
|
}
|
|
48
54
|
return R2(origin) * Math.cos(originLat) * deltaAngle;
|
|
49
55
|
}
|
|
50
|
-
exports.distanceEast = distanceEast;
|
|
51
56
|
function distanceUp(origin, target) {
|
|
52
57
|
if (origin.coordinates.length === 3 && target.coordinates.length === 3) {
|
|
53
58
|
return target.coordinates[2] - origin.coordinates[2];
|
|
@@ -56,7 +61,6 @@ function distanceUp(origin, target) {
|
|
|
56
61
|
throw new Error('Input is not GeoJSON Point with height.');
|
|
57
62
|
}
|
|
58
63
|
}
|
|
59
|
-
exports.distanceUp = distanceUp;
|
|
60
64
|
function distance(origin, target) {
|
|
61
65
|
if (origin.coordinates.length === 2 || target.coordinates.length === 2) {
|
|
62
66
|
return Math.hypot(distanceNorth(origin, target), distanceEast(origin, target));
|
|
@@ -68,14 +72,12 @@ function distance(origin, target) {
|
|
|
68
72
|
throw new Error('Inputs are not GeoJSON Points.');
|
|
69
73
|
}
|
|
70
74
|
}
|
|
71
|
-
exports.distance = distance;
|
|
72
75
|
function bearing(origin, target) {
|
|
73
76
|
validCoord(origin);
|
|
74
77
|
validCoord(target);
|
|
75
78
|
return ((radToDeg(Math.atan2(distanceEast(origin, target), distanceNorth(origin, target))) + 360) %
|
|
76
79
|
360);
|
|
77
80
|
}
|
|
78
|
-
exports.bearing = bearing;
|
|
79
81
|
function pointNorthOf(origin, dN) {
|
|
80
82
|
validCoord(origin);
|
|
81
83
|
const lon = origin.coordinates[0];
|
|
@@ -91,7 +93,6 @@ function pointNorthOf(origin, dN) {
|
|
|
91
93
|
validCoord(result);
|
|
92
94
|
return result;
|
|
93
95
|
}
|
|
94
|
-
exports.pointNorthOf = pointNorthOf;
|
|
95
96
|
function pointEastOf(origin, dE) {
|
|
96
97
|
validCoord(origin);
|
|
97
98
|
const lat = origin.coordinates[1];
|
|
@@ -110,7 +111,6 @@ function pointEastOf(origin, dE) {
|
|
|
110
111
|
return { coordinates: [lon, lat], type: 'Point' };
|
|
111
112
|
}
|
|
112
113
|
}
|
|
113
|
-
exports.pointEastOf = pointEastOf;
|
|
114
114
|
function pointAbove(origin, dH) {
|
|
115
115
|
validCoord(origin);
|
|
116
116
|
return {
|
|
@@ -118,7 +118,6 @@ function pointAbove(origin, dH) {
|
|
|
118
118
|
type: 'Point'
|
|
119
119
|
};
|
|
120
120
|
}
|
|
121
|
-
exports.pointAbove = pointAbove;
|
|
122
121
|
function degToRad(deg) {
|
|
123
122
|
return (deg * Math.PI) / 180;
|
|
124
123
|
}
|
package/dist/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":";;AAiBA,sBAMC;AAeD,gBAIC;AAQD,gBAIC;AASD,sCAMC;AASD,oCAaC;AAQD,gCAMC;AAU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AI,CAAC,CAAC,WAAW,CAAC,MAAM,KAAK,CAAC,CAAC;QAC1D,CAAC,EAAE,IAAI,CAAC,CAAC,WAAW,CAAC,CAAC,CAAC;QACvB,CAAC,CAAC,WAAW,CAAC,CAAC,CAAC,GAAG,EAAE;QACrB,CAAC,GAAG,IAAI,CAAC,CAAC,WAAW,CAAC,CAAC,CAAC;QACxB,CAAC,CAAC,WAAW,CAAC,CAAC,CAAC,IAAI,GAAG,EACzB,CAAC;QACC,OAAO,IAAI,CAAC;IAChB,CAAC;SAAM,CAAC;QACJ,MAAM,IAAI,KAAK,CAAC,yCAAyC,CAAC,CAAC;IAC/D,CAAC;AACL,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"root":["../src/index.ts"],"version":"5.9.3"}
|
|
@@ -0,0 +1,336 @@
|
|
|
1
|
+
// @ts-check
|
|
2
|
+
import eslint from '@eslint/js';
|
|
3
|
+
import tseslint from 'typescript-eslint';
|
|
4
|
+
import jestPlugin from 'eslint-plugin-jest';
|
|
5
|
+
import importPlugin from 'eslint-plugin-import';
|
|
6
|
+
import simpleImportSort from 'eslint-plugin-simple-import-sort';
|
|
7
|
+
import sortKeysFix from 'eslint-plugin-sort-keys-fix';
|
|
8
|
+
import sortClassMembers from 'eslint-plugin-sort-class-members';
|
|
9
|
+
|
|
10
|
+
export default tseslint.config(
|
|
11
|
+
// Base recommended configs
|
|
12
|
+
eslint.configs.recommended,
|
|
13
|
+
...tseslint.configs.recommended,
|
|
14
|
+
|
|
15
|
+
// Global configuration for TypeScript files with type checking
|
|
16
|
+
{
|
|
17
|
+
files: ['src/**/*.ts'],
|
|
18
|
+
extends: [...tseslint.configs.recommendedTypeChecked],
|
|
19
|
+
|
|
20
|
+
plugins: {
|
|
21
|
+
'@typescript-eslint': tseslint.plugin,
|
|
22
|
+
'jest': jestPlugin,
|
|
23
|
+
'import': importPlugin,
|
|
24
|
+
'simple-import-sort': simpleImportSort,
|
|
25
|
+
'sort-keys-fix': sortKeysFix,
|
|
26
|
+
'sort-class-members': sortClassMembers,
|
|
27
|
+
},
|
|
28
|
+
|
|
29
|
+
languageOptions: {
|
|
30
|
+
parser: tseslint.parser,
|
|
31
|
+
parserOptions: {
|
|
32
|
+
ecmaVersion: 2018,
|
|
33
|
+
sourceType: 'module',
|
|
34
|
+
project: './tsconfig.json',
|
|
35
|
+
},
|
|
36
|
+
globals: {
|
|
37
|
+
// Node.js globals
|
|
38
|
+
process: 'readonly',
|
|
39
|
+
__dirname: 'readonly',
|
|
40
|
+
__filename: 'readonly',
|
|
41
|
+
require: 'readonly',
|
|
42
|
+
module: 'readonly',
|
|
43
|
+
exports: 'writable',
|
|
44
|
+
Buffer: 'readonly',
|
|
45
|
+
console: 'readonly',
|
|
46
|
+
// Jest globals
|
|
47
|
+
describe: 'readonly',
|
|
48
|
+
test: 'readonly',
|
|
49
|
+
it: 'readonly',
|
|
50
|
+
expect: 'readonly',
|
|
51
|
+
beforeEach: 'readonly',
|
|
52
|
+
afterEach: 'readonly',
|
|
53
|
+
beforeAll: 'readonly',
|
|
54
|
+
afterAll: 'readonly',
|
|
55
|
+
jest: 'readonly',
|
|
56
|
+
},
|
|
57
|
+
},
|
|
58
|
+
|
|
59
|
+
settings: {
|
|
60
|
+
'import/parsers': {
|
|
61
|
+
'@typescript-eslint/parser': ['.ts'],
|
|
62
|
+
},
|
|
63
|
+
'import/resolver': {
|
|
64
|
+
node: {
|
|
65
|
+
extensions: ['.ts'],
|
|
66
|
+
},
|
|
67
|
+
},
|
|
68
|
+
},
|
|
69
|
+
|
|
70
|
+
rules: {
|
|
71
|
+
// Jest recommended rules
|
|
72
|
+
...jestPlugin.configs.recommended.rules,
|
|
73
|
+
|
|
74
|
+
// Import plugin rules
|
|
75
|
+
'import/first': 'error',
|
|
76
|
+
'import/newline-after-import': 'error',
|
|
77
|
+
'import/no-duplicates': 'error',
|
|
78
|
+
'import/no-default-export': 'error',
|
|
79
|
+
|
|
80
|
+
// Simple import sort
|
|
81
|
+
'sort-imports': 'off',
|
|
82
|
+
'import/order': 'off',
|
|
83
|
+
'simple-import-sort/imports': 'error',
|
|
84
|
+
'simple-import-sort/exports': 'error',
|
|
85
|
+
|
|
86
|
+
// Sort class members
|
|
87
|
+
'sort-class-members/sort-class-members': ['error', {
|
|
88
|
+
order: [
|
|
89
|
+
'[static-properties]',
|
|
90
|
+
'[properties]',
|
|
91
|
+
'[conventional-private-properties]',
|
|
92
|
+
'constructor',
|
|
93
|
+
'[static-methods]',
|
|
94
|
+
'[methods]',
|
|
95
|
+
'[conventional-private-methods]',
|
|
96
|
+
],
|
|
97
|
+
accessorPairPositioning: 'getThenSet',
|
|
98
|
+
}],
|
|
99
|
+
|
|
100
|
+
// Sort keys
|
|
101
|
+
'sort-keys-fix/sort-keys-fix': 'warn',
|
|
102
|
+
|
|
103
|
+
// Error prevention
|
|
104
|
+
'no-async-promise-executor': 'off',
|
|
105
|
+
'no-return-assign': 'error',
|
|
106
|
+
'curly': 'error',
|
|
107
|
+
'no-throw-literal': 'error',
|
|
108
|
+
'eqeqeq': ['error', 'always'],
|
|
109
|
+
|
|
110
|
+
// Function rules
|
|
111
|
+
'func-names': ['error', 'always'],
|
|
112
|
+
'func-name-matching': ['error', { considerPropertyDescriptor: true }],
|
|
113
|
+
|
|
114
|
+
// Code consistency
|
|
115
|
+
'no-confusing-arrow': 'error',
|
|
116
|
+
'no-useless-computed-key': 'error',
|
|
117
|
+
'no-var': 'error',
|
|
118
|
+
'prefer-const': 'error',
|
|
119
|
+
'prefer-spread': 'error',
|
|
120
|
+
'no-console': 'error',
|
|
121
|
+
'no-void': 'error',
|
|
122
|
+
|
|
123
|
+
// Padding/spacing
|
|
124
|
+
'padding-line-between-statements': [
|
|
125
|
+
'error',
|
|
126
|
+
{ blankLine: 'always', prev: '*', next: 'function' },
|
|
127
|
+
{ blankLine: 'always', prev: '*', next: 'export' },
|
|
128
|
+
],
|
|
129
|
+
|
|
130
|
+
// TypeScript-specific rules
|
|
131
|
+
'@typescript-eslint/restrict-template-expressions': 'off',
|
|
132
|
+
'@typescript-eslint/no-misused-promises': 'off',
|
|
133
|
+
'@typescript-eslint/no-inferrable-types': 'off',
|
|
134
|
+
'@typescript-eslint/no-unused-vars': 'off',
|
|
135
|
+
'@typescript-eslint/no-namespace': ['error', {
|
|
136
|
+
allowDeclarations: false,
|
|
137
|
+
allowDefinitionFiles: false,
|
|
138
|
+
}],
|
|
139
|
+
'@typescript-eslint/explicit-member-accessibility': ['error', {
|
|
140
|
+
accessibility: 'explicit',
|
|
141
|
+
overrides: {
|
|
142
|
+
constructors: 'no-public',
|
|
143
|
+
properties: 'no-public',
|
|
144
|
+
},
|
|
145
|
+
}],
|
|
146
|
+
'@typescript-eslint/no-empty-interface': 'off',
|
|
147
|
+
'@typescript-eslint/explicit-function-return-type': 'error',
|
|
148
|
+
'@typescript-eslint/explicit-module-boundary-types': 'error',
|
|
149
|
+
'@typescript-eslint/interface-name-prefix': 'off',
|
|
150
|
+
'@typescript-eslint/member-delimiter-style': 'off',
|
|
151
|
+
'@typescript-eslint/consistent-type-assertions': ['error', {
|
|
152
|
+
assertionStyle: 'as',
|
|
153
|
+
}],
|
|
154
|
+
'@typescript-eslint/member-ordering': 'off',
|
|
155
|
+
'@typescript-eslint/no-extra-non-null-assertion': 'error',
|
|
156
|
+
'@typescript-eslint/no-misused-new': 'error',
|
|
157
|
+
'@typescript-eslint/no-useless-constructor': 'error',
|
|
158
|
+
'@typescript-eslint/prefer-function-type': 'error',
|
|
159
|
+
'@typescript-eslint/prefer-nullish-coalescing': 'error',
|
|
160
|
+
'@typescript-eslint/require-array-sort-compare': 'error',
|
|
161
|
+
'@typescript-eslint/restrict-plus-operands': 'error',
|
|
162
|
+
'@typescript-eslint/unified-signatures': 'error',
|
|
163
|
+
'@typescript-eslint/prefer-readonly': 'error',
|
|
164
|
+
'@typescript-eslint/prefer-includes': 'error',
|
|
165
|
+
},
|
|
166
|
+
},
|
|
167
|
+
|
|
168
|
+
// Configuration for test and example files (without type checking)
|
|
169
|
+
{
|
|
170
|
+
files: ['test/**/*.ts', 'example/**/*.ts', 'scripts/**/*.ts'],
|
|
171
|
+
|
|
172
|
+
plugins: {
|
|
173
|
+
'@typescript-eslint': tseslint.plugin,
|
|
174
|
+
'jest': jestPlugin,
|
|
175
|
+
'import': importPlugin,
|
|
176
|
+
'simple-import-sort': simpleImportSort,
|
|
177
|
+
'sort-keys-fix': sortKeysFix,
|
|
178
|
+
'sort-class-members': sortClassMembers,
|
|
179
|
+
},
|
|
180
|
+
|
|
181
|
+
languageOptions: {
|
|
182
|
+
parser: tseslint.parser,
|
|
183
|
+
parserOptions: {
|
|
184
|
+
ecmaVersion: 2018,
|
|
185
|
+
sourceType: 'module',
|
|
186
|
+
// No project option - skip type checking for these files
|
|
187
|
+
},
|
|
188
|
+
globals: {
|
|
189
|
+
process: 'readonly',
|
|
190
|
+
__dirname: 'readonly',
|
|
191
|
+
__filename: 'readonly',
|
|
192
|
+
require: 'readonly',
|
|
193
|
+
module: 'readonly',
|
|
194
|
+
exports: 'writable',
|
|
195
|
+
Buffer: 'readonly',
|
|
196
|
+
console: 'readonly',
|
|
197
|
+
describe: 'readonly',
|
|
198
|
+
test: 'readonly',
|
|
199
|
+
it: 'readonly',
|
|
200
|
+
expect: 'readonly',
|
|
201
|
+
beforeEach: 'readonly',
|
|
202
|
+
afterEach: 'readonly',
|
|
203
|
+
beforeAll: 'readonly',
|
|
204
|
+
afterAll: 'readonly',
|
|
205
|
+
jest: 'readonly',
|
|
206
|
+
},
|
|
207
|
+
},
|
|
208
|
+
|
|
209
|
+
settings: {
|
|
210
|
+
'import/parsers': {
|
|
211
|
+
'@typescript-eslint/parser': ['.ts'],
|
|
212
|
+
},
|
|
213
|
+
'import/resolver': {
|
|
214
|
+
node: {
|
|
215
|
+
extensions: ['.ts'],
|
|
216
|
+
},
|
|
217
|
+
},
|
|
218
|
+
},
|
|
219
|
+
|
|
220
|
+
rules: {
|
|
221
|
+
// Jest recommended rules
|
|
222
|
+
...jestPlugin.configs.recommended.rules,
|
|
223
|
+
|
|
224
|
+
// Import plugin rules
|
|
225
|
+
'import/first': 'error',
|
|
226
|
+
'import/newline-after-import': 'error',
|
|
227
|
+
'import/no-duplicates': 'error',
|
|
228
|
+
'import/no-default-export': 'error',
|
|
229
|
+
|
|
230
|
+
// Simple import sort
|
|
231
|
+
'sort-imports': 'off',
|
|
232
|
+
'import/order': 'off',
|
|
233
|
+
'simple-import-sort/imports': 'error',
|
|
234
|
+
'simple-import-sort/exports': 'error',
|
|
235
|
+
|
|
236
|
+
// Sort class members
|
|
237
|
+
'sort-class-members/sort-class-members': ['error', {
|
|
238
|
+
order: [
|
|
239
|
+
'[static-properties]',
|
|
240
|
+
'[properties]',
|
|
241
|
+
'[conventional-private-properties]',
|
|
242
|
+
'constructor',
|
|
243
|
+
'[static-methods]',
|
|
244
|
+
'[methods]',
|
|
245
|
+
'[conventional-private-methods]',
|
|
246
|
+
],
|
|
247
|
+
accessorPairPositioning: 'getThenSet',
|
|
248
|
+
}],
|
|
249
|
+
|
|
250
|
+
// Sort keys
|
|
251
|
+
'sort-keys-fix/sort-keys-fix': 'warn',
|
|
252
|
+
|
|
253
|
+
// Error prevention
|
|
254
|
+
'no-async-promise-executor': 'off',
|
|
255
|
+
'no-return-assign': 'error',
|
|
256
|
+
'curly': 'error',
|
|
257
|
+
'no-throw-literal': 'error',
|
|
258
|
+
'eqeqeq': ['error', 'always'],
|
|
259
|
+
|
|
260
|
+
// Function rules
|
|
261
|
+
'func-names': ['error', 'always'],
|
|
262
|
+
'func-name-matching': ['error', { considerPropertyDescriptor: true }],
|
|
263
|
+
|
|
264
|
+
// Code consistency
|
|
265
|
+
'no-confusing-arrow': 'error',
|
|
266
|
+
'no-useless-computed-key': 'error',
|
|
267
|
+
'no-var': 'error',
|
|
268
|
+
'prefer-const': 'error',
|
|
269
|
+
'prefer-spread': 'error',
|
|
270
|
+
'no-console': 'off', // Allow console in tests/examples
|
|
271
|
+
'no-void': 'error',
|
|
272
|
+
|
|
273
|
+
// Padding/spacing
|
|
274
|
+
'padding-line-between-statements': [
|
|
275
|
+
'error',
|
|
276
|
+
{ blankLine: 'always', prev: '*', next: 'function' },
|
|
277
|
+
{ blankLine: 'always', prev: '*', next: 'export' },
|
|
278
|
+
],
|
|
279
|
+
|
|
280
|
+
// TypeScript-specific rules (non-type-checked versions)
|
|
281
|
+
'@typescript-eslint/no-unused-vars': 'off',
|
|
282
|
+
'@typescript-eslint/no-namespace': ['error', {
|
|
283
|
+
allowDeclarations: false,
|
|
284
|
+
allowDefinitionFiles: false,
|
|
285
|
+
}],
|
|
286
|
+
'@typescript-eslint/explicit-member-accessibility': ['error', {
|
|
287
|
+
accessibility: 'explicit',
|
|
288
|
+
overrides: {
|
|
289
|
+
constructors: 'no-public',
|
|
290
|
+
properties: 'no-public',
|
|
291
|
+
},
|
|
292
|
+
}],
|
|
293
|
+
'@typescript-eslint/no-empty-interface': 'off',
|
|
294
|
+
'@typescript-eslint/explicit-function-return-type': 'error',
|
|
295
|
+
'@typescript-eslint/explicit-module-boundary-types': 'error',
|
|
296
|
+
'@typescript-eslint/interface-name-prefix': 'off',
|
|
297
|
+
'@typescript-eslint/member-delimiter-style': 'off',
|
|
298
|
+
'@typescript-eslint/consistent-type-assertions': ['error', {
|
|
299
|
+
assertionStyle: 'as',
|
|
300
|
+
}],
|
|
301
|
+
'@typescript-eslint/member-ordering': 'off',
|
|
302
|
+
'@typescript-eslint/no-extra-non-null-assertion': 'error',
|
|
303
|
+
'@typescript-eslint/no-misused-new': 'error',
|
|
304
|
+
'@typescript-eslint/no-useless-constructor': 'error',
|
|
305
|
+
|
|
306
|
+
// Relaxed rules for test/example files
|
|
307
|
+
'@typescript-eslint/no-explicit-any': 'off',
|
|
308
|
+
'@typescript-eslint/unbound-method': 'off',
|
|
309
|
+
'@typescript-eslint/require-await': 'off',
|
|
310
|
+
'@typescript-eslint/ban-ts-ignore': 'off',
|
|
311
|
+
'jest/no-disabled-tests': 'off',
|
|
312
|
+
},
|
|
313
|
+
},
|
|
314
|
+
|
|
315
|
+
// Override rules for server files
|
|
316
|
+
{
|
|
317
|
+
files: ['**/server/*.ts'],
|
|
318
|
+
rules: {
|
|
319
|
+
'no-inner-declarations': 'off',
|
|
320
|
+
},
|
|
321
|
+
},
|
|
322
|
+
|
|
323
|
+
|
|
324
|
+
|
|
325
|
+
// Ignore patterns (including config files)
|
|
326
|
+
{
|
|
327
|
+
ignores: [
|
|
328
|
+
'dist/**',
|
|
329
|
+
'coverage/**',
|
|
330
|
+
'report/**',
|
|
331
|
+
'node_modules/**',
|
|
332
|
+
'*.config.*',
|
|
333
|
+
'eslint.config.mjs'
|
|
334
|
+
],
|
|
335
|
+
}
|
|
336
|
+
);
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@ulrik.ek/wgs84",
|
|
3
|
-
"version": "1.0.
|
|
3
|
+
"version": "1.0.5",
|
|
4
4
|
"description": "Basic library for computing small distances between WGS84 coordinates using a flat earth approximation.",
|
|
5
5
|
"author": "Ulrik E.",
|
|
6
6
|
"license": "MIT",
|
|
@@ -24,29 +24,29 @@
|
|
|
24
24
|
"type_doc": "npx typedoc --plugin typedoc-plugin-markdown --out doc src/index.ts --excludeNotDocumented"
|
|
25
25
|
},
|
|
26
26
|
"devDependencies": {
|
|
27
|
-
"@
|
|
28
|
-
"@types/
|
|
29
|
-
"@types/
|
|
30
|
-
"@
|
|
31
|
-
"@typescript-eslint/
|
|
32
|
-
"eslint": "^8.
|
|
33
|
-
"eslint
|
|
34
|
-
"eslint-plugin-
|
|
35
|
-
"eslint-plugin-
|
|
36
|
-
"eslint-plugin-simple-import-sort": "^12.
|
|
37
|
-
"eslint-plugin-sort-class-members": "^1.
|
|
27
|
+
"@eslint/js": "^9.15.0",
|
|
28
|
+
"@types/geojson": "^7946.0.16",
|
|
29
|
+
"@types/jest": "^30.0.0",
|
|
30
|
+
"@types/node": "^24.10.1",
|
|
31
|
+
"@typescript-eslint/eslint-plugin": "^8.47.0",
|
|
32
|
+
"@typescript-eslint/parser": "^8.47.0",
|
|
33
|
+
"eslint": "^9.15.0",
|
|
34
|
+
"eslint-plugin-import": "^2.31.0",
|
|
35
|
+
"eslint-plugin-jest": "^28.9.0",
|
|
36
|
+
"eslint-plugin-simple-import-sort": "^12.1.1",
|
|
37
|
+
"eslint-plugin-sort-class-members": "^1.21.0",
|
|
38
38
|
"eslint-plugin-sort-keys-fix": "^1.1.2",
|
|
39
|
-
"
|
|
40
|
-
"
|
|
41
|
-
"jest": "^29.7.0",
|
|
39
|
+
"globals": "^15.12.0",
|
|
40
|
+
"jest": "^30.2.0",
|
|
42
41
|
"jest-junit": "^16.0.0",
|
|
43
|
-
"prettier": "
|
|
44
|
-
"shx": "^0.
|
|
45
|
-
"ts-jest": "^29.
|
|
42
|
+
"prettier": "3.6.2",
|
|
43
|
+
"shx": "^0.4.0",
|
|
44
|
+
"ts-jest": "^29.4.5",
|
|
46
45
|
"ts-node": "^10.9.2",
|
|
47
|
-
"
|
|
48
|
-
"typedoc
|
|
49
|
-
"
|
|
46
|
+
"typescript-eslint": "^8.47.0",
|
|
47
|
+
"typedoc": "^0.28.14",
|
|
48
|
+
"typedoc-plugin-markdown": "^4.9.0",
|
|
49
|
+
"typescript": "^5.9.3"
|
|
50
50
|
},
|
|
51
51
|
"types": "./dist/index.d.ts",
|
|
52
52
|
"repository": {
|
|
@@ -57,5 +57,10 @@
|
|
|
57
57
|
"url": "https://github.com/UEk/wgs84/issues"
|
|
58
58
|
},
|
|
59
59
|
"homepage": "https://github.com/UEk/wgs84#readme",
|
|
60
|
-
"keywords": [
|
|
60
|
+
"keywords": [
|
|
61
|
+
"wgs84",
|
|
62
|
+
"geojson",
|
|
63
|
+
"latitude",
|
|
64
|
+
"longitude"
|
|
65
|
+
]
|
|
61
66
|
}
|