@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/dist.dev.js CHANGED
@@ -7800,7 +7800,7 @@ var __exports__ = (() => {
7800
7800
  if (moment2.version === void 0 && moment2.default) {
7801
7801
  moment2 = moment2.default;
7802
7802
  }
7803
- var VERSION4 = "0.5.45", zones = {}, links = {}, countries = {}, names = {}, guesses = {}, cachedGuess;
7803
+ var VERSION5 = "0.5.45", zones = {}, links = {}, countries = {}, names = {}, guesses = {}, cachedGuess;
7804
7804
  if (!moment2 || typeof moment2.version !== "string") {
7805
7805
  logError("Moment Timezone requires Moment.js. See https://momentjs.com/timezone/docs/#/use-it/browser/");
7806
7806
  }
@@ -8204,7 +8204,7 @@ var __exports__ = (() => {
8204
8204
  out.tz(name);
8205
8205
  return out;
8206
8206
  }
8207
- tz.version = VERSION4;
8207
+ tz.version = VERSION5;
8208
8208
  tz.dataVersion = "";
8209
8209
  tz._zones = zones;
8210
8210
  tz._links = links;
@@ -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
  }
@@ -10638,11 +10653,11 @@ void main(void) {
10638
10653
 
10639
10654
  // ../../node_modules/@loaders.gl/gis/dist/lib/binary-features/binary-to-geojson.js
10640
10655
  function binaryToGeojson(data, options) {
10641
- const globalFeatureId = options === null || options === void 0 ? void 0 : options.globalFeatureId;
10656
+ const globalFeatureId = options?.globalFeatureId;
10642
10657
  if (globalFeatureId !== void 0) {
10643
10658
  return getSingleFeature(data, globalFeatureId);
10644
10659
  }
10645
- return parseFeatures(data, options === null || options === void 0 ? void 0 : options.type);
10660
+ return parseFeatures(data, options?.type);
10646
10661
  }
10647
10662
  function getSingleFeature(data, globalFeatureId) {
10648
10663
  const dataArray = normalizeInput(data);
@@ -10680,7 +10695,7 @@ void main(void) {
10680
10695
  return polygonToGeoJson(data, startIndex, endIndex);
10681
10696
  default:
10682
10697
  const unexpectedInput = data;
10683
- throw new Error(`Unsupported geometry type: ${unexpectedInput === null || unexpectedInput === void 0 ? void 0 : unexpectedInput.type}`);
10698
+ throw new Error(`Unsupported geometry type: ${unexpectedInput?.type}`);
10684
10699
  }
10685
10700
  }
10686
10701
  function normalizeInput(data, type) {
@@ -10724,33 +10739,20 @@ void main(void) {
10724
10739
  const geometry = binaryToGeometry(data, startIndex, endIndex);
10725
10740
  const properties = parseProperties(data, startIndex, endIndex);
10726
10741
  const fields = parseFields(data, startIndex, endIndex);
10727
- return {
10728
- type: "Feature",
10729
- geometry,
10730
- properties,
10731
- ...fields
10732
- };
10742
+ return { type: "Feature", geometry, properties, ...fields };
10733
10743
  }
10734
- function parseFields(data) {
10735
- let startIndex = arguments.length > 1 && arguments[1] !== void 0 ? arguments[1] : 0;
10736
- let endIndex = arguments.length > 2 ? arguments[2] : void 0;
10744
+ function parseFields(data, startIndex = 0, endIndex) {
10737
10745
  return data.fields && data.fields[data.featureIds.value[startIndex]];
10738
10746
  }
10739
- function parseProperties(data) {
10740
- let startIndex = arguments.length > 1 && arguments[1] !== void 0 ? arguments[1] : 0;
10741
- let endIndex = arguments.length > 2 ? arguments[2] : void 0;
10747
+ function parseProperties(data, startIndex = 0, endIndex) {
10742
10748
  const properties = Object.assign({}, data.properties[data.featureIds.value[startIndex]]);
10743
10749
  for (const key in data.numericProps) {
10744
10750
  properties[key] = data.numericProps[key].value[startIndex];
10745
10751
  }
10746
10752
  return properties;
10747
10753
  }
10748
- function polygonToGeoJson(data) {
10749
- let startIndex = arguments.length > 1 && arguments[1] !== void 0 ? arguments[1] : -Infinity;
10750
- let endIndex = arguments.length > 2 && arguments[2] !== void 0 ? arguments[2] : Infinity;
10751
- const {
10752
- positions
10753
- } = data;
10754
+ function polygonToGeoJson(data, startIndex = -Infinity, endIndex = Infinity) {
10755
+ const { positions } = data;
10754
10756
  const polygonIndices = data.polygonIndices.value.filter((x) => x >= startIndex && x <= endIndex);
10755
10757
  const primitivePolygonIndices = data.primitivePolygonIndices.value.filter((x) => x >= startIndex && x <= endIndex);
10756
10758
  const multi = polygonIndices.length > 2;
@@ -10762,10 +10764,7 @@ void main(void) {
10762
10764
  const ringCoordinates = ringToGeoJson(positions, startRingIndex, endRingIndex);
10763
10765
  coordinates2.push(ringCoordinates);
10764
10766
  }
10765
- return {
10766
- type: "Polygon",
10767
- coordinates: coordinates2
10768
- };
10767
+ return { type: "Polygon", coordinates: coordinates2 };
10769
10768
  }
10770
10769
  const coordinates = [];
10771
10770
  for (let i = 0; i < polygonIndices.length - 1; i++) {
@@ -10774,52 +10773,31 @@ void main(void) {
10774
10773
  const polygonCoordinates = polygonToGeoJson(data, startPolygonIndex, endPolygonIndex).coordinates;
10775
10774
  coordinates.push(polygonCoordinates);
10776
10775
  }
10777
- return {
10778
- type: "MultiPolygon",
10779
- coordinates
10780
- };
10776
+ return { type: "MultiPolygon", coordinates };
10781
10777
  }
10782
- function lineStringToGeoJson(data) {
10783
- let startIndex = arguments.length > 1 && arguments[1] !== void 0 ? arguments[1] : -Infinity;
10784
- let endIndex = arguments.length > 2 && arguments[2] !== void 0 ? arguments[2] : Infinity;
10785
- const {
10786
- positions
10787
- } = data;
10778
+ function lineStringToGeoJson(data, startIndex = -Infinity, endIndex = Infinity) {
10779
+ const { positions } = data;
10788
10780
  const pathIndices = data.pathIndices.value.filter((x) => x >= startIndex && x <= endIndex);
10789
10781
  const multi = pathIndices.length > 2;
10790
10782
  if (!multi) {
10791
10783
  const coordinates2 = ringToGeoJson(positions, pathIndices[0], pathIndices[1]);
10792
- return {
10793
- type: "LineString",
10794
- coordinates: coordinates2
10795
- };
10784
+ return { type: "LineString", coordinates: coordinates2 };
10796
10785
  }
10797
10786
  const coordinates = [];
10798
10787
  for (let i = 0; i < pathIndices.length - 1; i++) {
10799
10788
  const ringCoordinates = ringToGeoJson(positions, pathIndices[i], pathIndices[i + 1]);
10800
10789
  coordinates.push(ringCoordinates);
10801
10790
  }
10802
- return {
10803
- type: "MultiLineString",
10804
- coordinates
10805
- };
10791
+ return { type: "MultiLineString", coordinates };
10806
10792
  }
10807
10793
  function pointToGeoJson(data, startIndex, endIndex) {
10808
- const {
10809
- positions
10810
- } = data;
10794
+ const { positions } = data;
10811
10795
  const coordinates = ringToGeoJson(positions, startIndex, endIndex);
10812
10796
  const multi = coordinates.length > 1;
10813
10797
  if (multi) {
10814
- return {
10815
- type: "MultiPoint",
10816
- coordinates
10817
- };
10798
+ return { type: "MultiPoint", coordinates };
10818
10799
  }
10819
- return {
10820
- type: "Point",
10821
- coordinates: coordinates[0]
10822
- };
10800
+ return { type: "Point", coordinates: coordinates[0] };
10823
10801
  }
10824
10802
  function ringToGeoJson(positions, startIndex, endIndex) {
10825
10803
  startIndex = startIndex || 0;
@@ -12995,12 +12973,14 @@ ${formatErrorKey(key)}: ${errorContext[key]}`;
12995
12973
  }
12996
12974
 
12997
12975
  // src/api/common.ts
12976
+ var import_core11 = __toESM(require_core(), 1);
12998
12977
  var DEFAULT_API_BASE_URL = "https://gcp-us-east1.api.carto.com";
12999
12978
  var DEFAULT_CLIENT = "deck-gl-carto";
13000
12979
  var V3_MINOR_VERSION = "3.4";
13001
12980
  var MAX_GET_LENGTH = 8192;
13002
12981
  var DEFAULT_PARAMETERS = {
13003
- v: V3_MINOR_VERSION
12982
+ v: V3_MINOR_VERSION,
12983
+ deckglVersion: import_core11.VERSION
13004
12984
  };
13005
12985
  var DEFAULT_HEADERS = {
13006
12986
  Accept: "application/json",
@@ -14012,7 +13992,7 @@ ${formatErrorKey(key)}: ${errorContext[key]}`;
14012
13992
  })(GLEnum || (GLEnum = {}));
14013
13993
 
14014
13994
  // src/api/parse-map.ts
14015
- var import_core11 = __toESM(require_core(), 1);
13995
+ var import_core12 = __toESM(require_core(), 1);
14016
13996
 
14017
13997
  // src/api/layer-map.ts
14018
13998
  var import_moment_timezone = __toESM(require_moment_timezone2(), 1);
@@ -14406,7 +14386,7 @@ ${formatErrorKey(key)}: ${errorContext[key]}`;
14406
14386
  ...createLoadOptions(token)
14407
14387
  });
14408
14388
  } catch (e) {
14409
- import_core11.log.error(e.message)();
14389
+ import_core12.log.error(e.message)();
14410
14390
  return void 0;
14411
14391
  }
14412
14392
  })
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.6" : "latest";
267
+ var VERSION = true ? "9.0.8" : "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.6" : "latest";
538
+ var VERSION2 = true ? "9.0.8" : "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.6" : "latest";
1290
+ var VERSION3 = true ? "9.0.8" : "latest";
1274
1291
  var id3 = "cartoVectorTile";
1275
1292
  var DEFAULT_OPTIONS3 = {
1276
1293
  cartoVectorTile: {
@@ -1587,12 +1604,14 @@ function formatErrorKey(key) {
1587
1604
  }
1588
1605
 
1589
1606
  // dist/api/common.js
1607
+ var import_core11 = require("@deck.gl/core");
1590
1608
  var DEFAULT_API_BASE_URL = "https://gcp-us-east1.api.carto.com";
1591
1609
  var DEFAULT_CLIENT = "deck-gl-carto";
1592
1610
  var V3_MINOR_VERSION = "3.4";
1593
1611
  var MAX_GET_LENGTH = 8192;
1594
1612
  var DEFAULT_PARAMETERS = {
1595
- v: V3_MINOR_VERSION
1613
+ v: V3_MINOR_VERSION,
1614
+ deckglVersion: import_core11.VERSION
1596
1615
  };
1597
1616
  var DEFAULT_HEADERS = {
1598
1617
  Accept: "application/json",
@@ -1889,7 +1908,7 @@ var vectorTilesetSource = async function(options) {
1889
1908
 
1890
1909
  // dist/api/parse-map.js
1891
1910
  var import_constants12 = require("@luma.gl/constants");
1892
- var import_core11 = require("@deck.gl/core");
1911
+ var import_core12 = require("@deck.gl/core");
1893
1912
 
1894
1913
  // dist/api/layer-map.js
1895
1914
  var import_d3_array = require("d3-array");
@@ -2280,7 +2299,7 @@ function parseMap(json) {
2280
2299
  ...createLoadOptions(token)
2281
2300
  });
2282
2301
  } catch (e) {
2283
- import_core11.log.error(e.message)();
2302
+ import_core12.log.error(e.message)();
2284
2303
  return void 0;
2285
2304
  }
2286
2305
  })