@deck.gl/carto 8.7.1 → 8.7.4
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/dist/dist.dev.js +9851 -1639
- package/dist/es5/api/layer-map.js +93 -16
- package/dist/es5/api/layer-map.js.map +1 -1
- package/dist/es5/api/maps-v3-client.js +5 -4
- package/dist/es5/api/maps-v3-client.js.map +1 -1
- package/dist/es5/api/parseMap.js +10 -0
- package/dist/es5/api/parseMap.js.map +1 -1
- package/dist/esm/api/layer-map.js +82 -14
- package/dist/esm/api/layer-map.js.map +1 -1
- package/dist/esm/api/maps-v3-client.js +4 -2
- package/dist/esm/api/maps-v3-client.js.map +1 -1
- package/dist/esm/api/parseMap.js +5 -0
- package/dist/esm/api/parseMap.js.map +1 -1
- package/dist.min.js +138 -138
- package/package.json +2 -2
- package/src/api/layer-map.ts +45 -14
- package/src/api/maps-v3-client.ts +4 -3
- package/src/api/parseMap.ts +6 -1
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.7.
|
|
5
|
+
"version": "8.7.4",
|
|
6
6
|
"publishConfig": {
|
|
7
7
|
"access": "public"
|
|
8
8
|
},
|
|
@@ -56,5 +56,5 @@
|
|
|
56
56
|
"@deck.gl/layers": "^8.0.0",
|
|
57
57
|
"@loaders.gl/core": "^3.1.5"
|
|
58
58
|
},
|
|
59
|
-
"gitHead": "
|
|
59
|
+
"gitHead": "eb545b0af1760f83d8225ef8282aca66754fd0b7"
|
|
60
60
|
}
|
package/src/api/layer-map.ts
CHANGED
|
@@ -11,8 +11,11 @@ import {
|
|
|
11
11
|
} from 'd3-scale';
|
|
12
12
|
import {format as d3Format} from 'd3-format';
|
|
13
13
|
import moment from 'moment-timezone';
|
|
14
|
-
|
|
14
|
+
|
|
15
|
+
import {CPUGridLayer, HeatmapLayer, HexagonLayer} from '@deck.gl/aggregation-layers';
|
|
15
16
|
import {GeoJsonLayer} from '@deck.gl/layers';
|
|
17
|
+
import {H3HexagonLayer, MVTLayer} from '@deck.gl/geo-layers';
|
|
18
|
+
|
|
16
19
|
import CartoTileLayer from '../layers/carto-tile-layer';
|
|
17
20
|
import {TILE_FORMATS} from './maps-api-common';
|
|
18
21
|
import {assert} from '../utils';
|
|
@@ -28,6 +31,11 @@ const SCALE_FUNCS = {
|
|
|
28
31
|
};
|
|
29
32
|
export type SCALE_TYPE = keyof typeof SCALE_FUNCS;
|
|
30
33
|
|
|
34
|
+
const hexToRGBA = c => {
|
|
35
|
+
const {r, g, b, opacity} = rgb(c);
|
|
36
|
+
return [r, g, b, 255 * opacity];
|
|
37
|
+
};
|
|
38
|
+
|
|
31
39
|
// Kepler -> Deck.gl
|
|
32
40
|
const sharedPropMap = {
|
|
33
41
|
color: 'getFillColor',
|
|
@@ -41,6 +49,7 @@ const sharedPropMap = {
|
|
|
41
49
|
},
|
|
42
50
|
visConfig: {
|
|
43
51
|
enable3d: 'extruded',
|
|
52
|
+
elevationScale: 'elevationScale',
|
|
44
53
|
filled: 'filled',
|
|
45
54
|
opacity: 'opacity',
|
|
46
55
|
strokeColor: 'getLineColor',
|
|
@@ -51,6 +60,14 @@ const sharedPropMap = {
|
|
|
51
60
|
}
|
|
52
61
|
};
|
|
53
62
|
|
|
63
|
+
const aggregationVisConfig = {
|
|
64
|
+
colorAggregation: 'colorAggregation',
|
|
65
|
+
colorRange: x => ({colorRange: x.colors.map(hexToRGBA)}),
|
|
66
|
+
coverage: 'coverage',
|
|
67
|
+
elevationPercentile: ['elevationLowerPercentile', 'elevationUpperPercentile'],
|
|
68
|
+
percentile: ['lowerPercentile', 'upperPercentile']
|
|
69
|
+
};
|
|
70
|
+
|
|
54
71
|
const RADIUS_DOWNSCALE = 0.2;
|
|
55
72
|
|
|
56
73
|
const defaultProps = {
|
|
@@ -62,7 +79,7 @@ const defaultProps = {
|
|
|
62
79
|
wrapLongitude: false
|
|
63
80
|
};
|
|
64
81
|
|
|
65
|
-
function mergePropMaps(a, b) {
|
|
82
|
+
function mergePropMaps(a = {}, b = {}) {
|
|
66
83
|
return {...a, ...b, visConfig: {...a.visConfig, ...b.visConfig}};
|
|
67
84
|
}
|
|
68
85
|
|
|
@@ -75,30 +92,44 @@ export function getLayer(
|
|
|
75
92
|
return getTileLayer(dataset);
|
|
76
93
|
}
|
|
77
94
|
|
|
95
|
+
const geoColumn = dataset?.geoColumn;
|
|
96
|
+
const getPosition = d => d[geoColumn].coordinates;
|
|
97
|
+
|
|
78
98
|
const hexagonId = config.columns?.hex_id;
|
|
79
99
|
const layer = {
|
|
80
100
|
point: {
|
|
81
101
|
Layer: GeoJsonLayer,
|
|
82
|
-
propMap:
|
|
83
|
-
visConfig: {outline: 'stroked'}
|
|
84
|
-
}),
|
|
85
|
-
defaultProps
|
|
102
|
+
propMap: {visConfig: {outline: 'stroked'}}
|
|
86
103
|
},
|
|
87
104
|
geojson: {
|
|
88
105
|
Layer: GeoJsonLayer,
|
|
89
|
-
|
|
90
|
-
|
|
106
|
+
defaultProps: {lineWidthScale: 2}
|
|
107
|
+
},
|
|
108
|
+
grid: {
|
|
109
|
+
Layer: CPUGridLayer,
|
|
110
|
+
propMap: {visConfig: {...aggregationVisConfig, worldUnitSize: x => ({cellSize: 1000 * x})}},
|
|
111
|
+
defaultProps: {getPosition}
|
|
112
|
+
},
|
|
113
|
+
heatmap: {
|
|
114
|
+
Layer: HeatmapLayer,
|
|
115
|
+
propMap: {visConfig: {...aggregationVisConfig, radius: 'radiusPixels'}},
|
|
116
|
+
defaultProps: {getPosition}
|
|
117
|
+
},
|
|
118
|
+
hexagon: {
|
|
119
|
+
Layer: HexagonLayer,
|
|
120
|
+
propMap: {visConfig: {...aggregationVisConfig, worldUnitSize: x => ({radius: 1000 * x})}},
|
|
121
|
+
defaultProps: {getPosition}
|
|
91
122
|
},
|
|
92
123
|
hexagonId: {
|
|
93
124
|
Layer: H3HexagonLayer,
|
|
94
|
-
propMap:
|
|
95
|
-
|
|
96
|
-
}),
|
|
97
|
-
defaultProps: {...defaultProps, getHexagon: d => d[hexagonId]}
|
|
125
|
+
propMap: {visConfig: {coverage: 'coverage'}},
|
|
126
|
+
defaultProps: {getHexagon: d => d[hexagonId]}
|
|
98
127
|
}
|
|
99
128
|
}[type];
|
|
100
129
|
|
|
101
130
|
assert(layer, `Unsupported layer type: ${type}`);
|
|
131
|
+
layer.propMap = mergePropMaps(sharedPropMap, layer.propMap);
|
|
132
|
+
layer.defaultProps = {...defaultProps, ...layer.defaultProps};
|
|
102
133
|
return layer;
|
|
103
134
|
}
|
|
104
135
|
|
|
@@ -189,8 +220,8 @@ export function getColorAccessor(
|
|
|
189
220
|
const alpha = opacity !== undefined ? Math.round(255 * Math.pow(opacity, 1 / 2.2)) : 255;
|
|
190
221
|
|
|
191
222
|
const accessor = properties => {
|
|
192
|
-
const
|
|
193
|
-
return [
|
|
223
|
+
const {r, g, b} = rgb(scale(properties[name]));
|
|
224
|
+
return [r, g, b, alpha];
|
|
194
225
|
};
|
|
195
226
|
return normalizeAccessor(accessor, data);
|
|
196
227
|
}
|
|
@@ -338,16 +338,17 @@ async function _fetchMapDataset(
|
|
|
338
338
|
credentials: CloudNativeCredentials,
|
|
339
339
|
clientId?: string
|
|
340
340
|
) {
|
|
341
|
-
const {connectionName: connection, columns, geoColumn, source, type} = dataset;
|
|
341
|
+
const {connectionName: connection, columns, format, geoColumn, source, type} = dataset;
|
|
342
342
|
// First fetch metadata
|
|
343
343
|
const {url, mapFormat} = await _fetchDataUrl({
|
|
344
|
+
clientId,
|
|
344
345
|
credentials: {...credentials, accessToken},
|
|
345
346
|
connection,
|
|
346
347
|
columns,
|
|
348
|
+
format,
|
|
347
349
|
geoColumn,
|
|
348
350
|
source,
|
|
349
|
-
type
|
|
350
|
-
clientId
|
|
351
|
+
type
|
|
351
352
|
});
|
|
352
353
|
|
|
353
354
|
// Extract the last time the data changed
|
package/src/api/parseMap.ts
CHANGED
|
@@ -114,8 +114,11 @@ function mapProps(source, target, mapping) {
|
|
|
114
114
|
}
|
|
115
115
|
if (typeof targetKey === 'string') {
|
|
116
116
|
target[targetKey] = sourceValue;
|
|
117
|
+
} else if (typeof targetKey === 'function') {
|
|
118
|
+
const [key, value] = Object.entries(targetKey(sourceValue))[0];
|
|
119
|
+
target[key] = value;
|
|
117
120
|
} else if (typeof targetKey === 'object') {
|
|
118
|
-
// Nested definition, recurse down one level
|
|
121
|
+
// Nested definition, recurse down one level (also handles arrays)
|
|
119
122
|
mapProps(sourceValue, target, targetKey);
|
|
120
123
|
}
|
|
121
124
|
}
|
|
@@ -148,6 +151,8 @@ function createChannelProps(visualChannels, type, config, data) {
|
|
|
148
151
|
1, // Rely on layer opacity
|
|
149
152
|
data
|
|
150
153
|
);
|
|
154
|
+
} else if (type === 'grid' || type === 'hexagon') {
|
|
155
|
+
result.colorScaleType = colorScale;
|
|
151
156
|
}
|
|
152
157
|
if (strokeColorField) {
|
|
153
158
|
const opacity = visConfig.strokeOpacity !== undefined ? visConfig.strokeOpacity : 1;
|