@accelint/geo 0.5.1 → 0.6.1
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/CHANGELOG.md +12 -0
- package/README.md +233 -1
- package/catalog-info.yaml +1 -1
- package/dist/cartesian.d.ts +2 -0
- package/dist/cartesian.js +3 -1
- package/dist/cartesian.js.map +1 -1
- package/dist/coordinates/coordinate.d.ts +42 -8
- package/dist/coordinates/coordinate.js +103 -13
- package/dist/coordinates/coordinate.js.map +1 -1
- package/dist/coordinates/latlon/decimal-degrees/formatter.d.ts +21 -1
- package/dist/coordinates/latlon/decimal-degrees/formatter.js +39 -1
- package/dist/coordinates/latlon/decimal-degrees/formatter.js.map +1 -1
- package/dist/coordinates/latlon/decimal-degrees/parser.d.ts +69 -3
- package/dist/coordinates/latlon/decimal-degrees/parser.js +67 -6
- package/dist/coordinates/latlon/decimal-degrees/parser.js.map +1 -1
- package/dist/coordinates/latlon/decimal-degrees/system.d.ts +33 -1
- package/dist/coordinates/latlon/decimal-degrees/system.js +32 -1
- package/dist/coordinates/latlon/decimal-degrees/system.js.map +1 -1
- package/dist/coordinates/latlon/degrees-decimal-minutes/formatter.d.ts +21 -1
- package/dist/coordinates/latlon/degrees-decimal-minutes/formatter.js +43 -3
- package/dist/coordinates/latlon/degrees-decimal-minutes/formatter.js.map +1 -1
- package/dist/coordinates/latlon/degrees-decimal-minutes/parser.d.ts +73 -3
- package/dist/coordinates/latlon/degrees-decimal-minutes/parser.js +67 -4
- package/dist/coordinates/latlon/degrees-decimal-minutes/parser.js.map +1 -1
- package/dist/coordinates/latlon/degrees-decimal-minutes/system.d.ts +33 -1
- package/dist/coordinates/latlon/degrees-decimal-minutes/system.js +32 -1
- package/dist/coordinates/latlon/degrees-decimal-minutes/system.js.map +1 -1
- package/dist/coordinates/latlon/degrees-minutes-seconds/formatter.d.ts +21 -1
- package/dist/coordinates/latlon/degrees-minutes-seconds/formatter.js +46 -4
- package/dist/coordinates/latlon/degrees-minutes-seconds/formatter.js.map +1 -1
- package/dist/coordinates/latlon/degrees-minutes-seconds/parser.d.ts +75 -3
- package/dist/coordinates/latlon/degrees-minutes-seconds/parser.js +67 -4
- package/dist/coordinates/latlon/degrees-minutes-seconds/parser.js.map +1 -1
- package/dist/coordinates/latlon/degrees-minutes-seconds/system.d.ts +33 -1
- package/dist/coordinates/latlon/degrees-minutes-seconds/system.js +32 -1
- package/dist/coordinates/latlon/degrees-minutes-seconds/system.js.map +1 -1
- package/dist/coordinates/latlon/internal/coordinate-system.d.ts +23 -1
- package/dist/coordinates/latlon/internal/coordinate-system.js +1 -1
- package/dist/coordinates/latlon/internal/create-cache.d.ts +18 -2
- package/dist/coordinates/latlon/internal/create-cache.js +20 -4
- package/dist/coordinates/latlon/internal/create-cache.js.map +1 -1
- package/dist/coordinates/latlon/internal/exhaustive-errors.d.ts +15 -0
- package/dist/coordinates/latlon/internal/exhaustive-errors.js +29 -1
- package/dist/coordinates/latlon/internal/exhaustive-errors.js.map +1 -1
- package/dist/coordinates/latlon/internal/format.d.ts +20 -0
- package/dist/coordinates/latlon/internal/format.js +21 -1
- package/dist/coordinates/latlon/internal/format.js.map +1 -1
- package/dist/coordinates/latlon/internal/in-range.d.ts +23 -0
- package/dist/coordinates/latlon/internal/in-range.js +25 -1
- package/dist/coordinates/latlon/internal/in-range.js.map +1 -1
- package/dist/coordinates/latlon/internal/index.d.ts +16 -1
- package/dist/coordinates/latlon/internal/index.js +26 -2
- package/dist/coordinates/latlon/internal/index.js.map +1 -1
- package/dist/coordinates/latlon/internal/lexer.d.ts +2 -0
- package/dist/coordinates/latlon/internal/lexer.js +27 -1
- package/dist/coordinates/latlon/internal/lexer.js.map +1 -1
- package/dist/coordinates/latlon/internal/normalize.d.ts +67 -0
- package/dist/coordinates/latlon/internal/normalize.js +87 -0
- package/dist/coordinates/latlon/internal/normalize.js.map +1 -0
- package/dist/coordinates/latlon/internal/ordinal.d.ts +25 -0
- package/dist/coordinates/latlon/internal/ordinal.js +26 -1
- package/dist/coordinates/latlon/internal/ordinal.js.map +1 -1
- package/dist/coordinates/latlon/internal/parse-format.d.ts +23 -1
- package/dist/coordinates/latlon/internal/parse-format.js +44 -2
- package/dist/coordinates/latlon/internal/parse-format.js.map +1 -1
- package/dist/coordinates/latlon/internal/parse.d.ts +3 -1
- package/dist/coordinates/latlon/internal/parse.js +5 -2
- package/dist/coordinates/latlon/internal/parse.js.map +1 -1
- package/dist/coordinates/latlon/internal/pipes/check-ambiguous.d.ts +18 -1
- package/dist/coordinates/latlon/internal/pipes/check-ambiguous.js +17 -1
- package/dist/coordinates/latlon/internal/pipes/check-ambiguous.js.map +1 -1
- package/dist/coordinates/latlon/internal/pipes/check-numbers.d.ts +26 -1
- package/dist/coordinates/latlon/internal/pipes/check-numbers.js +34 -1
- package/dist/coordinates/latlon/internal/pipes/check-numbers.js.map +1 -1
- package/dist/coordinates/latlon/internal/pipes/fix-bearings.d.ts +18 -1
- package/dist/coordinates/latlon/internal/pipes/fix-bearings.js +32 -1
- package/dist/coordinates/latlon/internal/pipes/fix-bearings.js.map +1 -1
- package/dist/coordinates/latlon/internal/pipes/fix-dividers.d.ts +18 -1
- package/dist/coordinates/latlon/internal/pipes/fix-dividers.js +30 -1
- package/dist/coordinates/latlon/internal/pipes/fix-dividers.js.map +1 -1
- package/dist/coordinates/latlon/internal/pipes/genome.d.ts +17 -1
- package/dist/coordinates/latlon/internal/pipes/genome.js +42 -1
- package/dist/coordinates/latlon/internal/pipes/genome.js.map +1 -1
- package/dist/coordinates/latlon/internal/pipes/index.d.ts +33 -3
- package/dist/coordinates/latlon/internal/pipes/index.js +58 -5
- package/dist/coordinates/latlon/internal/pipes/index.js.map +1 -1
- package/dist/coordinates/latlon/internal/pipes/simpler.d.ts +17 -4
- package/dist/coordinates/latlon/internal/pipes/simpler.js +16 -4
- package/dist/coordinates/latlon/internal/pipes/simpler.js.map +1 -1
- package/dist/coordinates/latlon/internal/validate.d.ts +75 -0
- package/dist/coordinates/latlon/internal/validate.js +105 -0
- package/dist/coordinates/latlon/internal/validate.js.map +1 -0
- package/dist/coordinates/latlon/internal/violation.d.ts +18 -0
- package/dist/coordinates/latlon/internal/violation.js +19 -1
- package/dist/coordinates/latlon/internal/violation.js.map +1 -1
- package/dist/coordinates/mgrs/parser.d.ts +25 -1
- package/dist/coordinates/mgrs/parser.js +57 -1
- package/dist/coordinates/mgrs/parser.js.map +1 -1
- package/dist/coordinates/mgrs/system.d.ts +32 -1
- package/dist/coordinates/mgrs/system.js +31 -1
- package/dist/coordinates/mgrs/system.js.map +1 -1
- package/dist/coordinates/utm/parser.d.ts +25 -1
- package/dist/coordinates/utm/parser.js +57 -1
- package/dist/coordinates/utm/parser.js.map +1 -1
- package/dist/coordinates/utm/system.d.ts +22 -1
- package/dist/coordinates/utm/system.js +21 -1
- package/dist/coordinates/utm/system.js.map +1 -1
- package/dist/index.d.ts +4 -2
- package/dist/index.js +4 -2
- package/dist/patterning.d.ts +12 -2
- package/dist/patterning.js +13 -3
- package/dist/patterning.js.map +1 -1
- package/package.json +5 -3
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
/*
|
|
2
|
-
* Copyright
|
|
2
|
+
* Copyright 2026 Hypergiant Galactic Systems Inc. All rights reserved.
|
|
3
3
|
* This file is licensed to you under the Apache License, Version 2.0 (the "License");
|
|
4
4
|
* you may not use this file except in compliance with the License. You may obtain a copy
|
|
5
5
|
* of the License at https://www.apache.org/licenses/LICENSE-2.0
|
|
@@ -13,15 +13,28 @@
|
|
|
13
13
|
import { Tokens } from "../lexer.js";
|
|
14
14
|
|
|
15
15
|
//#region src/coordinates/latlon/internal/pipes/simpler.d.ts
|
|
16
|
+
|
|
16
17
|
/**
|
|
17
18
|
* Create a simplified pattern string - numbers = 'N', bearings = 'B' - to
|
|
18
19
|
* allow for simpler pattern matching.
|
|
19
20
|
*
|
|
20
|
-
* @
|
|
21
|
-
*
|
|
21
|
+
* @param tokens - Array of coordinate tokens to simplify.
|
|
22
|
+
* @returns Simplified pattern string where 'N' = number and 'B' = bearing.
|
|
23
|
+
*
|
|
24
|
+
* @example
|
|
25
|
+
* ```typescript
|
|
26
|
+
* simpler(['45', '30', 'N', '/', '122', '15', 'W']);
|
|
27
|
+
* // 'NNBNNNB'
|
|
28
|
+
* ```
|
|
22
29
|
*
|
|
23
30
|
* @example
|
|
24
|
-
*
|
|
31
|
+
* ```typescript
|
|
32
|
+
* simpler(['45', 'N']);
|
|
33
|
+
* // 'NB'
|
|
34
|
+
* ```
|
|
35
|
+
*
|
|
36
|
+
* @remarks
|
|
37
|
+
* pure function
|
|
25
38
|
*/
|
|
26
39
|
declare const simpler: (tokens: Tokens) => string;
|
|
27
40
|
//#endregion
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
/*
|
|
2
|
-
* Copyright
|
|
2
|
+
* Copyright 2026 Hypergiant Galactic Systems Inc. All rights reserved.
|
|
3
3
|
* This file is licensed to you under the Apache License, Version 2.0 (the "License");
|
|
4
4
|
* you may not use this file except in compliance with the License. You may obtain a copy
|
|
5
5
|
* of the License at https://www.apache.org/licenses/LICENSE-2.0
|
|
@@ -16,11 +16,23 @@
|
|
|
16
16
|
* Create a simplified pattern string - numbers = 'N', bearings = 'B' - to
|
|
17
17
|
* allow for simpler pattern matching.
|
|
18
18
|
*
|
|
19
|
-
* @
|
|
20
|
-
*
|
|
19
|
+
* @param tokens - Array of coordinate tokens to simplify.
|
|
20
|
+
* @returns Simplified pattern string where 'N' = number and 'B' = bearing.
|
|
21
|
+
*
|
|
22
|
+
* @example
|
|
23
|
+
* ```typescript
|
|
24
|
+
* simpler(['45', '30', 'N', '/', '122', '15', 'W']);
|
|
25
|
+
* // 'NNBNNNB'
|
|
26
|
+
* ```
|
|
21
27
|
*
|
|
22
28
|
* @example
|
|
23
|
-
*
|
|
29
|
+
* ```typescript
|
|
30
|
+
* simpler(['45', 'N']);
|
|
31
|
+
* // 'NB'
|
|
32
|
+
* ```
|
|
33
|
+
*
|
|
34
|
+
* @remarks
|
|
35
|
+
* pure function
|
|
24
36
|
*/
|
|
25
37
|
const simpler = (tokens) => tokens.map((t) => /\d/.test(t) ? "N" : "B").join("");
|
|
26
38
|
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"simpler.js","names":[],"sources":["../../../../../src/coordinates/latlon/internal/pipes/simpler.ts"],"sourcesContent":["// __private-exports\n/*\n * Copyright 2024 Hypergiant Galactic Systems Inc. All rights reserved.\n * This file is licensed to you under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License. You may obtain a copy\n * of the License at https://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software distributed under\n * the License is distributed on an \"AS IS\" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS\n * OF ANY KIND, either express or implied. See the License for the specific language\n * governing permissions and limitations under the License.\n */\n\nimport type { Tokens } from '../lexer';\n\n/**\n * Create a simplified pattern string - numbers = 'N', bearings = 'B' - to\n * allow for simpler pattern matching.\n *\n * @
|
|
1
|
+
{"version":3,"file":"simpler.js","names":[],"sources":["../../../../../src/coordinates/latlon/internal/pipes/simpler.ts"],"sourcesContent":["// __private-exports\n/*\n * Copyright 2024 Hypergiant Galactic Systems Inc. All rights reserved.\n * This file is licensed to you under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License. You may obtain a copy\n * of the License at https://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software distributed under\n * the License is distributed on an \"AS IS\" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS\n * OF ANY KIND, either express or implied. See the License for the specific language\n * governing permissions and limitations under the License.\n */\n\nimport type { Tokens } from '../lexer';\n\n/**\n * Create a simplified pattern string - numbers = 'N', bearings = 'B' - to\n * allow for simpler pattern matching.\n *\n * @param tokens - Array of coordinate tokens to simplify.\n * @returns Simplified pattern string where 'N' = number and 'B' = bearing.\n *\n * @example\n * ```typescript\n * simpler(['45', '30', 'N', '/', '122', '15', 'W']);\n * // 'NNBNNNB'\n * ```\n *\n * @example\n * ```typescript\n * simpler(['45', 'N']);\n * // 'NB'\n * ```\n *\n * @remarks\n * pure function\n */\nexport const simpler = (tokens: Tokens) =>\n tokens.map((t) => (/\\d/.test(t) ? 'N' : 'B')).join('');\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAqCA,MAAa,WAAW,WACtB,OAAO,KAAK,MAAO,KAAK,KAAK,EAAE,GAAG,MAAM,IAAK,CAAC,KAAK,GAAG"}
|
|
@@ -0,0 +1,75 @@
|
|
|
1
|
+
//#region src/coordinates/latlon/internal/validate.d.ts
|
|
2
|
+
/**
|
|
3
|
+
* Checks if a value is a finite number (not NaN, not Infinity, not -Infinity).
|
|
4
|
+
*
|
|
5
|
+
* @param value - The numeric value to check
|
|
6
|
+
* @returns True if the value is a finite number, false otherwise
|
|
7
|
+
*
|
|
8
|
+
* @example
|
|
9
|
+
* ```typescript
|
|
10
|
+
* isFiniteNumber(42); // true
|
|
11
|
+
* isFiniteNumber(NaN); // false
|
|
12
|
+
* isFiniteNumber(Infinity); // false
|
|
13
|
+
* ```
|
|
14
|
+
*/
|
|
15
|
+
declare function isFiniteNumber(value: number): boolean;
|
|
16
|
+
/**
|
|
17
|
+
* Validates that a value is within a signed range (-limit to +limit).
|
|
18
|
+
*
|
|
19
|
+
* @param label - The label for error messages (used as-is for range errors,
|
|
20
|
+
* lowercased for "Invalid" errors)
|
|
21
|
+
* @param value - The numeric value to validate
|
|
22
|
+
* @param limit - The absolute limit (validates -limit to +limit)
|
|
23
|
+
* @returns Error message string if validation fails, undefined if valid
|
|
24
|
+
*
|
|
25
|
+
* @example
|
|
26
|
+
* ```typescript
|
|
27
|
+
* validateSignedRange('Latitude', 45, 90);
|
|
28
|
+
* // => undefined
|
|
29
|
+
* ```
|
|
30
|
+
*
|
|
31
|
+
* @example
|
|
32
|
+
* ```typescript
|
|
33
|
+
* validateSignedRange('Latitude', 95, 90);
|
|
34
|
+
* // => '[ERROR] Latitude value (95) is outside valid range (-90 to 90).'
|
|
35
|
+
* ```
|
|
36
|
+
*
|
|
37
|
+
* @example
|
|
38
|
+
* ```typescript
|
|
39
|
+
* validateSignedRange('Longitude', NaN, 180);
|
|
40
|
+
* // => '[ERROR] Invalid longitude value (NaN); expected a finite number.'
|
|
41
|
+
* ```
|
|
42
|
+
*/
|
|
43
|
+
declare function validateSignedRange(label: string, value: number, limit: number): string | undefined;
|
|
44
|
+
/**
|
|
45
|
+
* Validates numeric latitude and longitude coordinate values.
|
|
46
|
+
*
|
|
47
|
+
* @param lat - The latitude value to validate (must be -90 to 90)
|
|
48
|
+
* @param lon - The longitude value to validate (must be -180 to 180)
|
|
49
|
+
* @returns Array of error message strings, empty if all validations pass
|
|
50
|
+
*
|
|
51
|
+
* @example
|
|
52
|
+
* ```typescript
|
|
53
|
+
* validateNumericCoordinate(45.5, -122.6);
|
|
54
|
+
* // => []
|
|
55
|
+
* ```
|
|
56
|
+
*
|
|
57
|
+
* @example
|
|
58
|
+
* ```typescript
|
|
59
|
+
* validateNumericCoordinate(91, -122.6);
|
|
60
|
+
* // => ['[ERROR] Latitude value (91) is outside valid range (-90 to 90).']
|
|
61
|
+
* ```
|
|
62
|
+
*
|
|
63
|
+
* @example
|
|
64
|
+
* ```typescript
|
|
65
|
+
* validateNumericCoordinate(NaN, 200);
|
|
66
|
+
* // => [
|
|
67
|
+
* // '[ERROR] Invalid latitude value (NaN); expected a finite number.',
|
|
68
|
+
* // '[ERROR] Longitude value (200) is outside valid range (-180 to 180).'
|
|
69
|
+
* // ]
|
|
70
|
+
* ```
|
|
71
|
+
*/
|
|
72
|
+
declare function validateNumericCoordinate(lat: number, lon: number): string[];
|
|
73
|
+
//#endregion
|
|
74
|
+
export { isFiniteNumber, validateNumericCoordinate, validateSignedRange };
|
|
75
|
+
//# sourceMappingURL=validate.d.ts.map
|
|
@@ -0,0 +1,105 @@
|
|
|
1
|
+
/*
|
|
2
|
+
* Copyright 2026 Hypergiant Galactic Systems Inc. All rights reserved.
|
|
3
|
+
* This file is licensed to you under the Apache License, Version 2.0 (the "License");
|
|
4
|
+
* you may not use this file except in compliance with the License. You may obtain a copy
|
|
5
|
+
* of the License at https://www.apache.org/licenses/LICENSE-2.0
|
|
6
|
+
*
|
|
7
|
+
* Unless required by applicable law or agreed to in writing, software distributed under
|
|
8
|
+
* the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS
|
|
9
|
+
* OF ANY KIND, either express or implied. See the License for the specific language
|
|
10
|
+
* governing permissions and limitations under the License.
|
|
11
|
+
*/
|
|
12
|
+
|
|
13
|
+
|
|
14
|
+
import { violation } from "./violation.js";
|
|
15
|
+
|
|
16
|
+
//#region src/coordinates/latlon/internal/validate.ts
|
|
17
|
+
const LAT_LIMIT = 90;
|
|
18
|
+
const LON_LIMIT = 180;
|
|
19
|
+
/**
|
|
20
|
+
* Checks if a value is a finite number (not NaN, not Infinity, not -Infinity).
|
|
21
|
+
*
|
|
22
|
+
* @param value - The numeric value to check
|
|
23
|
+
* @returns True if the value is a finite number, false otherwise
|
|
24
|
+
*
|
|
25
|
+
* @example
|
|
26
|
+
* ```typescript
|
|
27
|
+
* isFiniteNumber(42); // true
|
|
28
|
+
* isFiniteNumber(NaN); // false
|
|
29
|
+
* isFiniteNumber(Infinity); // false
|
|
30
|
+
* ```
|
|
31
|
+
*/
|
|
32
|
+
function isFiniteNumber(value) {
|
|
33
|
+
return typeof value === "number" && Number.isFinite(value);
|
|
34
|
+
}
|
|
35
|
+
/**
|
|
36
|
+
* Validates that a value is within a signed range (-limit to +limit).
|
|
37
|
+
*
|
|
38
|
+
* @param label - The label for error messages (used as-is for range errors,
|
|
39
|
+
* lowercased for "Invalid" errors)
|
|
40
|
+
* @param value - The numeric value to validate
|
|
41
|
+
* @param limit - The absolute limit (validates -limit to +limit)
|
|
42
|
+
* @returns Error message string if validation fails, undefined if valid
|
|
43
|
+
*
|
|
44
|
+
* @example
|
|
45
|
+
* ```typescript
|
|
46
|
+
* validateSignedRange('Latitude', 45, 90);
|
|
47
|
+
* // => undefined
|
|
48
|
+
* ```
|
|
49
|
+
*
|
|
50
|
+
* @example
|
|
51
|
+
* ```typescript
|
|
52
|
+
* validateSignedRange('Latitude', 95, 90);
|
|
53
|
+
* // => '[ERROR] Latitude value (95) is outside valid range (-90 to 90).'
|
|
54
|
+
* ```
|
|
55
|
+
*
|
|
56
|
+
* @example
|
|
57
|
+
* ```typescript
|
|
58
|
+
* validateSignedRange('Longitude', NaN, 180);
|
|
59
|
+
* // => '[ERROR] Invalid longitude value (NaN); expected a finite number.'
|
|
60
|
+
* ```
|
|
61
|
+
*/
|
|
62
|
+
function validateSignedRange(label, value, limit) {
|
|
63
|
+
if (!isFiniteNumber(value)) return violation(`Invalid ${label.toLowerCase()} value (${value}); expected a finite number.`);
|
|
64
|
+
if (value < -limit || value > limit) return violation(`${label} value (${value}) is outside valid range (-${limit} to ${limit}).`);
|
|
65
|
+
}
|
|
66
|
+
/**
|
|
67
|
+
* Validates numeric latitude and longitude coordinate values.
|
|
68
|
+
*
|
|
69
|
+
* @param lat - The latitude value to validate (must be -90 to 90)
|
|
70
|
+
* @param lon - The longitude value to validate (must be -180 to 180)
|
|
71
|
+
* @returns Array of error message strings, empty if all validations pass
|
|
72
|
+
*
|
|
73
|
+
* @example
|
|
74
|
+
* ```typescript
|
|
75
|
+
* validateNumericCoordinate(45.5, -122.6);
|
|
76
|
+
* // => []
|
|
77
|
+
* ```
|
|
78
|
+
*
|
|
79
|
+
* @example
|
|
80
|
+
* ```typescript
|
|
81
|
+
* validateNumericCoordinate(91, -122.6);
|
|
82
|
+
* // => ['[ERROR] Latitude value (91) is outside valid range (-90 to 90).']
|
|
83
|
+
* ```
|
|
84
|
+
*
|
|
85
|
+
* @example
|
|
86
|
+
* ```typescript
|
|
87
|
+
* validateNumericCoordinate(NaN, 200);
|
|
88
|
+
* // => [
|
|
89
|
+
* // '[ERROR] Invalid latitude value (NaN); expected a finite number.',
|
|
90
|
+
* // '[ERROR] Longitude value (200) is outside valid range (-180 to 180).'
|
|
91
|
+
* // ]
|
|
92
|
+
* ```
|
|
93
|
+
*/
|
|
94
|
+
function validateNumericCoordinate(lat, lon) {
|
|
95
|
+
const errors = [];
|
|
96
|
+
const latError = validateSignedRange("Latitude", lat, LAT_LIMIT);
|
|
97
|
+
if (latError) errors.push(latError);
|
|
98
|
+
const lonError = validateSignedRange("Longitude", lon, LON_LIMIT);
|
|
99
|
+
if (lonError) errors.push(lonError);
|
|
100
|
+
return errors;
|
|
101
|
+
}
|
|
102
|
+
|
|
103
|
+
//#endregion
|
|
104
|
+
export { isFiniteNumber, validateNumericCoordinate, validateSignedRange };
|
|
105
|
+
//# sourceMappingURL=validate.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"validate.js","names":["errors: string[]"],"sources":["../../../../src/coordinates/latlon/internal/validate.ts"],"sourcesContent":["/*\n * Copyright 2024 Hypergiant Galactic Systems Inc. All rights reserved.\n * This file is licensed to you under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License. You may obtain a copy\n * of the License at https://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software distributed under\n * the License is distributed on an \"AS IS\" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS\n * OF ANY KIND, either express or implied. See the License for the specific language\n * governing permissions and limitations under the License.\n */\n\nimport { violation } from './violation';\n\nconst LAT_LIMIT = 90;\nconst LON_LIMIT = 180;\n\n/**\n * Checks if a value is a finite number (not NaN, not Infinity, not -Infinity).\n *\n * @param value - The numeric value to check\n * @returns True if the value is a finite number, false otherwise\n *\n * @example\n * ```typescript\n * isFiniteNumber(42); // true\n * isFiniteNumber(NaN); // false\n * isFiniteNumber(Infinity); // false\n * ```\n */\nexport function isFiniteNumber(value: number): boolean {\n return typeof value === 'number' && Number.isFinite(value);\n}\n\n/**\n * Validates that a value is within a signed range (-limit to +limit).\n *\n * @param label - The label for error messages (used as-is for range errors,\n * lowercased for \"Invalid\" errors)\n * @param value - The numeric value to validate\n * @param limit - The absolute limit (validates -limit to +limit)\n * @returns Error message string if validation fails, undefined if valid\n *\n * @example\n * ```typescript\n * validateSignedRange('Latitude', 45, 90);\n * // => undefined\n * ```\n *\n * @example\n * ```typescript\n * validateSignedRange('Latitude', 95, 90);\n * // => '[ERROR] Latitude value (95) is outside valid range (-90 to 90).'\n * ```\n *\n * @example\n * ```typescript\n * validateSignedRange('Longitude', NaN, 180);\n * // => '[ERROR] Invalid longitude value (NaN); expected a finite number.'\n * ```\n */\nexport function validateSignedRange(\n label: string,\n value: number,\n limit: number,\n): string | undefined {\n if (!isFiniteNumber(value)) {\n return violation(\n `Invalid ${label.toLowerCase()} value (${value}); expected a finite number.`,\n );\n }\n\n if (value < -limit || value > limit) {\n return violation(\n `${label} value (${value}) is outside valid range (-${limit} to ${limit}).`,\n );\n }\n}\n\n/**\n * Validates numeric latitude and longitude coordinate values.\n *\n * @param lat - The latitude value to validate (must be -90 to 90)\n * @param lon - The longitude value to validate (must be -180 to 180)\n * @returns Array of error message strings, empty if all validations pass\n *\n * @example\n * ```typescript\n * validateNumericCoordinate(45.5, -122.6);\n * // => []\n * ```\n *\n * @example\n * ```typescript\n * validateNumericCoordinate(91, -122.6);\n * // => ['[ERROR] Latitude value (91) is outside valid range (-90 to 90).']\n * ```\n *\n * @example\n * ```typescript\n * validateNumericCoordinate(NaN, 200);\n * // => [\n * // '[ERROR] Invalid latitude value (NaN); expected a finite number.',\n * // '[ERROR] Longitude value (200) is outside valid range (-180 to 180).'\n * // ]\n * ```\n */\nexport function validateNumericCoordinate(lat: number, lon: number): string[] {\n const errors: string[] = [];\n\n const latError = validateSignedRange('Latitude', lat, LAT_LIMIT);\n if (latError) {\n errors.push(latError);\n }\n\n const lonError = validateSignedRange('Longitude', lon, LON_LIMIT);\n if (lonError) {\n errors.push(lonError);\n }\n\n return errors;\n}\n"],"mappings":";;;;;;;;;;;;;;;;AAcA,MAAM,YAAY;AAClB,MAAM,YAAY;;;;;;;;;;;;;;AAelB,SAAgB,eAAe,OAAwB;AACrD,QAAO,OAAO,UAAU,YAAY,OAAO,SAAS,MAAM;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AA8B5D,SAAgB,oBACd,OACA,OACA,OACoB;AACpB,KAAI,CAAC,eAAe,MAAM,CACxB,QAAO,UACL,WAAW,MAAM,aAAa,CAAC,UAAU,MAAM,8BAChD;AAGH,KAAI,QAAQ,CAAC,SAAS,QAAQ,MAC5B,QAAO,UACL,GAAG,MAAM,UAAU,MAAM,6BAA6B,MAAM,MAAM,MAAM,IACzE;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAgCL,SAAgB,0BAA0B,KAAa,KAAuB;CAC5E,MAAMA,SAAmB,EAAE;CAE3B,MAAM,WAAW,oBAAoB,YAAY,KAAK,UAAU;AAChE,KAAI,SACF,QAAO,KAAK,SAAS;CAGvB,MAAM,WAAW,oBAAoB,aAAa,KAAK,UAAU;AACjE,KAAI,SACF,QAAO,KAAK,SAAS;AAGvB,QAAO"}
|
|
@@ -1,4 +1,22 @@
|
|
|
1
1
|
//#region src/coordinates/latlon/internal/violation.d.ts
|
|
2
|
+
/**
|
|
3
|
+
* Formats an error message with a standard [ERROR] prefix.
|
|
4
|
+
*
|
|
5
|
+
* @param s - The error message string to format.
|
|
6
|
+
* @returns Formatted error string with [ERROR] prefix.
|
|
7
|
+
*
|
|
8
|
+
* @example
|
|
9
|
+
* ```typescript
|
|
10
|
+
* violation('Invalid coordinate value.');
|
|
11
|
+
* // '[ERROR] Invalid coordinate value.'
|
|
12
|
+
* ```
|
|
13
|
+
*
|
|
14
|
+
* @example
|
|
15
|
+
* ```typescript
|
|
16
|
+
* violation('Degrees value (91) exceeds max value (90).');
|
|
17
|
+
* // '[ERROR] Degrees value (91) exceeds max value (90).'
|
|
18
|
+
* ```
|
|
19
|
+
*/
|
|
2
20
|
declare const violation: (s: string) => string;
|
|
3
21
|
//#endregion
|
|
4
22
|
export { violation };
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
/*
|
|
2
|
-
* Copyright
|
|
2
|
+
* Copyright 2026 Hypergiant Galactic Systems Inc. All rights reserved.
|
|
3
3
|
* This file is licensed to you under the Apache License, Version 2.0 (the "License");
|
|
4
4
|
* you may not use this file except in compliance with the License. You may obtain a copy
|
|
5
5
|
* of the License at https://www.apache.org/licenses/LICENSE-2.0
|
|
@@ -12,6 +12,24 @@
|
|
|
12
12
|
|
|
13
13
|
|
|
14
14
|
//#region src/coordinates/latlon/internal/violation.ts
|
|
15
|
+
/**
|
|
16
|
+
* Formats an error message with a standard [ERROR] prefix.
|
|
17
|
+
*
|
|
18
|
+
* @param s - The error message string to format.
|
|
19
|
+
* @returns Formatted error string with [ERROR] prefix.
|
|
20
|
+
*
|
|
21
|
+
* @example
|
|
22
|
+
* ```typescript
|
|
23
|
+
* violation('Invalid coordinate value.');
|
|
24
|
+
* // '[ERROR] Invalid coordinate value.'
|
|
25
|
+
* ```
|
|
26
|
+
*
|
|
27
|
+
* @example
|
|
28
|
+
* ```typescript
|
|
29
|
+
* violation('Degrees value (91) exceeds max value (90).');
|
|
30
|
+
* // '[ERROR] Degrees value (91) exceeds max value (90).'
|
|
31
|
+
* ```
|
|
32
|
+
*/
|
|
15
33
|
const violation = (s) => `[ERROR] ${s}`;
|
|
16
34
|
|
|
17
35
|
//#endregion
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"violation.js","names":[],"sources":["../../../../src/coordinates/latlon/internal/violation.ts"],"sourcesContent":["// __private-exports\n/*\n * Copyright 2024 Hypergiant Galactic Systems Inc. All rights reserved.\n * This file is licensed to you under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License. You may obtain a copy\n * of the License at https://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software distributed under\n * the License is distributed on an \"AS IS\" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS\n * OF ANY KIND, either express or implied. See the License for the specific language\n * governing permissions and limitations under the License.\n */\n\nexport const violation = (s: string) => `[ERROR] ${s}`;\n"],"mappings":"
|
|
1
|
+
{"version":3,"file":"violation.js","names":[],"sources":["../../../../src/coordinates/latlon/internal/violation.ts"],"sourcesContent":["// __private-exports\n/*\n * Copyright 2024 Hypergiant Galactic Systems Inc. All rights reserved.\n * This file is licensed to you under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License. You may obtain a copy\n * of the License at https://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software distributed under\n * the License is distributed on an \"AS IS\" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS\n * OF ANY KIND, either express or implied. See the License for the specific language\n * governing permissions and limitations under the License.\n */\n\n/**\n * Formats an error message with a standard [ERROR] prefix.\n *\n * @param s - The error message string to format.\n * @returns Formatted error string with [ERROR] prefix.\n *\n * @example\n * ```typescript\n * violation('Invalid coordinate value.');\n * // '[ERROR] Invalid coordinate value.'\n * ```\n *\n * @example\n * ```typescript\n * violation('Degrees value (91) exceeds max value (90).');\n * // '[ERROR] Degrees value (91) exceeds max value (90).'\n * ```\n */\nexport const violation = (s: string) => `[ERROR] ${s}`;\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AA+BA,MAAa,aAAa,MAAc,WAAW"}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
/*
|
|
2
|
-
* Copyright
|
|
2
|
+
* Copyright 2026 Hypergiant Galactic Systems Inc. All rights reserved.
|
|
3
3
|
* This file is licensed to you under the Apache License, Version 2.0 (the "License");
|
|
4
4
|
* you may not use this file except in compliance with the License. You may obtain a copy
|
|
5
5
|
* of the License at https://www.apache.org/licenses/LICENSE-2.0
|
|
@@ -13,6 +13,30 @@
|
|
|
13
13
|
import { ParseResults } from "../latlon/internal/parse.js";
|
|
14
14
|
|
|
15
15
|
//#region src/coordinates/mgrs/parser.d.ts
|
|
16
|
+
|
|
17
|
+
/**
|
|
18
|
+
* Parses a Military Grid Reference System (MGRS) coordinate string into latitude/longitude values.
|
|
19
|
+
*
|
|
20
|
+
* Converts MGRS coordinates to UTM, then to latitude/longitude decimal degrees. Returns
|
|
21
|
+
* detailed error messages for invalid MGRS formats including zone numbers, band letters,
|
|
22
|
+
* square identification, and numerical locations.
|
|
23
|
+
*
|
|
24
|
+
* @param _format - Format parameter (unused, MGRS has fixed format).
|
|
25
|
+
* @param input - The MGRS coordinate string to parse (e.g., '31U BF 12345 67890').
|
|
26
|
+
* @returns Parse results with coordinate values or detailed error messages.
|
|
27
|
+
*
|
|
28
|
+
* @example
|
|
29
|
+
* ```typescript
|
|
30
|
+
* parseMGRS(null, '31U BF 12345 67890');
|
|
31
|
+
* // [[['48.123456', 'N'], ['11.234567', 'E']], []]
|
|
32
|
+
* ```
|
|
33
|
+
*
|
|
34
|
+
* @example
|
|
35
|
+
* ```typescript
|
|
36
|
+
* parseMGRS(null, 'invalid');
|
|
37
|
+
* // [[], ['Invalid UTM zone number found...']]
|
|
38
|
+
* ```
|
|
39
|
+
*/
|
|
16
40
|
declare function parseMGRS(_format: any, input: string): ParseResults;
|
|
17
41
|
//#endregion
|
|
18
42
|
export { parseMGRS };
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
/*
|
|
2
|
-
* Copyright
|
|
2
|
+
* Copyright 2026 Hypergiant Galactic Systems Inc. All rights reserved.
|
|
3
3
|
* This file is licensed to you under the Apache License, Version 2.0 (the "License");
|
|
4
4
|
* you may not use this file except in compliance with the License. You may obtain a copy
|
|
5
5
|
* of the License at https://www.apache.org/licenses/LICENSE-2.0
|
|
@@ -17,7 +17,40 @@ import Mgrs from "geodesy/mgrs";
|
|
|
17
17
|
|
|
18
18
|
//#region src/coordinates/mgrs/parser.ts
|
|
19
19
|
const PATTERN_PARTS = /^((?:..?)?)(\w?)\s*((?:\w{2})?)\s*(?:(\d+(?:\.\d*)?)?)\s*(?:(\d+(?:\.\d*)?)?)$/i;
|
|
20
|
+
/**
|
|
21
|
+
* Creates a parse error result with a formatted error message.
|
|
22
|
+
*
|
|
23
|
+
* @param message - The error message describing what went wrong.
|
|
24
|
+
* @returns Parse results tuple with empty data array and error message array.
|
|
25
|
+
*
|
|
26
|
+
* @example
|
|
27
|
+
* ```typescript
|
|
28
|
+
* error('Invalid UTM zone');
|
|
29
|
+
* // [[], ['Invalid UTM zone; expected format DDZ AA DDD DDD.']]
|
|
30
|
+
* ```
|
|
31
|
+
*/
|
|
20
32
|
const error = (message) => [[], [`${violation(message)}; expected format DDZ AA DDD DDD.`]];
|
|
33
|
+
/**
|
|
34
|
+
* Validates MGRS coordinate input and returns detailed error messages for invalid formats.
|
|
35
|
+
*
|
|
36
|
+
* Checks UTM zone number, latitude band letter, 100K meter square identification, and
|
|
37
|
+
* numerical location components. Returns specific error messages for each validation failure.
|
|
38
|
+
*
|
|
39
|
+
* @param input - The MGRS coordinate string to validate.
|
|
40
|
+
* @returns Parse results with detailed error messages for validation failures.
|
|
41
|
+
*
|
|
42
|
+
* @example
|
|
43
|
+
* ```typescript
|
|
44
|
+
* detailedErrors('99Z AA 12345 67890');
|
|
45
|
+
* // [[], ['Invalid UTM zone number (99) found in grid zone designation; expected format DDZ AA DDD DDD.']]
|
|
46
|
+
* ```
|
|
47
|
+
*
|
|
48
|
+
* @example
|
|
49
|
+
* ```typescript
|
|
50
|
+
* detailedErrors('31U BF 12345 67890');
|
|
51
|
+
* // Valid format, parsed successfully
|
|
52
|
+
* ```
|
|
53
|
+
*/
|
|
21
54
|
function detailedErrors(input) {
|
|
22
55
|
if (!input) return error("No input provided");
|
|
23
56
|
const [utm, bnd, hkm, east, north] = (input.trim().replace(/\s+/g, " ").match(PATTERN_PARTS) ?? []).slice(1);
|
|
@@ -27,6 +60,29 @@ function detailedErrors(input) {
|
|
|
27
60
|
if (!(east && north && +east > 0 && +north > 0)) return error(`Invalid numerical location (${[east, north].join()}) found`);
|
|
28
61
|
return error("Uncaught error condition.");
|
|
29
62
|
}
|
|
63
|
+
/**
|
|
64
|
+
* Parses a Military Grid Reference System (MGRS) coordinate string into latitude/longitude values.
|
|
65
|
+
*
|
|
66
|
+
* Converts MGRS coordinates to UTM, then to latitude/longitude decimal degrees. Returns
|
|
67
|
+
* detailed error messages for invalid MGRS formats including zone numbers, band letters,
|
|
68
|
+
* square identification, and numerical locations.
|
|
69
|
+
*
|
|
70
|
+
* @param _format - Format parameter (unused, MGRS has fixed format).
|
|
71
|
+
* @param input - The MGRS coordinate string to parse (e.g., '31U BF 12345 67890').
|
|
72
|
+
* @returns Parse results with coordinate values or detailed error messages.
|
|
73
|
+
*
|
|
74
|
+
* @example
|
|
75
|
+
* ```typescript
|
|
76
|
+
* parseMGRS(null, '31U BF 12345 67890');
|
|
77
|
+
* // [[['48.123456', 'N'], ['11.234567', 'E']], []]
|
|
78
|
+
* ```
|
|
79
|
+
*
|
|
80
|
+
* @example
|
|
81
|
+
* ```typescript
|
|
82
|
+
* parseMGRS(null, 'invalid');
|
|
83
|
+
* // [[], ['Invalid UTM zone number found...']]
|
|
84
|
+
* ```
|
|
85
|
+
*/
|
|
30
86
|
function parseMGRS(_format, input) {
|
|
31
87
|
try {
|
|
32
88
|
const point = Mgrs.parse(input).toUtm().toLatLon();
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"parser.js","names":[],"sources":["../../../src/coordinates/mgrs/parser.ts"],"sourcesContent":["/*\n * Copyright 2024 Hypergiant Galactic Systems Inc. All rights reserved.\n * This file is licensed to you under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License. You may obtain a copy\n * of the License at https://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software distributed under\n * the License is distributed on an \"AS IS\" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS\n * OF ANY KIND, either express or implied. See the License for the specific language\n * governing permissions and limitations under the License.\n */\n\nimport Mgrs from 'geodesy/mgrs';\nimport { type ParseResults, parse } from '../latlon/internal/parse';\nimport { violation } from '../latlon/internal/violation';\n\ntype Match = [string, string, string, string, string];\n\nconst PATTERN_PARTS =\n /^((?:..?)?)(\\w?)\\s*((?:\\w{2})?)\\s*(?:(\\d+(?:\\.\\d*)?)?)\\s*(?:(\\d+(?:\\.\\d*)?)?)$/i;\n\nconst error = (message: string) =>\n [\n [],\n [`${violation(message)}; expected format DDZ AA DDD DDD.`],\n ] as ParseResults;\n\nfunction detailedErrors(input: string) {\n if (!input) {\n return error('No input provided');\n }\n\n const [utm, bnd, hkm, east, north] = (\n input.trim().replace(/\\s+/g, ' ').match(PATTERN_PARTS) ?? []\n ).slice(1) as Match;\n\n if (!utm || +utm > 60 || +utm < 1) {\n return error(\n `Invalid UTM zone number (${utm}) found in grid zone designation`,\n );\n }\n\n if (!/[C-HJ-NP-X]/i.test(bnd)) {\n return error(\n `Invalid Latitude band letter (${bnd}) found in grid zone designation`,\n );\n }\n\n if (!/^[A-HJ-NP-Z]*$/i.test(hkm)) {\n return error(`Invalid 100K m square identification (${hkm}) found`);\n }\n\n if (!(east && north && +east > 0 && +north > 0)) {\n return error(`Invalid numerical location (${[east, north].join()}) found`);\n }\n\n return error('Uncaught error condition.');\n}\n\n// biome-ignore lint/suspicious/noExplicitAny: Format is unused\nexport function parseMGRS(_format: any, input: string) {\n try {\n const point = Mgrs.parse(input).toUtm().toLatLon();\n\n return parse(`${point.lat} / ${point.lon}`, 'LATLON');\n } catch (_e) {\n return detailedErrors(input);\n }\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;AAkBA,MAAM,gBACJ
|
|
1
|
+
{"version":3,"file":"parser.js","names":[],"sources":["../../../src/coordinates/mgrs/parser.ts"],"sourcesContent":["/*\n * Copyright 2024 Hypergiant Galactic Systems Inc. All rights reserved.\n * This file is licensed to you under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License. You may obtain a copy\n * of the License at https://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software distributed under\n * the License is distributed on an \"AS IS\" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS\n * OF ANY KIND, either express or implied. See the License for the specific language\n * governing permissions and limitations under the License.\n */\n\nimport Mgrs from 'geodesy/mgrs';\nimport { type ParseResults, parse } from '../latlon/internal/parse';\nimport { violation } from '../latlon/internal/violation';\n\ntype Match = [string, string, string, string, string];\n\nconst PATTERN_PARTS =\n /^((?:..?)?)(\\w?)\\s*((?:\\w{2})?)\\s*(?:(\\d+(?:\\.\\d*)?)?)\\s*(?:(\\d+(?:\\.\\d*)?)?)$/i;\n\n/**\n * Creates a parse error result with a formatted error message.\n *\n * @param message - The error message describing what went wrong.\n * @returns Parse results tuple with empty data array and error message array.\n *\n * @example\n * ```typescript\n * error('Invalid UTM zone');\n * // [[], ['Invalid UTM zone; expected format DDZ AA DDD DDD.']]\n * ```\n */\nconst error = (message: string) =>\n [\n [],\n [`${violation(message)}; expected format DDZ AA DDD DDD.`],\n ] as ParseResults;\n\n/**\n * Validates MGRS coordinate input and returns detailed error messages for invalid formats.\n *\n * Checks UTM zone number, latitude band letter, 100K meter square identification, and\n * numerical location components. Returns specific error messages for each validation failure.\n *\n * @param input - The MGRS coordinate string to validate.\n * @returns Parse results with detailed error messages for validation failures.\n *\n * @example\n * ```typescript\n * detailedErrors('99Z AA 12345 67890');\n * // [[], ['Invalid UTM zone number (99) found in grid zone designation; expected format DDZ AA DDD DDD.']]\n * ```\n *\n * @example\n * ```typescript\n * detailedErrors('31U BF 12345 67890');\n * // Valid format, parsed successfully\n * ```\n */\nfunction detailedErrors(input: string) {\n if (!input) {\n return error('No input provided');\n }\n\n const [utm, bnd, hkm, east, north] = (\n input.trim().replace(/\\s+/g, ' ').match(PATTERN_PARTS) ?? []\n ).slice(1) as Match;\n\n if (!utm || +utm > 60 || +utm < 1) {\n return error(\n `Invalid UTM zone number (${utm}) found in grid zone designation`,\n );\n }\n\n if (!/[C-HJ-NP-X]/i.test(bnd)) {\n return error(\n `Invalid Latitude band letter (${bnd}) found in grid zone designation`,\n );\n }\n\n if (!/^[A-HJ-NP-Z]*$/i.test(hkm)) {\n return error(`Invalid 100K m square identification (${hkm}) found`);\n }\n\n if (!(east && north && +east > 0 && +north > 0)) {\n return error(`Invalid numerical location (${[east, north].join()}) found`);\n }\n\n return error('Uncaught error condition.');\n}\n\n/**\n * Parses a Military Grid Reference System (MGRS) coordinate string into latitude/longitude values.\n *\n * Converts MGRS coordinates to UTM, then to latitude/longitude decimal degrees. Returns\n * detailed error messages for invalid MGRS formats including zone numbers, band letters,\n * square identification, and numerical locations.\n *\n * @param _format - Format parameter (unused, MGRS has fixed format).\n * @param input - The MGRS coordinate string to parse (e.g., '31U BF 12345 67890').\n * @returns Parse results with coordinate values or detailed error messages.\n *\n * @example\n * ```typescript\n * parseMGRS(null, '31U BF 12345 67890');\n * // [[['48.123456', 'N'], ['11.234567', 'E']], []]\n * ```\n *\n * @example\n * ```typescript\n * parseMGRS(null, 'invalid');\n * // [[], ['Invalid UTM zone number found...']]\n * ```\n */\n// biome-ignore lint/suspicious/noExplicitAny: Format is unused\nexport function parseMGRS(_format: any, input: string) {\n try {\n const point = Mgrs.parse(input).toUtm().toLatLon();\n\n return parse(`${point.lat} / ${point.lon}`, 'LATLON');\n } catch (_e) {\n return detailedErrors(input);\n }\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;AAkBA,MAAM,gBACJ;;;;;;;;;;;;;AAcF,MAAM,SAAS,YACb,CACE,EAAE,EACF,CAAC,GAAG,UAAU,QAAQ,CAAC,mCAAmC,CAC3D;;;;;;;;;;;;;;;;;;;;;;AAuBH,SAAS,eAAe,OAAe;AACrC,KAAI,CAAC,MACH,QAAO,MAAM,oBAAoB;CAGnC,MAAM,CAAC,KAAK,KAAK,KAAK,MAAM,UAC1B,MAAM,MAAM,CAAC,QAAQ,QAAQ,IAAI,CAAC,MAAM,cAAc,IAAI,EAAE,EAC5D,MAAM,EAAE;AAEV,KAAI,CAAC,OAAO,CAAC,MAAM,MAAM,CAAC,MAAM,EAC9B,QAAO,MACL,4BAA4B,IAAI,kCACjC;AAGH,KAAI,CAAC,eAAe,KAAK,IAAI,CAC3B,QAAO,MACL,iCAAiC,IAAI,kCACtC;AAGH,KAAI,CAAC,kBAAkB,KAAK,IAAI,CAC9B,QAAO,MAAM,yCAAyC,IAAI,SAAS;AAGrE,KAAI,EAAE,QAAQ,SAAS,CAAC,OAAO,KAAK,CAAC,QAAQ,GAC3C,QAAO,MAAM,+BAA+B,CAAC,MAAM,MAAM,CAAC,MAAM,CAAC,SAAS;AAG5E,QAAO,MAAM,4BAA4B;;;;;;;;;;;;;;;;;;;;;;;;;AA2B3C,SAAgB,UAAU,SAAc,OAAe;AACrD,KAAI;EACF,MAAM,QAAQ,KAAK,MAAM,MAAM,CAAC,OAAO,CAAC,UAAU;AAElD,SAAO,MAAM,GAAG,MAAM,IAAI,KAAK,MAAM,OAAO,SAAS;UAC9C,IAAI;AACX,SAAO,eAAe,MAAM"}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
/*
|
|
2
|
-
* Copyright
|
|
2
|
+
* Copyright 2026 Hypergiant Galactic Systems Inc. All rights reserved.
|
|
3
3
|
* This file is licensed to you under the Apache License, Version 2.0 (the "License");
|
|
4
4
|
* you may not use this file except in compliance with the License. You may obtain a copy
|
|
5
5
|
* of the License at https://www.apache.org/licenses/LICENSE-2.0
|
|
@@ -13,6 +13,37 @@
|
|
|
13
13
|
import { CoordinateSystem } from "../latlon/internal/coordinate-system.js";
|
|
14
14
|
|
|
15
15
|
//#region src/coordinates/mgrs/system.d.ts
|
|
16
|
+
|
|
17
|
+
/**
|
|
18
|
+
* Military Grid Reference System (MGRS) coordinate system implementation.
|
|
19
|
+
*
|
|
20
|
+
* Provides parsing, conversion, and formatting for MGRS coordinates. MGRS is a geocoordinate
|
|
21
|
+
* standard used by NATO militaries for locating points on Earth, based on the UTM coordinate
|
|
22
|
+
* system. Format: Grid Zone Designation + 100km Square ID + Numerical Location (e.g., '31U BF 12345 67890').
|
|
23
|
+
*
|
|
24
|
+
* @property name - Human-readable name: 'Military Grid Reference System'.
|
|
25
|
+
* @property parse - Parses MGRS coordinate strings into latitude/longitude values.
|
|
26
|
+
* @property toFloat - Converts coordinate component with bearing to signed float value.
|
|
27
|
+
* @property toFormat - Formats latitude/longitude pair back to MGRS coordinate string.
|
|
28
|
+
*
|
|
29
|
+
* @example
|
|
30
|
+
* ```typescript
|
|
31
|
+
* systemMGRS.parse(null, '31U BF 12345 67890');
|
|
32
|
+
* // [[['48.123456', 'N'], ['11.234567', 'E']], []]
|
|
33
|
+
* ```
|
|
34
|
+
*
|
|
35
|
+
* @example
|
|
36
|
+
* ```typescript
|
|
37
|
+
* systemMGRS.toFormat('LATLON', [48.123456, 11.234567]);
|
|
38
|
+
* // '31U BF 12345 67890'
|
|
39
|
+
* ```
|
|
40
|
+
*
|
|
41
|
+
* @example
|
|
42
|
+
* ```typescript
|
|
43
|
+
* systemMGRS.toFloat(['48.123456', 'N']);
|
|
44
|
+
* // 48.123456
|
|
45
|
+
* ```
|
|
46
|
+
*/
|
|
16
47
|
declare const systemMGRS: CoordinateSystem;
|
|
17
48
|
//#endregion
|
|
18
49
|
export { systemMGRS };
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
/*
|
|
2
|
-
* Copyright
|
|
2
|
+
* Copyright 2026 Hypergiant Galactic Systems Inc. All rights reserved.
|
|
3
3
|
* This file is licensed to you under the Apache License, Version 2.0 (the "License");
|
|
4
4
|
* you may not use this file except in compliance with the License. You may obtain a copy
|
|
5
5
|
* of the License at https://www.apache.org/licenses/LICENSE-2.0
|
|
@@ -16,6 +16,36 @@ import { parseMGRS } from "./parser.js";
|
|
|
16
16
|
import { LatLon } from "geodesy/mgrs";
|
|
17
17
|
|
|
18
18
|
//#region src/coordinates/mgrs/system.ts
|
|
19
|
+
/**
|
|
20
|
+
* Military Grid Reference System (MGRS) coordinate system implementation.
|
|
21
|
+
*
|
|
22
|
+
* Provides parsing, conversion, and formatting for MGRS coordinates. MGRS is a geocoordinate
|
|
23
|
+
* standard used by NATO militaries for locating points on Earth, based on the UTM coordinate
|
|
24
|
+
* system. Format: Grid Zone Designation + 100km Square ID + Numerical Location (e.g., '31U BF 12345 67890').
|
|
25
|
+
*
|
|
26
|
+
* @property name - Human-readable name: 'Military Grid Reference System'.
|
|
27
|
+
* @property parse - Parses MGRS coordinate strings into latitude/longitude values.
|
|
28
|
+
* @property toFloat - Converts coordinate component with bearing to signed float value.
|
|
29
|
+
* @property toFormat - Formats latitude/longitude pair back to MGRS coordinate string.
|
|
30
|
+
*
|
|
31
|
+
* @example
|
|
32
|
+
* ```typescript
|
|
33
|
+
* systemMGRS.parse(null, '31U BF 12345 67890');
|
|
34
|
+
* // [[['48.123456', 'N'], ['11.234567', 'E']], []]
|
|
35
|
+
* ```
|
|
36
|
+
*
|
|
37
|
+
* @example
|
|
38
|
+
* ```typescript
|
|
39
|
+
* systemMGRS.toFormat('LATLON', [48.123456, 11.234567]);
|
|
40
|
+
* // '31U BF 12345 67890'
|
|
41
|
+
* ```
|
|
42
|
+
*
|
|
43
|
+
* @example
|
|
44
|
+
* ```typescript
|
|
45
|
+
* systemMGRS.toFloat(['48.123456', 'N']);
|
|
46
|
+
* // 48.123456
|
|
47
|
+
* ```
|
|
48
|
+
*/
|
|
19
49
|
const systemMGRS = {
|
|
20
50
|
name: "Military Grid Reference System",
|
|
21
51
|
parse: parseMGRS,
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"system.js","names":["systemMGRS: CoordinateSystem"],"sources":["../../../src/coordinates/mgrs/system.ts"],"sourcesContent":["// __private-exports\n/*\n * Copyright 2024 Hypergiant Galactic Systems Inc. All rights reserved.\n * This file is licensed to you under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License. You may obtain a copy\n * of the License at https://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software distributed under\n * the License is distributed on an \"AS IS\" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS\n * OF ANY KIND, either express or implied. See the License for the specific language\n * governing permissions and limitations under the License.\n */\n\nimport { LatLon } from 'geodesy/mgrs';\nimport { type Compass, type Format, SYMBOL_PATTERNS } from '../latlon/internal';\nimport { parseMGRS } from './parser';\nimport type { CoordinateSystem } from '../latlon/internal/coordinate-system';\n\nexport const systemMGRS: CoordinateSystem = {\n name: 'Military Grid Reference System',\n\n parse: parseMGRS,\n\n toFloat(arg) {\n const [num, bear] = arg as [string, Compass];\n\n return (\n Number.parseFloat(num) *\n (SYMBOL_PATTERNS.NEGATIVE_BEARINGS.test(bear) ? -1 : 1)\n );\n },\n\n toFormat(format: Format, [left, right]: [number, number]) {\n const { LAT, LON } = Object.fromEntries([\n [format.slice(0, 3), left],\n [format.slice(3), right],\n ]) as Record<'LAT' | 'LON', number>;\n\n const latlon = new LatLon(LAT, LON);\n\n return latlon.toUtm().toMgrs().toString();\n },\n};\n"],"mappings":"
|
|
1
|
+
{"version":3,"file":"system.js","names":["systemMGRS: CoordinateSystem"],"sources":["../../../src/coordinates/mgrs/system.ts"],"sourcesContent":["// __private-exports\n/*\n * Copyright 2024 Hypergiant Galactic Systems Inc. All rights reserved.\n * This file is licensed to you under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License. You may obtain a copy\n * of the License at https://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software distributed under\n * the License is distributed on an \"AS IS\" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS\n * OF ANY KIND, either express or implied. See the License for the specific language\n * governing permissions and limitations under the License.\n */\n\nimport { LatLon } from 'geodesy/mgrs';\nimport { type Compass, type Format, SYMBOL_PATTERNS } from '../latlon/internal';\nimport { parseMGRS } from './parser';\nimport type { CoordinateSystem } from '../latlon/internal/coordinate-system';\n\n/**\n * Military Grid Reference System (MGRS) coordinate system implementation.\n *\n * Provides parsing, conversion, and formatting for MGRS coordinates. MGRS is a geocoordinate\n * standard used by NATO militaries for locating points on Earth, based on the UTM coordinate\n * system. Format: Grid Zone Designation + 100km Square ID + Numerical Location (e.g., '31U BF 12345 67890').\n *\n * @property name - Human-readable name: 'Military Grid Reference System'.\n * @property parse - Parses MGRS coordinate strings into latitude/longitude values.\n * @property toFloat - Converts coordinate component with bearing to signed float value.\n * @property toFormat - Formats latitude/longitude pair back to MGRS coordinate string.\n *\n * @example\n * ```typescript\n * systemMGRS.parse(null, '31U BF 12345 67890');\n * // [[['48.123456', 'N'], ['11.234567', 'E']], []]\n * ```\n *\n * @example\n * ```typescript\n * systemMGRS.toFormat('LATLON', [48.123456, 11.234567]);\n * // '31U BF 12345 67890'\n * ```\n *\n * @example\n * ```typescript\n * systemMGRS.toFloat(['48.123456', 'N']);\n * // 48.123456\n * ```\n */\nexport const systemMGRS: CoordinateSystem = {\n name: 'Military Grid Reference System',\n\n parse: parseMGRS,\n\n toFloat(arg) {\n const [num, bear] = arg as [string, Compass];\n\n return (\n Number.parseFloat(num) *\n (SYMBOL_PATTERNS.NEGATIVE_BEARINGS.test(bear) ? -1 : 1)\n );\n },\n\n toFormat(format: Format, [left, right]: [number, number]) {\n const { LAT, LON } = Object.fromEntries([\n [format.slice(0, 3), left],\n [format.slice(3), right],\n ]) as Record<'LAT' | 'LON', number>;\n\n const latlon = new LatLon(LAT, LON);\n\n return latlon.toUtm().toMgrs().toString();\n },\n};\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAgDA,MAAaA,aAA+B;CAC1C,MAAM;CAEN,OAAO;CAEP,QAAQ,KAAK;EACX,MAAM,CAAC,KAAK,QAAQ;AAEpB,SACE,OAAO,WAAW,IAAI,IACrB,gBAAgB,kBAAkB,KAAK,KAAK,GAAG,KAAK;;CAIzD,SAAS,QAAgB,CAAC,MAAM,QAA0B;EACxD,MAAM,EAAE,KAAK,QAAQ,OAAO,YAAY,CACtC,CAAC,OAAO,MAAM,GAAG,EAAE,EAAE,KAAK,EAC1B,CAAC,OAAO,MAAM,EAAE,EAAE,MAAM,CACzB,CAAC;AAIF,SAFe,IAAI,OAAO,KAAK,IAAI,CAErB,OAAO,CAAC,QAAQ,CAAC,UAAU;;CAE5C"}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
/*
|
|
2
|
-
* Copyright
|
|
2
|
+
* Copyright 2026 Hypergiant Galactic Systems Inc. All rights reserved.
|
|
3
3
|
* This file is licensed to you under the Apache License, Version 2.0 (the "License");
|
|
4
4
|
* you may not use this file except in compliance with the License. You may obtain a copy
|
|
5
5
|
* of the License at https://www.apache.org/licenses/LICENSE-2.0
|
|
@@ -13,6 +13,30 @@
|
|
|
13
13
|
import { ParseResults } from "../latlon/internal/parse.js";
|
|
14
14
|
|
|
15
15
|
//#region src/coordinates/utm/parser.d.ts
|
|
16
|
+
|
|
17
|
+
/**
|
|
18
|
+
* Parses UTM (Universal Transverse Mercator) coordinate string into lat/lon format.
|
|
19
|
+
*
|
|
20
|
+
* Accepts UTM coordinates in format "ZZ N|S EEEEE NNNNN" where ZZ is zone (1-60),
|
|
21
|
+
* N|S is hemisphere, EEEEE is easting, and NNNNN is northing. Converts to
|
|
22
|
+
* latitude/longitude using the geodesy library.
|
|
23
|
+
*
|
|
24
|
+
* @param _format - Unused format parameter (kept for interface compatibility).
|
|
25
|
+
* @param input - UTM coordinate string to parse.
|
|
26
|
+
* @returns ParseResults with lat/lon tokens or error messages.
|
|
27
|
+
*
|
|
28
|
+
* @example
|
|
29
|
+
* ```typescript
|
|
30
|
+
* parseUTM(null, '18N 585628 4511644');
|
|
31
|
+
* // [['40.7128', '/', '-74.0060'], []]
|
|
32
|
+
* ```
|
|
33
|
+
*
|
|
34
|
+
* @example
|
|
35
|
+
* ```typescript
|
|
36
|
+
* parseUTM(null, '65N 585628 4511644');
|
|
37
|
+
* // [[], ['[ERROR] Invalid Zone number (65) found; expected format ZZ N|S DDD DDD.']]
|
|
38
|
+
* ```
|
|
39
|
+
*/
|
|
16
40
|
declare function parseUTM(_format: any, input: string): ParseResults;
|
|
17
41
|
//#endregion
|
|
18
42
|
export { parseUTM };
|