@accelint/geo 0.3.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 +10 -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 -29
  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 -18
  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 +49 -15
  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,67 +1,79 @@
1
- import { BEARINGS, SYMBOLS, SYMBOL_PATTERNS } 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
+
14
+ import { BEARINGS, SYMBOLS, SYMBOL_PATTERNS } from "../index.js";
15
+
16
+ //#region src/coordinates/latlon/internal/pipes/fix-bearings.ts
3
17
  const orthogonal = {
4
- N: BEARINGS.LON,
5
- S: BEARINGS.LON,
6
- E: BEARINGS.LAT,
7
- W: BEARINGS.LAT
18
+ N: BEARINGS.LON,
19
+ S: BEARINGS.LON,
20
+ E: BEARINGS.LAT,
21
+ W: BEARINGS.LAT
8
22
  };
9
23
  const bearingConflictsWithNumber = (tokens) => tokens[0] && tokens[1] && SYMBOL_PATTERNS.NEGATIVE_SIGN.test(tokens[1]) && SYMBOL_PATTERNS.NSEW.test(tokens[0]) && !SYMBOL_PATTERNS.NEGATIVE_BEARINGS.test(tokens[0]);
10
24
  const bePositive = (n) => n.replace(SYMBOL_PATTERNS.NEGATIVE_SIGN, "");
11
25
  const conflict = ([a, b]) => `Bearing (${a}) conflicts with negative number (${b}).`;
26
+ /**
27
+ * Normalize bearings - negative and positive numeric values to NSEW - and
28
+ * positioning of bearings - after the numeric values - and fill in any missing
29
+ * bearings if only one is provided.
30
+ */
12
31
  function fixBearings(tokens, format) {
13
- const [left, right] = [
14
- tokens.slice(0, tokens.indexOf(SYMBOLS.DIVIDER)),
15
- tokens.slice(1 + tokens.indexOf(SYMBOLS.DIVIDER))
16
- ].map(moveBearingsToHead);
17
- if (bearingConflictsWithNumber(left)) {
18
- return [[], conflict(left)];
19
- }
20
- if (bearingConflictsWithNumber(right)) {
21
- return [[], conflict(right)];
22
- }
23
- const [leftHasBearing, rightHasBearing] = [left, right].map(
24
- (list) => !!(list?.[0] && SYMBOL_PATTERNS.NSEW.test(list[0]))
25
- );
26
- let leftBearing = "";
27
- let rightBearing = "";
28
- if (leftHasBearing && rightHasBearing) {
29
- leftBearing = left.shift() ?? "";
30
- rightBearing = right.shift() ?? "";
31
- } else if (leftHasBearing) {
32
- leftBearing = left.shift() ?? "";
33
- rightBearing = orthogonal[leftBearing][+SYMBOL_PATTERNS.NEGATIVE_SIGN.test(right[0] ?? "")];
34
- } else if (rightHasBearing) {
35
- rightBearing = right.shift() ?? "";
36
- leftBearing = orthogonal[rightBearing][+SYMBOL_PATTERNS.NEGATIVE_SIGN.test(right[0] ?? "")];
37
- } else if (format) {
38
- leftBearing = `${BEARINGS[format][0][+SYMBOL_PATTERNS.NEGATIVE_SIGN.test(`${left[0]}`)]}`;
39
- rightBearing = `${BEARINGS[format][1][+SYMBOL_PATTERNS.NEGATIVE_SIGN.test(`${right[0]}`)]}`;
40
- } else {
41
- return [[...left, SYMBOLS.DIVIDER, ...right], false];
42
- }
43
- return [
44
- [
45
- ...left.map(bePositive),
46
- leftBearing,
47
- SYMBOLS.DIVIDER,
48
- ...right.map(bePositive),
49
- rightBearing
50
- ],
51
- false
52
- ];
32
+ const [left, right] = [tokens.slice(0, tokens.indexOf(SYMBOLS.DIVIDER)), tokens.slice(1 + tokens.indexOf(SYMBOLS.DIVIDER))].map(moveBearingsToHead);
33
+ if (bearingConflictsWithNumber(left)) return [[], conflict(left)];
34
+ if (bearingConflictsWithNumber(right)) return [[], conflict(right)];
35
+ const [leftHasBearing, rightHasBearing] = [left, right].map((list) => !!(list?.[0] && SYMBOL_PATTERNS.NSEW.test(list[0])));
36
+ let leftBearing = "";
37
+ let rightBearing = "";
38
+ if (leftHasBearing && rightHasBearing) {
39
+ leftBearing = left.shift() ?? "";
40
+ rightBearing = right.shift() ?? "";
41
+ } else if (leftHasBearing) {
42
+ leftBearing = left.shift() ?? "";
43
+ rightBearing = orthogonal[leftBearing][+SYMBOL_PATTERNS.NEGATIVE_SIGN.test(right[0] ?? "")];
44
+ } else if (rightHasBearing) {
45
+ rightBearing = right.shift() ?? "";
46
+ leftBearing = orthogonal[rightBearing][+SYMBOL_PATTERNS.NEGATIVE_SIGN.test(right[0] ?? "")];
47
+ } else if (format) {
48
+ leftBearing = `${BEARINGS[format][0][+SYMBOL_PATTERNS.NEGATIVE_SIGN.test(`${left[0]}`)]}`;
49
+ rightBearing = `${BEARINGS[format][1][+SYMBOL_PATTERNS.NEGATIVE_SIGN.test(`${right[0]}`)]}`;
50
+ } else return [[
51
+ ...left,
52
+ SYMBOLS.DIVIDER,
53
+ ...right
54
+ ], false];
55
+ return [[
56
+ ...left.map(bePositive),
57
+ leftBearing,
58
+ SYMBOLS.DIVIDER,
59
+ ...right.map(bePositive),
60
+ rightBearing
61
+ ], false];
53
62
  }
63
+ /**
64
+ * Move the bearings indicators to the first element in the list - in this
65
+ * module only - so that it is easier to work with; moving a bearing to the
66
+ * "head" allows for `push()` of subsequent number processing will keep the
67
+ * order of the numeric values intact.
68
+ */
54
69
  function moveBearingsToHead(coord) {
55
- return coord.reduce((acc, t) => {
56
- if (/\d/.test(t)) {
57
- acc.push(t);
58
- } else {
59
- acc.unshift(t);
60
- }
61
- return acc;
62
- }, []);
70
+ return coord.reduce((acc, t) => {
71
+ if (/\d/.test(t)) acc.push(t);
72
+ else acc.unshift(t);
73
+ return acc;
74
+ }, []);
63
75
  }
64
76
 
77
+ //#endregion
65
78
  export { fixBearings };
66
- //# sourceMappingURL=fix-bearings.js.map
67
79
  //# sourceMappingURL=fix-bearings.js.map
