@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 +1 @@
|
|
|
1
|
-
{"version":3,"
|
|
1
|
+
{"version":3,"file":"parser.js","names":["Patterning.fromTemplate","isNegative: 0 | 1"],"sources":["../../../../src/coordinates/latlon/decimal-degrees/parser.ts"],"sourcesContent":["/*\n * Copyright 2024 Hypergiant Galactic Systems Inc. All rights reserved.\n * This file is licensed to you under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License. You may obtain a copy\n * of the License at https://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software distributed under\n * the License is distributed on an \"AS IS\" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS\n * OF ANY KIND, either express or implied. See the License for the specific language\n * governing permissions and limitations under the License.\n */\n\nimport * as Patterning from '@/patterning';\nimport {\n BEARINGS,\n type Format,\n LIMITS,\n PARTIAL_PATTERNS,\n SYMBOL_PATTERNS,\n SYMBOLS,\n} from '../internal';\nimport { createParser } from '../internal/parse-format';\nimport type { ParseResults } from '../internal/parse';\n\ntype DecimalDegrees = {\n bear: string;\n deg: string;\n};\n\nconst checks = {\n deg: (deg: string, limit: number) => {\n if (Number.parseFloat(deg) > limit) {\n return `Degrees value (${deg}) exceeds max value (${limit}).`;\n }\n },\n min: (val: string) => {\n if (val.includes(SYMBOLS.MINUTES)) {\n return `Seconds indicator (${SYMBOLS.MINUTES}) not valid in Decimal Degrees.`;\n }\n },\n sec: (val: string) => {\n if (val.includes(SYMBOLS.SECONDS)) {\n return `Seconds indicator (${SYMBOLS.SECONDS}) not valid in Decimal Degrees.`;\n }\n },\n};\n\nconst formats = {\n LATLON: Patterning.fromTemplate(\n PARTIAL_PATTERNS,\n `degLatDec NS ${SYMBOLS.DIVIDER} degLonDec EW`,\n ),\n LONLAT: Patterning.fromTemplate(\n PARTIAL_PATTERNS,\n `degLonDec EW ${SYMBOLS.DIVIDER} degLatDec NS`,\n ),\n};\n\nfunction identifyErrors(format: Format) {\n return (arg: DecimalDegrees | undefined, i: number) => {\n if (!arg) {\n return [[], ['Invalid coordinate value.']] as ParseResults;\n }\n\n let { bear, deg } = arg;\n\n deg ??= '0';\n\n let isNegative: 0 | 1 = SYMBOL_PATTERNS.NEGATIVE_SIGN.test(deg) ? 1 : 0;\n const bearingOptions = BEARINGS[format][i] as [string, string];\n\n if (!bear || isNegative) {\n bear = bearingOptions[isNegative];\n deg = Math.abs(Number.parseFloat(deg)).toString();\n isNegative = 0;\n }\n\n const errors = [\n ...[checks.deg(deg, LIMITS[format][i] ?? 0)],\n ...[checks.min([bear, deg].join(''))],\n ...[checks.sec([bear, deg].join(''))],\n ].filter(Boolean);\n\n return (errors.length ? [[], errors] : [[deg, bear], []]) as ParseResults;\n };\n}\n\nfunction identifyPieces(half: string[]) {\n if (half.length > 2 || half.length < 1) {\n return;\n }\n\n const places = { bear: '', deg: '' };\n\n return half.reduce((acc, token) => {\n if (SYMBOL_PATTERNS.NSEW.test(token) && !acc.bear) {\n acc.bear ||= token;\n } else {\n acc.deg ||= token;\n }\n\n return acc;\n }, places);\n}\n\n/** Parse a Decimal Degrees coordinate. */\nexport const parseDecimalDegrees = createParser<DecimalDegrees>({\n formats,\n identifyErrors,\n identifyPieces,\n});\n"],"mappings":";;;;;;;;;;;;;;;;;;AA6BA,MAAM,SAAS;CACb,MAAM,KAAa,UAAkB;AACnC,MAAI,OAAO,WAAW,IAAI,GAAG,MAC3B,QAAO,kBAAkB,IAAI,uBAAuB,MAAM;;CAG9D,MAAM,QAAgB;AACpB,MAAI,IAAI,SAAS,QAAQ,QAAQ,CAC/B,QAAO,sBAAsB,QAAQ,QAAQ;;CAGjD,MAAM,QAAgB;AACpB,MAAI,IAAI,SAAS,QAAQ,QAAQ,CAC/B,QAAO,sBAAsB,QAAQ,QAAQ;;CAGlD;AAED,MAAM,UAAU;CACd,QAAQA,aACN,kBACA,gBAAgB,QAAQ,QAAQ,eACjC;CACD,QAAQA,aACN,kBACA,gBAAgB,QAAQ,QAAQ,eACjC;CACF;AAED,SAAS,eAAe,QAAgB;AACtC,SAAQ,KAAiC,MAAc;AACrD,MAAI,CAAC,IACH,QAAO,CAAC,EAAE,EAAE,CAAC,4BAA4B,CAAC;EAG5C,IAAI,EAAE,MAAM,QAAQ;AAEpB,UAAQ;EAER,IAAIC,aAAoB,gBAAgB,cAAc,KAAK,IAAI,GAAG,IAAI;EACtE,MAAM,iBAAiB,SAAS,QAAQ;AAExC,MAAI,CAAC,QAAQ,YAAY;AACvB,UAAO,eAAe;AACtB,SAAM,KAAK,IAAI,OAAO,WAAW,IAAI,CAAC,CAAC,UAAU;AACjD,gBAAa;;EAGf,MAAM,SAAS;GACb,GAAG,CAAC,OAAO,IAAI,KAAK,OAAO,QAAQ,MAAM,EAAE,CAAC;GAC5C,GAAG,CAAC,OAAO,IAAI,CAAC,MAAM,IAAI,CAAC,KAAK,GAAG,CAAC,CAAC;GACrC,GAAG,CAAC,OAAO,IAAI,CAAC,MAAM,IAAI,CAAC,KAAK,GAAG,CAAC,CAAC;GACtC,CAAC,OAAO,QAAQ;AAEjB,SAAQ,OAAO,SAAS,CAAC,EAAE,EAAE,OAAO,GAAG,CAAC,CAAC,KAAK,KAAK,EAAE,EAAE,CAAC;;;AAI5D,SAAS,eAAe,MAAgB;AACtC,KAAI,KAAK,SAAS,KAAK,KAAK,SAAS,EACnC;AAKF,QAAO,KAAK,QAAQ,KAAK,UAAU;AACjC,MAAI,gBAAgB,KAAK,KAAK,MAAM,IAAI,CAAC,IAAI,KAC3C,KAAI,SAAS;MAEb,KAAI,QAAQ;AAGd,SAAO;IATM;EAAE,MAAM;EAAI,KAAK;EAAI,CAU1B;;;AAIZ,MAAa,sBAAsB,aAA6B;CAC9D;CACA;CACA;CACD,CAAC"}
|
|
@@ -1,8 +1,19 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
1
|
+
/*
|
|
2
|
+
* Copyright 2025 Hypergiant Galactic Systems Inc. All rights reserved.
|
|
3
|
+
* This file is licensed to you under the Apache License, Version 2.0 (the "License");
|
|
4
|
+
* you may not use this file except in compliance with the License. You may obtain a copy
|
|
5
|
+
* of the License at https://www.apache.org/licenses/LICENSE-2.0
|
|
6
|
+
*
|
|
7
|
+
* Unless required by applicable law or agreed to in writing, software distributed under
|
|
8
|
+
* the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS
|
|
9
|
+
* OF ANY KIND, either express or implied. See the License for the specific language
|
|
10
|
+
* governing permissions and limitations under the License.
|
|
11
|
+
*/
|
|
5
12
|
|
|
6
|
-
|
|
13
|
+
import { CoordinateSystem } from "../internal/coordinate-system.js";
|
|
7
14
|
|
|
15
|
+
//#region src/coordinates/latlon/decimal-degrees/system.d.ts
|
|
16
|
+
declare const systemDecimalDegrees: CoordinateSystem;
|
|
17
|
+
//#endregion
|
|
8
18
|
export { systemDecimalDegrees };
|
|
19
|
+
//# sourceMappingURL=system.d.ts.map
|
|
@@ -1,20 +1,32 @@
|
|
|
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 { BEARINGS, SYMBOLS, SYMBOL_PATTERNS } from "../internal/index.js";
|
|
15
|
+
import { parseDecimalDegrees } from "./parser.js";
|
|
16
|
+
|
|
17
|
+
//#region src/coordinates/latlon/decimal-degrees/system.ts
|
|
4
18
|
const systemDecimalDegrees = {
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
).join(` ${SYMBOLS.DIVIDER} `);
|
|
15
|
-
}
|
|
19
|
+
name: "Decimal Degrees",
|
|
20
|
+
parse: parseDecimalDegrees,
|
|
21
|
+
toFloat(arg) {
|
|
22
|
+
const [num, bear] = arg;
|
|
23
|
+
return Number.parseFloat(num) * (SYMBOL_PATTERNS.NEGATIVE_BEARINGS.test(bear) ? -1 : 1);
|
|
24
|
+
},
|
|
25
|
+
toFormat(format, [left, right]) {
|
|
26
|
+
return [left, right].map((num, index) => `${Math.abs(num)} ${BEARINGS[format][index][+(num < 0)]}`).join(` ${SYMBOLS.DIVIDER} `);
|
|
27
|
+
}
|
|
16
28
|
};
|
|
17
29
|
|
|
30
|
+
//#endregion
|
|
18
31
|
export { systemDecimalDegrees };
|
|
19
|
-
//# sourceMappingURL=system.js.map
|
|
20
32
|
//# sourceMappingURL=system.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"
|
|
1
|
+
{"version":3,"file":"system.js","names":["systemDecimalDegrees: CoordinateSystem"],"sources":["../../../../src/coordinates/latlon/decimal-degrees/system.ts"],"sourcesContent":["// __private-exports\n/*\n * Copyright 2024 Hypergiant Galactic Systems Inc. All rights reserved.\n * This file is licensed to you under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License. You may obtain a copy\n * of the License at https://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software distributed under\n * the License is distributed on an \"AS IS\" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS\n * OF ANY KIND, either express or implied. See the License for the specific language\n * governing permissions and limitations under the License.\n */\n\nimport {\n BEARINGS,\n type Compass,\n type Format,\n SYMBOL_PATTERNS,\n SYMBOLS,\n} from '../internal';\nimport { parseDecimalDegrees } from './parser';\nimport type { CoordinateSystem } from '../internal/coordinate-system';\n\nexport const systemDecimalDegrees: CoordinateSystem = {\n name: 'Decimal Degrees',\n\n parse: parseDecimalDegrees,\n\n toFloat(arg) {\n const [num, bear] = arg as [string, Compass];\n\n return (\n Number.parseFloat(num) *\n (SYMBOL_PATTERNS.NEGATIVE_BEARINGS.test(bear) ? -1 : 1)\n );\n },\n\n toFormat(format: Format, [left, right]: [number, number]) {\n return [left, right]\n .map(\n (num, index) =>\n `${Math.abs(num)} ${BEARINGS[format][index as 0 | 1][+(num < 0)]}`,\n )\n .join(` ${SYMBOLS.DIVIDER} `);\n },\n};\n"],"mappings":";;;;;;;;;;;;;;;;;AAuBA,MAAaA,uBAAyC;CACpD,MAAM;CAEN,OAAO;CAEP,QAAQ,KAAK;EACX,MAAM,CAAC,KAAK,QAAQ;AAEpB,SACE,OAAO,WAAW,IAAI,IACrB,gBAAgB,kBAAkB,KAAK,KAAK,GAAG,KAAK;;CAIzD,SAAS,QAAgB,CAAC,MAAM,QAA0B;AACxD,SAAO,CAAC,MAAM,MAAM,CACjB,KACE,KAAK,UACJ,GAAG,KAAK,IAAI,IAAI,CAAC,GAAG,SAAS,QAAQ,OAAgB,EAAE,MAAM,MAChE,CACA,KAAK,IAAI,QAAQ,QAAQ,GAAG;;CAElC"}
|
|
@@ -1,5 +1,19 @@
|
|
|
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
|
+
*/
|
|
2
12
|
|
|
3
|
-
|
|
13
|
+
import { FormatOptions } from "../internal/format.js";
|
|
4
14
|
|
|
15
|
+
//#region src/coordinates/latlon/degrees-decimal-minutes/formatter.d.ts
|
|
16
|
+
declare const formatDegreesDecimalMinutes: (coordinates: [number, number], config?: FormatOptions) => string;
|
|
17
|
+
//#endregion
|
|
5
18
|
export { formatDegreesDecimalMinutes };
|
|
19
|
+
//# sourceMappingURL=formatter.d.ts.map
|
|
@@ -1,14 +1,25 @@
|
|
|
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
|
+
*/
|
|
2
12
|
|
|
13
|
+
|
|
14
|
+
import { createFormatter } from "../internal/format.js";
|
|
15
|
+
|
|
16
|
+
//#region src/coordinates/latlon/degrees-decimal-minutes/formatter.ts
|
|
3
17
|
const toDegreesDecimalMinutes = (num) => {
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
return `${degrees}\xB0 ${minutes}'`;
|
|
18
|
+
const degrees = Math.floor(Math.abs(num));
|
|
19
|
+
return `${degrees}° ${((Math.abs(num) - degrees) * 60).toFixed(4)}'`;
|
|
7
20
|
};
|
|
8
|
-
const formatDegreesDecimalMinutes = createFormatter(
|
|
9
|
-
toDegreesDecimalMinutes
|
|
10
|
-
);
|
|
21
|
+
const formatDegreesDecimalMinutes = createFormatter(toDegreesDecimalMinutes);
|
|
11
22
|
|
|
23
|
+
//#endregion
|
|
12
24
|
export { formatDegreesDecimalMinutes };
|
|
13
|
-
//# sourceMappingURL=formatter.js.map
|
|
14
25
|
//# sourceMappingURL=formatter.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../../src/coordinates/latlon/degrees-decimal-minutes/formatter.ts"],"
|
|
1
|
+
{"version":3,"file":"formatter.js","names":[],"sources":["../../../../src/coordinates/latlon/degrees-decimal-minutes/formatter.ts"],"sourcesContent":["/*\n * Copyright 2025 Hypergiant Galactic Systems Inc. All rights reserved.\n * This file is licensed to you under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License. You may obtain a copy\n * of the License at https://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software distributed under\n * the License is distributed on an \"AS IS\" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS\n * OF ANY KIND, either express or implied. See the License for the specific language\n * governing permissions and limitations under the License.\n */\n\nimport { createFormatter } from '../internal/format';\n\nconst toDegreesDecimalMinutes = (num: number): string => {\n const degrees = Math.floor(Math.abs(num));\n const minutes = ((Math.abs(num) - degrees) * 60).toFixed(4);\n\n return `${degrees}° ${minutes}'`;\n};\n\nexport const formatDegreesDecimalMinutes = createFormatter(\n toDegreesDecimalMinutes,\n);\n"],"mappings":";;;;;;;;;;;;;;;;AAcA,MAAM,2BAA2B,QAAwB;CACvD,MAAM,UAAU,KAAK,MAAM,KAAK,IAAI,IAAI,CAAC;AAGzC,QAAO,GAAG,QAAQ,MAFA,KAAK,IAAI,IAAI,GAAG,WAAW,IAAI,QAAQ,EAAE,CAE7B;;AAGhC,MAAa,8BAA8B,gBACzC,wBACD"}
|
|
@@ -1,8 +1,21 @@
|
|
|
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 "../internal/index.js";
|
|
14
|
+
import { ParseResults } from "../internal/parse.js";
|
|
15
|
+
|
|
16
|
+
//#region src/coordinates/latlon/degrees-decimal-minutes/parser.d.ts
|
|
5
17
|
/** Parse a Degrees Decimal Minutes coordinate. */
|
|
6
18
|
declare const parseDegreesDecimalMinutes: (format: Format, input: string) => ParseResults;
|
|
7
|
-
|
|
19
|
+
//#endregion
|
|
8
20
|
export { parseDegreesDecimalMinutes };
|
|
21
|
+
//# sourceMappingURL=parser.d.ts.map
|
|
@@ -1,85 +1,93 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
1
|
+
/*
|
|
2
|
+
* Copyright 2025 Hypergiant Galactic Systems Inc. All rights reserved.
|
|
3
|
+
* This file is licensed to you under the Apache License, Version 2.0 (the "License");
|
|
4
|
+
* you may not use this file except in compliance with the License. You may obtain a copy
|
|
5
|
+
* of the License at https://www.apache.org/licenses/LICENSE-2.0
|
|
6
|
+
*
|
|
7
|
+
* Unless required by applicable law or agreed to in writing, software distributed under
|
|
8
|
+
* the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS
|
|
9
|
+
* OF ANY KIND, either express or implied. See the License for the specific language
|
|
10
|
+
* governing permissions and limitations under the License.
|
|
11
|
+
*/
|
|
5
12
|
|
|
13
|
+
|
|
14
|
+
import { fromTemplate } from "../../../patterning.js";
|
|
15
|
+
import { BEARINGS, LIMITS, PARTIAL_PATTERNS, SYMBOLS, SYMBOL_PATTERNS } from "../internal/index.js";
|
|
16
|
+
import { createParser } from "../internal/parse-format.js";
|
|
17
|
+
import { inRange } from "../internal/in-range.js";
|
|
18
|
+
|
|
19
|
+
//#region src/coordinates/latlon/degrees-decimal-minutes/parser.ts
|
|
6
20
|
const checks = {
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
min: (min) => inRange("Minutes", min, 59.999999999),
|
|
16
|
-
sec: (val) => {
|
|
17
|
-
if (val.includes(SYMBOLS.SECONDS)) {
|
|
18
|
-
return `Seconds indicator (${SYMBOLS.SECONDS}) not valid in Degree Decimal Minutes.`;
|
|
19
|
-
}
|
|
20
|
-
}
|
|
21
|
+
deg: (deg, limit) => {
|
|
22
|
+
if (Number.parseFloat(deg) > limit) return `Degrees value (${deg}) exceeds max value (${limit}).`;
|
|
23
|
+
if (/\./.test(deg)) return `Degrees value (${deg}) must not include decimal value.`;
|
|
24
|
+
},
|
|
25
|
+
min: (min) => inRange("Minutes", min, 59.999999999),
|
|
26
|
+
sec: (val) => {
|
|
27
|
+
if (val.includes(SYMBOLS.SECONDS)) return `Seconds indicator (${SYMBOLS.SECONDS}) not valid in Degree Decimal Minutes.`;
|
|
28
|
+
}
|
|
21
29
|
};
|
|
22
30
|
const formats = {
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
`degLat minDec NS ${SYMBOLS.DIVIDER} degLon minDec EW`
|
|
26
|
-
),
|
|
27
|
-
LONLAT: Patterning.fromTemplate(
|
|
28
|
-
PARTIAL_PATTERNS,
|
|
29
|
-
`degLon minDec EW ${SYMBOLS.DIVIDER} degLat minDec NS`
|
|
30
|
-
)
|
|
31
|
+
LATLON: fromTemplate(PARTIAL_PATTERNS, `degLat minDec NS ${SYMBOLS.DIVIDER} degLon minDec EW`),
|
|
32
|
+
LONLAT: fromTemplate(PARTIAL_PATTERNS, `degLon minDec EW ${SYMBOLS.DIVIDER} degLat minDec NS`)
|
|
31
33
|
};
|
|
32
34
|
function identifyErrors(format) {
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
35
|
+
return (arg, i) => {
|
|
36
|
+
if (!arg) return [[], ["Invalid coordinate value."]];
|
|
37
|
+
let { bear, deg, min } = arg;
|
|
38
|
+
deg ??= "0";
|
|
39
|
+
min ??= "0";
|
|
40
|
+
let isNegative = SYMBOL_PATTERNS.NEGATIVE_SIGN.test(deg) ? 1 : 0;
|
|
41
|
+
const bearingOptions = BEARINGS[format][i];
|
|
42
|
+
if (!bear || isNegative) {
|
|
43
|
+
bear = bearingOptions[isNegative];
|
|
44
|
+
deg = Math.abs(Number.parseFloat(deg)).toString();
|
|
45
|
+
isNegative = 0;
|
|
46
|
+
}
|
|
47
|
+
const errors = [
|
|
48
|
+
...[checks.deg(deg, LIMITS[format][i] ?? 0)],
|
|
49
|
+
...[checks.min(min)],
|
|
50
|
+
...[checks.sec([
|
|
51
|
+
bear,
|
|
52
|
+
deg,
|
|
53
|
+
min
|
|
54
|
+
].join(""))]
|
|
55
|
+
].filter(Boolean);
|
|
56
|
+
return errors.length ? [[], errors] : [[
|
|
57
|
+
deg,
|
|
58
|
+
min,
|
|
59
|
+
bear
|
|
60
|
+
], []];
|
|
61
|
+
};
|
|
54
62
|
}
|
|
55
63
|
function identifyPieces(half) {
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
}, places);
|
|
64
|
+
if (half.length < 1 || half.length > 3) return;
|
|
65
|
+
const asString = half.join(" ");
|
|
66
|
+
const places = {
|
|
67
|
+
bear: "",
|
|
68
|
+
deg: "",
|
|
69
|
+
min: ""
|
|
70
|
+
};
|
|
71
|
+
const keys = ["deg", "min"];
|
|
72
|
+
const test = (r, b, v) => r.test(v) || r.test(asString) && b;
|
|
73
|
+
return half.reduce((acc, token, i, { length }) => {
|
|
74
|
+
if (test(SYMBOL_PATTERNS.NSEW, i === length - 1, token)) acc.bear ||= token;
|
|
75
|
+
else if (test(SYMBOL_PATTERNS.DEGREES, i === 0, token)) acc.deg ||= token;
|
|
76
|
+
else if (test(SYMBOL_PATTERNS.MINUTES, i === 1, token)) acc.min ||= token;
|
|
77
|
+
else {
|
|
78
|
+
const key = keys.find((k) => !acc[k]);
|
|
79
|
+
acc[key] = token;
|
|
80
|
+
}
|
|
81
|
+
return acc;
|
|
82
|
+
}, places);
|
|
76
83
|
}
|
|
84
|
+
/** Parse a Degrees Decimal Minutes coordinate. */
|
|
77
85
|
const parseDegreesDecimalMinutes = createParser({
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
86
|
+
formats,
|
|
87
|
+
identifyErrors,
|
|
88
|
+
identifyPieces
|
|
81
89
|
});
|
|
82
90
|
|
|
91
|
+
//#endregion
|
|
83
92
|
export { parseDegreesDecimalMinutes };
|
|
84
|
-
//# sourceMappingURL=parser.js.map
|
|
85
93
|
//# sourceMappingURL=parser.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"
|
|
1
|
+
{"version":3,"file":"parser.js","names":["Patterning.fromTemplate","isNegative: 0 | 1"],"sources":["../../../../src/coordinates/latlon/degrees-decimal-minutes/parser.ts"],"sourcesContent":["/*\n * Copyright 2024 Hypergiant Galactic Systems Inc. All rights reserved.\n * This file is licensed to you under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License. You may obtain a copy\n * of the License at https://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software distributed under\n * the License is distributed on an \"AS IS\" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS\n * OF ANY KIND, either express or implied. See the License for the specific language\n * governing permissions and limitations under the License.\n */\n\nimport * as Patterning from '@/patterning';\nimport {\n BEARINGS,\n type Format,\n LIMITS,\n PARTIAL_PATTERNS,\n SYMBOL_PATTERNS,\n SYMBOLS,\n} from '../internal';\nimport { inRange } from '../internal/in-range';\nimport { createParser } from '../internal/parse-format';\nimport type { ParseResults } from '../internal/parse';\n\ntype DegreesDecimalMinutes = {\n bear: string;\n deg: string;\n min: string;\n};\n\nconst checks = {\n deg: (deg: string, limit: number) => {\n if (Number.parseFloat(deg) > limit) {\n return `Degrees value (${deg}) exceeds max value (${limit}).`;\n }\n\n if (/\\./.test(deg)) {\n return `Degrees value (${deg}) must not include decimal value.`;\n }\n },\n min: (min: string) => inRange('Minutes', min, 59.999999999),\n sec: (val: string) => {\n if (val.includes(SYMBOLS.SECONDS)) {\n return `Seconds indicator (${SYMBOLS.SECONDS}) not valid in Degree Decimal Minutes.`;\n }\n },\n};\n\nconst formats = {\n LATLON: Patterning.fromTemplate(\n PARTIAL_PATTERNS,\n `degLat minDec NS ${SYMBOLS.DIVIDER} degLon minDec EW`,\n ),\n LONLAT: Patterning.fromTemplate(\n PARTIAL_PATTERNS,\n `degLon minDec EW ${SYMBOLS.DIVIDER} degLat minDec NS`,\n ),\n};\n\nfunction identifyErrors(format: Format) {\n return (arg: DegreesDecimalMinutes | undefined, i: number) => {\n if (!arg) {\n return [[], ['Invalid coordinate value.']] as ParseResults;\n }\n\n let { bear, deg, min } = arg;\n\n deg ??= '0';\n min ??= '0';\n\n let isNegative: 0 | 1 = SYMBOL_PATTERNS.NEGATIVE_SIGN.test(deg) ? 1 : 0;\n const bearingOptions = BEARINGS[format][i] as [string, string];\n\n if (!bear || isNegative) {\n bear = bearingOptions[isNegative];\n deg = Math.abs(Number.parseFloat(deg)).toString();\n isNegative = 0;\n }\n\n const errors = [\n ...[checks.deg(deg, LIMITS[format][i] ?? 0)],\n ...[checks.min(min)],\n ...[checks.sec([bear, deg, min].join(''))],\n ].filter(Boolean);\n\n return (\n errors.length ? [[], errors] : [[deg, min, bear], []]\n ) as ParseResults;\n };\n}\n\nfunction identifyPieces(half: string[]) {\n if (half.length < 1 || half.length > 3) {\n return;\n }\n\n const asString = half.join(' ');\n const places = { bear: '', deg: '', min: '' };\n const keys = ['deg', 'min'] as (keyof typeof places)[];\n const test = (r: RegExp, b: boolean, v: string) =>\n r.test(v) || (r.test(asString) && b);\n\n return half.reduce((acc, token, i, { length }) => {\n if (test(SYMBOL_PATTERNS.NSEW, i === length - 1, token)) {\n acc.bear ||= token;\n } else if (test(SYMBOL_PATTERNS.DEGREES, i === 0, token)) {\n acc.deg ||= token;\n } else if (test(SYMBOL_PATTERNS.MINUTES, i === 1, token)) {\n acc.min ||= token;\n } else {\n const key = keys.find((k) => !acc[k]);\n\n acc[key as keyof typeof acc] = token;\n }\n\n return acc;\n }, places);\n}\n\n/** Parse a Degrees Decimal Minutes coordinate. */\nexport const parseDegreesDecimalMinutes = createParser<DegreesDecimalMinutes>({\n formats,\n identifyErrors,\n identifyPieces,\n});\n"],"mappings":";;;;;;;;;;;;;;;;;;;AA+BA,MAAM,SAAS;CACb,MAAM,KAAa,UAAkB;AACnC,MAAI,OAAO,WAAW,IAAI,GAAG,MAC3B,QAAO,kBAAkB,IAAI,uBAAuB,MAAM;AAG5D,MAAI,KAAK,KAAK,IAAI,CAChB,QAAO,kBAAkB,IAAI;;CAGjC,MAAM,QAAgB,QAAQ,WAAW,KAAK,aAAa;CAC3D,MAAM,QAAgB;AACpB,MAAI,IAAI,SAAS,QAAQ,QAAQ,CAC/B,QAAO,sBAAsB,QAAQ,QAAQ;;CAGlD;AAED,MAAM,UAAU;CACd,QAAQA,aACN,kBACA,oBAAoB,QAAQ,QAAQ,mBACrC;CACD,QAAQA,aACN,kBACA,oBAAoB,QAAQ,QAAQ,mBACrC;CACF;AAED,SAAS,eAAe,QAAgB;AACtC,SAAQ,KAAwC,MAAc;AAC5D,MAAI,CAAC,IACH,QAAO,CAAC,EAAE,EAAE,CAAC,4BAA4B,CAAC;EAG5C,IAAI,EAAE,MAAM,KAAK,QAAQ;AAEzB,UAAQ;AACR,UAAQ;EAER,IAAIC,aAAoB,gBAAgB,cAAc,KAAK,IAAI,GAAG,IAAI;EACtE,MAAM,iBAAiB,SAAS,QAAQ;AAExC,MAAI,CAAC,QAAQ,YAAY;AACvB,UAAO,eAAe;AACtB,SAAM,KAAK,IAAI,OAAO,WAAW,IAAI,CAAC,CAAC,UAAU;AACjD,gBAAa;;EAGf,MAAM,SAAS;GACb,GAAG,CAAC,OAAO,IAAI,KAAK,OAAO,QAAQ,MAAM,EAAE,CAAC;GAC5C,GAAG,CAAC,OAAO,IAAI,IAAI,CAAC;GACpB,GAAG,CAAC,OAAO,IAAI;IAAC;IAAM;IAAK;IAAI,CAAC,KAAK,GAAG,CAAC,CAAC;GAC3C,CAAC,OAAO,QAAQ;AAEjB,SACE,OAAO,SAAS,CAAC,EAAE,EAAE,OAAO,GAAG,CAAC;GAAC;GAAK;GAAK;GAAK,EAAE,EAAE,CAAC;;;AAK3D,SAAS,eAAe,MAAgB;AACtC,KAAI,KAAK,SAAS,KAAK,KAAK,SAAS,EACnC;CAGF,MAAM,WAAW,KAAK,KAAK,IAAI;CAC/B,MAAM,SAAS;EAAE,MAAM;EAAI,KAAK;EAAI,KAAK;EAAI;CAC7C,MAAM,OAAO,CAAC,OAAO,MAAM;CAC3B,MAAM,QAAQ,GAAW,GAAY,MACnC,EAAE,KAAK,EAAE,IAAK,EAAE,KAAK,SAAS,IAAI;AAEpC,QAAO,KAAK,QAAQ,KAAK,OAAO,GAAG,EAAE,aAAa;AAChD,MAAI,KAAK,gBAAgB,MAAM,MAAM,SAAS,GAAG,MAAM,CACrD,KAAI,SAAS;WACJ,KAAK,gBAAgB,SAAS,MAAM,GAAG,MAAM,CACtD,KAAI,QAAQ;WACH,KAAK,gBAAgB,SAAS,MAAM,GAAG,MAAM,CACtD,KAAI,QAAQ;OACP;GACL,MAAM,MAAM,KAAK,MAAM,MAAM,CAAC,IAAI,GAAG;AAErC,OAAI,OAA2B;;AAGjC,SAAO;IACN,OAAO;;;AAIZ,MAAa,6BAA6B,aAAoC;CAC5E;CACA;CACA;CACD,CAAC"}
|
|
@@ -1,8 +1,19 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
1
|
+
/*
|
|
2
|
+
* Copyright 2025 Hypergiant Galactic Systems Inc. All rights reserved.
|
|
3
|
+
* This file is licensed to you under the Apache License, Version 2.0 (the "License");
|
|
4
|
+
* you may not use this file except in compliance with the License. You may obtain a copy
|
|
5
|
+
* of the License at https://www.apache.org/licenses/LICENSE-2.0
|
|
6
|
+
*
|
|
7
|
+
* Unless required by applicable law or agreed to in writing, software distributed under
|
|
8
|
+
* the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS
|
|
9
|
+
* OF ANY KIND, either express or implied. See the License for the specific language
|
|
10
|
+
* governing permissions and limitations under the License.
|
|
11
|
+
*/
|
|
5
12
|
|
|
6
|
-
|
|
13
|
+
import { CoordinateSystem } from "../internal/coordinate-system.js";
|
|
7
14
|
|
|
15
|
+
//#region src/coordinates/latlon/degrees-decimal-minutes/system.d.ts
|
|
16
|
+
declare const systemDegreesDecimalMinutes: CoordinateSystem;
|
|
17
|
+
//#endregion
|
|
8
18
|
export { systemDegreesDecimalMinutes };
|
|
19
|
+
//# sourceMappingURL=system.d.ts.map
|
|
@@ -1,25 +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 { BEARINGS, SYMBOLS, SYMBOL_PATTERNS } from "../internal/index.js";
|
|
15
|
+
import { parseDegreesDecimalMinutes } from "./parser.js";
|
|
16
|
+
|
|
17
|
+
//#region src/coordinates/latlon/degrees-decimal-minutes/system.ts
|
|
4
18
|
const systemDegreesDecimalMinutes = {
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
return `${deg} ${min} ${BEARINGS[format][index][+(num < 0)]}`;
|
|
19
|
-
}).join(` ${SYMBOLS.DIVIDER} `);
|
|
20
|
-
}
|
|
19
|
+
name: "Degrees Decimal Minutes",
|
|
20
|
+
parse: parseDegreesDecimalMinutes,
|
|
21
|
+
toFloat(arg) {
|
|
22
|
+
const [degrees, minutes, bear] = arg;
|
|
23
|
+
return Number.parseFloat(((Number.parseFloat(degrees) + Number.parseFloat(minutes) / 60) * (SYMBOL_PATTERNS.NEGATIVE_BEARINGS.test(bear) ? -1 : 1)).toFixed(9));
|
|
24
|
+
},
|
|
25
|
+
toFormat(format, [left, right]) {
|
|
26
|
+
return [left, right].map((num, index) => {
|
|
27
|
+
const abs = Math.abs(num);
|
|
28
|
+
const deg = Math.floor(abs);
|
|
29
|
+
return `${deg} ${Number.parseFloat(((abs - deg) * 60).toFixed(9))} ${BEARINGS[format][index][+(num < 0)]}`;
|
|
30
|
+
}).join(` ${SYMBOLS.DIVIDER} `);
|
|
31
|
+
}
|
|
21
32
|
};
|
|
22
33
|
|
|
34
|
+
//#endregion
|
|
23
35
|
export { systemDegreesDecimalMinutes };
|
|
24
|
-
//# sourceMappingURL=system.js.map
|
|
25
36
|
//# sourceMappingURL=system.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../../src/coordinates/latlon/degrees-decimal-minutes/system.ts"],"
|
|
1
|
+
{"version":3,"file":"system.js","names":["systemDegreesDecimalMinutes: CoordinateSystem"],"sources":["../../../../src/coordinates/latlon/degrees-decimal-minutes/system.ts"],"sourcesContent":["// __private-exports\n/*\n * Copyright 2024 Hypergiant Galactic Systems Inc. All rights reserved.\n * This file is licensed to you under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License. You may obtain a copy\n * of the License at https://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software distributed under\n * the License is distributed on an \"AS IS\" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS\n * OF ANY KIND, either express or implied. See the License for the specific language\n * governing permissions and limitations under the License.\n */\n\nimport {\n BEARINGS,\n type Compass,\n type Format,\n SYMBOL_PATTERNS,\n SYMBOLS,\n} from '../internal';\nimport { parseDegreesDecimalMinutes } from './parser';\nimport type { CoordinateSystem } from '../internal/coordinate-system';\n\nexport const systemDegreesDecimalMinutes: CoordinateSystem = {\n name: 'Degrees Decimal Minutes',\n\n parse: parseDegreesDecimalMinutes,\n\n toFloat(arg) {\n const [degrees, minutes, bear] = arg as [string, string, Compass];\n\n return Number.parseFloat(\n (\n (Number.parseFloat(degrees) + Number.parseFloat(minutes) / 60) *\n (SYMBOL_PATTERNS.NEGATIVE_BEARINGS.test(bear) ? -1 : 1)\n ).toFixed(9),\n );\n },\n\n toFormat(format: Format, [left, right]: [number, number]) {\n return [left, right]\n .map((num, index) => {\n const abs = Math.abs(num);\n const deg = Math.floor(abs);\n const min = Number.parseFloat(((abs - deg) * 60).toFixed(9));\n\n return `${deg} ${min} ${BEARINGS[format][index as 0 | 1][+(num < 0)]}`;\n })\n .join(` ${SYMBOLS.DIVIDER} `);\n },\n};\n"],"mappings":";;;;;;;;;;;;;;;;;AAuBA,MAAaA,8BAAgD;CAC3D,MAAM;CAEN,OAAO;CAEP,QAAQ,KAAK;EACX,MAAM,CAAC,SAAS,SAAS,QAAQ;AAEjC,SAAO,OAAO,aAET,OAAO,WAAW,QAAQ,GAAG,OAAO,WAAW,QAAQ,GAAG,OAC1D,gBAAgB,kBAAkB,KAAK,KAAK,GAAG,KAAK,IACrD,QAAQ,EAAE,CACb;;CAGH,SAAS,QAAgB,CAAC,MAAM,QAA0B;AACxD,SAAO,CAAC,MAAM,MAAM,CACjB,KAAK,KAAK,UAAU;GACnB,MAAM,MAAM,KAAK,IAAI,IAAI;GACzB,MAAM,MAAM,KAAK,MAAM,IAAI;AAG3B,UAAO,GAAG,IAAI,GAFF,OAAO,aAAa,MAAM,OAAO,IAAI,QAAQ,EAAE,CAAC,CAEvC,GAAG,SAAS,QAAQ,OAAgB,EAAE,MAAM;IACjE,CACD,KAAK,IAAI,QAAQ,QAAQ,GAAG;;CAElC"}
|
|
@@ -1,5 +1,19 @@
|
|
|
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
|
+
*/
|
|
2
12
|
|
|
3
|
-
|
|
13
|
+
import { FormatOptions } from "../internal/format.js";
|
|
4
14
|
|
|
15
|
+
//#region src/coordinates/latlon/degrees-minutes-seconds/formatter.d.ts
|
|
16
|
+
declare const formatDegreesMinutesSeconds: (coordinates: [number, number], config?: FormatOptions) => string;
|
|
17
|
+
//#endregion
|
|
5
18
|
export { formatDegreesMinutesSeconds };
|
|
19
|
+
//# sourceMappingURL=formatter.d.ts.map
|
|
@@ -1,16 +1,27 @@
|
|
|
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
|
+
*/
|
|
2
12
|
|
|
13
|
+
|
|
14
|
+
import { createFormatter } from "../internal/format.js";
|
|
15
|
+
|
|
16
|
+
//#region src/coordinates/latlon/degrees-minutes-seconds/formatter.ts
|
|
3
17
|
const toDegreesMinutesSeconds = (num) => {
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
return `${degrees}\xB0 ${minutes}' ${seconds}\u2033`;
|
|
18
|
+
const degrees = Math.floor(Math.abs(num));
|
|
19
|
+
const minutesFull = (Math.abs(num) - degrees) * 60;
|
|
20
|
+
const minutes = Math.floor(minutesFull);
|
|
21
|
+
return `${degrees}° ${minutes}' ${((minutesFull - minutes) * 60).toFixed(2)}″`;
|
|
9
22
|
};
|
|
10
|
-
const formatDegreesMinutesSeconds = createFormatter(
|
|
11
|
-
toDegreesMinutesSeconds
|
|
12
|
-
);
|
|
23
|
+
const formatDegreesMinutesSeconds = createFormatter(toDegreesMinutesSeconds);
|
|
13
24
|
|
|
25
|
+
//#endregion
|
|
14
26
|
export { formatDegreesMinutesSeconds };
|
|
15
|
-
//# sourceMappingURL=formatter.js.map
|
|
16
27
|
//# sourceMappingURL=formatter.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../../src/coordinates/latlon/degrees-minutes-seconds/formatter.ts"],"
|
|
1
|
+
{"version":3,"file":"formatter.js","names":[],"sources":["../../../../src/coordinates/latlon/degrees-minutes-seconds/formatter.ts"],"sourcesContent":["/*\n * Copyright 2025 Hypergiant Galactic Systems Inc. All rights reserved.\n * This file is licensed to you under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License. You may obtain a copy\n * of the License at https://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software distributed under\n * the License is distributed on an \"AS IS\" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS\n * OF ANY KIND, either express or implied. See the License for the specific language\n * governing permissions and limitations under the License.\n */\n\nimport { createFormatter } from '../internal/format';\n\nconst toDegreesMinutesSeconds = (num: number): string => {\n const degrees = Math.floor(Math.abs(num));\n const minutesFull = (Math.abs(num) - degrees) * 60;\n const minutes = Math.floor(minutesFull);\n const seconds = ((minutesFull - minutes) * 60).toFixed(2);\n\n return `${degrees}° ${minutes}' ${seconds}″`;\n};\n\nexport const formatDegreesMinutesSeconds = createFormatter(\n toDegreesMinutesSeconds,\n);\n"],"mappings":";;;;;;;;;;;;;;;;AAcA,MAAM,2BAA2B,QAAwB;CACvD,MAAM,UAAU,KAAK,MAAM,KAAK,IAAI,IAAI,CAAC;CACzC,MAAM,eAAe,KAAK,IAAI,IAAI,GAAG,WAAW;CAChD,MAAM,UAAU,KAAK,MAAM,YAAY;AAGvC,QAAO,GAAG,QAAQ,IAAI,QAAQ,MAFZ,cAAc,WAAW,IAAI,QAAQ,EAAE,CAEf;;AAG5C,MAAa,8BAA8B,gBACzC,wBACD"}
|
|
@@ -1,8 +1,21 @@
|
|
|
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 "../internal/index.js";
|
|
14
|
+
import { ParseResults } from "../internal/parse.js";
|
|
15
|
+
|
|
16
|
+
//#region src/coordinates/latlon/degrees-minutes-seconds/parser.d.ts
|
|
5
17
|
/** Parse a Degrees Minutes Seconds coordinate. */
|
|
6
18
|
declare const parseDegreesMinutesSeconds: (format: Format, input: string) => ParseResults;
|
|
7
|
-
|
|
19
|
+
//#endregion
|
|
8
20
|
export { parseDegreesMinutesSeconds };
|
|
21
|
+
//# sourceMappingURL=parser.d.ts.map
|