@accelint/geo 0.4.0 → 0.4.2

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.
Files changed (109) hide show
  1. package/CHANGELOG.md +13 -0
  2. package/catalog-info.yaml +2 -4
  3. package/dist/cartesian.d.ts +3 -1
  4. package/dist/cartesian.js +34 -5
  5. package/dist/cartesian.js.map +1 -1
  6. package/dist/coordinates/coordinate.d.ts +37 -25
  7. package/dist/coordinates/coordinate.js +71 -77
  8. package/dist/coordinates/coordinate.js.map +1 -1
  9. package/dist/coordinates/latlon/decimal-degrees/formatter.d.ts +16 -2
  10. package/dist/coordinates/latlon/decimal-degrees/formatter.js +17 -3
  11. package/dist/coordinates/latlon/decimal-degrees/formatter.js.map +1 -1
  12. package/dist/coordinates/latlon/decimal-degrees/parser.d.ts +17 -4
  13. package/dist/coordinates/latlon/decimal-degrees/parser.js +60 -62
  14. package/dist/coordinates/latlon/decimal-degrees/parser.js.map +1 -1
  15. package/dist/coordinates/latlon/decimal-degrees/system.d.ts +16 -5
  16. package/dist/coordinates/latlon/decimal-degrees/system.js +26 -14
  17. package/dist/coordinates/latlon/decimal-degrees/system.js.map +1 -1
  18. package/dist/coordinates/latlon/degrees-decimal-minutes/formatter.d.ts +16 -2
  19. package/dist/coordinates/latlon/degrees-decimal-minutes/formatter.js +19 -8
  20. package/dist/coordinates/latlon/degrees-decimal-minutes/formatter.js.map +1 -1
  21. package/dist/coordinates/latlon/degrees-decimal-minutes/parser.d.ts +17 -4
  22. package/dist/coordinates/latlon/degrees-decimal-minutes/parser.js +79 -71
  23. package/dist/coordinates/latlon/degrees-decimal-minutes/parser.js.map +1 -1
  24. package/dist/coordinates/latlon/degrees-decimal-minutes/system.d.ts +16 -5
  25. package/dist/coordinates/latlon/degrees-decimal-minutes/system.js +30 -19
  26. package/dist/coordinates/latlon/degrees-decimal-minutes/system.js.map +1 -1
  27. package/dist/coordinates/latlon/degrees-minutes-seconds/formatter.d.ts +16 -2
  28. package/dist/coordinates/latlon/degrees-minutes-seconds/formatter.js +21 -10
  29. package/dist/coordinates/latlon/degrees-minutes-seconds/formatter.js.map +1 -1
  30. package/dist/coordinates/latlon/degrees-minutes-seconds/parser.d.ts +17 -4
  31. package/dist/coordinates/latlon/degrees-minutes-seconds/parser.js +81 -70
  32. package/dist/coordinates/latlon/degrees-minutes-seconds/parser.js.map +1 -1
  33. package/dist/coordinates/latlon/degrees-minutes-seconds/system.d.ts +16 -5
  34. package/dist/coordinates/latlon/degrees-minutes-seconds/system.js +32 -21
  35. package/dist/coordinates/latlon/degrees-minutes-seconds/system.js.map +1 -1
  36. package/dist/coordinates/latlon/internal/coordinate-system.d.ts +22 -9
  37. package/dist/coordinates/latlon/internal/coordinate-system.js +11 -2
  38. package/dist/coordinates/latlon/internal/create-cache.d.ts +17 -3
  39. package/dist/coordinates/latlon/internal/create-cache.js +27 -7
  40. package/dist/coordinates/latlon/internal/create-cache.js.map +1 -1
  41. package/dist/coordinates/latlon/internal/exhaustive-errors.d.ts +4 -2
  42. package/dist/coordinates/latlon/internal/exhaustive-errors.js +107 -62
  43. package/dist/coordinates/latlon/internal/exhaustive-errors.js.map +1 -1
  44. package/dist/coordinates/latlon/internal/format.d.ts +8 -6
  45. package/dist/coordinates/latlon/internal/format.js +24 -11
  46. package/dist/coordinates/latlon/internal/format.js.map +1 -1
  47. package/dist/coordinates/latlon/internal/in-range.d.ts +3 -1
  48. package/dist/coordinates/latlon/internal/in-range.js +22 -8
  49. package/dist/coordinates/latlon/internal/in-range.js.map +1 -1
  50. package/dist/coordinates/latlon/internal/index.d.ts +35 -33
  51. package/dist/coordinates/latlon/internal/index.js +64 -102
  52. package/dist/coordinates/latlon/internal/index.js.map +1 -1
  53. package/dist/coordinates/latlon/internal/lexer.d.ts +4 -2
  54. package/dist/coordinates/latlon/internal/lexer.js +54 -33
  55. package/dist/coordinates/latlon/internal/lexer.js.map +1 -1
  56. package/dist/coordinates/latlon/internal/ordinal.d.ts +3 -1
  57. package/dist/coordinates/latlon/internal/ordinal.js +17 -5
  58. package/dist/coordinates/latlon/internal/ordinal.js.map +1 -1
  59. package/dist/coordinates/latlon/internal/parse-format.d.ts +23 -10
  60. package/dist/coordinates/latlon/internal/parse-format.js +37 -54
  61. package/dist/coordinates/latlon/internal/parse-format.js.map +1 -1
  62. package/dist/coordinates/latlon/internal/parse.d.ts +18 -4
  63. package/dist/coordinates/latlon/internal/parse.js +55 -9
  64. package/dist/coordinates/latlon/internal/parse.js.map +1 -1
  65. package/dist/coordinates/latlon/internal/pipes/check-ambiguous.d.ts +17 -3
  66. package/dist/coordinates/latlon/internal/pipes/check-ambiguous.js +31 -16
  67. package/dist/coordinates/latlon/internal/pipes/check-ambiguous.js.map +1 -1
  68. package/dist/coordinates/latlon/internal/pipes/check-numbers.d.ts +16 -2
  69. package/dist/coordinates/latlon/internal/pipes/check-numbers.js +30 -28
  70. package/dist/coordinates/latlon/internal/pipes/check-numbers.js.map +1 -1
  71. package/dist/coordinates/latlon/internal/pipes/fix-bearings.d.ts +18 -4
  72. package/dist/coordinates/latlon/internal/pipes/fix-bearings.js +66 -54
  73. package/dist/coordinates/latlon/internal/pipes/fix-bearings.js.map +1 -1
  74. package/dist/coordinates/latlon/internal/pipes/fix-dividers.d.ts +18 -4
  75. package/dist/coordinates/latlon/internal/pipes/fix-dividers.js +42 -25
  76. package/dist/coordinates/latlon/internal/pipes/fix-dividers.js.map +1 -1
  77. package/dist/coordinates/latlon/internal/pipes/genome.d.ts +16 -2
  78. package/dist/coordinates/latlon/internal/pipes/genome.js +46 -25
  79. package/dist/coordinates/latlon/internal/pipes/genome.js.map +1 -1
  80. package/dist/coordinates/latlon/internal/pipes/index.d.ts +18 -4
  81. package/dist/coordinates/latlon/internal/pipes/index.js +58 -35
  82. package/dist/coordinates/latlon/internal/pipes/index.js.map +1 -1
  83. package/dist/coordinates/latlon/internal/pipes/simpler.d.ts +16 -2
  84. package/dist/coordinates/latlon/internal/pipes/simpler.js +25 -1
  85. package/dist/coordinates/latlon/internal/pipes/simpler.js.map +1 -1
  86. package/dist/coordinates/latlon/internal/violation.d.ts +3 -1
  87. package/dist/coordinates/latlon/internal/violation.js +15 -1
  88. package/dist/coordinates/latlon/internal/violation.js.map +1 -1
  89. package/dist/coordinates/mgrs/parser.d.ts +16 -4
  90. package/dist/coordinates/mgrs/parser.js +32 -35
  91. package/dist/coordinates/mgrs/parser.js.map +1 -1
  92. package/dist/coordinates/mgrs/system.d.ts +16 -5
  93. package/dist/coordinates/mgrs/system.js +28 -18
  94. package/dist/coordinates/mgrs/system.js.map +1 -1
  95. package/dist/coordinates/utm/parser.d.ts +16 -4
  96. package/dist/coordinates/utm/parser.js +32 -30
  97. package/dist/coordinates/utm/parser.js.map +1 -1
  98. package/dist/coordinates/utm/system.d.ts +16 -5
  99. package/dist/coordinates/utm/system.js +29 -23
  100. package/dist/coordinates/utm/system.js.map +1 -1
  101. package/dist/index.d.ts +24 -15
  102. package/dist/index.js +26 -13
  103. package/dist/patterning.d.ts +3 -1
  104. package/dist/patterning.js +75 -11
  105. package/dist/patterning.js.map +1 -1
  106. package/package.json +77 -42
  107. package/dist/coordinates/latlon/internal/coordinate-system.js.map +0 -1
  108. package/dist/index.js.map +0 -1
  109. package/dist/metafile-esm.json +0 -1
