@deck.gl/carto 9.0.0 → 9.0.2

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/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.0",
6
+ "version": "9.0.2",
7
7
  "publishConfig": {
8
8
  "access": "public"
9
9
  },
@@ -47,7 +47,7 @@
47
47
  "@loaders.gl/mvt": "^4.1.4",
48
48
  "@loaders.gl/schema": "^4.1.4",
49
49
  "@loaders.gl/tiles": "^4.1.4",
50
- "@luma.gl/constants": "^9.0.6",
50
+ "@luma.gl/constants": "^9.0.7",
51
51
  "@math.gl/web-mercator": "^4.0.0",
52
52
  "@types/d3-array": "^3.0.2",
53
53
  "@types/d3-color": "^1.4.2",
@@ -72,5 +72,5 @@
72
72
  "@loaders.gl/core": "^4.1.0",
73
73
  "@luma.gl/core": "^9.0.0"
74
74
  },
75
- "gitHead": "fcb5ccf0a899e651949b24986488211e278e9321"
75
+ "gitHead": "4f17a7e9b7a68187990b0cfb0239ad9a186df0f6"
76
76
  }
@@ -11,13 +11,11 @@ function encodeParameter(name: string, value: string | boolean | number): string
11
11
 
12
12
  const REQUEST_CACHE = new Map<string, Promise<unknown>>();
13
13
  export async function requestWithParameters<T = any>({
14
- accessToken,
15
14
  baseUrl,
16
15
  parameters,
17
16
  headers: customHeaders,
18
17
  errorContext
19
18
  }: {
20
- accessToken?: string;
21
19
  baseUrl: string;
22
20
  parameters?: Record<string, string>;
23
21
  headers: Record<string, string>;
@@ -47,9 +45,6 @@ export async function requestWithParameters<T = any>({
47
45
  if (!response || !response.ok) {
48
46
  throw new Error(json.error);
49
47
  }
50
- if (accessToken) {
51
- json.accessToken = accessToken;
52
- }
53
48
  return json;
54
49
  })
55
50
  .catch((error: Error) => {
@@ -61,13 +61,13 @@ export default class H3TileLayer<DataT = any, ExtraPropsT extends {} = {}> exten
61
61
  if (this.props.minZoom) {
62
62
  minresolution = Math.max(
63
63
  minresolution,
64
- getHexagonResolution({zoom: this.props.minZoom, latitude: 0})
64
+ getHexagonResolution({zoom: this.props.minZoom, latitude: 0}, this.props.tileSize)
65
65
  );
66
66
  }
67
67
  if (this.props.maxZoom) {
68
68
  maxresolution = Math.min(
69
69
  maxresolution,
70
- getHexagonResolution({zoom: this.props.maxZoom, latitude: 0})
70
+ getHexagonResolution({zoom: this.props.maxZoom, latitude: 0}, this.props.tileSize)
71
71
  );
72
72
  }
73
73
 
@@ -66,8 +66,14 @@ function tileToBoundingBox(index: string): GeoBoundingBox {
66
66
  // similar
67
67
  // Relative scale factor (0 = no biasing, 2 = a few hexagons cover view)
68
68
  const BIAS = 2;
69
- export function getHexagonResolution(viewport): number {
70
- const hexagonScaleFactor = (2 / 3) * viewport.zoom;
69
+ export function getHexagonResolution(
70
+ viewport: {zoom: number; latitude: number},
71
+ tileSize: number
72
+ ): number {
73
+ // Difference in given tile size compared to deck's internal 512px tile size,
74
+ // expressed as an offset to the viewport zoom.
75
+ const zoomOffset = Math.log2(tileSize / 512);
76
+ const hexagonScaleFactor = (2 / 3) * (viewport.zoom - zoomOffset);
71
77
  const latitudeScaleFactor = Math.log(1 / Math.cos((Math.PI * viewport.latitude) / 180));
72
78
 
73
79
  // Clip and bias
@@ -84,8 +90,9 @@ export default class H3Tileset2D extends Tileset2D {
84
90
  getTileIndices({viewport, minZoom, maxZoom}): H3TileIndex[] {
85
91
  if (viewport.latitude === undefined) return [];
86
92
  const [east, south, west, north] = viewport.getBounds();
93
+ const {tileSize} = this.opts;
87
94
 
88
- let z = getHexagonResolution(viewport);
95
+ let z = getHexagonResolution(viewport, tileSize);
89
96
  let indices: string[];
90
97
  if (typeof minZoom === 'number' && Number.isFinite(minZoom) && z < minZoom) {
91
98
  // TODO support `extent` prop
@@ -56,12 +56,15 @@ export async function baseSource<UrlParameters extends Record<string, string>>(
56
56
  errorContext.requestType = 'Map data';
57
57
 
58
58
  if (format === 'tilejson') {
59
- return await requestWithParameters<TilejsonResult>({
60
- accessToken,
59
+ const json = await requestWithParameters<TilejsonResult>({
61
60
  baseUrl: dataUrl,
62
61
  headers,
63
62
  errorContext
64
63
  });
64
+ if (accessToken) {
65
+ json.accessToken = accessToken;
66
+ }
67
+ return json;
65
68
  }
66
69
 
67
70
  return await requestWithParameters<GeojsonResult | JsonResult>({