@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.
@@ -1 +1 @@
1
- {"version":3,"file":"h3-tileset-2d.d.ts","sourceRoot":"","sources":["../../src/layers/h3-tileset-2d.ts"],"names":[],"mappings":"AAAA,OAAO,EAAC,UAAU,IAAI,SAAS,EAAE,cAAc,EAAC,MAAM,qBAAqB,CAAC;AAU5E,MAAM,MAAM,WAAW,GAAG;IAAC,CAAC,EAAE,MAAM,CAAA;CAAC,CAAC;AA0DtC,wBAAgB,oBAAoB,CAClC,QAAQ,EAAE;IAAC,IAAI,EAAE,MAAM,CAAC;IAAC,QAAQ,EAAE,MAAM,CAAA;CAAC,EAC1C,QAAQ,EAAE,MAAM,GACf,MAAM,CASR;AAED,MAAM,CAAC,OAAO,OAAO,WAAY,SAAQ,SAAS;IAChD;;;;OAIG;IAEH,cAAc,CAAC,EAAC,QAAQ,EAAE,OAAO,EAAE,OAAO,EAAC;;;;KAAA,GAAG,WAAW,EAAE;IA0B3D,SAAS,CAAC,EAAC,CAAC,EAAC,EAAE,WAAW,GAAG,MAAM;IAKnC,eAAe,CAAC,EAAC,CAAC,EAAC,EAAE,WAAW;;;IAKhC,WAAW,CAAC,EAAC,CAAC,EAAC,EAAE,WAAW,GAAG,MAAM;IAKrC,cAAc,CAAC,KAAK,EAAE,WAAW,GAAG,WAAW;CAKhD"}
1
+ {"version":3,"file":"h3-tileset-2d.d.ts","sourceRoot":"","sources":["../../src/layers/h3-tileset-2d.ts"],"names":[],"mappings":"AAAA,OAAO,EAAC,UAAU,IAAI,SAAS,EAAE,cAAc,EAAC,MAAM,qBAAqB,CAAC;AAa5E,MAAM,MAAM,WAAW,GAAG;IAAC,CAAC,EAAE,MAAM,CAAA;CAAC,CAAC;AA6EtC,wBAAgB,oBAAoB,CAClC,QAAQ,EAAE;IAAC,IAAI,EAAE,MAAM,CAAC;IAAC,QAAQ,EAAE,MAAM,CAAA;CAAC,EAC1C,QAAQ,EAAE,MAAM,GACf,MAAM,CASR;AAED,MAAM,CAAC,OAAO,OAAO,WAAY,SAAQ,SAAS;IAChD;;;;OAIG;IAEH,cAAc,CAAC,EAAC,QAAQ,EAAE,OAAO,EAAE,OAAO,EAAC;;;;KAAA,GAAG,WAAW,EAAE;IA2B3D,SAAS,CAAC,EAAC,CAAC,EAAC,EAAE,WAAW,GAAG,MAAM;IAKnC,eAAe,CAAC,EAAC,CAAC,EAAC,EAAE,WAAW;;;IAKhC,WAAW,CAAC,EAAC,CAAC,EAAC,EAAE,WAAW,GAAG,MAAM;IAKrC,cAAc,CAAC,KAAK,EAAE,WAAW,GAAG,WAAW;CAKhD"}
@@ -1,5 +1,26 @@
1
1
  import { _Tileset2D as Tileset2D } from '@deck.gl/geo-layers';
