@ulrik.ek/wgs84 1.0.4 → 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 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
- - 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!_
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
 
@@ -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,61 +1,66 @@
1
- {
2
- "name": "@ulrik.ek/wgs84",
3
- "version": "1.0.4",
4
- "description": "Basic library for computing small distances between WGS84 coordinates using a flat earth approximation.",
5
- "author": "Ulrik E.",
6
- "license": "MIT",
7
- "main": "dist/index.js",
8
- "directories": {
9
- "doc": "doc",
10
- "test": "test"
11
- },
12
- "type": "commonjs",
13
- "scripts": {
14
- "audit": "npm audit --registry=https://registry.npmjs.org",
15
- "lint": "npx eslint .",
16
- "lint_fix": "npx eslint . --fix",
17
- "style": "npx prettier --check \"./**/*.ts\" --check \"./**/*.json\" --check \"./**/*.md\"",
18
- "style_fix": "npx prettier --write \"./**/*.ts\" --write \"./**/*.json\" --write \"./**/*.md\"",
19
- "verify_and_install": "npm cache verify && npm install",
20
- "clean": "npx shx rm -rf ./coverage/ ./report/ ./dist/",
21
- "build": "tsc --build tsconfig.json",
22
- "test": "npm run clean && npx jest --clearCache && jest --verbose --coverage --color --modulePathIgnorePatterns=./dist/ && npm run build",
23
- "run_example": "npx ts-node example/index.ts",
24
- "type_doc": "npx typedoc --plugin typedoc-plugin-markdown --out doc src/index.ts --excludeNotDocumented"
25
- },
26
- "devDependencies": {
27
- "@types/geojson": "^7946.0.14",
28
- "@types/jest": "^29.5.12",
29
- "@types/node": "^22.1.0",
30
- "@typescript-eslint/eslint-plugin": "^7.5.0",
31
- "@typescript-eslint/parser": "^7.5.0",
32
- "eslint": "^8.57.0",
33
- "eslint-plugin-import": "^2.29.1",
34
- "eslint-plugin-jest": "^27.9.0",
35
- "eslint-plugin-json": "^3.1.0",
36
- "eslint-plugin-simple-import-sort": "^12.0.0",
37
- "eslint-plugin-sort-class-members": "^1.20.0",
38
- "eslint-plugin-sort-keys-fix": "^1.1.2",
39
- "eslint-plugin-unicorn": "^52.0.0",
40
- "eslint-plugin-yaml": "^0.5.0",
41
- "jest": "^29.7.0",
42
- "jest-junit": "^16.0.0",
43
- "prettier": "3.3.0",
44
- "shx": "^0.3.4",
45
- "ts-jest": "^29.1.2",
46
- "ts-node": "^10.9.2",
47
- "typedoc": "^0.26.5",
48
- "typedoc-plugin-markdown": "^4.2.3",
49
- "typescript": "^5.5.4"
50
- },
51
- "types": "./dist/index.d.ts",
52
- "repository": {
53
- "type": "git",
54
- "url": "git+https://github.com/UEk/wgs84.git"
55
- },
56
- "bugs": {
57
- "url": "https://github.com/UEk/wgs84/issues"
58
- },
59
- "homepage": "https://github.com/UEk/wgs84#readme",
60
- "keywords": ["wgs84", "geojson", "latitude", "longitude"]
61
- }
1
+ {
2
+ "name": "@ulrik.ek/wgs84",
3
+ "version": "1.0.5",
4
+ "description": "Basic library for computing small distances between WGS84 coordinates using a flat earth approximation.",
5
+ "author": "Ulrik E.",
6
+ "license": "MIT",
7
+ "main": "dist/index.js",
8
+ "directories": {
9
+ "doc": "doc",
10
+ "test": "test"
11
+ },
12
+ "type": "commonjs",
13
+ "scripts": {
14
+ "audit": "npm audit --registry=https://registry.npmjs.org",
15
+ "lint": "npx eslint .",
16
+ "lint_fix": "npx eslint . --fix",
17
+ "style": "npx prettier --check \"./**/*.ts\" --check \"./**/*.json\" --check \"./**/*.md\"",
18
+ "style_fix": "npx prettier --write \"./**/*.ts\" --write \"./**/*.json\" --write \"./**/*.md\"",
19
+ "verify_and_install": "npm cache verify && npm install",
20
+ "clean": "npx shx rm -rf ./coverage/ ./report/ ./dist/",
21
+ "build": "tsc --build tsconfig.json",
22
+ "test": "npm run clean && npx jest --clearCache && jest --verbose --coverage --color --modulePathIgnorePatterns=./dist/ && npm run build",
23
+ "run_example": "npx ts-node example/index.ts",
24
+ "type_doc": "npx typedoc --plugin typedoc-plugin-markdown --out doc src/index.ts --excludeNotDocumented"
25
+ },
26
+ "devDependencies": {
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
+ "eslint-plugin-sort-keys-fix": "^1.1.2",
39
+ "globals": "^15.12.0",
40
+ "jest": "^30.2.0",
41
+ "jest-junit": "^16.0.0",
42
+ "prettier": "3.6.2",
43
+ "shx": "^0.4.0",
44
+ "ts-jest": "^29.4.5",
45
+ "ts-node": "^10.9.2",
46
+ "typescript-eslint": "^8.47.0",
47
+ "typedoc": "^0.28.14",
48
+ "typedoc-plugin-markdown": "^4.9.0",
49
+ "typescript": "^5.9.3"
50
+ },
51
+ "types": "./dist/index.d.ts",
52
+ "repository": {
53
+ "type": "git",
54
+ "url": "git+https://github.com/UEk/wgs84.git"
55
+ },
56
+ "bugs": {
57
+ "url": "https://github.com/UEk/wgs84/issues"
58
+ },
59
+ "homepage": "https://github.com/UEk/wgs84#readme",
60
+ "keywords": [
61
+ "wgs84",
62
+ "geojson",
63
+ "latitude",
64
+ "longitude"
65
+ ]
66
+ }