@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
|
|
@@ -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"}
|
|
@@ -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,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 };
|
|
@@ -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,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
|
@@ -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
|
|
@@ -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
|
@@ -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
|
|
@@ -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
|
@@ -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
|
|
@@ -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.1",
|
|
5
5
|
"author": "https://hypergiant.com",
|
|
6
6
|
"$schema": "https://json.schemastore.org/package",
|
|
7
7
|
"dependencies": {
|
|
@@ -12,8 +12,8 @@
|
|
|
12
12
|
"tsdown": "^0.18.0",
|
|
13
13
|
"typescript": "^5.9.3",
|
|
14
14
|
"vitest": "^4.0.15",
|
|
15
|
-
"@accelint/
|
|
16
|
-
"@accelint/
|
|
15
|
+
"@accelint/vitest-config": "0.1.6",
|
|
16
|
+
"@accelint/typescript-config": "0.1.4"
|
|
17
17
|
},
|
|
18
18
|
"engines": {
|
|
19
19
|
"node": ">=22",
|
|
@@ -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",
|