@math.gl/dggs 5.0.0-alpha.2 → 5.0.0-alpha.20
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/LICENSE +54 -87
- package/README.md +6 -1
- package/THIRD-PARTY-NOTICES.md +18 -0
- package/dist/a5-decoder.d.ts +4 -4
- package/dist/a5-decoder.d.ts.map +1 -1
- package/dist/a5-decoder.js +4 -4
- package/dist/a5-decoder.js.map +1 -1
- package/dist/a5.cjs +59 -2
- package/dist/a5.cjs.map +3 -3
- package/dist/a5.js +1 -1
- package/dist/a5.js.map +1 -1
- package/dist/converters/s2-to-obb-points.js +1 -1
- package/dist/converters/s2-to-obb-points.js.map +1 -1
- package/dist/converters/s2-to-region.js +1 -1
- package/dist/converters/s2-to-region.js.map +1 -1
- package/dist/dggs-decoder.d.ts +13 -4
- package/dist/dggs-decoder.d.ts.map +1 -1
- package/dist/dggs-decoder.js +25 -1
- package/dist/dggs-decoder.js.map +1 -1
- package/dist/expressions.cjs +637 -0
- package/dist/expressions.cjs.map +6 -0
- package/dist/expressions.d.ts +7 -0
- package/dist/expressions.d.ts.map +1 -0
- package/dist/expressions.js +32 -0
- package/dist/expressions.js.map +1 -0
- package/dist/geohash-decoder.d.ts +4 -4
- package/dist/geohash-decoder.d.ts.map +1 -1
- package/dist/geohash-decoder.js +4 -4
- package/dist/geohash-decoder.js.map +1 -1
- package/dist/geohash.cjs +75 -2
- package/dist/geohash.cjs.map +2 -2
- package/dist/geohash.js +1 -1
- package/dist/geohash.js.map +1 -1
- package/dist/h3-decoder.d.ts +4 -4
- package/dist/h3-decoder.d.ts.map +1 -1
- package/dist/h3-decoder.js +4 -4
- package/dist/h3-decoder.js.map +1 -1
- package/dist/h3.cjs +59 -2
- package/dist/h3.cjs.map +3 -3
- package/dist/h3.js +1 -1
- package/dist/h3.js.map +1 -1
- package/dist/index.cjs +281 -33
- package/dist/index.cjs.map +3 -3
- package/dist/index.d.ts +6 -3
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +5 -3
- package/dist/index.js.map +1 -1
- package/dist/plus-code-decoder.d.ts +4 -4
- package/dist/plus-code-decoder.d.ts.map +1 -1
- package/dist/plus-code-decoder.js +4 -4
- package/dist/plus-code-decoder.js.map +1 -1
- package/dist/plus-code.cjs +75 -2
- package/dist/plus-code.cjs.map +2 -2
- package/dist/plus-code.js +1 -1
- package/dist/plus-code.js.map +1 -1
- package/dist/quadkey-decoder.d.ts +4 -4
- package/dist/quadkey-decoder.d.ts.map +1 -1
- package/dist/quadkey-decoder.js +4 -4
- package/dist/quadkey-decoder.js.map +1 -1
- package/dist/quadkey.cjs +75 -2
- package/dist/quadkey.cjs.map +2 -2
- package/dist/quadkey.js +1 -1
- package/dist/quadkey.js.map +1 -1
- package/dist/s2-decoder.d.ts +14 -4
- package/dist/s2-decoder.d.ts.map +1 -1
- package/dist/s2-decoder.js +90 -22
- package/dist/s2-decoder.js.map +1 -1
- package/dist/s2-geometry/s2-geometry.d.ts +20 -0
- package/dist/s2-geometry/s2-geometry.d.ts.map +1 -1
- package/dist/s2-geometry/s2-geometry.js +128 -2
- package/dist/s2-geometry/s2-geometry.js.map +1 -1
- package/dist/s2-geometry/s2-to-boundary.js +1 -1
- package/dist/s2-geometry/s2-to-boundary.js.map +1 -1
- package/dist/s2-geometry/s2-token.d.ts +30 -0
- package/dist/s2-geometry/s2-token.d.ts.map +1 -1
- package/dist/s2-geometry/s2-token.js +74 -6
- package/dist/s2-geometry/s2-token.js.map +1 -1
- package/dist/s2.cjs +288 -23
- package/dist/s2.cjs.map +2 -2
- package/dist/s2.d.ts +4 -2
- package/dist/s2.d.ts.map +1 -1
- package/dist/s2.js +4 -3
- package/dist/s2.js.map +1 -1
- package/dist/unwrap-dggs-boundary.d.ts +12 -0
- package/dist/unwrap-dggs-boundary.d.ts.map +1 -0
- package/dist/unwrap-dggs-boundary.js +49 -0
- package/dist/unwrap-dggs-boundary.js.map +1 -0
- package/package.json +13 -6
- package/src/a5-decoder.ts +10 -5
- package/src/a5.ts +1 -1
- package/src/converters/s2-to-obb-points.ts +2 -2
- package/src/converters/s2-to-region.ts +1 -1
- package/src/dggs-decoder.ts +42 -5
- package/src/expressions.ts +37 -0
- package/src/geohash-decoder.ts +10 -5
- package/src/geohash.ts +1 -1
- package/src/h3-decoder.ts +10 -5
- package/src/h3.ts +1 -1
- package/src/index.ts +14 -3
- package/src/open-location-code.d.ts +3 -0
- package/src/plus-code-decoder.ts +10 -5
- package/src/plus-code.ts +1 -1
- package/src/quadkey-decoder.ts +10 -5
- package/src/quadkey.ts +1 -1
- package/src/s2-decoder.ts +92 -22
- package/src/s2-geometry/s2-geometry.ts +142 -2
- package/src/s2-geometry/s2-to-boundary.ts +1 -1
- package/src/s2-geometry/s2-token.ts +77 -6
- package/src/s2.ts +12 -3
- package/src/unwrap-dggs-boundary.ts +54 -0
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
// math.gl
|
|
2
|
+
// SPDX-License-Identifier: MIT
|
|
3
|
+
// SPDX-FileCopyrightText: Copyright (c) vis.gl contributors
|
|
4
|
+
/* eslint-disable @typescript-eslint/no-explicit-any, @typescript-eslint/no-unsafe-return */
|
|
5
|
+
import { GeohashDecoder } from "./geohash-decoder.js";
|
|
6
|
+
import { QuadkeyDecoder, quadkeyToWorldBounds } from "./quadkey-decoder.js";
|
|
7
|
+
import { S2Decoder } from "./s2-decoder.js";
|
|
8
|
+
import { getS2ChildIndex } from "./s2-geometry/s2-token.js";
|
|
9
|
+
export const GEOHASH_FUNCTION_LIBRARY = {
|
|
10
|
+
getGeohashBoundary: GeohashDecoder.cellToBoundary,
|
|
11
|
+
getGeohashBoundaryFlat: GeohashDecoder.cellToBoundaryFlat,
|
|
12
|
+
getGeohashBounds: GeohashDecoder.cellToBounds,
|
|
13
|
+
getGeohashLngLat: GeohashDecoder.cellToLngLat
|
|
14
|
+
};
|
|
15
|
+
export const QUADKEY_FUNCTION_LIBRARY = {
|
|
16
|
+
getQuadkeyBoundary: QuadkeyDecoder.cellToBoundary,
|
|
17
|
+
getQuadkeyBoundaryFlat: QuadkeyDecoder.cellToBoundaryFlat,
|
|
18
|
+
getQuadkeyLngLat: QuadkeyDecoder.cellToLngLat,
|
|
19
|
+
quadkeyToWorldBounds
|
|
20
|
+
};
|
|
21
|
+
export const S2_FUNCTION_LIBRARY = {
|
|
22
|
+
getS2BoundaryFlat: S2Decoder.cellToBoundaryFlat,
|
|
23
|
+
getS2ChildIndex,
|
|
24
|
+
getS2IndexFromToken: S2Decoder.tokenToCell,
|
|
25
|
+
getS2TokenFromIndex: S2Decoder.cellToToken
|
|
26
|
+
};
|
|
27
|
+
export const DGGS_FUNCTION_LIBRARY = {
|
|
28
|
+
...GEOHASH_FUNCTION_LIBRARY,
|
|
29
|
+
...QUADKEY_FUNCTION_LIBRARY,
|
|
30
|
+
...S2_FUNCTION_LIBRARY
|
|
31
|
+
};
|
|
32
|
+
//# sourceMappingURL=expressions.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"expressions.js","sourceRoot":"","sources":["../src/expressions.ts"],"names":[],"mappings":"AAAA,UAAU;AACV,+BAA+B;AAC/B,4DAA4D;AAC5D,4FAA4F;AAE5F,OAAO,EAAC,cAAc,EAAC,6BAA0B;AACjD,OAAO,EAAC,cAAc,EAAE,oBAAoB,EAAC,6BAA0B;AACvE,OAAO,EAAC,SAAS,EAAC,wBAAqB;AACvC,OAAO,EAAC,eAAe,EAAC,kCAA+B;AAGvD,MAAM,CAAC,MAAM,wBAAwB,GAA8B;IACjE,kBAAkB,EAAE,cAAc,CAAC,cAAc;IACjD,sBAAsB,EAAE,cAAc,CAAC,kBAAkB;IACzD,gBAAgB,EAAE,cAAc,CAAC,YAAY;IAC7C,gBAAgB,EAAE,cAAc,CAAC,YAAY;CAC9C,CAAC;AAEF,MAAM,CAAC,MAAM,wBAAwB,GAA8B;IACjE,kBAAkB,EAAE,cAAc,CAAC,cAAc;IACjD,sBAAsB,EAAE,cAAc,CAAC,kBAAkB;IACzD,gBAAgB,EAAE,cAAc,CAAC,YAAY;IAC7C,oBAAoB;CACrB,CAAC;AAEF,MAAM,CAAC,MAAM,mBAAmB,GAA8B;IAC5D,iBAAiB,EAAE,SAAS,CAAC,kBAAkB;IAC/C,eAAe;IACf,mBAAmB,EAAE,SAAS,CAAC,WAAW;IAC1C,mBAAmB,EAAE,SAAS,CAAC,WAAW;CAC3C,CAAC;AAEF,MAAM,CAAC,MAAM,qBAAqB,GAA8B;IAC9D,GAAG,wBAAwB;IAC3B,GAAG,wBAAwB;IAC3B,GAAG,mBAAmB;CACvB,CAAC"}
|
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
import { type Bounds2D } from '@math.gl/types';
|
|
2
|
-
import { type DGGSCell } from "./dggs-decoder.js";
|
|
1
|
+
import { type Bounds2D } from '@math.gl/core/types';
|
|
2
|
+
import { type DGGSCell, type DGGSDecoder } from "./dggs-decoder.js";
|
|
3
3
|
/** Decoder for the geohash dggs */
|
|
4
|
-
export declare const GeohashDecoder: {
|
|
4
|
+
export declare const GeohashDecoder: Omit<{
|
|
5
5
|
readonly name: "geohash";
|
|
6
6
|
readonly hasNumericRepresentation: false;
|
|
7
7
|
readonly cellColumnNames: readonly ["geohash", "geohashId", "geohash_id"];
|
|
@@ -9,7 +9,7 @@ export declare const GeohashDecoder: {
|
|
|
9
9
|
readonly cellToBoundary: (cell: DGGSCell) => [number, number][];
|
|
10
10
|
readonly cellToBoundaryFlat: (cell: DGGSCell) => number[];
|
|
11
11
|
readonly cellToBounds: (cell: DGGSCell) => Bounds2D;
|
|
12
|
-
}
|
|
12
|
+
}, "cellToBoundary" | "cellToBoundaryFlat" | "cellToBounds"> & Pick<DGGSDecoder, "cellToBoundary" | "cellToBoundaryFlat" | "cellToBounds">;
|
|
13
13
|
/**
|
|
14
14
|
* @note Adapted from ngeohash decode_bbox
|
|
15
15
|
*/
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"geohash-decoder.d.ts","sourceRoot":"","sources":["../src/geohash-decoder.ts"],"names":[],"mappings":"AAIA,OAAO,EAAC,KAAK,QAAQ,EAAC,MAAM,
|
|
1
|
+
{"version":3,"file":"geohash-decoder.d.ts","sourceRoot":"","sources":["../src/geohash-decoder.ts"],"names":[],"mappings":"AAIA,OAAO,EAAC,KAAK,QAAQ,EAAC,MAAM,qBAAqB,CAAC;AAClD,OAAO,EAEL,KAAK,QAAQ,EACb,KAAK,WAAW,EAEjB,0BAAuB;AAExB,mCAAmC;AACnC,eAAO,MAAM,cAAc;;;;kCAIJ,QAAQ,KAAG,CAAC,MAAM,EAAE,MAAM,CAAC;oCAEzB,QAAQ,KAAG,CAAC,MAAM,EAAE,MAAM,CAAC,EAAE;wCAEzB,QAAQ,KAAG,MAAM,EAAE;kCAEzB,QAAQ,KAAG,QAAQ;0IACT,CAAC;AAqClC;;GAEG;AAEH,wBAAgB,gBAAgB,CAAC,OAAO,EAAE,MAAM,GAAG,QAAQ,CAsC1D"}
|
package/dist/geohash-decoder.js
CHANGED
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
// math.gl
|
|
2
2
|
// SPDX-License-Identifier: MIT
|
|
3
|
-
// Copyright (c) vis.gl contributors
|
|
4
|
-
import { getDGGSCellToken } from "./dggs-decoder.js";
|
|
3
|
+
// SPDX-FileCopyrightText: Copyright (c) vis.gl contributors
|
|
4
|
+
import { withDGGSBoundaryOptions, getDGGSCellToken } from "./dggs-decoder.js";
|
|
5
5
|
/** Decoder for the geohash dggs */
|
|
6
|
-
export const GeohashDecoder = {
|
|
6
|
+
export const GeohashDecoder = withDGGSBoundaryOptions({
|
|
7
7
|
name: 'geohash',
|
|
8
8
|
hasNumericRepresentation: false,
|
|
9
9
|
cellColumnNames: ['geohash', 'geohashId', 'geohash_id'],
|
|
@@ -11,7 +11,7 @@ export const GeohashDecoder = {
|
|
|
11
11
|
cellToBoundary: (cell) => getGeohashBoundary(getDGGSCellToken(cell, 'GeoHash')),
|
|
12
12
|
cellToBoundaryFlat: (cell) => getGeohashBoundaryFlat(getDGGSCellToken(cell, 'GeoHash')),
|
|
13
13
|
cellToBounds: (cell) => getGeohashBounds(getDGGSCellToken(cell, 'GeoHash'))
|
|
14
|
-
};
|
|
14
|
+
});
|
|
15
15
|
const BASE32_CODES = '0123456789bcdefghjkmnpqrstuvwxyz';
|
|
16
16
|
const BASE32_CODES_DICT = {};
|
|
17
17
|
for (let i = 0; i < BASE32_CODES.length; i++) {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"geohash-decoder.js","sourceRoot":"","sources":["../src/geohash-decoder.ts"],"names":[],"mappings":"AAAA,UAAU;AACV,+BAA+B;AAC/B,
|
|
1
|
+
{"version":3,"file":"geohash-decoder.js","sourceRoot":"","sources":["../src/geohash-decoder.ts"],"names":[],"mappings":"AAAA,UAAU;AACV,+BAA+B;AAC/B,4DAA4D;AAG5D,OAAO,EACL,uBAAuB,EAGvB,gBAAgB,EACjB,0BAAuB;AAExB,mCAAmC;AACnC,MAAM,CAAC,MAAM,cAAc,GAAG,uBAAuB,CAAC;IACpD,IAAI,EAAE,SAAS;IACf,wBAAwB,EAAE,KAAK;IAC/B,eAAe,EAAE,CAAC,SAAS,EAAE,WAAW,EAAE,YAAY,CAAC;IACvD,YAAY,EAAE,CAAC,IAAc,EAAoB,EAAE,CACjD,gBAAgB,CAAC,gBAAgB,CAAC,IAAI,EAAE,SAAS,CAAC,CAAC;IACrD,cAAc,EAAE,CAAC,IAAc,EAAsB,EAAE,CACrD,kBAAkB,CAAC,gBAAgB,CAAC,IAAI,EAAE,SAAS,CAAC,CAAC;IACvD,kBAAkB,EAAE,CAAC,IAAc,EAAY,EAAE,CAC/C,sBAAsB,CAAC,gBAAgB,CAAC,IAAI,EAAE,SAAS,CAAC,CAAC;IAC3D,YAAY,EAAE,CAAC,IAAc,EAAY,EAAE,CAAC,gBAAgB,CAAC,gBAAgB,CAAC,IAAI,EAAE,SAAS,CAAC,CAAC;CACjE,CAAC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AG,CAAC,MAAM,GAAG,MAAM,CAAC,GAAG,CAAC,CAAC;gBAC5B,IAAI,GAAG,KAAK,CAAC,EAAE,CAAC;oBACd,MAAM,GAAG,GAAG,CAAC;gBACf,CAAC;qBAAM,CAAC;oBACN,MAAM,GAAG,GAAG,CAAC;gBACf,CAAC;YACH,CAAC;YACD,KAAK,GAAG,CAAC,KAAK,CAAC;QACjB,CAAC;IACH,CAAC;IAED,OAAO;QACL,CAAC,MAAM,EAAE,MAAM,CAAC;QAChB,CAAC,MAAM,EAAE,MAAM,CAAC;KACjB,CAAC;AACJ,CAAC"}
|
package/dist/geohash.cjs
CHANGED
|
@@ -24,6 +24,42 @@ __export(geohash_exports, {
|
|
|
24
24
|
});
|
|
25
25
|
module.exports = __toCommonJS(geohash_exports);
|
|
26
26
|
|
|
27
|
+
// dist/unwrap-dggs-boundary.js
|
|
28
|
+
function unwrapDGGSBoundary(boundary, referenceLongitude) {
|
|
29
|
+
const result = boundary.map(([longitude, latitude]) => [longitude, latitude]);
|
|
30
|
+
if (result.length === 0) {
|
|
31
|
+
return result;
|
|
32
|
+
}
|
|
33
|
+
let west = Infinity;
|
|
34
|
+
let east = -Infinity;
|
|
35
|
+
for (const [longitude] of boundary) {
|
|
36
|
+
west = Math.min(west, longitude);
|
|
37
|
+
east = Math.max(east, longitude);
|
|
38
|
+
}
|
|
39
|
+
if (east - west >= 360) {
|
|
40
|
+
return result;
|
|
41
|
+
}
|
|
42
|
+
let previous = referenceLongitude ?? result[0][0];
|
|
43
|
+
for (const point of result) {
|
|
44
|
+
const delta = point[0] - previous;
|
|
45
|
+
if (delta > 180) {
|
|
46
|
+
point[0] -= 360 * Math.ceil((delta - 180) / 360);
|
|
47
|
+
} else if (delta < -180) {
|
|
48
|
+
point[0] += 360 * Math.ceil((-delta - 180) / 360);
|
|
49
|
+
}
|
|
50
|
+
previous = point[0];
|
|
51
|
+
}
|
|
52
|
+
const first = boundary[0];
|
|
53
|
+
const last = boundary[boundary.length - 1];
|
|
54
|
+
if (first[0] === last[0] && first[1] === last[1]) {
|
|
55
|
+
if (Math.abs(result[result.length - 1][0] - result[0][0]) > 180) {
|
|
56
|
+
return boundary.map(([longitude, latitude]) => [longitude, latitude]);
|
|
57
|
+
}
|
|
58
|
+
result[result.length - 1] = [...result[0]];
|
|
59
|
+
}
|
|
60
|
+
return result;
|
|
61
|
+
}
|
|
62
|
+
|
|
27
63
|
// dist/dggs-decoder.js
|
|
28
64
|
function getDGGSCellToken(cell, gridName) {
|
|
29
65
|
if (typeof cell !== "string") {
|
|
@@ -31,9 +67,46 @@ function getDGGSCellToken(cell, gridName) {
|
|
|
31
67
|
}
|
|
32
68
|
return cell;
|
|
33
69
|
}
|
|
70
|
+
function getDGGSCellBounds(boundary) {
|
|
71
|
+
let west = Infinity;
|
|
72
|
+
let south = Infinity;
|
|
73
|
+
let east = -Infinity;
|
|
74
|
+
let north = -Infinity;
|
|
75
|
+
for (const [longitude, latitude] of boundary) {
|
|
76
|
+
west = Math.min(west, longitude);
|
|
77
|
+
south = Math.min(south, latitude);
|
|
78
|
+
east = Math.max(east, longitude);
|
|
79
|
+
north = Math.max(north, latitude);
|
|
80
|
+
}
|
|
81
|
+
return [
|
|
82
|
+
[west, south],
|
|
83
|
+
[east, north]
|
|
84
|
+
];
|
|
85
|
+
}
|
|
86
|
+
function withDGGSBoundaryOptions(decoder) {
|
|
87
|
+
const cellToBoundary = (cell, options) => {
|
|
88
|
+
const boundary = decoder.cellToBoundary(cell);
|
|
89
|
+
return (options == null ? void 0 : options.unwrap) ? unwrapDGGSBoundary(boundary, options.referenceLongitude) : boundary;
|
|
90
|
+
};
|
|
91
|
+
return {
|
|
92
|
+
...decoder,
|
|
93
|
+
cellToBoundary,
|
|
94
|
+
cellToBoundaryFlat: (cell, options) => (options == null ? void 0 : options.unwrap) ? cellToBoundary(cell, options).flat() : decoder.cellToBoundaryFlat(cell),
|
|
95
|
+
cellToBounds: (cell, options) => {
|
|
96
|
+
const bounds = decoder.cellToBounds(cell);
|
|
97
|
+
if (!(options == null ? void 0 : options.unwrap) || bounds[1][0] - bounds[0][0] >= 360) {
|
|
98
|
+
return bounds;
|
|
99
|
+
}
|
|
100
|
+
const unwrapped = getDGGSCellBounds(cellToBoundary(cell, options));
|
|
101
|
+
unwrapped[0][1] = bounds[0][1];
|
|
102
|
+
unwrapped[1][1] = bounds[1][1];
|
|
103
|
+
return unwrapped;
|
|
104
|
+
}
|
|
105
|
+
};
|
|
106
|
+
}
|
|
34
107
|
|
|
35
108
|
// dist/geohash-decoder.js
|
|
36
|
-
var GeohashDecoder = {
|
|
109
|
+
var GeohashDecoder = withDGGSBoundaryOptions({
|
|
37
110
|
name: "geohash",
|
|
38
111
|
hasNumericRepresentation: false,
|
|
39
112
|
cellColumnNames: ["geohash", "geohashId", "geohash_id"],
|
|
@@ -41,7 +114,7 @@ var GeohashDecoder = {
|
|
|
41
114
|
cellToBoundary: (cell) => getGeohashBoundary(getDGGSCellToken(cell, "GeoHash")),
|
|
42
115
|
cellToBoundaryFlat: (cell) => getGeohashBoundaryFlat(getDGGSCellToken(cell, "GeoHash")),
|
|
43
116
|
cellToBounds: (cell) => getGeohashBounds(getDGGSCellToken(cell, "GeoHash"))
|
|
44
|
-
};
|
|
117
|
+
});
|
|
45
118
|
var BASE32_CODES = "0123456789bcdefghjkmnpqrstuvwxyz";
|
|
46
119
|
var BASE32_CODES_DICT = {};
|
|
47
120
|
for (let i = 0; i < BASE32_CODES.length; i++) {
|
package/dist/geohash.cjs.map
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
|
-
"sources": ["../src/geohash.ts", "../src/dggs-decoder.ts", "../src/geohash-decoder.ts"],
|
|
4
|
-
"mappings": ";;;;;;;;;;;;;;;;;;;AAAA;;;;;;;;
|
|
3
|
+
"sources": ["../src/geohash.ts", "../src/unwrap-dggs-boundary.ts", "../src/dggs-decoder.ts", "../src/geohash-decoder.ts"],
|
|
4
|
+
"mappings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AAChB,WAAS,IAAI,GAAG,IAAI,QAAQ,QAAQ,IAAI,GAAG,KAAK;AAC9C,UAAM,OAAO,QAAQ,CAAC,EAAE,YAAW;AACnC,gBAAY,kBAAkB,IAAI;AAElC,aAAS,OAAO,GAAG,QAAQ,GAAG,QAAQ;AACpC,YAAM,MAAO,aAAa,OAAQ;AAClC,UAAI,OAAO;AACT,eAAO,SAAS,UAAU;AAC1B,YAAI,QAAQ,GAAG;AACb,mBAAS;QACX,OAAO;AACL,mBAAS;QACX;MACF,OAAO;AACL,eAAO,SAAS,UAAU;AAC1B,YAAI,QAAQ,GAAG;AACb,mBAAS;QACX,OAAO;AACL,mBAAS;QACX;MACF;AACA,cAAQ,CAAC;IACX;EACF;AAEA,SAAO;IACL,CAAC,QAAQ,MAAM;IACf,CAAC,QAAQ,MAAM;;AAEnB;",
|
|
5
5
|
"names": []
|
|
6
6
|
}
|
package/dist/geohash.js
CHANGED
package/dist/geohash.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"geohash.js","sourceRoot":"","sources":["../src/geohash.ts"],"names":[],"mappings":"AAAA,UAAU;AACV,+BAA+B;AAC/B,
|
|
1
|
+
{"version":3,"file":"geohash.js","sourceRoot":"","sources":["../src/geohash.ts"],"names":[],"mappings":"AAAA,UAAU;AACV,+BAA+B;AAC/B,4DAA4D;AAE5D,OAAO,EAAC,cAAc,EAAE,gBAAgB,EAAC,6BAA0B"}
|
package/dist/h3-decoder.d.ts
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
import { type Bounds2D } from '@math.gl/types';
|
|
2
|
-
import { type DGGSCell } from "./dggs-decoder.js";
|
|
1
|
+
import { type Bounds2D } from '@math.gl/core/types';
|
|
2
|
+
import { type DGGSCell, type DGGSDecoder } from "./dggs-decoder.js";
|
|
3
3
|
/** Lightweight cell geometry decoder for the H3 hexagonal DGGS. */
|
|
4
|
-
export declare const H3Decoder: {
|
|
4
|
+
export declare const H3Decoder: Omit<{
|
|
5
5
|
readonly name: "h3";
|
|
6
6
|
readonly hasNumericRepresentation: true;
|
|
7
7
|
readonly cellColumnNames: readonly ["h3", "h3Index", "h3_index", "h3Cell", "h3_cell", "h3CellId", "h3_cell_id", "hexagon"];
|
|
@@ -11,5 +11,5 @@ export declare const H3Decoder: {
|
|
|
11
11
|
readonly cellToBoundary: (cell: DGGSCell) => [number, number][];
|
|
12
12
|
readonly cellToBoundaryFlat: (cell: DGGSCell) => number[];
|
|
13
13
|
readonly cellToBounds: (cell: DGGSCell) => Bounds2D;
|
|
14
|
-
}
|
|
14
|
+
}, "cellToBoundary" | "cellToBoundaryFlat" | "cellToBounds"> & Pick<DGGSDecoder, "cellToBoundary" | "cellToBoundaryFlat" | "cellToBounds">;
|
|
15
15
|
//# sourceMappingURL=h3-decoder.d.ts.map
|
package/dist/h3-decoder.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"h3-decoder.d.ts","sourceRoot":"","sources":["../src/h3-decoder.ts"],"names":[],"mappings":"AAKA,OAAO,EAAC,KAAK,QAAQ,EAAC,MAAM,
|
|
1
|
+
{"version":3,"file":"h3-decoder.d.ts","sourceRoot":"","sources":["../src/h3-decoder.ts"],"names":[],"mappings":"AAKA,OAAO,EAAC,KAAK,QAAQ,EAAC,MAAM,qBAAqB,CAAC;AAClD,OAAO,EAEL,KAAK,QAAQ,EACb,KAAK,WAAW,EAEjB,0BAAuB;AAExB,mEAAmE;AACnE,eAAO,MAAM,SAAS;;;;kCAaC,MAAM,KAAG,MAAM;iCAChB,QAAQ,KAAG,MAAM;kCAChB,QAAQ,KAAG,CAAC,MAAM,EAAE,MAAM,CAAC;oCACzB,QAAQ,KAAG,CAAC,MAAM,EAAE,MAAM,CAAC,EAAE;wCACzB,QAAQ,KAAG,MAAM,EAAE;kCACzB,QAAQ,KAAG,QAAQ;0IACT,CAAC"}
|
package/dist/h3-decoder.js
CHANGED
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
// math.gl
|
|
2
2
|
// SPDX-License-Identifier: MIT
|
|
3
|
-
// Copyright (c) vis.gl contributors
|
|
3
|
+
// SPDX-FileCopyrightText: Copyright (c) vis.gl contributors
|
|
4
4
|
import { cellToBoundary, cellToLatLng } from 'h3-js';
|
|
5
|
-
import { getDGGSCellBounds } from "./dggs-decoder.js";
|
|
5
|
+
import { withDGGSBoundaryOptions, getDGGSCellBounds } from "./dggs-decoder.js";
|
|
6
6
|
/** Lightweight cell geometry decoder for the H3 hexagonal DGGS. */
|
|
7
|
-
export const H3Decoder = {
|
|
7
|
+
export const H3Decoder = withDGGSBoundaryOptions({
|
|
8
8
|
name: 'h3',
|
|
9
9
|
hasNumericRepresentation: true,
|
|
10
10
|
cellColumnNames: [
|
|
@@ -23,7 +23,7 @@ export const H3Decoder = {
|
|
|
23
23
|
cellToBoundary: (cell) => getH3Boundary(cell),
|
|
24
24
|
cellToBoundaryFlat: (cell) => getH3Boundary(cell).flat(),
|
|
25
25
|
cellToBounds: (cell) => getDGGSCellBounds(getH3Boundary(cell))
|
|
26
|
-
};
|
|
26
|
+
});
|
|
27
27
|
function getH3Token(cell) {
|
|
28
28
|
return typeof cell === 'bigint' ? cell.toString(16) : removeHexPrefix(cell);
|
|
29
29
|
}
|
package/dist/h3-decoder.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"h3-decoder.js","sourceRoot":"","sources":["../src/h3-decoder.ts"],"names":[],"mappings":"AAAA,UAAU;AACV,+BAA+B;AAC/B,
|
|
1
|
+
{"version":3,"file":"h3-decoder.js","sourceRoot":"","sources":["../src/h3-decoder.ts"],"names":[],"mappings":"AAAA,UAAU;AACV,+BAA+B;AAC/B,4DAA4D;AAE5D,OAAO,EAAC,cAAc,EAAE,YAAY,EAAC,MAAM,OAAO,CAAC;AAEnD,OAAO,EACL,uBAAuB,EAGvB,iBAAiB,EAClB,0BAAuB;AAExB,mEAAmE;AACnE,MAAM,CAAC,MAAM,SAAS,GAAG,uB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ACT,QAAQ;KACT,CAAC,CAAC;AACL,CAAC;AAED,SAAS,qBAAqB,CAAC,KAAa;IAC1C,OAAO,MAAM,CAAC,KAAK,eAAe,CAAC,KAAK,CAAC,EAAE,CAAC,CAAC;AAC/C,CAAC;AAED,SAAS,eAAe,CAAC,KAAa;IACpC,OAAO,KAAK,CAAC,UAAU,CAAC,IAAI,CAAC,IAAI,KAAK,CAAC,UAAU,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC,KAAK,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,KAAK,CAAC;AACnF,CAAC"}
|
package/dist/h3.cjs
CHANGED
|
@@ -26,6 +26,42 @@ module.exports = __toCommonJS(h3_exports);
|
|
|
26
26
|
// dist/h3-decoder.js
|
|
27
27
|
var import_h3_js = require("h3-js");
|
|
28
28
|
|
|
29
|
+
// dist/unwrap-dggs-boundary.js
|
|
30
|
+
function unwrapDGGSBoundary(boundary, referenceLongitude) {
|
|
31
|
+
const result = boundary.map(([longitude, latitude]) => [longitude, latitude]);
|
|
32
|
+
if (result.length === 0) {
|
|
33
|
+
return result;
|
|
34
|
+
}
|
|
35
|
+
let west = Infinity;
|
|
36
|
+
let east = -Infinity;
|
|
37
|
+
for (const [longitude] of boundary) {
|
|
38
|
+
west = Math.min(west, longitude);
|
|
39
|
+
east = Math.max(east, longitude);
|
|
40
|
+
}
|
|
41
|
+
if (east - west >= 360) {
|
|
42
|
+
return result;
|
|
43
|
+
}
|
|
44
|
+
let previous = referenceLongitude ?? result[0][0];
|
|
45
|
+
for (const point of result) {
|
|
46
|
+
const delta = point[0] - previous;
|
|
47
|
+
if (delta > 180) {
|
|
48
|
+
point[0] -= 360 * Math.ceil((delta - 180) / 360);
|
|
49
|
+
} else if (delta < -180) {
|
|
50
|
+
point[0] += 360 * Math.ceil((-delta - 180) / 360);
|
|
51
|
+
}
|
|
52
|
+
previous = point[0];
|
|
53
|
+
}
|
|
54
|
+
const first = boundary[0];
|
|
55
|
+
const last = boundary[boundary.length - 1];
|
|
56
|
+
if (first[0] === last[0] && first[1] === last[1]) {
|
|
57
|
+
if (Math.abs(result[result.length - 1][0] - result[0][0]) > 180) {
|
|
58
|
+
return boundary.map(([longitude, latitude]) => [longitude, latitude]);
|
|
59
|
+
}
|
|
60
|
+
result[result.length - 1] = [...result[0]];
|
|
61
|
+
}
|
|
62
|
+
return result;
|
|
63
|
+
}
|
|
64
|
+
|
|
29
65
|
// dist/dggs-decoder.js
|
|
30
66
|
function getDGGSCellBounds(boundary) {
|
|
31
67
|
let west = Infinity;
|
|
@@ -43,9 +79,30 @@ function getDGGSCellBounds(boundary) {
|
|
|
43
79
|
[east, north]
|
|
44
80
|
];
|
|
45
81
|
}
|
|
82
|
+
function withDGGSBoundaryOptions(decoder) {
|
|
83
|
+
const cellToBoundary2 = (cell, options) => {
|
|
84
|
+
const boundary = decoder.cellToBoundary(cell);
|
|
85
|
+
return (options == null ? void 0 : options.unwrap) ? unwrapDGGSBoundary(boundary, options.referenceLongitude) : boundary;
|
|
86
|
+
};
|
|
87
|
+
return {
|
|
88
|
+
...decoder,
|
|
89
|
+
cellToBoundary: cellToBoundary2,
|
|
90
|
+
cellToBoundaryFlat: (cell, options) => (options == null ? void 0 : options.unwrap) ? cellToBoundary2(cell, options).flat() : decoder.cellToBoundaryFlat(cell),
|
|
91
|
+
cellToBounds: (cell, options) => {
|
|
92
|
+
const bounds = decoder.cellToBounds(cell);
|
|
93
|
+
if (!(options == null ? void 0 : options.unwrap) || bounds[1][0] - bounds[0][0] >= 360) {
|
|
94
|
+
return bounds;
|
|
95
|
+
}
|
|
96
|
+
const unwrapped = getDGGSCellBounds(cellToBoundary2(cell, options));
|
|
97
|
+
unwrapped[0][1] = bounds[0][1];
|
|
98
|
+
unwrapped[1][1] = bounds[1][1];
|
|
99
|
+
return unwrapped;
|
|
100
|
+
}
|
|
101
|
+
};
|
|
102
|
+
}
|
|
46
103
|
|
|
47
104
|
// dist/h3-decoder.js
|
|
48
|
-
var H3Decoder = {
|
|
105
|
+
var H3Decoder = withDGGSBoundaryOptions({
|
|
49
106
|
name: "h3",
|
|
50
107
|
hasNumericRepresentation: true,
|
|
51
108
|
cellColumnNames: [
|
|
@@ -64,7 +121,7 @@ var H3Decoder = {
|
|
|
64
121
|
cellToBoundary: (cell) => getH3Boundary(cell),
|
|
65
122
|
cellToBoundaryFlat: (cell) => getH3Boundary(cell).flat(),
|
|
66
123
|
cellToBounds: (cell) => getDGGSCellBounds(getH3Boundary(cell))
|
|
67
|
-
};
|
|
124
|
+
});
|
|
68
125
|
function getH3Token(cell) {
|
|
69
126
|
return typeof cell === "bigint" ? cell.toString(16) : removeHexPrefix(cell);
|
|
70
127
|
}
|
package/dist/h3.cjs.map
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
|
-
"sources": ["../src/h3.ts", "../src/h3-decoder.ts", "../src/dggs-decoder.ts"],
|
|
4
|
-
"mappings": ";;;;;;;;;;;;;;;;;;;AAAA;;;;;;;ACIA,mBAA2C;;;
|
|
5
|
-
"names": []
|
|
3
|
+
"sources": ["../src/h3.ts", "../src/h3-decoder.ts", "../src/unwrap-dggs-boundary.ts", "../src/dggs-decoder.ts"],
|
|
4
|
+
"mappings": ";;;;;;;;;;;;;;;;;;;AAAA;;;;;;;ACIA,mBAA2C;;;ACUrC,SAAU,mBACd,UACA,oBAA2B;AAE3B,QAAM,SAA6B,SAAS,IAAI,CAAC,CAAC,WAAW,QAAQ,MAAM,CAAC,WAAW,QAAQ,CAAC;AAChG,MAAI,OAAO,WAAW,GAAG;AACvB,WAAO;EACT;AAEA,MAAI,OAAO;AACX,MAAI,OAAO;AACX,aAAW,CAAC,SAAS,KAAK,UAAU;AAClC,WAAO,KAAK,IAAI,MAAM,SAAS;AAC/B,WAAO,KAAK,IAAI,MAAM,SAAS;EACjC;AACA,MAAI,OAAO,QAAQ,KAAK;AACtB,WAAO;EACT;AAEA,MAAI,WAAW,sBAAsB,O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AAW,IAAI,GAAG,IAAI,EAAE,IAAI,CAAC,CAAC,WAAW,QAAQ,MAAM;IAC3E;IACA;GACD;AACH;AAEA,SAAS,sBAAsB,OAAa;AAC1C,SAAO,OAAO,KAAK,gBAAgB,KAAK,CAAC,EAAE;AAC7C;AAEA,SAAS,gBAAgB,OAAa;AACpC,SAAO,MAAM,WAAW,IAAI,KAAK,MAAM,WAAW,IAAI,IAAI,MAAM,MAAM,CAAC,IAAI;AAC7E;",
|
|
5
|
+
"names": ["cellToBoundary"]
|
|
6
6
|
}
|
package/dist/h3.js
CHANGED
package/dist/h3.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"h3.js","sourceRoot":"","sources":["../src/h3.ts"],"names":[],"mappings":"AAAA,UAAU;AACV,+BAA+B;AAC/B,
|
|
1
|
+
{"version":3,"file":"h3.js","sourceRoot":"","sources":["../src/h3.ts"],"names":[],"mappings":"AAAA,UAAU;AACV,+BAA+B;AAC/B,4DAA4D;AAE5D,OAAO,EAAC,SAAS,EAAC,wBAAqB"}
|