@accelint/geo 0.4.0 → 0.4.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.
Files changed (109) hide show
  1. package/CHANGELOG.md +5 -0
  2. package/catalog-info.yaml +1 -1
  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 +48 -14
  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
@@ -1,84 +1,95 @@
1
- import * as Patterning from './../../../patterning.js';
2
- import { PARTIAL_PATTERNS, SYMBOLS, SYMBOL_PATTERNS, BEARINGS, LIMITS } from '../internal/index.js';
3
- import { inRange } from '../internal/in-range.js';
4
- 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
+ */
5
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
+ import { inRange } from "../internal/in-range.js";
18
+
19
+ //#region src/coordinates/latlon/degrees-minutes-seconds/parser.ts
6
20
  const checks = {
7
- deg: (deg, limit) => {
8
- if (Number.parseFloat(deg) > limit) {
9
- return `Degrees value (${deg}) exceeds max value (${limit}).`;
10
- }
11
- if (/\./.test(deg)) {
12
- return `Degrees value (${deg}) must not include decimal value.`;
13
- }
14
- },
15
- min: (min) => inRange("Minutes", min, 59),
16
- sec: (sec) => inRange("Seconds", sec, 59.999999999)
21
+ deg: (deg, limit) => {
22
+ if (Number.parseFloat(deg) > limit) return `Degrees value (${deg}) exceeds max value (${limit}).`;
23
+ if (/\./.test(deg)) return `Degrees value (${deg}) must not include decimal value.`;
24
+ },
25
+ min: (min) => inRange("Minutes", min, 59),
26
+ sec: (sec) => inRange("Seconds", sec, 59.999999999)
17
27
  };
18
28
  const formats = {
19
- LATLON: Patterning.fromTemplate(
20
- PARTIAL_PATTERNS,
21
- `degLat min secDec NS ${SYMBOLS.DIVIDER} degLon min secDec EW`
22
- ),
23
- LONLAT: Patterning.fromTemplate(
24
- PARTIAL_PATTERNS,
25
- `degLon min secDec EW ${SYMBOLS.DIVIDER} degLat min secDec NS`
26
- )
29
+ LATLON: fromTemplate(PARTIAL_PATTERNS, `degLat min secDec NS ${SYMBOLS.DIVIDER} degLon min secDec EW`),
30
+ LONLAT: fromTemplate(PARTIAL_PATTERNS, `degLon min secDec EW ${SYMBOLS.DIVIDER} degLat min secDec NS`)
27
31
  };
28
32
  function identifyErrors(format) {
29
- return (arg, i) => {
30
- if (!arg) {
31
- return [[], ["Invalid coordinate value."]];
32
- }
33
- let { bear, deg, min, sec } = arg;
34
- deg ??= "0";
35
- min ||= "0";
36
- sec ||= "0";
37
- let isNegative = SYMBOL_PATTERNS.NEGATIVE_SIGN.test(deg) ? 1 : 0;
38
- const bearingOptions = BEARINGS[format][i];
39
- if (!bear || isNegative) {
40
- bear = bearingOptions[isNegative];
41
- deg = Math.abs(Number.parseFloat(deg)).toString();
42
- isNegative = 0;
43
- }
44
- const errors = [
45
- ...[checks.deg(deg, LIMITS[format][i] ?? 0)],
46
- ...[checks.min(min)],
47
- ...[checks.sec(sec)]
48
- ].filter(Boolean);
49
- return errors.length ? [[], errors] : [[deg, min, sec, bear], []];
50
- };
33
+ return (arg, i) => {
34
+ if (!arg) return [[], ["Invalid coordinate value."]];
35
+ let { bear, deg, min, sec } = arg;
36
+ deg ??= "0";
37
+ min ||= "0";
38
+ sec ||= "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(min)],
49
+ ...[checks.sec(sec)]
50
+ ].filter(Boolean);
51
+ return errors.length ? [[], errors] : [[
52
+ deg,
53
+ min,
54
+ sec,
55
+ bear
56
+ ], []];
57
+ };
51
58
  }
52
59
  function identifyPieces(half) {
53
- if (half.length < 1 || half.length > 4) {
54
- return;
55
- }
56
- const asString = half.join(" ");
57
- const places = { bear: "", deg: "", min: "", sec: "" };
58
- const keys = ["deg", "min", "sec"];
59
- const test = (r, b, v) => r.test(v) || r.test(asString) && b;
60
- return half.reduce((acc, token, i, { length }) => {
61
- if (test(SYMBOL_PATTERNS.NSEW, i === length - 1, token)) {
62
- acc.bear ||= token;
63
- } else if (test(SYMBOL_PATTERNS.DEGREES, i === 0, token)) {
64
- acc.deg ||= token;
65
- } else if (test(SYMBOL_PATTERNS.MINUTES, i === 1, token)) {
66
- acc.min ||= token;
67
- } else if (test(SYMBOL_PATTERNS.SECONDS, i === 2, token)) {
68
- acc.sec ||= token;
69
- } else {
70
- const key = keys.find((k) => !acc[k]);
71
- acc[key] = token;
72
- }
73
- return acc;
74
- }, places);
60
+ if (half.length < 1 || half.length > 4) return;
61
+ const asString = half.join(" ");
62
+ const places = {
63
+ bear: "",
64
+ deg: "",
65
+ min: "",
66
+ sec: ""
67
+ };
68
+ const keys = [
69
+ "deg",
70
+ "min",
71
+ "sec"
72
+ ];
73
+ const test = (r, b, v) => r.test(v) || r.test(asString) && b;
74
+ return half.reduce((acc, token, i, { length }) => {
75
+ if (test(SYMBOL_PATTERNS.NSEW, i === length - 1, token)) acc.bear ||= token;
76
+ else if (test(SYMBOL_PATTERNS.DEGREES, i === 0, token)) acc.deg ||= token;
77
+ else if (test(SYMBOL_PATTERNS.MINUTES, i === 1, token)) acc.min ||= token;
78
+ else if (test(SYMBOL_PATTERNS.SECONDS, i === 2, token)) acc.sec ||= token;
79
+ else {
80
+ const key = keys.find((k) => !acc[k]);
81
+ acc[key] = token;
82
+ }
83
+ return acc;
84
+ }, places);
75
85
  }
