@deck.gl/carto 9.0.6 → 9.0.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/dist/api/common.d.ts +1 -0
- package/dist/api/common.d.ts.map +1 -1
- package/dist/api/common.js +3 -1
- package/dist/cartoRasterTile-worker.js +15 -48
- package/dist/cartoSpatialTile-worker.js +15 -48
- package/dist/cartoVectorTile-worker.js +15 -48
- package/dist/dist.dev.js +62 -82
- package/dist/index.cjs +44 -25
- package/dist/index.cjs.map +3 -3
- package/dist/layers/h3-tileset-2d.d.ts.map +1 -1
- package/dist/layers/h3-tileset-2d.js +35 -18
- package/dist/layers/schema/carto-raster-tile-loader.js +1 -1
- package/dist/layers/schema/carto-spatial-tile-loader.js +1 -1
- package/dist/layers/schema/carto-vector-tile-loader.js +1 -1
- package/dist.min.js +8 -8
- package/package.json +8 -8
- package/src/api/common.ts +4 -1
- package/src/layers/h3-tileset-2d.ts +46 -23
package/package.json
CHANGED
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
"description": "CARTO official integration with Deck.gl. Build geospatial applications using CARTO and Deck.gl.",
|
|
4
4
|
"license": "MIT",
|
|
5
5
|
"type": "module",
|
|
6
|
-
"version": "9.0.
|
|
6
|
+
"version": "9.0.8",
|
|
7
7
|
"publishConfig": {
|
|
8
8
|
"access": "public"
|
|
9
9
|
},
|
|
@@ -42,11 +42,11 @@
|
|
|
42
42
|
"prepublishOnly": "npm run build-bundle && npm run build-bundle -- --env=dev"
|
|
43
43
|
},
|
|
44
44
|
"dependencies": {
|
|
45
|
-
"@loaders.gl/gis": "^4.
|
|
46
|
-
"@loaders.gl/loader-utils": "^4.
|
|
47
|
-
"@loaders.gl/mvt": "^4.
|
|
48
|
-
"@loaders.gl/schema": "^4.
|
|
49
|
-
"@loaders.gl/tiles": "^4.
|
|
45
|
+
"@loaders.gl/gis": "^4.2.0",
|
|
46
|
+
"@loaders.gl/loader-utils": "^4.2.0",
|
|
47
|
+
"@loaders.gl/mvt": "^4.2.0",
|
|
48
|
+
"@loaders.gl/schema": "^4.2.0",
|
|
49
|
+
"@loaders.gl/tiles": "^4.2.0",
|
|
50
50
|
"@luma.gl/constants": "^9.0.9",
|
|
51
51
|
"@math.gl/web-mercator": "^4.0.0",
|
|
52
52
|
"@types/d3-array": "^3.0.2",
|
|
@@ -69,8 +69,8 @@
|
|
|
69
69
|
"@deck.gl/extensions": "^9.0.0",
|
|
70
70
|
"@deck.gl/geo-layers": "^9.0.0",
|
|
71
71
|
"@deck.gl/layers": "^9.0.0",
|
|
72
|
-
"@loaders.gl/core": "^4.
|
|
72
|
+
"@loaders.gl/core": "^4.2.0",
|
|
73
73
|
"@luma.gl/core": "^9.0.0"
|
|
74
74
|
},
|
|
75
|
-
"gitHead": "
|
|
75
|
+
"gitHead": "bca774eae5c0b2da3901e2bc57268ccc2eec81fe"
|
|
76
76
|
}
|
package/src/api/common.ts
CHANGED
|
@@ -1,10 +1,13 @@
|
|
|
1
|
+
import {VERSION} from '@deck.gl/core';
|
|
2
|
+
|
|
1
3
|
export const DEFAULT_API_BASE_URL = 'https://gcp-us-east1.api.carto.com';
|
|
2
4
|
export const DEFAULT_CLIENT = 'deck-gl-carto';
|
|
3
5
|
export const V3_MINOR_VERSION = '3.4';
|
|
4
6
|
export const MAX_GET_LENGTH = 8192;
|
|
5
7
|
|
|
6
8
|
export const DEFAULT_PARAMETERS = {
|
|
7
|
-
v: V3_MINOR_VERSION
|
|
9
|
+
v: V3_MINOR_VERSION,
|
|
10
|
+
deckglVersion: VERSION
|
|
8
11
|
};
|
|
9
12
|
|
|
10
13
|
export const DEFAULT_HEADERS = {
|
|
@@ -5,11 +5,43 @@ import {
|
|
|
5
5
|
getResolution,
|
|
6
6
|
cellToBoundary,
|
|
7
7
|
cellToParent,
|
|
8
|
-
gridDisk
|
|
8
|
+
gridDisk,
|
|
9
|
+
edgeLength,
|
|
10
|
+
UNITS,
|
|
11
|
+
originToDirectedEdges
|
|
9
12
|
} from 'h3-js';
|
|
10
13
|
|
|
11
14
|
export type H3TileIndex = {i: string};
|
|
12
15
|
|
|
16
|
+
const MAX_LATITUDE = 85.051128;
|
|
17
|
+
|
|
18
|
+
// `polygonToCells()` fills based on hexagon center, this function will
|
|
19
|
+
// pad the bounds such that all cells that overlap the bounds will be included
|
|
20
|
+
function padBoundingBox(
|
|
21
|
+
{west, north, east, south}: GeoBoundingBox,
|
|
22
|
+
resolution: number
|
|
23
|
+
): GeoBoundingBox {
|
|
24
|
+
const corners = [
|
|
25
|
+
[north, east],
|
|
26
|
+
[south, east],
|
|
27
|
+
[south, west],
|
|
28
|
+
[north, west]
|
|
29
|
+
];
|
|
30
|
+
const cornerCells = corners.map(c => latLngToCell(c[0], c[1], resolution));
|
|
31
|
+
const cornerEdgeLengths = cornerCells.map(
|
|
32
|
+
c => (Math.max(...originToDirectedEdges(c).map(e => edgeLength(e, UNITS.rads))) * 180) / Math.PI
|
|
33
|
+
);
|
|
34
|
+
const bufferLat = Math.max(...cornerEdgeLengths);
|
|
35
|
+
const bufferLon = Math.min(180, bufferLat / Math.cos((((north + south) / 2) * Math.PI) / 180));
|
|
36
|
+
|
|
37
|
+
return {
|
|
38
|
+
north: Math.min(north + bufferLat, MAX_LATITUDE),
|
|
39
|
+
east: east + bufferLon,
|
|
40
|
+
south: Math.max(south - bufferLat, -MAX_LATITUDE),
|
|
41
|
+
west: west - bufferLon
|
|
42
|
+
};
|
|
43
|
+
}
|
|
44
|
+
|
|
13
45
|
function getHexagonsInBoundingBox(
|
|
14
46
|
{west, north, east, south}: GeoBoundingBox,
|
|
15
47
|
resolution: number
|
|
@@ -21,8 +53,8 @@ function getHexagonsInBoundingBox(
|
|
|
21
53
|
const nSegments = Math.ceil(longitudeSpan / 180);
|
|
22
54
|
let h3Indices: string[] = [];
|
|
23
55
|
for (let s = 0; s < nSegments; s++) {
|
|
24
|
-
const
|
|
25
|
-
const
|
|
56
|
+
const segmentWest = west + s * 180;
|
|
57
|
+
const segmentEast = Math.min(segmentWest + 179.9999999, east);
|
|
26
58
|
h3Indices = h3Indices.concat(
|
|
27
59
|
getHexagonsInBoundingBox({west: segmentWest, north, east: segmentEast, south}, resolution)
|
|
28
60
|
);
|
|
@@ -30,24 +62,14 @@ function getHexagonsInBoundingBox(
|
|
|
30
62
|
return [...new Set(h3Indices)];
|
|
31
63
|
}
|
|
32
64
|
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
[
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
[east, south],
|
|
42
|
-
[east, north],
|
|
43
|
-
[west, north]
|
|
44
|
-
]
|
|
45
|
-
],
|
|
46
|
-
resolution + oversample,
|
|
47
|
-
true
|
|
48
|
-
);
|
|
49
|
-
|
|
50
|
-
return oversample ? [...new Set(h3Indices.map(i => cellToParent(i, resolution)))] : h3Indices;
|
|
65
|
+
const polygon = [
|
|
66
|
+
[north, east],
|
|
67
|
+
[south, east],
|
|
68
|
+
[south, west],
|
|
69
|
+
[north, west],
|
|
70
|
+
[north, east]
|
|
71
|
+
];
|
|
72
|
+
return polygonToCells(polygon, resolution);
|
|
51
73
|
}
|
|
52
74
|
|
|
53
75
|
function tileToBoundingBox(index: string): GeoBoundingBox {
|
|
@@ -89,7 +111,7 @@ export default class H3Tileset2D extends Tileset2D {
|
|
|
89
111
|
// @ts-expect-error Tileset2D should be generic over TileIndex
|
|
90
112
|
getTileIndices({viewport, minZoom, maxZoom}): H3TileIndex[] {
|
|
91
113
|
if (viewport.latitude === undefined) return [];
|
|
92
|
-
const [
|
|
114
|
+
const [west, south, east, north] = viewport.getBounds();
|
|
93
115
|
const {tileSize} = this.opts;
|
|
94
116
|
|
|
95
117
|
let z = getHexagonResolution(viewport, tileSize);
|
|
@@ -106,7 +128,8 @@ export default class H3Tileset2D extends Tileset2D {
|
|
|
106
128
|
const center = latLngToCell(viewport.latitude, viewport.longitude, maxZoom);
|
|
107
129
|
indices = gridDisk(center, 1);
|
|
108
130
|
} else {
|
|
109
|
-
|
|
131
|
+
const paddedBounds = padBoundingBox({west, north, east, south}, z);
|
|
132
|
+
indices = getHexagonsInBoundingBox(paddedBounds, z);
|
|
110
133
|
}
|
|
111
134
|
|
|
112
135
|
return indices.map(i => ({i}));
|