@deck.gl/carto 9.0.7 → 9.0.9

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.
@@ -1008,7 +1008,7 @@
1008
1008
  }
1009
1009
 
1010
1010
  // src/layers/schema/carto-raster-tile-loader.ts
1011
- var VERSION = true ? "9.0.7" : "latest";
1011
+ var VERSION = true ? "9.0.9" : "latest";
1012
1012
  var id = "cartoRasterTile";
1013
1013
  var DEFAULT_OPTIONS = {
1014
1014
  cartoRasterTile: {
@@ -1397,7 +1397,7 @@
1397
1397
  }
1398
1398
 
1399
1399
  // src/layers/schema/carto-spatial-tile-loader.ts
1400
- var VERSION = true ? "9.0.7" : "latest";
1400
+ var VERSION = true ? "9.0.9" : "latest";
1401
1401
  var id = "cartoSpatialTile";
1402
1402
  var DEFAULT_OPTIONS = {
1403
1403
  cartoSpatialTile: {
@@ -1625,7 +1625,7 @@
1625
1625
  }
1626
1626
 
1627
1627
  // src/layers/schema/carto-vector-tile-loader.ts
1628
- var VERSION = true ? "9.0.7" : "latest";
1628
+ var VERSION = true ? "9.0.9" : "latest";
1629
1629
  var id = "cartoVectorTile";
1630
1630
  var DEFAULT_OPTIONS = {
1631
1631
  cartoVectorTile: {
package/dist/dist.dev.js CHANGED
@@ -9231,35 +9231,49 @@ var __exports__ = (() => {
9231
9231
  // src/layers/h3-tileset-2d.ts
9232
9232
  var import_geo_layers = __toESM(require_geo_layers(), 1);
9233
9233
  var import_h3_js = __toESM(require_h3_js(), 1);
9234
+ var MAX_LATITUDE = 85.051128;
9235
+ function padBoundingBox({ west, north, east, south }, resolution) {
9236
+ const corners = [
9237
+ [north, east],
9238
+ [south, east],
9239
+ [south, west],
9240
+ [north, west]
9241
+ ];
9242
+ const cornerCells = corners.map((c) => (0, import_h3_js.latLngToCell)(c[0], c[1], resolution));
9243
+ const cornerEdgeLengths = cornerCells.map(
9244
+ (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
9245
+ );
9246
+ const bufferLat = Math.max(...cornerEdgeLengths);
9247
+ const bufferLon = Math.min(180, bufferLat / Math.cos((north + south) / 2 * Math.PI / 180));
9248
+ return {
9249
+ north: Math.min(north + bufferLat, MAX_LATITUDE),
9250
+ east: east + bufferLon,
9251
+ south: Math.max(south - bufferLat, -MAX_LATITUDE),
9252
+ west: west - bufferLon
9253
+ };
9254
+ }
9234
9255
  function getHexagonsInBoundingBox({ west, north, east, south }, resolution) {
9235
9256
  const longitudeSpan = Math.abs(east - west);
9236
9257
  if (longitudeSpan > 180) {
9237
9258
  const nSegments = Math.ceil(longitudeSpan / 180);
9238
- let h3Indices2 = [];
9259
+ let h3Indices = [];
9239
9260
  for (let s = 0; s < nSegments; s++) {
9240
- const segmentEast = east + s * 180;
9241
- const segmentWest = Math.min(segmentEast + 179.9999999, west);
9242
- h3Indices2 = h3Indices2.concat(
9261
+ const segmentWest = west + s * 180;
9262
+ const segmentEast = Math.min(segmentWest + 179.9999999, east);
9263
+ h3Indices = h3Indices.concat(
9243
9264
  getHexagonsInBoundingBox({ west: segmentWest, north, east: segmentEast, south }, resolution)
9244
9265
  );
9245
9266
  }
9246
- return [...new Set(h3Indices2)];
9247
- }
9248
- const oversample = 2;
9249
- const h3Indices = (0, import_h3_js.polygonToCells)(
9250
- [
9251
- [
9252
- [west, north],
9253
- [west, south],
9254
- [east, south],
9255
- [east, north],
9256
- [west, north]
9257
- ]
9258
- ],
9259
- resolution + oversample,
9260
- true
9261
- );
9262
- return oversample ? [...new Set(h3Indices.map((i) => (0, import_h3_js.cellToParent)(i, resolution)))] : h3Indices;
9267
+ return [...new Set(h3Indices)];
9268
+ }
9269
+ const polygon = [
9270
+ [north, east],
9271
+ [south, east],
9272
+ [south, west],
9273
+ [north, west],
9274
+ [north, east]
9275
+ ];
9276
+ return (0, import_h3_js.polygonToCells)(polygon, resolution);
9263
9277
  }
9264
9278
  function tileToBoundingBox(index) {
9265
9279
  const coordinates = (0, import_h3_js.cellToBoundary)(index);
@@ -9282,7 +9296,7 @@ var __exports__ = (() => {
9282
9296
  getTileIndices({ viewport, minZoom, maxZoom }) {
9283
9297
  if (viewport.latitude === void 0)
9284
9298
  return [];
9285
- const [east, south, west, north] = viewport.getBounds();
9299
+ const [west, south, east, north] = viewport.getBounds();
9286
9300
  const { tileSize } = this.opts;
9287
9301
  let z = getHexagonResolution(viewport, tileSize);
9288
9302
  let indices;
@@ -9294,7 +9308,8 @@ var __exports__ = (() => {
9294
9308
  const center = (0, import_h3_js.latLngToCell)(viewport.latitude, viewport.longitude, maxZoom);
9295
9309
  indices = (0, import_h3_js.gridDisk)(center, 1);
9296
9310
  } else {
9297
- indices = getHexagonsInBoundingBox({ west, north, east, south }, z);
9311
+ const paddedBounds = padBoundingBox({ west, north, east, south }, z);
9312
+ indices = getHexagonsInBoundingBox(paddedBounds, z);
9298
9313
  }
9299
9314
  return indices.map((i) => ({ i }));
9300
9315
  }
package/dist/index.cjs CHANGED
@@ -63,29 +63,45 @@ var import_geo_layers3 = require("@deck.gl/geo-layers");
63
63
  // dist/layers/h3-tileset-2d.js
64
64
  var import_geo_layers = require("@deck.gl/geo-layers");
65
65
  var import_h3_js = require("h3-js");
66
+ var MAX_LATITUDE = 85.051128;
67
+ function padBoundingBox({ west, north, east, south }, resolution) {
68
+ const corners = [
69
+ [north, east],
70
+ [south, east],
71
+ [south, west],
72
+ [north, west]
73
+ ];
74
+ const cornerCells = corners.map((c) => (0, import_h3_js.latLngToCell)(c[0], c[1], resolution));
75
+ 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);
76
+ const bufferLat = Math.max(...cornerEdgeLengths);
77
+ const bufferLon = Math.min(180, bufferLat / Math.cos((north + south) / 2 * Math.PI / 180));
78
+ return {
79
+ north: Math.min(north + bufferLat, MAX_LATITUDE),
80
+ east: east + bufferLon,
81
+ south: Math.max(south - bufferLat, -MAX_LATITUDE),
82
+ west: west - bufferLon
83
+ };
84
+ }
66
85
  function getHexagonsInBoundingBox({ west, north, east, south }, resolution) {
67
86
  const longitudeSpan = Math.abs(east - west);
68
87
  if (longitudeSpan > 180) {
69
88
  const nSegments = Math.ceil(longitudeSpan / 180);
70
- let h3Indices2 = [];
89
+ let h3Indices = [];
71
90
  for (let s = 0; s < nSegments; s++) {
72
- const segmentEast = east + s * 180;
73
- const segmentWest = Math.min(segmentEast + 179.9999999, west);
74
- h3Indices2 = h3Indices2.concat(getHexagonsInBoundingBox({ west: segmentWest, north, east: segmentEast, south }, resolution));
91
+ const segmentWest = west + s * 180;
92
+ const segmentEast = Math.min(segmentWest + 179.9999999, east);
93
+ h3Indices = h3Indices.concat(getHexagonsInBoundingBox({ west: segmentWest, north, east: segmentEast, south }, resolution));
75
94
  }
76
- return [...new Set(h3Indices2)];
77
- }
78
- const oversample = 2;
79
- const h3Indices = (0, import_h3_js.polygonToCells)([
80
- [
81
- [west, north],
82
- [west, south],
83
- [east, south],
84
- [east, north],
85
- [west, north]
86
- ]
87
- ], resolution + oversample, true);
88
- return oversample ? [...new Set(h3Indices.map((i) => (0, import_h3_js.cellToParent)(i, resolution)))] : h3Indices;
95
+ return [...new Set(h3Indices)];
96
+ }
97
+ const polygon = [
98
+ [north, east],
99
+ [south, east],
100
+ [south, west],
101
+ [north, west],
102
+ [north, east]
103
+ ];
104
+ return (0, import_h3_js.polygonToCells)(polygon, resolution);
89
105
  }
90
106
  function tileToBoundingBox(index) {
91
107
  const coordinates = (0, import_h3_js.cellToBoundary)(index);
@@ -108,7 +124,7 @@ var H3Tileset2D = class extends import_geo_layers._Tileset2D {
108
124
  getTileIndices({ viewport, minZoom, maxZoom }) {
109
125
  if (viewport.latitude === void 0)
110
126
  return [];
111
- const [east, south, west, north] = viewport.getBounds();
127
+ const [west, south, east, north] = viewport.getBounds();
112
128
  const { tileSize } = this.opts;
113
129
  let z = getHexagonResolution(viewport, tileSize);
114
130
  let indices;
@@ -120,7 +136,8 @@ var H3Tileset2D = class extends import_geo_layers._Tileset2D {
120
136
  const center = (0, import_h3_js.latLngToCell)(viewport.latitude, viewport.longitude, maxZoom);
121
137
  indices = (0, import_h3_js.gridDisk)(center, 1);
122
138
  } else {
123
- indices = getHexagonsInBoundingBox({ west, north, east, south }, z);
139
+ const paddedBounds = padBoundingBox({ west, north, east, south }, z);
140
+ indices = getHexagonsInBoundingBox(paddedBounds, z);
124
141
  }
125
142
  return indices.map((i) => ({ i }));
126
143
  }
@@ -247,7 +264,7 @@ function scaleIdentity() {
247
264
  }
248
265
 
249
266
  // dist/layers/schema/carto-raster-tile-loader.js
250
- var VERSION = true ? "9.0.7" : "latest";
267
+ var VERSION = true ? "9.0.9" : "latest";
251
268
  var id = "cartoRasterTile";
252
269
  var DEFAULT_OPTIONS = {
253
270
  cartoRasterTile: {
@@ -518,7 +535,7 @@ function binaryToSpatialjson(binary) {
518
535
  }
519
536
 
520
537
  // dist/layers/schema/carto-spatial-tile-loader.js
521
- var VERSION2 = true ? "9.0.7" : "latest";
538
+ var VERSION2 = true ? "9.0.9" : "latest";
522
539
  var id2 = "cartoSpatialTile";
523
540
  var DEFAULT_OPTIONS2 = {
524
541
  cartoSpatialTile: {
@@ -1270,7 +1287,7 @@ var carto_properties_tile_loader_default = CartoPropertiesTileLoader;
1270
1287
 
1271
1288
  // dist/layers/schema/carto-vector-tile-loader.js
1272
1289
  var import_earcut = __toESM(require("earcut"), 1);
1273
- var VERSION3 = true ? "9.0.7" : "latest";
1290
+ var VERSION3 = true ? "9.0.9" : "latest";
1274
1291
  var id3 = "cartoVectorTile";
1275
1292
  var DEFAULT_OPTIONS3 = {
1276
1293
  cartoVectorTile: {