@@ -1 +1 @@
1
- {"version":3,"sources":["../../../../../src/coordinates/latlon/internal/pipes/fix-bearings.ts"],"names":[],"mappings":";;AAiBA,MAAM,UAAA,GAAa;AAAA,EACjB,GAAG,QAAA,CAAS,GAAA;AAAA,EACZ,GAAG,QAAA,CAAS,GAAA;AAAA,EACZ,GAAG,QAAA,CAAS,GAAA;AAAA,EACZ,GAAG,QAAA,CAAS;AACd,CAAA;AAEA,MAAM,0BAAA,GAA6B,CAAC,MAAA,KAClC,MAAA,CAAO,CAAC,CAAA,IACR,MAAA,CAAO,CAAC,CAAA,IACR,eAAA,CAAgB,aAAA,CAAc,IAAA,CAAK,MAAA,CAAO,CAAC,CAAC,CAAA,IAC5C,eAAA,CAAgB,IAAA,CAAK,IAAA,CAAK,MAAA,CAAO,CAAC,CAAC,CAAA,IACnC,CAAC,eAAA,CAAgB,iBAAA,CAAkB,IA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AAM,GAAA,CAAI,UAAU,CAAA;AAAA,MACvB;AAAA,KACF;AAAA,IACA;AAAA,GACF;AACF;AAQA,SAAS,mBAAmB,KAAA,EAAe;AACzC,EAAA,OAAO,KAAA,CAAM,MAAA,CAAO,CAAC,GAAA,EAAK,CAAA,KAAM;AAC9B,IAAA,IAAI,IAAA,CAAK,IAAA,CAAK,CAAC,CAAA,EAAG;AAChB,MAAA,GAAA,CAAI,KAAK,CAAC,CAAA;AAAA,IACZ,CAAA,MAAO;AACL,MAAA,GAAA,CAAI,QAAQ,CAAC,CAAA;AAAA,IACf;AAEA,IAAA,OAAO,GAAA;AAAA,EACT,CAAA,EAAG,EAAY,CAAA;AACjB","file":"fix-bearings.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 { BEARINGS, type Format, SYMBOL_PATTERNS, SYMBOLS } from '..';\nimport type { Tokens } from '../lexer';\nimport type { PipeResult } from '../pipes';\n\nconst orthogonal = {\n N: BEARINGS.LON,\n S: BEARINGS.LON,\n E: BEARINGS.LAT,\n W: BEARINGS.LAT,\n};\n\nconst bearingConflictsWithNumber = (tokens: Tokens) =>\n tokens[0] &&\n tokens[1] &&\n SYMBOL_PATTERNS.NEGATIVE_SIGN.test(tokens[1]) &&\n SYMBOL_PATTERNS.NSEW.test(tokens[0]) &&\n !SYMBOL_PATTERNS.NEGATIVE_BEARINGS.test(tokens[0]);\n\nconst bePositive = (n: string) => n.replace(SYMBOL_PATTERNS.NEGATIVE_SIGN, '');\n\nconst conflict = ([a, b]: Tokens) =>\n `Bearing (${a}) conflicts with negative number (${b}).`;\n\n/**\n * Normalize bearings - negative and positive numeric values to NSEW - and\n * positioning of bearings - after the numeric values - and fill in any missing\n * bearings if only one is provided.\n */\nexport function fixBearings(tokens: Tokens, format?: Format): PipeResult {\n const [left, right] = [\n tokens.slice(0, tokens.indexOf(SYMBOLS.DIVIDER)),\n tokens.slice(1 + tokens.indexOf(SYMBOLS.DIVIDER)),\n ].map(moveBearingsToHead) as [Tokens, Tokens];\n\n if (bearingConflictsWithNumber(left)) {\n return [[], conflict(left)];\n }\n\n if (bearingConflictsWithNumber(right)) {\n return [[], conflict(right)];\n }\n\n const [leftHasBearing, rightHasBearing] = [left, right].map(\n (list) => !!(list?.[0] && SYMBOL_PATTERNS.NSEW.test(list[0])),\n );\n\n let leftBearing = '';\n let rightBearing = '';\n\n if (leftHasBearing && rightHasBearing) {\n leftBearing = left.shift() ?? '';\n rightBearing = right.shift() ?? '';\n } else if (leftHasBearing) {\n leftBearing = left.shift() ?? '';\n rightBearing =\n orthogonal[leftBearing as keyof typeof orthogonal][\n +SYMBOL_PATTERNS.NEGATIVE_SIGN.test(right[0] ?? '') as 0 | 1\n ];\n } else if (rightHasBearing) {\n rightBearing = right.shift() ?? '';\n leftBearing =\n orthogonal[rightBearing as keyof typeof orthogonal][\n +SYMBOL_PATTERNS.NEGATIVE_SIGN.test(right[0] ?? '') as 0 | 1\n ];\n } else if (format) {\n leftBearing = `${BEARINGS[format][0][+SYMBOL_PATTERNS.NEGATIVE_SIGN.test(`${left[0]}`)]}`;\n rightBearing = `${BEARINGS[format][1][+SYMBOL_PATTERNS.NEGATIVE_SIGN.test(`${right[0]}`)]}`;\n } else {\n // neither exist\n return [[...left, SYMBOLS.DIVIDER, ...right], false];\n }\n\n return [\n [\n ...left.map(bePositive),\n leftBearing,\n SYMBOLS.DIVIDER,\n ...right.map(bePositive),\n rightBearing,\n ],\n false,\n ];\n}\n\n/**\n * Move the bearings indicators to the first element in the list - in this\n * module only - so that it is easier to work with; moving a bearing to the\n * \"head\" allows for `push()` of subsequent number processing will keep the\n * order of the numeric values intact.\n */\nfunction moveBearingsToHead(coord: Tokens) {\n return coord.reduce((acc, t) => {\n if (/\\d/.test(t)) {\n acc.push(t);\n } else {\n acc.unshift(t);\n }\n\n return acc;\n }, [] as Tokens);\n}\n"]}
1
+ {"version":3,"file":"fix-bearings.js","names":[],"sources":["../../../../../src/coordinates/latlon/internal/pipes/fix-bearings.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 { BEARINGS, type Format, SYMBOL_PATTERNS, SYMBOLS } from '..';\nimport type { Tokens } from '../lexer';\nimport type { PipeResult } from '../pipes';\n\nconst orthogonal = {\n N: BEARINGS.LON,\n S: BEARINGS.LON,\n E: BEARINGS.LAT,\n W: BEARINGS.LAT,\n};\n\nconst bearingConflictsWithNumber = (tokens: Tokens) =>\n tokens[0] &&\n tokens[1] &&\n SYMBOL_PATTERNS.NEGATIVE_SIGN.test(tokens[1]) &&\n SYMBOL_PATTERNS.NSEW.test(tokens[0]) &&\n !SYMBOL_PATTERNS.NEGATIVE_BEARINGS.test(tokens[0]);\n\nconst bePositive = (n: string) => n.replace(SYMBOL_PATTERNS.NEGATIVE_SIGN, '');\n\nconst conflict = ([a, b]: Tokens) =>\n `Bearing (${a}) conflicts with negative number (${b}).`;\n\n/**\n * Normalize bearings - negative and positive numeric values to NSEW - and\n * positioning of bearings - after the numeric values - and fill in any missing\n * bearings if only one is provided.\n */\nexport function fixBearings(tokens: Tokens, format?: Format): PipeResult {\n const [left, right] = [\n tokens.slice(0, tokens.indexOf(SYMBOLS.DIVIDER)),\n tokens.slice(1 + tokens.indexOf(SYMBOLS.DIVIDER)),\n ].map(moveBearingsToHead) as [Tokens, Tokens];\n\n if (bearingConflictsWithNumber(left)) {\n return [[], conflict(left)];\n }\n\n if (bearingConflictsWithNumber(right)) {\n return [[], conflict(right)];\n }\n\n const [leftHasBearing, rightHasBearing] = [left, right].map(\n (list) => !!(list?.[0] && SYMBOL_PATTERNS.NSEW.test(list[0])),\n );\n\n let leftBearing = '';\n let rightBearing = '';\n\n if (leftHasBearing && rightHasBearing) {\n leftBearing = left.shift() ?? '';\n rightBearing = right.shift() ?? '';\n } else if (leftHasBearing) {\n leftBearing = left.shift() ?? '';\n rightBearing =\n orthogonal[leftBearing as keyof typeof orthogonal][\n +SYMBOL_PATTERNS.NEGATIVE_SIGN.test(right[0] ?? '') as 0 | 1\n ];\n } else if (rightHasBearing) {\n rightBearing = right.shift() ?? '';\n leftBearing =\n orthogonal[rightBearing as keyof typeof orthogonal][\n +SYMBOL_PATTERNS.NEGATIVE_SIGN.test(right[0] ?? '') as 0 | 1\n ];\n } else if (format) {\n leftBearing = `${BEARINGS[format][0][+SYMBOL_PATTERNS.NEGATIVE_SIGN.test(`${left[0]}`)]}`;\n rightBearing = `${BEARINGS[format][1][+SYMBOL_PATTERNS.NEGATIVE_SIGN.test(`${right[0]}`)]}`;\n } else {\n // neither exist\n return [[...left, SYMBOLS.DIVIDER, ...right], false];\n }\n\n return [\n [\n ...left.map(bePositive),\n leftBearing,\n SYMBOLS.DIVIDER,\n ...right.map(bePositive),\n rightBearing,\n ],\n false,\n ];\n}\n\n/**\n * Move the bearings indicators to the first element in the list - in this\n * module only - so that it is easier to work with; moving a bearing to the\n * \"head\" allows for `push()` of subsequent number processing will keep the\n * order of the numeric values intact.\n */\nfunction moveBearingsToHead(coord: Tokens) {\n return coord.reduce((acc, t) => {\n if (/\\d/.test(t)) {\n acc.push(t);\n } else {\n acc.unshift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AO,IAAI;AAChC,gBACE,WAAW,cACT,CAAC,gBAAgB,cAAc,KAAK,MAAM,MAAM,GAAG;YAE9C,QAAQ;AACjB,gBAAc,GAAG,SAAS,QAAQ,GAAG,CAAC,gBAAgB,cAAc,KAAK,GAAG,KAAK,KAAK;AACtF,iBAAe,GAAG,SAAS,QAAQ,GAAG,CAAC,gBAAgB,cAAc,KAAK,GAAG,MAAM,KAAK;OAGxF,QAAO,CAAC;EAAC,GAAG;EAAM,QAAQ;EAAS,GAAG;EAAM,EAAE,MAAM;AAGtD,QAAO,CACL;EACE,GAAG,KAAK,IAAI,WAAW;EACvB;EACA,QAAQ;EACR,GAAG,MAAM,IAAI,WAAW;EACxB;EACD,EACD,MACD;;;;;;;;AASH,SAAS,mBAAmB,OAAe;AACzC,QAAO,MAAM,QAAQ,KAAK,MAAM;AAC9B,MAAI,KAAK,KAAK,EAAE,CACd,KAAI,KAAK,EAAE;MAEX,KAAI,QAAQ,EAAE;AAGhB,SAAO;IACN,EAAE,CAAW"}
@@ -1,7 +1,20 @@
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
+ */
4
12
 
13
+ import { Format } from "../index.js";
14
+ import { Tokens } from "../lexer.js";
15
+ import { PipeResult } from "./index.js";
16
+
17
+ //#region src/coordinates/latlon/internal/pipes/fix-dividers.d.ts
5
18
  /**
6
19
  * For tokens lists without a divider, `fixDivider` attempts to determine the
7
20
  * __safe__ location to add a divider based on the existing formatting of the
@@ -11,5 +24,6 @@ import { PipeResult } from './index.js';
11
24
  * pure function
12
25
  */
13
26
  declare function fixDivider(original: Tokens, _format?: Format): PipeResult;
14
-
27
+ //#endregion
15
28
  export { fixDivider };
29
+ //# sourceMappingURL=fix-dividers.d.ts.map
@@ -1,33 +1,50 @@
1
- import { SYMBOLS } from '../index.js';
2
- import { getGenomeIndex } from './genome.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 } from "../index.js";
15
+ import { simpler } from "./simpler.js";
16
+ import { getGenomeIndex } from "./genome.js";
17
+
18
+ //#region src/coordinates/latlon/internal/pipes/fix-dividers.ts
5
19
  const SIMPLER_PATTERNS = {
6
- NN: 1,
7
- NNB: 1,
8
- BNNB: 2,
9
- BNN: 2
20
+ NN: 1,
21
+ NNB: 1,
22
+ BNNB: 2,
23
+ BNN: 2
10
24
  };
11
- const insertDivider = (tokens, index) => [
12
- [...tokens.slice(0, index), SYMBOLS.DIVIDER, ...tokens.slice(index)],
13
- false
14
- ];
25
+ const insertDivider = (tokens, index) => [[
26
+ ...tokens.slice(0, index),
27
+ SYMBOLS.DIVIDER,
28
+ ...tokens.slice(index)
29
+ ], false];
30
+ /**
31
+ * For tokens lists without a divider, `fixDivider` attempts to determine the
32
+ * __safe__ location to add a divider based on the existing formatting of the
33
+ * coordinate: numbers, number positions, and number indicators.
34
+ *
35
+ * @remarks
36
+ * pure function
37
+ */
15
38
  function fixDivider(original, _format) {
16
- if (original.includes(SYMBOLS.DIVIDER)) {
17
- return [original, false];
18
- }
19
- const tokens = original.slice(0);
20
- const genomeIndex = getGenomeIndex(tokens);
21
- if (genomeIndex) {
22
- return insertDivider(tokens, genomeIndex);
23
- }
24
- const simple = simpler(tokens);
25
- if (SIMPLER_PATTERNS[simple]) {
26
- return insertDivider(tokens, SIMPLER_PATTERNS[simple]);
27
- }
28
- return [[], true];
39
+ if (original.includes(SYMBOLS.DIVIDER)) return [original, false];
40
+ const tokens = original.slice(0);
41
+ const genomeIndex = getGenomeIndex(tokens);
42
+ if (genomeIndex) return insertDivider(tokens, genomeIndex);
43
+ const simple = simpler(tokens);
44
+ if (SIMPLER_PATTERNS[simple]) return insertDivider(tokens, SIMPLER_PATTERNS[simple]);
45
+ return [[], true];
29
46
  }
30
47
 
48
+ //#endregion
31
49
  export { fixDivider };
32
- //# sourceMappingURL=fix-dividers.js.map
33
50
  //# sourceMappingURL=fix-dividers.js.map
@@ -1 +1 @@
1
- {"version":3,"sources":["../../../../../src/coordinates/latlon/internal/pipes/fix-dividers.ts"],"names":[],"mappings":";;;;AAqBA,MAAM,gBAAA,GAAmB;AAAA,EACvB,EAAA,EAAI,CAAA;AAAA,EACJ,GAAA,EAAK,CAAA;AAAA,EACL,IAAA,EAAM,CAAA;AAAA,EACN,GAAA,EAAK;AACP,CAAA;AAEA,MAAM,aAAA,GAAgB,CAAC,MAAA,EAAgB,KAAA,KAA8B;AAAA,EACnE,CAAC,GAAG,MAAA,CAAO,KAAA,CAAM,CAAA,EAAG,KAAK,CAAA,EAAG,OAAA,CAAQ,OAAA,EAAS,GAAG,MAAA,CAAO,KAAA,CAAM,KAAK,CAAC,CAAA;AAAA,EACnE;AACF,CAAA;AAUO,SAAS,UAAA,CAAW,UAAkB,OAAA,EAA8B;AAEzE,EAAA,IAAI,QAAA,CAAS,QAAA,CAAS,OAAA,CAAQ,OAAO,CAAA,EAAG;AACtC,IAAA,OAAO,CAAC,UAAU,KAAK,CAAA;AAAA,EACzB;AAGA,EAAA,MAAM,MAAA,GAAS,QAAA,CAAS,KAAA,CAAM,CAAC,CAAA;AAE/B,EAAA,MAAM,WAAA,GAAc,eAAe,MAAM,CAAA;AAEzC,EAAA,IAAI,WAAA,EAAa;AACf,IAAA,OAAO,aAAA,CAAc,QAAQ,WAAW,CAAA;AAAA,EAC1C;AAEA,EAAA,MAAM,MAAA,GAAS,QAAQ,MAAM,CAAA;AAE7B,EAAA,IAAI,gBAAA,CAAiB,MAAM,CAAA,EAAG;AAC5B,IAAA,OAAO,aAAA,CAAc,MAAA,EAAQ,gBAAA,CAAiB,MAAM,CAAC,CAAA;AAAA,EACvD;AAIA,EAAA,OAAO,CAAC,EAAC,EAAG,IAAI,CAAA;AAClB","file":"fix-dividers.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, SYMBOLS } from '..';\nimport { getGenomeIndex } from './genome';\nimport { simpler } from './simpler';\nimport type { Tokens } from '../lexer';\nimport type { PipeResult } from '../pipes';\n\n// N = number\n// B = bearing\nconst SIMPLER_PATTERNS = {\n NN: 1,\n NNB: 1,\n BNNB: 2,\n BNN: 2,\n};\n\nconst insertDivider = (tokens: Tokens, index: number): PipeResult => [\n [...tokens.slice(0, index), SYMBOLS.DIVIDER, ...tokens.slice(index)],\n false,\n];\n\n/**\n * For tokens lists without a divider, `fixDivider` attempts to determine the\n * __safe__ location to add a divider based on the existing formatting of the\n * coordinate: numbers, number positions, and number indicators.\n *\n * @remarks\n * pure function\n */\nexport function fixDivider(original: Tokens, _format?: Format): PipeResult {\n // if there is already a divider then there is nothing to do\n if (original.includes(SYMBOLS.DIVIDER)) {\n return [original, false];\n }\n\n // disconnect from argument memory space so we aren't working on shared memory\n const tokens = original.slice(0);\n\n const genomeIndex = getGenomeIndex(tokens);\n\n if (genomeIndex) {\n return insertDivider(tokens, genomeIndex);\n }\n\n const simple = simpler(tokens) as keyof typeof SIMPLER_PATTERNS;\n\n if (SIMPLER_PATTERNS[simple]) {\n return insertDivider(tokens, SIMPLER_PATTERNS[simple]);\n }\n\n // no position is found to be a safe location to insert a divider; any placement\n // would be a guess and therefor only has a 50% chance of being wrong or right\n return [[], true];\n}\n"]}
1
+ {"version":3,"file":"fix-dividers.js","names":[],"sources":["../../../../../src/coordinates/latlon/internal/pipes/fix-dividers.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, SYMBOLS } from '..';\nimport { getGenomeIndex } from './genome';\nimport { simpler } from './simpler';\nimport type { Tokens } from '../lexer';\nimport type { PipeResult } from '../pipes';\n\n// N = number\n// B = bearing\nconst SIMPLER_PATTERNS = {\n NN: 1,\n NNB: 1,\n BNNB: 2,\n BNN: 2,\n};\n\nconst insertDivider = (tokens: Tokens, index: number): PipeResult => [\n [...tokens.slice(0, index), SYMBOLS.DIVIDER, ...tokens.slice(index)],\n false,\n];\n\n/**\n * For tokens lists without a divider, `fixDivider` attempts to determine the\n * __safe__ location to add a divider based on the existing formatting of the\n * coordinate: numbers, number positions, and number indicators.\n *\n * @remarks\n * pure function\n */\nexport function fixDivider(original: Tokens, _format?: Format): PipeResult {\n // if there is already a divider then there is nothing to do\n if (original.includes(SYMBOLS.DIVIDER)) {\n return [original, false];\n }\n\n // disconnect from argument memory space so we aren't working on shared memory\n const tokens = original.slice(0);\n\n const genomeIndex = getGenomeIndex(tokens);\n\n if (genomeIndex) {\n return insertDivider(tokens, genomeIndex);\n }\n\n const simple = simpler(tokens) as keyof typeof SIMPLER_PATTERNS;\n\n if (SIMPLER_PATTERNS[simple]) {\n return insertDivider(tokens, SIMPLER_PATTERNS[simple]);\n }\n\n // no position is found to be a safe location to insert a divider; any placement\n // would be a guess and therefor only has a 50% chance of being wrong or right\n return [[], true];\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;AAqBA,MAAM,mBAAmB;CACvB,IAAI;CACJ,KAAK;CACL,MAAM;CACN,KAAK;CACN;AAED,MAAM,iBAAiB,QAAgB,UAA8B,CACnE;CAAC,GAAG,OAAO,MAAM,GAAG,MAAM;CAAE,QAAQ;CAAS,GAAG,OAAO,MAAM,MAAM;CAAC,EACpE,MACD;;;;;;;;;AAUD,SAAgB,WAAW,UAAkB,SAA8B;AAEzE,KAAI,SAAS,SAAS,QAAQ,QAAQ,CACpC,QAAO,CAAC,UAAU,MAAM;CAI1B,MAAM,SAAS,SAAS,MAAM,EAAE;CAEhC,MAAM,cAAc,eAAe,OAAO;AAE1C,KAAI,YACF,QAAO,cAAc,QAAQ,YAAY;CAG3C,MAAM,SAAS,QAAQ,OAAO;AAE9B,KAAI,iBAAiB,QACnB,QAAO,cAAc,QAAQ,iBAAiB,QAAQ;AAKxD,QAAO,CAAC,EAAE,EAAE,KAAK"}
@@ -1,9 +1,23 @@
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/genome.d.ts
3
16
  /**
4
17
  * Use the "genome" sequence of the token list to find the index for inserting
5
18
  * a missing divider token.
6
19
  */
7
20
  declare function getGenomeIndex(tokens: Tokens): number;
8
-
21
+ //#endregion
9
22
  export { getGenomeIndex };
23
+ //# sourceMappingURL=genome.d.ts.map
@@ -1,36 +1,57 @@
1
- import { SYMBOLS, SYMBOL_PATTERNS } 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
+
14
+ import { SYMBOLS, SYMBOL_PATTERNS } from "../index.js";
15
+
16
+ //#region src/coordinates/latlon/internal/pipes/genome.ts
3
17
  const GENOME_PATTERN = /^(B?)([DN]?[MN]?[SN]?)(B?)(?:B?)([DN]?[MN]?[SN]?)(?:B?)$/;
18
+ /**
19
+ * Get the position (index) of where to insert a divider into the token list;
20
+ * basically, the count of numeric components (left-of-divider position) plus
21
+ * 1 if there is a bearing identifier (left-of-divider).
22
+ */
4
23
  function dividerIndexer(_full, ...args) {
5
- const [bearing1 = "", number1, bearing2 = "", number2] = args;
6
- if (!(number1?.length && number2?.length)) {
7
- return "0";
8
- }
9
- return `${number1.length + (bearing1.length || bearing2.length)}`;
24
+ const [bearing1 = "", number1, bearing2 = "", number2] = args;
25
+ if (!(number1?.length && number2?.length)) return "0";
26
+ return `${number1.length + (bearing1.length || bearing2.length)}`;
10
27
  }
28
+ /**
29
+ * The genome sequence is a simplification of the tokens list:
30
+ *
31
+ * - B = bearings (NSEW)
32
+ * - D = degrees (number with degree character following)
33
+ * - M = minutes (number with minutes character following)
34
+ * - S = seconds (number with seconds character following)
35
+ * - N = number (no identifying character following)
36
+ * - X = for unmatched token types
37
+ */
11
38
  function genomeSequencer(acc, t) {
12
- if (t.includes(SYMBOLS.DEGREES)) {
13
- return `${acc}D`;
14
- }
15
- if (t.includes(SYMBOLS.MINUTES)) {
16
- return `${acc}M`;
17
- }
18
- if (t.includes(SYMBOLS.SECONDS)) {
19
- return `${acc}S`;
20
- }
21
- if (SYMBOL_PATTERNS.NSEW.test(t)) {
22
- return `${acc}B`;
23
- }
24
- if (/\d/.test(t)) {
25
- return `${acc}N`;
26
- }
27
- return `${acc}X`;
39
+ if (t.includes(SYMBOLS.DEGREES)) return `${acc}D`;
40
+ if (t.includes(SYMBOLS.MINUTES)) return `${acc}M`;
41
+ if (t.includes(SYMBOLS.SECONDS)) return `${acc}S`;
42
+ if (SYMBOL_PATTERNS.NSEW.test(t)) return `${acc}B`;
43
+ if (/\d/.test(t)) return `${acc}N`;
44
+ return `${acc}X`;
28
45
  }
46
+ /**
47
+ * Use the "genome" sequence of the token list to find the index for inserting
48
+ * a missing divider token.
49
+ */
29
50
  function getGenomeIndex(tokens) {
30
- const seq = tokens.reduce(genomeSequencer, "");
31
- return GENOME_PATTERN.test(seq) ? Number.parseInt(seq.replace(GENOME_PATTERN, dividerIndexer), 10) : 0;
51
+ const seq = tokens.reduce(genomeSequencer, "");
52
+ return GENOME_PATTERN.test(seq) ? Number.parseInt(seq.replace(GENOME_PATTERN, dividerIndexer), 10) : 0;
32
53
  }
33
54
 
55
+ //#endregion
34
56
  export { getGenomeIndex };
35
- //# sourceMappingURL=genome.js.map
36
57
  //# sourceMappingURL=genome.js.map
@@ -1 +1 @@
1
- {"version":3,"sources":["../../../../../src/coordinates/latlon/internal/pipes/genome.ts"],"names":[],"mappings":";;AAgBA,MAAM,cAAA,GACJ,0DAAA;AAOF,SAAS,cAAA,CAAe,UAAkB,IAAA,EAAgB;AACxD,EAAA,MAAM,CAAC,QAAA,GAAW,EAAA,EAAI,SAAS,QAAA,GAAW,EAAA,EAAI,OAAO,CAAA,GAAI,IAAA;AAGzD,EAAA,IAAI,EAAE,OAAA,EAAS,MAAA,IAAU,OAAA,EAAS,MAAA,CAAA,EAAS;AACzC,IAAA,OAAO,GAAA;AAAA,EACT;AAEA,EAAA,OAAO,GAAG,OAAA,CAAQ,MAAA,IAAU,QAAA,CAAS,MAAA,IAAU,SAAS,MAAA,CAAO,CAAA,CAAA;AACjE;AAYA,SAAS,eAAA,CAAgB,KAAa,CAAA,EAAW;AAC/C,EAAA,IAAI,CAAA,CAAE,QAAA,CAAS,OAAA,CAAQ,OAAO,CAAA,EAAG;AAC/B,IAAA,OAAO,GAAG,GAAG,CAAA,CAAA,CAAA;AAAA,EACf;AAEA,EAAA,IAAI,CAAA,CAAE,QAAA,CAAS,OAAA,CAAQ,OAAO,CAAA,EAAG;AAC/B,IAAA,OAAO,GAAG,GAAG,CAAA,CAAA,CAAA;AAAA,EACf;AAEA,EAAA,IAAI,CAAA,CAAE,QAAA,CAAS,OAAA,CAAQ,OAAO,CAAA,EAAG;AAC/B,IAAA,OAAO,GAAG,GAAG,CAAA,CAAA,CAAA;AAAA,EACf;AAEA,EAAA,IAAI,eAAA,CAAgB,IAAA,CAAK,IAAA,CAAK,CAAC,CAAA,EAAG;AAChC,IAAA,OAAO,GAAG,GAAG,CAAA,CAAA,CAAA;AAAA,EACf;AAEA,EAAA,IAAI,IAAA,CAAK,IAAA,CAAK,CAAC,CAAA,EAAG;AAChB,IAAA,OAAO,GAAG,GAAG,CAAA,CAAA,CAAA;AAAA,EACf;AAEA,EAAA,OAAO,GAAG,GAAG,CAAA,CAAA,CAAA;AACf;AAMO,SAAS,eAAe,MAAA,EAAgB;AAC7C,EAAA,MAAM,GAAA,GAAM,MAAA,CAAO,MAAA,CAAO,eAAA,EAAiB,EAAE,CAAA;AAE7C,EAAA,OAAO,cAAA,CAAe,IAAA,CAAK,GAAG,CAAA,GAC1B,MAAA,CAAO,QAAA,CAAS,GAAA,CAAI,OAAA,CAAQ,cAAA,EAAgB,cAAc,CAAA,EAAG,EAAE,CAAA,GAC/D,CAAA;AACN","file":"genome.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 { SYMBOL_PATTERNS, SYMBOLS } from '..';\nimport type { Tokens } from '../lexer';\n\nconst GENOME_PATTERN =\n /^(B?)([DN]?[MN]?[SN]?)(B?)(?:B?)([DN]?[MN]?[SN]?)(?:B?)$/;\n\n/**\n * Get the position (index) of where to insert a divider into the token list;\n * basically, the count of numeric components (left-of-divider position) plus\n * 1 if there is a bearing identifier (left-of-divider).\n */\nfunction dividerIndexer(_full: string, ...args: string[]) {\n const [bearing1 = '', number1, bearing2 = '', number2] = args;\n\n // if no numeric values exist there no way to infer a location to insert a divider\n if (!(number1?.length && number2?.length)) {\n return '0';\n }\n\n return `${number1.length + (bearing1.length || bearing2.length)}`;\n}\n\n/**\n * The genome sequence is a simplification of the tokens list:\n *\n * - B = bearings (NSEW)\n * - D = degrees (number with degree character following)\n * - M = minutes (number with minutes character following)\n * - S = seconds (number with seconds character following)\n * - N = number (no identifying character following)\n * - X = for unmatched token types\n */\nfunction genomeSequencer(acc: string, t: string) {\n if (t.includes(SYMBOLS.DEGREES)) {\n return `${acc}D`;\n }\n\n if (t.includes(SYMBOLS.MINUTES)) {\n return `${acc}M`;\n }\n\n if (t.includes(SYMBOLS.SECONDS)) {\n return `${acc}S`;\n }\n\n if (SYMBOL_PATTERNS.NSEW.test(t)) {\n return `${acc}B`;\n }\n\n if (/\\d/.test(t)) {\n return `${acc}N`;\n }\n\n return `${acc}X`;\n}\n\n/**\n * Use the \"genome\" sequence of the token list to find the index for inserting\n * a missing divider token.\n */\nexport function getGenomeIndex(tokens: Tokens) {\n const seq = tokens.reduce(genomeSequencer, '');\n\n return GENOME_PATTERN.test(seq)\n ? Number.parseInt(seq.replace(GENOME_PATTERN, dividerIndexer), 10)\n : 0;\n}\n"]}
1
+ {"version":3,"file":"genome.js","names":[],"sources":["../../../../../src/coordinates/latlon/internal/pipes/genome.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 { SYMBOL_PATTERNS, SYMBOLS } from '..';\nimport type { Tokens } from '../lexer';\n\nconst GENOME_PATTERN =\n /^(B?)([DN]?[MN]?[SN]?)(B?)(?:B?)([DN]?[MN]?[SN]?)(?:B?)$/;\n\n/**\n * Get the position (index) of where to insert a divider into the token list;\n * basically, the count of numeric components (left-of-divider position) plus\n * 1 if there is a bearing identifier (left-of-divider).\n */\nfunction dividerIndexer(_full: string, ...args: string[]) {\n const [bearing1 = '', number1, bearing2 = '', number2] = args;\n\n // if no numeric values exist there no way to infer a location to insert a divider\n if (!(number1?.length && number2?.length)) {\n return '0';\n }\n\n return `${number1.length + (bearing1.length || bearing2.length)}`;\n}\n\n/**\n * The genome sequence is a simplification of the tokens list:\n *\n * - B = bearings (NSEW)\n * - D = degrees (number with degree character following)\n * - M = minutes (number with minutes character following)\n * - S = seconds (number with seconds character following)\n * - N = number (no identifying character following)\n * - X = for unmatched token types\n */\nfunction genomeSequencer(acc: string, t: string) {\n if (t.includes(SYMBOLS.DEGREES)) {\n return `${acc}D`;\n }\n\n if (t.includes(SYMBOLS.MINUTES)) {\n return `${acc}M`;\n }\n\n if (t.includes(SYMBOLS.SECONDS)) {\n return `${acc}S`;\n }\n\n if (SYMBOL_PATTERNS.NSEW.test(t)) {\n return `${acc}B`;\n }\n\n if (/\\d/.test(t)) {\n return `${acc}N`;\n }\n\n return `${acc}X`;\n}\n\n/**\n * Use the \"genome\" sequence of the token list to find the index for inserting\n * a missing divider token.\n */\nexport function getGenomeIndex(tokens: Tokens) {\n const seq = tokens.reduce(genomeSequencer, '');\n\n return GENOME_PATTERN.test(seq)\n ? Number.parseInt(seq.replace(GENOME_PATTERN, dividerIndexer), 10)\n : 0;\n}\n"],"mappings":";;;;;;;;;;;;;;;;AAgBA,MAAM,iBACJ;;;;;;AAOF,SAAS,eAAe,OAAe,GAAG,MAAgB;CACxD,MAAM,CAAC,WAAW,IAAI,SAAS,WAAW,IAAI,WAAW;AAGzD,KAAI,EAAE,SAAS,UAAU,SAAS,QAChC,QAAO;AAGT,QAAO,GAAG,QAAQ,UAAU,SAAS,UAAU,SAAS;;;;;;;;;;;;AAa1D,SAAS,gBAAgB,KAAa,GAAW;AAC/C,KAAI,EAAE,SAAS,QAAQ,QAAQ,CAC7B,QAAO,GAAG,IAAI;AAGhB,KAAI,EAAE,SAAS,QAAQ,QAAQ,CAC7B,QAAO,GAAG,IAAI;AAGhB,KAAI,EAAE,SAAS,QAAQ,QAAQ,CAC7B,QAAO,GAAG,IAAI;AAGhB,KAAI,gBAAgB,KAAK,KAAK,EAAE,CAC9B,QAAO,GAAG,IAAI;AAGhB,KAAI,KAAK,KAAK,EAAE,CACd,QAAO,GAAG,IAAI;AAGhB,QAAO,GAAG,IAAI;;;;;;AAOhB,SAAgB,eAAe,QAAgB;CAC7C,MAAM,MAAM,OAAO,OAAO,iBAAiB,GAAG;AAE9C,QAAO,eAAe,KAAK,IAAI,GAC3B,OAAO,SAAS,IAAI,QAAQ,gBAAgB,eAAe,EAAE,GAAG,GAChE"}
@@ -1,6 +1,19 @@
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
+ */
3
12
 
