@deck.gl/carto 9.0.24 → 9.0.25

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 (44) hide show
  1. package/dist/cartoRasterTile-worker.js +1 -1
  2. package/dist/cartoSpatialTile-worker.js +1 -1
  3. package/dist/cartoVectorTile-worker.js +1 -1
  4. package/dist/dist.dev.js +75 -15
  5. package/dist/index.cjs +74 -18
  6. package/dist/index.cjs.map +3 -3
  7. package/dist/layers/raster-layer.d.ts +21 -1
  8. package/dist/layers/raster-layer.d.ts.map +1 -1
  9. package/dist/layers/raster-layer.js +31 -1
  10. package/dist/layers/raster-tile-layer.d.ts +2 -2
  11. package/dist/layers/raster-tile-layer.d.ts.map +1 -1
  12. package/dist/layers/raster-tile-layer.js +2 -2
  13. package/dist/layers/schema/carto-raster-tile-loader.js +1 -1
  14. package/dist/layers/schema/carto-spatial-tile-loader.js +1 -1
  15. package/dist/layers/schema/carto-vector-tile-loader.js +1 -1
  16. package/dist/layers/spatial-index-tile-layer.d.ts +2 -5
  17. package/dist/layers/spatial-index-tile-layer.d.ts.map +1 -1
  18. package/dist/layers/vector-tile-layer.d.ts.map +1 -1
  19. package/dist/layers/vector-tile-layer.js +10 -2
  20. package/dist/sources/h3-query-source.d.ts +2 -2
  21. package/dist/sources/h3-query-source.d.ts.map +1 -1
  22. package/dist/sources/h3-query-source.js +4 -1
  23. package/dist/sources/h3-table-source.d.ts +2 -2
  24. package/dist/sources/h3-table-source.d.ts.map +1 -1
  25. package/dist/sources/h3-table-source.js +4 -1
  26. package/dist/sources/quadbin-query-source.d.ts +2 -2
  27. package/dist/sources/quadbin-query-source.d.ts.map +1 -1
  28. package/dist/sources/quadbin-query-source.js +4 -1
  29. package/dist/sources/quadbin-table-source.d.ts +2 -2
  30. package/dist/sources/quadbin-table-source.d.ts.map +1 -1
  31. package/dist/sources/quadbin-table-source.js +4 -1
  32. package/dist/utils.d.ts.map +1 -1
  33. package/dist/utils.js +6 -0
  34. package/dist.min.js +9 -9
  35. package/package.json +2 -2
  36. package/src/layers/raster-layer.ts +45 -2
  37. package/src/layers/raster-tile-layer.ts +3 -3
  38. package/src/layers/spatial-index-tile-layer.ts +2 -2
  39. package/src/layers/vector-tile-layer.ts +11 -2
  40. package/src/sources/h3-query-source.ts +11 -2
  41. package/src/sources/h3-table-source.ts +11 -2
  42. package/src/sources/quadbin-query-source.ts +11 -2
  43. package/src/sources/quadbin-table-source.ts +11 -2
  44. package/src/utils.ts +8 -0
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.24",
6
+ "version": "9.0.25",
7
7
  "publishConfig": {
8
8
  "access": "public"
9
9
  },
@@ -72,5 +72,5 @@
72
72
  "@deck.gl/layers": "^9.0.0",
73
73
  "@loaders.gl/core": "^4.2.0"
74
74
  },
75
- "gitHead": "0949b9e539222d84d35b1b315e55710106409553"
75
+ "gitHead": "7f2f016c464ba82472e732a213076a7248cb2c05"
76
76
  }
@@ -4,7 +4,8 @@ import {
4
4
  CompositeLayerProps,
5
5
  Layer,
6
6
  LayersList,
7
- DefaultProps
7
+ DefaultProps,
8
+ PickingInfo
8
9
  } from '@deck.gl/core';
9
10
  import {ColumnLayer, ColumnLayerProps} from '@deck.gl/layers';
10
11
  import {quadbinToOffset} from './quadbin-utils';
@@ -83,6 +84,11 @@ export default class RasterLayer<DataT = any, ExtraProps = {}> extends Composite
83
84
  static layerName = 'RasterLayer';
84
85
  static defaultProps = defaultProps;
85
86
 
