@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
@@ -1,10 +1,22 @@
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/coordinates/latlon/internal/ordinal.ts
1
15
  const getOrdinal = (num, isLatitude) => {
2
- if (isLatitude) {
3
- return num >= 0 ? "N" : "S";
4
- }
5
- return num >= 0 ? "E" : "W";
16
+ if (isLatitude) return num >= 0 ? "N" : "S";
17
+ return num >= 0 ? "E" : "W";
6
18
  };
7
19
 
20
+ //#endregion
8
21
  export { getOrdinal };
9
- //# sourceMappingURL=ordinal.js.map
10
22
  //# sourceMappingURL=ordinal.js.map
@@ -1 +1 @@
1
- {"version":3,"sources":["../../../../src/coordinates/latlon/internal/ordinal.ts"],"names":[],"mappings":"AAcO,MAAM,UAAA,GAAa,CAAC,GAAA,EAAa,UAAA,KAAgC;AACtE,EAAA,IAAI,UAAA,EAAY;AACd,IAAA,OAAO,GAAA,IAAO,IAAI,GAAA,GAAM,GAAA;AAAA,EAC1B;AACA,EAAA,OAAO,GAAA,IAAO,IAAI,GAAA,GAAM,GAAA;AAC1B","file":"ordinal.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\n// __private-exports\n\nexport const getOrdinal = (num: number, isLatitude: boolean): string => {\n if (isLatitude) {\n return num >= 0 ? 'N' : 'S';\n }\n return num >= 0 ? 'E' : 'W';\n};\n"]}
1
+ {"version":3,"file":"ordinal.js","names":[],"sources":["../../../../src/coordinates/latlon/internal/ordinal.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\n// __private-exports\n\nexport const getOrdinal = (num: number, isLatitude: boolean): string => {\n if (isLatitude) {\n return num >= 0 ? 'N' : 'S';\n }\n return num >= 0 ? 'E' : 'W';\n};\n"],"mappings":";;;;;;;;;;;;;;AAcA,MAAa,cAAc,KAAa,eAAgC;AACtE,KAAI,WACF,QAAO,OAAO,IAAI,MAAM;AAE1B,QAAO,OAAO,IAAI,MAAM"}
@@ -1,15 +1,28 @@
1
- import { Format } 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 { Format } from "./index.js";
14
+ import { ParseResults } from "./parse.js";
15
+
16
+ //#region src/coordinates/latlon/internal/parse-format.d.ts
5
17
  type FormatParserConfig<T> = {
6
- formats: {
7
- LATLON: RegExp;
8
- LONLAT: RegExp;
9
- };
10
- identifyErrors: (format: Format) => (arg: T, i: number) => ParseResults;
11
- identifyPieces: (half: string[]) => T;
18
+ formats: {
19
+ LATLON: RegExp;
20
+ LONLAT: RegExp;
21
+ };
22
+ identifyErrors: (format: Format) => (arg: T, i: number) => ParseResults;
23
+ identifyPieces: (half: string[]) => T;
12
24
  };
13
25
  declare const createParser: <T>(config: FormatParserConfig<T | undefined>) => (format: Format, input: string) => ParseResults;
14
-
26
+ //#endregion
15
27
  export { createParser };
28
+ //# sourceMappingURL=parse-format.d.ts.map
@@ -1,62 +1,45 @@
1
- import { SYMBOL_PATTERNS, SYMBOLS } from '.';
2
- import { parse } from './parse.js';
3
- import { violation } from './violation.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 { SYMBOLS, SYMBOL_PATTERNS } from "./index.js";
15
+ import { violation } from "./violation.js";
16
+ import { parse } from "./parse.js";
17
+
18
+ //#region src/coordinates/latlon/internal/parse-format.ts
5
19
  const axisTypeTest = (k, t) => SYMBOL_PATTERNS[k].test(t) && k;
6
20
  const createParser = (config) => (format, input) => parseWithConfig(config, format, input);
7
21
  function parseWithConfig(config, format, input) {
8
- const [parseTokens, violations] = parse(input, format);
9
- const foundFormat = parseTokens.reduce(
10
- (acc, t) => acc + (axisTypeTest("LAT", t) || axisTypeTest("LON", t) || ""),
11
- ""
12
- );
13
- if (!violations.length && foundFormat && foundFormat !== format) {
14
- return [
15
- [],
16
- [
17
- violation(
18
- `Mismatched formats: "${format}" expected, "${foundFormat}" found.`
19
- )
20
- ]
21
- ];
22
- }
23
- const hasErrors = !parseTokens.length && violations.length;
24
- if (hasErrors) {
25
- return [[], violations];
26
- }
27
- const [tokens, errors] = [
28
- parseTokens.slice(0, parseTokens.indexOf(SYMBOLS.DIVIDER)),
29
- // left of divider
30
- parseTokens.slice(1 + parseTokens.indexOf(SYMBOLS.DIVIDER))
31
- // right of divider
32
- ].map(config.identifyPieces).map(config.identifyErrors(format)).reduce((a, b) => [
33
- [...a[0], SYMBOLS.DIVIDER, ...b[0]],
34
- [...a[1], ...b[1]].map(violation)
35
- ]);
36
- if (errors.length) {
37
- return [
38
- [],
39
- // dedupe errors
40
- Array.from(new Set(errors))
41
- ];
42
- }
43
- const matches = (config.formats[format].exec(tokens.join(" ")) || []).slice(
44
- 1
45
- );
46
- if (!matches?.length) {
47
- throw new Error(
48
- [
49
- "A validation check seems to be missing because the cleaned and normalized input value (",
50
- tokens.join(" "),
51
- ") is not matching the pattern (",
52
- config.formats[format],
53
- ")."
54
- ].join("")
55
- );
56
- }
57
- return [matches, []];
22
+ const [parseTokens, violations] = parse(input, format);
23
+ const foundFormat = parseTokens.reduce((acc, t) => acc + (axisTypeTest("LAT", t) || axisTypeTest("LON", t) || ""), "");
24
+ if (!violations.length && foundFormat && foundFormat !== format) return [[], [violation(`Mismatched formats: "${format}" expected, "${foundFormat}" found.`)]];
25
+ if (!parseTokens.length && violations.length) return [[], violations];
26
+ const [tokens, errors] = [parseTokens.slice(0, parseTokens.indexOf(SYMBOLS.DIVIDER)), parseTokens.slice(1 + parseTokens.indexOf(SYMBOLS.DIVIDER))].map(config.identifyPieces).map(config.identifyErrors(format)).reduce((a, b) => [[
27
+ ...a[0],
28
+ SYMBOLS.DIVIDER,
29
+ ...b[0]
30
+ ], [...a[1], ...b[1]].map(violation)]);
31
+ if (errors.length) return [[], Array.from(new Set(errors))];
32
+ const matches = (config.formats[format].exec(tokens.join(" ")) || []).slice(1);
33
+ if (!matches?.length) throw new Error([
34
+ "A validation check seems to be missing because the cleaned and normalized input value (",
35
+ tokens.join(" "),
36
+ ") is not matching the pattern (",
37
+ config.formats[format],
38
+ ")."
39
+ ].join(""));
40
+ return [matches, []];
58
41
  }
