@deck.gl/carto 8.8.0-alpha.5 → 8.8.0-alpha.6

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.
Files changed (84) hide show
  1. package/dist/dist.dev.js +88 -48
  2. package/dist/es5/api/layer-map.js +7 -5
  3. package/dist/es5/api/layer-map.js.map +1 -1
  4. package/dist/es5/layers/carto-layer.js.map +1 -1
  5. package/dist/es5/layers/carto-tile-layer.js.map +1 -1
  6. package/dist/es5/layers/h3-tile-layer.js +20 -10
  7. package/dist/es5/layers/h3-tile-layer.js.map +1 -1
  8. package/dist/es5/layers/h3-tileset-2d.js +1 -1
  9. package/dist/es5/layers/h3-tileset-2d.js.map +1 -1
  10. package/dist/es5/layers/quadkey-tile-layer.js +23 -12
  11. package/dist/es5/layers/quadkey-tile-layer.js.map +1 -1
  12. package/dist/es5/layers/quadkey-tileset-2d.js.map +1 -1
  13. package/dist/es5/layers/spatial-index-tile-layer.js.map +1 -1
  14. package/dist/esm/api/layer-map.js +8 -6
  15. package/dist/esm/api/layer-map.js.map +1 -1
  16. package/dist/esm/layers/carto-layer.js.map +1 -1
  17. package/dist/esm/layers/carto-tile-layer.js.map +1 -1
  18. package/dist/esm/layers/h3-tile-layer.js +12 -6
  19. package/dist/esm/layers/h3-tile-layer.js.map +1 -1
  20. package/dist/esm/layers/h3-tileset-2d.js +1 -1
  21. package/dist/esm/layers/h3-tileset-2d.js.map +1 -1
  22. package/dist/esm/layers/quadkey-tile-layer.js +15 -8
  23. package/dist/esm/layers/quadkey-tile-layer.js.map +1 -1
  24. package/dist/esm/layers/quadkey-tileset-2d.js.map +1 -1
  25. package/dist/esm/layers/spatial-index-tile-layer.js.map +1 -1
  26. package/dist.min.js +3 -3
  27. package/package.json +4 -3
  28. package/src/api/layer-map.ts +16 -7
  29. package/src/layers/carto-layer.ts +11 -4
  30. package/src/layers/carto-tile-layer.ts +2 -2
  31. package/src/layers/h3-tile-layer.ts +78 -0
  32. package/src/layers/{h3-tileset-2d.js → h3-tileset-2d.ts} +20 -10
  33. package/src/layers/quadkey-tile-layer.ts +68 -0
  34. package/src/layers/{quadkey-tileset-2d.js → quadkey-tileset-2d.ts} +10 -5
  35. package/src/layers/{spatial-index-tile-layer.js → spatial-index-tile-layer.ts} +7 -6
  36. package/typed/api/index.d.ts +4 -0
  37. package/typed/api/index.d.ts.map +1 -0
  38. package/typed/api/layer-map.d.ts +54 -0
  39. package/typed/api/layer-map.d.ts.map +1 -0
  40. package/typed/api/maps-api-common.d.ts +65 -0
  41. package/typed/api/maps-api-common.d.ts.map +1 -0
  42. package/typed/api/maps-client.d.ts +18 -0
  43. package/typed/api/maps-client.d.ts.map +1 -0
  44. package/typed/api/maps-v3-client.d.ts +45 -0
  45. package/typed/api/maps-v3-client.d.ts.map +1 -0
  46. package/typed/api/parseMap.d.ts +11 -0
  47. package/typed/api/parseMap.d.ts.map +1 -0
  48. package/typed/basemap.d.ts +10 -0
  49. package/typed/basemap.d.ts.map +1 -0
  50. package/typed/config.d.ts +26 -0
  51. package/typed/config.d.ts.map +1 -0
  52. package/typed/index.d.ts +12 -0
  53. package/typed/index.d.ts.map +1 -0
  54. package/typed/layers/carto-layer.d.ts +98 -0
  55. package/typed/layers/carto-layer.d.ts.map +1 -0
  56. package/typed/layers/carto-tile-layer.d.ts +63 -0
  57. package/typed/layers/carto-tile-layer.d.ts.map +1 -0
  58. package/typed/layers/h3-tile-layer.d.ts +23 -0
  59. package/typed/layers/h3-tile-layer.d.ts.map +1 -0
  60. package/typed/layers/h3-tileset-2d.d.ts +18 -0
  61. package/typed/layers/h3-tileset-2d.d.ts.map +1 -0
  62. package/typed/layers/quadkey-tile-layer.d.ts +23 -0
  63. package/typed/layers/quadkey-tile-layer.d.ts.map +1 -0
  64. package/typed/layers/quadkey-tileset-2d.d.ts +15 -0
  65. package/typed/layers/quadkey-tileset-2d.d.ts.map +1 -0
  66. package/typed/layers/schema/carto-tile.d.ts +44 -0
  67. package/typed/layers/schema/carto-tile.d.ts.map +1 -0
  68. package/typed/layers/spatial-index-tile-layer.d.ts +11 -0
  69. package/typed/layers/spatial-index-tile-layer.d.ts.map +1 -0
  70. package/typed/package.json +6 -0
  71. package/typed/style/color-bins-style.d.ts +9 -0
  72. package/typed/style/color-bins-style.d.ts.map +1 -0
  73. package/typed/style/color-categories-style.d.ts +10 -0
  74. package/typed/style/color-categories-style.d.ts.map +1 -0
  75. package/typed/style/color-continuous-style.d.ts +9 -0
  76. package/typed/style/color-continuous-style.d.ts.map +1 -0
  77. package/typed/style/palette.d.ts +7 -0
  78. package/typed/style/palette.d.ts.map +1 -0
  79. package/typed/style/utils.d.ts +8 -0
  80. package/typed/style/utils.d.ts.map +1 -0
  81. package/typed/utils.d.ts +2 -0
  82. package/typed/utils.d.ts.map +1 -0
  83. package/src/layers/h3-tile-layer.js +0 -52
  84. package/src/layers/quadkey-tile-layer.js +0 -47