13
+ import { Format } from "../index.js";
14
+ import { Tokens } from "../lexer.js";
15
+
16
+ //#region src/coordinates/latlon/internal/pipes/index.d.ts
4
17
  type Pipe = (t: Tokens, f?: Format) => [Tokens, boolean | string];
5
18
  type PipeResult = ReturnType<Pipe>;
6
19
  /**
@@ -20,5 +33,6 @@ declare const pipesResult: (t: Tokens, e: boolean | string) => PipeResult;
20
33
  * violations that could be misleading or hide the most important violation
21
34
  */
22
35
  declare function pipesRunner(tokens: Tokens, format?: Format): [Tokens, string[]];
23
-
24
- export { type PipeResult, pipesResult, pipesRunner };
36
+ //#endregion
37
+ export { PipeResult, pipesResult, pipesRunner };
38
+ //# sourceMappingURL=index.d.ts.map
@@ -1,45 +1,68 @@
1
- import { SYMBOL_PATTERNS } from '../index.js';
2
- import { checkAmbiguousGrouping } from './check-ambiguous.js';
3
- import { checkNumberValues } from './check-numbers.js';
4
- import { fixBearings } from './fix-bearings.js';
5
- import { fixDivider } from './fix-dividers.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
+ */
6
12
 
13
+
14
+ import { SYMBOL_PATTERNS } from "../index.js";
15
+ import { checkAmbiguousGrouping } from "./check-ambiguous.js";
16
+ import { checkNumberValues } from "./check-numbers.js";
17
+ import { fixBearings } from "./fix-bearings.js";
18
+ import { fixDivider } from "./fix-dividers.js";
19
+
20
+ //#region src/coordinates/latlon/internal/pipes/index.ts
21
+ /** Make a RegExp global. */
7
22
  const makeGlobal = (k) => new RegExp(SYMBOL_PATTERNS[k], "g");
