@accelint/geo 0.1.0 → 0.1.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/dist/coordinates/__fixtures__/index.d.ts +4 -0
- package/dist/coordinates/__fixtures__/index.js +50 -0
- package/dist/coordinates/__fixtures__/index.js.map +1 -0
- package/dist/coordinates/configurations.d.ts +6 -0
- package/dist/coordinates/configurations.js +15 -0
- package/dist/coordinates/configurations.js.map +1 -0
- package/dist/coordinates/index.d.ts +11 -0
- package/dist/coordinates/index.js +23 -0
- package/dist/coordinates/index.js.map +1 -0
- package/dist/coordinates/match.d.ts +34 -0
- package/dist/coordinates/match.js +35 -0
- package/dist/coordinates/match.js.map +1 -0
- package/dist/coordinates/normalize.d.ts +1 -0
- package/dist/coordinates/normalize.js +28 -0
- package/dist/coordinates/normalize.js.map +1 -0
- package/dist/coordinates/regex.d.ts +126 -0
- package/dist/coordinates/regex.js +142 -0
- package/dist/coordinates/regex.js.map +1 -0
- package/dist/coordinates/utils.d.ts +5 -0
- package/dist/coordinates/utils.js +27 -0
- package/dist/coordinates/utils.js.map +1 -0
- package/dist/index.d.ts +5 -0
- package/dist/index.js +6 -0
- package/dist/index.js.map +1 -0
- package/package.json +5 -5
|
@@ -0,0 +1,50 @@
|
|
|
1
|
+
/*
|
|
2
|
+
* Copyright 2024 Hypergiant Galactic Systems Inc. All rights reserved.
|
|
3
|
+
* This file is licensed to you under the Apache License, Version 2.0 (the "License");
|
|
4
|
+
* you may not use this file except in compliance with the License. You may obtain a copy
|
|
5
|
+
* of the License at https://www.apache.org/licenses/LICENSE-2.0
|
|
6
|
+
*
|
|
7
|
+
* Unless required by applicable law or agreed to in writing, software distributed under
|
|
8
|
+
* the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS
|
|
9
|
+
* OF ANY KIND, either express or implied. See the License for the specific language
|
|
10
|
+
* governing permissions and limitations under the License.
|
|
11
|
+
*/
|
|
12
|
+
// const LAT_DD = 40.689247;
|
|
13
|
+
// const LON_DD = -74.044502;
|
|
14
|
+
export const ddPairs = [
|
|
15
|
+
['partial', '40, -74'],
|
|
16
|
+
['partial directions prefix', 'N 40, W 74'],
|
|
17
|
+
['partial directions prefix no space', 'N40, W74'],
|
|
18
|
+
['partial directions suffix', '40 N, 74 W'],
|
|
19
|
+
['partial directions suffix no space', '40N, 74W'],
|
|
20
|
+
['plus minus', '+40.689247, -74.044502'],
|
|
21
|
+
['inferred plus', '40.689247, -74.044502'],
|
|
22
|
+
['inferred positive direction', '40.689247, 74.044502 W'],
|
|
23
|
+
['degree delimeters', '40.689247° N, 74.044502° W'],
|
|
24
|
+
['separator ,', '40.689247,-74.044502'],
|
|
25
|
+
['separator /', '40.689247/-74.044502'],
|
|
26
|
+
['separator space', '40.689247 -74.044502'],
|
|
27
|
+
['NSEW directions prefix', 'N 40.689247, W 74.044502'],
|
|
28
|
+
['NSEW directions prefix no space', 'N40.689247, W74.044502'],
|
|
29
|
+
['NSEW directions suffix', '40.689247 N, 74.044502 W'],
|
|
30
|
+
['NSEW directions suffix no space', '40.689247N, 74.044502W'],
|
|
31
|
+
['mixed plus minus and directions', '+40.689247, W74.044502'],
|
|
32
|
+
['mixed full and partial', '40.689247, W74'],
|
|
33
|
+
['odd whitespace', ' + 40.689247 , - 74.044502 '],
|
|
34
|
+
];
|
|
35
|
+
// const LAT_DMS = `40° 41' 21.2892"`;
|
|
36
|
+
// const LON_DMS = `-74° 02' 40.2066"`;
|
|
37
|
+
export const dmsPairs = [
|
|
38
|
+
['partial no delimeters', '40 41 -74 02'],
|
|
39
|
+
['partial delimeters', `40° 41' -74 02'`],
|
|
40
|
+
['plus minus no delimeters', '+40 41 21.2892 -74 02 40.2066'],
|
|
41
|
+
['plus minus delimeters', `+40° 41' 21.2892" -74° 02' 40.2066"`],
|
|
42
|
+
['directions no delimeters', '40 41 21.2892 N 74 02 40.2066 W'],
|
|
43
|
+
['directions delimeters', `40° 41' 21.2892" N 74° 02' 40.2066" W`],
|
|
44
|
+
['separator ,', `40° 41' 21.2892",-74° 02' 40.2066"`],
|
|
45
|
+
['separator /', `40° 41' 21.2892"/-74° 02' 40.2066"`],
|
|
46
|
+
['separator space', `40° 41' 21.2892" -74° 02' 40.2066"`],
|
|
47
|
+
];
|
|
48
|
+
export const ddmPairs = [];
|
|
49
|
+
export const mixedPairs = [];
|
|
50
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/coordinates/__fixtures__/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;GAUG;AAEH,4BAA4B;AAC5B,6BAA6B;AAE7B,MAAM,CAAC,MAAM,OAAO,GAAG;IACrB,CAAC,SAAS,EAAE,SAAS,CAAC;IACtB,CAAC,2BAA2B,EAAE,YAAY,CAAC;IAC3C,CAAC,oCAAoC,EAAE,UAAU,CAAC;IAClD,CAAC,2BAA2B,EAAE,YAAY,CAAC;IAC3C,CAAC,oCAAoC,EAAE,UAAU,CAAC;IAClD,CAAC,YAAY,EAAE,wBAAwB,CAAC;IACxC,CAAC,eAAe,EAAE,uBAAuB,CAAC;IAC1C,CAAC,6BAA6B,EAAE,wBAAwB,CAAC;IACzD,CAAC,mBAAmB,EAAE,4BAA4B,CAAC;IACnD,CAAC,aAAa,EAAE,sBAAsB,CAAC;IACvC,CAAC,aAAa,EAAE,sBAAsB,CAAC;IACvC,CAAC,iBAAiB,EAAE,sBAAsB,CAAC;IAC3C,CAAC,wBAAwB,EAAE,0BAA0B,CAAC;IACtD,CAAC,iCAAiC,EAAE,wBAAwB,CAAC;IAC7D,CAAC,wBAAwB,EAAE,0BAA0B,CAAC;IACtD,CAAC,iCAAiC,EAAE,wBAAwB,CAAC;IAC7D,CAAC,iCAAiC,EAAE,wBAAwB,CAAC;IAC7D,CAAC,wBAAwB,EAAE,gBAAgB,CAAC;IAC5C,CAAC,gBAAgB,EAAE,oCAAoC,CAAC;CACzD,CAAC;AAEF,sCAAsC;AACtC,uCAAuC;AAEvC,MAAM,CAAC,MAAM,QAAQ,GAAG;IACtB,CAAC,uBAAuB,EAAE,cAAc,CAAC;IACzC,CAAC,oBAAoB,EAAE,iBAAiB,CAAC;IACzC,CAAC,0BAA0B,EAAE,+BAA+B,CAAC;IAC7D,CAAC,uBAAuB,EAAE,qCAAqC,CAAC;IAChE,CAAC,0BAA0B,EAAE,iCAAiC,CAAC;IAC/D,CAAC,uBAAuB,EAAE,uCAAuC,CAAC;IAClE,CAAC,aAAa,EAAE,oCAAoC,CAAC;IACrD,CAAC,aAAa,EAAE,oCAAoC,CAAC;IACrD,CAAC,iBAAiB,EAAE,oCAAoC,CAAC;CAC1D,CAAC;AAEF,MAAM,CAAC,MAAM,QAAQ,GAAG,EAAE,CAAC;AAE3B,MAAM,CAAC,MAAM,UAAU,GAAG,EAAE,CAAC"}
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
// __private-exports
|
|
2
|
+
import { DD_LAT, DD_LON, SEPARATORS, DMS_LAT, DMS_LON } from './regex';
|
|
3
|
+
/**
|
|
4
|
+
* NOTE: these pairs are setup to support different lon/lat ordering
|
|
5
|
+
* 0 = latitude first, 1 = longitude first
|
|
6
|
+
*/
|
|
7
|
+
export const dd = [
|
|
8
|
+
new RegExp(DD_LAT + SEPARATORS + DD_LON, 'i'),
|
|
9
|
+
new RegExp(DD_LON + SEPARATORS + DD_LAT, 'i'),
|
|
10
|
+
];
|
|
11
|
+
export const dms = [
|
|
12
|
+
new RegExp(DMS_LAT + SEPARATORS + DMS_LON, 'i'),
|
|
13
|
+
new RegExp(DMS_LON + SEPARATORS + DMS_LAT, 'i'),
|
|
14
|
+
];
|
|
15
|
+
//# sourceMappingURL=configurations.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"configurations.js","sourceRoot":"","sources":["../../src/coordinates/configurations.ts"],"names":[],"mappings":"AAAA,oBAAoB;AAEpB,OAAO,EAAE,MAAM,EAAE,MAAM,EAAE,UAAU,EAAE,OAAO,EAAE,OAAO,EAAE,MAAM,SAAS,CAAC;AAEvE;;;GAGG;AAEH,MAAM,CAAC,MAAM,EAAE,GAAG;IAChB,IAAI,MAAM,CAAC,MAAM,GAAG,UAAU,GAAG,MAAM,EAAE,GAAG,CAAC;IAC7C,IAAI,MAAM,CAAC,MAAM,GAAG,UAAU,GAAG,MAAM,EAAE,GAAG,CAAC;CACrC,CAAC;AAEX,MAAM,CAAC,MAAM,GAAG,GAAG;IACjB,IAAI,MAAM,CAAC,OAAO,GAAG,UAAU,GAAG,OAAO,EAAE,GAAG,CAAC;IAC/C,IAAI,MAAM,CAAC,OAAO,GAAG,UAAU,GAAG,OAAO,EAAE,GAAG,CAAC;CACvC,CAAC"}
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* TODOs:
|
|
3
|
+
*
|
|
4
|
+
* - Auto detect lon/lat ordering?
|
|
5
|
+
* - Some tricks we can
|
|
6
|
+
* - Regex for NS as first few chars
|
|
7
|
+
* - Regex for 3 digits
|
|
8
|
+
* - Regex for first digit > 90
|
|
9
|
+
*/
|
|
10
|
+
export { matchDD, matchDMS } from './match';
|
|
11
|
+
export { normalizeDD } from './normalize';
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
/*
|
|
2
|
+
* Copyright 2024 Hypergiant Galactic Systems Inc. All rights reserved.
|
|
3
|
+
* This file is licensed to you under the Apache License, Version 2.0 (the "License");
|
|
4
|
+
* you may not use this file except in compliance with the License. You may obtain a copy
|
|
5
|
+
* of the License at https://www.apache.org/licenses/LICENSE-2.0
|
|
6
|
+
*
|
|
7
|
+
* Unless required by applicable law or agreed to in writing, software distributed under
|
|
8
|
+
* the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS
|
|
9
|
+
* OF ANY KIND, either express or implied. See the License for the specific language
|
|
10
|
+
* governing permissions and limitations under the License.
|
|
11
|
+
*/
|
|
12
|
+
/**
|
|
13
|
+
* TODOs:
|
|
14
|
+
*
|
|
15
|
+
* - Auto detect lon/lat ordering?
|
|
16
|
+
* - Some tricks we can
|
|
17
|
+
* - Regex for NS as first few chars
|
|
18
|
+
* - Regex for 3 digits
|
|
19
|
+
* - Regex for first digit > 90
|
|
20
|
+
*/
|
|
21
|
+
export { matchDD, matchDMS } from './match';
|
|
22
|
+
export { normalizeDD } from './normalize';
|
|
23
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/coordinates/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;GAUG;AAEH;;;;;;;;GAQG;AAEH,OAAO,EAAE,OAAO,EAAE,QAAQ,EAAE,MAAM,SAAS,CAAC;AAC5C,OAAO,EAAE,WAAW,EAAE,MAAM,aAAa,CAAC"}
|
|
@@ -0,0 +1,34 @@
|
|
|
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
|
+
export 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
|
+
export declare function matchDMS(val: unknown): DMSMatches;
|
|
34
|
+
export {};
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
/*
|
|
2
|
+
* Copyright 2024 Hypergiant Galactic Systems Inc. All rights reserved.
|
|
3
|
+
* This file is licensed to you under the Apache License, Version 2.0 (the "License");
|
|
4
|
+
* you may not use this file except in compliance with the License. You may obtain a copy
|
|
5
|
+
* of the License at https://www.apache.org/licenses/LICENSE-2.0
|
|
6
|
+
*
|
|
7
|
+
* Unless required by applicable law or agreed to in writing, software distributed under
|
|
8
|
+
* the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS
|
|
9
|
+
* OF ANY KIND, either express or implied. See the License for the specific language
|
|
10
|
+
* governing permissions and limitations under the License.
|
|
11
|
+
*/
|
|
12
|
+
import { dd, dms } from './configurations';
|
|
13
|
+
const ddFallback = Array.from(Array(10), () => '');
|
|
14
|
+
// biome-ignore lint/style/useNamingConvention: <explanation>
|
|
15
|
+
export function matchDD(val) {
|
|
16
|
+
// TODO: lat/lon ordering
|
|
17
|
+
const matches = `${val}`.match(dd[0]);
|
|
18
|
+
if (!matches) {
|
|
19
|
+
return ddFallback;
|
|
20
|
+
}
|
|
21
|
+
// Remove first regex.match entry since it is the input value
|
|
22
|
+
return Array.from(matches).slice(1);
|
|
23
|
+
}
|
|
24
|
+
const dmsFallback = Array.from(Array(14), () => '');
|
|
25
|
+
// biome-ignore lint/style/useNamingConvention: <explanation>
|
|
26
|
+
export function matchDMS(val) {
|
|
27
|
+
// TODO: lat/lon ordering
|
|
28
|
+
const matches = `${val}`.match(dms[0]);
|
|
29
|
+
if (!matches) {
|
|
30
|
+
return dmsFallback;
|
|
31
|
+
}
|
|
32
|
+
// Remove first regex.match entry since it is the input value
|
|
33
|
+
return Array.from(matches).slice(1);
|
|
34
|
+
}
|
|
35
|
+
//# sourceMappingURL=match.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"match.js","sourceRoot":"","sources":["../../src/coordinates/match.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;GAUG;AAEH,OAAO,EAAE,EAAE,EAAE,GAAG,EAAE,MAAM,kBAAkB,CAAC;AAoB3C,MAAM,UAAU,GAAG,KAAK,CAAC,IAAI,CAAC,KAAK,CAAC,EAAE,CAAC,EAAE,GAAG,EAAE,CAAC,EAAE,CAAC,CAAC;AAEnD,6DAA6D;AAC7D,MAAM,UAAU,OAAO,CAAC,GAAY;IAClC,yBAAyB;IAEzB,MAAM,OAAO,GAAG,GAAG,GAAG,EAAE,CAAC,KAAK,CAAC,EAAE,CAAC,CAAC,CAAC,CAAC,CAAC;IAEtC,IAAI,CAAC,OAAO,EAAE,CAAC;QACb,OAAO,UAAuB,CAAC;IACjC,CAAC;IAED,6DAA6D;IAC7D,OAAO,KAAK,CAAC,IAAI,CAAC,OAAO,CAAC,CAAC,KAAK,CAAC,CAAC,CAAc,CAAC;AACnD,CAAC;AAoBD,MAAM,WAAW,GAAG,KAAK,CAAC,IAAI,CAAC,KAAK,CAAC,EAAE,CAAC,EAAE,GAAG,EAAE,CAAC,EAAE,CAAC,CAAC;AAEpD,6DAA6D;AAC7D,MAAM,UAAU,QAAQ,CAAC,GAAY;IACnC,yBAAyB;IAEzB,MAAM,OAAO,GAAG,GAAG,GAAG,EAAE,CAAC,KAAK,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC,CAAC;IAEvC,IAAI,CAAC,OAAO,EAAE,CAAC;QACb,OAAO,WAAyB,CAAC;IACnC,CAAC;IAED,6DAA6D;IAC7D,OAAO,KAAK,CAAC,IAAI,CAAC,OAAO,CAAC,CAAC,KAAK,CAAC,CAAC,CAAe,CAAC;AACpD,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare function normalizeDD(val: string): number[];
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
/*
|
|
2
|
+
* Copyright 2024 Hypergiant Galactic Systems Inc. All rights reserved.
|
|
3
|
+
* This file is licensed to you under the Apache License, Version 2.0 (the "License");
|
|
4
|
+
* you may not use this file except in compliance with the License. You may obtain a copy
|
|
5
|
+
* of the License at https://www.apache.org/licenses/LICENSE-2.0
|
|
6
|
+
*
|
|
7
|
+
* Unless required by applicable law or agreed to in writing, software distributed under
|
|
8
|
+
* the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS
|
|
9
|
+
* OF ANY KIND, either express or implied. See the License for the specific language
|
|
10
|
+
* governing permissions and limitations under the License.
|
|
11
|
+
*/
|
|
12
|
+
import { toDigits } from '@accelint/converters';
|
|
13
|
+
import { matchDD } from './match';
|
|
14
|
+
import { isPositiveDirection, normalizeDirection, negate } from './utils';
|
|
15
|
+
// biome-ignore lint/style/useNamingConvention: <explanation>
|
|
16
|
+
export function normalizeDD(val) {
|
|
17
|
+
const matches = matchDD(val);
|
|
18
|
+
const latDirection = normalizeDirection(matches[0] || matches[4]);
|
|
19
|
+
const lonDirection = normalizeDirection(matches[5] || matches[9]);
|
|
20
|
+
const latPositive = isPositiveDirection(latDirection, matches[1]);
|
|
21
|
+
const lonPositive = isPositiveDirection(lonDirection, matches[6]);
|
|
22
|
+
const latParsed = toDigits(Number.parseFloat(`${matches[2]}${matches[3]}`), 6);
|
|
23
|
+
const lonParsed = toDigits(Number.parseFloat(`${matches[7]}${matches[8]}`), 6);
|
|
24
|
+
const latValue = latPositive ? latParsed : negate(latParsed);
|
|
25
|
+
const lonValue = lonPositive ? lonParsed : negate(lonParsed);
|
|
26
|
+
return [latValue, lonValue];
|
|
27
|
+
}
|
|
28
|
+
//# sourceMappingURL=normalize.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"normalize.js","sourceRoot":"","sources":["../../src/coordinates/normalize.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;GAUG;AAEH,OAAO,EAAE,QAAQ,EAAE,MAAM,sBAAsB,CAAC;AAChD,OAAO,EAAE,OAAO,EAAE,MAAM,SAAS,CAAC;AAClC,OAAO,EAAE,mBAAmB,EAAE,kBAAkB,EAAE,MAAM,EAAE,MAAM,SAAS,CAAC;AAE1E,6DAA6D;AAC7D,MAAM,UAAU,WAAW,CAAC,GAAW;IACrC,MAAM,OAAO,GAAG,OAAO,CAAC,GAAG,CAAC,CAAC;IAE7B,MAAM,YAAY,GAAG,kBAAkB,CAAC,OAAO,CAAC,CAAC,CAAC,IAAI,OAAO,CAAC,CAAC,CAAC,CAAC,CAAC;IAClE,MAAM,YAAY,GAAG,kBAAkB,CAAC,OAAO,CAAC,CAAC,CAAC,IAAI,OAAO,CAAC,CAAC,CAAC,CAAC,CAAC;IAClE,MAAM,WAAW,GAAG,mBAAmB,CAAC,YAAY,EAAE,OAAO,CAAC,CAAC,CAAC,CAAC,CAAC;IAClE,MAAM,WAAW,GAAG,mBAAmB,CAAC,YAAY,EAAE,OAAO,CAAC,CAAC,CAAC,CAAC,CAAC;IAElE,MAAM,SAAS,GAAG,QAAQ,CACxB,MAAM,CAAC,UAAU,CAAC,GAAG,OAAO,CAAC,CAAC,CAAC,GAAG,OAAO,CAAC,CAAC,CAAC,EAAE,CAAC,EAC/C,CAAC,CACF,CAAC;IAEF,MAAM,SAAS,GAAG,QAAQ,CACxB,MAAM,CAAC,UAAU,CAAC,GAAG,OAAO,CAAC,CAAC,CAAC,GAAG,OAAO,CAAC,CAAC,CAAC,EAAE,CAAC,EAC/C,CAAC,CACF,CAAC;IAEF,MAAM,QAAQ,GAAG,WAAW,CAAC,CAAC,CAAC,SAAS,CAAC,CAAC,CAAC,MAAM,CAAC,SAAS,CAAC,CAAC;IAC7D,MAAM,QAAQ,GAAG,WAAW,CAAC,CAAC,CAAC,SAAS,CAAC,CAAC,CAAC,MAAM,CAAC,SAAS,CAAC,CAAC;IAE7D,OAAO,CAAC,QAAQ,EAAE,QAAQ,CAAC,CAAC;AAC9B,CAAC"}
|
|
@@ -0,0 +1,126 @@
|
|
|
1
|
+
export 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
|
+
export 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
|
+
export 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
|
+
export 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
|
+
export 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]?)";
|
|
@@ -0,0 +1,142 @@
|
|
|
1
|
+
// __private-exports
|
|
2
|
+
/*
|
|
3
|
+
* Copyright 2024 Hypergiant Galactic Systems Inc. All rights reserved.
|
|
4
|
+
* This file is licensed to you under the Apache License, Version 2.0 (the "License");
|
|
5
|
+
* you may not use this file except in compliance with the License. You may obtain a copy
|
|
6
|
+
* of the License at https://www.apache.org/licenses/LICENSE-2.0
|
|
7
|
+
*
|
|
8
|
+
* Unless required by applicable law or agreed to in writing, software distributed under
|
|
9
|
+
* the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS
|
|
10
|
+
* OF ANY KIND, either express or implied. See the License for the specific language
|
|
11
|
+
* governing permissions and limitations under the License.
|
|
12
|
+
*/
|
|
13
|
+
// biome-ignore lint/style/noUnusedTemplateLiteral: makes it easier for future modifications
|
|
14
|
+
export const SEPARATORS = `[\\s,\\/]*`;
|
|
15
|
+
/**
|
|
16
|
+
* @see https://en.wikipedia.org/wiki/ISO_6709
|
|
17
|
+
*
|
|
18
|
+
* Matches common DD format for longitude values.
|
|
19
|
+
*
|
|
20
|
+
* NSEW ± DDD.D NSEW
|
|
21
|
+
*
|
|
22
|
+
* Five capture groups:
|
|
23
|
+
* 1. Optional NSEW
|
|
24
|
+
* 2. Optional +-
|
|
25
|
+
* 3. Degrees
|
|
26
|
+
* 4. Optional Decimals
|
|
27
|
+
* 5. Optional NSEW
|
|
28
|
+
*
|
|
29
|
+
* @example
|
|
30
|
+
* ```markdown
|
|
31
|
+
* 75
|
|
32
|
+
* 75.00417
|
|
33
|
+
* 075.00417
|
|
34
|
+
* -075.00417
|
|
35
|
+
* - 075.00417
|
|
36
|
+
* W075.00417
|
|
37
|
+
* 075.00417W
|
|
38
|
+
* W 075.00417
|
|
39
|
+
* 075.00417 W
|
|
40
|
+
* ```
|
|
41
|
+
*/
|
|
42
|
+
// biome-ignore lint/style/noUnusedTemplateLiteral: makes it easier for future modifications
|
|
43
|
+
export const DD_LON = `([NSEW]?)[\\s]*([-+]?)[\\s]*(\\d{1,3})(\\.\\d*)?[\\s°]*([NSEW]?)`;
|
|
44
|
+
/**
|
|
45
|
+
* @see https://en.wikipedia.org/wiki/ISO_6709
|
|
46
|
+
*
|
|
47
|
+
* Matches common DD format for latitude values.
|
|
48
|
+
*
|
|
49
|
+
* NSEW ± DD.D NSEW
|
|
50
|
+
*
|
|
51
|
+
* Five capture groups:
|
|
52
|
+
* 1. Optional NSEW
|
|
53
|
+
* 2. Optional +-
|
|
54
|
+
* 3. Degrees
|
|
55
|
+
* 4. Optional Decimals
|
|
56
|
+
* 5. Optional NSEW
|
|
57
|
+
*
|
|
58
|
+
* @example
|
|
59
|
+
* ```markdown
|
|
60
|
+
* 40
|
|
61
|
+
* 40.20361
|
|
62
|
+
* +40.20361
|
|
63
|
+
* + 40.20361
|
|
64
|
+
* N40.20361
|
|
65
|
+
* 40.20361N
|
|
66
|
+
* N 40.20361
|
|
67
|
+
* 40.20361 N
|
|
68
|
+
* ```
|
|
69
|
+
*/
|
|
70
|
+
// biome-ignore lint/style/noUnusedTemplateLiteral: makes it easier for future modifications
|
|
71
|
+
export const DD_LAT = `([NSEW]?)[\\s]*([-+]?)[\\s]*(\\d{1,2})(\\.\\d*)?[\\s°]*([NSEW]?)`;
|
|
72
|
+
/**
|
|
73
|
+
* @see https://en.wikipedia.org/wiki/ISO_6709
|
|
74
|
+
*
|
|
75
|
+
* Matches common DMS format for longitude values.
|
|
76
|
+
*
|
|
77
|
+
* Supported delimiters are comma, colon, space, degree, single quote, double quote, and forward slash.
|
|
78
|
+
*
|
|
79
|
+
* NSEW ± DDD DD DD .D|DDD NSEW
|
|
80
|
+
*
|
|
81
|
+
* Seven capture groups:
|
|
82
|
+
* 1. Optional NSEW
|
|
83
|
+
* 2. Optional +-
|
|
84
|
+
* 3. Degrees
|
|
85
|
+
* 4. Minutes
|
|
86
|
+
* 5. Seconds
|
|
87
|
+
* 6. Optional decimal seconds or milliarcseconds
|
|
88
|
+
* 7. Optional NSEW
|
|
89
|
+
*
|
|
90
|
+
* @example
|
|
91
|
+
* ```markdown
|
|
92
|
+
* 403456.45
|
|
93
|
+
* 40 34 56.45
|
|
94
|
+
* 40/34/56.45
|
|
95
|
+
* 40:34:56.45
|
|
96
|
+
* 40°34'56.45
|
|
97
|
+
* 403456
|
|
98
|
+
* 40°34'56"
|
|
99
|
+
* +403456.45
|
|
100
|
+
* W403456.45
|
|
101
|
+
* 403456.45W
|
|
102
|
+
* W 40 34 56.45
|
|
103
|
+
* 40 34 56.45 W
|
|
104
|
+
* ```
|
|
105
|
+
*/
|
|
106
|
+
export const DMS_LON = `([NSEW]?)[\\s]*([-+]?)[\\s]*(\\d{1,3})[\\s,:°'′"″\\/]*(\\d{2})[\\s,:°'′"″\\/]*(\\d{2})[\\s,:°'′"″\\/]*(\\.\\d*|\\d{3})?[\\s,:°'′"″\\/]*([NSEW]?)`;
|
|
107
|
+
/**
|
|
108
|
+
* @see https://en.wikipedia.org/wiki/ISO_6709
|
|
109
|
+
*
|
|
110
|
+
* Matches common DMS format for latitude values.
|
|
111
|
+
*
|
|
112
|
+
* Supported delimiters are comma, colon, space, degree, single quote, double quote, and forward slash.
|
|
113
|
+
*
|
|
114
|
+
* NSEW ± DD DD DD .D|DDD NSEW
|
|
115
|
+
*
|
|
116
|
+
* Seven capture groups:
|
|
117
|
+
* 1. Optional NSEW
|
|
118
|
+
* 2. Optional +-
|
|
119
|
+
* 3. Degrees
|
|
120
|
+
* 4. Minutes
|
|
121
|
+
* 5. Seconds
|
|
122
|
+
* 6. Optional decimal seconds or milliarcseconds
|
|
123
|
+
* 7. Optional NSEW
|
|
124
|
+
*
|
|
125
|
+
* @example
|
|
126
|
+
* ```markdown
|
|
127
|
+
* 403456.45
|
|
128
|
+
* 40 34 56.45
|
|
129
|
+
* 40/34/56.45
|
|
130
|
+
* 40:34:56.45
|
|
131
|
+
* 40°34'56.45
|
|
132
|
+
* 403456
|
|
133
|
+
* 40°34'56"
|
|
134
|
+
* +403456.45
|
|
135
|
+
* N403456.45
|
|
136
|
+
* 403456.45N
|
|
137
|
+
* N 40 34 56.45
|
|
138
|
+
* 40 34 56.45 N
|
|
139
|
+
* ```
|
|
140
|
+
*/
|
|
141
|
+
export const DMS_LAT = `([NSEW]?)[\\s]*([-+]?)[\\s]*(\\d{1,2})[\\s,:°'′"″\\/]*(\\d{2})[\\s,:°'′"″\\/]*(\\d{2})[\\s,:°'′"″\\/]*(\\.\\d*|\\d{3})?[\\s,:°'′"″\\/]*([NSEW]?)`;
|
|
142
|
+
//# sourceMappingURL=regex.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"regex.js","sourceRoot":"","sources":["../../src/coordinates/regex.ts"],"names":[],"mappings":"AAAA,oBAAoB;AAEpB;;;;;;;;;;GAUG;AAEH,4FAA4F;AAC5F,MAAM,CAAC,MAAM,UAAU,GAAG,YAAY,CAAC;AAEvC;;;;;;;;;;;;;;;;;;;;;;;;;;GA0BG;AACH,4FAA4F;AAC5F,MAAM,CAAC,MAAM,MAAM,GAAG,kEAAkE,CAAC;AAEzF;;;;;;;;;;;;;;;;;;;;;;;;;GAyBG;AACH,4FAA4F;AAC5F,MAAM,CAAC,MAAM,MAAM,GAAG,kEAAkE,CAAC;AAEzF;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAiCG;AACH,MAAM,CAAC,MAAM,OAAO,GAAG,kJAAkJ,CAAC;AAE1K;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAiCG;AACH,MAAM,CAAC,MAAM,OAAO,GAAG,kJAAkJ,CAAC"}
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
type Nullish<T> = T | undefined | null | '';
|
|
2
|
+
export declare function normalizeDirection(dir: Nullish<string>): 'N' | 'S' | 'E' | 'W' | '';
|
|
3
|
+
export declare function negate(val: number): number;
|
|
4
|
+
export declare function isPositiveDirection(dir: Nullish<'N' | 'S' | 'E' | 'W'>, sign: Nullish<'+' | '-'>): boolean;
|
|
5
|
+
export {};
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
// __private-exports
|
|
2
|
+
const supportedDirections = ['N', 'S', 'E', 'W'];
|
|
3
|
+
export function normalizeDirection(dir) {
|
|
4
|
+
if (!dir) {
|
|
5
|
+
return '';
|
|
6
|
+
}
|
|
7
|
+
const val = dir.toUpperCase();
|
|
8
|
+
// Sanity check that the we have a correct direction value
|
|
9
|
+
if (!supportedDirections.includes(val)) {
|
|
10
|
+
return '';
|
|
11
|
+
}
|
|
12
|
+
return val;
|
|
13
|
+
}
|
|
14
|
+
export function negate(val) {
|
|
15
|
+
return val * -1;
|
|
16
|
+
}
|
|
17
|
+
export function isPositiveDirection(dir, sign) {
|
|
18
|
+
if (sign === '-') {
|
|
19
|
+
return false;
|
|
20
|
+
}
|
|
21
|
+
if (dir === 'S' || dir === 'W') {
|
|
22
|
+
return false;
|
|
23
|
+
}
|
|
24
|
+
// A positive direction can be assumed from here
|
|
25
|
+
return true;
|
|
26
|
+
}
|
|
27
|
+
//# sourceMappingURL=utils.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"utils.js","sourceRoot":"","sources":["../../src/coordinates/utils.ts"],"names":[],"mappings":"AAAA,oBAAoB;AAgBpB,MAAM,mBAAmB,GAAG,CAAC,GAAG,EAAE,GAAG,EAAE,GAAG,EAAE,GAAG,CAAC,CAAC;AAEjD,MAAM,UAAU,kBAAkB,CAChC,GAAoB;IAEpB,IAAI,CAAC,GAAG,EAAE,CAAC;QACT,OAAO,EAAE,CAAC;IACZ,CAAC;IAED,MAAM,GAAG,GAAG,GAAG,CAAC,WAAW,EAAE,CAAC;IAE9B,0DAA0D;IAC1D,IAAI,CAAC,mBAAmB,CAAC,QAAQ,CAAC,GAAG,CAAC,EAAE,CAAC;QACvC,OAAO,EAAE,CAAC;IACZ,CAAC;IAED,OAAO,GAA4B,CAAC;AACtC,CAAC;AAED,MAAM,UAAU,MAAM,CAAC,GAAW;IAChC,OAAO,GAAG,GAAG,CAAC,CAAC,CAAC;AAClB,CAAC;AAED,MAAM,UAAU,mBAAmB,CACjC,GAAmC,EACnC,IAAwB;IAExB,IAAI,IAAI,KAAK,GAAG,EAAE,CAAC;QACjB,OAAO,KAAK,CAAC;IACf,CAAC;IAED,IAAI,GAAG,KAAK,GAAG,IAAI,GAAG,KAAK,GAAG,EAAE,CAAC;QAC/B,OAAO,KAAK,CAAC;IACf,CAAC;IAED,gDAAgD;IAChD,OAAO,IAAI,CAAC;AACd,CAAC"}
|
package/dist/index.d.ts
ADDED
package/dist/index.js
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA;;GAEG;AAEH,OAAO,EAAE,OAAO,EAAE,QAAQ,EAAE,MAAM,qBAAqB,CAAC;AACxD,OAAO,EAAE,WAAW,EAAE,MAAM,yBAAyB,CAAC"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@accelint/geo",
|
|
3
|
-
"version": "0.1.
|
|
3
|
+
"version": "0.1.1",
|
|
4
4
|
"private": false,
|
|
5
5
|
"license": "Apache-2.0",
|
|
6
6
|
"type": "module",
|
|
@@ -14,13 +14,13 @@
|
|
|
14
14
|
"devDependencies": {
|
|
15
15
|
"@vitest/coverage-istanbul": "^2.1.3",
|
|
16
16
|
"vitest": "^2.1.3",
|
|
17
|
-
"@accelint/typescript-config": "0.1.
|
|
18
|
-
"@accelint/vitest-config": "0.1.
|
|
17
|
+
"@accelint/typescript-config": "0.1.1",
|
|
18
|
+
"@accelint/vitest-config": "0.1.1"
|
|
19
19
|
},
|
|
20
20
|
"dependencies": {
|
|
21
21
|
"typescript": "^5.6.3",
|
|
22
|
-
"@accelint/converters": "0.1.
|
|
23
|
-
"@accelint/predicates": "0.1.
|
|
22
|
+
"@accelint/converters": "0.1.1",
|
|
23
|
+
"@accelint/predicates": "0.1.1"
|
|
24
24
|
},
|
|
25
25
|
"$schema": "https://json.schemastore.org/package",
|
|
26
26
|
"author": "https://hypergiant.com",
|