87
+ state!: {
88
+ highlightedObjectIndex: number;
89
+ highlightColor: number[];
90
+ };
91
+
86
92
  renderLayers(): Layer | null | LayersList {
87
93
  // Rendering props underlying layer
88
94
  const {
@@ -102,6 +108,7 @@ export default class RasterLayer<DataT = any, ExtraProps = {}> extends Composite
102
108
 
103
109
  // Filled Column Layer
104
110
  const CellLayer = this.getSubLayerClass('column', RasterColumnLayer);
111
+ const {highlightedObjectIndex, highlightColor} = this.state;
105
112
  return new CellLayer(
106
113
  this.props,
107
114
  this.getSubLayerProps({
@@ -118,7 +125,9 @@ export default class RasterLayer<DataT = any, ExtraProps = {}> extends Composite
118
125
  data, // Pass through data for getSubLayerAccessor()
119
126
  length: blockSize * blockSize
120
127
  },
121
- offset
128
+ offset,
129
+ highlightedObjectIndex,
130
+ highlightColor
122
131
  }
123
132
  );
124
133
  }
@@ -137,4 +146,38 @@ export default class RasterLayer<DataT = any, ExtraProps = {}> extends Composite
137
146
  return accessor({properties: proxy}, info);
138
147
  };
139
148
  }
149
+
150
+ getPickingInfo(params: any) {
151
+ const info = super.getPickingInfo(params);
152
+
153
+ if (info.index !== -1) {
154
+ info.object = this.getSubLayerAccessor((x: any) => x)(undefined, {
155
+ data: this.props,
156
+ index: info.index
157
+ });
158
+ }
159
+
160
+ return info;
161
+ }
162
+
163
+ _updateAutoHighlight(info: PickingInfo) {
164
+ const {highlightedObjectIndex} = this.state;
165
+ let newHighlightedObjectIndex: number = -1;
166
+
167
+ if (info.index !== -1) {
168
+ newHighlightedObjectIndex = info.index;
169
+ }
170
+
171
+ if (highlightedObjectIndex !== newHighlightedObjectIndex) {
172
+ let {highlightColor} = this.props;
173
+ if (typeof highlightColor === 'function') {
174
+ highlightColor = highlightColor(info);
175
+ }
176
+
177
+ this.setState({
178
+ highlightColor,
179
+ highlightedObjectIndex: newHighlightedObjectIndex
180
+ });
181
+ }
182
+ }
140
183
  }
@@ -1,10 +1,10 @@
1
1
  import {CompositeLayer, CompositeLayerProps, DefaultProps, Layer, LayersList} from '@deck.gl/core';
2
2
  import RasterLayer, {RasterLayerProps} from './raster-layer';
3
3
  import QuadbinTileset2D from './quadbin-tileset-2d';
4
- import SpatialIndexTileLayer, {SpatialIndexTileLayerProps} from './spatial-index-tile-layer';
5
4
  import type {TilejsonResult} from '../sources/types';
6
5
  import {injectAccessToken, TilejsonPropType} from './utils';
7
6
  import {DEFAULT_TILE_SIZE} from '../constants';
7
+ import {TileLayer, TileLayerProps} from '@deck.gl/geo-layers';
8
8
 