8
- const pipesResult = (t, e) => [
9
- // if there are errors do NOT return the tokens
10
- e ? [] : t,
11
- e
12
- ];
23
+ /**
24
+ * Consistently create a PipesResult array to return. Use this instead of
25
+ * casting to PipesResult everywhere.
26
+ *
27
+ * @param e true = has error, false = no error
28
+ *
29
+ * @remarks
30
+ * pure function
31
+ */
32
+ const pipesResult = (t, e) => [e ? [] : t, e];
33
+ /** Check if there are more than 2 of something. */
13
34
  const tooMany = (p) => (t) => pipesResult(t, (t.join("").match(p) ?? []).length > 2);
14
35
  const pipes = [
15
- // Unrecoverable violations
16
- ["Too many bearings.", tooMany(makeGlobal("NSEW"))],
17
- ["Too many numeric signs.", tooMany(/[-+]/g)],
18
- ["Too many degrees indicators.", tooMany(makeGlobal("DEGREES"))],
19
- ["Too many minutes indicators.", tooMany(makeGlobal("MINUTES"))],
20
- ["Too many seconds indicators.", tooMany(makeGlobal("SECONDS"))],
21
- ["Number values checks.", checkNumberValues],
22
- ["Ambiguous grouping of numbers with no divider.", checkAmbiguousGrouping],
23
- // fix values and formatting to be consistent
24
- ["Unable to identify latitude from longitude.", fixDivider],
25
- ["Unable to identify bearings.", fixBearings]
36
+ ["Too many bearings.", tooMany(makeGlobal("NSEW"))],
37
+ ["Too many numeric signs.", tooMany(/[-+]/g)],
38
+ ["Too many degrees indicators.", tooMany(makeGlobal("DEGREES"))],
39
+ ["Too many minutes indicators.", tooMany(makeGlobal("MINUTES"))],
40
+ ["Too many seconds indicators.", tooMany(makeGlobal("SECONDS"))],
41
+ ["Number values checks.", checkNumberValues],
42
+ ["Ambiguous grouping of numbers with no divider.", checkAmbiguousGrouping],
43
+ ["Unable to identify latitude from longitude.", fixDivider],
44
+ ["Unable to identify bearings.", fixBearings]
26
45
  ];