86
+ /** Parse a Degrees Minutes Seconds coordinate. */
76
87
  const parseDegreesMinutesSeconds = createParser({
77
- formats,
78
- identifyErrors,
79
- identifyPieces
88
+ formats,
89
+ identifyErrors,
90
+ identifyPieces
80
91
  });
81
92
 
93
+ //#endregion
82
94
  export { parseDegreesMinutesSeconds };
83
- //# sourceMappingURL=parser.js.map
84
95
  //# sourceMappingURL=parser.js.map
@@ -1 +1 @@
1
- {"version":3,"sources":["../../../../src/coordinates/latlon/degrees-minutes-seconds/parser.ts"],"names":[],"mappings":";;;;;AAgCA,MAAM,MAAA,GAAS;AAAA,EACb,GAAA,EAAK,CAAC,GAAA,EAAa,KAAA,KAAkB;AACnC,IAAA,IAAI,MAAA,CAAO,UAAA,CAAW,GAAG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AAA,CAAE,IAAA,CAAK,QAAQ,CAAA,IAAK,CAAA;AAEpC,EAAA,OAAO,IAAA,CAAK,OAAO,CAAC,GAAA,EAAK,OAAO,CAAA,EAAG,EAAE,QAAO,KAAM;AAChD,IAAA,IAAI,KAAK,eAAA,CAAgB,IAAA,EAAM,MAAM,MAAA,GAAS,CAAA,EAAG,KAAK,CAAA,EAAG;AACvD,MAAA,GAAA,CAAI,IAAA,KAAS,KAAA;AAAA,IACf,WAAW,IAAA,CAAK,eAAA,CAAgB,SAAS,CAAA,KAAM,CAAA,EAAG,KAAK,CAAA,EAAG;AACxD,MAAA,GAAA,CAAI,GAAA,KAAQ,KAAA;AAAA,IACd,WAAW,IAAA,CAAK,eAAA,CAAgB,SAAS,CAAA,KAAM,CAAA,EAAG,KAAK,CAAA,EAAG;AACxD,MAAA,GAAA,CAAI,GAAA,KAAQ,KAAA;AAAA,IACd,WAAW,IAAA,CAAK,eAAA,CAAgB,SAAS,CAAA,KAAM,CAAA,EAAG,KAAK,CAAA,EAAG;AACxD,MAAA,GAAA,CAAI,GAAA,KAAQ,KAAA;AAAA,IACd,CAAA,MAAO;AACL,MAAA,MAAM,GAAA,GAAM,KAAK,IAAA,CAAK,CAAC,MAAM,CAAC,GAAA,CAAI,CAAC,CAAC,CAAA;AAEpC,MAAA,GAAA,CAAI,GAAuB,CAAA,GAAI,KAAA;AAAA,IACjC;AAEA,IAAA,OAAO,GAAA;AAAA,EACT,GAAG,MAAM,CAAA;AACX;AAGO,MAAM,6BAA6B,YAAA,CAAoC;AAAA,EAC5E,OAAA;AAAA,EACA,cAAA;AAAA,EACA;AACF,CAAC","file":"parser.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 * as Patterning from '@/patterning';\nimport {\n BEARINGS,\n type Format,\n LIMITS,\n PARTIAL_PATTERNS,\n SYMBOL_PATTERNS,\n SYMBOLS,\n} from '../internal';\nimport { inRange } from '../internal/in-range';\nimport { createParser } from '../internal/parse-format';\nimport type { ParseResults } from '../internal/parse';\n\ntype DegreesMinutesSeconds = {\n bear: string;\n deg: string;\n min: string;\n sec: string;\n};\n\nconst checks = {\n deg: (deg: string, limit: number) => {\n if (Number.parseFloat(deg) > limit) {\n return `Degrees value (${deg}) exceeds max value (${limit}).`;\n }\n\n if (/\\./.test(deg)) {\n return `Degrees value (${deg}) must not include decimal value.`;\n }\n },\n min: (min: string) => inRange('Minutes', min, 59),\n sec: (sec: string) => inRange('Seconds', sec, 59.999999999),\n};\n\nconst formats = {\n LATLON: Patterning.fromTemplate(\n PARTIAL_PATTERNS,\n `degLat min secDec NS ${SYMBOLS.DIVIDER} degLon min secDec EW`,\n ),\n LONLAT: Patterning.fromTemplate(\n PARTIAL_PATTERNS,\n `degLon min secDec EW ${SYMBOLS.DIVIDER} degLat min secDec NS`,\n ),\n};\n\nfunction identifyErrors(format: Format) {\n return (arg: DegreesMinutesSeconds | undefined, i: number) => {\n if (!arg) {\n return [[], ['Invalid coordinate value.']] as ParseResults;\n }\n\n let { bear, deg, min, sec } = arg;\n\n deg ??= '0';\n // NOTE: need `||=` not `??=` because empty-string is not nullish\n min ||= '0';\n sec ||= '0';\n\n let isNegative: 0 | 1 = SYMBOL_PATTERNS.NEGATIVE_SIGN.test(deg) ? 1 : 0;\n const bearingOptions = BEARINGS[format][i] as [string, string];\n\n if (!bear || isNegative) {\n bear = bearingOptions[isNegative];\n deg = Math.abs(Number.parseFloat(deg)).toString();\n isNegative = 0;\n }\n\n const errors = [\n ...[checks.deg(deg, LIMITS[format][i] ?? 0)],\n ...[checks.min(min)],\n ...[checks.sec(sec)],\n ].filter(Boolean);\n\n return (\n errors.length ? [[], errors] : [[deg, min, sec, bear], []]\n ) as ParseResults;\n };\n}\n\nfunction identifyPieces(half: string[]) {\n if (half.length < 1 || half.length > 4) {\n return;\n }\n\n const asString = half.join(' ');\n const places = { bear: '', deg: '', min: '', sec: '' };\n const keys = ['deg', 'min', 'sec'] as (keyof typeof places)[];\n const test = (r: RegExp, b: boolean, v: string) =>\n r.test(v) || (r.test(asString) && b);\n\n return half.reduce((acc, token, i, { length }) => {\n if (test(SYMBOL_PATTERNS.NSEW, i === length - 1, token)) {\n acc.bear ||= token;\n } else if (test(SYMBOL_PATTERNS.DEGREES, i === 0, token)) {\n acc.deg ||= token;\n } else if (test(SYMBOL_PATTERNS.MINUTES, i === 1, token)) {\n acc.min ||= token;\n } else if (test(SYMBOL_PATTERNS.SECONDS, i === 2, token)) {\n acc.sec ||= token;\n } else {\n const key = keys.find((k) => !acc[k]);\n\n acc[key as keyof typeof acc] = token;\n }\n\n return acc;\n }, places);\n}\n\n/** Parse a Degrees Minutes Seconds coordinate. */\nexport const parseDegreesMinutesSeconds = createParser<DegreesMinutesSeconds>({\n formats,\n identifyErrors,\n identifyPieces,\n});\n"]}
1
+ {"version":3,"file":"parser.js","names":["Patterning.fromTemplate","isNegative: 0 | 1"],"sources":["../../../../src/coordinates/latlon/degrees-minutes-seconds/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 * as Patterning from '@/patterning';\nimport {\n BEARINGS,\n type Format,\n LIMITS,\n PARTIAL_PATTERNS,\n SYMBOL_PATTERNS,\n SYMBOLS,\n} from '../internal';\nimport { inRange } from '../internal/in-range';\nimport { createParser } from '../internal/parse-format';\nimport type { ParseResults } from '../internal/parse';\n\ntype DegreesMinutesSeconds = {\n bear: string;\n deg: string;\n min: string;\n sec: string;\n};\n\nconst checks = {\n deg: (deg: string, limit: number) => {\n if (Number.parseFloat(deg) > limit) {\n return `Degrees value (${deg}) exceeds max value (${limit}).`;\n }\n\n if (/\\./.test(deg)) {\n return `Degrees value (${deg}) must not include decimal value.`;\n }\n },\n min: (min: string) => inRange('Minutes', min, 59),\n sec: (sec: string) => inRange('Seconds', sec, 59.999999999),\n};\n\nconst formats = {\n LATLON: Patterning.fromTemplate(\n PARTIAL_PATTERNS,\n `degLat min secDec NS ${SYMBOLS.DIVIDER} degLon min secDec EW`,\n ),\n LONLAT: Patterning.fromTemplate(\n PARTIAL_PATTERNS,\n `degLon min secDec EW ${SYMBOLS.DIVIDER} degLat min secDec NS`,\n ),\n};\n\nfunction identifyErrors(format: Format) {\n return (arg: DegreesMinutesSeconds | undefined, i: number) => {\n if (!arg) {\n return [[], ['Invalid coordinate value.']] as ParseResults;\n }\n\n let { bear, deg, min, sec } = arg;\n\n deg ??= '0';\n // NOTE: need `||=` not `??=` because empty-string is not nullish\n min ||= '0';\n sec ||= '0';\n\n let isNegative: 0 | 1 = SYMBOL_PATTERNS.NEGATIVE_SIGN.test(deg) ? 1 : 0;\n const bearingOptions = BEARINGS[format][i] as [string, string];\n\n if (!bear || isNegative) {\n bear = bearingOptions[isNegative];\n deg = Math.abs(Number.parseFloat(deg)).toString();\n isNegative = 0;\n }\n\n const errors = [\n ...[checks.deg(deg, LIMITS[format][i] ?? 0)],\n ...[checks.min(min)],\n ...[checks.sec(sec)],\n ].filter(Boolean);\n\n return (\n errors.length ? [[], errors] : [[deg, min, sec, bear], []]\n ) as ParseResults;\n };\n}\n\nfunction identifyPieces(half: string[]) {\n if (half.length < 1 || half.length > 4) {\n return;\n }\n\n const asString = half.join(' ');\n const places = { bear: '', deg: '', min: '', sec: '' };\n const keys = ['deg', 'min', 'sec'] as (keyof typeof places)[];\n const test = (r: RegExp, b: boolean, v: string) =>\n r.test(v) || (r.test(asString) && b);\n\n return half.reduce((acc, token, i, { length }) => {\n if (test(SYMBOL_PATTERNS.NSEW, i === length - 1, token)) {\n acc.bear ||= token;\n } else if (test(SYMBOL_PATTERNS.DEGREES, i === 0, token)) {\n acc.deg ||= token;\n } else if (test(SYMBOL_PATTERNS.MINUTES, i === 1, token)) {\n acc.min ||= token;\n } else if (test(SYMBOL_PATTERNS.SECONDS, i === 2, token)) {\n acc.sec ||= token;\n } else {\n const key = keys.find((k) => !acc[k]);\n\n acc[key as keyof typeof acc] = token;\n }\n\n return acc;\n }, places);\n}\n\n/** Parse a Degrees Minutes Seconds coordinate. */\nexport const parseDegreesMinutesSeconds = createParser<DegreesMinutesSeconds>({\n formats,\n identifyErrors,\n identifyPieces,\n});\n"],"mappings":";;;;;;;;;;;;;;;;;;;AAgCA,MAAM,SAAS;CACb,MAAM,KAAa,UAAkB;AACnC,MAAI,OAAO,WAAW,IAAI,GAAG,MAC3B,QAAO,kBAAkB,IAAI,uBAAuB,MAAM;AAG5D,MAAI,KAAK,KAAK,IAAI,CAChB,QAAO,kBAAkB,IAAI;;CAGjC,MAAM,QAAgB,QAAQ,WAAW,KAAK,GAAG;CACjD,MAAM,QAAgB,QAAQ,WAAW,KAAK,aAAa;CAC5D;AAED,MAAM,UAAU;CACd,QAAQA,aACN,kBACA,wBAAwB,QAAQ,QAAQ,uBACzC;CACD,QAAQA,aACN,kBACA,wBAAwB,QAAQ,QAAQ,uBACzC;CACF;AAED,SAAS,eAAe,QAAgB;AACtC,SAAQ,KAAwC,MAAc;AAC5D,MAAI,CAAC,IACH,QAAO,CAAC,EAAE,EAAE,CAAC,4BAA4B,CAAC;EAG5C,IAAI,EAAE,MAAM,KAAK,KAAK,QAAQ;AAE9B,UAAQ;AAER,UAAQ;A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,OAA2B;;AAGjC,SAAO;IACN,OAAO;;;AAIZ,MAAa,6BAA6B,aAAoC;CAC5E;CACA;CACA;CACD,CAAC"}
@@ -1,8 +1,19 @@
1
- import { CoordinateSystem } from '../internal/coordinate-system.js';
2
- import '../internal/index.js';
3
- import '../internal/parse.js';
4
- 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
+ */
5
12
 
