@deck.gl/carto 9.2.0-beta.1 → 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/dist/cartoPropertiesTile-worker.js +1 -1
- package/dist/cartoRasterTile-worker.js +1 -1
- package/dist/cartoSpatialTile-worker.js +1 -1
- package/dist/cartoVectorTile-worker.js +1 -1
- package/dist/dist.dev.js +2694 -725
- package/dist/index.cjs +180 -130
- package/dist/index.cjs.map +4 -4
- package/dist/layers/cluster-tile-layer.d.ts +9 -6
- package/dist/layers/cluster-tile-layer.d.ts.map +1 -1
- package/dist/layers/cluster-tile-layer.js +59 -10
- package/dist/layers/cluster-tile-layer.js.map +1 -1
- package/dist/layers/cluster-utils.d.ts +11 -3
- package/dist/layers/cluster-utils.d.ts.map +1 -1
- package/dist/layers/cluster-utils.js +11 -4
- package/dist/layers/cluster-utils.js.map +1 -1
- package/dist/layers/schema/carto-properties-tile-loader.js +1 -1
- 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 +10 -9
- package/package.json +6 -6
- package/src/layers/cluster-tile-layer.ts +97 -22
- package/src/layers/cluster-utils.ts +24 -9
package/dist/index.cjs
CHANGED
|
@@ -58,13 +58,14 @@ module.exports = __toCommonJS(dist_exports);
|
|
|
58
58
|
|
|
59
59
|
// dist/layers/cluster-tile-layer.js
|
|
60
60
|
var import_layers = require("@deck.gl/layers");
|
|
61
|
-
var
|
|
61
|
+
var import_geo_layers3 = require("@deck.gl/geo-layers");
|
|
62
62
|
var import_core5 = require("@loaders.gl/core");
|
|
63
63
|
var import_gis = require("@loaders.gl/gis");
|
|
64
64
|
var import_core6 = require("@deck.gl/core");
|
|
65
65
|
|
|
66
66
|
// dist/layers/cluster-utils.js
|
|
67
67
|
var import_quadbin = require("quadbin");
|
|
68
|
+
var import_h3_js = require("h3-js");
|
|
68
69
|
var import_core2 = require("@deck.gl/core");
|
|
69
70
|
|
|
70
71
|
// dist/utils.js
|
|
@@ -149,7 +150,7 @@ function copyNumericProps(sourceProps, targetProps, sourceIndex, targetIndex) {
|
|
|
149
150
|
}
|
|
150
151
|
|
|
151
152
|
// dist/layers/cluster-utils.js
|
|
152
|
-
function aggregateTile(tile, tileAggregationCache, aggregationLevels, properties = [], getPosition, getWeight) {
|
|
153
|
+
function aggregateTile(tile, tileAggregationCache, aggregationLevels, properties = [], getPosition, getWeight, scheme = "quadbin") {
|
|
153
154
|
var _a;
|
|
154
155
|
if (!tile.content)
|
|
155
156
|
return false;
|
|
@@ -167,9 +168,14 @@ function aggregateTile(tile, tileAggregationCache, aggregationLevels, properties
|
|
|
167
168
|
let id5 = cell.id;
|
|
168
169
|
const position = typeof getPosition === "function" ? getPosition(cell, {}) : getPosition;
|
|
169
170
|
for (let i = 0; i < aggregationLevels - 1; i++) {
|
|
170
|
-
|
|
171
|
+
if (scheme === "h3") {
|
|
172
|
+
const currentResolution = (0, import_h3_js.getResolution)(id5);
|
|
173
|
+
id5 = (0, import_h3_js.cellToParent)(id5, Math.max(0, currentResolution - 1));
|
|
174
|
+
} else {
|
|
175
|
+
id5 = (0, import_quadbin.cellToParent)(id5);
|
|
176
|
+
}
|
|
171
177
|
}
|
|
172
|
-
const parentId =
|
|
178
|
+
const parentId = String(id5);
|
|
173
179
|
if (!(parentId in out)) {
|
|
174
180
|
out[parentId] = { id: id5, count: 0, position: [0, 0] };
|
|
175
181
|
for (const { name, aggregation } of properties) {
|
|
@@ -271,6 +277,114 @@ var QuadbinTileset2D = class extends import_geo_layers._Tileset2D {
|
|
|
271
277
|
}
|
|
272
278
|
};
|
|
273
279
|
|
|
280
|
+
// dist/layers/h3-tileset-2d.js
|
|
281
|
+
var import_geo_layers2 = require("@deck.gl/geo-layers");
|
|
282
|
+
var import_h3_js2 = require("h3-js");
|
|
283
|
+
var MAX_LATITUDE = 85.051128;
|
|
284
|
+
function padBoundingBox({ west, north, east, south }, resolution, scale = 1) {
|
|
285
|
+
const corners = [
|
|
286
|
+
[north, east],
|
|
287
|
+
[south, east],
|
|
288
|
+
[south, west],
|
|
289
|
+
[north, west]
|
|
290
|
+
];
|
|
291
|
+
const cornerCells = corners.map((c) => (0, import_h3_js2.latLngToCell)(c[0], c[1], resolution));
|
|
292
|
+
const cornerEdgeLengths = cornerCells.map((c) => Math.max(...(0, import_h3_js2.originToDirectedEdges)(c).map((e) => (0, import_h3_js2.edgeLength)(e, import_h3_js2.UNITS.rads))) * 180 / Math.PI);
|
|
293
|
+
const bufferLat = Math.max(...cornerEdgeLengths) * scale;
|
|
294
|
+
const bufferLon = Math.min(180, bufferLat / Math.cos((north + south) / 2 * Math.PI / 180));
|
|
295
|
+
return {
|
|
296
|
+
north: Math.min(north + bufferLat, MAX_LATITUDE),
|
|
297
|
+
east: east + bufferLon,
|
|
298
|
+
south: Math.max(south - bufferLat, -MAX_LATITUDE),
|
|
299
|
+
west: west - bufferLon
|
|
300
|
+
};
|
|
301
|
+
}
|
|
302
|
+
function getHexagonsInBoundingBox({ west, north, east, south }, resolution) {
|
|
303
|
+
const longitudeSpan = Math.abs(east - west);
|
|
304
|
+
if (longitudeSpan > 180) {
|
|
305
|
+
const nSegments = Math.ceil(longitudeSpan / 180);
|
|
306
|
+
let h3Indices = [];
|
|
307
|
+
for (let s = 0; s < nSegments; s++) {
|
|
308
|
+
const segmentWest = west + s * 180;
|
|
309
|
+
const segmentEast = Math.min(segmentWest + 179.9999999, east);
|
|
310
|
+
h3Indices = h3Indices.concat(getHexagonsInBoundingBox({ west: segmentWest, north, east: segmentEast, south }, resolution));
|
|
311
|
+
}
|
|
312
|
+
return [...new Set(h3Indices)];
|
|
313
|
+
}
|
|
314
|
+
const polygon = [
|
|
315
|
+
[north, east],
|
|
316
|
+
[south, east],
|
|
317
|
+
[south, west],
|
|
318
|
+
[north, west],
|
|
319
|
+
[north, east]
|
|
320
|
+
];
|
|
321
|
+
return (0, import_h3_js2.polygonToCells)(polygon, resolution);
|
|
322
|
+
}
|
|
323
|
+
function tileToBoundingBox(index) {
|
|
324
|
+
const coordinates = (0, import_h3_js2.cellToBoundary)(index);
|
|
325
|
+
const latitudes = coordinates.map((c) => c[0]);
|
|
326
|
+
const longitudes = coordinates.map((c) => c[1]);
|
|
327
|
+
const west = Math.min(...longitudes);
|
|
328
|
+
const south = Math.min(...latitudes);
|
|
329
|
+
const east = Math.max(...longitudes);
|
|
330
|
+
const north = Math.max(...latitudes);
|
|
331
|
+
const bbox = { west, south, east, north };
|
|
332
|
+
return padBoundingBox(bbox, (0, import_h3_js2.getResolution)(index), 0.12);
|
|
333
|
+
}
|
|
334
|
+
var BIAS = 2;
|
|
335
|
+
function getHexagonResolution(viewport, tileSize) {
|
|
336
|
+
const zoomOffset = Math.log2(tileSize / 512);
|
|
337
|
+
const hexagonScaleFactor = 2 / 3 * (viewport.zoom - zoomOffset);
|
|
338
|
+
const latitudeScaleFactor = Math.log(1 / Math.cos(Math.PI * viewport.latitude / 180));
|
|
339
|
+
return Math.max(0, Math.floor(hexagonScaleFactor + latitudeScaleFactor - BIAS));
|
|
340
|
+
}
|
|
341
|
+
var H3Tileset2D = class extends import_geo_layers2._Tileset2D {
|
|
342
|
+
/**
|
|
343
|
+
* Returns all tile indices in the current viewport. If the current zoom level is smaller
|
|
344
|
+
* than minZoom, return an empty array. If the current zoom level is greater than maxZoom,
|
|
345
|
+
* return tiles that are on maxZoom.
|
|
346
|
+
*/
|
|
347
|
+
// @ts-expect-error Tileset2D should be generic over TileIndex
|
|
348
|
+
getTileIndices({ viewport, minZoom, maxZoom }) {
|
|
349
|
+
if (viewport.latitude === void 0)
|
|
350
|
+
return [];
|
|
351
|
+
const [west, south, east, north] = viewport.getBounds();
|
|
352
|
+
const { tileSize } = this.opts;
|
|
353
|
+
let z = getHexagonResolution(viewport, tileSize);
|
|
354
|
+
let indices;
|
|
355
|
+
if (typeof minZoom === "number" && Number.isFinite(minZoom) && z < minZoom) {
|
|
356
|
+
return [];
|
|
357
|
+
}
|
|
358
|
+
if (typeof maxZoom === "number" && Number.isFinite(maxZoom) && z > maxZoom) {
|
|
359
|
+
z = maxZoom;
|
|
360
|
+
const center = (0, import_h3_js2.latLngToCell)(viewport.latitude, viewport.longitude, maxZoom);
|
|
361
|
+
indices = (0, import_h3_js2.gridDisk)(center, 1);
|
|
362
|
+
} else {
|
|
363
|
+
const paddedBounds = padBoundingBox({ west, north, east, south }, z);
|
|
364
|
+
indices = getHexagonsInBoundingBox(paddedBounds, z);
|
|
365
|
+
}
|
|
366
|
+
return indices.map((i) => ({ i }));
|
|
367
|
+
}
|
|
368
|
+
// @ts-expect-error Tileset2D should be generic over TileIndex
|
|
369
|
+
getTileId({ i }) {
|
|
370
|
+
return i;
|
|
371
|
+
}
|
|
372
|
+
// @ts-expect-error Tileset2D should be generic over TileIndex
|
|
373
|
+
getTileMetadata({ i }) {
|
|
374
|
+
return { bbox: tileToBoundingBox(i) };
|
|
375
|
+
}
|
|
376
|
+
// @ts-expect-error Tileset2D should be generic over TileIndex
|
|
377
|
+
getTileZoom({ i }) {
|
|
378
|
+
return (0, import_h3_js2.getResolution)(i);
|
|
379
|
+
}
|
|
380
|
+
// @ts-expect-error Tileset2D should be generic over TileIndex
|
|
381
|
+
getParentIndex(index) {
|
|
382
|
+
const resolution = (0, import_h3_js2.getResolution)(index.i);
|
|
383
|
+
const i = (0, import_h3_js2.cellToParent)(index.i, resolution - 1);
|
|
384
|
+
return { i };
|
|
385
|
+
}
|
|
386
|
+
};
|
|
387
|
+
|
|
274
388
|
// dist/layers/quadbin-utils.js
|
|
275
389
|
var import_web_mercator = require("@math.gl/web-mercator");
|
|
276
390
|
var import_quadbin3 = require("quadbin");
|
|
@@ -294,6 +408,9 @@ function getQuadbinPolygon(quadbin, coverage = 1) {
|
|
|
294
408
|
return [e, n, e, s, w, s, w, n, e, n];
|
|
295
409
|
}
|
|
296
410
|
|
|
411
|
+
// dist/layers/cluster-tile-layer.js
|
|
412
|
+
var import_h3_js3 = require("h3-js");
|
|
413
|
+
|
|
297
414
|
// dist/layers/schema/fast-pbf.js
|
|
298
415
|
var import_compression = require("@loaders.gl/compression");
|
|
299
416
|
function readPackedTypedArray(TypedArray, pbf, obj, options) {
|
|
@@ -556,7 +673,7 @@ function binaryToSpatialjson(binary) {
|
|
|
556
673
|
}
|
|
557
674
|
|
|
558
675
|
// dist/layers/schema/carto-spatial-tile-loader.js
|
|
559
|
-
var VERSION = true ? "9.2.0-beta.
|
|
676
|
+
var VERSION = true ? "9.2.0-beta.3" : "latest";
|
|
560
677
|
var id = "cartoSpatialTile";
|
|
561
678
|
var DEFAULT_OPTIONS = {
|
|
562
679
|
cartoSpatialTile: {
|
|
@@ -672,21 +789,44 @@ var TilejsonPropType = {
|
|
|
672
789
|
|
|
673
790
|
// dist/layers/cluster-tile-layer.js
|
|
674
791
|
(0, import_core5.registerLoaders)([carto_spatial_tile_loader_default]);
|
|
792
|
+
function getScheme(tilesetClass) {
|
|
793
|
+
if (tilesetClass === H3Tileset2D)
|
|
794
|
+
return "h3";
|
|
795
|
+
if (tilesetClass === QuadbinTileset2D)
|
|
796
|
+
return "quadbin";
|
|
797
|
+
throw new Error("Invalid tileset class");
|
|
798
|
+
}
|
|
675
799
|
var defaultProps = {
|
|
676
800
|
data: TilejsonPropType,
|
|
677
801
|
clusterLevel: { type: "number", value: 5, min: 1 },
|
|
678
802
|
getPosition: {
|
|
679
803
|
type: "accessor",
|
|
680
|
-
value: ({ id: id5 }) =>
|
|
804
|
+
value: ({ id: id5 }) => {
|
|
805
|
+
if (typeof id5 === "string") {
|
|
806
|
+
const [lat, lng] = (0, import_h3_js3.cellToLatLng)(id5);
|
|
807
|
+
return [lng, lat];
|
|
808
|
+
}
|
|
809
|
+
return getQuadbinPolygon(id5, 0.5).slice(2, 4);
|
|
810
|
+
}
|
|
681
811
|
},
|
|
682
812
|
getWeight: { type: "accessor", value: 1 },
|
|
683
813
|
refinementStrategy: "no-overlap",
|
|
684
814
|
tileSize: DEFAULT_TILE_SIZE
|
|
685
815
|
};
|
|
686
|
-
var ClusterGeoJsonLayer = class extends
|
|
816
|
+
var ClusterGeoJsonLayer = class extends import_geo_layers3.TileLayer {
|
|
687
817
|
initializeState() {
|
|
688
818
|
super.initializeState();
|
|
689
819
|
this.state.aggregationCache = /* @__PURE__ */ new WeakMap();
|
|
820
|
+
this.state.scheme = getScheme(this.props.TilesetClass);
|
|
821
|
+
}
|
|
822
|
+
updateState(opts) {
|
|
823
|
+
const { props } = opts;
|
|
824
|
+
const scheme = getScheme(props.TilesetClass);
|
|
825
|
+
if (this.state.scheme !== scheme) {
|
|
826
|
+
this.setState({ scheme, tileset: null });
|
|
827
|
+
this.state.aggregationCache = /* @__PURE__ */ new WeakMap();
|
|
828
|
+
}
|
|
829
|
+
super.updateState(opts);
|
|
690
830
|
}
|
|
691
831
|
// eslint-disable-next-line max-statements
|
|
692
832
|
renderLayers() {
|
|
@@ -694,25 +834,24 @@ var ClusterGeoJsonLayer = class extends import_geo_layers2.TileLayer {
|
|
|
694
834
|
const visibleTiles = (_a = this.state.tileset) == null ? void 0 : _a.tiles.filter((tile) => {
|
|
695
835
|
return tile.isLoaded && tile.content && this.state.tileset.isTileVisible(tile);
|
|
696
836
|
});
|
|
697
|
-
if (!(visibleTiles == null ? void 0 : visibleTiles.length)) {
|
|
837
|
+
if (!(visibleTiles == null ? void 0 : visibleTiles.length) || !this.state.tileset) {
|
|
698
838
|
return null;
|
|
699
839
|
}
|
|
700
840
|
visibleTiles.sort((a, b) => b.zoom - a.zoom);
|
|
701
|
-
const {
|
|
702
|
-
const {
|
|
703
|
-
const
|
|
841
|
+
const { getPosition, getWeight } = this.props;
|
|
842
|
+
const { aggregationCache, scheme } = this.state;
|
|
843
|
+
const isH3 = scheme === "h3";
|
|
704
844
|
const properties = extractAggregationProperties(visibleTiles[0]);
|
|
705
845
|
const data = [];
|
|
706
846
|
let needsUpdate = false;
|
|
847
|
+
const aggregationLevels = this._getAggregationLevels(visibleTiles);
|
|
707
848
|
for (const tile of visibleTiles) {
|
|
708
|
-
const overZoom = Math.round(zoom - tile.zoom);
|
|
709
|
-
const aggregationLevels = Math.round(clusterLevel) - overZoom;
|
|
710
849
|
let tileAggregationCache = aggregationCache.get(tile.content);
|
|
711
850
|
if (!tileAggregationCache) {
|
|
712
851
|
tileAggregationCache = /* @__PURE__ */ new Map();
|
|
713
852
|
aggregationCache.set(tile.content, tileAggregationCache);
|
|
714
853
|
}
|
|
715
|
-
const didAggregate = aggregateTile(tile, tileAggregationCache, aggregationLevels, properties, getPosition, getWeight);
|
|
854
|
+
const didAggregate = aggregateTile(tile, tileAggregationCache, aggregationLevels, properties, getPosition, getWeight, isH3 ? "h3" : "quadbin");
|
|
716
855
|
needsUpdate || (needsUpdate = didAggregate);
|
|
717
856
|
data.push(...tileAggregationCache.get(aggregationLevels));
|
|
718
857
|
}
|
|
@@ -757,15 +896,32 @@ var ClusterGeoJsonLayer = class extends import_geo_layers2.TileLayer {
|
|
|
757
896
|
filterSubLayer() {
|
|
758
897
|
return true;
|
|
759
898
|
}
|
|
899
|
+
_getAggregationLevels(visibleTiles) {
|
|
900
|
+
const isH3 = this.state.scheme === "h3";
|
|
901
|
+
const firstTile = visibleTiles[0];
|
|
902
|
+
let tileResolution;
|
|
903
|
+
let viewportResolution;
|
|
904
|
+
if (isH3) {
|
|
905
|
+
tileResolution = (0, import_h3_js3.getResolution)(firstTile.id);
|
|
906
|
+
viewportResolution = getHexagonResolution(this.context.viewport, this.state.tileset.opts.tileSize);
|
|
907
|
+
} else {
|
|
908
|
+
tileResolution = firstTile.zoom;
|
|
909
|
+
viewportResolution = this.context.viewport.zoom;
|
|
910
|
+
}
|
|
911
|
+
const resolutionDiff = Math.round(viewportResolution - tileResolution);
|
|
912
|
+
const aggregationLevels = Math.round(this.props.clusterLevel) - resolutionDiff;
|
|
913
|
+
return aggregationLevels;
|
|
914
|
+
}
|
|
760
915
|
};
|
|
761
916
|
ClusterGeoJsonLayer.layerName = "ClusterGeoJsonLayer";
|
|
762
917
|
ClusterGeoJsonLayer.defaultProps = defaultProps;
|
|
763
918
|
var ClusterTileLayer = class extends import_core6.CompositeLayer {
|
|
764
919
|
getLoadOptions() {
|
|
765
920
|
const tileJSON = this.props.data;
|
|
921
|
+
const scheme = tileJSON && "scheme" in tileJSON ? tileJSON.scheme : "quadbin";
|
|
766
922
|
return mergeLoadOptions(super.getLoadOptions(), {
|
|
767
923
|
fetch: { headers: { Authorization: `Bearer ${tileJSON.accessToken}` } },
|
|
768
|
-
cartoSpatialTile: { scheme
|
|
924
|
+
cartoSpatialTile: { scheme }
|
|
769
925
|
});
|
|
770
926
|
}
|
|
771
927
|
renderLayers() {
|
|
@@ -773,13 +929,15 @@ var ClusterTileLayer = class extends import_core6.CompositeLayer {
|
|
|
773
929
|
if (!tileJSON)
|
|
774
930
|
return null;
|
|
775
931
|
const { tiles: data, maxresolution: maxZoom } = tileJSON;
|
|
932
|
+
const isH3 = tileJSON && "scheme" in tileJSON && tileJSON.scheme === "h3";
|
|
933
|
+
const TilesetClass = isH3 ? H3Tileset2D : QuadbinTileset2D;
|
|
776
934
|
return [
|
|
777
935
|
// @ts-ignore
|
|
778
936
|
new ClusterGeoJsonLayer(this.props, {
|
|
779
937
|
id: `cluster-geojson-layer-${this.props.id}`,
|
|
780
938
|
data,
|
|
781
939
|
// TODO: Tileset2D should be generic over TileIndex type
|
|
782
|
-
TilesetClass
|
|
940
|
+
TilesetClass,
|
|
783
941
|
maxZoom,
|
|
784
942
|
loadOptions: this.getLoadOptions()
|
|
785
943
|
})
|
|
@@ -794,114 +952,6 @@ var cluster_tile_layer_default = ClusterTileLayer;
|
|
|
794
952
|
var import_core8 = require("@deck.gl/core");
|
|
795
953
|
var import_geo_layers5 = require("@deck.gl/geo-layers");
|
|
796
954
|
|
|
797
|
-
// dist/layers/h3-tileset-2d.js
|
|
798
|
-
var import_geo_layers3 = require("@deck.gl/geo-layers");
|
|
799
|
-
var import_h3_js = require("h3-js");
|
|
800
|
-
var MAX_LATITUDE = 85.051128;
|
|
801
|
-
function padBoundingBox({ west, north, east, south }, resolution, scale = 1) {
|
|
802
|
-
const corners = [
|
|
803
|
-
[north, east],
|
|
804
|
-
[south, east],
|
|
805
|
-
[south, west],
|
|
806
|
-
[north, west]
|
|
807
|
-
];
|
|
808
|
-
const cornerCells = corners.map((c) => (0, import_h3_js.latLngToCell)(c[0], c[1], resolution));
|
|
809
|
-
const cornerEdgeLengths = cornerCells.map((c) => Math.max(...(0, import_h3_js.originToDirectedEdges)(c).map((e) => (0, import_h3_js.edgeLength)(e, import_h3_js.UNITS.rads))) * 180 / Math.PI);
|
|
810
|
-
const bufferLat = Math.max(...cornerEdgeLengths) * scale;
|
|
811
|
-
const bufferLon = Math.min(180, bufferLat / Math.cos((north + south) / 2 * Math.PI / 180));
|
|
812
|
-
return {
|
|
813
|
-
north: Math.min(north + bufferLat, MAX_LATITUDE),
|
|
814
|
-
east: east + bufferLon,
|
|
815
|
-
south: Math.max(south - bufferLat, -MAX_LATITUDE),
|
|
816
|
-
west: west - bufferLon
|
|
817
|
-
};
|
|
818
|
-
}
|
|
819
|
-
function getHexagonsInBoundingBox({ west, north, east, south }, resolution) {
|
|
820
|
-
const longitudeSpan = Math.abs(east - west);
|
|
821
|
-
if (longitudeSpan > 180) {
|
|
822
|
-
const nSegments = Math.ceil(longitudeSpan / 180);
|
|
823
|
-
let h3Indices = [];
|
|
824
|
-
for (let s = 0; s < nSegments; s++) {
|
|
825
|
-
const segmentWest = west + s * 180;
|
|
826
|
-
const segmentEast = Math.min(segmentWest + 179.9999999, east);
|
|
827
|
-
h3Indices = h3Indices.concat(getHexagonsInBoundingBox({ west: segmentWest, north, east: segmentEast, south }, resolution));
|
|
828
|
-
}
|
|
829
|
-
return [...new Set(h3Indices)];
|
|
830
|
-
}
|
|
831
|
-
const polygon = [
|
|
832
|
-
[north, east],
|
|
833
|
-
[south, east],
|
|
834
|
-
[south, west],
|
|
835
|
-
[north, west],
|
|
836
|
-
[north, east]
|
|
837
|
-
];
|
|
838
|
-
return (0, import_h3_js.polygonToCells)(polygon, resolution);
|
|
839
|
-
}
|
|
840
|
-
function tileToBoundingBox(index) {
|
|
841
|
-
const coordinates = (0, import_h3_js.cellToBoundary)(index);
|
|
842
|
-
const latitudes = coordinates.map((c) => c[0]);
|
|
843
|
-
const longitudes = coordinates.map((c) => c[1]);
|
|
844
|
-
const west = Math.min(...longitudes);
|
|
845
|
-
const south = Math.min(...latitudes);
|
|
846
|
-
const east = Math.max(...longitudes);
|
|
847
|
-
const north = Math.max(...latitudes);
|
|
848
|
-
const bbox = { west, south, east, north };
|
|
849
|
-
return padBoundingBox(bbox, (0, import_h3_js.getResolution)(index), 0.12);
|
|
850
|
-
}
|
|
851
|
-
var BIAS = 2;
|
|
852
|
-
function getHexagonResolution(viewport, tileSize) {
|
|
853
|
-
const zoomOffset = Math.log2(tileSize / 512);
|
|
854
|
-
const hexagonScaleFactor = 2 / 3 * (viewport.zoom - zoomOffset);
|
|
855
|
-
const latitudeScaleFactor = Math.log(1 / Math.cos(Math.PI * viewport.latitude / 180));
|
|
856
|
-
return Math.max(0, Math.floor(hexagonScaleFactor + latitudeScaleFactor - BIAS));
|
|
857
|
-
}
|
|
858
|
-
var H3Tileset2D = class extends import_geo_layers3._Tileset2D {
|
|
859
|
-
/**
|
|
860
|
-
* Returns all tile indices in the current viewport. If the current zoom level is smaller
|
|
861
|
-
* than minZoom, return an empty array. If the current zoom level is greater than maxZoom,
|
|
862
|
-
* return tiles that are on maxZoom.
|
|
863
|
-
*/
|
|
864
|
-
// @ts-expect-error Tileset2D should be generic over TileIndex
|
|
865
|
-
getTileIndices({ viewport, minZoom, maxZoom }) {
|
|
866
|
-
if (viewport.latitude === void 0)
|
|
867
|
-
return [];
|
|
868
|
-
const [west, south, east, north] = viewport.getBounds();
|
|
869
|
-
const { tileSize } = this.opts;
|
|
870
|
-
let z = getHexagonResolution(viewport, tileSize);
|
|
871
|
-
let indices;
|
|
872
|
-
if (typeof minZoom === "number" && Number.isFinite(minZoom) && z < minZoom) {
|
|
873
|
-
return [];
|
|
874
|
-
}
|
|
875
|
-
if (typeof maxZoom === "number" && Number.isFinite(maxZoom) && z > maxZoom) {
|
|
876
|
-
z = maxZoom;
|
|
877
|
-
const center = (0, import_h3_js.latLngToCell)(viewport.latitude, viewport.longitude, maxZoom);
|
|
878
|
-
indices = (0, import_h3_js.gridDisk)(center, 1);
|
|
879
|
-
} else {
|
|
880
|
-
const paddedBounds = padBoundingBox({ west, north, east, south }, z);
|
|
881
|
-
indices = getHexagonsInBoundingBox(paddedBounds, z);
|
|
882
|
-
}
|
|
883
|
-
return indices.map((i) => ({ i }));
|
|
884
|
-
}
|
|
885
|
-
// @ts-expect-error Tileset2D should be generic over TileIndex
|
|
886
|
-
getTileId({ i }) {
|
|
887
|
-
return i;
|
|
888
|
-
}
|
|
889
|
-
// @ts-expect-error Tileset2D should be generic over TileIndex
|
|
890
|
-
getTileMetadata({ i }) {
|
|
891
|
-
return { bbox: tileToBoundingBox(i) };
|
|
892
|
-
}
|
|
893
|
-
// @ts-expect-error Tileset2D should be generic over TileIndex
|
|
894
|
-
getTileZoom({ i }) {
|
|
895
|
-
return (0, import_h3_js.getResolution)(i);
|
|
896
|
-
}
|
|
897
|
-
// @ts-expect-error Tileset2D should be generic over TileIndex
|
|
898
|
-
getParentIndex(index) {
|
|
899
|
-
const resolution = (0, import_h3_js.getResolution)(index.i);
|
|
900
|
-
const i = (0, import_h3_js.cellToParent)(index.i, resolution - 1);
|
|
901
|
-
return { i };
|
|
902
|
-
}
|
|
903
|
-
};
|
|
904
|
-
|
|
905
955
|
// dist/layers/spatial-index-tile-layer.js
|
|
906
956
|
var import_core7 = require("@loaders.gl/core");
|
|
907
957
|
var import_geo_layers4 = require("@deck.gl/geo-layers");
|
|
@@ -1023,7 +1073,7 @@ var h3_tile_layer_default = H3TileLayer;
|
|
|
1023
1073
|
|
|
1024
1074
|
// dist/layers/heatmap-tile-layer.js
|
|
1025
1075
|
var import_quadbin6 = require("quadbin");
|
|
1026
|
-
var
|
|
1076
|
+
var import_h3_js4 = require("h3-js");
|
|
1027
1077
|
var import_core11 = require("@deck.gl/core");
|
|
1028
1078
|
var import_layers2 = require("@deck.gl/layers");
|
|
1029
1079
|
|
|
@@ -1383,8 +1433,8 @@ function unitDensityForQuadbinCell(cell) {
|
|
|
1383
1433
|
return Math.pow(4, cellResolution);
|
|
1384
1434
|
}
|
|
1385
1435
|
function unitDensityForH3Cell(cellId) {
|
|
1386
|
-
const cellResolution = Number((0,
|
|
1387
|
-
return (0,
|
|
1436
|
+
const cellResolution = Number((0, import_h3_js4.getResolution)(cellId));
|
|
1437
|
+
return (0, import_h3_js4.getNumCells)(cellResolution);
|
|
1388
1438
|
}
|
|
1389
1439
|
function colorRangeToFlatArray(colorRange) {
|
|
1390
1440
|
const flatArray = new Uint8Array(colorRange.length * 4);
|
|
@@ -1985,7 +2035,7 @@ var TileReader3 = class {
|
|
|
1985
2035
|
};
|
|
1986
2036
|
|
|
1987
2037
|
// dist/layers/schema/carto-raster-tile-loader.js
|
|
1988
|
-
var VERSION2 = true ? "9.2.0-beta.
|
|
2038
|
+
var VERSION2 = true ? "9.2.0-beta.3" : "latest";
|
|
1989
2039
|
var id2 = "cartoRasterTile";
|
|
1990
2040
|
var DEFAULT_OPTIONS2 = {
|
|
1991
2041
|
cartoRasterTile: {
|
|
@@ -2097,7 +2147,7 @@ var TileReader4 = class {
|
|
|
2097
2147
|
};
|
|
2098
2148
|
|
|
2099
2149
|
// dist/layers/schema/carto-properties-tile-loader.js
|
|
2100
|
-
var VERSION3 = true ? "9.2.0-beta.
|
|
2150
|
+
var VERSION3 = true ? "9.2.0-beta.3" : "latest";
|
|
2101
2151
|
var id3 = "cartoPropertiesTile";
|
|
2102
2152
|
var DEFAULT_OPTIONS3 = {
|
|
2103
2153
|
cartoPropertiesTile: {
|
|
@@ -2126,7 +2176,7 @@ var carto_properties_tile_loader_default = CartoPropertiesTileLoader;
|
|
|
2126
2176
|
|
|
2127
2177
|
// dist/layers/schema/carto-vector-tile-loader.js
|
|
2128
2178
|
var import_earcut = __toESM(require("earcut"), 1);
|
|
2129
|
-
var VERSION4 = true ? "9.2.0-beta.
|
|
2179
|
+
var VERSION4 = true ? "9.2.0-beta.3" : "latest";
|
|
2130
2180
|
var id4 = "cartoVectorTile";
|
|
2131
2181
|
var DEFAULT_OPTIONS4 = {
|
|
2132
2182
|
cartoVectorTile: {
|