package/package.json CHANGED
@@ -2,7 +2,7 @@
2
2
  "name": "@deck.gl/carto",
3
3
  "description": "CARTO official integration with Deck.gl. Build geospatial applications using CARTO and Deck.gl.",
4
4
  "license": "MIT",
5
- "version": "8.8.0-alpha.5",
5
+ "version": "8.8.0-alpha.6",
6
6
  "publishConfig": {
7
7
  "access": "public"
8
8
  },
@@ -37,12 +37,13 @@
37
37
  "@loaders.gl/mvt": "^3.2.0-alpha.4",
38
38
  "@loaders.gl/tiles": "^3.2.0-alpha.4",
39
39
  "@luma.gl/constants": "^8.5.13",
40
- "@math.gl/web-mercator": "3.6.0-alpha.5",
40
+ "@math.gl/web-mercator": "3.6.0-alpha.8",
41
41
  "cartocolor": "^4.0.2",
42
42
  "d3-array": "^2.8.0",
43
43
  "d3-color": "^2.0.0",
44
44
  "d3-format": "^2.0.0",
45
45
  "d3-scale": "^3.2.3",
46
+ "h3-js": "^3.6.0",
46
47
  "moment-timezone": "^0.5.33",
47
48
  "pbf": "^3.2.1"
48
49
  },
@@ -60,5 +61,5 @@
60
61
  "@deck.gl/layers": "^8.0.0",
61
62
  "@loaders.gl/core": "^3.0.0"
62
63
  },
63
- "gitHead": "a5e210f62321ab78b7cacbcd0614e0ffcdf6bca7"
64
+ "gitHead": "6885ccab01c91a7632385f566c9377f8ae387e7c"
64
65
  }