6
- declare const systemDegreesMinutesSeconds: CoordinateSystem;
13
+ import { CoordinateSystem } from "../internal/coordinate-system.js";
7
14
 
15
+ //#region src/coordinates/latlon/degrees-minutes-seconds/system.d.ts
16
+ declare const systemDegreesMinutesSeconds: CoordinateSystem;
17
+ //#endregion
8
18
  export { systemDegreesMinutesSeconds };
19
+ //# sourceMappingURL=system.d.ts.map
@@ -1,27 +1,38 @@
1
- import { BEARINGS, SYMBOLS, SYMBOL_PATTERNS } from '../internal/index.js';
2
- import { parseDegreesMinutesSeconds } from './parser.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
+ */
3
12
 
13
+
14
+ import { BEARINGS, SYMBOLS, SYMBOL_PATTERNS } from "../internal/index.js";
15
+ import { parseDegreesMinutesSeconds } from "./parser.js";
16
+
17
+ //#region src/coordinates/latlon/degrees-minutes-seconds/system.ts
4
18
  const systemDegreesMinutesSeconds = {
5
- name: "Degrees Minutes Seconds",
6
- parse: parseDegreesMinutesSeconds,
7
- toFloat(arg) {
8
- const [degrees, minutes, seconds, bear] = arg;
9
- return Number.parseFloat(
10
- ((Number.parseFloat(degrees) + Number.parseFloat(minutes) / 60 + Number.parseFloat(seconds) / 3600) * (SYMBOL_PATTERNS.NEGATIVE_BEARINGS.test(bear) ? -1 : 1)).toFixed(9)
11
- );
12
- },
13
- toFormat(format, [left, right]) {
14
- return [left, right].map((num, index) => {
15
- const abs = Math.abs(num);
16
- const deg = Math.floor(abs);
17
- const rem = (abs - deg) * 60;
18
- const min = Math.floor(rem);
19
- const sec = Number.parseFloat(((rem - min) * 60).toFixed(9));
20
- return `${deg} ${min} ${sec} ${BEARINGS[format][index][+(num < 0)]}`;
21
- }).join(` ${SYMBOLS.DIVIDER} `);
22
- }
19
+ name: "Degrees Minutes Seconds",
20
+ parse: parseDegreesMinutesSeconds,
21
+ toFloat(arg) {
22
+ const [degrees, minutes, seconds, bear] = arg;
23
+ return Number.parseFloat(((Number.parseFloat(degrees) + Number.parseFloat(minutes) / 60 + Number.parseFloat(seconds) / 3600) * (SYMBOL_PATTERNS.NEGATIVE_BEARINGS.test(bear) ? -1 : 1)).toFixed(9));
24
+ },
25
+ toFormat(format, [left, right]) {
26
+ return [left, right].map((num, index) => {
27
+ const abs = Math.abs(num);
28
+ const deg = Math.floor(abs);
29
+ const rem = (abs - deg) * 60;
30
+ const min = Math.floor(rem);
31
+ return `${deg} ${min} ${Number.parseFloat(((rem - min) * 60).toFixed(9))} ${BEARINGS[format][index][+(num < 0)]}`;
32
+ }).join(` ${SYMBOLS.DIVIDER} `);
33
+ }
23
34
  };
