@accelint/geo 0.1.3 → 0.2.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.
- package/README.md +9 -0
- package/dist/cartesian.d.ts +21 -0
- package/dist/cartesian.js +11 -0
- package/dist/cartesian.js.map +1 -0
- package/dist/coordinates/coordinate.d.ts +73 -0
- package/dist/coordinates/coordinate.js +87 -0
- package/dist/coordinates/coordinate.js.map +1 -0
- package/dist/coordinates/latlon/decimal-degrees/parser.d.ts +8 -0
- package/dist/coordinates/latlon/decimal-degrees/parser.js +77 -0
- package/dist/coordinates/latlon/decimal-degrees/parser.js.map +1 -0
- package/dist/coordinates/latlon/decimal-degrees/system.d.ts +8 -0
- package/dist/coordinates/latlon/decimal-degrees/system.js +21 -0
- package/dist/coordinates/latlon/decimal-degrees/system.js.map +1 -0
- package/dist/coordinates/latlon/degrees-decimal-minutes/parser.d.ts +8 -0
- package/dist/coordinates/latlon/degrees-decimal-minutes/parser.js +86 -0
- package/dist/coordinates/latlon/degrees-decimal-minutes/parser.js.map +1 -0
- package/dist/coordinates/latlon/degrees-decimal-minutes/system.d.ts +8 -0
- package/dist/coordinates/latlon/degrees-decimal-minutes/system.js +26 -0
- package/dist/coordinates/latlon/degrees-decimal-minutes/system.js.map +1 -0
- package/dist/coordinates/latlon/degrees-minutes-seconds/parser.d.ts +8 -0
- package/dist/coordinates/latlon/degrees-minutes-seconds/parser.js +85 -0
- package/dist/coordinates/latlon/degrees-minutes-seconds/parser.js.map +1 -0
- package/dist/coordinates/latlon/degrees-minutes-seconds/system.d.ts +8 -0
- package/dist/coordinates/latlon/degrees-minutes-seconds/system.js +28 -0
- package/dist/coordinates/latlon/degrees-minutes-seconds/system.js.map +1 -0
- package/dist/coordinates/latlon/internal/coordinate-system.d.ts +12 -0
- package/dist/coordinates/latlon/internal/coordinate-system.js +3 -0
- package/dist/coordinates/latlon/internal/coordinate-system.js.map +1 -0
- package/dist/coordinates/latlon/internal/create-cache.d.ts +12 -0
- package/dist/coordinates/latlon/internal/create-cache.js +15 -0
- package/dist/coordinates/latlon/internal/create-cache.js.map +1 -0
- package/dist/coordinates/latlon/internal/exhaustive-errors.d.ts +9 -0
- package/dist/coordinates/latlon/internal/exhaustive-errors.js +72 -0
- package/dist/coordinates/latlon/internal/exhaustive-errors.js.map +1 -0
- package/dist/coordinates/latlon/internal/in-range.d.ts +7 -0
- package/dist/coordinates/latlon/internal/in-range.js +14 -0
- package/dist/coordinates/latlon/internal/in-range.js.map +1 -0
- package/dist/coordinates/latlon/internal/index.d.ts +59 -0
- package/dist/coordinates/latlon/internal/index.js +117 -0
- package/dist/coordinates/latlon/internal/index.js.map +1 -0
- package/dist/coordinates/latlon/internal/lexer.d.ts +20 -0
- package/dist/coordinates/latlon/internal/lexer.js +46 -0
- package/dist/coordinates/latlon/internal/lexer.js.map +1 -0
- package/dist/coordinates/latlon/internal/parse-format.d.ts +15 -0
- package/dist/coordinates/latlon/internal/parse-format.js +63 -0
- package/dist/coordinates/latlon/internal/parse-format.js.map +1 -0
- package/dist/coordinates/latlon/internal/parse.d.ts +41 -0
- package/dist/coordinates/latlon/internal/parse.js +16 -0
- package/dist/coordinates/latlon/internal/parse.js.map +1 -0
- package/dist/coordinates/latlon/internal/pipes/check-ambiguous.d.ts +10 -0
- package/dist/coordinates/latlon/internal/pipes/check-ambiguous.js +23 -0
- package/dist/coordinates/latlon/internal/pipes/check-ambiguous.js.map +1 -0
- package/dist/coordinates/latlon/internal/pipes/check-numbers.d.ts +8 -0
- package/dist/coordinates/latlon/internal/pipes/check-numbers.js +35 -0
- package/dist/coordinates/latlon/internal/pipes/check-numbers.js.map +1 -0
- package/dist/coordinates/latlon/internal/pipes/fix-bearings.d.ts +12 -0
- package/dist/coordinates/latlon/internal/pipes/fix-bearings.js +68 -0
- package/dist/coordinates/latlon/internal/pipes/fix-bearings.js.map +1 -0
- package/dist/coordinates/latlon/internal/pipes/fix-dividers.d.ts +15 -0
- package/dist/coordinates/latlon/internal/pipes/fix-dividers.js +34 -0
- package/dist/coordinates/latlon/internal/pipes/fix-dividers.js.map +1 -0
- package/dist/coordinates/latlon/internal/pipes/genome.d.ts +9 -0
- package/dist/coordinates/latlon/internal/pipes/genome.js +37 -0
- package/dist/coordinates/latlon/internal/pipes/genome.js.map +1 -0
- package/dist/coordinates/latlon/internal/pipes/index.d.ts +24 -0
- package/dist/coordinates/latlon/internal/pipes/index.js +46 -0
- package/dist/coordinates/latlon/internal/pipes/index.js.map +1 -0
- package/dist/coordinates/latlon/internal/pipes/simpler.d.ts +15 -0
- package/dist/coordinates/latlon/internal/pipes/simpler.js +6 -0
- package/dist/coordinates/latlon/internal/pipes/simpler.js.map +1 -0
- package/dist/coordinates/latlon/internal/violation.d.ts +3 -0
- package/dist/coordinates/latlon/internal/violation.js +6 -0
- package/dist/coordinates/latlon/internal/violation.js.map +1 -0
- package/dist/coordinates/mgrs/parser.d.ts +7 -0
- package/dist/coordinates/mgrs/parser.js +45 -0
- package/dist/coordinates/mgrs/parser.js.map +1 -0
- package/dist/coordinates/mgrs/system.d.ts +8 -0
- package/dist/coordinates/mgrs/system.js +25 -0
- package/dist/coordinates/mgrs/system.js.map +1 -0
- package/dist/coordinates/utm/parser.d.ts +7 -0
- package/dist/coordinates/utm/parser.js +38 -0
- package/dist/coordinates/utm/parser.js.map +1 -0
- package/dist/coordinates/utm/system.d.ts +8 -0
- package/dist/coordinates/utm/system.js +25 -0
- package/dist/coordinates/utm/system.js.map +1 -0
- package/dist/index.d.ts +10 -2
- package/dist/index.js +6 -2
- package/dist/patterning.d.ts +63 -0
- package/dist/patterning.js +16 -0
- package/dist/patterning.js.map +1 -0
- package/package.json +16 -11
- package/dist/coordinates/__fixtures__/index.d.ts +0 -6
- package/dist/coordinates/__fixtures__/index.js +0 -39
- package/dist/coordinates/__fixtures__/index.js.map +0 -1
- package/dist/coordinates/configurations.d.ts +0 -8
- package/dist/coordinates/configurations.js +0 -15
- package/dist/coordinates/configurations.js.map +0 -1
- package/dist/coordinates/index.d.ts +0 -2
- package/dist/coordinates/index.js +0 -4
- package/dist/coordinates/index.js.map +0 -1
- package/dist/coordinates/match.d.ts +0 -35
- package/dist/coordinates/match.js +0 -23
- package/dist/coordinates/match.js.map +0 -1
- package/dist/coordinates/normalize.d.ts +0 -3
- package/dist/coordinates/normalize.js +0 -27
- package/dist/coordinates/normalize.js.map +0 -1
- package/dist/coordinates/regex.d.ts +0 -128
- package/dist/coordinates/regex.js +0 -10
- package/dist/coordinates/regex.js.map +0 -1
- package/dist/coordinates/utils.d.ts +0 -6
- package/dist/coordinates/utils.js +0 -28
- package/dist/coordinates/utils.js.map +0 -1
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../../../src/coordinates/mgrs/system.ts"],"names":[],"mappings":";;;;;;AAsBO,IAAM,UAA+B,GAAA;AAAA,EAC1C,IAAM,EAAA,gCAAA;AAAA,EAEN,KAAO,EAAA,SAAA;AAAA,EAEP,QAAQ,GAAK,EAAA;AACX,IAAM,MAAA,CAAC,GAAK,EAAA,IAAI,CAAI,GAAA,GAAA;AAEpB,IACE,OAAA,MAAA,CAAO,WAAW,GAAG,CAAA,IACpB,gBAAgB,iBAAkB,CAAA,IAAA,CAAK,IAAI,CAAA,GAAI,EAAK,GAAA,CAAA,CAAA;AAAA,GAEzD;AAAA,EAEA,QAAS,CAAA,MAAA,EAAgB,CAAC,IAAA,EAAM,KAAK,CAAqB,EAAA;AACxD,IAAA,MAAM,EAAE,GAAA,EAAK,GAAI,EAAA,GAAI,OAAO,WAAY,CAAA;AAAA,MACtC,CAAC,MAAO,CAAA,KAAA,CAAM,CAAG,EAAA,CAAC,GAAG,IAAI,CAAA;AAAA,MACzB,CAAC,MAAA,CAAO,KAAM,CAAA,CAAC,GAAG,KAAK;AAAA,KACxB,CAAA;AAED,IAAO,OAAA,IAAA,CAAK,KAAK,KAAM,CAAA,KAAA,CAAM,KAAK,GAAG,CAAC,EAAE,QAAS,EAAA;AAAA;AAErD","file":"system.js","sourcesContent":["// __private-exports\n/*\n * Copyright 2024 Hypergiant Galactic Systems Inc. All rights reserved.\n * This file is licensed to you under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License. You may obtain a copy\n * of the License at https://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software distributed under\n * the License is distributed on an \"AS IS\" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS\n * OF ANY KIND, either express or implied. See the License for the specific language\n * governing permissions and limitations under the License.\n */\n\nimport { Point } from '@ngageoint/grid-js';\nimport { MGRS } from '@ngageoint/mgrs-js';\n\nimport { type Compass, type Format, SYMBOL_PATTERNS } from '../latlon/internal';\nimport type { CoordinateSystem } from '../latlon/internal/coordinate-system';\n\nimport { parseMGRS } from './parser';\n\n// biome-ignore lint/style/useNamingConvention: acronym\nexport const systemMGRS: CoordinateSystem = {\n name: 'Military Grid Reference System',\n\n parse: parseMGRS,\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 const { LAT, LON } = Object.fromEntries([\n [format.slice(0, 3), left],\n [format.slice(3), right],\n ]) as Record<'LAT' | 'LON', number>;\n\n return MGRS.from(Point.point(LON, LAT)).toString();\n },\n};\n"]}
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
import { UTM } from '@ngageoint/mgrs-js';
|
|
2
|
+
import { parse } from '../latlon/internal/parse.js';
|
|
3
|
+
import { violation } from '../latlon/internal/violation.js';
|
|
4
|
+
|
|
5
|
+
// src/coordinates/utm/parser.ts
|
|
6
|
+
var PATTERN_PARTS = /^((?:..)?)\s*(\w?)\s*(?:(\d+(?:\.\d*)?)?)\s*(?:(\d+(?:\.\d*)?)?)$/i;
|
|
7
|
+
var error = (message) => [
|
|
8
|
+
[],
|
|
9
|
+
[`${violation(message)}; expected format ZZ N|S DDD DDD.`]
|
|
10
|
+
];
|
|
11
|
+
function detailedErrors(input) {
|
|
12
|
+
const [zone, band, east, north] = (input.trim().replace(/\s+/g, " ").match(PATTERN_PARTS) ?? []).slice(1);
|
|
13
|
+
if (!zone || +zone > 60 || +zone < 1) {
|
|
14
|
+
return error(`Invalid Zone number (${zone}) found`);
|
|
15
|
+
}
|
|
16
|
+
if (!/[NS]/i.test(band)) {
|
|
17
|
+
return error(`Invalid Latitude band letter (${band}) found`);
|
|
18
|
+
}
|
|
19
|
+
if (!(east || +east >= 0)) {
|
|
20
|
+
return error(`Invalid Easting number (${east ?? ""}) found`);
|
|
21
|
+
}
|
|
22
|
+
if (!(north || +north >= 0)) {
|
|
23
|
+
return error(`Invalid Northing number (${north ?? ""}) found`);
|
|
24
|
+
}
|
|
25
|
+
return error("Uncaught error condition.");
|
|
26
|
+
}
|
|
27
|
+
function parseUTM(_format, input) {
|
|
28
|
+
try {
|
|
29
|
+
const point = UTM.parse(input).toPoint();
|
|
30
|
+
return parse(`${point.getLatitude()} / ${point.getLongitude()}`, "LATLON");
|
|
31
|
+
} catch (_) {
|
|
32
|
+
return detailedErrors(input);
|
|
33
|
+
}
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
export { parseUTM };
|
|
37
|
+
//# sourceMappingURL=parser.js.map
|
|
38
|
+
//# sourceMappingURL=parser.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../../../src/coordinates/utm/parser.ts"],"names":[],"mappings":";;;;;AAmBA,IAAM,aACJ,GAAA,oEAAA;AAEF,IAAM,KAAA,GAAQ,CAAC,OACb,KAAA;AAAA,EACE,EAAC;AAAA,EACD,CAAC,CAAA,EAAG,SAAU,CAAA,OAAO,CAAC,CAAmC,iCAAA,CAAA;AAC3D,CAAA;AAEF,SAAS,eAAe,KAAe,EAAA;AACrC,EAAA,MAAM,CAAC,IAAM,EAAA,IAAA,EAAM,MAAM,KAAK,CAAA,GAAA,CAC5B,MAAM,IAAK,EAAA,CAAE,QAAQ,MAAQ,EAAA,GAAG,EAAE,KAAM,CAAA,aAAa,KAAK,EAAC,EAC3D,MAAM,CAAC,CAAA;AAET,EAAA,IAAI,CAAC,IAAQ,IAAA,CAAC,OAAO,EAAM,IAAA,CAAC,OAAO,CAAG,EAAA;AACpC,IAAO,OAAA,KAAA,CAAM,CAAwB,qBAAA,EAAA,IAAI,CAAS,OAAA,CAAA,CAAA;AAAA;AAGpD,EAAA,IAAI,CAAC,OAAA,CAAQ,IAAK,CAAA,IAAI,CAAG,EAAA;AACvB,IAAO,OAAA,KAAA,CAAM,CAAiC,8BAAA,EAAA,IAAI,CAAS,OAAA,CAAA,CAAA;AAAA;AAG7D,EAAA,IAAI,EAAE,IAAA,IAAQ,CAAC,IAAA,IAAQ,CAAI,CAAA,EAAA;AACzB,IAAA,OAAO,KAAM,CAAA,CAAA,wBAAA,EAA2B,IAAQ,IAAA,EAAE,CAAS,OAAA,CAAA,CAAA;AAAA;AAG7D,EAAA,IAAI,EAAE,KAAA,IAAS,CAAC,KAAA,IAAS,CAAI,CAAA,EAAA;AAC3B,IAAA,OAAO,KAAM,CAAA,CAAA,yBAAA,EAA4B,KAAS,IAAA,EAAE,CAAS,OAAA,CAAA,CAAA;AAAA;AAG/D,EAAA,OAAO,MAAM,2BAA2B,CAAA;AAC1C;AAIO,SAAS,QAAA,CAAS,SAAc,KAAe,EAAA;AACpD,EAAI,IAAA;AACF,IAAA,MAAM,KAAQ,GAAA,GAAA,CAAI,KAAM,CAAA,KAAK,EAAE,OAAQ,EAAA;AAEvC,IAAO,OAAA,KAAA,CAAM,CAAG,EAAA,KAAA,CAAM,WAAY,EAAC,MAAM,KAAM,CAAA,YAAA,EAAc,CAAA,CAAA,EAAI,QAAQ,CAAA;AAAA,WAClE,CAAG,EAAA;AACV,IAAA,OAAO,eAAe,KAAK,CAAA;AAAA;AAE/B","file":"parser.js","sourcesContent":["/*\n * Copyright 2024 Hypergiant Galactic Systems Inc. All rights reserved.\n * This file is licensed to you under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License. You may obtain a copy\n * of the License at https://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software distributed under\n * the License is distributed on an \"AS IS\" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS\n * OF ANY KIND, either express or implied. See the License for the specific language\n * governing permissions and limitations under the License.\n */\n\nimport { UTM } from '@ngageoint/mgrs-js';\n\nimport { type ParseResults, parse } from '../latlon/internal/parse';\nimport { violation } from '../latlon/internal/violation';\n\ntype Match = [string, string, string, string];\n\nconst PATTERN_PARTS =\n /^((?:..)?)\\s*(\\w?)\\s*(?:(\\d+(?:\\.\\d*)?)?)\\s*(?:(\\d+(?:\\.\\d*)?)?)$/i;\n\nconst error = (message: string) =>\n [\n [],\n [`${violation(message)}; expected format ZZ N|S DDD DDD.`],\n ] as ParseResults;\n\nfunction detailedErrors(input: string) {\n const [zone, band, east, north] = (\n input.trim().replace(/\\s+/g, ' ').match(PATTERN_PARTS) ?? []\n ).slice(1) as Match;\n\n if (!zone || +zone > 60 || +zone < 1) {\n return error(`Invalid Zone number (${zone}) found`);\n }\n\n if (!/[NS]/i.test(band)) {\n return error(`Invalid Latitude band letter (${band}) found`);\n }\n\n if (!(east || +east >= 0)) {\n return error(`Invalid Easting number (${east ?? ''}) found`);\n }\n\n if (!(north || +north >= 0)) {\n return error(`Invalid Northing number (${north ?? ''}) found`);\n }\n\n return error('Uncaught error condition.');\n}\n\n// biome-ignore lint/style/useNamingConvention: <explanation>\n// biome-ignore lint/suspicious/noExplicitAny: <explanation>\nexport function parseUTM(_format: any, input: string) {\n try {\n const point = UTM.parse(input).toPoint();\n\n return parse(`${point.getLatitude()} / ${point.getLongitude()}`, 'LATLON');\n } catch (_) {\n return detailedErrors(input);\n }\n}\n"]}
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import { CoordinateSystem } from '../latlon/internal/coordinate-system.js';
|
|
2
|
+
import '../latlon/internal/index.js';
|
|
3
|
+
import '../latlon/internal/parse.js';
|
|
4
|
+
import '../latlon/internal/lexer.js';
|
|
5
|
+
|
|
6
|
+
declare const systemUTM: CoordinateSystem;
|
|
7
|
+
|
|
8
|
+
export { systemUTM };
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
import { Point } from '@ngageoint/grid-js';
|
|
2
|
+
import { UTM } from '@ngageoint/mgrs-js';
|
|
3
|
+
import { SYMBOL_PATTERNS } from '../latlon/internal/index.js';
|
|
4
|
+
import { parseUTM } from './parser.js';
|
|
5
|
+
|
|
6
|
+
// src/coordinates/utm/system.ts
|
|
7
|
+
var systemUTM = {
|
|
8
|
+
name: "Military Grid Reference System",
|
|
9
|
+
parse: parseUTM,
|
|
10
|
+
toFloat(arg) {
|
|
11
|
+
const [num, bear] = arg;
|
|
12
|
+
return Number.parseFloat(num) * (SYMBOL_PATTERNS.NEGATIVE_BEARINGS.test(bear) ? -1 : 1);
|
|
13
|
+
},
|
|
14
|
+
toFormat(format, [left, right]) {
|
|
15
|
+
const { LAT, LON } = Object.fromEntries([
|
|
16
|
+
[format.slice(0, 3), left],
|
|
17
|
+
[format.slice(3), right]
|
|
18
|
+
]);
|
|
19
|
+
return UTM.from(Point.point(LON, LAT)).toString();
|
|
20
|
+
}
|
|
21
|
+
};
|
|
22
|
+
|
|
23
|
+
export { systemUTM };
|
|
24
|
+
//# sourceMappingURL=system.js.map
|
|
25
|
+
//# sourceMappingURL=system.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../../../src/coordinates/utm/system.ts"],"names":[],"mappings":";;;;;;AAsBO,IAAM,SAA8B,GAAA;AAAA,EACzC,IAAM,EAAA,gCAAA;AAAA,EAEN,KAAO,EAAA,QAAA;AAAA,EAEP,QAAQ,GAAK,EAAA;AACX,IAAM,MAAA,CAAC,GAAK,EAAA,IAAI,CAAI,GAAA,GAAA;AAEpB,IACE,OAAA,MAAA,CAAO,WAAW,GAAG,CAAA,IACpB,gBAAgB,iBAAkB,CAAA,IAAA,CAAK,IAAI,CAAA,GAAI,EAAK,GAAA,CAAA,CAAA;AAAA,GAEzD;AAAA,EAEA,QAAS,CAAA,MAAA,EAAgB,CAAC,IAAA,EAAM,KAAK,CAAqB,EAAA;AACxD,IAAA,MAAM,EAAE,GAAA,EAAK,GAAI,EAAA,GAAI,OAAO,WAAY,CAAA;AAAA,MACtC,CAAC,MAAO,CAAA,KAAA,CAAM,CAAG,EAAA,CAAC,GAAG,IAAI,CAAA;AAAA,MACzB,CAAC,MAAA,CAAO,KAAM,CAAA,CAAC,GAAG,KAAK;AAAA,KACxB,CAAA;AAED,IAAO,OAAA,GAAA,CAAI,KAAK,KAAM,CAAA,KAAA,CAAM,KAAK,GAAG,CAAC,EAAE,QAAS,EAAA;AAAA;AAEpD","file":"system.js","sourcesContent":["// __private-exports\n/*\n * Copyright 2024 Hypergiant Galactic Systems Inc. All rights reserved.\n * This file is licensed to you under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License. You may obtain a copy\n * of the License at https://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software distributed under\n * the License is distributed on an \"AS IS\" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS\n * OF ANY KIND, either express or implied. See the License for the specific language\n * governing permissions and limitations under the License.\n */\n\nimport { Point } from '@ngageoint/grid-js';\nimport { UTM } from '@ngageoint/mgrs-js';\n\nimport { type Compass, type Format, SYMBOL_PATTERNS } from '../latlon/internal';\nimport type { CoordinateSystem } from '../latlon/internal/coordinate-system';\n\nimport { parseUTM } from './parser';\n\n// biome-ignore lint/style/useNamingConvention: acronym\nexport const systemUTM: CoordinateSystem = {\n name: 'Military Grid Reference System',\n\n parse: parseUTM,\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 const { LAT, LON } = Object.fromEntries([\n [format.slice(0, 3), left],\n [format.slice(3), right],\n ]) as Record<'LAT' | 'LON', number>;\n\n return UTM.from(Point.point(LON, LAT)).toString();\n },\n};\n"]}
|
package/dist/index.d.ts
CHANGED
|
@@ -1,2 +1,10 @@
|
|
|
1
|
-
export {
|
|
2
|
-
export {
|
|
1
|
+
export { coordinateSystems, createCoordinate } from './coordinates/coordinate.js';
|
|
2
|
+
export { parseDecimalDegrees } from './coordinates/latlon/decimal-degrees/parser.js';
|
|
3
|
+
export { parseDegreesDecimalMinutes } from './coordinates/latlon/degrees-decimal-minutes/parser.js';
|
|
4
|
+
export { parseDegreesMinutesSeconds } from './coordinates/latlon/degrees-minutes-seconds/parser.js';
|
|
5
|
+
export { parseMGRS } from './coordinates/mgrs/parser.js';
|
|
6
|
+
export { parseUTM } from './coordinates/utm/parser.js';
|
|
7
|
+
import './coordinates/latlon/internal/index.js';
|
|
8
|
+
import './coordinates/latlon/internal/coordinate-system.js';
|
|
9
|
+
import './coordinates/latlon/internal/parse.js';
|
|
10
|
+
import './coordinates/latlon/internal/lexer.js';
|
package/dist/index.js
CHANGED
|
@@ -1,4 +1,8 @@
|
|
|
1
|
-
export {
|
|
2
|
-
export {
|
|
1
|
+
export { coordinateSystems, createCoordinate } from './coordinates/coordinate.js';
|
|
2
|
+
export { parseDecimalDegrees } from './coordinates/latlon/decimal-degrees/parser.js';
|
|
3
|
+
export { parseDegreesDecimalMinutes } from './coordinates/latlon/degrees-decimal-minutes/parser.js';
|
|
4
|
+
export { parseDegreesMinutesSeconds } from './coordinates/latlon/degrees-minutes-seconds/parser.js';
|
|
5
|
+
export { parseMGRS } from './coordinates/mgrs/parser.js';
|
|
6
|
+
export { parseUTM } from './coordinates/utm/parser.js';
|
|
3
7
|
//# sourceMappingURL=index.js.map
|
|
4
8
|
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1,63 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Create a "capturing" group with the pattern provided by all arguments
|
|
3
|
+
* merged into a single regex.
|
|
4
|
+
*
|
|
5
|
+
* @remarks
|
|
6
|
+
* pure function
|
|
7
|
+
*
|
|
8
|
+
* @example
|
|
9
|
+
* capture(/a/, /b/, /c/) === /(abc)/
|
|
10
|
+
*/
|
|
11
|
+
declare const capture: (...p: RegExp[]) => RegExp;
|
|
12
|
+
/**
|
|
13
|
+
* Create a pattern using a template string and dict(ionary) of terms.
|
|
14
|
+
*
|
|
15
|
+
* @param dict an object with keys/properties that are RegExp objects that will
|
|
16
|
+
* be used in the template string
|
|
17
|
+
* @param template the definition of the pattern to build using the dict(ionary)
|
|
18
|
+
* patterns
|
|
19
|
+
*
|
|
20
|
+
* @remarks
|
|
21
|
+
* pure function
|
|
22
|
+
*
|
|
23
|
+
* @example
|
|
24
|
+
* fromTemplate({ a: /alpha/, b: /beta/, ' ': / / }, 'a b') === /^alpha beta$/
|
|
25
|
+
*
|
|
26
|
+
*/
|
|
27
|
+
declare const fromTemplate: (dict: Record<string, RegExp>, template: string) => RegExp;
|
|
28
|
+
/**
|
|
29
|
+
* Create a "non-capturing" group with the pattern provided by all arguments
|
|
30
|
+
* merged into a single regex.
|
|
31
|
+
*
|
|
32
|
+
* @remarks
|
|
33
|
+
* pure function
|
|
34
|
+
*
|
|
35
|
+
* @example
|
|
36
|
+
* capture(/a/, /b/, /c/) === /(?:abc)/
|
|
37
|
+
*/
|
|
38
|
+
declare const group: (...p: RegExp[]) => RegExp;
|
|
39
|
+
/**
|
|
40
|
+
* Concatenate all of the provided patterns into a single pattern; each
|
|
41
|
+
* subsequent argument is joined with the previous with no "qualifier" between
|
|
42
|
+
* them.
|
|
43
|
+
*
|
|
44
|
+
* @remarks
|
|
45
|
+
* pure function
|
|
46
|
+
*
|
|
47
|
+
* @example
|
|
48
|
+
* merge(/a/, /b/, /c/) === /abc/
|
|
49
|
+
*/
|
|
50
|
+
declare const merge: (...all: RegExp[]) => RegExp;
|
|
51
|
+
/**
|
|
52
|
+
* Create an "optional" "non-capturing" group with the pattern provided by all
|
|
53
|
+
* arguments merged into a single regex.
|
|
54
|
+
*
|
|
55
|
+
* @remarks
|
|
56
|
+
* pure function
|
|
57
|
+
*
|
|
58
|
+
* @example
|
|
59
|
+
* capture(/a/, /b/, /c/) === /(?:abc)?/
|
|
60
|
+
*/
|
|
61
|
+
declare const optional: (...p: RegExp[]) => RegExp;
|
|
62
|
+
|
|
63
|
+
export { capture, fromTemplate, group, merge, optional };
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
// src/patterning.ts
|
|
2
|
+
var capture = (...p) => new RegExp(`(${merge(...p).source})`);
|
|
3
|
+
var fromTemplate = (dict, template) => merge(
|
|
4
|
+
/^/,
|
|
5
|
+
...(template.match(/(\s+)|([^\s]+)/g) ?? []).map(
|
|
6
|
+
(t) => dict[t] ?? new RegExp(`_MISS_${t}_MISS_`)
|
|
7
|
+
),
|
|
8
|
+
/$/
|
|
9
|
+
);
|
|
10
|
+
var group = (...p) => new RegExp(`(?:${merge(...p).source})`);
|
|
11
|
+
var merge = (...all) => all.reduce((acc, next) => new RegExp(acc?.source + next.source));
|
|
12
|
+
var optional = (...p) => new RegExp(`(?:${merge(...p).source})?`);
|
|
13
|
+
|
|
14
|
+
export { capture, fromTemplate, group, merge, optional };
|
|
15
|
+
//# sourceMappingURL=patterning.js.map
|
|
16
|
+
//# sourceMappingURL=patterning.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../src/patterning.ts"],"names":[],"mappings":";AAuBa,IAAA,OAAA,GAAU,CAAI,GAAA,CAAA,KACzB,IAAI,MAAA,CAAO,CAAI,CAAA,EAAA,KAAA,CAAM,GAAG,CAAC,CAAE,CAAA,MAAM,CAAG,CAAA,CAAA;AAiBzB,IAAA,YAAA,GAAe,CAAC,IAAA,EAA8B,QACzD,KAAA,KAAA;AAAA,EACE,GAAA;AAAA,EACA,IAAI,QAAS,CAAA,KAAA,CAAM,iBAAiB,CAAA,IAAK,EAAI,EAAA,GAAA;AAAA,IAC3C,CAAC,MAAM,IAAK,CAAA,CAAsB,KAAK,IAAI,MAAA,CAAO,CAAS,MAAA,EAAA,CAAC,CAAQ,MAAA,CAAA;AAAA,GACtE;AAAA,EACA;AACF;AAYW,IAAA,KAAA,GAAQ,CAAI,GAAA,CAAA,KACvB,IAAI,MAAA,CAAO,CAAM,GAAA,EAAA,KAAA,CAAM,GAAG,CAAC,CAAE,CAAA,MAAM,CAAG,CAAA,CAAA;AAajC,IAAM,KAAQ,GAAA,CAAA,GAAI,GACvB,KAAA,GAAA,CAAI,OAAO,CAAC,GAAA,EAAK,IAAS,KAAA,IAAI,MAAO,CAAA,GAAA,EAAK,MAAS,GAAA,IAAA,CAAK,MAAM,CAAC;AAYpD,IAAA,QAAA,GAAW,CAAI,GAAA,CAAA,KAC1B,IAAI,MAAA,CAAO,CAAM,GAAA,EAAA,KAAA,CAAM,GAAG,CAAC,CAAE,CAAA,MAAM,CAAI,EAAA,CAAA","file":"patterning.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\n/**\n * Create a \"capturing\" group with the pattern provided by all arguments\n * merged into a single regex.\n *\n * @remarks\n * pure function\n *\n * @example\n * capture(/a/, /b/, /c/) === /(abc)/\n */\nexport const capture = (...p: RegExp[]) =>\n new RegExp(`(${merge(...p).source})`);\n\n/**\n * Create a pattern using a template string and dict(ionary) of terms.\n *\n * @param dict an object with keys/properties that are RegExp objects that will\n * be used in the template string\n * @param template the definition of the pattern to build using the dict(ionary)\n * patterns\n *\n * @remarks\n * pure function\n *\n * @example\n * fromTemplate({ a: /alpha/, b: /beta/, ' ': / / }, 'a b') === /^alpha beta$/\n *\n */\nexport const fromTemplate = (dict: Record<string, RegExp>, template: string) =>\n merge(\n /^/,\n ...(template.match(/(\\s+)|([^\\s]+)/g) ?? []).map(\n (t) => dict[t as keyof typeof dict] ?? new RegExp(`_MISS_${t}_MISS_`),\n ),\n /$/,\n );\n\n/**\n * Create a \"non-capturing\" group with the pattern provided by all arguments\n * merged into a single regex.\n *\n * @remarks\n * pure function\n *\n * @example\n * capture(/a/, /b/, /c/) === /(?:abc)/\n */\nexport const group = (...p: RegExp[]) =>\n new RegExp(`(?:${merge(...p).source})`);\n\n/**\n * Concatenate all of the provided patterns into a single pattern; each\n * subsequent argument is joined with the previous with no \"qualifier\" between\n * them.\n *\n * @remarks\n * pure function\n *\n * @example\n * merge(/a/, /b/, /c/) === /abc/\n */\nexport const merge = (...all: RegExp[]) =>\n all.reduce((acc, next) => new RegExp(acc?.source + next.source));\n\n/**\n * Create an \"optional\" \"non-capturing\" group with the pattern provided by all\n * arguments merged into a single regex.\n *\n * @remarks\n * pure function\n *\n * @example\n * capture(/a/, /b/, /c/) === /(?:abc)?/\n */\nexport const optional = (...p: RegExp[]) =>\n new RegExp(`(?:${merge(...p).source})?`);\n"]}
|
package/package.json
CHANGED
|
@@ -1,8 +1,12 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@accelint/geo",
|
|
3
|
-
"version": "0.1
|
|
3
|
+
"version": "0.2.1",
|
|
4
4
|
"private": false,
|
|
5
5
|
"license": "Apache-2.0",
|
|
6
|
+
"repository": {
|
|
7
|
+
"type": "git",
|
|
8
|
+
"url": "https://github.com/gohypergiant/standard-toolkit"
|
|
9
|
+
},
|
|
6
10
|
"type": "module",
|
|
7
11
|
"files": [
|
|
8
12
|
"dist/**"
|
|
@@ -19,17 +23,18 @@
|
|
|
19
23
|
"./package.json": "./package.json"
|
|
20
24
|
},
|
|
21
25
|
"devDependencies": {
|
|
22
|
-
"
|
|
23
|
-
"
|
|
24
|
-
"
|
|
25
|
-
"vitest": "^2.1.3",
|
|
26
|
+
"esbuild-plugin-file-path-extensions": "2.1.3",
|
|
27
|
+
"tsup": "8.3.0",
|
|
28
|
+
"vitest": "2.1.3",
|
|
26
29
|
"@accelint/typescript-config": "0.1.2",
|
|
27
|
-
"@accelint/vitest-config": "0.1.
|
|
30
|
+
"@accelint/vitest-config": "0.1.3"
|
|
28
31
|
},
|
|
29
32
|
"dependencies": {
|
|
30
|
-
"
|
|
31
|
-
"@
|
|
32
|
-
"
|
|
33
|
+
"@ngageoint/grid-js": "2.1.0",
|
|
34
|
+
"@ngageoint/mgrs-js": "1.0.0",
|
|
35
|
+
"typescript": "5.6.3",
|
|
36
|
+
"@accelint/math": "0.1.3",
|
|
37
|
+
"@accelint/predicates": "0.2.1"
|
|
33
38
|
},
|
|
34
39
|
"$schema": "https://json.schemastore.org/package",
|
|
35
40
|
"author": "https://hypergiant.com",
|
|
@@ -42,7 +47,7 @@
|
|
|
42
47
|
"build": "pnpm tsup",
|
|
43
48
|
"dev": "pnpm tsc --watch",
|
|
44
49
|
"index": "pnpm zx ../../scripts/indexer.mjs packages/geo",
|
|
45
|
-
"lint": "pnpm biome lint
|
|
46
|
-
"test": "pnpm vitest --
|
|
50
|
+
"lint": "pnpm biome lint",
|
|
51
|
+
"test": "pnpm vitest --dir=src"
|
|
47
52
|
}
|
|
48
53
|
}
|
|
@@ -1,39 +0,0 @@
|
|
|
1
|
-
// src/coordinates/__fixtures__/index.ts
|
|
2
|
-
var ddPairs = [
|
|
3
|
-
["partial", "40, -74"],
|
|
4
|
-
["partial directions prefix", "N 40, W 74"],
|
|
5
|
-
["partial directions prefix no space", "N40, W74"],
|
|
6
|
-
["partial directions suffix", "40 N, 74 W"],
|
|
7
|
-
["partial directions suffix no space", "40N, 74W"],
|
|
8
|
-
["plus minus", "+40.689247, -74.044502"],
|
|
9
|
-
["inferred plus", "40.689247, -74.044502"],
|
|
10
|
-
["inferred positive direction", "40.689247, 74.044502 W"],
|
|
11
|
-
["degree delimeters", "40.689247\xB0 N, 74.044502\xB0 W"],
|
|
12
|
-
["separator ,", "40.689247,-74.044502"],
|
|
13
|
-
["separator /", "40.689247/-74.044502"],
|
|
14
|
-
["separator space", "40.689247 -74.044502"],
|
|
15
|
-
["NSEW directions prefix", "N 40.689247, W 74.044502"],
|
|
16
|
-
["NSEW directions prefix no space", "N40.689247, W74.044502"],
|
|
17
|
-
["NSEW directions suffix", "40.689247 N, 74.044502 W"],
|
|
18
|
-
["NSEW directions suffix no space", "40.689247N, 74.044502W"],
|
|
19
|
-
["mixed plus minus and directions", "+40.689247, W74.044502"],
|
|
20
|
-
["mixed full and partial", "40.689247, W74"],
|
|
21
|
-
["odd whitespace", " + 40.689247 , - 74.044502 "]
|
|
22
|
-
];
|
|
23
|
-
var dmsPairs = [
|
|
24
|
-
["partial no delimeters", "40 41 -74 02"],
|
|
25
|
-
["partial delimeters", `40\xB0 41' -74 02'`],
|
|
26
|
-
["plus minus no delimeters", "+40 41 21.2892 -74 02 40.2066"],
|
|
27
|
-
["plus minus delimeters", `+40\xB0 41' 21.2892" -74\xB0 02' 40.2066"`],
|
|
28
|
-
["directions no delimeters", "40 41 21.2892 N 74 02 40.2066 W"],
|
|
29
|
-
["directions delimeters", `40\xB0 41' 21.2892" N 74\xB0 02' 40.2066" W`],
|
|
30
|
-
["separator ,", `40\xB0 41' 21.2892",-74\xB0 02' 40.2066"`],
|
|
31
|
-
["separator /", `40\xB0 41' 21.2892"/-74\xB0 02' 40.2066"`],
|
|
32
|
-
["separator space", `40\xB0 41' 21.2892" -74\xB0 02' 40.2066"`]
|
|
33
|
-
];
|
|
34
|
-
var ddmPairs = [];
|
|
35
|
-
var mixedPairs = [];
|
|
36
|
-
|
|
37
|
-
export { ddPairs, ddmPairs, dmsPairs, mixedPairs };
|
|
38
|
-
//# sourceMappingURL=index.js.map
|
|
39
|
-
//# sourceMappingURL=index.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../src/coordinates/__fixtures__/index.ts"],"names":[],"mappings":";AAeO,IAAM,OAAU,GAAA;AAAA,EACrB,CAAC,WAAW,SAAS,CAAA;AAAA,EACrB,CAAC,6BAA6B,YAAY,CAAA;AAAA,EAC1C,CAAC,sCAAsC,UAAU,CAAA;AAAA,EACjD,CAAC,6BAA6B,YAAY,CAAA;AAAA,EAC1C,CAAC,sCAAsC,UAAU,CAAA;AAAA,EACjD,CAAC,cAAc,wBAAwB,CAAA;AAAA,EACvC,CAAC,iBAAiB,uBAAuB,CAAA;AAAA,EACzC,CAAC,+BAA+B,wBAAwB,CAAA;AAAA,EACxD,CAAC,qBAAqB,kCAA4B,CAAA;AAAA,EAClD,CAAC,eAAe,sBAAsB,CAAA;AAAA,EACtC,CAAC,eAAe,sBAAsB,CAAA;AAAA,EACtC,CAAC,mBAAmB,sBAAsB,CAAA;AAAA,EAC1C,CAAC,0BAA0B,0BAA0B,CAAA;AAAA,EACrD,CAAC,mCAAmC,wBAAwB,CAAA;AAAA,EAC5D,CAAC,0BAA0B,0BAA0B,CAAA;AAAA,EACrD,CAAC,mCAAmC,wBAAwB,CAAA;AAAA,EAC5D,CAAC,mCAAmC,wBAAwB,CAAA;AAAA,EAC5D,CAAC,0BAA0B,gBAAgB,CAAA;AAAA,EAC3C,CAAC,kBAAkB,oCAAoC,CAAA;AACzD,EAAA;AAKO,IAAM,QAAW,GAAA;AAAA,EACtB,CAAC,yBAAyB,cAAc,CAAA;AAAA,EACxC,CAAC,sBAAsB,CAAiB,kBAAA,CAAA,CAAA;AAAA,EACxC,CAAC,4BAA4B,+BAA+B,CAAA;AAAA,EAC5D,CAAC,yBAAyB,CAAqC,yCAAA,CAAA,CAAA;AAAA,EAC/D,CAAC,4BAA4B,iCAAiC,CAAA;AAAA,EAC9D,CAAC,yBAAyB,CAAuC,2CAAA,CAAA,CAAA;AAAA,EACjE,CAAC,eAAe,CAAoC,wCAAA,CAAA,CAAA;AAAA,EACpD,CAAC,eAAe,CAAoC,wCAAA,CAAA,CAAA;AAAA,EACpD,CAAC,mBAAmB,CAAoC,wCAAA,CAAA,CAAA;AAC1D,EAAA;AAEO,IAAM,WAAW,GAAC;AAElB,IAAM,aAAa","file":"index.js","sourcesContent":["/*\n * Copyright 2024 Hypergiant Galactic Systems Inc. All rights reserved.\n * This file is licensed to you under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License. You may obtain a copy\n * of the License at https://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software distributed under\n * the License is distributed on an \"AS IS\" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS\n * OF ANY KIND, either express or implied. See the License for the specific language\n * governing permissions and limitations under the License.\n */\n\n// const LAT_DD = 40.689247;\n// const LON_DD = -74.044502;\n\nexport const ddPairs = [\n ['partial', '40, -74'],\n ['partial directions prefix', 'N 40, W 74'],\n ['partial directions prefix no space', 'N40, W74'],\n ['partial directions suffix', '40 N, 74 W'],\n ['partial directions suffix no space', '40N, 74W'],\n ['plus minus', '+40.689247, -74.044502'],\n ['inferred plus', '40.689247, -74.044502'],\n ['inferred positive direction', '40.689247, 74.044502 W'],\n ['degree delimeters', '40.689247° N, 74.044502° W'],\n ['separator ,', '40.689247,-74.044502'],\n ['separator /', '40.689247/-74.044502'],\n ['separator space', '40.689247 -74.044502'],\n ['NSEW directions prefix', 'N 40.689247, W 74.044502'],\n ['NSEW directions prefix no space', 'N40.689247, W74.044502'],\n ['NSEW directions suffix', '40.689247 N, 74.044502 W'],\n ['NSEW directions suffix no space', '40.689247N, 74.044502W'],\n ['mixed plus minus and directions', '+40.689247, W74.044502'],\n ['mixed full and partial', '40.689247, W74'],\n ['odd whitespace', ' + 40.689247 , - 74.044502 '],\n];\n\n// const LAT_DMS = `40° 41' 21.2892\"`;\n// const LON_DMS = `-74° 02' 40.2066\"`;\n\nexport const dmsPairs = [\n ['partial no delimeters', '40 41 -74 02'],\n ['partial delimeters', `40° 41' -74 02'`],\n ['plus minus no delimeters', '+40 41 21.2892 -74 02 40.2066'],\n ['plus minus delimeters', `+40° 41' 21.2892\" -74° 02' 40.2066\"`],\n ['directions no delimeters', '40 41 21.2892 N 74 02 40.2066 W'],\n ['directions delimeters', `40° 41' 21.2892\" N 74° 02' 40.2066\" W`],\n ['separator ,', `40° 41' 21.2892\",-74° 02' 40.2066\"`],\n ['separator /', `40° 41' 21.2892\"/-74° 02' 40.2066\"`],\n ['separator space', `40° 41' 21.2892\" -74° 02' 40.2066\"`],\n];\n\nexport const ddmPairs = [];\n\nexport const mixedPairs = [];\n"]}
|
|
@@ -1,15 +0,0 @@
|
|
|
1
|
-
import { DD_LAT, SEPARATORS, DD_LON, DMS_LAT, DMS_LON } from './regex.js';
|
|
2
|
-
|
|
3
|
-
// src/coordinates/configurations.ts
|
|
4
|
-
var dd = [
|
|
5
|
-
new RegExp(DD_LAT + SEPARATORS + DD_LON, "i"),
|
|
6
|
-
new RegExp(DD_LON + SEPARATORS + DD_LAT, "i")
|
|
7
|
-
];
|
|
8
|
-
var dms = [
|
|
9
|
-
new RegExp(DMS_LAT + SEPARATORS + DMS_LON, "i"),
|
|
10
|
-
new RegExp(DMS_LON + SEPARATORS + DMS_LAT, "i")
|
|
11
|
-
];
|
|
12
|
-
|
|
13
|
-
export { dd, dms };
|
|
14
|
-
//# sourceMappingURL=configurations.js.map
|
|
15
|
-
//# sourceMappingURL=configurations.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"sources":["../../src/coordinates/configurations.ts"],"names":[],"mappings":";;;AASO,IAAM,EAAK,GAAA;AAAA,EAChB,IAAI,MAAA,CAAO,MAAS,GAAA,UAAA,GAAa,QAAQ,GAAG,CAAA;AAAA,EAC5C,IAAI,MAAA,CAAO,MAAS,GAAA,UAAA,GAAa,QAAQ,GAAG,CAAA;AAC9C,EAAA;AAEO,IAAM,GAAM,GAAA;AAAA,EACjB,IAAI,MAAA,CAAO,OAAU,GAAA,UAAA,GAAa,SAAS,GAAG,CAAA;AAAA,EAC9C,IAAI,MAAA,CAAO,OAAU,GAAA,UAAA,GAAa,SAAS,GAAG,CAAA;AAChD","file":"configurations.js","sourcesContent":["// __private-exports\n\nimport { DD_LAT, DD_LON, SEPARATORS, DMS_LAT, DMS_LON } from './regex';\n\n/**\n * NOTE: these pairs are setup to support different lon/lat ordering\n * 0 = latitude first, 1 = longitude first\n */\n\nexport const dd = [\n new RegExp(DD_LAT + SEPARATORS + DD_LON, 'i'),\n new RegExp(DD_LON + SEPARATORS + DD_LAT, 'i'),\n] as const;\n\nexport const dms = [\n new RegExp(DMS_LAT + SEPARATORS + DMS_LON, 'i'),\n new RegExp(DMS_LON + SEPARATORS + DMS_LAT, 'i'),\n] as const;\n"]}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"sources":[],"names":[],"mappings":"","file":"index.js","sourcesContent":[]}
|
|
@@ -1,35 +0,0 @@
|
|
|
1
|
-
type Nullish<T> = T | undefined | null | '';
|
|
2
|
-
type PlusMinus = '+' | '-';
|
|
3
|
-
type Directions = 'N' | 'S' | 'E' | 'W';
|
|
4
|
-
type DDMatches = [
|
|
5
|
-
Nullish<Directions>,
|
|
6
|
-
Nullish<PlusMinus>,
|
|
7
|
-
Nullish<string>,
|
|
8
|
-
Nullish<string>,
|
|
9
|
-
Nullish<Directions>,
|
|
10
|
-
Nullish<Directions>,
|
|
11
|
-
Nullish<PlusMinus>,
|
|
12
|
-
Nullish<string>,
|
|
13
|
-
Nullish<string>,
|
|
14
|
-
Nullish<Directions>
|
|
15
|
-
];
|
|
16
|
-
declare function matchDD(val: unknown): DDMatches;
|
|
17
|
-
type DMSMatches = [
|
|
18
|
-
Nullish<Directions>,
|
|
19
|
-
Nullish<PlusMinus>,
|
|
20
|
-
Nullish<string>,
|
|
21
|
-
Nullish<string>,
|
|
22
|
-
Nullish<string>,
|
|
23
|
-
Nullish<string>,
|
|
24
|
-
Nullish<Directions>,
|
|
25
|
-
Nullish<Directions>,
|
|
26
|
-
Nullish<PlusMinus>,
|
|
27
|
-
Nullish<string>,
|
|
28
|
-
Nullish<string>,
|
|
29
|
-
Nullish<string>,
|
|
30
|
-
Nullish<string>,
|
|
31
|
-
Nullish<Directions>
|
|
32
|
-
];
|
|
33
|
-
declare function matchDMS(val: unknown): DMSMatches;
|
|
34
|
-
|
|
35
|
-
export { matchDD, matchDMS };
|
|
@@ -1,23 +0,0 @@
|
|
|
1
|
-
import { dd, dms } from './configurations.js';
|
|
2
|
-
|
|
3
|
-
// src/coordinates/match.ts
|
|
4
|
-
var ddFallback = Array.from(Array(10), () => "");
|
|
5
|
-
function matchDD(val) {
|
|
6
|
-
const matches = `${val}`.match(dd[0]);
|
|
7
|
-
if (!matches) {
|
|
8
|
-
return ddFallback;
|
|
9
|
-
}
|
|
10
|
-
return Array.from(matches).slice(1);
|
|
11
|
-
}
|
|
12
|
-
var dmsFallback = Array.from(Array(14), () => "");
|
|
13
|
-
function matchDMS(val) {
|
|
14
|
-
const matches = `${val}`.match(dms[0]);
|
|
15
|
-
if (!matches) {
|
|
16
|
-
return dmsFallback;
|
|
17
|
-
}
|
|
18
|
-
return Array.from(matches).slice(1);
|
|
19
|
-
}
|
|
20
|
-
|
|
21
|
-
export { matchDD, matchDMS };
|
|
22
|
-
//# sourceMappingURL=match.js.map
|
|
23
|
-
//# sourceMappingURL=match.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"sources":["../../src/coordinates/match.ts"],"names":[],"mappings":";;;AAgCA,IAAM,aAAa,KAAM,CAAA,IAAA,CAAK,MAAM,EAAE,CAAA,EAAG,MAAM,EAAE,CAAA,CAAA;AAG1C,SAAS,QAAQ,GAAyB,EAAA;AAG/C,EAAA,MAAM,UAAU,CAAG,EAAA,GAAG,GAAG,KAAM,CAAA,EAAA,CAAG,CAAC,CAAC,CAAA,CAAA;AAEpC,EAAA,IAAI,CAAC,OAAS,EAAA;AACZ,IAAO,OAAA,UAAA,CAAA;AAAA,GACT;AAGA,EAAA,OAAO,KAAM,CAAA,IAAA,CAAK,OAAO,CAAA,CAAE,MAAM,CAAC,CAAA,CAAA;AACpC,CAAA;AAoBA,IAAM,cAAc,KAAM,CAAA,IAAA,CAAK,MAAM,EAAE,CAAA,EAAG,MAAM,EAAE,CAAA,CAAA;AAG3C,SAAS,SAAS,GAA0B,EAAA;AAGjD,EAAA,MAAM,UAAU,CAAG,EAAA,GAAG,GAAG,KAAM,CAAA,GAAA,CAAI,CAAC,CAAC,CAAA,CAAA;AAErC,EAAA,IAAI,CAAC,OAAS,EAAA;AACZ,IAAO,OAAA,WAAA,CAAA;AAAA,GACT;AAGA,EAAA,OAAO,KAAM,CAAA,IAAA,CAAK,OAAO,CAAA,CAAE,MAAM,CAAC,CAAA,CAAA;AACpC","file":"match.js","sourcesContent":["/*\n * Copyright 2024 Hypergiant Galactic Systems Inc. All rights reserved.\n * This file is licensed to you under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License. You may obtain a copy\n * of the License at https://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software distributed under\n * the License is distributed on an \"AS IS\" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS\n * OF ANY KIND, either express or implied. See the License for the specific language\n * governing permissions and limitations under the License.\n */\n\nimport { dd, dms } from './configurations';\n\ntype Nullish<T> = T | undefined | null | '';\ntype PlusMinus = '+' | '-';\ntype Directions = 'N' | 'S' | 'E' | 'W';\n\n// biome-ignore lint/style/useNamingConvention: <explanation>\ntype DDMatches = [\n Nullish<Directions>,\n Nullish<PlusMinus>,\n Nullish<string>, // degrees\n Nullish<string>, // decimals\n Nullish<Directions>,\n Nullish<Directions>,\n Nullish<PlusMinus>,\n Nullish<string>, // degrees\n Nullish<string>, // decimals\n Nullish<Directions>,\n];\n\nconst ddFallback = Array.from(Array(10), () => '');\n\n// biome-ignore lint/style/useNamingConvention: <explanation>\nexport function matchDD(val: unknown): DDMatches {\n // TODO: lat/lon ordering\n\n const matches = `${val}`.match(dd[0]);\n\n if (!matches) {\n return ddFallback as DDMatches;\n }\n\n // Remove first regex.match entry since it is the input value\n return Array.from(matches).slice(1) as DDMatches;\n}\n\n// biome-ignore lint/style/useNamingConvention: <explanation>\ntype DMSMatches = [\n Nullish<Directions>,\n Nullish<PlusMinus>,\n Nullish<string>, // degrees\n Nullish<string>, // minutes\n Nullish<string>, // seconds\n Nullish<string>, // milliarcseconds\n Nullish<Directions>,\n Nullish<Directions>,\n Nullish<PlusMinus>,\n Nullish<string>, // degrees\n Nullish<string>, // minutes\n Nullish<string>, // seconds\n Nullish<string>, // milliarcseconds\n Nullish<Directions>,\n];\n\nconst dmsFallback = Array.from(Array(14), () => '');\n\n// biome-ignore lint/style/useNamingConvention: <explanation>\nexport function matchDMS(val: unknown): DMSMatches {\n // TODO: lat/lon ordering\n\n const matches = `${val}`.match(dms[0]);\n\n if (!matches) {\n return dmsFallback as DMSMatches;\n }\n\n // Remove first regex.match entry since it is the input value\n return Array.from(matches).slice(1) as DMSMatches;\n}\n"]}
|
|
@@ -1,27 +0,0 @@
|
|
|
1
|
-
import { toDigits } from '@accelint/converters';
|
|
2
|
-
import { matchDD } from './match.js';
|
|
3
|
-
import { normalizeDirection, isPositiveDirection, negate } from './utils.js';
|
|
4
|
-
|
|
5
|
-
// src/coordinates/normalize.ts
|
|
6
|
-
function normalizeDD(val) {
|
|
7
|
-
const matches = matchDD(val);
|
|
8
|
-
const latDirection = normalizeDirection(matches[0] || matches[4]);
|
|
9
|
-
const lonDirection = normalizeDirection(matches[5] || matches[9]);
|
|
10
|
-
const latPositive = isPositiveDirection(latDirection, matches[1]);
|
|
11
|
-
const lonPositive = isPositiveDirection(lonDirection, matches[6]);
|
|
12
|
-
const latParsed = toDigits(
|
|
13
|
-
Number.parseFloat(`${matches[2]}${matches[3]}`),
|
|
14
|
-
6
|
|
15
|
-
);
|
|
16
|
-
const lonParsed = toDigits(
|
|
17
|
-
Number.parseFloat(`${matches[7]}${matches[8]}`),
|
|
18
|
-
6
|
|
19
|
-
);
|
|
20
|
-
const latValue = latPositive ? latParsed : negate(latParsed);
|
|
21
|
-
const lonValue = lonPositive ? lonParsed : negate(lonParsed);
|
|
22
|
-
return [latValue, lonValue];
|
|
23
|
-
}
|
|
24
|
-
|
|
25
|
-
export { normalizeDD };
|
|
26
|
-
//# sourceMappingURL=normalize.js.map
|
|
27
|
-
//# sourceMappingURL=normalize.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"sources":["../../src/coordinates/normalize.ts"],"names":[],"mappings":";;;;;AAiBO,SAAS,YAAY,GAAa,EAAA;AACvC,EAAM,MAAA,OAAA,GAAU,QAAQ,GAAG,CAAA,CAAA;AAE3B,EAAA,MAAM,eAAe,kBAAmB,CAAA,OAAA,CAAQ,CAAC,CAAK,IAAA,OAAA,CAAQ,CAAC,CAAC,CAAA,CAAA;AAChE,EAAA,MAAM,eAAe,kBAAmB,CAAA,OAAA,CAAQ,CAAC,CAAK,IAAA,OAAA,CAAQ,CAAC,CAAC,CAAA,CAAA;AAChE,EAAA,MAAM,WAAc,GAAA,mBAAA,CAAoB,YAAc,EAAA,OAAA,CAAQ,CAAC,CAAC,CAAA,CAAA;AAChE,EAAA,MAAM,WAAc,GAAA,mBAAA,CAAoB,YAAc,EAAA,OAAA,CAAQ,CAAC,CAAC,CAAA,CAAA;AAEhE,EAAA,MAAM,SAAY,GAAA,QAAA;AAAA,IAChB,MAAA,CAAO,UAAW,CAAA,CAAA,EAAG,OAAQ,CAAA,CAAC,CAAC,CAAG,EAAA,OAAA,CAAQ,CAAC,CAAC,CAAE,CAAA,CAAA;AAAA,IAC9C,CAAA;AAAA,GACF,CAAA;AAEA,EAAA,MAAM,SAAY,GAAA,QAAA;AAAA,IAChB,MAAA,CAAO,UAAW,CAAA,CAAA,EAAG,OAAQ,CAAA,CAAC,CAAC,CAAG,EAAA,OAAA,CAAQ,CAAC,CAAC,CAAE,CAAA,CAAA;AAAA,IAC9C,CAAA;AAAA,GACF,CAAA;AAEA,EAAA,MAAM,QAAW,GAAA,WAAA,GAAc,SAAY,GAAA,MAAA,CAAO,SAAS,CAAA,CAAA;AAC3D,EAAA,MAAM,QAAW,GAAA,WAAA,GAAc,SAAY,GAAA,MAAA,CAAO,SAAS,CAAA,CAAA;AAE3D,EAAO,OAAA,CAAC,UAAU,QAAQ,CAAA,CAAA;AAC5B","file":"normalize.js","sourcesContent":["/*\n * Copyright 2024 Hypergiant Galactic Systems Inc. All rights reserved.\n * This file is licensed to you under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License. You may obtain a copy\n * of the License at https://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software distributed under\n * the License is distributed on an \"AS IS\" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS\n * OF ANY KIND, either express or implied. See the License for the specific language\n * governing permissions and limitations under the License.\n */\n\nimport { toDigits } from '@accelint/converters';\nimport { matchDD } from './match';\nimport { isPositiveDirection, normalizeDirection, negate } from './utils';\n\n// biome-ignore lint/style/useNamingConvention: <explanation>\nexport function normalizeDD(val: string) {\n const matches = matchDD(val);\n\n const latDirection = normalizeDirection(matches[0] || matches[4]);\n const lonDirection = normalizeDirection(matches[5] || matches[9]);\n const latPositive = isPositiveDirection(latDirection, matches[1]);\n const lonPositive = isPositiveDirection(lonDirection, matches[6]);\n\n const latParsed = toDigits(\n Number.parseFloat(`${matches[2]}${matches[3]}`),\n 6,\n );\n\n const lonParsed = toDigits(\n Number.parseFloat(`${matches[7]}${matches[8]}`),\n 6,\n );\n\n const latValue = latPositive ? latParsed : negate(latParsed);\n const lonValue = lonPositive ? lonParsed : negate(lonParsed);\n\n return [latValue, lonValue];\n}\n"]}
|
|
@@ -1,128 +0,0 @@
|
|
|
1
|
-
declare const SEPARATORS = "[\\s,\\/]*";
|
|
2
|
-
/**
|
|
3
|
-
* @see https://en.wikipedia.org/wiki/ISO_6709
|
|
4
|
-
*
|
|
5
|
-
* Matches common DD format for longitude values.
|
|
6
|
-
*
|
|
7
|
-
* NSEW ± DDD.D NSEW
|
|
8
|
-
*
|
|
9
|
-
* Five capture groups:
|
|
10
|
-
* 1. Optional NSEW
|
|
11
|
-
* 2. Optional +-
|
|
12
|
-
* 3. Degrees
|
|
13
|
-
* 4. Optional Decimals
|
|
14
|
-
* 5. Optional NSEW
|
|
15
|
-
*
|
|
16
|
-
* @example
|
|
17
|
-
* ```markdown
|
|
18
|
-
* 75
|
|
19
|
-
* 75.00417
|
|
20
|
-
* 075.00417
|
|
21
|
-
* -075.00417
|
|
22
|
-
* - 075.00417
|
|
23
|
-
* W075.00417
|
|
24
|
-
* 075.00417W
|
|
25
|
-
* W 075.00417
|
|
26
|
-
* 075.00417 W
|
|
27
|
-
* ```
|
|
28
|
-
*/
|
|
29
|
-
declare const DD_LON = "([NSEW]?)[\\s]*([-+]?)[\\s]*(\\d{1,3})(\\.\\d*)?[\\s\u00B0]*([NSEW]?)";
|
|
30
|
-
/**
|
|
31
|
-
* @see https://en.wikipedia.org/wiki/ISO_6709
|
|
32
|
-
*
|
|
33
|
-
* Matches common DD format for latitude values.
|
|
34
|
-
*
|
|
35
|
-
* NSEW ± DD.D NSEW
|
|
36
|
-
*
|
|
37
|
-
* Five capture groups:
|
|
38
|
-
* 1. Optional NSEW
|
|
39
|
-
* 2. Optional +-
|
|
40
|
-
* 3. Degrees
|
|
41
|
-
* 4. Optional Decimals
|
|
42
|
-
* 5. Optional NSEW
|
|
43
|
-
*
|
|
44
|
-
* @example
|
|
45
|
-
* ```markdown
|
|
46
|
-
* 40
|
|
47
|
-
* 40.20361
|
|
48
|
-
* +40.20361
|
|
49
|
-
* + 40.20361
|
|
50
|
-
* N40.20361
|
|
51
|
-
* 40.20361N
|
|
52
|
-
* N 40.20361
|
|
53
|
-
* 40.20361 N
|
|
54
|
-
* ```
|
|
55
|
-
*/
|
|
56
|
-
declare const DD_LAT = "([NSEW]?)[\\s]*([-+]?)[\\s]*(\\d{1,2})(\\.\\d*)?[\\s\u00B0]*([NSEW]?)";
|
|
57
|
-
/**
|
|
58
|
-
* @see https://en.wikipedia.org/wiki/ISO_6709
|
|
59
|
-
*
|
|
60
|
-
* Matches common DMS format for longitude values.
|
|
61
|
-
*
|
|
62
|
-
* Supported delimiters are comma, colon, space, degree, single quote, double quote, and forward slash.
|
|
63
|
-
*
|
|
64
|
-
* NSEW ± DDD DD DD .D|DDD NSEW
|
|
65
|
-
*
|
|
66
|
-
* Seven capture groups:
|
|
67
|
-
* 1. Optional NSEW
|
|
68
|
-
* 2. Optional +-
|
|
69
|
-
* 3. Degrees
|
|
70
|
-
* 4. Minutes
|
|
71
|
-
* 5. Seconds
|
|
72
|
-
* 6. Optional decimal seconds or milliarcseconds
|
|
73
|
-
* 7. Optional NSEW
|
|
74
|
-
*
|
|
75
|
-
* @example
|
|
76
|
-
* ```markdown
|
|
77
|
-
* 403456.45
|
|
78
|
-
* 40 34 56.45
|
|
79
|
-
* 40/34/56.45
|
|
80
|
-
* 40:34:56.45
|
|
81
|
-
* 40°34'56.45
|
|
82
|
-
* 403456
|
|
83
|
-
* 40°34'56"
|
|
84
|
-
* +403456.45
|
|
85
|
-
* W403456.45
|
|
86
|
-
* 403456.45W
|
|
87
|
-
* W 40 34 56.45
|
|
88
|
-
* 40 34 56.45 W
|
|
89
|
-
* ```
|
|
90
|
-
*/
|
|
91
|
-
declare const DMS_LON = "([NSEW]?)[\\s]*([-+]?)[\\s]*(\\d{1,3})[\\s,:\u00B0'\u2032\"\u2033\\/]*(\\d{2})[\\s,:\u00B0'\u2032\"\u2033\\/]*(\\d{2})[\\s,:\u00B0'\u2032\"\u2033\\/]*(\\.\\d*|\\d{3})?[\\s,:\u00B0'\u2032\"\u2033\\/]*([NSEW]?)";
|
|
92
|
-
/**
|
|
93
|
-
* @see https://en.wikipedia.org/wiki/ISO_6709
|
|
94
|
-
*
|
|
95
|
-
* Matches common DMS format for latitude values.
|
|
96
|
-
*
|
|
97
|
-
* Supported delimiters are comma, colon, space, degree, single quote, double quote, and forward slash.
|
|
98
|
-
*
|
|
99
|
-
* NSEW ± DD DD DD .D|DDD NSEW
|
|
100
|
-
*
|
|
101
|
-
* Seven capture groups:
|
|
102
|
-
* 1. Optional NSEW
|
|
103
|
-
* 2. Optional +-
|
|
104
|
-
* 3. Degrees
|
|
105
|
-
* 4. Minutes
|
|
106
|
-
* 5. Seconds
|
|
107
|
-
* 6. Optional decimal seconds or milliarcseconds
|
|
108
|
-
* 7. Optional NSEW
|
|
109
|
-
*
|
|
110
|
-
* @example
|
|
111
|
-
* ```markdown
|
|
112
|
-
* 403456.45
|
|
113
|
-
* 40 34 56.45
|
|
114
|
-
* 40/34/56.45
|
|
115
|
-
* 40:34:56.45
|
|
116
|
-
* 40°34'56.45
|
|
117
|
-
* 403456
|
|
118
|
-
* 40°34'56"
|
|
119
|
-
* +403456.45
|
|
120
|
-
* N403456.45
|
|
121
|
-
* 403456.45N
|
|
122
|
-
* N 40 34 56.45
|
|
123
|
-
* 40 34 56.45 N
|
|
124
|
-
* ```
|
|
125
|
-
*/
|
|
126
|
-
declare const DMS_LAT = "([NSEW]?)[\\s]*([-+]?)[\\s]*(\\d{1,2})[\\s,:\u00B0'\u2032\"\u2033\\/]*(\\d{2})[\\s,:\u00B0'\u2032\"\u2033\\/]*(\\d{2})[\\s,:\u00B0'\u2032\"\u2033\\/]*(\\.\\d*|\\d{3})?[\\s,:\u00B0'\u2032\"\u2033\\/]*([NSEW]?)";
|
|
127
|
-
|
|
128
|
-
export { DD_LAT, DD_LON, DMS_LAT, DMS_LON, SEPARATORS };
|
|
@@ -1,10 +0,0 @@
|
|
|
1
|
-
// src/coordinates/regex.ts
|
|
2
|
-
var SEPARATORS = `[\\s,\\/]*`;
|
|
3
|
-
var DD_LON = `([NSEW]?)[\\s]*([-+]?)[\\s]*(\\d{1,3})(\\.\\d*)?[\\s\xB0]*([NSEW]?)`;
|
|
4
|
-
var DD_LAT = `([NSEW]?)[\\s]*([-+]?)[\\s]*(\\d{1,2})(\\.\\d*)?[\\s\xB0]*([NSEW]?)`;
|
|
5
|
-
var DMS_LON = `([NSEW]?)[\\s]*([-+]?)[\\s]*(\\d{1,3})[\\s,:\xB0'\u2032"\u2033\\/]*(\\d{2})[\\s,:\xB0'\u2032"\u2033\\/]*(\\d{2})[\\s,:\xB0'\u2032"\u2033\\/]*(\\.\\d*|\\d{3})?[\\s,:\xB0'\u2032"\u2033\\/]*([NSEW]?)`;
|
|
6
|
-
var DMS_LAT = `([NSEW]?)[\\s]*([-+]?)[\\s]*(\\d{1,2})[\\s,:\xB0'\u2032"\u2033\\/]*(\\d{2})[\\s,:\xB0'\u2032"\u2033\\/]*(\\d{2})[\\s,:\xB0'\u2032"\u2033\\/]*(\\.\\d*|\\d{3})?[\\s,:\xB0'\u2032"\u2033\\/]*([NSEW]?)`;
|
|
7
|
-
|
|
8
|
-
export { DD_LAT, DD_LON, DMS_LAT, DMS_LON, SEPARATORS };
|
|
9
|
-
//# sourceMappingURL=regex.js.map
|
|
10
|
-
//# sourceMappingURL=regex.js.map
|