@@ -13,6 +13,7 @@ import {
13
13
  import {format as d3Format} from 'd3-format';
14
14
  import moment from 'moment-timezone';
15
15
 
16
+ import {Layer, _ConstructorOf as ConstructorOf} from '@deck.gl/core';
16
17
  import {CPUGridLayer, HeatmapLayer, HexagonLayer} from '@deck.gl/aggregation-layers';
17
18
  import {GeoJsonLayer} from '@deck.gl/layers';
18
19
  import {H3HexagonLayer, MVTLayer} from '@deck.gl/geo-layers';
@@ -101,7 +102,7 @@ const defaultProps = {
101
102
  wrapLongitude: false
102
103
  };
103
104
 
104
- function mergePropMaps(a = {}, b = {}) {
105
+ function mergePropMaps(a: Record<string, any> = {}, b: Record<string, any> = {}) {
105
106
  return {...a, ...b, visConfig: {...a.visConfig, ...b.visConfig}};
106
107
  }
107
108
 
@@ -109,7 +110,7 @@ export function getLayer(
109
110
  type: string,
110
111
  config,
111
112
  dataset
112
- ): {Layer: any; propMap: any; defaultProps: any} {
113
+ ): {Layer: ConstructorOf<Layer>; propMap: any; defaultProps: any} {
113
114
  if (type === 'mvt' || type === 'tileset') {
114
115
  return getTileLayer(dataset);
115
116
  }
@@ -118,7 +119,11 @@ export function getLayer(
118
119
  const getPosition = d => d[geoColumn].coordinates;
119
120
 
120
121
  const hexagonId = config.columns?.hex_id;
121
- const layer = {
122
+
123
+ const layerTypeDefs: Record<
124
+ string,
125
+ {Layer: ConstructorOf<Layer>; propMap?: any; defaultProps?: any}
126
+ > = {
122
127
  point: {
123
128
  Layer: GeoJsonLayer,
124
129
  propMap: {visConfig: {outline: 'stroked'}}
@@ -146,12 +151,16 @@ export function getLayer(
146
151
  propMap: {visConfig: {coverage: 'coverage'}},
147
152
  defaultProps: {getHexagon: d => d[hexagonId], stroked: false}
148
153
  }
149
- }[type];
154
+ };
155
+
156
+ const layer = layerTypeDefs[type];
150
157
 
151
158
  assert(layer, `Unsupported layer type: ${type}`);
152
- layer.propMap = mergePropMaps(sharedPropMap, layer.propMap);
153
- layer.defaultProps = {...defaultProps, ...layer.defaultProps};
154
- return layer;
159
+ return {
160
+ ...layer,
161
+ propMap: mergePropMaps(sharedPropMap, layer.propMap),
162
+ defaultProps: {...defaultProps, ...layer.defaultProps}
163
+ };
155
164
  }
156
165
 
157
166
  function getTileLayer(dataset) {
@@ -66,7 +66,11 @@ const defaultProps = {
66
66
  aggregationResLevel: null
67
67
  };
68
68
 
69
- export interface CartoLayerProps<DataT = any> extends CompositeLayerProps<DataT> {
69
+ /** All properties supported by CartoLayer. */
70
+ export type CartoLayerProps<DataT = any> = _CartoLayerProps & CompositeLayerProps<DataT>;
71
+
72
+ /** Properties added by CartoLayer. */
73
+ type _CartoLayerProps = {
70
74
  /**
71
75
  * Either a SQL query or a name of dataset/tileset.
72
76
  */
@@ -147,9 +151,11 @@ export interface CartoLayerProps<DataT = any> extends CompositeLayerProps<DataT>
147
151
  onDataError?: (err: unknown) => void;
148
152
 
149
153
  clientId?: string;
150
- }
154
+ };
151
155
 
152
- export default class CartoLayer<DataT = any> extends CompositeLayer<CartoLayerProps<DataT>> {
156
+ export default class CartoLayer<ExtraProps = {}> extends CompositeLayer<
157
+ Required<_CartoLayerProps> & ExtraProps
158
+ > {
153
159
  static layerName = 'CartoLayer';
154
160
  static defaultProps = defaultProps as any;
155
161
 
@@ -237,7 +243,7 @@ export default class CartoLayer<DataT = any> extends CompositeLayer<CartoLayerPr
237
243
  const localConfig = {...getDefaultCredentials(), ...credentials};
238
244
  const {apiVersion} = localConfig;
239
245
 
240
- let result: FetchLayerDataResult;
246
+ let result: Partial<FetchLayerDataResult>;
241
247
  if (apiVersion === API_VERSIONS.V1 || apiVersion === API_VERSIONS.V2) {
242
248
  result = {
243
249
  data: await getDataV2({type, source, credentials: credentials as ClassicCredentials})
@@ -276,6 +282,7 @@ export default class CartoLayer<DataT = any> extends CompositeLayer<CartoLayerPr
276
282
  const {uniqueIdProperty} = defaultProps;
277
283
  // eslint-disable-next-line @typescript-eslint/no-unused-vars
278
284
  const {data: _notUsed, ...propsNoData} = this.props;
285
+ // @ts-expect-error 'uniqueIdProperty' is specified more than once, so this usage will be overwritten.
279
286
  const props = {uniqueIdProperty, ...propsNoData};
280
287
 
281
288
  if (apiVersion === API_VERSIONS.V1 || apiVersion === API_VERSIONS.V2) {
@@ -1,6 +1,6 @@
1
1
  /* global TextDecoder */
2
2
  import Protobuf from 'pbf';
3
- import {Layer, LayersList, log} from '@deck.gl/core';
3
+ import {log} from '@deck.gl/core';
4
4
  import {ClipExtension} from '@deck.gl/extensions';
5
5
  import {
6
6
  MVTLayer,
@@ -96,7 +96,7 @@ type _CartoTileLayerProps = {
96
96
  * Possible values are: `TILE_FORMATS.BINARY`, `TILE_FORMATS.GEOJSON` and `TILE_FORMATS.MVT`.
97
97
  *
98
98
  * Only supported when `apiVersion` is `API_VERSIONS.V3` and `format` is `FORMATS.TILEJSON`.
99
- * */
99
+ */
100
100
  formatTiles?: TileFormat;
101
101
  };
102
102
 
@@ -0,0 +1,78 @@
1
+ import {
2
+ CompositeLayer,
3
+ CompositeLayerProps,
4
+ Layer,
5
+ LayersList,
6
+ UpdateParameters
7
+ } from '@deck.gl/core';
8
+ import {H3HexagonLayer} from '@deck.gl/geo-layers';
9
+ import H3Tileset2D from './h3-tileset-2d';
10
+ import SpatialIndexTileLayer from './spatial-index-tile-layer';
11
+
12
+ const renderSubLayers = props => {
13
+ const {data} = props;
14
+ const {index} = props.tile;
15
+ if (!data || !data.length) return null;
16
+
17
+ return new H3HexagonLayer(props, {
18
+ getHexagon: d => d.id,
19
+ centerHexagon: index,
20
+ highPrecision: true
21
+ });
22
+ };
23
+
24
+ const defaultProps = {
25
+ aggregationResLevel: 4
26
+ };
27
+
28
+ /** All properties supported by H3TileLayer. */
29
+ export type H3TileLayerProps<DataT = any> = _H3TileLayerProps<DataT> & CompositeLayerProps<DataT>;
30
+
31
+ // TODO: use type from h3-hexagon-layer when available
32
+ // eslint-disable-next-line @typescript-eslint/no-unused-vars
33
+ type H3HexagonLayerProps<DataT = any> = Record<string, any>;
34
+
35
+ /** Properties added by H3TileLayer. */
36
+ type _H3TileLayerProps<DataT = any> = H3HexagonLayerProps<DataT> & {
37
+ aggregationResLevel?: number;
38
+ };
39
+
40
+ export default class H3TileLayer<DataT = any, ExtraPropsT = {}> extends CompositeLayer<
41
+ ExtraPropsT & Required<_H3TileLayerProps<DataT>>
42
+ > {
43
+ static layerName = 'H3TileLayer';
44
+ static defaultProps = defaultProps;
45
+
46
+ state!: {
47
+ tileJSON: any;
48
+ data: any;
49
+ };
50
+
51
+ initializeState(): void {
52
+ this.setState({data: null, tileJSON: null});
53
+ }
54
+
55
+ updateState({changeFlags}: UpdateParameters<this>): void {
56
+ if (changeFlags.dataChanged) {
57
+ let {data} = this.props;
58
+ const tileJSON = data;
59
+ data = (tileJSON as any).tiles;
60
+ this.setState({data, tileJSON});
61
+ }
62
+ }
63
+
64
+ renderLayers(): Layer | null | LayersList {
65
+ const {data, tileJSON} = this.state;
66
+ const maxZoom = parseInt(tileJSON.maxresolution);
67
+ return [
68
+ new SpatialIndexTileLayer(this.props, {
69
+ id: `h3-tile-layer-${this.props.id}`,
70
+ data,
71
+ // @ts-expect-error Tileset2D should be generic over TileIndex
72
+ TilesetClass: H3Tileset2D,
73
+ renderSubLayers,
74
+ maxZoom
75
+ })
76
+ ];
77
+ }
78
+ }
@@ -1,4 +1,4 @@
1
- import {_Tileset2D as Tileset2D} from '@deck.gl/geo-layers';
1
+ import {_Tileset2D as Tileset2D, GeoBoundingBox} from '@deck.gl/geo-layers';
2
2
  import {
3
3
  polyfill,
4
4
  getRes0Indexes,
@@ -9,7 +9,12 @@ import {
9
9
  kRing
10
10
  } from 'h3-js';
11
11
 
12
- function getHexagonsInBoundingBox({west, north, east, south}, resolution) {
12
+ export type H3TileIndex = {i: string};
13
+
14
+ function getHexagonsInBoundingBox(
15
+ {west, north, east, south}: GeoBoundingBox,
16
+ resolution: number
17
+ ): string[] {
13
18
  if (resolution === 0) {
14
19
  return getRes0Indexes();
15
20
  }
@@ -41,7 +46,7 @@ function getHexagonsInBoundingBox({west, north, east, south}, resolution) {
41
46
  return oversample ? [...new Set(h3Indices.map(i => h3ToParent(i, resolution)))] : h3Indices;
42
47
  }
43
48
 
44
- function tileToBoundingBox(index) {
49
+ function tileToBoundingBox(index: string): GeoBoundingBox {
45
50
  const coordinates = h3ToGeoBoundary(index);
46
51
  const latitudes = coordinates.map(c => c[0]);
47
52
  const longitudes = coordinates.map(c => c[1]);
@@ -57,7 +62,7 @@ function tileToBoundingBox(index) {
57
62
  // similar
58
63
  // Relative scale factor (0 = no biasing, 2 = a few hexagons cover view)
59
64
  const BIAS = 2;
60
- function getHexagonResolution(viewport) {
65
+ function getHexagonResolution(viewport): number {
61
66
  const hexagonScaleFactor = (2 / 3) * viewport.zoom;
62
67
  const latitudeScaleFactor = Math.log(1 / Math.cos((Math.PI * viewport.latitude) / 180));
63
68
 
@@ -66,11 +71,12 @@ function getHexagonResolution(viewport) {
66
71
  }
67
72
 
68
73
  export default class H3Tileset2D extends Tileset2D {
69
- getTileIndices({viewport, minZoom, maxZoom}) {
74
+ // @ts-expect-error Tileset2D should be generic over TileIndex
75
+ getTileIndices({viewport, minZoom, maxZoom}): H3TileIndex[] {
70
76
  const [east, south, west, north] = viewport.getBounds();
71
77
 
72
78
  let z = getHexagonResolution(viewport);
73
- let indices = [];
79
+ let indices: string[];
74
80
  if (typeof minZoom === 'number' && Number.isFinite(minZoom) && z < minZoom) {
75
81
  z = minZoom;
76
82
  }
@@ -88,19 +94,23 @@ export default class H3Tileset2D extends Tileset2D {
88
94
  return indices.map(i => ({i}));
89
95
  }
90
96
 
91
- getTileId({i}) {
97
+ // @ts-expect-error Tileset2D should be generic over TileIndex
98
+ getTileId({i}: H3TileIndex): string {
92
99
  return i;
93
100
  }
94
101
 
95
- getTileMetadata({i}) {
102
+ // @ts-expect-error Tileset2D should be generic over TileIndex
103
+ getTileMetadata({i}: H3TileIndex) {
96
104
  return {bbox: tileToBoundingBox(i)};
97
105
  }
98
106
 
99
- getTileZoom({i}) {
107
+ // @ts-expect-error Tileset2D should be generic over TileIndex
108
+ getTileZoom({i}: H3TileIndex): number {
100
109
  return h3GetResolution(i);
101
110
  }
102
111
 
103
- getParentIndex(index) {
112
+ // @ts-expect-error Tileset2D should be generic over TileIndex
113
+ getParentIndex(index: H3TileIndex): H3TileIndex {
104
114
  const resolution = h3GetResolution(index.i);
105
115
  const i = h3ToParent(index.i, resolution - 1);
106
116
  return {i};
@@ -0,0 +1,68 @@
1
+ import {
2
+ CompositeLayer,
3
+ CompositeLayerProps,
4
+ Layer,
5
+ LayersList,
6
+ UpdateParameters
7
+ } from '@deck.gl/core';
8
+ import {QuadkeyLayer, QuadkeyLayerProps} from '@deck.gl/geo-layers';
9
+ import QuadkeyTileset2D from './quadkey-tileset-2d';
10
+ import SpatialIndexTileLayer from './spatial-index-tile-layer';
11
+
12
+ const renderSubLayers = props => {
13
+ const {data} = props;
14
+ if (!data || !data.length) return null;
15
+ return new QuadkeyLayer(props, {getQuadkey: d => d.id});
16
+ };
17
+
18
+ const defaultProps = {
19
+ aggregationResLevel: 6
20
+ };
21
+
22
+ /** All properties supported by QuadkeyTileLayer. */
23
+ export type QuadkeyTileLayerProps<DataT = any> = _QuadkeyTileLayerProps<DataT> &
24
+ CompositeLayerProps<DataT>;
25
+
26
+ /** Properties added by QuadkeyTileLayer. */
27
+ type _QuadkeyTileLayerProps<DataT> = QuadkeyLayerProps<DataT> & {
28
+ aggregationResLevel?: number;
29
+ };
30
+
31
+ export default class QuadkeyTileLayer<DataT = any, ExtraProps = {}> extends CompositeLayer<
32
+ ExtraProps & Required<_QuadkeyTileLayerProps<DataT>>
33
+ > {
34
+ static layerName = 'QuadkeyTileLayer';
35
+ static defaultProps = defaultProps;
36
+
37
+ state!: {
38
+ tileJSON: any;
39
+ data: any;
40
+ };
41
+ initializeState(): void {
42
+ this.setState({data: null, tileJSON: null});
43
+ }
44
+
45
+ updateState({changeFlags}: UpdateParameters<this>): void {
46
+ if (changeFlags.dataChanged) {
47
+ let {data} = this.props;
48
+ const tileJSON = data;
49
+ data = (tileJSON as any).tiles;
50
+ this.setState({data, tileJSON});
51
+ }
52
+ }
53
+
54
+ renderLayers(): Layer | null | LayersList {
55
+ const {data, tileJSON} = this.state;
56
+ const maxZoom = parseInt(tileJSON?.maxresolution);
57
+ return [
58
+ new SpatialIndexTileLayer(this.props, {
59
+ id: `quadkey-tile-layer-${this.props.id}`,
60
+ data,
61
+ // TODO: Tileset2D should be generic over TileIndex type
62
+ TilesetClass: QuadkeyTileset2D as any,
63
+ renderSubLayers,
64
+ maxZoom
65
+ })
66
+ ];
67
+ }
68
+ }
@@ -1,6 +1,7 @@
1
1
  import {_Tileset2D as Tileset2D} from '@deck.gl/geo-layers';
2
2
 
3
- function tileToQuadkey(tile) {
3
+ type QuadkeyTileIndex = {i: string};
4
+ function tileToQuadkey(tile): QuadkeyTileIndex {
4
5
  let index = '';
5
6
  for (let z = tile.z; z > 0; z--) {
6
7
  let b = 0;
@@ -13,11 +14,13 @@ function tileToQuadkey(tile) {
13
14
  }
14
15
 
15
16
  export default class QuadkeyTileset2D extends Tileset2D {
16
- getTileIndices(opts) {
17
+ // @ts-expect-error for spatial indices, TileSet2d should be parametrized by TileIndexT
18
+ getTileIndices(opts): QuadkeyTileIndex[] {
17
19
  return super.getTileIndices(opts).map(tileToQuadkey);
18
20
  }
19
21
 
20
- getTileId({i}) {
22
+ // @ts-expect-error TileIndex must be generic
23
+ getTileId({i}: QuadkeyTileIndex) {
21
24
  return i;
22
25
  }
23
26
 
@@ -25,11 +28,13 @@ export default class QuadkeyTileset2D extends Tileset2D {
25
28
  return {};
26
29
  }
27
30
 
28
- getTileZoom({i}) {
31
+ // @ts-expect-error TileIndex must be generic
32
+ getTileZoom({i}: QuadkeyTileIndex) {
29
33
  return i.length;
30
34
  }
31
35
 
32
- getParentIndex(index) {
36
+ // @ts-expect-error TileIndex must be generic
37
+ getParentIndex(index: QuadkeyTileIndex) {
33
38
  const i = index.i.slice(0, -1);
34
39
  return {i};
35
40
  }
@@ -1,11 +1,12 @@
1
- import {TileLayer} from '@deck.gl/geo-layers';
1
+ import {PickingInfo} from '@deck.gl/core';
2
+ import {TileLayer, _Tile2DHeader as Tile2DHeader} from '@deck.gl/geo-layers';
2
3
 
3
- function isFeatureIdDefined(value) {
4
+ function isFeatureIdDefined(value: unknown): boolean {
4
5
  return value !== undefined && value !== null && value !== '';
5
6
  }
6
7
 
7
- export default class SpatialIndexTileLayer extends TileLayer {
8
- _updateAutoHighlight(info) {
8
+ export default class SpatialIndexTileLayer<ExtraProps = {}> extends TileLayer<any, ExtraProps> {
9
+ protected _updateAutoHighlight(info: PickingInfo): void {
9
10
  const {hoveredFeatureId} = this.state;
10
11
  const hoveredFeature = info.object;
11
12
  let newHoveredFeatureId;
@@ -27,14 +28,14 @@ export default class SpatialIndexTileLayer extends TileLayer {
27
28
  }
28
29
  }
29
30
 
30
- getSubLayerPropsByTile(tile) {
31
+ getSubLayerPropsByTile(tile: Tile2DHeader) {
31
32
  return {
32
33
  highlightedObjectIndex: this.getHighlightedObjectIndex(tile),
33
34
  highlightColor: this.state.highlightColor
34
35
  };
35
36
  }
36
37
 
37
- getHighlightedObjectIndex(tile) {
38
+ getHighlightedObjectIndex(tile: Tile2DHeader) {
38
39
  const {hoveredFeatureId} = this.state;
39
40
  const data = tile.content;
40
41
 
@@ -0,0 +1,4 @@
1
+ export { FORMATS, TILE_FORMATS, MAP_TYPES, API_VERSIONS } from './maps-api-common';
2
+ export { getDataV2, CONNECTIONS } from './maps-client';
3
+ export { fetchLayerData, fetchMap, getData, mapInstantiation } from './maps-v3-client';
4
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/api/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAC,OAAO,EAAE,YAAY,EAAE,SAAS,EAAE,YAAY,EAAC,MAAM,mBAAmB,CAAC;AACjF,OAAO,EAAC,SAAS,EAAE,WAAW,EAAC,MAAM,eAAe,CAAC;AACrD,OAAO,EAAC,cAAc,EAAE,QAAQ,EAAE,OAAO,EAAE,gBAAgB,EAAC,MAAM,kBAAkB,CAAC"}
@@ -0,0 +1,54 @@
1
+ import { scaleLinear, scaleOrdinal, scaleLog, scalePoint, scaleQuantile, scaleQuantize, scaleSqrt, scaleThreshold } from 'd3-scale';
2
+ import { Layer, _ConstructorOf as ConstructorOf } from '@deck.gl/core/typed';
3
+ declare const SCALE_FUNCS: {
4
+ linear: typeof scaleLinear;
5
+ ordinal: typeof scaleOrdinal;
6
+ log: typeof scaleLog;
7
+ point: typeof scalePoint;
8
+ quantile: typeof scaleQuantile;
9
+ quantize: typeof scaleQuantize;
10
+ sqrt: typeof scaleSqrt;
11
+ custom: typeof scaleThreshold;
12
+ };
13
+ export declare type SCALE_TYPE = keyof typeof SCALE_FUNCS;
14
+ export declare const AGGREGATION: {
15
+ average: string;
16
+ maximum: string;
17
+ minimum: string;
18
+ sum: string;
19
+ };
20
+ export declare const OPACITY_MAP: {
21
+ getFillColor: string;
22
+ getLineColor: string;
23
+ getTextColor: string;
24
+ };
25
+ export declare function getLayer(type: string, config: any, dataset: any): {
26
+ Layer: ConstructorOf<Layer>;
27
+ propMap: any;
28
+ defaultProps: any;
29
+ };
30
+ declare function domainFromValues(values: any, scaleType: SCALE_TYPE): any;
31
+ export declare function opacityToAlpha(opacity: any): number;
32
+ export declare function getColorValueAccessor({ name }: {
33
+ name: any;
34
+ }, colorAggregation: any, data: any): any;
35
+ export declare function getColorAccessor({ name }: {
36
+ name: any;
37
+ }, scaleType: SCALE_TYPE, { colors, colorMap }: {
38
+ colors: any;
39
+ colorMap: any;
40
+ }, opacity: number | undefined, data: any): any;
41
+ export declare function getSizeAccessor({ name }: {
42
+ name: any;
43
+ }, scaleType: SCALE_TYPE, range: Iterable<Range>, data: any): any;
44
+ export declare function getTextAccessor({ name, type }: {
45
+ name: any;
46
+ type: any;
47
+ }, data: any): any;
48
+ export declare function getTextPixelOffsetAccessor({ alignment, anchor, size }: {
49
+ alignment: any;
50
+ anchor: any;
51
+ size: any;
52
+ }, radius: any): number[] | ((d: any) => number[]);
53
+ export { domainFromValues as _domainFromValues };
54
+ //# sourceMappingURL=layer-map.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"layer-map.d.ts","sourceRoot":"","sources":["../../src/api/layer-map.ts"],"names":[],"mappings":"AAEA,OAAO,EACL,WAAW,EACX,YAAY,EACZ,QAAQ,EACR,UAAU,EACV,aAAa,EACb,aAAa,EACb,SAAS,EACT,cAAc,EACf,MAAM,UAAU,CAAC;AAIlB,OAAO,EAAC,KAAK,EAAE,cAAc,IAAI,aAAa,EAAC,MAAM,eAAe,CAAC;AASrE,QAAA,MAAM,WAAW;;;;;;;;;CAShB,CAAC;AACF,oBAAY,UAAU,GAAG,MAAM,OAAO,WAAW,CAAC;AAIlD,eAAO,MAAM,WAAW;;;;;CAKvB,CAAC;AAEF,eAAO,MAAM,WAAW;;;;CAIvB,CAAC;AA2DF,wBAAgB,QAAQ,CACtB,IAAI,EAAE,MAAM,EACZ,MAAM,KAAA,EACN,OAAO,KAAA,GACN;IAAC,KAAK,EAAE,aAAa,CAAC,KAAK,CAAC,CAAC;IAAC,OAAO,EAAE,GAAG,CAAC;IAAC,YAAY,EAAE,GAAG,CAAA;CAAC,CAmDhE;AAkCD,iBAAS,gBAAgB,CAAC,MAAM,KAAA,EAAE,SAAS,EAAE,UAAU,OActD;AA8BD,wBAAgB,cAAc,CAAC,OAAO,KAAA,UAErC;AAED,wBAAgB,qBAAqB,CAAC,EAAC,IAAI,EAAC;;CAAA,EAAE,gBAAgB,KAAA,EAAE,IAAI,EAAE,GAAG,OAIxE;AAED,wBAAgB,gBAAgB,CAC9B,EAAC,IAAI,EAAC;;CAAA,EACN,SAAS,EAAE,UAAU,EACrB,EAAC,MAAM,EAAE,QAAQ,EAAC;;;CAAA,EAClB,OAAO,EAAE,MAAM,GAAG,SAAS,EAC3B,IAAI,EAAE,GAAG,OA+BV;AAED,wBAAgB,eAAe,CAAC,EAAC,IAAI,EAAC;;CAAA,EAAE,SAAS,EAAE,UAAU,EAAE,KAAK,EAAE,QAAQ,CAAC,KAAK,CAAC,EAAE,IAAI,EAAE,GAAG,OAS/F;AAUD,wBAAgB,eAAe,CAAC,EAAC,IAAI,EAAE,IAAI,EAAC;;;CAAA,EAAE,IAAI,KAAA,OAMjD;AAED,wBAAgB,0BAA0B,CAAC,EAAC,SAAS,EAAE,MAAM,EAAE,IAAI,EAAC;;;;CAAA,EAAE,MAAM,KAAA,qCAa3E;AAED,OAAO,EAAC,gBAAgB,IAAI,iBAAiB,EAAC,CAAC"}
@@ -0,0 +1,65 @@
1
+ export declare const DEFAULT_USER_COMPONENT_IN_URL = "{user}";
2
+ export declare const DEFAULT_REGION_COMPONENT_IN_URL = "{region}";
3
+ export declare type ValuesOf<T extends {}> = T[keyof T];
4
+ export declare const API_VERSIONS: {
5
+ readonly V1: "v1";
6
+ readonly V2: "v2";
7
+ readonly V3: "v3";
8
+ };
9
+ export declare type ApiVersion = ValuesOf<typeof API_VERSIONS>;
10
+ export declare const DEFAULT_MAPS_URL_FORMAT: {
11
+ readonly v1: "https://{user}.carto.com/api/v1/map";
12
+ readonly v2: "https://maps-api-v2.{region}.carto.com/user/{user}";
13
+ };
14
+ export declare const MAP_TYPES: {
15
+ readonly QUERY: "query";
16
+ readonly TABLE: "table";
17
+ readonly TILESET: "tileset";
18
+ };
19
+ export declare type MapType = ValuesOf<typeof MAP_TYPES>;
20
+ export declare const COLUMNS_SUPPORT: MapType[];
21
+ export declare const GEO_COLUMN_SUPPORT: MapType[];
22
+ export declare const FORMATS: {
23
+ readonly GEOJSON: "geojson";
24
+ readonly NDJSON: "ndjson";
25
+ readonly TILEJSON: "tilejson";
26
+ readonly JSON: "json";
27
+ };
28
+ export declare type Format = ValuesOf<typeof FORMATS>;
29
+ export declare const TILE_FORMATS: {
30
+ readonly MVT: "mvt";
31
+ readonly JSON: "json";
32
+ readonly GEOJSON: "geojson";
33
+ readonly BINARY: "binary";
34
+ };
35
+ export declare type TileFormat = ValuesOf<typeof TILE_FORMATS>;
36
+ export declare enum SchemaFieldType {
37
+ Number = "number",
38
+ Bigint = "bigint",
39
+ String = "string",
40
+ Geometry = "geometry",
41
+ Timestamp = "timestamp",
42
+ Object = "object",
43
+ Boolean = "boolean",
44
+ Variant = "variant",
45
+ Unknown = "unknown"
46
+ }
47
+ export interface SchemaField {
48
+ name: string;
49
+ type: SchemaFieldType;
50
+ }
51
+ export interface MapInstantiation extends MapInstantiationFormats {
52
+ nrows: number;
53
+ size?: number;
54
+ schema: SchemaField[];
55
+ }
56
+ declare type MapInstantiationFormats = Record<Format, {
57
+ url: string[];
58
+ error?: any;
59
+ }>;
60
+ /**
61
+ * Simple encode parameter
62
+ */
63
+ export declare function encodeParameter(name: string, value: string | boolean | number): string;
64
+ export {};
65
+ //# sourceMappingURL=maps-api-common.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"maps-api-common.d.ts","sourceRoot":"","sources":["../../src/api/maps-api-common.ts"],"names":[],"mappings":"AAAA,eAAO,MAAM,6BAA6B,WAAW,CAAC;AACtD,eAAO,MAAM,+BAA+B,aAAa,CAAC;AAE1D,oBAAY,QAAQ,CAAC,CAAC,SAAS,EAAE,IAAI,CAAC,CAAC,MAAM,CAAC,CAAC,CAAC;AAChD,eAAO,MAAM,YAAY;;;;CAIf,CAAC;AACX,oBAAY,UAAU,GAAG,QAAQ,CAAC,OAAO,YAAY,CAAC,CAAC;AAEvD,eAAO,MAAM,uBAAuB;;;CAG1B,CAAC;AAEX,eAAO,MAAM,SAAS;;;;CAIZ,CAAC;AACX,oBAAY,OAAO,GAAG,QAAQ,CAAC,OAAO,SAAS,CAAC,CAAC;AACjD,eAAO,MAAM,eAAe,EAAE,OAAO,EAAsB,CAAC;AAC5D,eAAO,MAAM,kBAAkB,EAAE,OAAO,EAAuC,CAAC;AAGhF,eAAO,MAAM,OAAO;;;;;CAKV,CAAC;AACX,oBAAY,MAAM,GAAG,QAAQ,CAAC,OAAO,OAAO,CAAC,CAAC;AAG9C,eAAO,MAAM,YAAY;;;;;CAKf,CAAC;AACX,oBAAY,UAAU,GAAG,QAAQ,CAAC,OAAO,YAAY,CAAC,CAAC;AAEvD,oBAAY,eAAe;IACzB,MAAM,WAAW;IACjB,MAAM,WAAW;IACjB,MAAM,WAAW;IACjB,QAAQ,aAAa;IACrB,SAAS,cAAc;IACvB,MAAM,WAAW;IACjB,OAAO,YAAY;IACnB,OAAO,YAAY;IACnB,OAAO,YAAY;CACpB;AACD,MAAM,WAAW,WAAW;IAC1B,IAAI,EAAE,MAAM,CAAC;IACb,IAAI,EAAE,eAAe,CAAC;CACvB;AAED,MAAM,WAAW,gBAAiB,SAAQ,uBAAuB;IAC/D,KAAK,EAAE,MAAM,CAAC;IACd,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,MAAM,EAAE,WAAW,EAAE,CAAC;CACvB;AAED,aAAK,uBAAuB,GAAG,MAAM,CACnC,MAAM,EACN;IACE,GAAG,EAAE,MAAM,EAAE,CAAC;IACd,KAAK,CAAC,EAAE,GAAG,CAAC;CACb,CACF,CAAC;AAEF;;GAEG;AACH,wBAAgB,eAAe,CAAC,IAAI,EAAE,MAAM,EAAE,KAAK,EAAE,MAAM,GAAG,OAAO,GAAG,MAAM,GAAG,MAAM,CAEtF"}
@@ -0,0 +1,18 @@
1
+ /**
2
+ * Maps API Client for Maps API v1 and Maps API v2
3
+ */
4
+ import { ClassicCredentials } from '../config';
5
+ import { MapType } from './maps-api-common';
6
+ export declare const CONNECTIONS: {
7
+ BIGQUERY: string;
8
+ CARTO: string;
9
+ };
10
+ /**
11
+ * Obtain a TileJson from Maps API v1 and v2
12
+ */
13
+ export declare function getDataV2({ type, source, credentials }: {
14
+ type: MapType;
15
+ source: string;
16
+ credentials?: Partial<ClassicCredentials>;
17
+ }): Promise<any>;
18
+ //# sourceMappingURL=maps-client.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"maps-client.d.ts","sourceRoot":"","sources":["../../src/api/maps-client.ts"],"names":[],"mappings":"AAAA;;GAEG;AACH,OAAO,EACL,kBAAkB,EAInB,MAAM,WAAW,CAAC;AACnB,OAAO,EAML,OAAO,EAER,MAAM,mBAAmB,CAAC;AAE3B,eAAO,MAAM,WAAW;;;CAGvB,CAAC;AAKF;;GAEG;AACH,wBAAsB,SAAS,CAAC,EAC9B,IAAI,EACJ,MAAM,EACN,WAAW,EACZ,EAAE;IACD,IAAI,EAAE,OAAO,CAAC;IACd,MAAM,EAAE,MAAM,CAAC;IACf,WAAW,CAAC,EAAE,OAAO,CAAC,kBAAkB,CAAC,CAAC;CAC3C,gBAkCA"}
@@ -0,0 +1,45 @@
1
+ /**
2
+ * Maps API Client for Carto 3
3
+ */
4
+ import { CloudNativeCredentials } from '../config';
5
+ import { Format, MapInstantiation, MapType, SchemaField, TileFormat } from './maps-api-common';
6
+ declare type FetchLayerDataParams = {
7
+ type: MapType;
8
+ source: string;
9
+ connection: string;
10
+ credentials: CloudNativeCredentials;
11
+ geoColumn?: string;
12
+ columns?: string[];
13
+ clientId?: string;
14
+ format?: Format;
15
+ formatTiles?: TileFormat;
16
+ aggregationExp?: string;
17
+ aggregationResLevel?: number;
18
+ };
19
+ export declare function mapInstantiation({ type, source, connection, credentials, geoColumn, columns, clientId, aggregationExp, aggregationResLevel }: FetchLayerDataParams): Promise<MapInstantiation>;
20
+ export interface FetchLayerDataResult {
21
+ data: any;
22
+ format?: Format;
23
+ schema: SchemaField[];
24
+ }
25
+ export declare function fetchLayerData({ type, source, connection, credentials, geoColumn, columns, format, formatTiles, clientId, aggregationExp, aggregationResLevel }: FetchLayerDataParams): Promise<FetchLayerDataResult>;
26
+ export declare function getData({ type, source, connection, credentials, geoColumn, columns, format, clientId }: FetchLayerDataParams): Promise<any>;
27
+ export declare function fetchMap({ cartoMapId, clientId, credentials, autoRefresh, onNewData }: {
28
+ cartoMapId: string;
29
+ clientId: string;
30
+ credentials?: CloudNativeCredentials;
31
+ autoRefresh?: number;
32
+ onNewData?: (map: any) => void;
33
+ }): Promise<{
34
+ stopAutoRefresh: (() => void) | undefined;
35
+ id: any;
36
+ title: any;
37
+ description: any;
38
+ createdAt: any;
39
+ updatedAt: any;
40
+ initialViewState: any;
41
+ mapStyle: any;
42
+ layers: (import("@deck.gl/core").Layer<any> | undefined)[];
43
+ }>;
44
+ export {};
45
+ //# sourceMappingURL=maps-v3-client.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"maps-v3-client.d.ts","sourceRoot":"","sources":["../../src/api/maps-v3-client.ts"],"names":[],"mappings":"AAAA;;GAEG;AACH,OAAO,EAA8C,sBAAsB,EAAC,MAAM,WAAW,CAAC;AAC9F,OAAO,EAIL,MAAM,EAGN,gBAAgB,EAChB,OAAO,EAEP,WAAW,EACX,UAAU,EAEX,MAAM,mBAAmB,CAAC;AA0F3B,aAAK,oBAAoB,GAAG;IAC1B,IAAI,EAAE,OAAO,CAAC;IACd,MAAM,EAAE,MAAM,CAAC;IACf,UAAU,EAAE,MAAM,CAAC;IACnB,WAAW,EAAE,sBAAsB,CAAC;IACpC,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,OAAO,CAAC,EAAE,MAAM,EAAE,CAAC;IACnB,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB,WAAW,CAAC,EAAE,UAAU,CAAC;IACzB,cAAc,CAAC,EAAE,MAAM,CAAC;IACxB,mBAAmB,CAAC,EAAE,MAAM,CAAC;CAC9B,CAAC;AAmCF,wBAAsB,gBAAgB,CAAC,EACrC,IAAI,EACJ,MAAM,EACN,UAAU,EACV,WAAW,EACX,SAAS,EACT,OAAO,EACP,QAAQ,EACR,cAAc,EACd,mBAAmB,EACpB,EAAE,oBAAoB,GAAG,OAAO,CAAC,gBAAgB,CAAC,CAuBlD;AAsDD,MAAM,WAAW,oBAAoB;IACnC,IAAI,EAAE,GAAG,CAAC;IACV,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB,MAAM,EAAE,WAAW,EAAE,CAAC;CACvB;AACD,wBAAsB,cAAc,CAAC,EACnC,IAAI,EACJ,MAAM,EACN,UAAU,EACV,WAAW,EACX,SAAS,EACT,OAAO,EACP,MAAM,EACN,WAAW,EACX,QAAQ,EACR,cAAc,EACd,mBAAmB,EACpB,EAAE,oBAAoB,GAAG,OAAO,CAAC,oBAAoB,CAAC,CAoBtD;AAgFD,wBAAsB,OAAO,CAAC,EAC5B,IAAI,EACJ,MAAM,EACN,UAAU,EACV,WAAW,EACX,SAAS,EACT,OAAO,EACP,MAAM,EACN,QAAQ,EACT,EAAE,oBAAoB,gBAatB;AA4CD,wBAAsB,QAAQ,CAAC,EAC7B,UAAU,EACV,QAAQ,EACR,WAAW,EACX,WAAW,EACX,SAAS,EACV,EAAE;IACD,UAAU,EAAE,MAAM,CAAC;IACnB,QAAQ,EAAE,MAAM,CAAC;IACjB,WAAW,CAAC,EAAE,sBAAsB,CAAC;IACrC,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,SAAS,CAAC,EAAE,CAAC,GAAG,EAAE,GAAG,KAAK,IAAI,CAAC;CAChC;4BA8B6B,IAAI;;;;;;;;;GA8BjC"}