24
35
 
36
+ //#endregion
25
37
  export { systemDegreesMinutesSeconds };
26
- //# sourceMappingURL=system.js.map
27
38
  //# sourceMappingURL=system.js.map
@@ -1 +1 @@
1
- {"version":3,"sources":["../../../../src/coordinates/latlon/degrees-minutes-seconds/system.ts"],"names":[],"mappings":";;;AAuBO,MAAM,2BAAA,GAAgD;AAAA,EAC3D,IAAA,EAAM,yBAAA;AAAA,EAEN,KAAA,EAAO,0BAAA;AAAA,EAEP,QAAQ,GAAA,EAAK;AACX,IAAA,MAAM,CAAC,OAAA,EAAS,OAAA,EAAS,OAAA,EAAS,IAAI,CAAA,GAAI,GAAA;AAO1C,IAAA,OAAO,MAAA,CAAO,UAAA;AAAA,MAAA,CAAA,CAET,MAAA,CAAO,WAAW,OAAO,CAAA,GACxB,OAAO,UAAA,CAAW,OAAO,CAAA,GAAI,EAAA,GAC7B,MAAA,CAAO,UAAA,CAAW,OAAO,CAAA,GAAI,IAAA,KAC9B,gBAAgB,iBAAA,CAAkB,IAAA,CAAK,IAAI,CAAA,GAAI,EAAA,GAAK,CAAA,CAAA,EACrD,OAAA,CAAQ,CAAC;AAAA,KACb;AAAA,EACF,CAAA;AAAA,EAEA,QAAA,CAAS,MAAA,EAAgB,CAAC,IAAA,EAAM,KAAK,CAAA,EAAqB;AACxD,IAAA,OAAO,CAAC,IAAA,EAAM,KAAK,EAChB,GAAA,CAAI,CAAC,KAAK,KAAA,KAAU;AACnB,MAAA,MAAM,GAAA,GAAM,IAAA,CAAK,GAAA,CAAI,GAAG,CAAA;AACxB,MAAA,MAAM,GAAA,GAAM,IAAA,CAAK,KAAA,CAAM,GAAG,CAAA;AAC1B,MAAA,MAAM,GAAA,GAAA,CAAO,MAAM,GAAA,IAAO,EAAA;AAC1B,MAAA,MAAM,GAAA,GAAM,IAAA,CAAK,KAAA,CAAM,GAAG,CAAA;AAC1B,MAAA,MAAM,GAAA,GAAM,OAAO,UAAA,CAAA,CAAA,CAAa,GAAA,GAAM,OAAO,EAAA,EAAI,OAAA,CAAQ,CAAC,CAAC,CAAA;AAE3D,MAAA,OAAO,CAAA,EAAG,GAAG,CAAA,CAAA,EAAI,GAAG,IAAI,GAAG,CAAA,CAAA,EAAI,QAAA,CAAS,MAAM,EAAE,KAAc,CAAA,CAAE,EAAE,GAAA,GAAM,EAAE,CAAC,CAAA,CAAA;AAAA,IAC7E,CAAC,CAAA,CACA,IAAA,CAAK,CAAA,CAAA,EAAI,OAAA,CAAQ,OAAO,CAAA,CAAA,CAAG,CAAA;AAAA,EAChC;AACF","file":"system.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\nimport {\n BEARINGS,\n type Compass,\n type Format,\n SYMBOL_PATTERNS,\n SYMBOLS,\n} from '../internal';\nimport { parseDegreesMinutesSeconds } from './parser';\nimport type { CoordinateSystem } from '../internal/coordinate-system';\n\nexport const systemDegreesMinutesSeconds: CoordinateSystem = {\n name: 'Degrees Minutes Seconds',\n\n parse: parseDegreesMinutesSeconds,\n\n toFloat(arg) {\n const [degrees, minutes, seconds, bear] = arg as [\n string,\n string,\n string,\n Compass,\n ];\n\n return Number.parseFloat(\n (\n (Number.parseFloat(degrees) +\n Number.parseFloat(minutes) / 60 +\n Number.parseFloat(seconds) / 3600) *\n (SYMBOL_PATTERNS.NEGATIVE_BEARINGS.test(bear) ? -1 : 1)\n ).toFixed(9),\n );\n },\n\n toFormat(format: Format, [left, right]: [number, number]) {\n return [left, right]\n .map((num, index) => {\n const abs = Math.abs(num);\n const deg = Math.floor(abs);\n const rem = (abs - deg) * 60;\n const min = Math.floor(rem);\n const sec = Number.parseFloat(((rem - min) * 60).toFixed(9));\n\n return `${deg} ${min} ${sec} ${BEARINGS[format][index as 0 | 1][+(num < 0)]}`;\n })\n .join(` ${SYMBOLS.DIVIDER} `);\n },\n};\n"]}
1
+ {"version":3,"file":"system.js","names":["systemDegreesMinutesSeconds: CoordinateSystem"],"sources":["../../../../src/coordinates/latlon/degrees-minutes-seconds/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 {\n BEARINGS,\n type Compass,\n type Format,\n SYMBOL_PATTERNS,\n SYMBOLS,\n} from '../internal';\nimport { parseDegreesMinutesSeconds } from './parser';\nimport type { CoordinateSystem } from '../internal/coordinate-system';\n\nexport const systemDegreesMinutesSeconds: CoordinateSystem = {\n name: 'Degrees Minutes Seconds',\n\n parse: parseDegreesMinutesSeconds,\n\n toFloat(arg) {\n const [degrees, minutes, seconds, bear] = arg as [\n string,\n string,\n string,\n Compass,\n ];\n\n return Number.parseFloat(\n (\n (Number.parseFloat(degrees) +\n Number.parseFloat(minutes) / 60 +\n Number.parseFloat(seconds) / 3600) *\n (SYMBOL_PATTERNS.NEGATIVE_BEARINGS.test(bear) ? -1 : 1)\n ).toFixed(9),\n );\n },\n\n toFormat(format: Format, [left, right]: [number, number]) {\n return [left, right]\n .map((num, index) => {\n const abs = Math.abs(num);\n const deg = Math.floor(abs);\n const rem = (abs - deg) * 60;\n const min = Math.floor(rem);\n const sec = Number.parseFloat(((rem - min) * 60).toFixed(9));\n\n return `${deg} ${min} ${sec} ${BEARINGS[format][index as 0 | 1][+(num < 0)]}`;\n })\n .join(` ${SYMBOLS.DIVIDER} `);\n },\n};\n"],"mappings":";;;;;;;;;;;;;;;;;AAuBA,MAAaA,8BAAgD;CAC3D,MAAM;CAEN,OAAO;CAEP,QAAQ,KAAK;EACX,MAAM,CAAC,SAAS,SAAS,SAAS,QAAQ;AAO1C,SAAO,OAAO,aAET,OAAO,WAAW,QAAQ,GACzB,OAAO,WAAW,QAAQ,GAAG,KAC7B,OAAO,WAAW,QAAQ,GAAG,SAC9B,gBAAgB,kBAAkB,KAAK,KAAK,GAAG,KAAK,IACrD,QAAQ,EAAE,CACb;;CAGH,SAAS,QAAgB,CAAC,MAAM,QAA0B;AACxD,SAAO,CAAC,MAAM,MAAM,CACjB,KAAK,KAAK,UAAU;GACnB,MAAM,MAAM,KAAK,IAAI,IAAI;GACzB,MAAM,MAAM,KAAK,MAAM,IAAI;GAC3B,MAAM,OAAO,MAAM,OAAO;GAC1B,MAAM,MAAM,KAAK,MAAM,IAAI;AAG3B,UAAO,GAAG,IAAI,GAAG,IAAI,GAFT,OAAO,aAAa,MAAM,OAAO,IAAI,QAAQ,EAAE,CAAC,CAEhC,GAAG,SAAS,QAAQ,OAAgB,EAAE,MAAM;IACxE,CACD,KAAK,IAAI,QAAQ,QAAQ,GAAG;;CAElC"}
@@ -1,12 +1,25 @@
1
- import { Format, Compass } from './index.js';
2
- import { ParseResults } from './parse.js';
3
- import './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 { Compass, Format } from "./index.js";
14
+ import { ParseResults } from "./parse.js";
15
+
16
+ //#region src/coordinates/latlon/internal/coordinate-system.d.ts
5
17
  type CoordinateSystem = {
6
- name: string;
7
- parse: (format: Format, input: string) => ParseResults;
8
- toFloat: (a: [string, ...string[], Compass]) => number;
9
- toFormat: (f: Format, a: [number, number]) => string;
18
+ name: string;
19
+ parse: (format: Format, input: string) => ParseResults;
20
+ toFloat: (a: [string, ...string[], Compass]) => number;
21
+ toFormat: (f: Format, a: [number, number]) => string;
10
22
  };