46
+ /**
47
+ * Run the tokens through a preset pipeline of violations checks exiting the
48
+ * process as early as possible when violations are found because violations
49
+ * will make further violations checks less accurate and could return inaccurate
50
+ * violations that could be misleading or hide the most important violation
51
+ */
27
52
  function pipesRunner(tokens, format) {
28
- let copy = tokens.slice(0);
29
- let error = false;
30
- const errors = [];
31
- for (const [message, op] of pipes) {
32
- [copy, error] = op(copy, format);
33
- if (error) {
34
- errors.push(error === true ? message : error);
35
- if (!copy.length) {
36
- return [copy, [error === true ? message : error]];
37
- }
38
- }
39
- }
40
- return [copy, errors];
53
+ let copy = tokens.slice(0);
54
+ let error = false;
55
+ const errors = [];
56
+ for (const [message, op] of pipes) {
57
+ [copy, error] = op(copy, format);
58
+ if (error) {
59
+ errors.push(error === true ? message : error);
60
+ if (!copy.length) return [copy, [error === true ? message : error]];
61
+ }
62
+ }
63
+ return [copy, errors];
41
64
  }
42
65
 
66
+ //#endregion
43
67
  export { pipesResult, pipesRunner };
44
- //# sourceMappingURL=index.js.map
45
68
  //# sourceMappingURL=index.js.map
