@accelint/geo 0.5.1 → 0.6.0
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 +6 -0
- package/README.md +233 -1
- package/catalog-info.yaml +1 -1
- package/dist/cartesian.d.ts +2 -0
- package/dist/cartesian.js +2 -0
- package/dist/cartesian.js.map +1 -1
- package/dist/coordinates/coordinate.d.ts +41 -7
- package/dist/coordinates/coordinate.js +102 -12
- package/dist/coordinates/coordinate.js.map +1 -1
- package/dist/coordinates/latlon/decimal-degrees/formatter.d.ts +20 -0
- package/dist/coordinates/latlon/decimal-degrees/formatter.js +38 -0
- package/dist/coordinates/latlon/decimal-degrees/formatter.js.map +1 -1
- package/dist/coordinates/latlon/decimal-degrees/parser.d.ts +68 -2
- package/dist/coordinates/latlon/decimal-degrees/parser.js +66 -5
- package/dist/coordinates/latlon/decimal-degrees/parser.js.map +1 -1
- package/dist/coordinates/latlon/decimal-degrees/system.d.ts +32 -0
- package/dist/coordinates/latlon/decimal-degrees/system.js +31 -0
- package/dist/coordinates/latlon/decimal-degrees/system.js.map +1 -1
- package/dist/coordinates/latlon/degrees-decimal-minutes/formatter.d.ts +20 -0
- package/dist/coordinates/latlon/degrees-decimal-minutes/formatter.js +37 -0
- package/dist/coordinates/latlon/degrees-decimal-minutes/formatter.js.map +1 -1
- package/dist/coordinates/latlon/degrees-decimal-minutes/parser.d.ts +72 -2
- package/dist/coordinates/latlon/degrees-decimal-minutes/parser.js +66 -3
- package/dist/coordinates/latlon/degrees-decimal-minutes/parser.js.map +1 -1
- package/dist/coordinates/latlon/degrees-decimal-minutes/system.d.ts +32 -0
- package/dist/coordinates/latlon/degrees-decimal-minutes/system.js +31 -0
- package/dist/coordinates/latlon/degrees-decimal-minutes/system.js.map +1 -1
- package/dist/coordinates/latlon/degrees-minutes-seconds/formatter.d.ts +20 -0
- package/dist/coordinates/latlon/degrees-minutes-seconds/formatter.js +37 -0
- package/dist/coordinates/latlon/degrees-minutes-seconds/formatter.js.map +1 -1
- package/dist/coordinates/latlon/degrees-minutes-seconds/parser.d.ts +74 -2
- package/dist/coordinates/latlon/degrees-minutes-seconds/parser.js +66 -3
- package/dist/coordinates/latlon/degrees-minutes-seconds/parser.js.map +1 -1
- package/dist/coordinates/latlon/degrees-minutes-seconds/system.d.ts +32 -0
- package/dist/coordinates/latlon/degrees-minutes-seconds/system.js +31 -0
- package/dist/coordinates/latlon/degrees-minutes-seconds/system.js.map +1 -1
- package/dist/coordinates/latlon/internal/coordinate-system.d.ts +22 -0
- package/dist/coordinates/latlon/internal/create-cache.d.ts +17 -1
- package/dist/coordinates/latlon/internal/create-cache.js +19 -3
- 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 +28 -0
- 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 +20 -0
- 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 +24 -0
- 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 +25 -1
- 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 +26 -0
- 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 +25 -0
- package/dist/coordinates/latlon/internal/ordinal.js.map +1 -1
- package/dist/coordinates/latlon/internal/parse-format.d.ts +22 -0
- package/dist/coordinates/latlon/internal/parse-format.js +43 -1
- package/dist/coordinates/latlon/internal/parse-format.js.map +1 -1
- package/dist/coordinates/latlon/internal/parse.d.ts +2 -0
- package/dist/coordinates/latlon/internal/parse.js +4 -1
- package/dist/coordinates/latlon/internal/parse.js.map +1 -1
- package/dist/coordinates/latlon/internal/pipes/check-ambiguous.d.ts +17 -0
- package/dist/coordinates/latlon/internal/pipes/check-ambiguous.js +16 -0
- package/dist/coordinates/latlon/internal/pipes/check-ambiguous.js.map +1 -1
- package/dist/coordinates/latlon/internal/pipes/check-numbers.d.ts +25 -0
- package/dist/coordinates/latlon/internal/pipes/check-numbers.js +33 -0
- package/dist/coordinates/latlon/internal/pipes/check-numbers.js.map +1 -1
- package/dist/coordinates/latlon/internal/pipes/fix-bearings.d.ts +17 -0
- package/dist/coordinates/latlon/internal/pipes/fix-bearings.js +31 -0
- package/dist/coordinates/latlon/internal/pipes/fix-bearings.js.map +1 -1
- package/dist/coordinates/latlon/internal/pipes/fix-dividers.d.ts +17 -0
- package/dist/coordinates/latlon/internal/pipes/fix-dividers.js +29 -0
- package/dist/coordinates/latlon/internal/pipes/fix-dividers.js.map +1 -1
- package/dist/coordinates/latlon/internal/pipes/genome.d.ts +16 -0
- package/dist/coordinates/latlon/internal/pipes/genome.js +41 -0
- package/dist/coordinates/latlon/internal/pipes/genome.js.map +1 -1
- package/dist/coordinates/latlon/internal/pipes/index.d.ts +32 -2
- package/dist/coordinates/latlon/internal/pipes/index.js +57 -4
- package/dist/coordinates/latlon/internal/pipes/index.js.map +1 -1
- package/dist/coordinates/latlon/internal/pipes/simpler.d.ts +16 -3
- package/dist/coordinates/latlon/internal/pipes/simpler.js +15 -3
- 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 +18 -0
- package/dist/coordinates/latlon/internal/violation.js.map +1 -1
- package/dist/coordinates/mgrs/parser.d.ts +24 -0
- package/dist/coordinates/mgrs/parser.js +56 -0
- package/dist/coordinates/mgrs/parser.js.map +1 -1
- package/dist/coordinates/mgrs/system.d.ts +31 -0
- package/dist/coordinates/mgrs/system.js +30 -0
- package/dist/coordinates/mgrs/system.js.map +1 -1
- package/dist/coordinates/utm/parser.d.ts +24 -0
- package/dist/coordinates/utm/parser.js +56 -0
- package/dist/coordinates/utm/parser.js.map +1 -1
- package/dist/coordinates/utm/system.d.ts +21 -0
- package/dist/coordinates/utm/system.js +20 -0
- package/dist/coordinates/utm/system.js.map +1 -1
- package/dist/index.d.ts +3 -1
- package/dist/index.js +3 -1
- package/dist/patterning.d.ts +12 -2
- package/dist/patterning.js +12 -2
- package/dist/patterning.js.map +1 -1
- package/package.json +3 -1
|
@@ -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"}
|
|
@@ -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 };
|
|
@@ -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"}
|
|
@@ -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 };
|
|
@@ -17,7 +17,40 @@ import Utm from "geodesy/utm";
|
|
|
17
17
|
|
|
18
18
|
//#region src/coordinates/utm/parser.ts
|
|
19
19
|
const PATTERN_PARTS = /^((?:..)?)\s*(\w?)\s*(?:(\d+(?:\.\d*)?)?)\s*(?:(\d+(?:\.\d*)?)?)$/i;
|
|
20
|
+
/**
|
|
21
|
+
* Creates a ParseResults error tuple with formatted message.
|
|
22
|
+
*
|
|
23
|
+
* @param message - Error message describing the parsing failure.
|
|
24
|
+
* @returns ParseResults tuple with empty tokens array and formatted error message.
|
|
25
|
+
*
|
|
26
|
+
* @example
|
|
27
|
+
* ```typescript
|
|
28
|
+
* error('Invalid Zone number (65) found');
|
|
29
|
+
* // [[], ['[ERROR] Invalid Zone number (65) found; expected format ZZ N|S DDD DDD.']]
|
|
30
|
+
* ```
|
|
31
|
+
*/
|
|
20
32
|
const error = (message) => [[], [`${violation(message)}; expected format ZZ N|S DDD DDD.`]];
|
|
33
|
+
/**
|
|
34
|
+
* Validates UTM coordinate components and returns detailed error messages.
|
|
35
|
+
*
|
|
36
|
+
* Checks zone number (1-60), latitude band letter (N/S), easting, and northing values
|
|
37
|
+
* for validity and returns specific error messages for each invalid component.
|
|
38
|
+
*
|
|
39
|
+
* @param input - UTM coordinate string to validate.
|
|
40
|
+
* @returns ParseResults with empty tokens and detailed error message.
|
|
41
|
+
*
|
|
42
|
+
* @example
|
|
43
|
+
* ```typescript
|
|
44
|
+
* detailedErrors('65N 585628 4511644');
|
|
45
|
+
* // [[], ['[ERROR] Invalid Zone number (65) found; expected format ZZ N|S DDD DDD.']]
|
|
46
|
+
* ```
|
|
47
|
+
*
|
|
48
|
+
* @example
|
|
49
|
+
* ```typescript
|
|
50
|
+
* detailedErrors('18X 585628 4511644');
|
|
51
|
+
* // [[], ['[ERROR] Invalid Latitude band letter (X) found; expected format ZZ N|S DDD DDD.']]
|
|
52
|
+
* ```
|
|
53
|
+
*/
|
|
21
54
|
function detailedErrors(input) {
|
|
22
55
|
const [zone, band, east, north] = (input.trim().replace(/\s+/g, " ").match(PATTERN_PARTS) ?? []).slice(1);
|
|
23
56
|
if (!zone || +zone > 60 || +zone < 1) return error(`Invalid Zone number (${zone}) found`);
|
|
@@ -26,6 +59,29 @@ function detailedErrors(input) {
|
|
|
26
59
|
if (!(north || +north >= 0)) return error(`Invalid Northing number (${north ?? ""}) found`);
|
|
27
60
|
return error("Uncaught error condition.");
|
|
28
61
|
}
|
|
62
|
+
/**
|
|
63
|
+
* Parses UTM (Universal Transverse Mercator) coordinate string into lat/lon format.
|
|
64
|
+
*
|
|
65
|
+
* Accepts UTM coordinates in format "ZZ N|S EEEEE NNNNN" where ZZ is zone (1-60),
|
|
66
|
+
* N|S is hemisphere, EEEEE is easting, and NNNNN is northing. Converts to
|
|
67
|
+
* latitude/longitude using the geodesy library.
|
|
68
|
+
*
|
|
69
|
+
* @param _format - Unused format parameter (kept for interface compatibility).
|
|
70
|
+
* @param input - UTM coordinate string to parse.
|
|
71
|
+
* @returns ParseResults with lat/lon tokens or error messages.
|
|
72
|
+
*
|
|
73
|
+
* @example
|
|
74
|
+
* ```typescript
|
|
75
|
+
* parseUTM(null, '18N 585628 4511644');
|
|
76
|
+
* // [['40.7128', '/', '-74.0060'], []]
|
|
77
|
+
* ```
|
|
78
|
+
*
|
|
79
|
+
* @example
|
|
80
|
+
* ```typescript
|
|
81
|
+
* parseUTM(null, '65N 585628 4511644');
|
|
82
|
+
* // [[], ['[ERROR] Invalid Zone number (65) found; expected format ZZ N|S DDD DDD.']]
|
|
83
|
+
* ```
|
|
84
|
+
*/
|
|
29
85
|
function parseUTM(_format, input) {
|
|
30
86
|
try {
|
|
31
87
|
const normalized = input.trim().replace(/^(\d{1,2})([NS])\s+/i, "$1 $2 ");
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"parser.js","names":[],"sources":["../../../src/coordinates/utm/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 Utm from 'geodesy/utm';\nimport { type ParseResults, parse } from '../latlon/internal/parse';\nimport { violation } from '../latlon/internal/violation';\n\ntype Match = [string, string, string, string];\n\nconst PATTERN_PARTS =\n /^((?:..)?)\\s*(\\w?)\\s*(?:(\\d+(?:\\.\\d*)?)?)\\s*(?:(\\d+(?:\\.\\d*)?)?)$/i;\n\nconst error = (message: string) =>\n [\n [],\n [`${violation(message)}; expected format ZZ N|S DDD DDD.`],\n ] as ParseResults;\n\nfunction detailedErrors(input: string) {\n const [zone, band, east, north] = (\n input.trim().replace(/\\s+/g, ' ').match(PATTERN_PARTS) ?? []\n ).slice(1) as Match;\n\n if (!zone || +zone > 60 || +zone < 1) {\n return error(`Invalid Zone number (${zone}) found`);\n }\n\n if (!/[NS]/i.test(band)) {\n return error(`Invalid Latitude band letter (${band}) found`);\n }\n\n if (!(east || +east >= 0)) {\n return error(`Invalid Easting number (${east ?? ''}) found`);\n }\n\n if (!(north || +north >= 0)) {\n return error(`Invalid Northing number (${north ?? ''}) found`);\n }\n\n return error('Uncaught error condition.');\n}\n\n// biome-ignore lint/suspicious/noExplicitAny: Format is unused\nexport function parseUTM(_format: any, input: string) {\n try {\n // Preprocess: ensure space between zone and hemisphere for geodesy parser\n // Convert \"18N 585628 4511644\" to \"18 N 585628 4511644\"\n // The geodesy library requires 4 space-separated elements\n const normalized = input.trim().replace(/^(\\d{1,2})([NS])\\s+/i, '$1 $2 ');\n\n const utm = Utm.parse(normalized);\n const latlon = utm.toLatLon();\n\n return parse(`${latlon.lat} / ${latlon.lon}`, 'LATLON');\n } catch (_) {\n return detailedErrors(input);\n }\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;AAkBA,MAAM,gBACJ
|
|
1
|
+
{"version":3,"file":"parser.js","names":[],"sources":["../../../src/coordinates/utm/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 Utm from 'geodesy/utm';\nimport { type ParseResults, parse } from '../latlon/internal/parse';\nimport { violation } from '../latlon/internal/violation';\n\ntype Match = [string, string, string, string];\n\nconst PATTERN_PARTS =\n /^((?:..)?)\\s*(\\w?)\\s*(?:(\\d+(?:\\.\\d*)?)?)\\s*(?:(\\d+(?:\\.\\d*)?)?)$/i;\n\n/**\n * Creates a ParseResults error tuple with formatted message.\n *\n * @param message - Error message describing the parsing failure.\n * @returns ParseResults tuple with empty tokens array and formatted error message.\n *\n * @example\n * ```typescript\n * error('Invalid Zone number (65) found');\n * // [[], ['[ERROR] Invalid Zone number (65) found; expected format ZZ N|S DDD DDD.']]\n * ```\n */\nconst error = (message: string) =>\n [\n [],\n [`${violation(message)}; expected format ZZ N|S DDD DDD.`],\n ] as ParseResults;\n\n/**\n * Validates UTM coordinate components and returns detailed error messages.\n *\n * Checks zone number (1-60), latitude band letter (N/S), easting, and northing values\n * for validity and returns specific error messages for each invalid component.\n *\n * @param input - UTM coordinate string to validate.\n * @returns ParseResults with empty tokens and detailed error message.\n *\n * @example\n * ```typescript\n * detailedErrors('65N 585628 4511644');\n * // [[], ['[ERROR] Invalid Zone number (65) found; expected format ZZ N|S DDD DDD.']]\n * ```\n *\n * @example\n * ```typescript\n * detailedErrors('18X 585628 4511644');\n * // [[], ['[ERROR] Invalid Latitude band letter (X) found; expected format ZZ N|S DDD DDD.']]\n * ```\n */\nfunction detailedErrors(input: string) {\n const [zone, band, east, north] = (\n input.trim().replace(/\\s+/g, ' ').match(PATTERN_PARTS) ?? []\n ).slice(1) as Match;\n\n if (!zone || +zone > 60 || +zone < 1) {\n return error(`Invalid Zone number (${zone}) found`);\n }\n\n if (!/[NS]/i.test(band)) {\n return error(`Invalid Latitude band letter (${band}) found`);\n }\n\n if (!(east || +east >= 0)) {\n return error(`Invalid Easting number (${east ?? ''}) found`);\n }\n\n if (!(north || +north >= 0)) {\n return error(`Invalid Northing number (${north ?? ''}) found`);\n }\n\n return error('Uncaught error condition.');\n}\n\n/**\n * Parses UTM (Universal Transverse Mercator) coordinate string into lat/lon format.\n *\n * Accepts UTM coordinates in format \"ZZ N|S EEEEE NNNNN\" where ZZ is zone (1-60),\n * N|S is hemisphere, EEEEE is easting, and NNNNN is northing. Converts to\n * latitude/longitude using the geodesy library.\n *\n * @param _format - Unused format parameter (kept for interface compatibility).\n * @param input - UTM coordinate string to parse.\n * @returns ParseResults with lat/lon tokens or error messages.\n *\n * @example\n * ```typescript\n * parseUTM(null, '18N 585628 4511644');\n * // [['40.7128', '/', '-74.0060'], []]\n * ```\n *\n * @example\n * ```typescript\n * parseUTM(null, '65N 585628 4511644');\n * // [[], ['[ERROR] Invalid Zone number (65) found; expected format ZZ N|S DDD DDD.']]\n * ```\n */\n// biome-ignore lint/suspicious/noExplicitAny: Format is unused\nexport function parseUTM(_format: any, input: string) {\n try {\n // Preprocess: ensure space between zone and hemisphere for geodesy parser\n // Convert \"18N 585628 4511644\" to \"18 N 585628 4511644\"\n // The geodesy library requires 4 space-separated elements\n const normalized = input.trim().replace(/^(\\d{1,2})([NS])\\s+/i, '$1 $2 ');\n\n const utm = Utm.parse(normalized);\n const latlon = utm.toLatLon();\n\n return parse(`${latlon.lat} / ${latlon.lon}`, 'LATLON');\n } catch (_) {\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;CACrC,MAAM,CAAC,MAAM,MAAM,MAAM,UACvB,MAAM,MAAM,CAAC,QAAQ,QAAQ,IAAI,CAAC,MAAM,cAAc,IAAI,EAAE,EAC5D,MAAM,EAAE;AAEV,KAAI,CAAC,QAAQ,CAAC,OAAO,MAAM,CAAC,OAAO,EACjC,QAAO,MAAM,wBAAwB,KAAK,SAAS;AAGrD,KAAI,CAAC,QAAQ,KAAK,KAAK,CACrB,QAAO,MAAM,iCAAiC,KAAK,SAAS;AAG9D,KAAI,EAAE,QAAQ,CAAC,QAAQ,GACrB,QAAO,MAAM,2BAA2B,QAAQ,GAAG,SAAS;AAG9D,KAAI,EAAE,SAAS,CAAC,SAAS,GACvB,QAAO,MAAM,4BAA4B,SAAS,GAAG,SAAS;AAGhE,QAAO,MAAM,4BAA4B;;;;;;;;;;;;;;;;;;;;;;;;;AA2B3C,SAAgB,SAAS,SAAc,OAAe;AACpD,KAAI;EAIF,MAAM,aAAa,MAAM,MAAM,CAAC,QAAQ,wBAAwB,SAAS;EAGzE,MAAM,SADM,IAAI,MAAM,WAAW,CACd,UAAU;AAE7B,SAAO,MAAM,GAAG,OAAO,IAAI,KAAK,OAAO,OAAO,SAAS;UAChD,GAAG;AACV,SAAO,eAAe,MAAM"}
|
|
@@ -13,6 +13,27 @@
|
|
|
13
13
|
import { CoordinateSystem } from "../latlon/internal/coordinate-system.js";
|
|
14
14
|
|
|
15
15
|
//#region src/coordinates/utm/system.d.ts
|
|
16
|
+
|
|
17
|
+
/**
|
|
18
|
+
* Universal Transverse Mercator (UTM) coordinate system implementation.
|
|
19
|
+
*
|
|
20
|
+
* Provides parsing, conversion, and formatting for UTM coordinates. UTM divides
|
|
21
|
+
* the Earth into 60 zones, each 6 degrees of longitude wide, using a transverse
|
|
22
|
+
* Mercator projection. Coordinates are expressed as zone number, hemisphere (N/S),
|
|
23
|
+
* easting, and northing values.
|
|
24
|
+
*
|
|
25
|
+
* @example
|
|
26
|
+
* ```typescript
|
|
27
|
+
* systemUTM.parse(null, '18N 585628 4511644');
|
|
28
|
+
* // [['40.7128', '/', '-74.0060'], []]
|
|
29
|
+
* ```
|
|
30
|
+
*
|
|
31
|
+
* @example
|
|
32
|
+
* ```typescript
|
|
33
|
+
* systemUTM.toFormat('LATLON', [40.7128, -74.0060]);
|
|
34
|
+
* // '18N 585628 4511644'
|
|
35
|
+
* ```
|
|
36
|
+
*/
|
|
16
37
|
declare const systemUTM: CoordinateSystem;
|
|
17
38
|
//#endregion
|
|
18
39
|
export { systemUTM };
|
|
@@ -16,6 +16,26 @@ import { parseUTM } from "./parser.js";
|
|
|
16
16
|
import { LatLon } from "geodesy/utm";
|
|
17
17
|
|
|
18
18
|
//#region src/coordinates/utm/system.ts
|
|
19
|
+
/**
|
|
20
|
+
* Universal Transverse Mercator (UTM) coordinate system implementation.
|
|
21
|
+
*
|
|
22
|
+
* Provides parsing, conversion, and formatting for UTM coordinates. UTM divides
|
|
23
|
+
* the Earth into 60 zones, each 6 degrees of longitude wide, using a transverse
|
|
24
|
+
* Mercator projection. Coordinates are expressed as zone number, hemisphere (N/S),
|
|
25
|
+
* easting, and northing values.
|
|
26
|
+
*
|
|
27
|
+
* @example
|
|
28
|
+
* ```typescript
|
|
29
|
+
* systemUTM.parse(null, '18N 585628 4511644');
|
|
30
|
+
* // [['40.7128', '/', '-74.0060'], []]
|
|
31
|
+
* ```
|
|
32
|
+
*
|
|
33
|
+
* @example
|
|
34
|
+
* ```typescript
|
|
35
|
+
* systemUTM.toFormat('LATLON', [40.7128, -74.0060]);
|
|
36
|
+
* // '18N 585628 4511644'
|
|
37
|
+
* ```
|
|
38
|
+
*/
|
|
19
39
|
const systemUTM = {
|
|
20
40
|
name: "Universal Transverse Mercator",
|
|
21
41
|
parse: parseUTM,
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"system.js","names":["systemUTM: CoordinateSystem"],"sources":["../../../src/coordinates/utm/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/utm';\nimport { type Compass, type Format, SYMBOL_PATTERNS } from '../latlon/internal';\nimport { parseUTM } from './parser';\nimport type { CoordinateSystem } from '../latlon/internal/coordinate-system';\n\nexport const systemUTM: CoordinateSystem = {\n name: 'Universal Transverse Mercator',\n\n parse: parseUTM,\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 const utm = latlon.toUtm();\n\n // Format UTM coordinates manually to ensure correct format\n // Expected format: \"18N 585628 4511644\" (zone hemisphere easting northing)\n const zone = utm.zone.toString().padStart(2, '0');\n const hemisphere = utm.hemisphere;\n const easting = Math.round(utm.easting).toString();\n const northing = Math.round(utm.northing).toString();\n\n return `${zone}${hemisphere} ${easting} ${northing}`;\n },\n};\n"],"mappings":"
|
|
1
|
+
{"version":3,"file":"system.js","names":["systemUTM: CoordinateSystem"],"sources":["../../../src/coordinates/utm/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/utm';\nimport { type Compass, type Format, SYMBOL_PATTERNS } from '../latlon/internal';\nimport { parseUTM } from './parser';\nimport type { CoordinateSystem } from '../latlon/internal/coordinate-system';\n\n/**\n * Universal Transverse Mercator (UTM) coordinate system implementation.\n *\n * Provides parsing, conversion, and formatting for UTM coordinates. UTM divides\n * the Earth into 60 zones, each 6 degrees of longitude wide, using a transverse\n * Mercator projection. Coordinates are expressed as zone number, hemisphere (N/S),\n * easting, and northing values.\n *\n * @example\n * ```typescript\n * systemUTM.parse(null, '18N 585628 4511644');\n * // [['40.7128', '/', '-74.0060'], []]\n * ```\n *\n * @example\n * ```typescript\n * systemUTM.toFormat('LATLON', [40.7128, -74.0060]);\n * // '18N 585628 4511644'\n * ```\n */\nexport const systemUTM: CoordinateSystem = {\n name: 'Universal Transverse Mercator',\n\n parse: parseUTM,\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 const utm = latlon.toUtm();\n\n // Format UTM coordinates manually to ensure correct format\n // Expected format: \"18N 585628 4511644\" (zone hemisphere easting northing)\n const zone = utm.zone.toString().padStart(2, '0');\n const hemisphere = utm.hemisphere;\n const easting = Math.round(utm.easting).toString();\n const northing = Math.round(utm.northing).toString();\n\n return `${zone}${hemisphere} ${easting} ${northing}`;\n },\n};\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAsCA,MAAaA,YAA8B;CACzC,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;EAGF,MAAM,MADS,IAAI,OAAO,KAAK,IAAI,CAChB,OAAO;AAS1B,SAAO,GALM,IAAI,KAAK,UAAU,CAAC,SAAS,GAAG,IAAI,GAC9B,IAAI,WAIK,GAHZ,KAAK,MAAM,IAAI,QAAQ,CAAC,UAAU,CAGX,GAFtB,KAAK,MAAM,IAAI,SAAS,CAAC,UAAU;;CAIvD"}
|
package/dist/index.d.ts
CHANGED
|
@@ -10,6 +10,8 @@
|
|
|
10
10
|
* governing permissions and limitations under the License.
|
|
11
11
|
*/
|
|
12
12
|
|
|
13
|
+
import { CoordinateInput, CoordinateInternalValue, CoordinateObject, CoordinateTuple, LatLonTuple, LonLatTuple, isCoordinateObject, isCoordinateTuple, normalizeObjectToLatLon, tupleToLatLon } from "./coordinates/latlon/internal/normalize.js";
|
|
14
|
+
import { isFiniteNumber, validateNumericCoordinate, validateSignedRange } from "./coordinates/latlon/internal/validate.js";
|
|
13
15
|
import { coordinateSystems, createCoordinate } from "./coordinates/coordinate.js";
|
|
14
16
|
import { FormatOptions, createFormatter } from "./coordinates/latlon/internal/format.js";
|
|
15
17
|
import { formatDecimalDegrees } from "./coordinates/latlon/decimal-degrees/formatter.js";
|
|
@@ -21,4 +23,4 @@ import { parseDegreesMinutesSeconds } from "./coordinates/latlon/degrees-minutes
|
|
|
21
23
|
import { getOrdinal } from "./coordinates/latlon/internal/ordinal.js";
|
|
22
24
|
import { parseMGRS } from "./coordinates/mgrs/parser.js";
|
|
23
25
|
import { parseUTM } from "./coordinates/utm/parser.js";
|
|
24
|
-
export { type FormatOptions, coordinateSystems, createCoordinate, createFormatter, formatDecimalDegrees, formatDegreesDecimalMinutes, formatDegreesMinutesSeconds, getOrdinal, parseDecimalDegrees, parseDegreesDecimalMinutes, parseDegreesMinutesSeconds, parseMGRS, parseUTM };
|
|
26
|
+
export { type CoordinateInput, type CoordinateInternalValue, type CoordinateObject, type CoordinateTuple, type FormatOptions, type LatLonTuple, type LonLatTuple, coordinateSystems, createCoordinate, createFormatter, formatDecimalDegrees, formatDegreesDecimalMinutes, formatDegreesMinutesSeconds, getOrdinal, isCoordinateObject, isCoordinateTuple, isFiniteNumber, normalizeObjectToLatLon, parseDecimalDegrees, parseDegreesDecimalMinutes, parseDegreesMinutesSeconds, parseMGRS, parseUTM, tupleToLatLon, validateNumericCoordinate, validateSignedRange };
|
package/dist/index.js
CHANGED
|
@@ -11,6 +11,8 @@
|
|
|
11
11
|
*/
|
|
12
12
|
|
|
13
13
|
|
|
14
|
+
import { isCoordinateObject, isCoordinateTuple, normalizeObjectToLatLon, tupleToLatLon } from "./coordinates/latlon/internal/normalize.js";
|
|
15
|
+
import { isFiniteNumber, validateNumericCoordinate, validateSignedRange } from "./coordinates/latlon/internal/validate.js";
|
|
14
16
|
import { parseDecimalDegrees } from "./coordinates/latlon/decimal-degrees/parser.js";
|
|
15
17
|
import { parseDegreesDecimalMinutes } from "./coordinates/latlon/degrees-decimal-minutes/parser.js";
|
|
16
18
|
import { parseDegreesMinutesSeconds } from "./coordinates/latlon/degrees-minutes-seconds/parser.js";
|
|
@@ -23,4 +25,4 @@ import { formatDecimalDegrees } from "./coordinates/latlon/decimal-degrees/forma
|
|
|
23
25
|
import { formatDegreesDecimalMinutes } from "./coordinates/latlon/degrees-decimal-minutes/formatter.js";
|
|
24
26
|
import { formatDegreesMinutesSeconds } from "./coordinates/latlon/degrees-minutes-seconds/formatter.js";
|
|
25
27
|
|
|
26
|
-
export { coordinateSystems, createCoordinate, createFormatter, formatDecimalDegrees, formatDegreesDecimalMinutes, formatDegreesMinutesSeconds, getOrdinal, parseDecimalDegrees, parseDegreesDecimalMinutes, parseDegreesMinutesSeconds, parseMGRS, parseUTM };
|
|
28
|
+
export { coordinateSystems, createCoordinate, createFormatter, formatDecimalDegrees, formatDegreesDecimalMinutes, formatDegreesMinutesSeconds, getOrdinal, isCoordinateObject, isCoordinateTuple, isFiniteNumber, normalizeObjectToLatLon, parseDecimalDegrees, parseDegreesDecimalMinutes, parseDegreesMinutesSeconds, parseMGRS, parseUTM, tupleToLatLon, validateNumericCoordinate, validateSignedRange };
|
package/dist/patterning.d.ts
CHANGED
|
@@ -7,7 +7,9 @@
|
|
|
7
7
|
* pure function
|
|
8
8
|
*
|
|
9
9
|
* @example
|
|
10
|
+
* ```typescript
|
|
10
11
|
* capture(/a/, /b/, /c/) === /(abc)/
|
|
12
|
+
* ```
|
|
11
13
|
*/
|
|
12
14
|
declare const capture: (...p: RegExp[]) => RegExp;
|
|
13
15
|
/**
|
|
@@ -22,7 +24,9 @@ declare const capture: (...p: RegExp[]) => RegExp;
|
|
|
22
24
|
* pure function
|
|
23
25
|
*
|
|
24
26
|
* @example
|
|
27
|
+
* ```typescript
|
|
25
28
|
* fromTemplate({ a: /alpha/, b: /beta/, ' ': / / }, 'a b') === /^alpha beta$/
|
|
29
|
+
* ```
|
|
26
30
|
*
|
|
27
31
|
*/
|
|
28
32
|
declare const fromTemplate: (dict: Record<string, RegExp>, template: string) => RegExp;
|
|
@@ -34,7 +38,9 @@ declare const fromTemplate: (dict: Record<string, RegExp>, template: string) =>
|
|
|
34
38
|
* pure function
|
|
35
39
|
*
|
|
36
40
|
* @example
|
|
37
|
-
*
|
|
41
|
+
* ```typescript
|
|
42
|
+
* group(/a/, /b/, /c/) === /(?:abc)/
|
|
43
|
+
* ```
|
|
38
44
|
*/
|
|
39
45
|
declare const group: (...p: RegExp[]) => RegExp;
|
|
40
46
|
/**
|
|
@@ -46,7 +52,9 @@ declare const group: (...p: RegExp[]) => RegExp;
|
|
|
46
52
|
* pure function
|
|
47
53
|
*
|
|
48
54
|
* @example
|
|
55
|
+
* ```typescript
|
|
49
56
|
* merge(/a/, /b/, /c/) === /abc/
|
|
57
|
+
* ```
|
|
50
58
|
*/
|
|
51
59
|
declare const merge: (...all: RegExp[]) => RegExp;
|
|
52
60
|
/**
|
|
@@ -57,7 +65,9 @@ declare const merge: (...all: RegExp[]) => RegExp;
|
|
|
57
65
|
* pure function
|
|
58
66
|
*
|
|
59
67
|
* @example
|
|
60
|
-
*
|
|
68
|
+
* ```typescript
|
|
69
|
+
* optional(/a/, /b/, /c/) === /(?:abc)?/
|
|
70
|
+
* ```
|
|
61
71
|
*/
|
|
62
72
|
declare const optional: (...p: RegExp[]) => RegExp;
|
|
63
73
|
//#endregion
|
package/dist/patterning.js
CHANGED
|
@@ -20,7 +20,9 @@
|
|
|
20
20
|
* pure function
|
|
21
21
|
*
|
|
22
22
|
* @example
|
|
23
|
+
* ```typescript
|
|
23
24
|
* capture(/a/, /b/, /c/) === /(abc)/
|
|
25
|
+
* ```
|
|
24
26
|
*/
|
|
25
27
|
const capture = (...p) => /* @__PURE__ */ new RegExp(`(${merge(...p).source})`);
|
|
26
28
|
/**
|
|
@@ -35,7 +37,9 @@ const capture = (...p) => /* @__PURE__ */ new RegExp(`(${merge(...p).source})`);
|
|
|
35
37
|
* pure function
|
|
36
38
|
*
|
|
37
39
|
* @example
|
|
40
|
+
* ```typescript
|
|
38
41
|
* fromTemplate({ a: /alpha/, b: /beta/, ' ': / / }, 'a b') === /^alpha beta$/
|
|
42
|
+
* ```
|
|
39
43
|
*
|
|
40
44
|
*/
|
|
41
45
|
const fromTemplate = (dict, template) => merge(/^/, ...(template.match(/(\s+)|([^\s]+)/g) ?? []).map((t) => dict[t] ?? /* @__PURE__ */ new RegExp(`_MISS_${t}_MISS_`)), /$/);
|
|
@@ -47,7 +51,9 @@ const fromTemplate = (dict, template) => merge(/^/, ...(template.match(/(\s+)|([
|
|
|
47
51
|
* pure function
|
|
48
52
|
*
|
|
49
53
|
* @example
|
|
50
|
-
*
|
|
54
|
+
* ```typescript
|
|
55
|
+
* group(/a/, /b/, /c/) === /(?:abc)/
|
|
56
|
+
* ```
|
|
51
57
|
*/
|
|
52
58
|
const group = (...p) => /* @__PURE__ */ new RegExp(`(?:${merge(...p).source})`);
|
|
53
59
|
/**
|
|
@@ -59,7 +65,9 @@ const group = (...p) => /* @__PURE__ */ new RegExp(`(?:${merge(...p).source})`);
|
|
|
59
65
|
* pure function
|
|
60
66
|
*
|
|
61
67
|
* @example
|
|
68
|
+
* ```typescript
|
|
62
69
|
* merge(/a/, /b/, /c/) === /abc/
|
|
70
|
+
* ```
|
|
63
71
|
*/
|
|
64
72
|
const merge = (...all) => all.reduce((acc, next) => new RegExp(acc?.source + next.source));
|
|
65
73
|
/**
|
|
@@ -70,7 +78,9 @@ const merge = (...all) => all.reduce((acc, next) => new RegExp(acc?.source + nex
|
|
|
70
78
|
* pure function
|
|
71
79
|
*
|
|
72
80
|
* @example
|
|
73
|
-
*
|
|
81
|
+
* ```typescript
|
|
82
|
+
* optional(/a/, /b/, /c/) === /(?:abc)?/
|
|
83
|
+
* ```
|
|
74
84
|
*/
|
|
75
85
|
const optional = (...p) => /* @__PURE__ */ new RegExp(`(?:${merge(...p).source})?`);
|
|
76
86
|
|
package/dist/patterning.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"patterning.js","names":[],"sources":["../src/patterning.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 * Create a \"capturing\" group with the pattern provided by all arguments\n * merged into a single regex.\n *\n * @remarks\n * pure function\n *\n * @example\n * capture(/a/, /b/, /c/) === /(abc)/\n */\nexport const capture = (...p: RegExp[]) =>\n new RegExp(`(${merge(...p).source})`);\n\n/**\n * Create a pattern using a template string and dict(ionary) of terms.\n *\n * @param dict an object with keys/properties that are RegExp objects that will\n * be used in the template string\n * @param template the definition of the pattern to build using the dict(ionary)\n * patterns\n *\n * @remarks\n * pure function\n *\n * @example\n * fromTemplate({ a: /alpha/, b: /beta/, ' ': / / }, 'a b') === /^alpha beta$/\n *\n */\nexport const fromTemplate = (dict: Record<string, RegExp>, template: string) =>\n merge(\n /^/,\n ...(template.match(/(\\s+)|([^\\s]+)/g) ?? []).map(\n (t) => dict[t as keyof typeof dict] ?? new RegExp(`_MISS_${t}_MISS_`),\n ),\n /$/,\n );\n\n/**\n * Create a \"non-capturing\" group with the pattern provided by all arguments\n * merged into a single regex.\n *\n * @remarks\n * pure function\n *\n * @example\n *
|
|
1
|
+
{"version":3,"file":"patterning.js","names":[],"sources":["../src/patterning.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 * Create a \"capturing\" group with the pattern provided by all arguments\n * merged into a single regex.\n *\n * @remarks\n * pure function\n *\n * @example\n * ```typescript\n * capture(/a/, /b/, /c/) === /(abc)/\n * ```\n */\nexport const capture = (...p: RegExp[]) =>\n new RegExp(`(${merge(...p).source})`);\n\n/**\n * Create a pattern using a template string and dict(ionary) of terms.\n *\n * @param dict an object with keys/properties that are RegExp objects that will\n * be used in the template string\n * @param template the definition of the pattern to build using the dict(ionary)\n * patterns\n *\n * @remarks\n * pure function\n *\n * @example\n * ```typescript\n * fromTemplate({ a: /alpha/, b: /beta/, ' ': / / }, 'a b') === /^alpha beta$/\n * ```\n *\n */\nexport const fromTemplate = (dict: Record<string, RegExp>, template: string) =>\n merge(\n /^/,\n ...(template.match(/(\\s+)|([^\\s]+)/g) ?? []).map(\n (t) => dict[t as keyof typeof dict] ?? new RegExp(`_MISS_${t}_MISS_`),\n ),\n /$/,\n );\n\n/**\n * Create a \"non-capturing\" group with the pattern provided by all arguments\n * merged into a single regex.\n *\n * @remarks\n * pure function\n *\n * @example\n * ```typescript\n * group(/a/, /b/, /c/) === /(?:abc)/\n * ```\n */\nexport const group = (...p: RegExp[]) =>\n new RegExp(`(?:${merge(...p).source})`);\n\n/**\n * Concatenate all of the provided patterns into a single pattern; each\n * subsequent argument is joined with the previous with no \"qualifier\" between\n * them.\n *\n * @remarks\n * pure function\n *\n * @example\n * ```typescript\n * merge(/a/, /b/, /c/) === /abc/\n * ```\n */\nexport const merge = (...all: RegExp[]) =>\n all.reduce((acc, next) => new RegExp(acc?.source + next.source));\n\n/**\n * Create an \"optional\" \"non-capturing\" group with the pattern provided by all\n * arguments merged into a single regex.\n *\n * @remarks\n * pure function\n *\n * @example\n * ```typescript\n * optional(/a/, /b/, /c/) === /(?:abc)?/\n * ```\n */\nexport const optional = (...p: RegExp[]) =>\n new RegExp(`(?:${merge(...p).source})?`);\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;AAyBA,MAAa,WAAW,GAAG,sBACzB,IAAI,OAAO,IAAI,MAAM,GAAG,EAAE,CAAC,OAAO,GAAG;;;;;;;;;;;;;;;;;;AAmBvC,MAAa,gBAAgB,MAA8B,aACzD,MACE,KACA,IAAI,SAAS,MAAM,kBAAkB,IAAI,EAAE,EAAE,KAC1C,MAAM,KAAK,sBAA2B,IAAI,OAAO,SAAS,EAAE,QAAQ,CACtE,EACD,IACD;;;;;;;;;;;;;AAcH,MAAa,SAAS,GAAG,sBACvB,IAAI,OAAO,MAAM,MAAM,GAAG,EAAE,CAAC,OAAO,GAAG;;;;;;;;;;;;;;AAezC,MAAa,SAAS,GAAG,QACvB,IAAI,QAAQ,KAAK,SAAS,IAAI,OAAO,KAAK,SAAS,KAAK,OAAO,CAAC;;;;;;;;;;;;;AAclE,MAAa,YAAY,GAAG,sBAC1B,IAAI,OAAO,MAAM,MAAM,GAAG,EAAE,CAAC,OAAO,IAAI"}
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@accelint/geo",
|
|
3
3
|
"description": "A collection of JavaScript functions for working with coordinates and geospatial data.",
|
|
4
|
-
"version": "0.
|
|
4
|
+
"version": "0.6.0",
|
|
5
5
|
"author": "https://hypergiant.com",
|
|
6
6
|
"$schema": "https://json.schemastore.org/package",
|
|
7
7
|
"dependencies": {
|
|
@@ -39,6 +39,7 @@
|
|
|
39
39
|
"./coordinates/latlon/internal/format": "./dist/coordinates/latlon/internal/format.js",
|
|
40
40
|
"./coordinates/latlon/internal/in-range": "./dist/coordinates/latlon/internal/in-range.js",
|
|
41
41
|
"./coordinates/latlon/internal/lexer": "./dist/coordinates/latlon/internal/lexer.js",
|
|
42
|
+
"./coordinates/latlon/internal/normalize": "./dist/coordinates/latlon/internal/normalize.js",
|
|
42
43
|
"./coordinates/latlon/internal/ordinal": "./dist/coordinates/latlon/internal/ordinal.js",
|
|
43
44
|
"./coordinates/latlon/internal/parse": "./dist/coordinates/latlon/internal/parse.js",
|
|
44
45
|
"./coordinates/latlon/internal/parse-format": "./dist/coordinates/latlon/internal/parse-format.js",
|
|
@@ -49,6 +50,7 @@
|
|
|
49
50
|
"./coordinates/latlon/internal/pipes/fix-dividers": "./dist/coordinates/latlon/internal/pipes/fix-dividers.js",
|
|
50
51
|
"./coordinates/latlon/internal/pipes/genome": "./dist/coordinates/latlon/internal/pipes/genome.js",
|
|
51
52
|
"./coordinates/latlon/internal/pipes/simpler": "./dist/coordinates/latlon/internal/pipes/simpler.js",
|
|
53
|
+
"./coordinates/latlon/internal/validate": "./dist/coordinates/latlon/internal/validate.js",
|
|
52
54
|
"./coordinates/latlon/internal/violation": "./dist/coordinates/latlon/internal/violation.js",
|
|
53
55
|
"./coordinates/mgrs/parser": "./dist/coordinates/mgrs/parser.js",
|
|
54
56
|
"./coordinates/mgrs/system": "./dist/coordinates/mgrs/system.js",
|