2
- import { polygonToCells, latLngToCell, getResolution, cellToBoundary, cellToParent, gridDisk } from 'h3-js';
2
+ import { polygonToCells, latLngToCell, getResolution, cellToBoundary, cellToParent, gridDisk, edgeLength, UNITS, originToDirectedEdges } from 'h3-js';
3
+ const MAX_LATITUDE = 85.051128;
4
+ // `polygonToCells()` fills based on hexagon center, this function will
5
+ // pad the bounds such that all cells that overlap the bounds will be included
6
+ function padBoundingBox({ west, north, east, south }, resolution) {
7
+ const corners = [
8
+ [north, east],
9
+ [south, east],
10
+ [south, west],
11
+ [north, west]
12
+ ];
13
+ const cornerCells = corners.map(c => latLngToCell(c[0], c[1], resolution));
14
+ const cornerEdgeLengths = cornerCells.map(c => (Math.max(...originToDirectedEdges(c).map(e => edgeLength(e, UNITS.rads))) * 180) / Math.PI);
15
+ const bufferLat = Math.max(...cornerEdgeLengths);
16
+ const bufferLon = Math.min(180, bufferLat / Math.cos((((north + south) / 2) * Math.PI) / 180));
17
+ return {
18
+ north: Math.min(north + bufferLat, MAX_LATITUDE),
19
+ east: east + bufferLon,
20
+ south: Math.max(south - bufferLat, -MAX_LATITUDE),
21
+ west: west - bufferLon
22
+ };
23
+ }
3
24
  function getHexagonsInBoundingBox({ west, north, east, south }, resolution) {
4
25
  const longitudeSpan = Math.abs(east - west);
5
26
  if (longitudeSpan > 180) {
@@ -8,25 +29,20 @@ function getHexagonsInBoundingBox({ west, north, east, south }, resolution) {
8
29
  const nSegments = Math.ceil(longitudeSpan / 180);
9
30
  let h3Indices = [];
10
31
  for (let s = 0; s < nSegments; s++) {
11
- const segmentEast = east + s * 180;
12
- const segmentWest = Math.min(segmentEast + 179.9999999, west);
32
+ const segmentWest = west + s * 180;
33
+ const segmentEast = Math.min(segmentWest + 179.9999999, east);
13
34
  h3Indices = h3Indices.concat(getHexagonsInBoundingBox({ west: segmentWest, north, east: segmentEast, south }, resolution));
14
35
  }
15
36
  return [...new Set(h3Indices)];
16
37
  }
17
- // `polygonToCells()` fills based on hexagon center, which means tiles vanish
18
- // prematurely. Get more accurate coverage by oversampling
19
- const oversample = 2;
20
- const h3Indices = polygonToCells([
21
- [
22
- [west, north],
23
- [west, south],
24
- [east, south],
25
- [east, north],
26
- [west, north]
27
- ]
28
- ], resolution + oversample, true);
29
- return oversample ? [...new Set(h3Indices.map(i => cellToParent(i, resolution)))] : h3Indices;
38
+ const polygon = [
39
+ [north, east],
40
+ [south, east],
41
+ [south, west],
42
+ [north, west],
43
+ [north, east]
44
+ ];
45
+ return polygonToCells(polygon, resolution);
30
46
  }
31
47
  function tileToBoundingBox(index) {
32
48
  const coordinates = cellToBoundary(index);
@@ -62,7 +78,7 @@ export default class H3Tileset2D extends Tileset2D {
62
78
  getTileIndices({ viewport, minZoom, maxZoom }) {
63
79
  if (viewport.latitude === undefined)
64
80
  return [];
65
- const [east, south, west, north] = viewport.getBounds();
81
+ const [west, south, east, north] = viewport.getBounds();
66
82
  const { tileSize } = this.opts;
67
83
  let z = getHexagonResolution(viewport, tileSize);
68
84
  let indices;
@@ -78,7 +94,8 @@ export default class H3Tileset2D extends Tileset2D {
78
94
  indices = gridDisk(center, 1);
79
95
  }
80
96
  else {
81
- indices = getHexagonsInBoundingBox({ west, north, east, south }, z);
97
+ const paddedBounds = padBoundingBox({ west, north, east, south }, z);
98
+ indices = getHexagonsInBoundingBox(paddedBounds, z);
82
99
  }
83
100
  return indices.map(i => ({ i }));
84
101
  }
@@ -1,7 +1,7 @@
1
1
  import { TileReader } from "./carto-raster-tile.js";
2
2
  import { parsePbf } from "./tile-loader-utils.js";
3
3
  import { getWorkerUrl } from "../../utils.js";
4
- const VERSION = typeof "9.0.6" !== 'undefined' ? "9.0.6" : 'latest';
4
+ const VERSION = typeof "9.0.8" !== 'undefined' ? "9.0.8" : 'latest';
5
5
  const id = 'cartoRasterTile';
6
6
  const DEFAULT_OPTIONS = {
7
7
  cartoRasterTile: {
@@ -2,7 +2,7 @@ import { TileReader } from "./carto-spatial-tile.js";
2
2
  import { parsePbf } from "./tile-loader-utils.js";
3
3
  import { getWorkerUrl } from "../../utils.js";
4
4
  import { binaryToSpatialjson } from "./spatialjson-utils.js";
5
- const VERSION = typeof "9.0.6" !== 'undefined' ? "9.0.6" : 'latest';
5
+ const VERSION = typeof "9.0.8" !== 'undefined' ? "9.0.8" : 'latest';
6
6
  const id = 'cartoSpatialTile';
7
7
  const DEFAULT_OPTIONS = {
8
8
  cartoSpatialTile: {
@@ -2,7 +2,7 @@ import earcut from 'earcut';
2
2
  import { TileReader } from "./carto-tile.js";
3
3
  import { parsePbf } from "./tile-loader-utils.js";
4
4
  import { getWorkerUrl } from "../../utils.js";
5
- const VERSION = typeof "9.0.6" !== 'undefined' ? "9.0.6" : 'latest';
5
+ const VERSION = typeof "9.0.8" !== 'undefined' ? "9.0.8" : 'latest';
6
6
  const id = 'cartoVectorTile';
7
7
  const DEFAULT_OPTIONS = {
8
8
  cartoVectorTile: {