@deck.gl-community/geo-layers 9.2.0-beta.3
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 +19 -0
- package/README.md +5 -0
- package/dist/global-grid-layer/global-grid-cluster-layer.d.ts +36 -0
- package/dist/global-grid-layer/global-grid-cluster-layer.d.ts.map +1 -0
- package/dist/global-grid-layer/global-grid-cluster-layer.js +55 -0
- package/dist/global-grid-layer/global-grid-cluster-layer.js.map +1 -0
- package/dist/global-grid-layer/global-grid-layer.d.ts +21 -0
- package/dist/global-grid-layer/global-grid-layer.d.ts.map +1 -0
- package/dist/global-grid-layer/global-grid-layer.js +33 -0
- package/dist/global-grid-layer/global-grid-layer.js.map +1 -0
- package/dist/global-grid-systems/grids/a5-grid.d.ts +18 -0
- package/dist/global-grid-systems/grids/a5-grid.d.ts.map +1 -0
- package/dist/global-grid-systems/grids/a5-grid.js +23 -0
- package/dist/global-grid-systems/grids/a5-grid.js.map +1 -0
- package/dist/global-grid-systems/grids/geohash-grid.d.ts +15 -0
- package/dist/global-grid-systems/grids/geohash-grid.d.ts.map +1 -0
- package/dist/global-grid-systems/grids/geohash-grid.js +92 -0
- package/dist/global-grid-systems/grids/geohash-grid.js.map +1 -0
- package/dist/global-grid-systems/grids/global-grid.d.ts +31 -0
- package/dist/global-grid-systems/grids/global-grid.d.ts.map +1 -0
- package/dist/global-grid-systems/grids/global-grid.js +5 -0
- package/dist/global-grid-systems/grids/global-grid.js.map +1 -0
- package/dist/global-grid-systems/grids/h3-grid.d.ts +16 -0
- package/dist/global-grid-systems/grids/h3-grid.d.ts.map +1 -0
- package/dist/global-grid-systems/grids/h3-grid.js +29 -0
- package/dist/global-grid-systems/grids/h3-grid.js.map +1 -0
- package/dist/global-grid-systems/grids/quadkey-grid.d.ts +41 -0
- package/dist/global-grid-systems/grids/quadkey-grid.d.ts.map +1 -0
- package/dist/global-grid-systems/grids/quadkey-grid.js +166 -0
- package/dist/global-grid-systems/grids/quadkey-grid.js.map +1 -0
- package/dist/global-grid-systems/grids/s2-grid.d.ts +16 -0
- package/dist/global-grid-systems/grids/s2-grid.d.ts.map +1 -0
- package/dist/global-grid-systems/grids/s2-grid.js +74 -0
- package/dist/global-grid-systems/grids/s2-grid.js.map +1 -0
- package/dist/global-grid-systems/h3-js-bigint/h3-js-bigint.d.ts +9 -0
- package/dist/global-grid-systems/h3-js-bigint/h3-js-bigint.d.ts.map +1 -0
- package/dist/global-grid-systems/h3-js-bigint/h3-js-bigint.js +62 -0
- package/dist/global-grid-systems/h3-js-bigint/h3-js-bigint.js.map +1 -0
- package/dist/global-grid-systems/s2-geometry/s2-geometry.d.ts +13 -0
- package/dist/global-grid-systems/s2-geometry/s2-geometry.d.ts.map +1 -0
- package/dist/global-grid-systems/s2-geometry/s2-geometry.js +139 -0
- package/dist/global-grid-systems/s2-geometry/s2-geometry.js.map +1 -0
- package/dist/global-grid-systems/s2-geometry/s2-to-boundary.d.ts +14 -0
- package/dist/global-grid-systems/s2-geometry/s2-to-boundary.d.ts.map +1 -0
- package/dist/global-grid-systems/s2-geometry/s2-to-boundary.js +60 -0
- package/dist/global-grid-systems/s2-geometry/s2-to-boundary.js.map +1 -0
- package/dist/global-grid-systems/s2-geometry/s2-token.d.ts +13 -0
- package/dist/global-grid-systems/s2-geometry/s2-token.d.ts.map +1 -0
- package/dist/global-grid-systems/s2-geometry/s2-token.js +61 -0
- package/dist/global-grid-systems/s2-geometry/s2-token.js.map +1 -0
- package/dist/global-grid-systems/utils/geometry-utils.d.ts +4 -0
- package/dist/global-grid-systems/utils/geometry-utils.d.ts.map +1 -0
- package/dist/global-grid-systems/utils/geometry-utils.js +26 -0
- package/dist/global-grid-systems/utils/geometry-utils.js.map +1 -0
- package/dist/global-grid-systems/utils/h3-utils.d.ts +5 -0
- package/dist/global-grid-systems/utils/h3-utils.d.ts.map +1 -0
- package/dist/global-grid-systems/utils/h3-utils.js +41 -0
- package/dist/global-grid-systems/utils/h3-utils.js.map +1 -0
- package/dist/global-grid-systems/utils/hex-utils.d.ts +8 -0
- package/dist/global-grid-systems/utils/hex-utils.d.ts.map +1 -0
- package/dist/global-grid-systems/utils/hex-utils.js +34 -0
- package/dist/global-grid-systems/utils/hex-utils.js.map +1 -0
- package/dist/index.cjs +640 -0
- package/dist/index.cjs.map +7 -0
- package/dist/index.d.ts +10 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +11 -0
- package/dist/index.js.map +1 -0
- package/dist/tile-source-layer/tile-source-layer.d.ts +45 -0
- package/dist/tile-source-layer/tile-source-layer.d.ts.map +1 -0
- package/dist/tile-source-layer/tile-source-layer.js +110 -0
- package/dist/tile-source-layer/tile-source-layer.js.map +1 -0
- package/package.json +53 -0
- package/src/global-grid-layer/global-grid-cluster-layer.ts +93 -0
- package/src/global-grid-layer/global-grid-layer.ts +54 -0
- package/src/global-grid-systems/grids/a5-grid.ts +38 -0
- package/src/global-grid-systems/grids/geohash-grid.ts +105 -0
- package/src/global-grid-systems/grids/global-grid.ts +40 -0
- package/src/global-grid-systems/grids/h3-grid.ts +45 -0
- package/src/global-grid-systems/grids/quadkey-grid.ts +190 -0
- package/src/global-grid-systems/grids/s2-grid.ts +86 -0
- package/src/global-grid-systems/h3-js-bigint/h3-js-bigint.ts +85 -0
- package/src/global-grid-systems/s2-geometry/s2-geometry.ts +180 -0
- package/src/global-grid-systems/s2-geometry/s2-to-boundary.ts +76 -0
- package/src/global-grid-systems/s2-geometry/s2-token.ts +70 -0
- package/src/global-grid-systems/utils/geometry-utils.ts +28 -0
- package/src/global-grid-systems/utils/h3-utils.ts +52 -0
- package/src/global-grid-systems/utils/hex-utils.ts +37 -0
- package/src/index.ts +15 -0
- package/src/tile-source-layer/tile-source-layer.ts +156 -0
package/LICENSE
ADDED
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
Copyright (c) 2022 - 2025 vis.gl contributors
|
|
2
|
+
|
|
3
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
4
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
5
|
+
in the Software without restriction, including without limitation the rights
|
|
6
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
7
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
8
|
+
furnished to do so, subject to the following conditions:
|
|
9
|
+
|
|
10
|
+
The above copyright notice and this permission notice shall be included in
|
|
11
|
+
all copies or substantial portions of the Software.
|
|
12
|
+
|
|
13
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
14
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
15
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
16
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
17
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
18
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
|
19
|
+
THE SOFTWARE.
|
package/README.md
ADDED
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
import { type AccessorFunction, type UpdateParameters } from '@deck.gl/core';
|
|
2
|
+
import { _GeoCellLayer, type _GeoCellLayerProps } from '@deck.gl/geo-layers';
|
|
3
|
+
import { type GlobalGrid } from "../global-grid-systems/grids/global-grid.js";
|
|
4
|
+
/** All properties supported by GlobalGridClusterLayer. */
|
|
5
|
+
export type GlobalGridClusterLayerProps<DataT = unknown> = _GlobalGridClusterLayerProps<DataT> & _GeoCellLayerProps<DataT>;
|
|
6
|
+
/** Properties added by GlobalGridClusterLayer. */
|
|
7
|
+
type _GlobalGridClusterLayerProps<DataT> = {
|
|
8
|
+
/** The DGGS decoder to use. */
|
|
9
|
+
globalGrid: GlobalGrid;
|
|
10
|
+
/** Called for each data object to retrieve the hexagon identifiers. By default, it reads `cellIds` property of data object. */
|
|
11
|
+
getCellIds?: AccessorFunction<DataT, string[] | bigint[]>;
|
|
12
|
+
};
|
|
13
|
+
export declare class GlobalGridClusterLayer<DataT = any, ExtraProps extends {} = {}> extends _GeoCellLayer<DataT, Required<_GlobalGridClusterLayerProps<DataT>> & ExtraProps> {
|
|
14
|
+
static layerName: string;
|
|
15
|
+
static defaultProps: {
|
|
16
|
+
readonly getCellIds: {
|
|
17
|
+
readonly type: "accessor";
|
|
18
|
+
readonly value: (d: any) => any;
|
|
19
|
+
};
|
|
20
|
+
readonly globalGrid: {
|
|
21
|
+
readonly type: "object";
|
|
22
|
+
readonly compare: true;
|
|
23
|
+
readonly value: any;
|
|
24
|
+
};
|
|
25
|
+
};
|
|
26
|
+
state: {
|
|
27
|
+
polygons: {
|
|
28
|
+
polygon: number[][][];
|
|
29
|
+
}[];
|
|
30
|
+
};
|
|
31
|
+
initializeState(): void;
|
|
32
|
+
updateState({ props, changeFlags }: UpdateParameters<this>): void;
|
|
33
|
+
indexToBounds(): Partial<_GeoCellLayer['props']>;
|
|
34
|
+
}
|
|
35
|
+
export {};
|
|
36
|
+
//# sourceMappingURL=global-grid-cluster-layer.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"global-grid-cluster-layer.d.ts","sourceRoot":"","sources":["../../src/global-grid-layer/global-grid-cluster-layer.ts"],"names":[],"mappings":"AAIA,OAAO,EACL,KAAK,gBAAgB,EACrB,KAAK,gBAAgB,EAGtB,MAAM,eAAe,CAAC;AACvB,OAAO,EAAC,aAAa,EAAE,KAAK,kBAAkB,EAAC,MAAM,qBAAqB,CAAC;AAC3E,OAAO,EAAC,KAAK,UAAU,EAAC,oDAAiD;AAGzE,0DAA0D;AAC1D,MAAM,MAAM,2BAA2B,CAAC,KAAK,GAAG,OAAO,IAAI,4BAA4B,CAAC,KAAK,CAAC,GAC5F,kBAAkB,CAAC,KAAK,CAAC,CAAC;AAE5B,kDAAkD;AAClD,KAAK,4BAA4B,CAAC,KAAK,IAAI;IACzC,+BAA+B;IAC/B,UAAU,EAAE,UAAU,CAAC;IACvB,+HAA+H;IAC/H,UAAU,CAAC,EAAE,gBAAgB,CAAC,KAAK,EAAE,MAAM,EAAE,GAAG,MAAM,EAAE,CAAC,CAAC;CAC3D,CAAC;AAEF,qBAAa,sBAAsB,CAAC,KAAK,GAAG,GAAG,EAAE,UAAU,SAAS,EAAE,GAAG,EAAE,CAAE,SAAQ,aAAa,CAChG,KAAK,EACL,QAAQ,CAAC,4BAA4B,CAAC,KAAK,CAAC,CAAC,GAAG,UAAU,CAC3D;IACC,MAAM,CAAC,SAAS,SAA4B;IAC5C,MAAM,CAAC,YAAY;;;gCACyB,GAAG;;;;;;;MAEgB;IAEvD,KAAK,EAAE;QACb,QAAQ,EAAE;YAAC,OAAO,EAAE,MAAM,EAAE,EAAE,EAAE,CAAA;SAAC,EAAE,CAAC;KACrC,CAAC;IAEF,eAAe,IAAI,IAAI;IAIvB,WAAW,CAAC,EAAC,KAAK,EAAE,WAAW,EAAC,EAAE,gBAAgB,CAAC,IAAI,CAAC,GAAG,IAAI;IAmC/D,aAAa,IAAI,OAAO,CAAC,aAAa,CAAC,OAAO,CAAC,CAAC;CAajD"}
|
|
@@ -0,0 +1,55 @@
|
|
|
1
|
+
// deck.gl
|
|
2
|
+
// SPDX-License-Identifier: MIT
|
|
3
|
+
// Copyright (c) vis.gl contributors
|
|
4
|
+
import { createIterable } from '@deck.gl/core';
|
|
5
|
+
import { _GeoCellLayer } from '@deck.gl/geo-layers';
|
|
6
|
+
import { normalizeLongitudes } from "../global-grid-systems/utils/geometry-utils.js";
|
|
7
|
+
export class GlobalGridClusterLayer extends _GeoCellLayer {
|
|
8
|
+
static layerName = 'GlobalGridClusterLayer';
|
|
9
|
+
static defaultProps = {
|
|
10
|
+
getCellIds: { type: 'accessor', value: (d) => d.cellIds },
|
|
11
|
+
globalGrid: { type: 'object', compare: true, value: undefined }
|
|
12
|
+
};
|
|
13
|
+
initializeState() {
|
|
14
|
+
this.props.globalGrid.initialize?.();
|
|
15
|
+
}
|
|
16
|
+
updateState({ props, changeFlags }) {
|
|
17
|
+
if (changeFlags.dataChanged ||
|
|
18
|
+
(changeFlags.updateTriggersChanged && changeFlags.updateTriggersChanged.getCellIds)) {
|
|
19
|
+
const { data, getCellIds, globalGrid } = props;
|
|
20
|
+
const polygons = [];
|
|
21
|
+
const { iterable, objectInfo } = createIterable(data);
|
|
22
|
+
for (const object of iterable) {
|
|
23
|
+
objectInfo.index++;
|
|
24
|
+
const cellIds = getCellIds(object, objectInfo);
|
|
25
|
+
if (!globalGrid.cellsToBoundaryMultiPolygon) {
|
|
26
|
+
throw new Error(`${globalGrid.name} adapter: cellsToBoundaryMultiPolygon not supported`);
|
|
27
|
+
}
|
|
28
|
+
// TODO - should not need to map the tokens
|
|
29
|
+
const cellIndexes = cellIds.map((cellId) => typeof cellId === 'string' ? globalGrid.tokenToCell?.(cellId) : cellId);
|
|
30
|
+
const multiPolygon = globalGrid.cellsToBoundaryMultiPolygon(cellIndexes);
|
|
31
|
+
for (const polygon of multiPolygon) {
|
|
32
|
+
// Normalize polygons to prevent wrapping over the anti-meridian
|
|
33
|
+
// eslint-disable-next-line max-depth
|
|
34
|
+
for (const ring of polygon) {
|
|
35
|
+
normalizeLongitudes(ring);
|
|
36
|
+
}
|
|
37
|
+
polygons.push(this.getSubLayerRow({ polygon }, object, objectInfo.index));
|
|
38
|
+
}
|
|
39
|
+
}
|
|
40
|
+
this.setState({ polygons });
|
|
41
|
+
}
|
|
42
|
+
}
|
|
43
|
+
indexToBounds() {
|
|
44
|
+
const { getElevation, getFillColor, getLineColor, getLineWidth } = this.props;
|
|
45
|
+
return {
|
|
46
|
+
data: this.state.polygons,
|
|
47
|
+
getPolygon: (d) => d.polygon,
|
|
48
|
+
getElevation: this.getSubLayerAccessor(getElevation),
|
|
49
|
+
getFillColor: this.getSubLayerAccessor(getFillColor),
|
|
50
|
+
getLineColor: this.getSubLayerAccessor(getLineColor),
|
|
51
|
+
getLineWidth: this.getSubLayerAccessor(getLineWidth)
|
|
52
|
+
};
|
|
53
|
+
}
|
|
54
|
+
}
|
|
55
|
+
//# sourceMappingURL=global-grid-cluster-layer.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"global-grid-cluster-layer.js","sourceRoot":"","sources":["../../src/global-grid-layer/global-grid-cluster-layer.ts"],"names":[],"mappings":"AAAA,UAAU;AACV,+BAA+B;AAC/B,oCAAoC;AAEpC,OAAO,EAIL,cAAc,EACf,MAAM,eAAe,CAAC;AACvB,OAAO,EAAC,aAAa,EAA0B,MAAM,qBAAqB,CAAC;AAE3E,OAAO,EAAC,mBAAmB,EAAC,uDAAoD;AAchF,MAAM,OAAO,sBAAgE,SAAQ,aAGpF;IACC,MAAM,CAAC,SAAS,GAAG,wBAAwB,CAAC;IAC5C,MAAM,CAAC,YAAY,GAAG;QACpB,UAAU,EAAE,EAAC,IAAI,EAAE,UAAU,EAAE,KAAK,EAAE,CAAC,CAAM,EAAE,EAAE,CAAC,CAAC,CAAC,OAAO,EAAC;QAC5D,UAAU,EAAE,EAAC,IAAI,EAAE,QAAQ,EAAE,OAAO,EAAE,IAAI,EAAE,KAAK,EAAE,SAAU,EAAC;KACF,CAAC;IAM/D,eAAe;QACb,IAAI,CAAC,KAAK,CAAC,UAAU,CAAC,UAAU,EAAE,EAAE,CAAC;IACvC,CAAC;IAED,WAAW,CAAC,EAAC,KAAK,EAAE,WAAW,EAAyB;QACtD,IACE,WAAW,CAAC,WAAW;YACvB,CAAC,WAAW,CAAC,qBAAqB,IAAI,WAAW,CAAC,qBAAqB,CAAC,UAAU,CAAC,EACnF,CAAC;YACD,MAAM,EAAC,IAAI,EAAE,UAAU,EAAE,UAAU,EAAC,GAAG,KAAK,CAAC;YAC7C,MAAM,QAAQ,GAA8B,EAAE,CAAC;YAE/C,MAAM,EAAC,QAAQ,EAAE,UAAU,EAAC,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AAC,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,OAAO;YAE5B,YAAY,EAAE,IAAI,CAAC,mBAAmB,CAAC,YAAY,CAAC;YACpD,YAAY,EAAE,IAAI,CAAC,mBAAmB,CAAC,YAAY,CAAC;YACpD,YAAY,EAAE,IAAI,CAAC,mBAAmB,CAAC,YAAY,CAAC;YACpD,YAAY,EAAE,IAAI,CAAC,mBAAmB,CAAC,YAAY,CAAC;SACrD,CAAC;IACJ,CAAC"}
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
import { type AccessorFunction, type DefaultProps } from '@deck.gl/core';
|
|
2
|
+
import { _GeoCellLayer, type _GeoCellLayerProps } from '@deck.gl/geo-layers';
|
|
3
|
+
import { GlobalGrid } from "../global-grid-systems/grids/global-grid.js";
|
|
4
|
+
/** All properties supported by GlobalGridLayer. */
|
|
5
|
+
export type GlobalGridLayerProps<DataT = unknown> = _GlobalGridLayerProps<DataT> & _GeoCellLayerProps<DataT>;
|
|
6
|
+
/** Properties added by GlobalGridLayer. */
|
|
7
|
+
type _GlobalGridLayerProps<DataT> = {
|
|
8
|
+
/** The DGGS decoder to use. */
|
|
9
|
+
globalGrid: GlobalGrid;
|
|
10
|
+
/** Called for each data object to retrieve the DGGS cell identifier. By default, it reads `cellId` property of data object. */
|
|
11
|
+
getCellId?: AccessorFunction<DataT, string | bigint>;
|
|
12
|
+
};
|
|
13
|
+
/** Render filled and/or stroked polygons based on the specified DGGS geospatial indexing system. */
|
|
14
|
+
export declare class GlobalGridLayer<DataT = any, ExtraProps extends {} = {}> extends _GeoCellLayer<DataT, Required<_GlobalGridLayerProps<DataT>> & ExtraProps> {
|
|
15
|
+
static layerName: string;
|
|
16
|
+
static defaultProps: DefaultProps<GlobalGridLayerProps>;
|
|
17
|
+
initializeState(): void;
|
|
18
|
+
indexToBounds(): Partial<_GeoCellLayer['props']> | null;
|
|
19
|
+
}
|
|
20
|
+
export {};
|
|
21
|
+
//# sourceMappingURL=global-grid-layer.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"global-grid-layer.d.ts","sourceRoot":"","sources":["../../src/global-grid-layer/global-grid-layer.ts"],"names":[],"mappings":"AAIA,OAAO,EAAC,KAAK,gBAAgB,EAAE,KAAK,YAAY,EAAC,MAAM,eAAe,CAAC;AACvE,OAAO,EAAC,aAAa,EAAE,KAAK,kBAAkB,EAAC,MAAM,qBAAqB,CAAC;AAC3E,OAAO,EAAC,UAAU,EAAC,oDAAiD;AAGpE,mDAAmD;AACnD,MAAM,MAAM,oBAAoB,CAAC,KAAK,GAAG,OAAO,IAAI,qBAAqB,CAAC,KAAK,CAAC,GAC9E,kBAAkB,CAAC,KAAK,CAAC,CAAC;AAE5B,2CAA2C;AAC3C,KAAK,qBAAqB,CAAC,KAAK,IAAI;IAClC,+BAA+B;IAC/B,UAAU,EAAE,UAAU,CAAC;IACvB,+HAA+H;IAC/H,SAAS,CAAC,EAAE,gBAAgB,CAAC,KAAK,EAAE,MAAM,GAAG,MAAM,CAAC,CAAC;CACtD,CAAC;AAEF,oGAAoG;AACpG,qBAAa,eAAe,CAAC,KAAK,GAAG,GAAG,EAAE,UAAU,SAAS,EAAE,GAAG,EAAE,CAAE,SAAQ,aAAa,CACzF,KAAK,EACL,QAAQ,CAAC,qBAAqB,CAAC,KAAK,CAAC,CAAC,GAAG,UAAU,CACpD;IACC,MAAM,CAAC,SAAS,SAAqB;IACrC,MAAM,CAAC,YAAY,EAAE,YAAY,CAAC,oBAAoB,CAAC,CAGrD;IAEF,eAAe,IAAI,IAAI;IAIvB,aAAa,IAAI,OAAO,CAAC,aAAa,CAAC,OAAO,CAAC,CAAC,GAAG,IAAI;CAiBxD"}
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
// deck.gl
|
|
2
|
+
// SPDX-License-Identifier: MIT
|
|
3
|
+
// Copyright (c) vis.gl contributors
|
|
4
|
+
import { _GeoCellLayer } from '@deck.gl/geo-layers';
|
|
5
|
+
import { flattenPolygon } from "../global-grid-systems/utils/geometry-utils.js";
|
|
6
|
+
/** Render filled and/or stroked polygons based on the specified DGGS geospatial indexing system. */
|
|
7
|
+
export class GlobalGridLayer extends _GeoCellLayer {
|
|
8
|
+
static layerName = 'GlobalGridLayer';
|
|
9
|
+
static defaultProps = {
|
|
10
|
+
getCellId: { type: 'accessor', value: (d) => d.cellId },
|
|
11
|
+
globalGrid: { type: 'object', compare: true, value: undefined }
|
|
12
|
+
};
|
|
13
|
+
initializeState() {
|
|
14
|
+
this.props.globalGrid?.initialize?.();
|
|
15
|
+
}
|
|
16
|
+
indexToBounds() {
|
|
17
|
+
const { data, getCellId } = this.props;
|
|
18
|
+
return {
|
|
19
|
+
data,
|
|
20
|
+
_normalize: false,
|
|
21
|
+
_windingOrder: 'CCW',
|
|
22
|
+
positionFormat: 'XY',
|
|
23
|
+
getPolygon: (x, objectInfo) => {
|
|
24
|
+
const { globalGrid } = this.props;
|
|
25
|
+
const cell = getCellId(x, objectInfo);
|
|
26
|
+
const boundary = globalGrid.cellToBoundary(cell);
|
|
27
|
+
boundary.push(boundary[0]);
|
|
28
|
+
return flattenPolygon(boundary);
|
|
29
|
+
}
|
|
30
|
+
};
|
|
31
|
+
}
|
|
32
|
+
}
|
|
33
|
+
//# sourceMappingURL=global-grid-layer.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"global-grid-layer.js","sourceRoot":"","sources":["../../src/global-grid-layer/global-grid-layer.ts"],"names":[],"mappings":"AAAA,UAAU;AACV,+BAA+B;AAC/B,oCAAoC;AAGpC,OAAO,EAAC,aAAa,EAA0B,MAAM,qBAAqB,CAAC;AAE3E,OAAO,EAAC,cAAc,EAAC,uDAAoD;AAc3E,oGAAoG;AACpG,MAAM,OAAO,eAAyD,SAAQ,aAG7E;IACC,MAAM,CAAC,SAAS,GAAG,iBAAiB,CAAC;IACrC,MAAM,CAAC,YAAY,GAAuC;QACxD,SAAS,EAAE,EAAC,IAAI,EAAE,UAAU,EAAE,KAAK,EAAE,CAAC,CAAM,EAAE,EAAE,CAAC,CAAC,CAAC,MAAM,EAAC;QAC1D,UAAU,EAAE,EAAC,IAAI,EAAE,QAAQ,EAAE,OAAO,EAAE,IAAI,EAAE,KAAK,EAAE,SAAU,EAAC;KAC/D,CAAC;IAEF,eAAe;QACb,IAAI,CAAC,KAAK,CAAC,UAAU,EAAE,UAAU,EAAE,EAAE,CAAC;IACxC,CAAC;IAED,aAAa;QACX,MAAM,EAAC,IAAI,EAAE,SAAS,EAAC,GAAG,IAAI,CAAC,KAAK,CAAC;QAErC,OAAO;YACL,IAAI;YACJ,UAAU,EAAE,KAAK;YACjB,aAAa,EAAE,KAAK;YACpB,cAAc,EAAE,IAAI;YACpB,UAAU,EAAE,CAAC,CAAQ,EAAE,UAAU,EAAE,EAAE;gBACnC,MAAM,EAAC,UAAU,EAAC,GAAG,IAAI,CAAC,KAAK,CAAC;gBAChC,MAAM,IAAI,GAAG,SAAS,CAAC,CAAC,EAAE,UAAU,CAAC,CAAC;gBACtC,MAAM,QAAQ,GAAG,UAAU,CAAC,cAAc,CAAC,IAAI,CAAC,CAAC;gBACjD,QAAQ,CAAC,IAAI,CAAC,QAAQ,CAAC,CAAC,CAAC,CAAC,CAAC;gBAC3B,OAAO,cAAc,CAAC,QAAQ,CAAC,CAAC;YAClC,CAAC;SACF,CAAC;IACJ,CAAC"}
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* "Standardized" API for working with A5 DGGS tokens.
|
|
3
|
+
* @note Copy of same type in math.gl. They are structurally identical. Will be replaced by an import in the future.
|
|
4
|
+
*/
|
|
5
|
+
export declare const A5Grid: {
|
|
6
|
+
readonly name: "A5";
|
|
7
|
+
readonly hasNumericRepresentation: true;
|
|
8
|
+
readonly tokenToCell: (token: string) => bigint;
|
|
9
|
+
readonly lngLatToCell: (lngLat: [number, number], resolution: number) => bigint;
|
|
10
|
+
readonly cellToToken: (cell: string | bigint) => string;
|
|
11
|
+
readonly cellToLngLat: (cell: string | bigint) => [longitude: import("a5-js").Degrees, latitude: import("a5-js").Degrees] & {
|
|
12
|
+
__brand: "LonLat";
|
|
13
|
+
};
|
|
14
|
+
readonly cellToBoundary: (cell: string | bigint) => ([longitude: import("a5-js").Degrees, latitude: import("a5-js").Degrees] & {
|
|
15
|
+
__brand: "LonLat";
|
|
16
|
+
})[];
|
|
17
|
+
};
|
|
18
|
+
//# sourceMappingURL=a5-grid.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"a5-grid.d.ts","sourceRoot":"","sources":["../../../src/global-grid-systems/grids/a5-grid.ts"],"names":[],"mappings":"AAiBA;;;GAGG;AACH,eAAO,MAAM,MAAM;;;kCAII,MAAM;oCACJ,CAAC,MAAM,EAAE,MAAM,CAAC,cAAc,MAAM;iCAGvC,MAAM,GAAG,MAAM;kCACd,MAAM,GAAG,MAAM;;;oCACb,MAAM,GAAG,MAAM;;;CACT,CAAC"}
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
// deck.gl
|
|
2
|
+
// SPDX-License-Identifier: MIT
|
|
3
|
+
// Copyright (c) vis.gl contributors
|
|
4
|
+
import { cellToBoundary, cellToLonLat, lonLatToCell } from 'a5-js';
|
|
5
|
+
import { hexToBigInt } from "../utils/hex-utils.js";
|
|
6
|
+
/**
|
|
7
|
+
* "Standardized" API for working with A5 DGGS tokens.
|
|
8
|
+
* @note Copy of same type in math.gl. They are structurally identical. Will be replaced by an import in the future.
|
|
9
|
+
*/
|
|
10
|
+
export const A5Grid = {
|
|
11
|
+
name: 'A5',
|
|
12
|
+
hasNumericRepresentation: true,
|
|
13
|
+
tokenToCell: (token) => hexToBigInt(token),
|
|
14
|
+
lngLatToCell: (lngLat, resolution) => lonLatToCell(lngLat, resolution),
|
|
15
|
+
cellToToken: (cell) => (typeof cell === 'string' ? cell : cell.toString(16)),
|
|
16
|
+
cellToLngLat: (cell) => cellToLonLat(getBigInt(cell)),
|
|
17
|
+
cellToBoundary: (cell) => cellToBoundary(getBigInt(cell))
|
|
18
|
+
};
|
|
19
|
+
/** Helper function to convert cells to bigints */
|
|
20
|
+
const getBigInt = (value) => {
|
|
21
|
+
return typeof value === 'string' ? hexToBigInt(value) : value;
|
|
22
|
+
};
|
|
23
|
+
//# sourceMappingURL=a5-grid.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"a5-grid.js","sourceRoot":"","sources":["../../../src/global-grid-systems/grids/a5-grid.ts"],"names":[],"mappings":"AAAA,UAAU;AACV,+BAA+B;AAC/B,oCAAoC;AAIpC,OAAO,EAAC,cAAc,EAAE,YAAY,EAAE,YAAY,EAAC,MAAM,OAAO,CAAC;AACjE,OAAO,EAAE,WAAW,EAAE,8BAA2B;AAUjD;;;GAGG;AACH,MAAM,CAAC,MAAM,MAAM,GAAG;IACpB,IAAI,EAAE,IAAI;IACV,wBAAwB,EAAE,IAAI;IAE9B,WAAW,EAAE,CAAC,KAAa,EAAE,EAAE,CAAC,WAAW,CAAC,KAAK,CAAC;IAClD,YAAY,EAAE,CAAC,MAAwB,EAAE,UAAkB,EAAE,EAAE,CAC7D,YAAY,CAAC,MAAgB,EAAE,UAAU,CAAC;IAE5C,WAAW,EAAE,CAAC,IAAqB,EAAE,EAAE,CAAC,CAAC,OAAO,IAAI,KAAK,QAAQ,CAAC,CAAC,CAAC,IAAI,CAAC,CAAC,CAAC,IAAI,CAAC,QAAQ,CAAC,EAAE,CAAC,CAAC;IAC7F,YAAY,EAAE,CAAC,IAAqB,EAAE,EAAE,CAAC,YAAY,CAAC,SAAS,CAAC,IAAI,CAAC,CAAC;IACtE,cAAc,EAAE,CAAC,IAAqB,EAAE,EAAE,CAAC,cAAc,CAAC,SAAS,CAAC,IAAI,CAAC,CAAC;CAC7C,CAAC;AAEhC,kDAAkD;AAClD,MAAM,SAAS,GAAG,CAAC,KAAsB,EAAU,EAAE;IACnD,OAAO,OAAO,KAAK,KAAK,QAAQ,CAAC,CAAC,CAAC,WAAW,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC,KAAK,CAAC;AAChE,CAAC,CAAC"}
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import { type Bounds2D } from '@math.gl/types';
|
|
2
|
+
/** Decoder for the geohash global grid system */
|
|
3
|
+
export declare const GeohashGrid: {
|
|
4
|
+
readonly name: "geohash";
|
|
5
|
+
readonly hasNumericRepresentation: false;
|
|
6
|
+
readonly cellToLngLat: (geohash: string | bigint) => [number, number];
|
|
7
|
+
readonly cellToBoundary: (geohash: string | bigint) => [number, number][];
|
|
8
|
+
};
|
|
9
|
+
/** Return boundary polygon of geohash cell as flat array */
|
|
10
|
+
export declare function getGeohashBoundaryFlat(geohash: string): number[];
|
|
11
|
+
/**
|
|
12
|
+
* @note Adapted from ngeohash decode_bbox
|
|
13
|
+
*/
|
|
14
|
+
export declare function getGeohashBounds(geohash: string): Bounds2D;
|
|
15
|
+
//# sourceMappingURL=geohash-grid.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"geohash-grid.d.ts","sourceRoot":"","sources":["../../../src/global-grid-systems/grids/geohash-grid.ts"],"names":[],"mappings":"AAIA,OAAO,EAAC,KAAK,QAAQ,EAAC,MAAM,gBAAgB,CAAC;AAG7C,iDAAiD;AACjD,eAAO,MAAM,WAAW;;;qCAIE,MAAM,GAAG,MAAM,KAAG,CAAC,MAAM,EAAE,MAAM,CAAC;uCAEhC,MAAM,GAAG,MAAM,KAAG,CAAC,MAAM,EAAE,MAAM,CAAC,EAAE;CAIjC,CAAC;AAsChC,4DAA4D;AAC5D,wBAAgB,sBAAsB,CAAC,OAAO,EAAE,MAAM,GAAG,MAAM,EAAE,CAGhE;AAED;;GAEG;AAEH,wBAAgB,gBAAgB,CAAC,OAAO,EAAE,MAAM,GAAG,QAAQ,CAsC1D"}
|
|
@@ -0,0 +1,92 @@
|
|
|
1
|
+
// math.gl
|
|
2
|
+
// SPDX-License-Identifier: MIT
|
|
3
|
+
// Copyright (c) vis.gl contributors
|
|
4
|
+
/** Decoder for the geohash global grid system */
|
|
5
|
+
export const GeohashGrid = {
|
|
6
|
+
name: 'geohash',
|
|
7
|
+
hasNumericRepresentation: false,
|
|
8
|
+
cellToLngLat: (geohash) => getGeohashLngLat(getString(geohash)),
|
|
9
|
+
cellToBoundary: (geohash) => getGeohashBoundary(getString(geohash))
|
|
10
|
+
// cellToBoundaryPolygonFlat: (geohash: bigint): number[] => getGeohashBoundaryFlat(geohash),
|
|
11
|
+
// cellToBounds: (geohash: bigint): Bounds2D => getGeohashBounds(geohash)
|
|
12
|
+
};
|
|
13
|
+
const getString = (geohash) => {
|
|
14
|
+
if (typeof geohash !== 'string') {
|
|
15
|
+
throw new Error('geohash must be a string');
|
|
16
|
+
}
|
|
17
|
+
return geohash;
|
|
18
|
+
};
|
|
19
|
+
const BASE32_CODES = '0123456789bcdefghjkmnpqrstuvwxyz';
|
|
20
|
+
const BASE32_CODES_DICT = {};
|
|
21
|
+
for (let i = 0; i < BASE32_CODES.length; i++) {
|
|
22
|
+
BASE32_CODES_DICT[BASE32_CODES.charAt(i)] = i;
|
|
23
|
+
}
|
|
24
|
+
const MIN_LAT = -90;
|
|
25
|
+
const MAX_LAT = 90;
|
|
26
|
+
const MIN_LON = -180;
|
|
27
|
+
const MAX_LON = 180;
|
|
28
|
+
/** Return center lng,lat of geohash cell */
|
|
29
|
+
function getGeohashLngLat(geohash) {
|
|
30
|
+
const [[s, w], [n, e]] = getGeohashBounds(geohash);
|
|
31
|
+
return [(e + w) / 2, (n + s) / 2];
|
|
32
|
+
}
|
|
33
|
+
/** Return boundary polygon of geohash cell as lng,lat array */
|
|
34
|
+
function getGeohashBoundary(geohash) {
|
|
35
|
+
const [[s, w], [n, e]] = getGeohashBounds(geohash);
|
|
36
|
+
return [
|
|
37
|
+
[e, n],
|
|
38
|
+
[e, s],
|
|
39
|
+
[w, s],
|
|
40
|
+
[w, n],
|
|
41
|
+
[e, n]
|
|
42
|
+
];
|
|
43
|
+
}
|
|
44
|
+
/** Return boundary polygon of geohash cell as flat array */
|
|
45
|
+
export function getGeohashBoundaryFlat(geohash) {
|
|
46
|
+
const [[s, w], [n, e]] = getGeohashBounds(geohash);
|
|
47
|
+
return [e, n, e, s, w, s, w, n, e, n];
|
|
48
|
+
}
|
|
49
|
+
/**
|
|
50
|
+
* @note Adapted from ngeohash decode_bbox
|
|
51
|
+
*/
|
|
52
|
+
/* eslint-disable max-depth */
|
|
53
|
+
export function getGeohashBounds(geohash) {
|
|
54
|
+
let isLon = true;
|
|
55
|
+
let maxLat = MAX_LAT;
|
|
56
|
+
let minLat = MIN_LAT;
|
|
57
|
+
let maxLon = MAX_LON;
|
|
58
|
+
let minLon = MIN_LON;
|
|
59
|
+
let mid;
|
|
60
|
+
let hashValue = 0;
|
|
61
|
+
for (let i = 0, l = geohash.length; i < l; i++) {
|
|
62
|
+
const code = geohash[i].toLowerCase();
|
|
63
|
+
hashValue = BASE32_CODES_DICT[code];
|
|
64
|
+
for (let bits = 4; bits >= 0; bits--) {
|
|
65
|
+
const bit = (hashValue >> bits) & 1;
|
|
66
|
+
if (isLon) {
|
|
67
|
+
mid = (maxLon + minLon) / 2;
|
|
68
|
+
if (bit === 1) {
|
|
69
|
+
minLon = mid;
|
|
70
|
+
}
|
|
71
|
+
else {
|
|
72
|
+
maxLon = mid;
|
|
73
|
+
}
|
|
74
|
+
}
|
|
75
|
+
else {
|
|
76
|
+
mid = (maxLat + minLat) / 2;
|
|
77
|
+
if (bit === 1) {
|
|
78
|
+
minLat = mid;
|
|
79
|
+
}
|
|
80
|
+
else {
|
|
81
|
+
maxLat = mid;
|
|
82
|
+
}
|
|
83
|
+
}
|
|
84
|
+
isLon = !isLon;
|
|
85
|
+
}
|
|
86
|
+
}
|
|
87
|
+
return [
|
|
88
|
+
[minLat, minLon],
|
|
89
|
+
[maxLat, maxLon]
|
|
90
|
+
];
|
|
91
|
+
}
|
|
92
|
+
//# sourceMappingURL=geohash-grid.js.map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CAAC,CAAC;IAClB,KAAK,IAAI,CAAC,GAAG,CAAC,EAAE,CAAC,GAAG,OAAO,CAAC,MAAM,EAAE,CAAC,GAAG,CAAC,EAAE,CAAC,EAAE,EAAE,CAAC;QAC/C,MAAM,IAAI,GAAG,OAAO,CAAC,CAAC,CAAC,CAAC,WAAW,EAAE,CAAC;QACtC,SAAS,GAAG,iBAAiB,CAAC,IAAI,CAAC,CAAC;QAEpC,KAAK,IAAI,IAAI,GAAG,CAAC,EAAE,IAAI,IAAI,CAAC,EAAE,IAAI,EAAE,EAAE,CAAC;YACrC,MAAM,GAAG,GAAG,CAAC,SAAS,IAAI,IAAI,CAAC,GAAG,CAAC,CAAC;YACpC,IAAI,KAAK,EAAE,CAAC;gBACV,GAAG,GAAG,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;iBAAM,CAAC;gBACN,GAAG,GAAG,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"}
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Copy of same type in math.gl. They are structurally identical.
|
|
3
|
+
* This type declares a "standardized" API for accessing basic DGGS token decoding
|
|
4
|
+
* DGGS modules export objects that satisfy this "interface",
|
|
5
|
+
* allowing different DGGS systems can be used interchangeably.
|
|
6
|
+
*/
|
|
7
|
+
export type GlobalGrid = {
|
|
8
|
+
/** The name of the DGGS */
|
|
9
|
+
name: string;
|
|
10
|
+
/** Does this grid have a numeric representation of cells? */
|
|
11
|
+
hasNumericRepresentation: boolean;
|
|
12
|
+
/** Initialization function. Should be idempotent, i.e. it may be called multiple times */
|
|
13
|
+
initialize?: () => void;
|
|
14
|
+
/** Is the argument a valid index in this grid? */
|
|
15
|
+
isValidCell?: (cell: string | bigint) => boolean;
|
|
16
|
+
/** Convert a string token to a binary cell index */
|
|
17
|
+
tokenToCell?: (token: string) => bigint;
|
|
18
|
+
/** Convert a binary cell index to a token */
|
|
19
|
+
cellToToken?: (cell: string | bigint) => string;
|
|
20
|
+
/** Convert a long, lat to a cell */
|
|
21
|
+
lngLatToCell?: (lngLat: [number, number], resolution: any) => bigint;
|
|
22
|
+
/** Convert a long, lat to a string token (H3 index) */
|
|
23
|
+
lngLatToToken?: (lngLat: [number, number], resolution: any) => string;
|
|
24
|
+
/** @returns the center of the cell */
|
|
25
|
+
cellToLngLat: (cell: string | bigint) => [number, number];
|
|
26
|
+
/** @returns the boundary of the cell, as an array of coordinate arrays */
|
|
27
|
+
cellToBoundary: (cell: string | bigint) => [number, number][];
|
|
28
|
+
/** @returns the bounds of the cell */
|
|
29
|
+
cellsToBoundaryMultiPolygon?: (cells: string[] | bigint[]) => [number, number][][][];
|
|
30
|
+
};
|
|
31
|
+
//# sourceMappingURL=global-grid.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"global-grid.d.ts","sourceRoot":"","sources":["../../../src/global-grid-systems/grids/global-grid.ts"],"names":[],"mappings":"AAIA;;;;;GAKG;AACH,MAAM,MAAM,UAAU,GAAG;IACvB,2BAA2B;IAC3B,IAAI,EAAE,MAAM,CAAC;IAEb,6DAA6D;IAC7D,wBAAwB,EAAE,OAAO,CAAC;IAElC,0FAA0F;IAC1F,UAAU,CAAC,EAAE,MAAM,IAAI,CAAC;IAExB,kDAAkD;IAClD,WAAW,CAAC,EAAE,CAAC,IAAI,EAAE,MAAM,GAAG,MAAM,KAAK,OAAO,CAAC;IAEjD,oDAAoD;IACpD,WAAW,CAAC,EAAE,CAAC,KAAK,EAAE,MAAM,KAAK,MAAM,CAAC;IACxC,6CAA6C;IAC7C,WAAW,CAAC,EAAE,CAAC,IAAI,EAAE,MAAM,GAAG,MAAM,KAAK,MAAM,CAAC;IAEhD,oCAAoC;IACpC,YAAY,CAAC,EAAE,CAAC,MAAM,EAAE,CAAC,MAAM,EAAE,MAAM,CAAC,EAAE,UAAU,KAAA,KAAK,MAAM,CAAC;IAChE,uDAAuD;IACvD,aAAa,CAAC,EAAE,CAAC,MAAM,EAAE,CAAC,MAAM,EAAE,MAAM,CAAC,EAAE,UAAU,KAAA,KAAK,MAAM,CAAC;IAEjE,sCAAsC;IACtC,YAAY,EAAE,CAAC,IAAI,EAAE,MAAM,GAAG,MAAM,KAAK,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;IAC1D,0EAA0E;IAC1E,cAAc,EAAE,CAAC,IAAI,EAAE,MAAM,GAAG,MAAM,KAAK,CAAC,MAAM,EAAE,MAAM,CAAC,EAAE,CAAC;IAC9D,sCAAsC;IACtC,2BAA2B,CAAC,EAAE,CAAC,KAAK,EAAE,MAAM,EAAE,GAAG,MAAM,EAAE,KAAK,CAAC,MAAM,EAAE,MAAM,CAAC,EAAE,EAAE,EAAE,CAAC;CACtF,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"global-grid.js","sourceRoot":"","sources":["../../../src/global-grid-systems/grids/global-grid.ts"],"names":[],"mappings":"AAAA,UAAU;AACV,+BAA+B;AAC/B,oCAAoC"}
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* "Standardized" API for working with H3 DGGS tokens.
|
|
3
|
+
* @note Inspired by similar work in math.gl. May replace by an import in the future.
|
|
4
|
+
*/
|
|
5
|
+
export declare const H3Grid: {
|
|
6
|
+
readonly name: "H3";
|
|
7
|
+
readonly hasNumericRepresentation: true;
|
|
8
|
+
readonly initialize: () => void;
|
|
9
|
+
readonly tokenToCell: (token: string) => bigint;
|
|
10
|
+
readonly lngLatToToken: (lngLat: [number, number], resolution: number) => string;
|
|
11
|
+
readonly lngLatToCell: (lngLat: [number, number], resolution: number) => bigint;
|
|
12
|
+
readonly cellToLngLat: (cell: string | bigint) => [number, number];
|
|
13
|
+
readonly cellToBoundary: (cell: string | bigint) => import("h3-js").CoordPair[];
|
|
14
|
+
readonly cellsToBoundaryMultiPolygon: (cells: string[] | bigint[]) => import("h3-js").CoordPair[][][];
|
|
15
|
+
};
|
|
16
|
+
//# sourceMappingURL=h3-grid.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"h3-grid.d.ts","sourceRoot":"","sources":["../../../src/global-grid-systems/grids/h3-grid.ts"],"names":[],"mappings":"AAaA;;;GAGG;AACH,eAAO,MAAM,MAAM;;;;kCAOI,MAAM;qCAEH,CAAC,MAAM,EAAE,MAAM,CAAC,cAAc,MAAM;oCAErC,CAAC,MAAM,EAAE,MAAM,CAAC,cAAc,MAAM;kCAGtC,MAAM,GAAG,MAAM;oCACb,MAAM,GAAG,MAAM;kDACD,MAAM,EAAE,GAAG,MAAM,EAAE;CAC3B,CAAC"}
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
// deck.gl
|
|
2
|
+
// SPDX-License-Identifier: MIT
|
|
3
|
+
// Copyright (c) vis.gl contributors
|
|
4
|
+
import { latLngToCell, cellToBoundary, cellToLatLng, cellsToMultiPolygon, h3IndexToBigInt } from "../h3-js-bigint/h3-js-bigint.js";
|
|
5
|
+
/**
|
|
6
|
+
* "Standardized" API for working with H3 DGGS tokens.
|
|
7
|
+
* @note Inspired by similar work in math.gl. May replace by an import in the future.
|
|
8
|
+
*/
|
|
9
|
+
export const H3Grid = {
|
|
10
|
+
name: 'H3',
|
|
11
|
+
hasNumericRepresentation: true,
|
|
12
|
+
// See `main/bundle.ts`, installs a check for the H3 library.
|
|
13
|
+
initialize: () => { },
|
|
14
|
+
tokenToCell: (token) => h3IndexToBigInt(token),
|
|
15
|
+
lngLatToToken: (lngLat, resolution) => latLngToCell(lngLat[1], lngLat[0], resolution),
|
|
16
|
+
lngLatToCell: (lngLat, resolution) => h3IndexToBigInt(latLngToCell(lngLat[1], lngLat[0], resolution)),
|
|
17
|
+
cellToLngLat: (cell) => reverseLatLngInPlace(cellToLatLng(cell)),
|
|
18
|
+
cellToBoundary: (cell) => cellToBoundary(cell),
|
|
19
|
+
cellsToBoundaryMultiPolygon: (cells) => cellsToMultiPolygon(cells, true)
|
|
20
|
+
};
|
|
21
|
+
// HELPERS
|
|
22
|
+
/** Reverse the latitude and longitude in place to avoid minting new arrays. */
|
|
23
|
+
function reverseLatLngInPlace(latLng) {
|
|
24
|
+
const temp = latLng[0];
|
|
25
|
+
latLng[0] = latLng[1];
|
|
26
|
+
latLng[1] = temp;
|
|
27
|
+
return latLng;
|
|
28
|
+
}
|
|
29
|
+
//# sourceMappingURL=h3-grid.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"h3-grid.js","sourceRoot":"","sources":["../../../src/global-grid-systems/grids/h3-grid.ts"],"names":[],"mappings":"AAAA,UAAU;AACV,+BAA+B;AAC/B,oCAAoC;AAGpC,OAAO,EACL,YAAY,EACZ,cAAc,EACd,YAAY,EACZ,mBAAmB,EACnB,eAAe,EAChB,wCAAqC;AAEtC;;;GAGG;AACH,MAAM,CAAC,MAAM,MAAM,GAAG;IACpB,IAAI,EAAE,IAAI;IACV,wBAAwB,EAAE,IAAI;IAE9B,6DAA6D;IAC7D,UAAU,EAAE,GAAG,EAAE,GAAE,CAAC;IAEpB,WAAW,EAAE,CAAC,KAAa,EAAE,EAAE,CAAC,eAAe,CAAC,KAAK,CAAC;IAEtD,aAAa,EAAE,CAAC,MAAwB,EAAE,UAAkB,EAAE,EAAE,CAC9D,YAAY,CAAC,MAAM,CAAC,CAAC,CAAC,EAAE,MAAM,CAAC,CAAC,CAAC,EAAE,UAAU,CAAC;IAChD,YAAY,EAAE,CAAC,MAAwB,EAAE,UAAkB,EAAE,EAAE,CAC7D,eAAe,CAAC,YAAY,CAAC,MAAM,CAAC,CAAC,CAAC,EAAE,MAAM,CAAC,CAAC,CAAC,EAAE,UAAU,CAAC,CAAC;IAEjE,YAAY,EAAE,CAAC,IAAqB,EAAE,EAAE,CAAC,oBAAoB,CAAC,YAAY,CAAC,IAAI,CAAC,CAAC;IACjF,cAAc,EAAE,CAAC,IAAqB,EAAE,EAAE,CAAC,cAAc,CAAC,IAAI,CAAC;IAC/D,2BAA2B,EAAE,CAAC,KAA0B,EAAE,EAAE,CAAC,mBAAmB,CAAC,KAAK,EAAE,IAAI,CAAC;CAChE,CAAC;AAEhC,UAAU;AAEV,+EAA+E;AAC/E,SAAS,oBAAoB,CAAC,MAAwB;IACpD,MAAM,IAAI,GAAG,MAAM,CAAC,CAAC,CAAC,CAAC;IACvB,MAAM,CAAC,CAAC,CAAC,GAAG,MAAM,CAAC,CAAC,CAAC,CAAC;IACtB,MAAM,CAAC,CAAC,CAAC,GAAG,IAAI,CAAC;IACjB,OAAO,MAAM,CAAC;AAChB,CAAC"}
|
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
import { type Bounds2D } from '@math.gl/types';
|
|
2
|
+
/** Decoder for the quadkey DGGS */
|
|
3
|
+
export declare const QuadkeyGrid: {
|
|
4
|
+
readonly name: "quadkey";
|
|
5
|
+
readonly hasNumericRepresentation: true;
|
|
6
|
+
readonly cellToLngLat: (cell: string | bigint) => [number, number];
|
|
7
|
+
readonly cellToBoundary: (cell: string | bigint) => [number, number][];
|
|
8
|
+
};
|
|
9
|
+
export declare function quadkeyCellToBoundaryFlat(quadkey: string): number[];
|
|
10
|
+
export declare function quadkeyCellToBounds(quadkey: string): Bounds2D;
|
|
11
|
+
export declare function quadkeyToWorldBounds(quadkey: string): [[number, number], [number, number]];
|
|
12
|
+
/**
|
|
13
|
+
* Encodes a QuadKey string into a bigint.
|
|
14
|
+
* @param quadkey - The QuadKey string.
|
|
15
|
+
* @returns The bigint representation of the QuadKey.
|
|
16
|
+
*/
|
|
17
|
+
export declare function quadKeyToBigint(quadkey: string): bigint;
|
|
18
|
+
/**
|
|
19
|
+
* Decodes a bigint-encoded QuadKey back into its string representation.
|
|
20
|
+
* @param encoded - The bigint representation of the QuadKey with embedded zoom level.
|
|
21
|
+
* @returns The decoded QuadKey string.
|
|
22
|
+
*/
|
|
23
|
+
export declare function bigintToQuadKey(encoded: bigint): string;
|
|
24
|
+
/**
|
|
25
|
+
* Checks if the child QuadKey is contained within the parent QuadKey.
|
|
26
|
+
* @param parent - The bigint representation of the parent QuadKey.
|
|
27
|
+
* @param child - The bigint representation of the child QuadKey.
|
|
28
|
+
* @returns True if the child is contained within the parent; otherwise, false.
|
|
29
|
+
*/
|
|
30
|
+
export declare function isContained(parent: bigint, child: bigint): boolean;
|
|
31
|
+
/**
|
|
32
|
+
* Decodes a bigint-encoded QuadKey into tile X, tile Y, and zoom level.
|
|
33
|
+
* @param encoded - The bigint representation of the QuadKey with embedded zoom level.
|
|
34
|
+
* @returns An object containing tileX, tileY, and zoom.
|
|
35
|
+
*/
|
|
36
|
+
export declare function decodeBigintQuadKey(encoded: bigint): {
|
|
37
|
+
tileX: number;
|
|
38
|
+
tileY: number;
|
|
39
|
+
zoom: number;
|
|
40
|
+
};
|
|
41
|
+
//# sourceMappingURL=quadkey-grid.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"quadkey-grid.d.ts","sourceRoot":"","sources":["../../../src/global-grid-systems/grids/quadkey-grid.ts"],"names":[],"mappings":"AAIA,OAAO,EAAC,KAAK,QAAQ,EAAC,MAAM,gBAAgB,CAAC;AAK7C,mCAAmC;AACnC,eAAO,MAAM,WAAW;;;kCAOD,MAAM,GAAG,MAAM,KAAG,CAAC,MAAM,EAAE,MAAM,CAAC;oCAChC,MAAM,GAAG,MAAM,KAAG,CAAC,MAAM,EAAE,MAAM,CAAC,EAAE;CAK9B,CAAC;AA8BhC,wBAAgB,yBAAyB,CAAC,OAAO,EAAE,MAAM,GAAG,MAAM,EAAE,CAKnE;AAED,wBAAgB,mBAAmB,CAAC,OAAO,EAAE,MAAM,GAAG,QAAQ,CAQ7D;AAED,wBAAgB,oBAAoB,CAAC,OAAO,EAAE,MAAM,GAAG,CAAC,CAAC,MAAM,EAAE,MAAM,CAAC,EAAE,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC,CAgB1F;AAyBD;;;;GAIG;AACH,wBAAgB,eAAe,CAAC,OAAO,EAAE,MAAM,GAAG,MAAM,CAYvD;AAED;;;;GAIG;AACH,wBAAgB,eAAe,CAAC,OAAO,EAAE,MAAM,GAAG,MAAM,CAUvD;AAED;;;;;GAKG;AACH,wBAAgB,WAAW,CAAC,MAAM,EAAE,MAAM,EAAE,KAAK,EAAE,MAAM,GAAG,OAAO,CAalE;AAED;;;;GAIG;AACH,wBAAgB,mBAAmB,CAAC,OAAO,EAAE,MAAM,GAAG;IAAC,KAAK,EAAE,MAAM,CAAC;IAAC,KAAK,EAAE,MAAM,CAAC;IAAC,IAAI,EAAE,MAAM,CAAA;CAAC,CAgBjG"}
|