11
-
12
- export type { CoordinateSystem };
23
+ //#endregion
24
+ export { CoordinateSystem };
25
+ //# sourceMappingURL=coordinate-system.d.ts.map
@@ -1,3 +1,12 @@
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
+ */
1
12
 
2
- //# sourceMappingURL=coordinate-system.js.map
3
- //# sourceMappingURL=coordinate-system.js.map
@@ -1,5 +1,18 @@
1
- import { Format } from './index.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
+ import { Format } from "./index.js";
14
+
15
+ //#region src/coordinates/latlon/internal/create-cache.d.ts
3
16
  type CoordinateCache = Record<Format, string>;
4
17
  /**
5
18
  * Create, and initialize, a cache object for coordinate conversions so that
@@ -8,5 +21,6 @@ type CoordinateCache = Record<Format, string>;
8
21
  * errors when converting between multiple formats.
9
22
  * */
10
23
  declare function createCache(format: Format, value: string): CoordinateCache;
11
-
12
- export { type CoordinateCache, createCache };
24
+ //#endregion
25
+ export { CoordinateCache, createCache };
26
+ //# sourceMappingURL=create-cache.d.ts.map
@@ -1,14 +1,34 @@
1
- import { SYMBOLS, FORMATS } from '.';
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 { FORMATS, SYMBOLS } from "./index.js";
15
+
16
+ //#region src/coordinates/latlon/internal/create-cache.ts
3
17
  const DIVIDER = ` ${SYMBOLS.DIVIDER} `;
