@deck.gl/carto 9.1.11 → 9.1.13

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.1.11",
6
+ "version": "9.1.13",
7
7
  "publishConfig": {
8
8
  "access": "public"
9
9
  },
@@ -75,5 +75,5 @@
75
75
  "@loaders.gl/core": "^4.2.0",
76
76
  "@luma.gl/core": "^9.1.5"
77
77
  },
78
- "gitHead": "13816c3da4f7deab1538dbc590d5267349a512e2"
78
+ "gitHead": "2befca58db3a98e84739804f74806f3cbe94ce38"
79
79
  }
@@ -30,6 +30,7 @@ import {ParseMapResult, parseMap} from './parse-map';
30
30
  import {assert} from '../utils';
31
31
  import type {Basemap} from './types';
32
32
  import {fetchBasemapProps} from './basemap';
33
+ import {DEFAULT_AGGREGATION_EXP} from '../constants';
33
34
 
34
35
  type Dataset = {
35
36
  id: string;
@@ -88,14 +89,24 @@ async function _fetchMapDataset(dataset: Dataset, context: _FetchMapContext) {
88
89
  });
89
90
  }
90
91
  } else if (spatialDataType === 'h3') {
91
- const options = {...globalOptions, aggregationExp, aggregationResLevel, spatialDataColumn};
92
+ const options = {
93
+ ...globalOptions,
94
+ aggregationExp: aggregationExp || DEFAULT_AGGREGATION_EXP,
95
+ aggregationResLevel,
96
+ spatialDataColumn
97
+ };
92
98
  if (type === 'table') {
93
99
  dataset.data = await h3TableSource({...options, tableName: source});
94
100
  } else if (type === 'query') {
95
101
  dataset.data = await h3QuerySource({...options, sqlQuery: source, queryParameters});
96
102
  }
97
103
  } else if (spatialDataType === 'quadbin') {
98
- const options = {...globalOptions, aggregationExp, aggregationResLevel, spatialDataColumn};
104
+ const options = {
105
+ ...globalOptions,
106
+ aggregationExp: aggregationExp || DEFAULT_AGGREGATION_EXP,
107
+ aggregationResLevel,
108
+ spatialDataColumn
109
+ };
99
110
  if (type === 'table') {
100
111
  dataset.data = await quadbinTableSource({...options, tableName: source});
101
112
  } else if (type === 'query') {
package/src/constants.ts CHANGED
@@ -3,3 +3,6 @@
3
3
  // Copyright (c) vis.gl contributors
4
4
 
5
5
  export const DEFAULT_TILE_SIZE = 512;
6
+
7
+ export const DEFAULT_AGGREGATION_EXP_ALIAS = '__aggregationValue';
8
+ export const DEFAULT_AGGREGATION_EXP = `1 AS ${DEFAULT_AGGREGATION_EXP_ALIAS}`;
@@ -19,11 +19,19 @@ export type H3TileIndex = {i: string};
19
19
 
20
20
  const MAX_LATITUDE = 85.051128;
21
21
 
22
- // `polygonToCells()` fills based on hexagon center, this function will
23
- // pad the bounds such that all cells that overlap the bounds will be included
22
+ /**
23
+ * `polygonToCells()` fills based on hexagon center, this function will
24
+ * pad the bounds such that all cells that overlap the bounds will be included.
25
+ *
26
+ * @param bbox - The bounding box to pad.
27
+ * @param resolution - The resolution of the hexagons.
28
+ * @param scale - The scale of the buffer. 1 is to pad by the max edge length of the tile cell.
29
+ * @returns The padded bounding box.
30
+ */
24
31
  function padBoundingBox(
25
32
  {west, north, east, south}: GeoBoundingBox,
26
- resolution: number
33
+ resolution: number,
34
+ scale: number = 1.0
27
35
  ): GeoBoundingBox {
28
36
  const corners = [
29
37
  [north, east],
@@ -35,7 +43,7 @@ function padBoundingBox(
35
43
  const cornerEdgeLengths = cornerCells.map(
36
44
  c => (Math.max(...originToDirectedEdges(c).map(e => edgeLength(e, UNITS.rads))) * 180) / Math.PI
37
45
  );
38
- const bufferLat = Math.max(...cornerEdgeLengths);
46
+ const bufferLat = Math.max(...cornerEdgeLengths) * scale;
39
47
  const bufferLon = Math.min(180, bufferLat / Math.cos((((north + south) / 2) * Math.PI) / 180));
40
48
 
41
49
  return {
@@ -84,7 +92,12 @@ function tileToBoundingBox(index: string): GeoBoundingBox {
84
92
  const south = Math.min(...latitudes);
85
93
  const east = Math.max(...longitudes);
86
94
  const north = Math.max(...latitudes);
87
- return {west, south, east, north};
95
+ const bbox = {west, south, east, north};
96
+
97
+ // H3 child cells extend beyond their parent's boundary forming a "snowflake"
98
+ // fractal pattern. The required buffer is approximately 10% of the
99
+ // edge length of the tile cell, add a bit more to be safe.
100
+ return padBoundingBox(bbox, getResolution(index), 0.12);
88
101
  }
89
102
 
90
103
  // Resolution conversion function. Takes a WebMercatorViewport and returns