package/CHANGELOG.md CHANGED
@@ -1,6 +1,19 @@
1
1
  # @accelint/geo
2
2
 
3
+ ## 0.4.2
4
+
5
+ ### Patch Changes
6
+
7
+ - bb73a1e: Ensure dependencies all follow the same semver range across devtk, maptk, and designtk.
8
+
9
+ ## 0.4.1
10
+
11
+ ### Patch Changes
12
+
13
+ - 34c42a0: Swap bundling to tsdown and auto generate exports entries in package.json.
14
+
3
15
  ## 0.4.0
16
+
4
17
  ### Minor Changes
5
18
 
6
19
  - cfe734a: Fix @accelint/geo UTM parsing and formatting. UTM format will no longer return MGRS format.
package/catalog-info.yaml CHANGED
@@ -11,12 +11,11 @@ metadata:
11
11
 
12
12
  Dependencies:
13
13
 
14
- accelint_constellation-tracker@1.0.1, accelint_typescript-config@0.1.4,
15
- accelint_vitest-config@0.1.5
14
+ accelint_typescript-config@0.1.4, accelint_vitest-config@0.1.6
16
15
  annotations:
17
16
  backstage.io/edit-url: https://github.com/gohypergiant/standard-toolkit/blob/main/packages/geo/catalog-info.yaml
18
17
  backstage.io/techdocs-ref: dir:.
19
- package/version: 0.4.0
18
+ package/version: 0.4.2
20
19
  github.com/project-slug: gohypergiant/standard-toolkit
21
20
  links:
22
21
  - url: https://github.com/gohypergiant/standard-toolkit/tree/main/packages/geo
@@ -31,6 +30,5 @@ spec:
31
30
  lifecycle: production
32
31
  owner: group:default/pathfinder
33
32
  dependsOn:
34
- - component:accelint_constellation-tracker
35
33
  - component:accelint_typescript-config
36
34
  - component:accelint_vitest-config
@@ -1,3 +1,4 @@
1
+ //#region src/cartesian.d.ts
1
2
  /**
2
3
  * Computes the Cartesian product of multiple arrays.
3
4
  *
@@ -17,5 +18,6 @@
17
18
  * // result: [[1, 'a'], [1, 'b'], [2, 'a'], [2, 'b']]
18
19
  */
19
20
  declare function cartesian<T>(...all: T[][]): T[][];
20
-
21
+ //#endregion
21
22
  export { cartesian };
23
+ //# sourceMappingURL=cartesian.d.ts.map
package/dist/cartesian.js CHANGED
@@ -1,10 +1,39 @@
1
+ /*
2
+ * Copyright 2025 Hypergiant Galactic Systems Inc. All rights reserved.
3
+ * This file is licensed to you under the Apache License, Version 2.0 (the "License");
4
+ * you may not use this file except in compliance with the License. You may obtain a copy
5
+ * of the License at https://www.apache.org/licenses/LICENSE-2.0
6
+ *
7
+ * Unless required by applicable law or agreed to in writing, software distributed under
8
+ * the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS
9
+ * OF ANY KIND, either express or implied. See the License for the specific language
10
+ * governing permissions and limitations under the License.
11
+ */
12
+
13
+
14
+ //#region src/cartesian.ts
15
+ /**
16
+ * Computes the Cartesian product of multiple arrays.
17
+ *
18
+ * @template T
19
+ * the type of elements in the input arrays.
20
+ * @param {...T[][]} all
21
+ * a variadic number of arrays to compute the Cartesian product of.
22
+ * @returns {T[][]}
23
+ * An array containing all possible combinations of elements from the input
24
+ * arrays, where each combination is represented as an array.
25
+ *
26
+ * @remarks
27
+ * pure function
28
+ *
29
+ * @example
30
+ * const result = cartesian([1, 2], ['a', 'b']);
31
+ * // result: [[1, 'a'], [1, 'b'], [2, 'a'], [2, 'b']]
32
+ */
1
33
  function cartesian(...all) {
2
- return all.reduce(
3
- (results, entries) => results.map((result) => entries.map((entry) => result.concat([entry]))).reduce((sub, res) => sub.concat(res), []),
4
- [[]]
5
- );
34
+ return all.reduce((results, entries) => results.map((result) => entries.map((entry) => result.concat([entry]))).reduce((sub, res) => sub.concat(res), []), [[]]);
6
35
  }
7
36
 
37
+ //#endregion
8
38
  export { cartesian };
9
- //# sourceMappingURL=cartesian.js.map
10
39
  //# sourceMappingURL=cartesian.js.map