18
+ /**
19
+ * Create, and initialize, a cache object for coordinate conversions so that
20
+ * conversions are only ever done once and only "one-direction-ally". The
21
+ * "one-direction" concept is to avoid the problem of encountering rounding
22
+ * errors when converting between multiple formats.
23
+ * */
4
24
  function createCache(format, value) {
5
- const [alternate] = FORMATS.filter((o) => o !== format);
6
- return {
7
- [format]: value,
8
- [alternate]: value.includes(SYMBOLS.DIVIDER) ? value.split(DIVIDER).reverse().join(DIVIDER).trim() : value
9
- };
25
+ const [alternate] = FORMATS.filter((o) => o !== format);
26
+ return {
27
+ [format]: value,
28
+ [alternate]: value.includes(SYMBOLS.DIVIDER) ? value.split(DIVIDER).reverse().join(DIVIDER).trim() : value
29
+ };
10
30
  }
11
31
 
32
+ //#endregion
12
33
  export { createCache };
13
- //# sourceMappingURL=create-cache.js.map
14
34
  //# sourceMappingURL=create-cache.js.map
@@ -1 +1 @@
1
- {"version":3,"sources":["../../../../src/coordinates/latlon/internal/create-cache.ts"],"names":[],"mappings":";;AAiBA,MAAM,OAAA,GAAU,CAAA,CAAA,EAAI,OAAA,CAAQ,OAAO,CAAA,CAAA,CAAA;AAQ5B,SAAS,WAAA,CAAY,QAAgB,KAAA,EAAe;AACzD,EAAA,MAAM,CAAC,SAAS,CAAA,GAAI,OAAA,CAAQ,OAAO,CAAC,CAAA,KAAM,MAAM,MAAM,CAAA;AAEtD,EAAA,OAAO;AAAA,IACL,CAAC,MAAM,GAAG,KAAA;AAAA,IACV,CAAC,SAAS,GAAG,MAAM,QAAA,CAAS,OAAA,CAAQ,OAAO,CAAA,GACvC,KAAA,CAAM,KAAA,CAAM,OAAO,EAAE,OAAA,EAAQ,CAAE,KAAK,OAAO,CAAA,CAAE,MAAK,GAClD;AAAA,GACN;AACF","file":"create-cache.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\nimport { FORMATS, type Format, SYMBOLS } from '.';\n\nexport type CoordinateCache = Record<Format, string>;\n\nconst DIVIDER = ` ${SYMBOLS.DIVIDER} `;\n\n/**\n * Create, and initialize, a cache object for coordinate conversions so that\n * conversions are only ever done once and only \"one-direction-ally\". The\n * \"one-direction\" concept is to avoid the problem of encountering rounding\n * errors when converting between multiple formats.\n * */\nexport function createCache(format: Format, value: string) {\n const [alternate] = FORMATS.filter((o) => o !== format) as [Format];\n\n return {\n [format]: value,\n [alternate]: value.includes(SYMBOLS.DIVIDER)\n ? value.split(DIVIDER).reverse().join(DIVIDER).trim()\n : value,\n } as CoordinateCache;\n}\n"]}
1
+ {"version":3,"file":"create-cache.js","names":[],"sources":["../../../../src/coordinates/latlon/internal/create-cache.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 { FORMATS, type Format, SYMBOLS } from '.';\n\nexport type CoordinateCache = Record<Format, string>;\n\nconst DIVIDER = ` ${SYMBOLS.DIVIDER} `;\n\n/**\n * Create, and initialize, a cache object for coordinate conversions so that\n * conversions are only ever done once and only \"one-direction-ally\". The\n * \"one-direction\" concept is to avoid the problem of encountering rounding\n * errors when converting between multiple formats.\n * */\nexport function createCache(format: Format, value: string) {\n const [alternate] = FORMATS.filter((o) => o !== format) as [Format];\n\n return {\n [format]: value,\n [alternate]: value.includes(SYMBOLS.DIVIDER)\n ? value.split(DIVIDER).reverse().join(DIVIDER).trim()\n : value,\n } as CoordinateCache;\n}\n"],"mappings":";;;;;;;;;;;;;;;;AAiBA,MAAM,UAAU,IAAI,QAAQ,QAAQ;;;;;;;AAQpC,SAAgB,YAAY,QAAgB,OAAe;CACzD,MAAM,CAAC,aAAa,QAAQ,QAAQ,MAAM,MAAM,OAAO;AAEvD,QAAO;GACJ,SAAS;GACT,YAAY,MAAM,SAAS,QAAQ,QAAQ,GACxC,MAAM,MAAM,QAAQ,CAAC,SAAS,CAAC,KAAK,QAAQ,CAAC,MAAM,GACnD;EACL"}
@@ -1,9 +1,11 @@
1
+ //#region src/coordinates/latlon/internal/exhaustive-errors.d.ts
1
2
  /**
2
3
  * A collection of input strings each with exactly one error in a unique
3
4
  * position for each format (LATLON and LONLAT) in each system (DD, DDM, DMS).
4
5
  */