@@ -1 +1 @@
1
- {"version":3,"sources":["../../../../../src/coordinates/lat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,OAAA,EAAS,EAAE,CAAA,IAAK,KAAA,EAAO;AACjC,IAAA,CAAC,IAAA,EAAM,KAAK,CAAA,GAAI,EAAA,CAAG,MAAM,MAAM,CAAA;AAE/B,IAAA,IAAI,KAAA,EAAO;AAGT,MAAA,MAAA,CAAO,IAAA,CAAK,KAAA,KAAU,IAAA,GAAO,OAAA,GAAU,KAAK,CAAA;AAE5C,MAAA,IAAI,CAAC,KAAK,MAAA,EAAQ;AAChB,QAAA,OAAO,CAAC,IAAA,EAAM,CAAC,UAAU,IAAA,GAAO,OAAA,GAAU,KAAK,CAAC,CAAA;AAAA,MAClD;AAAA,IACF;AAAA,EACF;AAEA,EAAA,OAAO,CAAC,MAAM,MAAM,CAAA;AACtB","file":"index.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 } from '..';\nimport { checkAmbiguousGrouping } from './check-ambiguous';\nimport { checkNumberValues } from './check-numbers';\nimport { fixBearings } from './fix-bearings';\nimport { fixDivider } from './fix-dividers';\nimport type { Tokens } from '../lexer';\n\ntype Pipe = (t: Tokens, f?: Format) => [Tokens, boolean | string];\n\nexport type PipeResult = ReturnType<Pipe>;\n\n/** Make a RegExp global. */\nconst makeGlobal = (k: keyof typeof SYMBOL_PATTERNS) =>\n new RegExp(SYMBOL_PATTERNS[k], 'g');\n\n/**\n * Consistently create a PipesResult array to return. Use this instead of\n * casting to PipesResult everywhere.\n *\n * @param e true = has error, false = no error\n *\n * @remarks\n * pure function\n */\nexport const pipesResult = (t: Tokens, e: boolean | string): PipeResult => [\n // if there are errors do NOT return the tokens\n e ? [] : t,\n e,\n];\n\n/** Check if there are more than 2 of something. */\nconst tooMany = (p: RegExp) => (t: Tokens) =>\n pipesResult(t, (t.join('').match(p) ?? []).length > 2);\n\nconst pipes: [string, Pipe][] = [\n // Unrecoverable violations\n ['Too many bearings.', tooMany(makeGlobal('NSEW'))],\n ['Too many numeric signs.', tooMany(/[-+]/g)],\n ['Too many degrees indicators.', tooMany(makeGlobal('DEGREES'))],\n ['Too many minutes indicators.', tooMany(makeGlobal('MINUTES'))],\n ['Too many seconds indicators.', tooMany(makeGlobal('SECONDS'))],\n ['Number values checks.', checkNumberValues],\n ['Ambiguous grouping of numbers with no divider.', checkAmbiguousGrouping],\n\n // fix values and formatting to be consistent\n ['Unable to identify latitude from longitude.', fixDivider],\n ['Unable to identify bearings.', fixBearings],\n];\n\n/**\n * Run the tokens through a preset pipeline of violations checks exiting the\n * process as early as possible when violations are found because violations\n * will make further violations checks less accurate and could return inaccurate\n * violations that could be misleading or hide the most important violation\n */\nexport function pipesRunner(\n tokens: Tokens,\n format?: Format,\n): [Tokens, string[]] {\n let copy = tokens.slice(0);\n let error: PipeResult[1] = false;\n const errors = [] as string[];\n\n for (const [message, op] of pipes) {\n [copy, error] = op(copy, format);\n\n if (error) {\n // accumulate the \"errors\" because if tokens are returned\n // the errors are only warnings and are recoverable\n errors.push(error === true ? message : error);\n\n if (!copy.length) {\n return [copy, [error === true ? message : error]];\n }\n }\n }\n\n return [copy, errors];\n}\n"]}
1
+ {"version":3,"file":"index.js","names":["pipes: [string, Pipe][]","error: PipeResult[1]"],"sources":["../../../../../src/coordinates/latlon/internal/pipes/index.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 } from '..';\nimport { checkAmbiguousGrouping } from './check-ambiguous';\nimport { checkNumberValues } from './check-numbers';\nimport { fixBearings } from './fix-bearings';\nimport { fixDivider } from './fix-dividers';\nimport type { Tokens } from '../lexer';\n\ntype Pipe = (t: Tokens, f?: Format) => [Tokens, boolean | string];\n\nexport type PipeResult = ReturnType<Pipe>;\n\n/** Make a RegExp global. */\nconst makeGlobal = (k: keyof typeof SYMBOL_PATTERNS) =>\n new RegExp(SYMBOL_PATTERNS[k], 'g');\n\n/**\n * Consistently create a PipesResult array to return. Use this instead of\n * casting to PipesResult everywhere.\n *\n * @param e true = has error, false = no error\n *\n * @remarks\n * pure function\n */\nexport const pipesResult = (t: Tokens, e: boolean | string): PipeResult => [\n // if there are errors do NOT return the tokens\n e ? [] : t,\n e,\n];\n\n/** Check if there are more than 2 of something. */\nconst tooMany = (p: RegExp) => (t: Tokens) =>\n pipesResult(t, (t.join('').match(p) ?? []).length > 2);\n\nconst pipes: [string, Pipe][] = [\n // Unrecoverable violations\n ['Too many bearings.', tooMany(makeGlobal('NSEW'))],\n ['Too many numeric signs.', tooMany(/[-+]/g)],\n ['Too many degrees indicators.', tooMany(makeGlobal('DEGREES'))],\n ['Too many minutes indicators.', tooMany(makeGlobal('MINUTES'))],\n ['Too many seconds indicators.', tooMany(makeGlobal('SECONDS'))],\n ['Number values checks.', checkNumberValues],\n ['Ambiguous grouping of numbers with no divider.', checkAmbiguousGrouping],\n\n // fix values and formatting to be consistent\n ['Unable to identify latitude from longitude.', fixDivider],\n ['Unable to identify bearings.', fixBearings],\n];\n\n/**\n * Run the tokens through a preset pipeline of violations checks exiting the\n * process as early as possible when violations are found because violations\n * will make further violations checks less accurate and could return inaccurate\n * violations that could be misleading or hide the most important violation\n */\nexport function pipesRunner(\n tokens: Tokens,\n format?: Format,\n): [Tokens, string[]] {\n let copy = tokens.slice(0);\n let error: PipeResult[1] = false;\n const errors = [] as string[];\n\n for (const [message, op] of pipes) {\n [copy, error] = op(copy, format);\n\n if (error) {\n // accumulate the \"errors\" because if tokens are returned\n // the errors are only warnings and are recoverable\n errors.push(error === true ? message : error);\n\n if (!copy.length) {\n return [copy, [error === true ? message : error]];\n }\n }\n }\n\n return [copy, errors];\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;AAyBA,MAAM,cAAc,MAClB,IAAI,OAAO,gBAAgB,IAAI,IAAI;;;;;;;;;;AAWrC,MAAa,eAAe,GAAW,MAAoC,CAEzE,IAAI,EAAE,GAAG,GACT,EACD;;AAGD,MAAM,WAAW,OAAe,MAC9B,YAAY,IAAI,EAAE,KAAK,GAAG,CAAC,MAAM,EAAE,IAAI,EAAE,EAAE,SAAS,EAAE;AAExD,MAAMA,QAA0B;CAE9B,CAAC,sBAAsB,QAAQ,WAAW,OAAO,CAAC,CAAC;CACnD,CAAC,2BAA2B,QAAQ,QAAQ,CAAC;CAC7C,CAAC,gCAAgC,QAAQ,WAAW,UAAU,CAAC,CAAC;CAChE,CAAC,gCAAgC,QAAQ,WAAW,UAAU,CAAC,CAAC;CAChE,CAAC,gCAAgC,QAAQ,WAAW,UAAU,CAAC,CAAC;CAChE,CAAC,yBAAyB,kBAAkB;CAC5C,CAAC,kDAAkD,uBAAuB;CAG1E,CAAC,+CAA+C,WAAW;CAC3D,CAAC,gCAAgC,YAAY;CAC9C;;;;;;;AAQD,SAAgB,YACd,QACA,QACoB;CACpB,IAAI,OAAO,OAAO,MAAM,EAAE;CAC1B,IAAIC,QAAuB;CAC3B,MAAM,SAAS,EAAE;AAEjB,MAAK,MAAM,CAAC,SAAS,OAAO,OAAO;AACjC,GAAC,MAAM,SAAS,GAAG,MAAM,OAAO;AAEhC,MAAI,OAAO;AAGT,UAAO,KAAK,UAAU,OAAO,UAAU,MAAM;AAE7C,OAAI,CAAC,KAAK,OACR,QAAO,CAAC,MAAM,CAAC,UAAU,OAAO,UAAU,MAAM,CAAC;;;AAKvD,QAAO,CAAC,MAAM,OAAO"}
@@ -1,5 +1,18 @@
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
+ */
2
12
 
13
+ import { Tokens } from "../lexer.js";
14
+
15
+ //#region src/coordinates/latlon/internal/pipes/simpler.d.ts
3
16
  /**
4
17
  * Create a simplified pattern string - numbers = 'N', bearings = 'B' - to
5
18
  * allow for simpler pattern matching.
@@ -11,5 +24,6 @@ import { Tokens } from '../lexer.js';
11
24
  * simplify(tokens); // 'NNNBNNNB' or similar
12
25
  */
13
26
  declare const simpler: (tokens: Tokens) => string;
14
-
27
+ //#endregion
15
28
  export { simpler };
29
+ //# sourceMappingURL=simpler.d.ts.map