59
42
 
43
+ //#endregion
60
44
  export { createParser };
61
- //# sourceMappingURL=parse-format.js.map
62
45
  //# sourceMappingURL=parse-format.js.map
@@ -1 +1 @@
1
- {"version":3,"sources":["../../../../src/coordinates/latlon/internal/parse-format.ts"],"names":[],"mappings":";;;;AA4BA,MAAM,YAAA,GAAe,CAAC,CAAA,EAAiC,CAAA,KACrD,gBAAgB,CAAC,CAAA,CAAE,IAAA,CAAK,CAAC,CAAA,IAAK,CAAA;AAEzB,MAAM,YAAA,GACX,CAAI,MAAA,KACJ,CAAC,QAAgB,KAAA,KACf,eAAA,CAAgB,MAAA,EAAQ,MAAA,EAAQ,KAAK;AAEzC,SAAS,eAAA,CACP,MAAA,EACA,MAAA,EACA,KAAA,EACc;AACd,EAAA,MAAM,CAAC,WAAA,EAAa,UAAU,CAAA,GAAI,KAAA,CAAM,OAAO,MAAM,CAAA;AAErD,EAAA,MAAM,cAAc,WAAA,CAAY,MAAA;AAAA,IAC9B,CAAC,GAAA,EAAK,CAAA,KAAM,GAAA,IAAO,YAAA,CAAa,KAAA,EAAO,CAAC,CAAA,IAAK,YAAA,CAAa,KAAA,EAAO,CAAC,CAAA,IAAK,EAAA,CAAA;AAAA,IACvE;AAAA,GACF;AAEA,EAAA,IAAI,CAAC,UAAA,CAAW,MAAA,IAAU,WAAA,IAAe,gBAAgB,MAAA,EAAQ;AAC/D,IAAA,OAAO;AAAA,MACL,EAAC;AAAA,MACD;AAAA,QACE,SAAA;AAAA,UACE,CAAA,qBAAA,EAAwB,MAAM,CAAA,aAAA,EAAgB,WAAW,CAAA,QAAA;AAAA;AAC3D;AACF,KACF;AAAA,EACF;AAEA,EAAA,MAAM,SAAA,GAAY,CAAC,WAAA,CAAY,MAAA,IAAU,UAAA,CAAW,MAAA;AAEpD,EAAA,IAAI,SAAA,EAAW;AACb,IAAA,OAAO,CAAC,EAAC,EAAG,UAAU,CAAA;AAAA,EACxB;AAEA,EAAA,MAAM,CAAC,MAAA,EAAQ,MAAM,CAAA,GAAI;AAAA,IACvB,YAAY,KAAA,CAAM,CAAA,EAAG,YAAY,OAAA,CAAQ,OAAA,CAAQ,OAAO,CAAC,CAAA;AAAA;AAAA,IACzD,YAAY,KAAA,CAAM,CAAA,GAAI,YAAY,OAAA,CAAQ,OAAA,CAAQ,OAAO,CAAC;AAAA;AAAA,GAC5D,CACG,GAAA,CAAI,MAAA,CAAO,cAAc,EACzB,GAAA,CAAI,MAAA,CAAO,cAAA,CAAe,MAAM,CAAC,CAAA,CACjC,MAAA,CAAO,CAAC,GAAG,CAAA,KAAM;AAAA,IAChB,CAAC,GAAG,CAAA,CAAE,CAAC,CAAA,EAAG,QAAQ,OAAA,EAAS,GAAG,CAAA,CAAE,CAAC,CAAC,CAAA;AAAA,IAClC,CAAC,GAAG,CAAA,CAAE,CAAC,CAAA,EAAG,GAAG,CAAA,CAAE,CAAC,CAAC,CAAA,CAAE,GAAA,CAAI,SAAS;AAAA,GACjC,CAAA;AAEH,EAAA,IAAI,OAAO,MAAA,EAAQ;AACjB,IAAA,OAAO;AAAA,MACL,EAAC;AAAA;AAAA,MAED,KAAA,CAAM,IAAA,CAAK,IAAI,GAAA,CAAI,MAAM,CAAC;AAAA,KAC5B;AAAA,EACF;AAEA,EAAA,MAAM,OAAA,GAAA,CAAW,MAAA,CAAO,OAAA,CAAQ,MAAM,CAAA,CAAE,IAAA,CAAK,MAAA,CAAO,IAAA,CAAK,GAAG,CAAC,CAAA,IAAK,EAAC,EAAG,KAAA;AAAA,IACpE;AAAA,GACF;AAEA,EAAA,IAAI,CAAC,SAAS,MAAA,EAAQ;AACpB,IAAA,MAAM,IAAI,KAAA;AAAA,MACR;AAAA,QACE,yFAAA;AAAA,QACA,MAAA,CAAO,KAAK,GAAG,CAAA;AAAA,QACf,iCAAA;AAAA,QACA,MAAA,CAAO,QAAQ,MAAM,CAAA;AAAA,QACrB;AAAA,OACF,CAAE,KAAK,EAAE;AAAA,KACX;AAAA,EACF;AAEA,EAAA,OAAO,CAAC,OAAA,EAAS,EAAE,CAAA;AACrB","file":"parse-format.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 { type Format, SYMBOL_PATTERNS, SYMBOLS } from '.';\nimport { type ParseResults, parse } from './parse';\nimport { violation } from './violation';\n\ntype FormatParserConfig<T> = {\n formats: {\n // biome-ignore lint/style/useNamingConvention: Name is chosen to stand out amongst other formats\n LATLON: RegExp;\n // biome-ignore lint/style/useNamingConvention: Name is chosen to stand out amongst other formats\n LONLAT: RegExp;\n };\n identifyErrors: (format: Format) => (arg: T, i: number) => ParseResults;\n identifyPieces: (half: string[]) => T;\n};\n\nconst axisTypeTest = (k: keyof typeof SYMBOL_PATTERNS, t: string) =>\n SYMBOL_PATTERNS[k].test(t) && k;\n\nexport const createParser =\n <T>(config: FormatParserConfig<T | undefined>) =>\n (format: Format, input: string) =>\n parseWithConfig(config, format, input);\n\nfunction parseWithConfig<T>(\n config: FormatParserConfig<T>,\n format: Format,\n input: string,\n): ParseResults {\n const [parseTokens, violations] = parse(input, format);\n\n const foundFormat = parseTokens.reduce(\n (acc, t) => acc + (axisTypeTest('LAT', t) || axisTypeTest('LON', t) || ''),\n '',\n );\n\n if (!violations.length && foundFormat && foundFormat !== format) {\n return [\n [],\n [\n violation(\n `Mismatched formats: \"${format}\" expected, \"${foundFormat}\" found.`,\n ),\n ],\n ];\n }\n\n const hasErrors = !parseTokens.length && violations.length;\n\n if (hasErrors) {\n return [[], violations];\n }\n\n const [tokens, errors] = [\n parseTokens.slice(0, parseTokens.indexOf(SYMBOLS.DIVIDER)), // left of divider\n parseTokens.slice(1 + parseTokens.indexOf(SYMBOLS.DIVIDER)), // right of divider\n ]\n .map(config.identifyPieces)\n .map(config.identifyErrors(format))\n .reduce((a, b) => [\n [...a[0], SYMBOLS.DIVIDER, ...b[0]],\n [...a[1], ...b[1]].map(violation),\n ]);\n\n if (errors.length) {\n return [\n [],\n // dedupe errors\n Array.from(new Set(errors)),\n ];\n }\n\n const matches = (config.formats[format].exec(tokens.join(' ')) || []).slice(\n 1,\n );\n\n if (!matches?.length) {\n throw new Error(\n [\n 'A validation check seems to be missing because the cleaned and normalized input value (',\n tokens.join(' '),\n ') is not matching the pattern (',\n config.formats[format],\n ').',\n ].join(''),\n );\n }\n\n return [matches, []];\n}\n"]}
1
+ {"version":3,"file":"parse-format.js","names":[],"sources":["../../../../src/coordinates/latlon/internal/parse-format.ts"],"sourcesContent":["// __private-exports\n/*\n * Copyright 2024 Hypergiant Galactic Systems Inc. All rights reserved.\n * This file is licensed to you under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License. You may obtain a copy\n * of the License at https://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software distributed under\n * the License is distributed on an \"AS IS\" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS\n * OF ANY KIND, either express or implied. See the License for the specific language\n * governing permissions and limitations under the License.\n */\n\nimport { type Format, SYMBOL_PATTERNS, SYMBOLS } from '.';\nimport { type ParseResults, parse } from './parse';\nimport { violation } from './violation';\n\ntype FormatParserConfig<T> = {\n formats: {\n // biome-ignore lint/style/useNamingConvention: Name is chosen to stand out amongst other formats\n LATLON: RegExp;\n // biome-ignore lint/style/useNamingConvention: Name is chosen to stand out amongst other formats\n LONLAT: RegExp;\n };\n identifyErrors: (format: Format) => (arg: T, i: number) => ParseResults;\n identifyPieces: (half: string[]) => T;\n};\n\nconst axisTypeTest = (k: keyof typeof SYMBOL_PATTERNS, t: string) =>\n SYMBOL_PATTERNS[k].test(t) && k;\n\nexport const createParser =\n <T>(config: FormatParserConfig<T | undefined>) =>\n (format: Format, input: string) =>\n parseWithConfig(config, format, input);\n\nfunction parseWithConfig<T>(\n config: FormatParserConfig<T>,\n format: Format,\n input: string,\n): ParseResults {\n const [parseTokens, violations] = parse(input, format);\n\n const foundFormat = parseTokens.reduce(\n (acc, t) => acc + (axisTypeTest('LAT', t) || axisTypeTest('LON', t) || ''),\n '',\n );\n\n if (!violations.length && foundFormat && foundFormat !== format) {\n return [\n [],\n [\n violation(\n `Mismatched formats: \"${format}\" expected, \"${foundFormat}\" found.`,\n ),\n ],\n ];\n }\n\n const hasErrors = !parseTokens.length && violations.length;\n\n if (hasErrors) {\n return [[], violations];\n }\n\n const [tokens, errors] = [\n parseTokens.slice(0, parseTokens.indexOf(SYMBOLS.DIVIDER)), // left of divider\n parseTokens.slice(1 + parseTokens.indexOf(SYMBOLS.DIVIDER)), // right of divider\n ]\n .map(config.identifyPieces)\n .map(config.identifyErrors(format))\n .reduce((a, b) => [\n [...a[0], SYMBOLS.DIVIDER, ...b[0]],\n [...a[1], ...b[1]].map(violation),\n ]);\n\n if (errors.length) {\n return [\n [],\n // dedupe errors\n Array.from(new Set(errors)),\n ];\n }\n\n const matches = (config.formats[format].exec(tokens.join(' ')) || []).slice(\n 1,\n );\n\n if (!matches?.length) {\n throw new Error(\n [\n 'A validation check seems to be missing because the cleaned and normalized input value (',\n tokens.join(' '),\n ') is not matching the pattern (',\n config.formats[format],\n ').',\n ].join(''),\n );\n }\n\n return [matches, []];\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;AA4BA,MAAM,gBAAgB,GAAiC,MACrD,gBAAgB,GAAG,KAAK,EAAE,IAAI;AAEhC,MAAa,gBACP,YACH,QAAgB,UACf,gBAAgB,QAAQ,QAAQ,MAAM;AAE1C,SAAS,gBACP,QACA,QACA,OACc;CACd,MAAM,CAAC,aAAa,cAAc,MAAM,OAAO,OAAO;CAEtD,MAAM,cAAc,YAAY,QAC7B,KAAK,MAAM,OAAO,aAAa,OAAO,EAAE,IAAI,aAAa,OAAO,EAAE,IAAI,KACvE,GACD;AAED,KAAI,CAAC,WAAW,UAAU,eAAe,gBAAgB,OACvD,QAAO,CACL,EAAE,EACF,CACE,UACE,wBAAwB,OAAO,eAAe,YAAY,UAC3D,CACF,CACF;AAKH,KAFkB,CAAC,YAAY,UAAU,WAAW,OAGlD,QAAO,CAAC,EAAE,EAAE,WAAW;CAGzB,MAAM,CAAC,QAAQ,UAAU,CACvB,YAAY,MAAM,GAAG,YAAY,QAAQ,QAAQ,QAAQ,CAAC,EAC1D,YAAY,MAAM,IAAI,YAAY,QAAQ,QAAQ,QAAQ,CAAC,CAC5D,CACE,IAAI,OAAO,eAAe,CAC1B,IAAI,OAAO,eAAe,OAAO,CAAC,CAClC,QAAQ,GAAG,MAAM,CAChB;EAAC,GAAG,EAAE;EAAI,QAAQ;EAAS,GAAG,EAAE;EAAG,EACnC,CAAC,GAAG,EAAE,IAAI,GAAG,EAAE,GAAG,CAAC,IAAI,UAAU,CAClC,CAAC;AAEJ,KAAI,OAAO,OACT,QAAO,CACL,EAAE,EAEF,MAAM,KAAK,IAAI,IAAI,OAAO,CAAC,CAC5B;CAGH,MAAM,WAAW,OAAO,QAAQ,QAAQ,KAAK,OAAO,KAAK,IAAI,CAAC,IAAI,EAAE,EAAE,MACpE,EACD;AAED,KAAI,CAAC,SAAS,OACZ,OAAM,IAAI,MACR;EACE;EACA,OAAO,KAAK,IAAI;EAChB;EACA,OAAO,QAAQ;EACf;EACD,CAAC,KAAK,GAAG,CACX;AAGH,QAAO,CAAC,SAAS,EAAE,CAAC"}
@@ -1,6 +1,19 @@
1
- import { Tokens } from './lexer.js';
2
- import { Errors, 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
+ */
3
12
 
13
+ import { Errors, Format } from "./index.js";
14
+ import { Tokens } from "./lexer.js";
15
+
16
+ //#region src/coordinates/latlon/internal/parse.d.ts
4
17
  type ParseResults = [Tokens, Errors];
5
18
  /**
6
19
  * Parse a raw input string into a validated and normalized coordinate
@@ -37,5 +50,6 @@ type ParseResults = [Tokens, Errors];
37
50
  *
38
51
  */
39
52
  declare function parse(input: string, format?: Format): ParseResults;
40
-
41
- export { type ParseResults, parse };
53
+ //#endregion
54
+ export { ParseResults, parse };
55
+ //# sourceMappingURL=parse.d.ts.map
@@ -1,15 +1,61 @@
1
- import { lexer } from './lexer.js';
2
- import { pipesRunner } from './pipes/index.js';
3
- import { violation } from './violation.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 { lexer } from "./lexer.js";
15
+ import { pipesRunner } from "./pipes/index.js";
16
+ import { violation } from "./violation.js";
17
+
18
+ //#region src/coordinates/latlon/internal/parse.ts
19
+ /**
20
+ * Parse a raw input string into a validated and normalized coordinate
21
+ * primitive ready for further refinement/validation by a more specific parser.
22
+ *
23
+ * @param input
24
+ * raw input, from a user or external system, of unknown validity
25
+ *
26
+ * @param format
27
+ * the expected format - LATLON or LONLAT - the coordinate should conform to
28
+ *
29
+ * @returns
30
+ * tuple with two values: tokens, and errors
31
+ *
32
+ * @remarks
33
+ * pure function
34
+ *
35
+ * @example
36
+ * const input = '1 2 3 / 4 5 6'
37
+ * parse(input); // [['1', '2', '3', '/', '4', '5', '6'], []]
38
+ *
39
+ * @description
40
+ * __Assumptions/Specification__
41
+ * 1. Decimals are indicated by a "." and not ","
42
+ * 2. A degrees indicator is "°"
43
+ * 3. A minutes indicator is "'"
44
+ * 4. A seconds indicator is '"'
45
+ * 5. Each indicator is expected to follow the number it is annotating
46
+ * 6. Numeric parts - degrees, minutes, and seconds - are positional and can
47
+ * not be arranged in alternative orders and be considered valid
48
+ * 7. Output will have explicit bearings characters (NSEW) and not rely on
49
+ * positive and negative values; when bearings are available. Negative
50
+ * values will only be replaced with absolute values if bearings are available.
51
+ *
52
+ */
5
53
  function parse(input, format) {
6
- if (!input?.length) {
7
- return [[], [violation("No input.")]];
8
- }
9
- const [tokens, errors] = pipesRunner(lexer(input), format);
10
- return [tokens, errors?.length ? errors.map(violation) : []];
54
+ if (!input?.length) return [[], [violation("No input.")]];
55
+ const [tokens, errors] = pipesRunner(lexer(input), format);
56
+ return [tokens, errors?.length ? errors.map(violation) : []];
11
57
  }
12
58
 
59
+ //#endregion
13
60
  export { parse };
14
- //# sourceMappingURL=parse.js.map
15
61
  //# sourceMappingURL=parse.js.map
@@ -1 +1 @@
1
- {"version":3,"sources":["../../../../src/coordinates/latlon/internal/parse.ts"],"names":[],"mappings":";;;;AAsDO,SAAS,KAAA,CAAM,OAAe,MAAA,EAA+B;AAClE,EAAA,IAAI,CAAC,OAAO,MAAA,EAAQ;AAClB,IAAA,OAAO,CAAC,EAAC,EAAG,CAAC,SAAA,CAAU,WAAW,CAAC,CAAC,CAAA;AAAA,EACtC;AAEA,EAAA,MAAM,CAAC,QAAQ,MAAM,CAAA,GAAI,YAAY,KAAA,CAAM,KAAK,GAAG,MAAM,CAAA;AAEzD,EAAA,OAAO,CAAC,QAAQ,MAAA,EAAQ,MAAA,GAAS,OAAO,GAAA,CAAI,SAAS,CAAA,GAAI,EAAE,CAAA;AAC7D","file":"parse.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 { lexer, type Tokens } from './lexer';\nimport { pipesRunner } from './pipes';\nimport { violation } from './violation';\nimport type { Errors, Format } from '.';\n\nexport type ParseResults = [Tokens, Errors];\n\n/**\n * Parse a raw input string into a validated and normalized coordinate\n * primitive ready for further refinement/validation by a more specific parser.\n *\n * @param input\n * raw input, from a user or external system, of unknown validity\n *\n * @param format\n * the expected format - LATLON or LONLAT - the coordinate should conform to\n *\n * @returns\n * tuple with two values: tokens, and errors\n *\n * @remarks\n * pure function\n *\n * @example\n * const input = '1 2 3 / 4 5 6'\n * parse(input); // [['1', '2', '3', '/', '4', '5', '6'], []]\n *\n * @description\n * __Assumptions/Specification__\n * 1. Decimals are indicated by a \".\" and not \",\"\n * 2. A degrees indicator is \"°\"\n * 3. A minutes indicator is \"'\"\n * 4. A seconds indicator is '\"'\n * 5. Each indicator is expected to follow the number it is annotating\n * 6. Numeric parts - degrees, minutes, and seconds - are positional and can\n * not be arranged in alternative orders and be considered valid\n * 7. Output will have explicit bearings characters (NSEW) and not rely on\n * positive and negative values; when bearings are available. Negative\n * values will only be replaced with absolute values if bearings are available.\n *\n */\nexport function parse(input: string, format?: Format): ParseResults {\n if (!input?.length) {\n return [[], [violation('No input.')]];\n }\n\n const [tokens, errors] = pipesRunner(lexer(input), format);\n\n return [tokens, errors?.length ? errors.map(violation) : []];\n}\n"]}
1
+ {"version":3,"file":"parse.js","names":[],"sources":["../../../../src/coordinates/latlon/internal/parse.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 { lexer, type Tokens } from './lexer';\nimport { pipesRunner } from './pipes';\nimport { violation } from './violation';\nimport type { Errors, Format } from '.';\n\nexport type ParseResults = [Tokens, Errors];\n\n/**\n * Parse a raw input string into a validated and normalized coordinate\n * primitive ready for further refinement/validation by a more specific parser.\n *\n * @param input\n * raw input, from a user or external system, of unknown validity\n *\n * @param format\n * the expected format - LATLON or LONLAT - the coordinate should conform to\n *\n * @returns\n * tuple with two values: tokens, and errors\n *\n * @remarks\n * pure function\n *\n * @example\n * const input = '1 2 3 / 4 5 6'\n * parse(input); // [['1', '2', '3', '/', '4', '5', '6'], []]\n *\n * @description\n * __Assumptions/Specification__\n * 1. Decimals are indicated by a \".\" and not \",\"\n * 2. A degrees indicator is \"°\"\n * 3. A minutes indicator is \"'\"\n * 4. A seconds indicator is '\"'\n * 5. Each indicator is expected to follow the number it is annotating\n * 6. Numeric parts - degrees, minutes, and seconds - are positional and can\n * not be arranged in alternative orders and be considered valid\n * 7. Output will have explicit bearings characters (NSEW) and not rely on\n * positive and negative values; when bearings are available. Negative\n * values will only be replaced with absolute values if bearings are available.\n *\n */\nexport function parse(input: string, format?: Format): ParseResults {\n if (!input?.length) {\n return [[], [violation('No input.')]];\n }\n\n const [tokens, errors] = pipesRunner(lexer(input), format);\n\n return [tokens, errors?.length ? errors.map(violation) : []];\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAsDA,SAAgB,MAAM,OAAe,QAA+B;AAClE,KAAI,CAAC,OAAO,OACV,QAAO,CAAC,EAAE,EAAE,CAAC,UAAU,YAAY,CAAC,CAAC;CAGvC,MAAM,CAAC,QAAQ,UAAU,YAAY,MAAM,MAAM,EAAE,OAAO;AAE1D,QAAO,CAAC,QAAQ,QAAQ,SAAS,OAAO,IAAI,UAAU,GAAG,EAAE,CAAC"}
@@ -1,10 +1,24 @@
1
- import { Format } from '../index.js';
2
- import { Tokens } from '../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
+ */
12
+
13
+ import { Format } from "../index.js";
14
+ import { Tokens } from "../lexer.js";
3
15
 
16
+ //#region src/coordinates/latlon/internal/pipes/check-ambiguous.d.ts
4
17
  /**
5
18
  * Look for groupings of numbers that are ambiguous; no indicators, or no
6
19
  * dividers and not possibility of deducing where a divider should be inserted.
7
20
  */
8
21
  declare function checkAmbiguousGrouping(tokens: Tokens, _format?: Format): [string[], string | boolean];
9
-
22
+ //#endregion
10
23
  export { checkAmbiguousGrouping };
24
+ //# sourceMappingURL=check-ambiguous.d.ts.map
@@ -1,22 +1,37 @@
1
- import { SYMBOLS, SYMBOL_PATTERNS } from '../index.js';
2
- import { pipesResult } from '../pipes/index.js';
3
- import { simpler } from './simpler.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 { SYMBOLS, SYMBOL_PATTERNS } from "../index.js";
15
+ import { simpler } from "./simpler.js";
16
+ import { pipesResult } from "./index.js";
17
+
18
+ //#region src/coordinates/latlon/internal/pipes/check-ambiguous.ts
19
+ /**
20
+ * Look for groupings of numbers that are ambiguous; no indicators, or no
21
+ * dividers and not possibility of deducing where a divider should be inserted.
22
+ */
5
23
  function checkAmbiguousGrouping(tokens, _format) {
6
- if (tokens.includes(SYMBOLS.DIVIDER)) {
7
- return pipesResult(tokens, false);
8
- }
9
- const simple = simpler(tokens);
10
- const ambiguous = /^(?:(?:BN{3,5})|(?:N{3,5}B))$/.test(simple);
11
- const bookends = /^BN{3,5}B$/.test(simple);
12
- const helpful = tokens.slice(1, -1).reduce((acc, t) => {
13
- const helps = t.includes(SYMBOLS.DEGREES) || t.includes(SYMBOLS.SECONDS) || SYMBOL_PATTERNS.NSEW.test(t);
14
- return `${acc}${helps ? "H" : "_"}`;
15
- }, "").includes("H");
16
- const hopeless = /^N{3,5}$/.test(simple) && !helpful;
17
- return pipesResult(tokens, ambiguous || bookends || hopeless);
24
+ if (tokens.includes(SYMBOLS.DIVIDER)) return pipesResult(tokens, false);
25
+ const simple = simpler(tokens);
26
+ const ambiguous = /^(?:(?:BN{3,5})|(?:N{3,5}B))$/.test(simple);
27
+ const bookends = /^BN{3,5}B$/.test(simple);
28
+ const helpful = tokens.slice(1, -1).reduce((acc, t) => {
29
+ return `${acc}${t.includes(SYMBOLS.DEGREES) || t.includes(SYMBOLS.SECONDS) || SYMBOL_PATTERNS.NSEW.test(t) ? "H" : "_"}`;
30
+ }, "").includes("H");
31
+ const hopeless = /^N{3,5}$/.test(simple) && !helpful;
32
+ return pipesResult(tokens, ambiguous || bookends || hopeless);
18
33
  }
19
34
 
35
+ //#endregion
20
36
  export { checkAmbiguousGrouping };
21
- //# sourceMappingURL=check-ambiguous.js.map
22
37
  //# sourceMappingURL=check-ambiguous.js.map
@@ -1 +1 @@
1
- {"version":3,"sources":["../../../../../src/coordinates/latlon/internal/pipes/check-ambiguous.ts"],"names":[],"mappings":";;;;AAsBO,SAAS,sBAAA,CAAuB,QAAgB,OAAA,EAAkB;AACvE,EAAA,IAAI,MAAA,CAAO,QAAA,CAAS,OAAA,CAAQ,OAAO,CAAA,EAAG;AACpC,IAAA,OAAO,WAAA,CAAY,QAAQ,KAAK,CAAA;AAAA,EAClC;AAEA,EAAA,MAAM,MAAA,GAAS,QAAQ,MAAM,CAAA;AAG7B,EAAA,MAAM,SAAA,GAAY,+BAAA,CAAgC,IAAA,CAAK,MAAM,CAAA;AAE7D,EAAA,MAAM,QAAA,GAAW,YAAA,CAAa,IAAA,CAAK,MAAM,CAAA;AAMzC,EAAA,MAAM,OAAA,GAAU,OAGb,KAAA,CAAM,CAAA,EAAG,EAAE,CAAA,CACX,MAAA,CAAO,CAAC,GAAA,EAAK,CAAA,KAAM;AAClB,IAAA,MAAM,KAAA,GACJ,CAAA,CAAE,QAAA,CAAS,OAAA,CAAQ,OAAO,CAAA,IAC1B,CAAA,CAAE,QAAA,CAAS,OAAA,CAAQ,OAAO,CAAA,IAC1B,eAAA,CAAgB,IAAA,CAAK,KAAK,CAAC,CAAA;AAE7B,IAAA,OAAO,CAAA,EAAG,GAAG,CAAA,EAAG,KAAA,GAAQ,MAAM,GAAG,CAAA,CAAA;AAAA,EACnC,CAAA,EAAG,EAAE,CAAA,CACJ,QAAA,CAAS,GAAG,CAAA;AAEf,EAAA,MAAM,QAAA,GAAW,UAAA,CAAW,IAAA,CAAK,MAAM,KAAK,CAAC,OAAA;AAE7C,EAAA,OAAO,WAAA,CAAY,MAAA,EAAQ,SAAA,IAAa,QAAA,IAAY,QAAQ,CAAA;AAC9D","file":"check-ambiguous.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 { type Format, SYMBOL_PATTERNS, SYMBOLS } from '..';\nimport { pipesResult } from '../pipes';\nimport { simpler } from './simpler';\nimport type { Tokens } from '../lexer';\n\n/**\n * Look for groupings of numbers that are ambiguous; no indicators, or no\n * dividers and not possibility of deducing where a divider should be inserted.\n */\nexport function checkAmbiguousGrouping(tokens: Tokens, _format?: Format) {\n if (tokens.includes(SYMBOLS.DIVIDER)) {\n return pipesResult(tokens, false);\n }\n\n const simple = simpler(tokens);\n\n // 3-5 numbers after or before a single bearing indicator BNNN, NNNB\n const ambiguous = /^(?:(?:BN{3,5})|(?:N{3,5}B))$/.test(simple);\n // 3-5 numbers between 2 bearings indicators BNNNB\n const bookends = /^BN{3,5}B$/.test(simple);\n // \"helpful\" indicators:\n // 1. degrees number in the right-of-divider position e.g. # #°\n // 2. seconds number in the left-of-divider position e.g. # #\" #\n // 3. trailing bearings in the left-of-divider position e.g. # N #\n // 4. leading bearings in the right-of-divider position e.g. N # E #\n const helpful = tokens\n // helpful tokens are only helpful in the middle of the token list\n // not the beginning or end of the list\n .slice(1, -1)\n .reduce((acc, t) => {\n const helps =\n t.includes(SYMBOLS.DEGREES) ||\n t.includes(SYMBOLS.SECONDS) ||\n SYMBOL_PATTERNS.NSEW.test(t);\n\n return `${acc}${helps ? 'H' : '_'}`;\n }, '')\n .includes('H');\n // 3-5 numbers with no bearings indicators, and no helpful indicators\n const hopeless = /^N{3,5}$/.test(simple) && !helpful;\n\n return pipesResult(tokens, ambiguous || bookends || hopeless);\n}\n"]}
1
+ {"version":3,"file":"check-ambiguous.js","names":[],"sources":["../../../../../src/coordinates/latlon/internal/pipes/check-ambiguous.ts"],"sourcesContent":["// __private-exports\n/*\n * Copyright 2024 Hypergiant Galactic Systems Inc. All rights reserved.\n * This file is licensed to you under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License. You may obtain a copy\n * of the License at https://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software distributed under\n * the License is distributed on an \"AS IS\" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS\n * OF ANY KIND, either express or implied. See the License for the specific language\n * governing permissions and limitations under the License.\n */\n\nimport { type Format, SYMBOL_PATTERNS, SYMBOLS } from '..';\nimport { pipesResult } from '../pipes';\nimport { simpler } from './simpler';\nimport type { Tokens } from '../lexer';\n\n/**\n * Look for groupings of numbers that are ambiguous; no indicators, or no\n * dividers and not possibility of deducing where a divider should be inserted.\n */\nexport function checkAmbiguousGrouping(tokens: Tokens, _format?: Format) {\n if (tokens.includes(SYMBOLS.DIVIDER)) {\n return pipesResult(tokens, false);\n }\n\n const simple = simpler(tokens);\n\n // 3-5 numbers after or before a single bearing indicator BNNN, NNNB\n const ambiguous = /^(?:(?:BN{3,5})|(?:N{3,5}B))$/.test(simple);\n // 3-5 numbers between 2 bearings indicators BNNNB\n const bookends = /^BN{3,5}B$/.test(simple);\n // \"helpful\" indicators:\n // 1. degrees number in the right-of-divider position e.g. # #°\n // 2. seconds number in the left-of-divider position e.g. # #\" #\n // 3. trailing bearings in the left-of-divider position e.g. # N #\n // 4. leading bearings in the right-of-divider position e.g. N # E #\n const helpful = tokens\n // helpful tokens are only helpful in the middle of the token list\n // not the beginning or end of the list\n .slice(1, -1)\n .reduce((acc, t) => {\n const helps =\n t.includes(SYMBOLS.DEGREES) ||\n t.includes(SYMBOLS.SECONDS) ||\n SYMBOL_PATTERNS.NSEW.test(t);\n\n return `${acc}${helps ? 'H' : '_'}`;\n }, '')\n .includes('H');\n // 3-5 numbers with no bearings indicators, and no helpful indicators\n const hopeless = /^N{3,5}$/.test(simple) && !helpful;\n\n return pipesResult(tokens, ambiguous || bookends || hopeless);\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;AAsBA,SAAgB,uBAAuB,QAAgB,SAAkB;AACvE,KAAI,OAAO,SAAS,QAAQ,QAAQ,CAClC,QAAO,YAAY,QAAQ,MAAM;CAGnC,MAAM,SAAS,QAAQ,OAAO;CAG9B,MAAM,YAAY,gCAAgC,KAAK,OAAO;CAE9D,MAAM,WAAW,aAAa,KAAK,OAAO;CAM1C,MAAM,UAAU,OAGb,MAAM,GAAG,GAAG,CACZ,QAAQ,KAAK,MAAM;AAMlB,SAAO,GAAG,MAJR,EAAE,SAAS,QAAQ,QAAQ,IAC3B,EAAE,SAAS,QAAQ,QAAQ,IAC3B,gBAAgB,KAAK,KAAK,EAAE,GAEN,MAAM;IAC7B,GAAG,CACL,SAAS,IAAI;CAEhB,MAAM,WAAW,WAAW,KAAK,OAAO,IAAI,CAAC;AAE7C,QAAO,YAAY,QAAQ,aAAa,YAAY,SAAS"}
@@ -1,8 +1,22 @@
1
- import { Tokens } from '../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
+ */
12
+
13
+ import { Tokens } from "../lexer.js";
2
14
 
15
+ //#region src/coordinates/latlon/internal/pipes/check-numbers.d.ts
3
16
  /**
4
17
  * Check for problems in the numeric values.
5
18
  */
6
19
  declare function checkNumberValues(tokens: Tokens): [string[], string | boolean];
7
-
20
+ //#endregion
8
21
  export { checkNumberValues };
22
+ //# sourceMappingURL=check-numbers.d.ts.map
@@ -1,34 +1,36 @@
1
- import { pipesResult } from '../pipes/index.js';
2
- import { simpler } from './simpler.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 { simpler } from "./simpler.js";
15
+ import { pipesResult } from "./index.js";
16
+
17
+ //#region src/coordinates/latlon/internal/pipes/check-numbers.ts
18
+ /**
19
+ * Check for problems in the numeric values.
20
+ */
4
21
  function checkNumberValues(tokens) {
5
- const simple = simpler(tokens);
6
- if ((simple.match(/N/g) ?? []).length < 2) {
7
- return pipesResult(tokens, "Too few numbers.");
8
- }
9
- const error = (
10
- // 4 consecutive numbers in specific formation is not going to be valid
11
- /(?:N{4,}BN+)|(?:N+BN{4,})/.test(simple) || // more than 6 numbers total
12
- (simple.match(/N/g) ?? []).length > 6
13
- );
14
- if (error) {
15
- return pipesResult(tokens, "Too many numbers.");
16
- }
17
- const pattern = tokens.reduce((acc, t) => {
18
- if (/\d/.test(t)) {
19
- acc.push(Number.parseFloat(t) < 0 ? "-" : "+");
20
- } else {
21
- acc.push("_");
22
- }
23
- return acc;
24
- }, []).join("");
25
- const matches = pattern.match(/[^_]-./);
26
- if (!!matches && pattern !== "_--_") {
27
- return pipesResult(tokens, "Negative value for non-degrees value found.");
28
- }
29
- return pipesResult(tokens, false);
22
+ const simple = simpler(tokens);
23
+ if ((simple.match(/N/g) ?? []).length < 2) return pipesResult(tokens, "Too few numbers.");
24
+ if (/(?:N{4,}BN+)|(?:N+BN{4,})/.test(simple) || (simple.match(/N/g) ?? []).length > 6) return pipesResult(tokens, "Too many numbers.");
25
+ const pattern = tokens.reduce((acc, t) => {
26
+ if (/\d/.test(t)) acc.push(Number.parseFloat(t) < 0 ? "-" : "+");
27
+ else acc.push("_");
28
+ return acc;
29
+ }, []).join("");
30
+ if (!!pattern.match(/[^_]-./) && pattern !== "_--_") return pipesResult(tokens, "Negative value for non-degrees value found.");
31
+ return pipesResult(tokens, false);
30
32
  }
31
33
 
34
+ //#endregion
32
35
  export { checkNumberValues };
33
- //# sourceMappingURL=check-numbers.js.map
34
36
  //# sourceMappingURL=check-numbers.js.map
@@ -1 +1 @@
1
- {"version":3,"sources":["../../../../../src/coordinates/latlon/internal/pipes/check-numbers.ts"],"names":[],"mappings":";;;AAoBO,SAAS,kBAAkB,MAAA,EAAgB;AAChD,EAAA,MAAM,MAAA,GAAS,QAAQ,MAAM,CAAA;AAE7B,EAAA,IAAA,CAAK,OAAO,KAAA,CAAM,IAAI,KAAK,EAAC,EAAG,SAAS,CAAA,EAAG;AACzC,IAAA,OAAO,WAAA,CAAY,QAAQ,kBAAkB,CAAA;AAAA,EAC/C;AAEA,EAAA,MAAM,KAAA;AAAA;AAAA,IAEJ,2BAAA,CAA4B,KAAK,MAAM,CAAA;AAAA,IAAA,CAEtC,OAAO,KAAA,CAAM,IAAI,CAAA,IAAK,IAAI,MAAA,GAAS;AAAA,GAAA;AAEtC,EAAA,IAAI,KAAA,EAAO;AACT,IAAA,OAAO,WAAA,CAAY,QAAQ,mBAAmB,CAAA;AAAA,EAChD;AAEA,EAAA,MAAM,OAAA,GAAU,MAAA,CACb,MAAA,CAAO,CAAC,KAAK,CAAA,KAAM;AAClB,IAAA,IAAI,IAAA,CAAK,IAAA,CAAK,CAAC,CAAA,EAAG;AAChB,MAAA,GAAA,CAAI,KAAK,MAAA,CAAO,UAAA,CAAW,CAAC,CAAA,GAAI,CAAA,GAAI,MAAM,GAAG,CAAA;AAAA,IAC/C,CAAA,MAAO;AACL,MAAA,GAAA,CAAI,KAAK,GAAG,CAAA;AAAA,IACd;AAEA,IAAA,OAAO,GAAA;AAAA,EACT,CAAA,EAAG,EAAc,CAAA,CAChB,KAAK,EAAE,CAAA;AAEV,EAAA,MAAM,OAAA,GAAU,OAAA,CAAQ,KAAA,CAAM,QAAQ,CAAA;AAItC,EAAA,IAAI,CAAC,CAAC,OAAA,IAAW,OAAA,KAAY,MAAA,EAAQ;AACnC,IAAA,OAAO,WAAA,CAAY,QAAQ,6CAA6C,CAAA;AAAA,EAC1E;AAEA,EAAA,OAAO,WAAA,CAAY,QAAQ,KAAK,CAAA;AAClC","file":"check-numbers.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 { pipesResult } from '../pipes';\nimport { simpler } from './simpler';\nimport type { Tokens } from '../lexer';\n\n/**\n * Check for problems in the numeric values.\n */\nexport function checkNumberValues(tokens: Tokens) {\n const simple = simpler(tokens);\n\n if ((simple.match(/N/g) ?? []).length < 2) {\n return pipesResult(tokens, 'Too few numbers.');\n }\n\n const error =\n // 4 consecutive numbers in specific formation is not going to be valid\n /(?:N{4,}BN+)|(?:N+BN{4,})/.test(simple) ||\n // more than 6 numbers total\n (simple.match(/N/g) ?? []).length > 6;\n\n if (error) {\n return pipesResult(tokens, 'Too many numbers.');\n }\n\n const pattern = tokens\n .reduce((acc, t) => {\n if (/\\d/.test(t)) {\n acc.push(Number.parseFloat(t) < 0 ? '-' : '+');\n } else {\n acc.push('_');\n }\n\n return acc;\n }, [] as string[])\n .join('');\n\n const matches = pattern.match(/[^_]-./);\n\n // special case '_--_' when the input is something like 'S -1 -1 W'\n // which is invalid for other reasons and will be caught elsewhere\n if (!!matches && pattern !== '_--_') {\n return pipesResult(tokens, 'Negative value for non-degrees value found.');\n }\n\n return pipesResult(tokens, false);\n}\n"]}
1
+ {"version":3,"file":"check-numbers.js","names":[],"sources":["../../../../../src/coordinates/latlon/internal/pipes/check-numbers.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 { pipesResult } from '../pipes';\nimport { simpler } from './simpler';\nimport type { Tokens } from '../lexer';\n\n/**\n * Check for problems in the numeric values.\n */\nexport function checkNumberValues(tokens: Tokens) {\n const simple = simpler(tokens);\n\n if ((simple.match(/N/g) ?? []).length < 2) {\n return pipesResult(tokens, 'Too few numbers.');\n }\n\n const error =\n // 4 consecutive numbers in specific formation is not going to be valid\n /(?:N{4,}BN+)|(?:N+BN{4,})/.test(simple) ||\n // more than 6 numbers total\n (simple.match(/N/g) ?? []).length > 6;\n\n if (error) {\n return pipesResult(tokens, 'Too many numbers.');\n }\n\n const pattern = tokens\n .reduce((acc, t) => {\n if (/\\d/.test(t)) {\n acc.push(Number.parseFloat(t) < 0 ? '-' : '+');\n } else {\n acc.push('_');\n }\n\n return acc;\n }, [] as string[])\n .join('');\n\n const matches = pattern.match(/[^_]-./);\n\n // special case '_--_' when the input is something like 'S -1 -1 W'\n // which is invalid for other reasons and will be caught elsewhere\n if (!!matches && pattern !== '_--_') {\n return pipesResult(tokens, 'Negative value for non-degrees value found.');\n }\n\n return pipesResult(tokens, false);\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;AAoBA,SAAgB,kBAAkB,QAAgB;CAChD,MAAM,SAAS,QAAQ,OAAO;AAE9B,MAAK,OAAO,MAAM,KAAK,IAAI,EAAE,EAAE,SAAS,EACtC,QAAO,YAAY,QAAQ,mBAAmB;AAShD,KAJE,4BAA4B,KAAK,OAAO,KAEvC,OAAO,MAAM,KAAK,IAAI,EAAE,EAAE,SAAS,EAGpC,QAAO,YAAY,QAAQ,oBAAoB;CAGjD,MAAM,UAAU,OACb,QAAQ,KAAK,MAAM;AAClB,MAAI,KAAK,KAAK,EAAE,CACd,KAAI,KAAK,OAAO,WAAW,EAAE,GAAG,IAAI,MAAM,IAAI;MAE9C,KAAI,KAAK,IAAI;AAGf,SAAO;IACN,EAAE,CAAa,CACjB,KAAK,GAAG;AAMX,KAAI,CAAC,CAJW,QAAQ,MAAM,SAAS,IAItB,YAAY,OAC3B,QAAO,YAAY,QAAQ,8CAA8C;AAG3E,QAAO,YAAY,QAAQ,MAAM"}
@@ -1,12 +1,26 @@
1
- import { Format } from '../index.js';
2
- import { Tokens } from '../lexer.js';
3
- import { PipeResult } 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
+ */
12
+
13
+ import { Format } from "../index.js";
14
+ import { Tokens } from "../lexer.js";
15
+ import { PipeResult } from "./index.js";
4
16
 
17
+ //#region src/coordinates/latlon/internal/pipes/fix-bearings.d.ts
5
18
  /**
6
19
  * Normalize bearings - negative and positive numeric values to NSEW - and
7
20
  * positioning of bearings - after the numeric values - and fill in any missing
8
21
  * bearings if only one is provided.
9
22
  */
10
23
  declare function fixBearings(tokens: Tokens, format?: Format): PipeResult;
11
-
24
+ //#endregion
12
25
  export { fixBearings };
26
+ //# sourceMappingURL=fix-bearings.d.ts.map