5
6
  declare const EXHAUSTIVE_ERRORS: {
6
- [k: string]: any;
7
+ [k: string]: any;
7
8
  };
8
-
9
+ //#endregion
9
10
  export { EXHAUSTIVE_ERRORS };
11
+ //# sourceMappingURL=exhaustive-errors.d.ts.map
@@ -1,71 +1,116 @@
1
- import { cartesian } from './../../../cartesian.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 { cartesian } from "../../../cartesian.js";
15
+
16
+ //#region src/coordinates/latlon/internal/exhaustive-errors.ts
3
17
  const values = {
4
- invalid: {
5
- BLAT: ["X", "random garbage"],
6
- BLON: ["X", "random garbage"],
7
- DLAT: ["91", "nope"],
8
- DDLAT: ["90.1", "nope"],
9
- DLON: ["181", "nope"],
10
- DDLON: ["180.1", "nope"],
11
- M: ["-1", "61", "nope"],
12
- MM: ["-0.1", "60.1", "nope"],
13
- SS: ["-0.1", "60.1", "nope"]
14
- },
15
- valid: {
16
- "/": "/",
17
- BLAT: "N",
18
- BLON: "E",
19
- DLAT: "89",
20
- DDLAT: "89.999999999",
21
- DLON: "179",
22
- DDLON: "179.999999999",
23
- M: "59",
24
- MM: "59.999999999",
25
- SS: "59.999999999"
26
- }
18
+ invalid: {
19
+ BLAT: ["X", "random garbage"],
20
+ BLON: ["X", "random garbage"],
21
+ DLAT: ["91", "nope"],
22
+ DDLAT: ["90.1", "nope"],
23
+ DLON: ["181", "nope"],
24
+ DDLON: ["180.1", "nope"],
25
+ M: [
26
+ "-1",
27
+ "61",
28
+ "nope"
29
+ ],
30
+ MM: [
31
+ "-0.1",
32
+ "60.1",
33
+ "nope"
34
+ ],
35
+ SS: [
36
+ "-0.1",
37
+ "60.1",
38
+ "nope"
39
+ ]
40
+ },
41
+ valid: {
42
+ "/": "/",
43
+ BLAT: "N",
44
+ BLON: "E",
45
+ DLAT: "89",
46
+ DDLAT: "89.999999999",
47
+ DLON: "179",
48
+ DDLON: "179.999999999",
49
+ M: "59",
50
+ MM: "59.999999999",
51
+ SS: "59.999999999"
52
+ }
27
53
  };