9
9
  export const renderSubLayers = props => {
10
10
  const tileIndex = props.tile?.index?.q;
@@ -23,7 +23,7 @@ export type RasterTileLayerProps<DataT = unknown> = _RasterTileLayerProps<DataT>
23
23
 
24
24
  /** Properties added by RasterTileLayer. */
25
25
  type _RasterTileLayerProps<DataT> = Omit<RasterLayerProps<DataT>, 'data'> &
26
- Omit<SpatialIndexTileLayerProps<DataT>, 'data'> & {
26
+ Omit<TileLayerProps<DataT>, 'data'> & {
27
27
  data: null | TilejsonResult | Promise<TilejsonResult>;
28
28
  };
29
29
 
@@ -48,7 +48,7 @@ export default class RasterTileLayer<
48
48
  const {tiles: data, minzoom: minZoom, maxzoom: maxZoom} = tileJSON;
49
49
  return [
50
50
  // @ts-ignore
51
- new SpatialIndexTileLayer(this.props, {
51
+ new TileLayer(this.props, {
52
52
  id: `raster-tile-layer-${this.props.id}`,
53
53
  data,
54
54
  // TODO: Tileset2D should be generic over TileIndex type
@@ -1,5 +1,5 @@
1
1
  import {registerLoaders} from '@loaders.gl/core';
2
- import {DefaultProps} from '@deck.gl/core';
2
+ import {DefaultProps, LayerProps} from '@deck.gl/core';
3
3
  import CartoRasterTileLoader from './schema/carto-raster-tile-loader';
4
4
  import CartoSpatialTileLoader from './schema/carto-spatial-tile-loader';
5
5
  registerLoaders([CartoRasterTileLoader, CartoSpatialTileLoader]);
@@ -57,7 +57,7 @@ export default class SpatialIndexTileLayer<
57
57
  }
58
58
  }
59
59
 
60
- getSubLayerPropsByTile(tile: Tile2DHeader) {
60
+ getSubLayerPropsByTile(tile: Tile2DHeader): Partial<LayerProps> | null {
61
61
  return {
62
62
  highlightedObjectIndex: this.getHighlightedObjectIndex(tile),
63
63
  highlightColor: this.state.highlightColor
@@ -134,11 +134,20 @@ export default class VectorTileLayer<
134
134
  const tileBbox = props.tile.bbox as any;
135
135
  const {west, south, east, north} = tileBbox;
136
136
 
137
+ const clipProps = {
138
+ extensions: [new ClipExtension(), ...(props.extensions || [])],
139
+ clipBounds: [west, south, east, north]
140
+ };
141
+
137
142
  const subLayerProps = {
138
143
  ...props,
139
144
  autoHighlight: false,
140
- extensions: [new ClipExtension(), ...(props.extensions || [])],
141
- clipBounds: [west, south, east, north]
145
+ // Do not perform clipping on points (#9059)
146
+ _subLayerProps: {
147
+ 'polygons-fill': clipProps,
148
+ 'polygons-stroke': clipProps,
149
+ linestrings: clipProps
150
+ }
142
151
  };
143
152
 
144
153
  const subLayer = new GeoJsonLayer(subLayerProps);
@@ -3,13 +3,17 @@ import {DEFAULT_AGGREGATION_RES_LEVEL_H3} from '../constants';
3
3
  import {baseSource} from './base-source';
4
4
  import type {
5
5
  AggregationOptions,
6
+ FilterOptions,
6
7
  QuerySourceOptions,
7
8
  SourceOptions,
8
9
  SpatialDataType,
9
10
  TilejsonResult
10
11
  } from './types';
11
12
 
12
- export type H3QuerySourceOptions = SourceOptions & QuerySourceOptions & AggregationOptions;
13
+ export type H3QuerySourceOptions = SourceOptions &
14
+ QuerySourceOptions &
15
+ AggregationOptions &
16
+ FilterOptions;
13
17
  type UrlParameters = {
14
18
  aggregationExp: string;
15
19
  aggregationResLevel?: string;
@@ -17,6 +21,7 @@ type UrlParameters = {
17
21
  spatialDataColumn?: string;
18
22
  q: string;
19
23
  queryParameters?: Record<string, unknown> | unknown[];
24
+ filters?: Record<string, unknown>;
20
25
  };
21
26
 
22
27
  export const h3QuerySource = async function (
@@ -27,7 +32,8 @@ export const h3QuerySource = async function (
27
32
  aggregationResLevel = DEFAULT_AGGREGATION_RES_LEVEL_H3,
28
33
  sqlQuery,
29
34
  spatialDataColumn = 'h3',
30
- queryParameters
35
+ queryParameters,
36
+ filters
31
37
  } = options;
32
38
  const urlParameters: UrlParameters = {
33
39
  aggregationExp,
@@ -42,5 +48,8 @@ export const h3QuerySource = async function (
42
48
  if (queryParameters) {
43
49
  urlParameters.queryParameters = queryParameters;
44
50
  }
51
+ if (filters) {
52
+ urlParameters.filters = filters;
53
+ }
45
54
  return baseSource<UrlParameters>('query', options, urlParameters) as Promise<TilejsonResult>;
46
55
  };
@@ -3,13 +3,17 @@ import {DEFAULT_AGGREGATION_RES_LEVEL_H3} from '../constants';
3
3
  import {baseSource} from './base-source';
4
4
  import type {
5
5
  AggregationOptions,
6
+ FilterOptions,
6
7
  SourceOptions,
7
8
  SpatialDataType,
8
9
  TableSourceOptions,
9
10
  TilejsonResult
10
11
  } from './types';
11
12
 
12
- export type H3TableSourceOptions = SourceOptions & TableSourceOptions & AggregationOptions;
13
+ export type H3TableSourceOptions = SourceOptions &
14
+ TableSourceOptions &
15
+ AggregationOptions &
16
+ FilterOptions;
13
17
 
14
18
  type UrlParameters = {
15
19
  aggregationExp: string;
@@ -17,6 +21,7 @@ type UrlParameters = {
17
21
  spatialDataType: SpatialDataType;
18
22
  spatialDataColumn?: string;
19
23
  name: string;
24
+ filters?: Record<string, unknown>;
20
25
  };
21
26
 
22
27
  export const h3TableSource = async function (
@@ -26,7 +31,8 @@ export const h3TableSource = async function (
26
31
  aggregationExp,
27
32
  aggregationResLevel = DEFAULT_AGGREGATION_RES_LEVEL_H3,
28
33
  spatialDataColumn = 'h3',
29
- tableName
34
+ tableName,
35
+ filters
30
36
  } = options;
31
37
  const urlParameters: UrlParameters = {
32
38
  aggregationExp,
@@ -38,5 +44,8 @@ export const h3TableSource = async function (
38
44
  if (aggregationResLevel) {
39
45
  urlParameters.aggregationResLevel = String(aggregationResLevel);
40
46
  }
47
+ if (filters) {
48
+ urlParameters.filters = filters;
49
+ }
41
50
  return baseSource<UrlParameters>('table', options, urlParameters) as Promise<TilejsonResult>;
42
51
  };
@@ -3,13 +3,17 @@ import {DEFAULT_AGGREGATION_RES_LEVEL_QUADBIN} from '../constants';
3
3
  import {baseSource} from './base-source';
4
4
  import type {
5
5
  AggregationOptions,
6
+ FilterOptions,
6
7
  QuerySourceOptions,
7
8
  SourceOptions,
8
9
  SpatialDataType,
9
10
  TilejsonResult
10
11
  } from './types';
11
12
 
12
- export type QuadbinQuerySourceOptions = SourceOptions & QuerySourceOptions & AggregationOptions;
13
+ export type QuadbinQuerySourceOptions = SourceOptions &
14
+ QuerySourceOptions &
15
+ AggregationOptions &
16
+ FilterOptions;
13
17
 
14
18
  type UrlParameters = {
15
19
  aggregationExp: string;
@@ -18,6 +22,7 @@ type UrlParameters = {
18
22
  spatialDataColumn?: string;
19
23
  q: string;
20
24
  queryParameters?: Record<string, unknown> | unknown[];
25
+ filters?: Record<string, unknown>;
21
26
  };
22
27
 
23
28
  export const quadbinQuerySource = async function (
@@ -28,7 +33,8 @@ export const quadbinQuerySource = async function (
28
33
  aggregationResLevel = DEFAULT_AGGREGATION_RES_LEVEL_QUADBIN,
29
34
  sqlQuery,
30
35
  spatialDataColumn = 'quadbin',
31
- queryParameters
36
+ queryParameters,
37
+ filters
32
38
  } = options;
33
39
  const urlParameters: UrlParameters = {
34
40
  aggregationExp,
@@ -43,5 +49,8 @@ export const quadbinQuerySource = async function (
43
49
  if (queryParameters) {
44
50
  urlParameters.queryParameters = queryParameters;
45
51
  }
52
+ if (filters) {
53
+ urlParameters.filters = filters;
54
+ }
46
55
  return baseSource<UrlParameters>('query', options, urlParameters) as Promise<TilejsonResult>;
47
56
  };
@@ -3,13 +3,17 @@ import {DEFAULT_AGGREGATION_RES_LEVEL_QUADBIN} from '../constants';
3
3
  import {baseSource} from './base-source';
4
4
  import type {
5
5
  AggregationOptions,
6
+ FilterOptions,
6
7
  SourceOptions,
7
8
  SpatialDataType,
8
9
  TableSourceOptions,
9
10
  TilejsonResult
10
11
  } from './types';
11
12
 
12
- export type QuadbinTableSourceOptions = SourceOptions & TableSourceOptions & AggregationOptions;
13
+ export type QuadbinTableSourceOptions = SourceOptions &
14
+ TableSourceOptions &
15
+ AggregationOptions &
16
+ FilterOptions;
13
17
 
14
18
  type UrlParameters = {
15
19
  aggregationExp: string;
@@ -17,6 +21,7 @@ type UrlParameters = {
17
21
  spatialDataType: SpatialDataType;
18
22
  spatialDataColumn?: string;
19
23
  name: string;
24
+ filters?: Record<string, unknown>;
20
25
  };
21
26
 
22
27
  export const quadbinTableSource = async function (
@@ -26,7 +31,8 @@ export const quadbinTableSource = async function (
26
31
  aggregationExp,
27
32
  aggregationResLevel = DEFAULT_AGGREGATION_RES_LEVEL_QUADBIN,
28
33
  spatialDataColumn = 'quadbin',
29
- tableName
34
+ tableName,
35
+ filters
30
36
  } = options;
31
37
 
32
38
  const urlParameters: UrlParameters = {
@@ -39,5 +45,8 @@ export const quadbinTableSource = async function (
39
45
  if (aggregationResLevel) {
40
46
  urlParameters.aggregationResLevel = String(aggregationResLevel);
41
47
  }
48
+ if (filters) {
49
+ urlParameters.filters = filters;
50
+ }
42
51
  return baseSource<UrlParameters>('table', options, urlParameters) as Promise<TilejsonResult>;
43
52
  };
package/src/utils.ts CHANGED
@@ -22,6 +22,14 @@ export function createBinaryProxy(
22
22
 
23
23
  has(target, property) {
24
24
  return property in numericProps || property in target;
25
+ },
26
+
27
+ ownKeys(target) {
28
+ return [...Object.keys(numericProps), ...Reflect.ownKeys(target)];
29
+ },
30
+
31
+ getOwnPropertyDescriptor(target, prop) {
32
+ return {enumerable: true, configurable: true};
25
33
  }
26
34
  });
27
35
  }