@math.gl/dggs 5.0.0-alpha.5 → 5.0.0-alpha.8
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 +1 -1
- package/dist/a5-decoder.d.ts +3 -3
- package/dist/a5-decoder.d.ts.map +1 -1
- package/dist/a5-decoder.js +3 -3
- package/dist/a5-decoder.js.map +1 -1
- package/dist/a5.cjs +59 -2
- package/dist/a5.cjs.map +3 -3
- package/dist/dggs-decoder.d.ts +12 -3
- package/dist/dggs-decoder.d.ts.map +1 -1
- package/dist/dggs-decoder.js +24 -0
- package/dist/dggs-decoder.js.map +1 -1
- package/dist/geohash-decoder.d.ts +3 -3
- package/dist/geohash-decoder.d.ts.map +1 -1
- package/dist/geohash-decoder.js +3 -3
- package/dist/geohash-decoder.js.map +1 -1
- package/dist/geohash.cjs +75 -2
- package/dist/geohash.cjs.map +2 -2
- package/dist/h3-decoder.d.ts +3 -3
- package/dist/h3-decoder.d.ts.map +1 -1
- package/dist/h3-decoder.js +3 -3
- package/dist/h3-decoder.js.map +1 -1
- package/dist/h3.cjs +59 -2
- package/dist/h3.cjs.map +3 -3
- 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 +4 -2
- package/dist/index.js.map +1 -1
- package/dist/plus-code-decoder.d.ts +3 -3
- package/dist/plus-code-decoder.d.ts.map +1 -1
- package/dist/plus-code-decoder.js +3 -3
- 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/quadkey-decoder.d.ts +3 -3
- package/dist/quadkey-decoder.d.ts.map +1 -1
- package/dist/quadkey-decoder.js +3 -3
- package/dist/quadkey-decoder.js.map +1 -1
- package/dist/quadkey.cjs +75 -2
- package/dist/quadkey.cjs.map +2 -2
- package/dist/s2-decoder.d.ts +13 -3
- package/dist/s2-decoder.d.ts.map +1 -1
- package/dist/s2-decoder.js +89 -21
- 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 +123 -0
- package/dist/s2-geometry/s2-geometry.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 +70 -4
- 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 +3 -2
- 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 +3 -3
- package/src/a5-decoder.ts +8 -3
- package/src/dggs-decoder.ts +40 -3
- package/src/geohash-decoder.ts +8 -3
- package/src/h3-decoder.ts +8 -3
- package/src/index.ts +13 -2
- package/src/plus-code-decoder.ts +8 -3
- package/src/quadkey-decoder.ts +8 -3
- package/src/s2-decoder.ts +90 -20
- package/src/s2-geometry/s2-geometry.ts +137 -0
- package/src/s2-geometry/s2-token.ts +73 -4
- package/src/s2.ts +11 -2
- package/src/unwrap-dggs-boundary.ts +54 -0
|
@@ -2,13 +2,13 @@
|
|
|
2
2
|
// SPDX-License-Identifier: MIT
|
|
3
3
|
// Copyright (c) vis.gl contributors
|
|
4
4
|
import OpenLocationCodePackage from 'open-location-code';
|
|
5
|
-
import { getDGGSCellToken } from "./dggs-decoder.js";
|
|
5
|
+
import { withDGGSBoundaryOptions, getDGGSCellToken } from "./dggs-decoder.js";
|
|
6
6
|
const openLocationCode = new OpenLocationCodePackage.OpenLocationCode();
|
|
7
7
|
/**
|
|
8
8
|
* Lightweight geometry decoder for full Google Plus Codes (Open Location Codes).
|
|
9
9
|
* Short codes require a reference location and are intentionally unsupported.
|
|
10
10
|
*/
|
|
11
|
-
export const PlusCodeDecoder = {
|
|
11
|
+
export const PlusCodeDecoder = withDGGSBoundaryOptions({
|
|
12
12
|
name: 'plus-code',
|
|
13
13
|
hasNumericRepresentation: false,
|
|
14
14
|
cellColumnNames: ['plusCode', 'plus_code', 'openLocationCode', 'open_location_code', 'olc'],
|
|
@@ -25,7 +25,7 @@ export const PlusCodeDecoder = {
|
|
|
25
25
|
[area.longitudeHi, area.latitudeHi]
|
|
26
26
|
];
|
|
27
27
|
}
|
|
28
|
-
};
|
|
28
|
+
});
|
|
29
29
|
function getPlusCodeLngLat(cell) {
|
|
30
30
|
const area = decodePlusCode(cell);
|
|
31
31
|
return [area.longitudeCenter, area.latitudeCenter];
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"plus-code-decoder.js","sourceRoot":"","sources":["../src/plus-code-decoder.ts"],"names":[],"mappings":"AAAA,UAAU;AACV,+BAA+B;AAC/B,oCAAoC;AAEpC,OAAO,uBAAoD,MAAM,oBAAoB,CAAC;AAEtF,OAAO,
|
|
1
|
+
{"version":3,"file":"plus-code-decoder.js","sourceRoot":"","sources":["../src/plus-code-decoder.ts"],"names":[],"mappings":"AAAA,UAAU;AACV,+BAA+B;AAC/B,oCAAoC;AAEpC,OAAO,uBAAoD,MAAM,oBAAoB,CAAC;AAEtF,OAAO,EACL,uBAAuB,EAGvB,gBAAgB,EACjB,0BAAuB;AAExB,MAAM,gBAAgB,GAAG,IAAI,uBAAuB,CAAC,gBAAgB,EAAE,CAAC;AAExE;;;GAGG;AACH,MAAM,CAAC,MAAM,eAAe,GAAG,uBAAuB,CAAC;IACrD,IAAI,EAAE,WAAW;IACjB,wBAAwB,EAAE,KAAK;IAC/B,eAAe,EAAE,CAAC,UAAU,EAAE,WAAW,EAAE,kBAAkB,EAAE,oBAAoB,EAAE,KAAK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EAAE,KAAK,EAAC,GAAG,IAAI,CAAC;IAC1F,OAAO;QACL,CAAC,IAAI,EAAE,KAAK,CAAC;QACb,CAAC,IAAI,EAAE,KAAK,CAAC;QACb,CAAC,IAAI,EAAE,KAAK,CAAC;QACb,CAAC,IAAI,EAAE,KAAK,CAAC;QACb,CAAC,IAAI,EAAE,KAAK,CAAC;KACd,CAAC;AACJ,CAAC"}
|
package/dist/plus-code.cjs
CHANGED
|
@@ -36,6 +36,42 @@ module.exports = __toCommonJS(plus_code_exports);
|
|
|
36
36
|
// dist/plus-code-decoder.js
|
|
37
37
|
var import_open_location_code = __toESM(require("open-location-code"), 1);
|
|
38
38
|
|
|
39
|
+
// dist/unwrap-dggs-boundary.js
|
|
40
|
+
function unwrapDGGSBoundary(boundary, referenceLongitude) {
|
|
41
|
+
const result = boundary.map(([longitude, latitude]) => [longitude, latitude]);
|
|
42
|
+
if (result.length === 0) {
|
|
43
|
+
return result;
|
|
44
|
+
}
|
|
45
|
+
let west = Infinity;
|
|
46
|
+
let east = -Infinity;
|
|
47
|
+
for (const [longitude] of boundary) {
|
|
48
|
+
west = Math.min(west, longitude);
|
|
49
|
+
east = Math.max(east, longitude);
|
|
50
|
+
}
|
|
51
|
+
if (east - west >= 360) {
|
|
52
|
+
return result;
|
|
53
|
+
}
|
|
54
|
+
let previous = referenceLongitude ?? result[0][0];
|
|
55
|
+
for (const point of result) {
|
|
56
|
+
const delta = point[0] - previous;
|
|
57
|
+
if (delta > 180) {
|
|
58
|
+
point[0] -= 360 * Math.ceil((delta - 180) / 360);
|
|
59
|
+
} else if (delta < -180) {
|
|
60
|
+
point[0] += 360 * Math.ceil((-delta - 180) / 360);
|
|
61
|
+
}
|
|
62
|
+
previous = point[0];
|
|
63
|
+
}
|
|
64
|
+
const first = boundary[0];
|
|
65
|
+
const last = boundary[boundary.length - 1];
|
|
66
|
+
if (first[0] === last[0] && first[1] === last[1]) {
|
|
67
|
+
if (Math.abs(result[result.length - 1][0] - result[0][0]) > 180) {
|
|
68
|
+
return boundary.map(([longitude, latitude]) => [longitude, latitude]);
|
|
69
|
+
}
|
|
70
|
+
result[result.length - 1] = [...result[0]];
|
|
71
|
+
}
|
|
72
|
+
return result;
|
|
73
|
+
}
|
|
74
|
+
|
|
39
75
|
// dist/dggs-decoder.js
|
|
40
76
|
function getDGGSCellToken(cell, gridName) {
|
|
41
77
|
if (typeof cell !== "string") {
|
|
@@ -43,10 +79,47 @@ function getDGGSCellToken(cell, gridName) {
|
|
|
43
79
|
}
|
|
44
80
|
return cell;
|
|
45
81
|
}
|
|
82
|
+
function getDGGSCellBounds(boundary) {
|
|
83
|
+
let west = Infinity;
|
|
84
|
+
let south = Infinity;
|
|
85
|
+
let east = -Infinity;
|
|
86
|
+
let north = -Infinity;
|
|
87
|
+
for (const [longitude, latitude] of boundary) {
|
|
88
|
+
west = Math.min(west, longitude);
|
|
89
|
+
south = Math.min(south, latitude);
|
|
90
|
+
east = Math.max(east, longitude);
|
|
91
|
+
north = Math.max(north, latitude);
|
|
92
|
+
}
|
|
93
|
+
return [
|
|
94
|
+
[west, south],
|
|
95
|
+
[east, north]
|
|
96
|
+
];
|
|
97
|
+
}
|
|
98
|
+
function withDGGSBoundaryOptions(decoder) {
|
|
99
|
+
const cellToBoundary = (cell, options) => {
|
|
100
|
+
const boundary = decoder.cellToBoundary(cell);
|
|
101
|
+
return (options == null ? void 0 : options.unwrap) ? unwrapDGGSBoundary(boundary, options.referenceLongitude) : boundary;
|
|
102
|
+
};
|
|
103
|
+
return {
|
|
104
|
+
...decoder,
|
|
105
|
+
cellToBoundary,
|
|
106
|
+
cellToBoundaryFlat: (cell, options) => (options == null ? void 0 : options.unwrap) ? cellToBoundary(cell, options).flat() : decoder.cellToBoundaryFlat(cell),
|
|
107
|
+
cellToBounds: (cell, options) => {
|
|
108
|
+
const bounds = decoder.cellToBounds(cell);
|
|
109
|
+
if (!(options == null ? void 0 : options.unwrap) || bounds[1][0] - bounds[0][0] >= 360) {
|
|
110
|
+
return bounds;
|
|
111
|
+
}
|
|
112
|
+
const unwrapped = getDGGSCellBounds(cellToBoundary(cell, options));
|
|
113
|
+
unwrapped[0][1] = bounds[0][1];
|
|
114
|
+
unwrapped[1][1] = bounds[1][1];
|
|
115
|
+
return unwrapped;
|
|
116
|
+
}
|
|
117
|
+
};
|
|
118
|
+
}
|
|
46
119
|
|
|
47
120
|
// dist/plus-code-decoder.js
|
|
48
121
|
var openLocationCode = new import_open_location_code.default.OpenLocationCode();
|
|
49
|
-
var PlusCodeDecoder = {
|
|
122
|
+
var PlusCodeDecoder = withDGGSBoundaryOptions({
|
|
50
123
|
name: "plus-code",
|
|
51
124
|
hasNumericRepresentation: false,
|
|
52
125
|
cellColumnNames: ["plusCode", "plus_code", "openLocationCode", "open_location_code", "olc"],
|
|
@@ -63,7 +136,7 @@ var PlusCodeDecoder = {
|
|
|
63
136
|
[area.longitudeHi, area.latitudeHi]
|
|
64
137
|
];
|
|
65
138
|
}
|
|
66
|
-
};
|
|
139
|
+
});
|
|
67
140
|
function getPlusCodeLngLat(cell) {
|
|
68
141
|
const area = decodePlusCode(cell);
|
|
69
142
|
return [area.longitudeCenter, area.latitudeCenter];
|
package/dist/plus-code.cjs.map
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
|
-
"sources": ["../src/plus-code.ts", "../src/plus-code-decoder.ts", "../src/dggs-decoder.ts"],
|
|
4
|
-
"mappings": ";;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;;;;;;;ACIA,gCAAiE;;;
|
|
3
|
+
"sources": ["../src/plus-code.ts", "../src/plus-code-decoder.ts", "../src/unwrap-dggs-boundary.ts", "../src/dggs-decoder.ts"],
|
|
4
|
+
"mappings": ";;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;;;;;;;ACIA,gCAAiE;;;ACU3D,SAAU,mBACd,UACA,oBAA2B;AAE3B,QAAM,SAA6B,SAAS,IAAI,CAAC,CAAC,WAA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BAAgB,CAAC,SAAuC,oBAAoB,eAAe,IAAI,CAAC;EAChG,oBAAoB,CAAC,SAA4B;AAC/C,UAAM,OAAO,eAAe,IAAI;AAChC,WAAO,oBAAoB,IAAI,EAAE,KAAI;EACvC;EACA,cAAc,CAAC,SAA4B;AACzC,UAAM,OAAO,eAAe,IAAI;AAChC,WAAO;MACL,CAAC,KAAK,aAAa,KAAK,UAAU;MAClC,CAAC,KAAK,aAAa,KAAK,UAAU;;EAEtC;CAC8B;AAEhC,SAAS,kBAAkB,MAAc;AACvC,QAAM,OAAO,eAAe,IAAI;AAChC,SAAO,CAAC,KAAK,iBAAiB,KAAK,cAAc;AACnD;AAEA,SAAS,eAAe,MAAc;AACpC,QAAM,OAAO,iBAAiB,MAAM,WAAW;AAC/C,MAAI,CAAC,iBAAiB,OAAO,IAAI,GAAG;AAClC,UAAM,IAAI,MAAM,2CAA2C,IAAI,EAAE;EACnE;AACA,SAAO,iBAAiB,OAAO,IAAI;AACrC;AAEA,SAAS,oBAAoB,MAA0B;AACrD,QAAM,EAAC,aAAa,MAAM,YAAY,OAAO,aAAa,MAAM,YAAY,MAAK,IAAI;AACrF,SAAO;IACL,CAAC,MAAM,KAAK;IACZ,CAAC,MAAM,KAAK;IACZ,CAAC,MAAM,KAAK;IACZ,CAAC,MAAM,KAAK;IACZ,CAAC,MAAM,KAAK;;AAEhB;",
|
|
5
5
|
"names": ["OpenLocationCodePackage"]
|
|
6
6
|
}
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { type Bounds2D } from '@math.gl/types';
|
|
2
|
-
import { type DGGSCell } from "./dggs-decoder.js";
|
|
2
|
+
import { type DGGSCell, type DGGSDecoder } from "./dggs-decoder.js";
|
|
3
3
|
/** Decoder for the quadkey DGGS */
|
|
4
|
-
export declare const QuadkeyDecoder: {
|
|
4
|
+
export declare const QuadkeyDecoder: Omit<{
|
|
5
5
|
readonly name: "quadkey";
|
|
6
6
|
readonly hasNumericRepresentation: false;
|
|
7
7
|
readonly cellColumnNames: readonly ["quadkey", "quadkeyId", "quadkey_id"];
|
|
@@ -9,6 +9,6 @@ export declare const QuadkeyDecoder: {
|
|
|
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
|
export declare function quadkeyToWorldBounds(quadkey: string): [[number, number], [number, number]];
|
|
14
14
|
//# sourceMappingURL=quadkey-decoder.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"quadkey-decoder.d.ts","sourceRoot":"","sources":["../src/quadkey-decoder.ts"],"names":[],"mappings":"AAIA,OAAO,EAAC,KAAK,QAAQ,EAAC,MAAM,gBAAgB,CAAC;AAC7C,OAAO,
|
|
1
|
+
{"version":3,"file":"quadkey-decoder.d.ts","sourceRoot":"","sources":["../src/quadkey-decoder.ts"],"names":[],"mappings":"AAIA,OAAO,EAAC,KAAK,QAAQ,EAAC,MAAM,gBAAgB,CAAC;AAC7C,OAAO,EAEL,KAAK,QAAQ,EACb,KAAK,WAAW,EAEjB,0BAAuB;AAIxB,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;AAuClC,wBAAgB,oBAAoB,CAAC,OAAO,EAAE,MAAM,GAAG,CAAC,CAAC,MAAM,EAAE,MAAM,CAAC,EAAE,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC,CAgB1F"}
|
package/dist/quadkey-decoder.js
CHANGED
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
// math.gl
|
|
2
2
|
// SPDX-License-Identifier: MIT
|
|
3
3
|
// Copyright (c) vis.gl contributors
|
|
4
|
-
import { getDGGSCellToken } from "./dggs-decoder.js";
|
|
4
|
+
import { withDGGSBoundaryOptions, getDGGSCellToken } from "./dggs-decoder.js";
|
|
5
5
|
const TILE_SIZE = 512;
|
|
6
6
|
/** Decoder for the quadkey DGGS */
|
|
7
|
-
export const QuadkeyDecoder = {
|
|
7
|
+
export const QuadkeyDecoder = withDGGSBoundaryOptions({
|
|
8
8
|
name: 'quadkey',
|
|
9
9
|
hasNumericRepresentation: false,
|
|
10
10
|
cellColumnNames: ['quadkey', 'quadkeyId', 'quadkey_id'],
|
|
@@ -12,7 +12,7 @@ export const QuadkeyDecoder = {
|
|
|
12
12
|
cellToBoundary: (cell) => getQuadkeyBoundary(getDGGSCellToken(cell, 'Quadkey')),
|
|
13
13
|
cellToBoundaryFlat: (cell) => getQuadkeyBoundaryFlat(getDGGSCellToken(cell, 'Quadkey')),
|
|
14
14
|
cellToBounds: (cell) => getQuadkeyBounds(getDGGSCellToken(cell, 'Quadkey'))
|
|
15
|
-
};
|
|
15
|
+
});
|
|
16
16
|
function getQuadkeyLngLat(quadkey) {
|
|
17
17
|
const [topLeft, bottomRight] = quadkeyToWorldBounds(quadkey);
|
|
18
18
|
const [w, n] = worldToLngLat(topLeft);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"quadkey-decoder.js","sourceRoot":"","sources":["../src/quadkey-decoder.ts"],"names":[],"mappings":"AAAA,UAAU;AACV,+BAA+B;AAC/B,oCAAoC;AAGpC,OAAO,
|
|
1
|
+
{"version":3,"file":"quadkey-decoder.js","sourceRoot":"","sources":["../src/quadkey-decoder.ts"],"names":[],"mappings":"AAAA,UAAU;AACV,+BAA+B;AAC/B,oCAAoC;AAGpC,OAAO,EACL,uBAAuB,EAGvB,gBAAgB,E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AG,EAAE,CAAC,CAAC,GAAG,IAAI,CAAC,CAAC;IAC/E,OAAO,CAAC,OAAO,GAAG,kBAAkB,EAAE,IAAI,GAAG,kBAAkB,CAAC,CAAC;AACnE,CAAC"}
|
package/dist/quadkey.cjs
CHANGED
|
@@ -24,6 +24,42 @@ __export(quadkey_exports, {
|
|
|
24
24
|
});
|
|
25
25
|
module.exports = __toCommonJS(quadkey_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,10 +67,47 @@ 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/quadkey-decoder.js
|
|
36
109
|
var TILE_SIZE = 512;
|
|
37
|
-
var QuadkeyDecoder = {
|
|
110
|
+
var QuadkeyDecoder = withDGGSBoundaryOptions({
|
|
38
111
|
name: "quadkey",
|
|
39
112
|
hasNumericRepresentation: false,
|
|
40
113
|
cellColumnNames: ["quadkey", "quadkeyId", "quadkey_id"],
|
|
@@ -42,7 +115,7 @@ var QuadkeyDecoder = {
|
|
|
42
115
|
cellToBoundary: (cell) => getQuadkeyBoundary(getDGGSCellToken(cell, "Quadkey")),
|
|
43
116
|
cellToBoundaryFlat: (cell) => getQuadkeyBoundaryFlat(getDGGSCellToken(cell, "Quadkey")),
|
|
44
117
|
cellToBounds: (cell) => getQuadkeyBounds(getDGGSCellToken(cell, "Quadkey"))
|
|
45
|
-
};
|
|
118
|
+
});
|
|
46
119
|
function getQuadkeyLngLat(quadkey) {
|
|
47
120
|
const [topLeft, bottomRight] = quadkeyToWorldBounds(quadkey);
|
|
48
121
|
const [w, n] = worldToLngLat(topLeft);
|
package/dist/quadkey.cjs.map
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
|
-
"sources": ["../src/quadkey.ts", "../src/dggs-decoder.ts", "../src/quadkey-decoder.ts"],
|
|
4
|
-
"mappings": ";;;;;;;;;;;;;;;;;;;AAAA;;;;;;;;
|
|
3
|
+
"sources": ["../src/quadkey.ts", "../src/unwrap-dggs-boundary.ts", "../src/dggs-decoder.ts", "../src/quadkey-decoder.ts"],
|
|
4
|
+
"mappings": ";;;;;;;;;;;;;;;;;;;AAAA;;;;;;;;ACcM,SAAU,mBACd,UACA,oBAA2B;AAE3B,QAAM,SAA6B,SAAS,IAAI,CAAC,CAAC,WAAW,QAAQ,MAAM,CAAC,WAAW,QAAQ,CAAC;AAChG,MAAI,OAAO,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QAAQ,OAAO;AAErB,WAAS,IAAI,GAAG,IAAI,QAAQ,QAAQ,KAAK;AACvC,aAAS;AACT,UAAM,IAAI,SAAS,QAAQ,CAAC,GAAG,EAAE;AACjC,QAAI,IAAI;AAAG,WAAK;AAChB,QAAI,IAAI;AAAG,WAAK;EAClB;AACA,SAAO;IACL,CAAC,IAAI,OAAO,YAAY,IAAI,KAAK;IACjC,EAAE,IAAI,QAAQ,OAAO,aAAa,IAAI,QAAQ,KAAK;;AAEvD;AAGA,IAAM,KAAK,KAAK;AAChB,IAAM,OAAO,KAAK;AAClB,IAAM,qBAAqB,MAAM;AAWjC,SAAS,cAAc,IAAY;AACjC,QAAM,CAAC,GAAG,CAAC,IAAI;AACf,QAAM,UAAW,IAAI,aAAc,IAAI,MAAM;AAC7C,QAAM,OAAO,KAAK,KAAK,KAAK,KAAK,IAAK,IAAI,aAAc,IAAI,MAAM,EAAE,CAAC,IAAI;AACzE,SAAO,CAAC,UAAU,oBAAoB,OAAO,kBAAkB;AACjE;",
|
|
5
5
|
"names": []
|
|
6
6
|
}
|
package/dist/s2-decoder.d.ts
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { type Bounds2D } from '@math.gl/types';
|
|
2
|
-
import { type DGGSCell } from "./dggs-decoder.js";
|
|
2
|
+
import { type DGGSCell, type DGGSDecoder } from "./dggs-decoder.js";
|
|
3
3
|
/** Decoder for the S2 DGGS */
|
|
4
|
-
export declare const S2Decoder: {
|
|
4
|
+
export declare const S2Decoder: Omit<{
|
|
5
5
|
readonly name: "s2";
|
|
6
6
|
readonly hasNumericRepresentation: true;
|
|
7
7
|
readonly cellColumnNames: readonly ["s2", "s2Token", "s2_token", "s2Cell", "s2_cell", "s2CellId", "s2_cell_id"];
|
|
@@ -11,7 +11,7 @@ export declare const S2Decoder: {
|
|
|
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
|
/**
|
|
16
16
|
* Retrieve S2 geometry center
|
|
17
17
|
*/
|
|
@@ -23,4 +23,14 @@ export declare function getS2LngLat(cell: DGGSCell): [number, number];
|
|
|
23
23
|
* - the polygon is closed, i.e. last coordinate is a copy of the first coordinate
|
|
24
24
|
*/
|
|
25
25
|
export declare function getS2BoundaryFlat(cell: DGGSCell): number[];
|
|
26
|
+
/**
|
|
27
|
+
* Returns conservative longitude/latitude bounds for an S2 cell.
|
|
28
|
+
*
|
|
29
|
+
* Longitudes are unwrapped so `east >= west`; either endpoint may lie outside `[-180, 180]` for
|
|
30
|
+
* antimeridian cells. The two level-zero polar faces span a complete 360-degree longitude range.
|
|
31
|
+
*
|
|
32
|
+
* @param cell - S2 token or 64-bit cell index.
|
|
33
|
+
* @returns Bounds in `[[west, south], [east, north]]` order and degrees.
|
|
34
|
+
*/
|
|
35
|
+
export declare function getS2Bounds(cell: DGGSCell): Bounds2D;
|
|
26
36
|
//# sourceMappingURL=s2-decoder.d.ts.map
|
package/dist/s2-decoder.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"s2-decoder.d.ts","sourceRoot":"","sources":["../src/s2-decoder.ts"],"names":[],"mappings":"AAIA,OAAO,EAAC,KAAK,QAAQ,EAAC,MAAM,gBAAgB,CAAC;AAC7C,OAAO,
|
|
1
|
+
{"version":3,"file":"s2-decoder.d.ts","sourceRoot":"","sources":["../src/s2-decoder.ts"],"names":[],"mappings":"AAIA,OAAO,EAAC,KAAK,QAAQ,EAAC,MAAM,gBAAgB,CAAC;AAC7C,OAAO,EAA0B,KAAK,QAAQ,EAAE,KAAK,WAAW,EAAC,0BAAuB;AAMxF,8BAA8B;AAC9B,eAAO,MAAM,SAAS;;;;oCAIG,MAAM,KAAG,MAAM;iCAClB,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;AAElC;;GAEG;AACH,wBAAgB,WAAW,CAAC,IAAI,EAAE,QAAQ,GAAG,CAAC,MAAM,EAAE,MAAM,CAAC,CAU5D;AAED;;;;;GAKG;AACH,wBAAgB,iBAAiB,CAAC,IAAI,EAAE,QAAQ,GAAG,MAAM,EAAE,CAK1D;AAWD;;;;;;;;GAQG;AACH,wBAAgB,WAAW,CAAC,IAAI,EAAE,QAAQ,GAAG,QAAQ,CA4CpD"}
|
package/dist/s2-decoder.js
CHANGED
|
@@ -1,21 +1,22 @@
|
|
|
1
1
|
// math.gl
|
|
2
2
|
// SPDX-License-Identifier: MIT
|
|
3
3
|
// Copyright (c) vis.gl contributors
|
|
4
|
+
import { withDGGSBoundaryOptions } from "./dggs-decoder.js";
|
|
4
5
|
import { getS2IndexFromToken, getS2TokenFromIndex } from "./s2-geometry/s2-token.js";
|
|
5
6
|
import { getS2GeoBounds } from "./s2-geometry/s2-to-boundary.js";
|
|
6
7
|
import { getS2Cell, IJToST, STToUV, FaceUVToXYZ, XYZToLngLat } from "./s2-geometry/s2-geometry.js";
|
|
7
8
|
/** Decoder for the S2 DGGS */
|
|
8
|
-
export const S2Decoder = {
|
|
9
|
+
export const S2Decoder = withDGGSBoundaryOptions({
|
|
9
10
|
name: 's2',
|
|
10
11
|
hasNumericRepresentation: true,
|
|
11
12
|
cellColumnNames: ['s2', 's2Token', 's2_token', 's2Cell', 's2_cell', 's2CellId', 's2_cell_id'],
|
|
12
13
|
tokenToCell: (s2Token) => getS2IndexFromToken(s2Token),
|
|
13
|
-
cellToToken: (cell) =>
|
|
14
|
+
cellToToken: (cell) => getS2TokenFromIndex(getS2CellIndex(cell)),
|
|
14
15
|
cellToLngLat: (cell) => getS2LngLat(cell),
|
|
15
16
|
cellToBoundary: (cell) => getS2Boundary(cell),
|
|
16
17
|
cellToBoundaryFlat: (cell) => getS2BoundaryFlat(cell),
|
|
17
18
|
cellToBounds: (cell) => getS2Bounds(cell)
|
|
18
|
-
};
|
|
19
|
+
});
|
|
19
20
|
/**
|
|
20
21
|
* Retrieve S2 geometry center
|
|
21
22
|
*/
|
|
@@ -48,29 +49,96 @@ function getS2Boundary(cell) {
|
|
|
48
49
|
}
|
|
49
50
|
return boundary;
|
|
50
51
|
}
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
52
|
+
/**
|
|
53
|
+
* Returns conservative longitude/latitude bounds for an S2 cell.
|
|
54
|
+
*
|
|
55
|
+
* Longitudes are unwrapped so `east >= west`; either endpoint may lie outside `[-180, 180]` for
|
|
56
|
+
* antimeridian cells. The two level-zero polar faces span a complete 360-degree longitude range.
|
|
57
|
+
*
|
|
58
|
+
* @param cell - S2 token or 64-bit cell index.
|
|
59
|
+
* @returns Bounds in `[[west, south], [east, north]]` order and degrees.
|
|
60
|
+
*/
|
|
61
|
+
export function getS2Bounds(cell) {
|
|
62
|
+
const s2Cell = getS2Cell(getS2CellIndex(cell));
|
|
63
|
+
if (s2Cell.level === 0) {
|
|
64
|
+
return getS2RootBounds(s2Cell.face);
|
|
65
|
+
}
|
|
66
|
+
// For non-root S2 cells, latitude and longitude extrema occur at vertices. Root cells require
|
|
67
|
+
// the special cases above because their curved edges or interiors contain the extrema.
|
|
68
|
+
// https://github.com/google/s2geometry/blob/master/src/s2/s2cell.cc
|
|
69
|
+
const offsets = [
|
|
70
|
+
[0, 0],
|
|
71
|
+
[0, 1],
|
|
72
|
+
[1, 1],
|
|
73
|
+
[1, 0]
|
|
74
|
+
];
|
|
75
|
+
let west = Infinity;
|
|
76
|
+
let south = Infinity;
|
|
77
|
+
let east = -Infinity;
|
|
78
|
+
let north = -Infinity;
|
|
79
|
+
let previousLongitude;
|
|
80
|
+
for (const offset of offsets) {
|
|
81
|
+
const st = IJToST(s2Cell.ij, s2Cell.level, offset);
|
|
82
|
+
const uv = STToUV(st);
|
|
83
|
+
const [x, y, z] = FaceUVToXYZ(s2Cell.face, uv);
|
|
84
|
+
let [longitude, latitude] = XYZToLngLat([x, y, z]);
|
|
85
|
+
if (x === 0 && y === 0 && previousLongitude !== undefined) {
|
|
86
|
+
longitude = previousLongitude;
|
|
87
|
+
}
|
|
88
|
+
if (previousLongitude !== undefined) {
|
|
89
|
+
const longitudeDelta = longitude - previousLongitude;
|
|
90
|
+
longitude += longitudeDelta > 180 ? -360 : longitudeDelta < -180 ? 360 : 0;
|
|
91
|
+
}
|
|
92
|
+
previousLongitude = longitude;
|
|
93
|
+
west = Math.min(west, longitude);
|
|
94
|
+
south = Math.min(south, latitude);
|
|
95
|
+
east = Math.max(east, longitude);
|
|
96
|
+
north = Math.max(north, latitude);
|
|
67
97
|
}
|
|
98
|
+
const angularEpsilon = (2 * Number.EPSILON * 180) / Math.PI;
|
|
68
99
|
return [
|
|
69
|
-
[
|
|
70
|
-
[
|
|
100
|
+
[west - angularEpsilon, Math.max(-90, south - angularEpsilon)],
|
|
101
|
+
[east + angularEpsilon, Math.min(90, north + angularEpsilon)]
|
|
71
102
|
];
|
|
72
103
|
}
|
|
73
104
|
function getS2CellIndex(cell) {
|
|
74
105
|
return typeof cell === 'bigint' ? cell : getS2IndexFromToken(cell);
|
|
75
106
|
}
|
|
107
|
+
function getS2RootBounds(face) {
|
|
108
|
+
const polarLatitude = (Math.asin(Math.sqrt(1 / 3)) * 180) / Math.PI;
|
|
109
|
+
switch (face) {
|
|
110
|
+
case 0:
|
|
111
|
+
return [
|
|
112
|
+
[-45, -45],
|
|
113
|
+
[45, 45]
|
|
114
|
+
];
|
|
115
|
+
case 1:
|
|
116
|
+
return [
|
|
117
|
+
[45, -45],
|
|
118
|
+
[135, 45]
|
|
119
|
+
];
|
|
120
|
+
case 2:
|
|
121
|
+
return [
|
|
122
|
+
[-180, polarLatitude],
|
|
123
|
+
[180, 90]
|
|
124
|
+
];
|
|
125
|
+
case 3:
|
|
126
|
+
return [
|
|
127
|
+
[135, -45],
|
|
128
|
+
[225, 45]
|
|
129
|
+
];
|
|
130
|
+
case 4:
|
|
131
|
+
return [
|
|
132
|
+
[-135, -45],
|
|
133
|
+
[-45, 45]
|
|
134
|
+
];
|
|
135
|
+
case 5:
|
|
136
|
+
return [
|
|
137
|
+
[-180, -90],
|
|
138
|
+
[180, -polarLatitude]
|
|
139
|
+
];
|
|
140
|
+
default:
|
|
141
|
+
throw new Error(`Invalid S2 face: ${face}`);
|
|
142
|
+
}
|
|
143
|
+
}
|
|
76
144
|
//# sourceMappingURL=s2-decoder.js.map
|
package/dist/s2-decoder.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"s2-decoder.js","sourceRoot":"","sources":["../src/s2-decoder.ts"],"names":[],"mappings":"AAAA,UAAU;AACV,+BAA+B;AAC/B,oCAAoC;
|
|
1
|
+
{"version":3,"file":"s2-decoder.js","sourceRoot":"","sources":["../src/s2-decoder.ts"],"names":[],"mappings":"AAAA,UAAU;AACV,+BAA+B;AAC/B,oCAAoC;AAGpC,OAAO,EAAC,uBAAuB,EAAkC,0BAAuB;AAExF,OAAO,EAAC,mBAAmB,EAAE,mBAAmB,EAAC,kCAA+B;AAChF,OAAO,EAAC,cAAc,EAAC,wCAAqC;AAC5D,OAAO,EAAC,SAAS,EAAE,MAAM,EAAE,MAAM,EAAE,WAAW,EAAE,WAAW,EAAC,qCAAkC;AAE9F,8BAA8B;AAC9B,MAAM,CAAC,MAAM,SAAS,GAAG,uBAAu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AAC;gBACX,CAAC,CAAC,EAAE,EAAE,EAAE,CAAC;aACV,CAAC;QACJ,KAAK,CAAC;YACJ,OAAO;gBACL,CAAC,CAAC,GAAG,EAAE,CAAC,EAAE,CAAC;gBACX,CAAC,GAAG,EAAE,CAAC,aAAa,CAAC;aACtB,CAAC;QACJ;YACE,MAAM,IAAI,KAAK,CAAC,oBAAoB,IAAI,EAAE,CAAC,CAAC;IAChD,CAAC;AACH,CAAC"}
|
|
@@ -6,6 +6,26 @@ export type S2Cell = {
|
|
|
6
6
|
export declare function getS2Cell(s2Index: bigint): S2Cell;
|
|
7
7
|
export declare function fromHilbertQuadKey(hilbertQuadkey: string): S2Cell;
|
|
8
8
|
export declare function toHilbertQuadkey(id: bigint): string;
|
|
9
|
+
/**
|
|
10
|
+
* Converts face-local integer coordinates into an S2 cell index.
|
|
11
|
+
*
|
|
12
|
+
* @param s2Cell - Face, `(i, j)` coordinates, and level of an S2 cell.
|
|
13
|
+
* @returns The corresponding 64-bit S2 cell index.
|
|
14
|
+
*/
|
|
15
|
+
export declare function getS2IndexFromCell(s2Cell: S2Cell): bigint;
|
|
16
|
+
/**
|
|
17
|
+
* Returns a spatially addressed descendant of an S2 cell.
|
|
18
|
+
*
|
|
19
|
+
* Unlike {@link getS2ChildIndex}, `x` and `y` address the descendant along increasing face-local
|
|
20
|
+
* `i` and `j` axes. This accounts for Hilbert orientation changes across faces and levels.
|
|
21
|
+
*
|
|
22
|
+
* @param rootIndex - Valid S2 cell index at the root of the relative grid.
|
|
23
|
+
* @param relativeLevel - Number of subdivision levels below the root.
|
|
24
|
+
* @param x - Descendant coordinate along the root cell's increasing `i` axis.
|
|
25
|
+
* @param y - Descendant coordinate along the root cell's increasing `j` axis.
|
|
26
|
+
* @returns The descendant S2 cell index.
|
|
27
|
+
*/
|
|
28
|
+
export declare function getS2DescendantIndex(rootIndex: bigint, relativeLevel: number, x: number, y: number): bigint;
|
|
9
29
|
export declare function IJToST(ij: [number, number], order: number, offsets: [number, number]): [number, number];
|
|
10
30
|
export declare function STToUV(st: [number, number]): [number, number];
|
|
11
31
|
export declare function FaceUVToXYZ(face: number, [u, v]: [number, number]): [number, number, number];
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"s2-geometry.d.ts","sourceRoot":"","sources":["../../src/s2-geometry/s2-geometry.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"s2-geometry.d.ts","sourceRoot":"","sources":["../../src/s2-geometry/s2-geometry.ts"],"names":[],"mappings":"AAeA,MAAM,MAAM,MAAM,GAAG;IACnB,IAAI,EAAE,MAAM,CAAC;IACb,EAAE,EAAE,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;IACrB,KAAK,EAAE,MAAM,CAAC;CACf,CAAC;AAEF,wBAAgB,SAAS,CAAC,OAAO,EAAE,MAAM,GAAG,MAAM,CAOjD;AA8CD,wBAAgB,kBAAkB,CAAC,cAAc,EAAE,MAAM,GAAG,MAAM,CAwCjE;AAED,wBAAgB,gBAAgB,CAAC,EAAE,EAAE,MAAM,GAAG,MAAM,CAgCnD;AAED;;;;;GAKG;AACH,wBAAgB,kBAAkB,CAAC,MAAM,EAAE,MAAM,GAAG,MAAM,CA4BzD;AAED;;;;;;;;;;;GAWG;AACH,wBAAgB,oBAAoB,CAClC,SAAS,EAAE,MAAM,EACjB,aAAa,EAAE,MAAM,EACrB,CAAC,EAAE,MAAM,EACT,CAAC,EAAE,MAAM,GACR,MAAM,CAyBR;AAED,wBAAgB,MAAM,CACpB,EAAE,EAAE,CAAC,MAAM,EAAE,MAAM,CAAC,EACpB,KAAK,EAAE,MAAM,EACb,OAAO,EAAE,CAAC,MAAM,EAAE,MAAM,CAAC,GACxB,CAAC,MAAM,EAAE,MAAM,CAAC,CAIlB;AASD,wBAAgB,MAAM,CAAC,EAAE,EAAE,CAAC,MAAM,EAAE,MAAM,CAAC,GAAG,CAAC,MAAM,EAAE,MAAM,CAAC,CAE7D;AAED,wBAAgB,WAAW,CAAC,IAAI,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