28
54
  const systems = [
29
- {
30
- designation: "DD",
31
- LAT: ["DDLAT", "BLAT DDLAT", "DDLAT BLAT"],
32
- LON: ["DDLON", "BLON DDLON", "DDLON BLON"]
33
- },
34
- {
35
- designation: "DDM",
36
- LAT: ["DLAT MM", "BLAT DLAT MM", "DLAT MM BLAT"],
37
- LON: ["DLON MM", "BLON DLON MM", "DLON MM BLON"]
38
- },
39
- {
40
- designation: "DMS",
41
- LAT: ["DLAT M SS", "BLAT DLAT M SS", "DLAT M SS BLAT"],
42
- LON: ["DLON M SS", "BLON DLON M SS", "DLON M SS BLON"]
43
- }
55
+ {
56
+ designation: "DD",
57
+ LAT: [
58
+ "DDLAT",
59
+ "BLAT DDLAT",
60
+ "DDLAT BLAT"
61
+ ],
62
+ LON: [
63
+ "DDLON",
64
+ "BLON DDLON",
65
+ "DDLON BLON"
66
+ ]
67
+ },
68
+ {
69
+ designation: "DDM",
70
+ LAT: [
71
+ "DLAT MM",
72
+ "BLAT DLAT MM",
73
+ "DLAT MM BLAT"
74
+ ],
75
+ LON: [
76
+ "DLON MM",
77
+ "BLON DLON MM",
78
+ "DLON MM BLON"
79
+ ]
80
+ },
81
+ {
82
+ designation: "DMS",
83
+ LAT: [
84
+ "DLAT M SS",
85
+ "BLAT DLAT M SS",
86
+ "DLAT M SS BLAT"
87
+ ],
88
+ LON: [
89
+ "DLON M SS",
90
+ "BLON DLON M SS",
91
+ "DLON M SS BLON"
92
+ ]
93
+ }
44
94
  ];
45
- const EXHAUSTIVE_ERRORS = Object.fromEntries(
46
- systems.map(({ designation, ...system }) => {
47
- const options = ["LAT LON", "LON LAT"].map((format) => [
48
- // create object key: 'LATLON' or 'LONLAT'
49
- format.replace(" ", ""),
50
- // cross-join each variation of LAT with each variation of LON in the system
51
- cartesian(
52
- ...format.split(" ").map((key) => system[key])
53
- ).map((pair) => pair.join(" / ")).flatMap((t) => fillTemplate(t, values))
54
- ]);
55
- return [designation, Object.fromEntries(options)];
56
- })
57
- );
58
- function fillTemplate(template, values2) {
59
- return template.split(" ").flatMap((key, i, original) => {
60
- if (!values2.invalid[key]) {
61
- return "";
62
- }
63
- return values2.invalid[key].map(
64
- (opt) => [...original.slice(0, i), opt, ...original.slice(i + 1)].map((token) => token in values2.valid ? values2.valid[token] : token).join(" ")
65
- );
66
- }).filter(Boolean);
95
+ /**
96
+ * A collection of input strings each with exactly one error in a unique
97
+ * position for each format (LATLON and LONLAT) in each system (DD, DDM, DMS).
98
+ */
99
+ const EXHAUSTIVE_ERRORS = Object.fromEntries(systems.map(({ designation, ...system }) => {
100
+ const options = ["LAT LON", "LON LAT"].map((format) => [format.replace(" ", ""), cartesian(...format.split(" ").map((key) => system[key])).map((pair) => pair.join(" / ")).flatMap((t) => fillTemplate(t, values))]);
101
+ return [designation, Object.fromEntries(options)];
102
+ }));
103
+ function fillTemplate(template, values$1) {
104
+ return template.split(" ").flatMap((key, i, original) => {
105
+ if (!values$1.invalid[key]) return "";
106
+ return values$1.invalid[key].map((opt) => [
107
+ ...original.slice(0, i),
108
+ opt,
109
+ ...original.slice(i + 1)
110
+ ].map((token) => token in values$1.valid ? values$1.valid[token] : token).join(" "));
111
+ }).filter(Boolean);
67
112
  }
68
113
 
114
+ //#endregion
69
115
  export { EXHAUSTIVE_ERRORS };
70
- //# sourceMappingURL=exhaustive-errors.js.map
71
116
  //# sourceMappingURL=exhaustive-errors.js.map