@@ -1 +1 @@
1
- {"version":3,"sources":["../src/cartesian.ts"],"names":[],"mappings":"AA+BO,SAAS,aAAgB,GAAA,EAAmB;AACjD,EAAA,OAAO,GAAA,CAAI,MAAA;AAAA,IACT,CAAC,OAAA,EAAS,OAAA,KACR,OAAA,CACG,GAAA,CAAI,CAAC,MAAA,KAAW,OAAA,CAAQ,GAAA,CAAI,CAAC,KAAA,KAAU,MAAA,CAAO,MAAA,CAAO,CAAC,KAAK,CAAC,CAAC,CAAC,CAAA,CAC9D,MAAA,CAAO,CAAC,GAAA,EAAK,GAAA,KAAQ,GAAA,CAAI,MAAA,CAAO,GAAG,CAAA,EAAG,EAAE,CAAA;AAAA,IAC7C,CAAC,EAAE;AAAA,GACL;AACF","file":"cartesian.js","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 * Computes the Cartesian product of multiple arrays.\n *\n * @template T\n * the type of elements in the input arrays.\n * @param {...T[][]} all\n * a variadic number of arrays to compute the Cartesian product of.\n * @returns {T[][]}\n * An array containing all possible combinations of elements from the input\n * arrays, where each combination is represented as an array.\n *\n * @remarks\n * pure function\n *\n * @example\n * const result = cartesian([1, 2], ['a', 'b']);\n * // result: [[1, 'a'], [1, 'b'], [2, 'a'], [2, 'b']]\n */\nexport function cartesian<T>(...all: T[][]): T[][] {\n return all.reduce<T[][]>(\n (results, entries) =>\n results\n .map((result) => entries.map((entry) => result.concat([entry])))\n .reduce((sub, res) => sub.concat(res), []),\n [[]],\n );\n}\n"]}
1
+ {"version":3,"file":"cartesian.js","names":[],"sources":["../src/cartesian.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 * Computes the Cartesian product of multiple arrays.\n *\n * @template T\n * the type of elements in the input arrays.\n * @param {...T[][]} all\n * a variadic number of arrays to compute the Cartesian product of.\n * @returns {T[][]}\n * An array containing all possible combinations of elements from the input\n * arrays, where each combination is represented as an array.\n *\n * @remarks\n * pure function\n *\n * @example\n * const result = cartesian([1, 2], ['a', 'b']);\n * // result: [[1, 'a'], [1, 'b'], [2, 'a'], [2, 'b']]\n */\nexport function cartesian<T>(...all: T[][]): T[][] {\n return all.reduce<T[][]>(\n (results, entries) =>\n results\n .map((result) => entries.map((entry) => result.concat([entry])))\n .reduce((sub, res) => sub.concat(res), []),\n [[]],\n );\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AA+BA,SAAgB,UAAa,GAAG,KAAmB;AACjD,QAAO,IAAI,QACR,SAAS,YACR,QACG,KAAK,WAAW,QAAQ,KAAK,UAAU,OAAO,OAAO,CAAC,MAAM,CAAC,CAAC,CAAC,CAC/D,QAAQ,KAAK,QAAQ,IAAI,OAAO,IAAI,EAAE,EAAE,CAAC,EAC9C,CAAC,EAAE,CAAC,CACL"}
@@ -1,26 +1,37 @@
1
- import { Format } from './latlon/internal/index.js';
2
- import { CoordinateSystem } from './latlon/internal/coordinate-system.js';
3
- import './latlon/internal/parse.js';
4
- import './latlon/internal/lexer.js';
1
+ /*
2
+ * Copyright 2025 Hypergiant Galactic Systems Inc. All rights reserved.
3
+ * This file is licensed to you under the Apache License, Version 2.0 (the "License");
4
+ * you may not use this file except in compliance with the License. You may obtain a copy
5
+ * of the License at https://www.apache.org/licenses/LICENSE-2.0
6
+ *
7
+ * Unless required by applicable law or agreed to in writing, software distributed under
8
+ * the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS
9
+ * OF ANY KIND, either express or implied. See the License for the specific language
10
+ * governing permissions and limitations under the License.
11
+ */
5
12
 
13
+ import { Format } from "./latlon/internal/index.js";
14
+ import { CoordinateSystem } from "./latlon/internal/coordinate-system.js";
15
+
16
+ //#region src/coordinates/coordinate.d.ts
6
17
  type Coordinate = {
7
- /** {@interitDoc Formatter} */
8
- dd: Formatter;
9
- /** {@interitDoc Formatter} */
10
- ddm: Formatter;
11
- /** {@interitDoc Formatter} */
12
- dms: Formatter;
13
- /** {@interitDoc Formatter} */
14
- mgrs: Formatter;
15
- /** {@interitDoc Formatter} */
16
- utm: Formatter;
17
- errors: string[];
18
- raw: CoordinateInternalValue;
19
- valid: boolean;
18
+ /** {@interitDoc Formatter} */
19
+ dd: Formatter;
20
+ /** {@interitDoc Formatter} */
21
+ ddm: Formatter;
22
+ /** {@interitDoc Formatter} */
23
+ dms: Formatter;
24
+ /** {@interitDoc Formatter} */
25
+ mgrs: Formatter;
26
+ /** {@interitDoc Formatter} */
27
+ utm: Formatter;
28
+ errors: string[];
29
+ raw: CoordinateInternalValue;
30
+ valid: boolean;
20
31
  };
21
32
  type CoordinateInternalValue = {
22
- LAT: number;
23
- LON: number;
33
+ LAT: number;
34
+ LON: number;
24
35
  };
25
36
  /**
26
37
  * Output a string value of a coordinate using an available system. The
@@ -48,11 +59,11 @@ type CoordinateInternalValue = {
48
59
  */
49
60
  type Formatter = (f?: Format) => string;
50
61
  declare const coordinateSystems: Readonly<{
51
- readonly dd: CoordinateSystem;
52
- readonly ddm: CoordinateSystem;
53
- readonly dms: CoordinateSystem;
54
- readonly mgrs: CoordinateSystem;
55
- readonly utm: CoordinateSystem;
62
+ readonly dd: CoordinateSystem;
63
+ readonly ddm: CoordinateSystem;
64
+ readonly dms: CoordinateSystem;
65
+ readonly mgrs: CoordinateSystem;
66
+ readonly utm: CoordinateSystem;
56
67
  }>;
57
68
  /**
58
69
  * Create a coordinate object enabling: lexing, parsing, validation, and
@@ -70,5 +81,6 @@ declare const coordinateSystems: Readonly<{
70
81
  * const create = createCoordinate(coordinateSystems.ddm, 'LONLAT')
71
82
  */
72
83
  declare function createCoordinate(initSystem?: CoordinateSystem, initFormat?: Format): (input: string) => Readonly<Coordinate>;
73
-
84
+ //#endregion
74
85
  export { coordinateSystems, createCoordinate };
86
+ //# sourceMappingURL=coordinate.d.ts.map
@@ -1,87 +1,81 @@
1
- import { systemDecimalDegrees } from './latlon/decimal-degrees/system.js';
2
- import { systemDegreesDecimalMinutes } from './latlon/degrees-decimal-minutes/system.js';
3
- import { systemDegreesMinutesSeconds } from './latlon/degrees-minutes-seconds/system.js';
4
- import { FORMATS_DEFAULT, SYMBOLS } from './latlon/internal/index.js';
5
- import { createCache } from './latlon/internal/create-cache.js';
6
- import { systemMGRS } from './mgrs/system.js';
7
- import { systemUTM } from './utm/system.js';
1
+ /*
2
+ * Copyright 2025 Hypergiant Galactic Systems Inc. All rights reserved.
3
+ * This file is licensed to you under the Apache License, Version 2.0 (the "License");
4
+ * you may not use this file except in compliance with the License. You may obtain a copy
5
+ * of the License at https://www.apache.org/licenses/LICENSE-2.0
6
+ *
7
+ * Unless required by applicable law or agreed to in writing, software distributed under
8
+ * the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS
9
+ * OF ANY KIND, either express or implied. See the License for the specific language
10
+ * governing permissions and limitations under the License.
11
+ */
8
12
 
13
+
14
+ import { FORMATS_DEFAULT, SYMBOLS } from "./latlon/internal/index.js";
15
+ import { systemDecimalDegrees } from "./latlon/decimal-degrees/system.js";
16
+ import { systemDegreesDecimalMinutes } from "./latlon/degrees-decimal-minutes/system.js";
17
+ import { systemDegreesMinutesSeconds } from "./latlon/degrees-minutes-seconds/system.js";
18
+ import { createCache } from "./latlon/internal/create-cache.js";
19
+ import { systemMGRS } from "./mgrs/system.js";
20
+ import { systemUTM } from "./utm/system.js";
21
+
22
+ //#region src/coordinates/coordinate.ts
9
23
  const coordinateSystems = Object.freeze({
10
- dd: systemDecimalDegrees,
11
- ddm: systemDegreesDecimalMinutes,
12
- dms: systemDegreesMinutesSeconds,
13
- mgrs: systemMGRS,
14
- utm: systemUTM
24
+ dd: systemDecimalDegrees,
25
+ ddm: systemDegreesDecimalMinutes,
26
+ dms: systemDegreesMinutesSeconds,
27
+ mgrs: systemMGRS,
28
+ utm: systemUTM
15
29
  });
16
30
  const freezeCoordinate = (errors, to, raw, valid) => Object.freeze({
17
- dd: (format) => to(systemDecimalDegrees, format),
18
- ddm: (format) => to(systemDegreesDecimalMinutes, format),
19
- dms: (format) => to(systemDegreesMinutesSeconds, format),
20
- mgrs: (format) => to(systemMGRS, format),
21
- utm: (format) => to(systemUTM, format),
22
- errors,
23
- raw,
24
- valid
31
+ dd: (format) => to(systemDecimalDegrees, format),
32
+ ddm: (format) => to(systemDegreesDecimalMinutes, format),
33
+ dms: (format) => to(systemDegreesMinutesSeconds, format),
34
+ mgrs: (format) => to(systemMGRS, format),
35
+ utm: (format) => to(systemUTM, format),
36
+ errors,
37
+ raw,
38
+ valid
25
39
  });
40
+ /**
41
+ * Create a coordinate object enabling: lexing, parsing, validation, and
42
+ * formatting in alternative systems and formats. The system and format will be
43
+ * used for validation and eventually for output as defaults if no alternatives
44
+ * are provided.
45
+ *
46
+ * @param initSystem dd, ddm, dms, mgrs, or utm of coordinateSystems
47
+ *
48
+ * @remarks
49
+ * pure function
50
+ *
51
+ * @example
52
+ * const create = createCoordinate(coordinateSystems.dd, 'LATLON')
53
+ * const create = createCoordinate(coordinateSystems.ddm, 'LONLAT')
54
+ */
26
55
  function createCoordinate(initSystem = coordinateSystems.dd, initFormat = FORMATS_DEFAULT) {
27
- return (input) => {
28
- let tokens;
29
- let errors;
30
- try {
31
- [tokens, errors] = initSystem.parse(initFormat, input);
32
- if (errors.length) {
33
- throw errors;
34
- }
35
- } catch (errors2) {
36
- return freezeCoordinate(
37
- errors2,
38
- () => "",
39
- {},
40
- false
41
- );
42
- }
43
- const cachedValues = {
44
- [initSystem.name]: createCache(
45
- initFormat,
46
- // because mgrs doesn't have two formats: LATLON v LONLAT
47
- initSystem.name === systemMGRS.name ? input : tokens.join(" ")
48
- )
49
- };
50
- const raw = Object.fromEntries([
51
- [
52
- initFormat.slice(0, 3),
53
- initSystem.toFloat(
54
- tokens.slice(0, tokens.indexOf(SYMBOLS.DIVIDER))
55
- )
56
- ],
57
- [
58
- initFormat.slice(3),
59
- initSystem.toFloat(
60
- tokens.slice(1 + tokens.indexOf(SYMBOLS.DIVIDER))
61
- )
62
- ]
63
- ]);
64
- function to(system = initSystem, format = initFormat) {
65
- const key = system.name;
66
- if (!cachedValues[key]?.[format]) {
67
- cachedValues[key] = {
68
- ...cachedValues[key],
69
- // use the Format to build the object, correctly pairing the halves of
70
- // the coordinate value with their labels
71
- [format]: system.toFormat(
72
- format,
73
- [format.slice(0, 3), format.slice(3)].map(
74
- (key2) => raw[key2]
75
- )
76
- )
77
- };
78
- }
79
- return cachedValues[key][format];
80
- }
81
- return freezeCoordinate([], to, raw, true);
82
- };
56
+ return (input) => {
57
+ let tokens;
58
+ let errors;
59
+ try {
60
+ [tokens, errors] = initSystem.parse(initFormat, input);
61
+ if (errors.length) throw errors;
62
+ } catch (errors$1) {
63
+ return freezeCoordinate(errors$1, () => "", {}, false);
64
+ }
65
+ const cachedValues = { [initSystem.name]: createCache(initFormat, initSystem.name === systemMGRS.name ? input : tokens.join(" ")) };
66
+ const raw = Object.fromEntries([[initFormat.slice(0, 3), initSystem.toFloat(tokens.slice(0, tokens.indexOf(SYMBOLS.DIVIDER)))], [initFormat.slice(3), initSystem.toFloat(tokens.slice(1 + tokens.indexOf(SYMBOLS.DIVIDER)))]]);
67
+ function to(system = initSystem, format = initFormat) {
68
+ const key = system.name;
69
+ if (!cachedValues[key]?.[format]) cachedValues[key] = {
70
+ ...cachedValues[key],
71
+ [format]: system.toFormat(format, [format.slice(0, 3), format.slice(3)].map((key$1) => raw[key$1]))
72
+ };
73
+ return cachedValues[key][format];
74
+ }
75
+ return freezeCoordinate([], to, raw, true);
76
+ };
83
77
  }
84
78
 
79
+ //#endregion
85
80
  export { coordinateSystems, createCoordinate };
86
- //# sourceMappingURL=coordinate.js.map
87
81
  //# sourceMappingURL=coordinate.js.map
@@ -1 +1 @@
1
- {"version":3,"sources":["../../src/coordinates/coordinate.ts"],"names":["errors","key"],"mappings":"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","file":"coordinate.js","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 { systemDecimalDegrees } from './latlon/decimal-degrees/system';\nimport { systemDegreesDecimalMinutes } from './latlon/degrees-decimal-minutes/system';\nimport { systemDegreesMinutesSeconds } from './latlon/degrees-minutes-seconds/system';\nimport {\n type Axes,\n type Errors,\n FORMATS_DEFAULT,\n type Format,\n SYMBOLS,\n} from './latlon/internal';\nimport {\n type CoordinateCache,\n createCache,\n} from './latlon/internal/create-cache';\nimport { systemMGRS } from './mgrs/system';\nimport { systemUTM } from './utm/system';\nimport type { CoordinateSystem } from './latlon/internal/coordinate-system';\nimport type { Tokens } from './latlon/internal/lexer';\n\ntype Coordinate = {\n /** {@interitDoc Formatter} */\n dd: Formatter;\n /** {@interitDoc Formatter} */\n ddm: Formatter;\n /** {@interitDoc Formatter} */\n dms: Formatter;\n /** {@interitDoc Formatter} */\n mgrs: Formatter;\n /** {@interitDoc Formatter} */\n utm: Formatter;\n errors: string[];\n raw: CoordinateInternalValue;\n valid: boolean;\n};\n\n// biome-ignore lint/style/useNamingConvention: consistency with Axes type\ntype CoordinateInternalValue = { LAT: number; LON: number };\n\n/**\n * Output a string value of a coordinate using an available system. The\n * original value is preserved without conversion to an internal\n * representation - Decimal Degrees - to prevent the possibility of\n * rounding errors. All alternative values are computed from a common\n * internal value to reduce complexity.\n *\n * @link https://en.wikipedia.org/wiki/Coordinate_system\n *\n * @remarks\n * pure function\n *\n * @example\n * const create = createCoordinate(coordinateSystems.dd, 'LATLON')\n * const coord = create('89.765432109 / 123.456789012')\n *\n * // honors the instantiation format 'LATLON'\n * coord.dd() === '89.765432109 N / 123.456789012 E'\n * coord.ddm() === '89 45.92592654 N / 123 27.40734072 E'\n * coord.dms() === '89 45 55.5555924 N / 123 27 24.4404432 E'\n *\n * // change format to 'LONLAT'\n * coord.dms('LONLAT') === '123 27 24.4404432 E / 89 45 55.5555924 N'\n */\ntype Formatter = (f?: Format) => string;\n\ntype ToFloatArg = Parameters<CoordinateSystem['toFloat']>[0];\n\ntype OutputCache = Record<keyof typeof coordinateSystems, CoordinateCache>;\n\nexport const coordinateSystems = Object.freeze({\n dd: systemDecimalDegrees,\n ddm: systemDegreesDecimalMinutes,\n dms: systemDegreesMinutesSeconds,\n mgrs: systemMGRS,\n utm: systemUTM,\n} as const);\n\nconst freezeCoordinate = (\n errors: Coordinate['errors'],\n to: (s?: CoordinateSystem, f?: Format) => string,\n raw: CoordinateInternalValue,\n valid: Coordinate['valid'],\n) =>\n Object.freeze({\n dd: (format?: Format) => to(systemDecimalDegrees, format),\n ddm: (format?: Format) => to(systemDegreesDecimalMinutes, format),\n dms: (format?: Format) => to(systemDegreesMinutesSeconds, format),\n mgrs: (format?: Format) => to(systemMGRS, format),\n utm: (format?: Format) => to(systemUTM, format),\n errors,\n raw,\n valid,\n } as Coordinate);\n\n/**\n * Create a coordinate object enabling: lexing, parsing, validation, and\n * formatting in alternative systems and formats. The system and format will be\n * used for validation and eventually for output as defaults if no alternatives\n * are provided.\n *\n * @param initSystem dd, ddm, dms, mgrs, or utm of coordinateSystems\n *\n * @remarks\n * pure function\n *\n * @example\n * const create = createCoordinate(coordinateSystems.dd, 'LATLON')\n * const create = createCoordinate(coordinateSystems.ddm, 'LONLAT')\n */\nexport function createCoordinate(\n initSystem: CoordinateSystem = coordinateSystems.dd,\n initFormat: Format = FORMATS_DEFAULT,\n) {\n return (input: string) => {\n let tokens: Tokens;\n let errors: Errors;\n\n try {\n [tokens, errors] = initSystem.parse(initFormat, input);\n\n if (errors.length) {\n throw errors;\n }\n } catch (errors) {\n return freezeCoordinate(\n errors as Coordinate['errors'],\n () => '',\n {} as CoordinateInternalValue,\n false,\n );\n }\n\n // start with the original value for the original system in the original format\n // other values will be computed as needed and cached per request\n const cachedValues = {\n [initSystem.name]: createCache(\n initFormat,\n // because mgrs doesn't have two formats: LATLON v LONLAT\n initSystem.name === systemMGRS.name ? input : tokens.join(' '),\n ),\n } as OutputCache;\n\n // Create the \"internal\" representation - Decimal Degrees - for\n // consistency and ease of computation; all systems expect to\n // start from a common starting point to reduce complexity.\n const raw = Object.fromEntries([\n [\n initFormat.slice(0, 3),\n initSystem.toFloat(\n tokens.slice(0, tokens.indexOf(SYMBOLS.DIVIDER)) as ToFloatArg,\n ),\n ],\n [\n initFormat.slice(3),\n initSystem.toFloat(\n tokens.slice(1 + tokens.indexOf(SYMBOLS.DIVIDER)) as ToFloatArg,\n ),\n ],\n ]) as CoordinateInternalValue;\n\n function to(\n system: CoordinateSystem = initSystem,\n format: Format = initFormat,\n ) {\n const key = system.name as keyof typeof coordinateSystems;\n\n if (!cachedValues[key]?.[format]) {\n // cache \"miss\" - fill the missing value in the cache before returning it\n\n // update the cache to include the newly computed value\n cachedValues[key] = {\n ...cachedValues[key],\n // use the Format to build the object, correctly pairing the halves of\n // the coordinate value with their labels\n [format]: system.toFormat(\n format,\n ([format.slice(0, 3), format.slice(3)] as Axes[]).map(\n (key) => raw[key],\n ) as [number, number],\n ),\n };\n }\n\n return cachedValues[key][format];\n }\n\n return freezeCoordinate([] as Coordinate['errors'], to, raw, true);\n };\n}\n"]}
1
+ {"version":3,"file":"coordinate.js","names":["tokens: Tokens","errors: Errors","errors","key"],"sources":["../../src/coordinates/coordinate.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 { systemDecimalDegrees } from './latlon/decimal-degrees/system';\nimport { systemDegreesDecimalMinutes } from './latlon/degrees-decimal-minutes/system';\nimport { systemDegreesMinutesSeconds } from './latlon/degrees-minutes-seconds/system';\nimport {\n type Axes,\n type Errors,\n FORMATS_DEFAULT,\n type Format,\n SYMBOLS,\n} from './latlon/internal';\nimport {\n type CoordinateCache,\n createCache,\n} from './latlon/internal/create-cache';\nimport { systemMGRS } from './mgrs/system';\nimport { systemUTM } from './utm/system';\nimport type { CoordinateSystem } from './latlon/internal/coordinate-system';\nimport type { Tokens } from './latlon/internal/lexer';\n\ntype Coordinate = {\n /** {@interitDoc Formatter} */\n dd: Formatter;\n /** {@interitDoc Formatter} */\n ddm: Formatter;\n /** {@interitDoc Formatter} */\n dms: Formatter;\n /** {@interitDoc Formatter} */\n mgrs: Formatter;\n /** {@interitDoc Formatter} */\n utm: Formatter;\n errors: string[];\n raw: CoordinateInternalValue;\n valid: boolean;\n};\n\n// biome-ignore lint/style/useNamingConvention: consistency with Axes type\ntype CoordinateInternalValue = { LAT: number; LON: number };\n\n/**\n * Output a string value of a coordinate using an available system. The\n * original value is preserved without conversion to an internal\n * representation - Decimal Degrees - to prevent the possibility of\n * rounding errors. All alternative values are computed from a common\n * internal value to reduce complexity.\n *\n * @link https://en.wikipedia.org/wiki/Coordinate_system\n *\n * @remarks\n * pure function\n *\n * @example\n * const create = createCoordinate(coordinateSystems.dd, 'LATLON')\n * const coord = create('89.765432109 / 123.456789012')\n *\n * // honors the instantiation format 'LATLON'\n * coord.dd() === '89.765432109 N / 123.456789012 E'\n * coord.ddm() === '89 45.92592654 N / 123 27.40734072 E'\n * coord.dms() === '89 45 55.5555924 N / 123 27 24.4404432 E'\n *\n * // change format to 'LONLAT'\n * coord.dms('LONLAT') === '123 27 24.4404432 E / 89 45 55.5555924 N'\n */\ntype Formatter = (f?: Format) => string;\n\ntype ToFloatArg = Parameters<CoordinateSystem['toFloat']>[0];\n\ntype OutputCache = Record<keyof typeof coordinateSystems, CoordinateCache>;\n\nexport const coordinateSystems = Object.freeze({\n dd: systemDecimalDegrees,\n ddm: systemDegreesDecimalMinutes,\n dms: systemDegreesMinutesSeconds,\n mgrs: systemMGRS,\n utm: systemUTM,\n} as const);\n\nconst freezeCoordinate = (\n errors: Coordinate['errors'],\n to: (s?: CoordinateSystem, f?: Format) => string,\n raw: CoordinateInternalValue,\n valid: Coordinate['valid'],\n) =>\n Object.freeze({\n dd: (format?: Format) => to(systemDecimalDegrees, format),\n ddm: (format?: Format) => to(systemDegreesDecimalMinutes, format),\n dms: (format?: Format) => to(systemDegreesMinutesSeconds, format),\n mgrs: (format?: Format) => to(systemMGRS, format),\n utm: (format?: Format) => to(systemUTM, format),\n errors,\n raw,\n valid,\n } as Coordinate);\n\n/**\n * Create a coordinate object enabling: lexing, parsing, validation, and\n * formatting in alternative systems and formats. The system and format will be\n * used for validation and eventually for output as defaults if no alternatives\n * are provided.\n *\n * @param initSystem dd, ddm, dms, mgrs, or utm of coordinateSystems\n *\n * @remarks\n * pure function\n *\n * @example\n * const create = createCoordinate(coordinateSystems.dd, 'LATLON')\n * const create = createCoordinate(coordinateSystems.ddm, 'LONLAT')\n */\nexport function createCoordinate(\n initSystem: CoordinateSystem = coordinateSystems.dd,\n initFormat: Format = FORMATS_DEFAULT,\n) {\n return (input: string) => {\n let tokens: Tokens;\n let errors: Errors;\n\n try {\n [tokens, errors] = initSystem.parse(initFormat, input);\n\n if (errors.length) {\n throw errors;\n }\n } catch (errors) {\n return freezeCoordinate(\n errors as Coordinate['errors'],\n () => '',\n {} as CoordinateInternalValue,\n false,\n );\n }\n\n // start with the original value for the original system in the original format\n // other values will be computed as needed and cached per request\n const cachedValues = {\n [initSystem.name]: createCache(\n initFormat,\n // because mgrs doesn't have two formats: LATLON v LONLAT\n initSystem.name === systemMGRS.name ? input : tokens.join(' '),\n ),\n } as OutputCache;\n\n // Create the \"internal\" representation - Decimal Degrees - for\n // consistency and ease of computation; all systems expect to\n // start from a common starting point to reduce complexity.\n const raw = Object.fromEntries([\n [\n initFormat.slice(0, 3),\n initSystem.toFloat(\n tokens.slice(0, tokens.indexOf(SYMBOLS.DIVIDER)) as ToFloatArg,\n ),\n ],\n [\n initFormat.slice(3),\n initSystem.toFloat(\n tokens.slice(1 + tokens.indexOf(SYMBOLS.DIVIDER)) as ToFloatArg,\n ),\n ],\n ]) as CoordinateInternalValue;\n\n function to(\n system: CoordinateSystem = initSystem,\n format: Format = initFormat,\n ) {\n const key = system.name as keyof typeof coordinateSystems;\n\n if (!cachedValues[key]?.[format]) {\n // cache \"miss\" - fill the missing value in the cache before returning it\n\n // update the cache to include the newly computed value\n cachedValues[key] = {\n ...cachedValues[key],\n // use the Format to build the object, correctly pairing the halves of\n // the coordinate value with their labels\n [format]: system.toFormat(\n format,\n ([format.slice(0, 3), format.slice(3)] as Axes[]).map(\n (key) => raw[key],\n ) as [number, number],\n ),\n };\n }\n\n return cachedValues[key][format];\n }\n\n return freezeCoordinate([] as Coordinate['errors'], to, raw, true);\n };\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;AAgFA,MAAa,oBAAoB,OAAO,OAAO;CAC7C,IAAI;CACJ,KAAK;CACL,KAAK;CACL,MAAM;CACN,KAAK;CACN,CAAU;AAEX,MAAM,oBACJ,QACA,IACA,KACA,UAEA,OAAO,OAAO;CACZ,KAAK,WAAoB,GAAG,sBAAsB,OAAO;CACzD,MAAM,WAAoB,GAAG,6BAA6B,OAAO;CACjE,MAAM,WAAoB,GAAG,6BAA6B,OAAO;CACjE,OAAO,WAAoB,GAAG,YAAY,OAAO;CACjD,MAAM,WAAoB,GAAG,WAAW,OAAO;CAC/C;CACA;CACA;CACD,CAAe;;;;;;;;;;;;;;;;AAiBlB,SAAgB,iBACd,aAA+B,kBAAkB,IACjD,aAAqB,iBACrB;AACA,SAAQ,UAAkB;EACxB,IAAIA;EACJ,IAAIC;AAEJ,MAAI;AACF,IAAC,QAAQ,UAAU,WAAW,MAAM,YAAY,MAAM;AAEtD,OAAI,OAAO,OACT,OAAM;WAEDC,UAAQ;AACf,UAAO,iBACLA,gBACM,IACN,EAAE,EACF,MACD;;EAKH,MAAM,eAAe,GAClB,WAAW,OAAO,YACjB,YAEA,WAAW,SAAS,WAAW,OAAO,QAAQ,OAAO,KAAK,IAAI,CAC/D,EACF;EAKD,MAAM,MAAM,OAAO,YAAY,CAC7B,CACE,WAAW,MAAM,GAAG,EAAE,EACtB,WAAW,QACT,OAAO,MAAM,GAAG,OAAO,QAAQ,QAAQ,QAAQ,CAAC,CACjD,CACF,EACD,CACE,WAAW,MAAM,EAAE,EACnB,WAAW,QACT,OAAO,MAAM,IAAI,OAAO,QAAQ,QAAQ,QAAQ,CAAC,CAClD,CACF,CACF,CAAC;EAEF,SAAS,GACP,SAA2B,YAC3B,SAAiB,YACjB;GACA,MAAM,MAAM,OAAO;AAEnB,OAAI,CAAC,aAAa,OAAO,QAIvB,cAAa,OAAO;IAClB,GAAG,aAAa;KAGf,SAAS,OAAO,SACf,QACC,CAAC,OAAO,MAAM,GAAG,EAAE,EAAE,OAAO,MAAM,EAAE,CAAC,CAAY,KAC/C,UAAQ,IAAIC,OACd,CACF;IACF;AAGH,UAAO,aAAa,KAAK;;AAG3B,SAAO,iBAAiB,EAAE,EAA0B,IAAI,KAAK,KAAK"}
@@ -1,5 +1,19 @@
1
- import { FormatOptions } from '../internal/format.js';
1
+ /*
2
+ * Copyright 2025 Hypergiant Galactic Systems Inc. All rights reserved.
3
+ * This file is licensed to you under the Apache License, Version 2.0 (the "License");
4
+ * you may not use this file except in compliance with the License. You may obtain a copy
5
+ * of the License at https://www.apache.org/licenses/LICENSE-2.0
6
+ *
7
+ * Unless required by applicable law or agreed to in writing, software distributed under
8
+ * the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS
9
+ * OF ANY KIND, either express or implied. See the License for the specific language
10
+ * governing permissions and limitations under the License.
11
+ */
2
12
 
3
- declare const formatDecimalDegrees: (coordinates: [number, number], config?: FormatOptions) => string;
13
+ import { FormatOptions } from "../internal/format.js";
4
14
 
15
+ //#region src/coordinates/latlon/decimal-degrees/formatter.d.ts
16
+ declare const formatDecimalDegrees: (coordinates: [number, number], config?: FormatOptions) => string;
17
+ //#endregion
5
18
  export { formatDecimalDegrees };
19
+ //# sourceMappingURL=formatter.d.ts.map
@@ -1,10 +1,24 @@
1
- import { createFormatter } from '../internal/format.js';
1
+ /*
2
+ * Copyright 2025 Hypergiant Galactic Systems Inc. All rights reserved.
3
+ * This file is licensed to you under the Apache License, Version 2.0 (the "License");
4
+ * you may not use this file except in compliance with the License. You may obtain a copy
5
+ * of the License at https://www.apache.org/licenses/LICENSE-2.0
6
+ *
7
+ * Unless required by applicable law or agreed to in writing, software distributed under
8
+ * the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS
9
+ * OF ANY KIND, either express or implied. See the License for the specific language
10
+ * governing permissions and limitations under the License.
11
+ */
2
12
 
13
+
14
+ import { createFormatter } from "../internal/format.js";
15
+
16
+ //#region src/coordinates/latlon/decimal-degrees/formatter.ts
3
17
  const toDecimalDegrees = (num) => {
4
- return `${num.toFixed(6)}\xB0`;
18
+ return `${num.toFixed(6)}°`;
5
19
  };
6
20
  const formatDecimalDegrees = createFormatter(toDecimalDegrees);
7
21
 
22
+ //#endregion
8
23
  export { formatDecimalDegrees };
9
- //# sourceMappingURL=formatter.js.map
10
24
  //# sourceMappingURL=formatter.js.map
@@ -1 +1 @@
1
- {"version":3,"sources":["../../../../src/coordinates/latlon/decimal-degrees/formatter.ts"],"names":[],"mappings":";;AAcA,MAAM,gBAAA,GAAmB,CAAC,GAAA,KAAwB;AAChD,EAAA,OAAO,CAAA,EAAG,GAAA,CAAI,OAAA,CAAQ,CAAC,CAAC,CAAA,IAAA,CAAA;AAC1B,CAAA;AAEO,MAAM,oBAAA,GAAuB,gBAAgB,gBAAgB","file":"formatter.js","sourcesContent":["/*\n * Copyright 2025 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 { createFormatter } from '../internal/format';\n\nconst toDecimalDegrees = (num: number): string => {\n return `${num.toFixed(6)}°`;\n};\n\nexport const formatDecimalDegrees = createFormatter(toDecimalDegrees);\n"]}
1
+ {"version":3,"file":"formatter.js","names":[],"sources":["../../../../src/coordinates/latlon/decimal-degrees/formatter.ts"],"sourcesContent":["/*\n * Copyright 2025 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 { createFormatter } from '../internal/format';\n\nconst toDecimalDegrees = (num: number): string => {\n return `${num.toFixed(6)}°`;\n};\n\nexport const formatDecimalDegrees = createFormatter(toDecimalDegrees);\n"],"mappings":";;;;;;;;;;;;;;;;AAcA,MAAM,oBAAoB,QAAwB;AAChD,QAAO,GAAG,IAAI,QAAQ,EAAE,CAAC;;AAG3B,MAAa,uBAAuB,gBAAgB,iBAAiB"}
@@ -1,8 +1,21 @@
1
- import { Format } from '../internal/index.js';
2
- import { ParseResults } from '../internal/parse.js';
3
- import '../internal/lexer.js';
1
+ /*
2
+ * Copyright 2025 Hypergiant Galactic Systems Inc. All rights reserved.
3
+ * This file is licensed to you under the Apache License, Version 2.0 (the "License");
4
+ * you may not use this file except in compliance with the License. You may obtain a copy
5
+ * of the License at https://www.apache.org/licenses/LICENSE-2.0
6
+ *
7
+ * Unless required by applicable law or agreed to in writing, software distributed under
8
+ * the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS
9
+ * OF ANY KIND, either express or implied. See the License for the specific language
10
+ * governing permissions and limitations under the License.
11
+ */
4
12
 
13
+ import { Format } from "../internal/index.js";
14
+ import { ParseResults } from "../internal/parse.js";
15
+
16
+ //#region src/coordinates/latlon/decimal-degrees/parser.d.ts
5
17
  /** Parse a Decimal Degrees coordinate. */
6
18
  declare const parseDecimalDegrees: (format: Format, input: string) => ParseResults;
7
-
19
+ //#endregion
8
20
  export { parseDecimalDegrees };
21
+ //# sourceMappingURL=parser.d.ts.map
@@ -1,76 +1,74 @@
1
- import * as Patterning from './../../../patterning.js';
2
- import { PARTIAL_PATTERNS, SYMBOLS, SYMBOL_PATTERNS, BEARINGS, LIMITS } from '../internal/index.js';
3
- import { createParser } from '../internal/parse-format.js';
1
+ /*
2
+ * Copyright 2025 Hypergiant Galactic Systems Inc. All rights reserved.
3
+ * This file is licensed to you under the Apache License, Version 2.0 (the "License");
4
+ * you may not use this file except in compliance with the License. You may obtain a copy
5
+ * of the License at https://www.apache.org/licenses/LICENSE-2.0
6
+ *
7
+ * Unless required by applicable law or agreed to in writing, software distributed under
8
+ * the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS
9
+ * OF ANY KIND, either express or implied. See the License for the specific language
10
+ * governing permissions and limitations under the License.
11
+ */
4
12
 
13
+
14
+ import { fromTemplate } from "../../../patterning.js";
15
+ import { BEARINGS, LIMITS, PARTIAL_PATTERNS, SYMBOLS, SYMBOL_PATTERNS } from "../internal/index.js";
16
+ import { createParser } from "../internal/parse-format.js";
17
+
18
+ //#region src/coordinates/latlon/decimal-degrees/parser.ts
5
19
  const checks = {
6
- deg: (deg, limit) => {
7
- if (Number.parseFloat(deg) > limit) {
8
- return `Degrees value (${deg}) exceeds max value (${limit}).`;
9
- }
10
- },
11
- min: (val) => {
12
- if (val.includes(SYMBOLS.MINUTES)) {
13
- return `Seconds indicator (${SYMBOLS.MINUTES}) not valid in Decimal Degrees.`;
14
- }
15
- },
16
- sec: (val) => {
17
- if (val.includes(SYMBOLS.SECONDS)) {
18
- return `Seconds indicator (${SYMBOLS.SECONDS}) not valid in Decimal Degrees.`;
19
- }
20
- }
20
+ deg: (deg, limit) => {
21
+ if (Number.parseFloat(deg) > limit) return `Degrees value (${deg}) exceeds max value (${limit}).`;
22
+ },
23
+ min: (val) => {
24
+ if (val.includes(SYMBOLS.MINUTES)) return `Seconds indicator (${SYMBOLS.MINUTES}) not valid in Decimal Degrees.`;
25
+ },
26
+ sec: (val) => {
27
+ if (val.includes(SYMBOLS.SECONDS)) return `Seconds indicator (${SYMBOLS.SECONDS}) not valid in Decimal Degrees.`;
28
+ }
21
29
  };
22
30
  const formats = {
23
- LATLON: Patterning.fromTemplate(
24
- PARTIAL_PATTERNS,
25
- `degLatDec NS ${SYMBOLS.DIVIDER} degLonDec EW`
26
- ),
27
- LONLAT: Patterning.fromTemplate(
28
- PARTIAL_PATTERNS,
29
- `degLonDec EW ${SYMBOLS.DIVIDER} degLatDec NS`
30
- )
31
+ LATLON: fromTemplate(PARTIAL_PATTERNS, `degLatDec NS ${SYMBOLS.DIVIDER} degLonDec EW`),
32
+ LONLAT: fromTemplate(PARTIAL_PATTERNS, `degLonDec EW ${SYMBOLS.DIVIDER} degLatDec NS`)
31
33
  };
32
34
  function identifyErrors(format) {
33
- return (arg, i) => {
34
- if (!arg) {
35
- return [[], ["Invalid coordinate value."]];
36
- }
37
- let { bear, deg } = arg;
38
- deg ??= "0";
39
- let isNegative = SYMBOL_PATTERNS.NEGATIVE_SIGN.test(deg) ? 1 : 0;
40
- const bearingOptions = BEARINGS[format][i];
41
- if (!bear || isNegative) {
42
- bear = bearingOptions[isNegative];
43
- deg = Math.abs(Number.parseFloat(deg)).toString();
44
- isNegative = 0;
45
- }
46
- const errors = [
47
- ...[checks.deg(deg, LIMITS[format][i] ?? 0)],
48
- ...[checks.min([bear, deg].join(""))],
49
- ...[checks.sec([bear, deg].join(""))]
50
- ].filter(Boolean);
51
- return errors.length ? [[], errors] : [[deg, bear], []];
52
- };
35
+ return (arg, i) => {
36
+ if (!arg) return [[], ["Invalid coordinate value."]];
37
+ let { bear, deg } = arg;
38
+ deg ??= "0";
39
+ let isNegative = SYMBOL_PATTERNS.NEGATIVE_SIGN.test(deg) ? 1 : 0;
40
+ const bearingOptions = BEARINGS[format][i];
41
+ if (!bear || isNegative) {
42
+ bear = bearingOptions[isNegative];
43
+ deg = Math.abs(Number.parseFloat(deg)).toString();
44
+ isNegative = 0;
45
+ }
46
+ const errors = [
47
+ ...[checks.deg(deg, LIMITS[format][i] ?? 0)],
48
+ ...[checks.min([bear, deg].join(""))],
49
+ ...[checks.sec([bear, deg].join(""))]
50
+ ].filter(Boolean);
51
+ return errors.length ? [[], errors] : [[deg, bear], []];
52
+ };
53
53
  }
54
54
  function identifyPieces(half) {
55
- if (half.length > 2 || half.length < 1) {
56
- return;
57
- }
58
- const places = { bear: "", deg: "" };
59
- return half.reduce((acc, token) => {
60
- if (SYMBOL_PATTERNS.NSEW.test(token) && !acc.bear) {
61
- acc.bear ||= token;
62
- } else {
63
- acc.deg ||= token;
64
- }
65
- return acc;
66
- }, places);
55
+ if (half.length > 2 || half.length < 1) return;
56
+ return half.reduce((acc, token) => {
57
+ if (SYMBOL_PATTERNS.NSEW.test(token) && !acc.bear) acc.bear ||= token;
58
+ else acc.deg ||= token;
59
+ return acc;
60
+ }, {
61
+ bear: "",
62
+ deg: ""
63
+ });
67
64
  }
65
+ /** Parse a Decimal Degrees coordinate. */
68
66
  const parseDecimalDegrees = createParser({
69
- formats,
70
- identifyErrors,
71
- identifyPieces
67
+ formats,
68
+ identifyErrors,
69
+ identifyPieces
72
70
  });
73
71
 
72
+ //#endregion
74
73
  export { parseDecimalDegrees };
75
- //# sourceMappingURL=parser.js.map
76
74
  //# sourceMappingURL=parser.js.map