@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.
- package/CHANGELOG.md +13 -0
- package/catalog-info.yaml +2 -4
- package/dist/cartesian.d.ts +3 -1
- package/dist/cartesian.js +34 -5
- package/dist/cartesian.js.map +1 -1
- package/dist/coordinates/coordinate.d.ts +37 -25
- package/dist/coordinates/coordinate.js +71 -77
- package/dist/coordinates/coordinate.js.map +1 -1
- package/dist/coordinates/latlon/decimal-degrees/formatter.d.ts +16 -2
- package/dist/coordinates/latlon/decimal-degrees/formatter.js +17 -3
- package/dist/coordinates/latlon/decimal-degrees/formatter.js.map +1 -1
- package/dist/coordinates/latlon/decimal-degrees/parser.d.ts +17 -4
- package/dist/coordinates/latlon/decimal-degrees/parser.js +60 -62
- package/dist/coordinates/latlon/decimal-degrees/parser.js.map +1 -1
- package/dist/coordinates/latlon/decimal-degrees/system.d.ts +16 -5
- package/dist/coordinates/latlon/decimal-degrees/system.js +26 -14
- package/dist/coordinates/latlon/decimal-degrees/system.js.map +1 -1
- package/dist/coordinates/latlon/degrees-decimal-minutes/formatter.d.ts +16 -2
- package/dist/coordinates/latlon/degrees-decimal-minutes/formatter.js +19 -8
- package/dist/coordinates/latlon/degrees-decimal-minutes/formatter.js.map +1 -1
- package/dist/coordinates/latlon/degrees-decimal-minutes/parser.d.ts +17 -4
- package/dist/coordinates/latlon/degrees-decimal-minutes/parser.js +79 -71
- package/dist/coordinates/latlon/degrees-decimal-minutes/parser.js.map +1 -1
- package/dist/coordinates/latlon/degrees-decimal-minutes/system.d.ts +16 -5
- package/dist/coordinates/latlon/degrees-decimal-minutes/system.js +30 -19
- package/dist/coordinates/latlon/degrees-decimal-minutes/system.js.map +1 -1
- package/dist/coordinates/latlon/degrees-minutes-seconds/formatter.d.ts +16 -2
- package/dist/coordinates/latlon/degrees-minutes-seconds/formatter.js +21 -10
- package/dist/coordinates/latlon/degrees-minutes-seconds/formatter.js.map +1 -1
- package/dist/coordinates/latlon/degrees-minutes-seconds/parser.d.ts +17 -4
- package/dist/coordinates/latlon/degrees-minutes-seconds/parser.js +81 -70
- package/dist/coordinates/latlon/degrees-minutes-seconds/parser.js.map +1 -1
- package/dist/coordinates/latlon/degrees-minutes-seconds/system.d.ts +16 -5
- package/dist/coordinates/latlon/degrees-minutes-seconds/system.js +32 -21
- package/dist/coordinates/latlon/degrees-minutes-seconds/system.js.map +1 -1
- package/dist/coordinates/latlon/internal/coordinate-system.d.ts +22 -9
- package/dist/coordinates/latlon/internal/coordinate-system.js +11 -2
- package/dist/coordinates/latlon/internal/create-cache.d.ts +17 -3
- package/dist/coordinates/latlon/internal/create-cache.js +27 -7
- package/dist/coordinates/latlon/internal/create-cache.js.map +1 -1
- package/dist/coordinates/latlon/internal/exhaustive-errors.d.ts +4 -2
- package/dist/coordinates/latlon/internal/exhaustive-errors.js +107 -62
- package/dist/coordinates/latlon/internal/exhaustive-errors.js.map +1 -1
- package/dist/coordinates/latlon/internal/format.d.ts +8 -6
- package/dist/coordinates/latlon/internal/format.js +24 -11
- package/dist/coordinates/latlon/internal/format.js.map +1 -1
- package/dist/coordinates/latlon/internal/in-range.d.ts +3 -1
- package/dist/coordinates/latlon/internal/in-range.js +22 -8
- package/dist/coordinates/latlon/internal/in-range.js.map +1 -1
- package/dist/coordinates/latlon/internal/index.d.ts +35 -33
- package/dist/coordinates/latlon/internal/index.js +64 -102
- package/dist/coordinates/latlon/internal/index.js.map +1 -1
- package/dist/coordinates/latlon/internal/lexer.d.ts +4 -2
- package/dist/coordinates/latlon/internal/lexer.js +54 -33
- package/dist/coordinates/latlon/internal/lexer.js.map +1 -1
- package/dist/coordinates/latlon/internal/ordinal.d.ts +3 -1
- package/dist/coordinates/latlon/internal/ordinal.js +17 -5
- package/dist/coordinates/latlon/internal/ordinal.js.map +1 -1
- package/dist/coordinates/latlon/internal/parse-format.d.ts +23 -10
- package/dist/coordinates/latlon/internal/parse-format.js +37 -54
- package/dist/coordinates/latlon/internal/parse-format.js.map +1 -1
- package/dist/coordinates/latlon/internal/parse.d.ts +18 -4
- package/dist/coordinates/latlon/internal/parse.js +55 -9
- package/dist/coordinates/latlon/internal/parse.js.map +1 -1
- package/dist/coordinates/latlon/internal/pipes/check-ambiguous.d.ts +17 -3
- package/dist/coordinates/latlon/internal/pipes/check-ambiguous.js +31 -16
- package/dist/coordinates/latlon/internal/pipes/check-ambiguous.js.map +1 -1
- package/dist/coordinates/latlon/internal/pipes/check-numbers.d.ts +16 -2
- package/dist/coordinates/latlon/internal/pipes/check-numbers.js +30 -28
- package/dist/coordinates/latlon/internal/pipes/check-numbers.js.map +1 -1
- package/dist/coordinates/latlon/internal/pipes/fix-bearings.d.ts +18 -4
- package/dist/coordinates/latlon/internal/pipes/fix-bearings.js +66 -54
- package/dist/coordinates/latlon/internal/pipes/fix-bearings.js.map +1 -1
- package/dist/coordinates/latlon/internal/pipes/fix-dividers.d.ts +18 -4
- package/dist/coordinates/latlon/internal/pipes/fix-dividers.js +42 -25
- package/dist/coordinates/latlon/internal/pipes/fix-dividers.js.map +1 -1
- package/dist/coordinates/latlon/internal/pipes/genome.d.ts +16 -2
- package/dist/coordinates/latlon/internal/pipes/genome.js +46 -25
- package/dist/coordinates/latlon/internal/pipes/genome.js.map +1 -1
- package/dist/coordinates/latlon/internal/pipes/index.d.ts +18 -4
- package/dist/coordinates/latlon/internal/pipes/index.js +58 -35
- package/dist/coordinates/latlon/internal/pipes/index.js.map +1 -1
- package/dist/coordinates/latlon/internal/pipes/simpler.d.ts +16 -2
- package/dist/coordinates/latlon/internal/pipes/simpler.js +25 -1
- package/dist/coordinates/latlon/internal/pipes/simpler.js.map +1 -1
- package/dist/coordinates/latlon/internal/violation.d.ts +3 -1
- package/dist/coordinates/latlon/internal/violation.js +15 -1
- package/dist/coordinates/latlon/internal/violation.js.map +1 -1
- package/dist/coordinates/mgrs/parser.d.ts +16 -4
- package/dist/coordinates/mgrs/parser.js +32 -35
- package/dist/coordinates/mgrs/parser.js.map +1 -1
- package/dist/coordinates/mgrs/system.d.ts +16 -5
- package/dist/coordinates/mgrs/system.js +28 -18
- package/dist/coordinates/mgrs/system.js.map +1 -1
- package/dist/coordinates/utm/parser.d.ts +16 -4
- package/dist/coordinates/utm/parser.js +32 -30
- package/dist/coordinates/utm/parser.js.map +1 -1
- package/dist/coordinates/utm/system.d.ts +16 -5
- package/dist/coordinates/utm/system.js +29 -23
- package/dist/coordinates/utm/system.js.map +1 -1
- package/dist/index.d.ts +24 -15
- package/dist/index.js +26 -13
- package/dist/patterning.d.ts +3 -1
- package/dist/patterning.js +75 -11
- package/dist/patterning.js.map +1 -1
- package/package.json +77 -42
- package/dist/coordinates/latlon/internal/coordinate-system.js.map +0 -1
- package/dist/index.js.map +0 -1
- 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
|
-
|
|
3
|
-
|
|
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,"
|
|
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
|
-
|
|
2
|
-
|
|
3
|
-
|
|
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
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
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
|
-
|
|
2
|
-
|
|
3
|
-
|
|
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
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
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,"
|
|
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
|
-
|
|
2
|
-
|
|
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 {
|
|
53
|
+
//#endregion
|
|
54
|
+
export { ParseResults, parse };
|
|
55
|
+
//# sourceMappingURL=parse.d.ts.map
|
|
@@ -1,15 +1,61 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
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
|
-
|
|
7
|
-
|
|
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,"
|
|
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
|
-
|
|
2
|
-
|
|
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
|
-
|
|
2
|
-
|
|
3
|
-
|
|
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
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
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,"
|
|
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
|
-
|
|
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
|
-
|
|
2
|
-
|
|
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
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
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,"
|
|
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
|
-
|
|
2
|
-
|
|
3
|
-
|
|
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
|