@deck.gl/carto 8.8.4 → 8.8.5
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 +237 -66
- package/dist/es5/api/layer-map.js +104 -17
- package/dist/es5/api/layer-map.js.map +1 -1
- package/dist/es5/api/maps-v3-client.js +191 -35
- package/dist/es5/api/maps-v3-client.js.map +1 -1
- package/dist/es5/api/parseMap.js +14 -4
- package/dist/es5/api/parseMap.js.map +1 -1
- package/dist/es5/config.js +11 -2
- package/dist/es5/config.js.map +1 -1
- package/dist/es5/layers/carto-layer.js +4 -17
- package/dist/es5/layers/carto-layer.js.map +1 -1
- package/dist/esm/api/layer-map.js +79 -14
- package/dist/esm/api/layer-map.js.map +1 -1
- package/dist/esm/api/maps-v3-client.js +90 -3
- package/dist/esm/api/maps-v3-client.js.map +1 -1
- package/dist/esm/api/parseMap.js +18 -4
- package/dist/esm/api/parseMap.js.map +1 -1
- package/dist/esm/config.js +10 -2
- package/dist/esm/config.js.map +1 -1
- package/dist/esm/layers/carto-layer.js +4 -15
- package/dist/esm/layers/carto-layer.js.map +1 -1
- package/dist.min.js +138 -138
- package/package.json +2 -2
- package/src/api/layer-map.ts +76 -13
- package/src/api/maps-v3-client.ts +92 -4
- package/src/api/parseMap.ts +6 -2
- package/src/config.ts +12 -2
- package/src/layers/carto-layer.ts +9 -29
- package/typed/api/layer-map.d.ts +12 -4
- package/typed/api/layer-map.d.ts.map +1 -1
- package/typed/api/maps-v3-client.d.ts.map +1 -1
- package/typed/config.d.ts +2 -0
- package/typed/config.d.ts.map +1 -1
- package/typed/layers/carto-layer.d.ts +2 -7
- package/typed/layers/carto-layer.d.ts.map +1 -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.8.
|
|
5
|
+
"version": "8.8.5",
|
|
6
6
|
"publishConfig": {
|
|
7
7
|
"access": "public"
|
|
8
8
|
},
|
|
@@ -61,5 +61,5 @@
|
|
|
61
61
|
"@deck.gl/layers": "^8.0.0",
|
|
62
62
|
"@loaders.gl/core": "^3.0.0"
|
|
63
63
|
},
|
|
64
|
-
"gitHead": "
|
|
64
|
+
"gitHead": "96af77adfd71563e0da68acd4e7ae318f551c5de"
|
|
65
65
|
}
|
package/src/api/layer-map.ts
CHANGED
|
@@ -19,6 +19,8 @@ import {GeoJsonLayer} from '@deck.gl/layers';
|
|
|
19
19
|
import {H3HexagonLayer, MVTLayer} from '@deck.gl/geo-layers';
|
|
20
20
|
|
|
21
21
|
import CartoTileLayer from '../layers/carto-tile-layer';
|
|
22
|
+
import H3TileLayer from '../layers/h3-tile-layer';
|
|
23
|
+
import QuadbinTileLayer from '../layers/quadbin-tile-layer';
|
|
22
24
|
import {TILE_FORMATS} from './maps-api-common';
|
|
23
25
|
import {assert} from '../utils';
|
|
24
26
|
|
|
@@ -111,7 +113,7 @@ export function getLayer(
|
|
|
111
113
|
config,
|
|
112
114
|
dataset
|
|
113
115
|
): {Layer: ConstructorOf<Layer>; propMap: any; defaultProps: any} {
|
|
114
|
-
if (type === 'mvt' || type === 'tileset') {
|
|
116
|
+
if (type === 'mvt' || type === 'tileset' || type === 'h3' || type === 'quadbin') {
|
|
115
117
|
return getTileLayer(dataset);
|
|
116
118
|
}
|
|
117
119
|
|
|
@@ -163,31 +165,58 @@ export function getLayer(
|
|
|
163
165
|
};
|
|
164
166
|
}
|
|
165
167
|
|
|
168
|
+
export function layerFromTileDataset(
|
|
169
|
+
formatTiles: string | null = TILE_FORMATS.MVT,
|
|
170
|
+
scheme: string
|
|
171
|
+
): typeof CartoTileLayer | typeof H3TileLayer | typeof MVTLayer | typeof QuadbinTileLayer {
|
|
172
|
+
if (scheme === 'h3') {
|
|
173
|
+
return H3TileLayer;
|
|
174
|
+
}
|
|
175
|
+
if (scheme === 'quadbin') {
|
|
176
|
+
return QuadbinTileLayer;
|
|
177
|
+
}
|
|
178
|
+
if (formatTiles === TILE_FORMATS.MVT) {
|
|
179
|
+
return MVTLayer;
|
|
180
|
+
}
|
|
181
|
+
|
|
182
|
+
// formatTiles === BINARY|JSON|GEOJSON
|
|
183
|
+
return CartoTileLayer;
|
|
184
|
+
}
|
|
185
|
+
|
|
166
186
|
function getTileLayer(dataset) {
|
|
167
187
|
const {
|
|
188
|
+
aggregationExp,
|
|
189
|
+
aggregationResLevel,
|
|
168
190
|
data: {
|
|
191
|
+
scheme,
|
|
169
192
|
tiles: [tileUrl]
|
|
170
193
|
}
|
|
171
194
|
} = dataset;
|
|
172
195
|
/* global URL */
|
|
173
|
-
const formatTiles = new URL(tileUrl).searchParams.get('formatTiles')
|
|
196
|
+
const formatTiles = new URL(tileUrl).searchParams.get('formatTiles');
|
|
174
197
|
|
|
175
198
|
return {
|
|
176
|
-
Layer: formatTiles
|
|
199
|
+
Layer: layerFromTileDataset(formatTiles, scheme),
|
|
177
200
|
propMap: sharedPropMap,
|
|
178
201
|
defaultProps: {
|
|
179
202
|
...defaultProps,
|
|
180
|
-
|
|
181
|
-
|
|
203
|
+
...(aggregationExp && {aggregationExp}),
|
|
204
|
+
...(aggregationResLevel && {aggregationResLevel}),
|
|
205
|
+
formatTiles,
|
|
206
|
+
uniqueIdProperty: 'geoid'
|
|
182
207
|
}
|
|
183
208
|
};
|
|
184
209
|
}
|
|
185
210
|
|
|
186
|
-
function domainFromAttribute(attribute, scaleType: SCALE_TYPE) {
|
|
211
|
+
function domainFromAttribute(attribute, scaleType: SCALE_TYPE, scaleLength: number) {
|
|
187
212
|
if (scaleType === 'ordinal' || scaleType === 'point') {
|
|
188
213
|
return attribute.categories.map(c => c.category).filter(c => c !== undefined && c !== null);
|
|
189
214
|
}
|
|
190
215
|
|
|
216
|
+
if (scaleType === 'quantile' && attribute.quantiles) {
|
|
217
|
+
return attribute.quantiles[scaleLength];
|
|
218
|
+
}
|
|
219
|
+
|
|
191
220
|
let {min} = attribute;
|
|
192
221
|
if (scaleType === 'log' && min === 0) {
|
|
193
222
|
min = 1e-5;
|
|
@@ -211,12 +240,12 @@ function domainFromValues(values, scaleType: SCALE_TYPE) {
|
|
|
211
240
|
return extent(values);
|
|
212
241
|
}
|
|
213
242
|
|
|
214
|
-
function calculateDomain(data, name, scaleType) {
|
|
243
|
+
function calculateDomain(data, name, scaleType, scaleLength?) {
|
|
215
244
|
if (data.tilestats) {
|
|
216
245
|
// Tileset data type
|
|
217
246
|
const {attributes} = data.tilestats.layers[0];
|
|
218
247
|
const attribute = attributes.find(a => a.attribute === name);
|
|
219
|
-
return domainFromAttribute(attribute, scaleType);
|
|
248
|
+
return domainFromAttribute(attribute, scaleType, scaleLength);
|
|
220
249
|
} else if (data.features) {
|
|
221
250
|
// GeoJSON data type
|
|
222
251
|
const values = data.features.map(({properties}) => properties[name]);
|
|
@@ -243,6 +272,25 @@ export function opacityToAlpha(opacity) {
|
|
|
243
272
|
return opacity !== undefined ? Math.round(255 * Math.pow(opacity, 1 / 2.2)) : 255;
|
|
244
273
|
}
|
|
245
274
|
|
|
275
|
+
function getAccessorKeys(name: string, aggregation: string | undefined): string[] {
|
|
276
|
+
let keys = [name];
|
|
277
|
+
if (aggregation) {
|
|
278
|
+
// Snowflake will capitalized the keys, need to check lower and upper case version
|
|
279
|
+
keys = keys.concat([aggregation, aggregation.toUpperCase()].map(a => `${name}_${a}`));
|
|
280
|
+
}
|
|
281
|
+
return keys;
|
|
282
|
+
}
|
|
283
|
+
|
|
284
|
+
function findAccessorKey(keys: string[], properties): string[] {
|
|
285
|
+
for (const key of keys) {
|
|
286
|
+
if (key in properties) {
|
|
287
|
+
return [key];
|
|
288
|
+
}
|
|
289
|
+
}
|
|
290
|
+
|
|
291
|
+
throw new Error(`Could not find property for any accessor key: ${keys}`);
|
|
292
|
+
}
|
|
293
|
+
|
|
246
294
|
export function getColorValueAccessor({name}, colorAggregation, data: any) {
|
|
247
295
|
const aggregator = AGGREGATION_FUNC[colorAggregation];
|
|
248
296
|
const accessor = values => aggregator(values, p => p[name]);
|
|
@@ -252,7 +300,7 @@ export function getColorValueAccessor({name}, colorAggregation, data: any) {
|
|
|
252
300
|
export function getColorAccessor(
|
|
253
301
|
{name},
|
|
254
302
|
scaleType: SCALE_TYPE,
|
|
255
|
-
{colors, colorMap},
|
|
303
|
+
{aggregation, range: {colors, colorMap}},
|
|
256
304
|
opacity: number | undefined,
|
|
257
305
|
data: any
|
|
258
306
|
) {
|
|
@@ -266,7 +314,7 @@ export function getColorAccessor(
|
|
|
266
314
|
scaleColor.push(color);
|
|
267
315
|
});
|
|
268
316
|
} else {
|
|
269
|
-
domain = calculateDomain(data, name, scaleType);
|
|
317
|
+
domain = calculateDomain(data, name, scaleType, colors.length);
|
|
270
318
|
scaleColor = colors;
|
|
271
319
|
}
|
|
272
320
|
|
|
@@ -279,21 +327,36 @@ export function getColorAccessor(
|
|
|
279
327
|
scale.unknown(UNKNOWN_COLOR);
|
|
280
328
|
const alpha = opacityToAlpha(opacity);
|
|
281
329
|
|
|
330
|
+
let accessorKeys = getAccessorKeys(name, aggregation);
|
|
282
331
|
const accessor = properties => {
|
|
283
|
-
|
|
332
|
+
if (!(accessorKeys[0] in properties)) {
|
|
333
|
+
accessorKeys = findAccessorKey(accessorKeys, properties);
|
|
334
|
+
}
|
|
335
|
+
const propertyValue = properties[accessorKeys[0]];
|
|
284
336
|
const {r, g, b} = rgb(scale(propertyValue));
|
|
285
337
|
return [r, g, b, propertyValue === null ? 0 : alpha];
|
|
286
338
|
};
|
|
287
339
|
return normalizeAccessor(accessor, data);
|
|
288
340
|
}
|
|
289
341
|
|
|
290
|
-
export function getSizeAccessor(
|
|
342
|
+
export function getSizeAccessor(
|
|
343
|
+
{name},
|
|
344
|
+
scaleType: SCALE_TYPE,
|
|
345
|
+
aggregation,
|
|
346
|
+
range: Iterable<Range>,
|
|
347
|
+
data: any
|
|
348
|
+
) {
|
|
291
349
|
const scale = SCALE_FUNCS[scaleType as any]();
|
|
292
350
|
scale.domain(calculateDomain(data, name, scaleType));
|
|
293
351
|
scale.range(range);
|
|
294
352
|
|
|
353
|
+
let accessorKeys = getAccessorKeys(name, aggregation);
|
|
295
354
|
const accessor = properties => {
|
|
296
|
-
|
|
355
|
+
if (!(accessorKeys[0] in properties)) {
|
|
356
|
+
accessorKeys = findAccessorKey(accessorKeys, properties);
|
|
357
|
+
}
|
|
358
|
+
const propertyValue = properties[accessorKeys[0]];
|
|
359
|
+
return scale(propertyValue);
|
|
297
360
|
};
|
|
298
361
|
return normalizeAccessor(accessor, data);
|
|
299
362
|
}
|
|
@@ -1,7 +1,12 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* Maps API Client for Carto 3
|
|
3
3
|
*/
|
|
4
|
-
import {
|
|
4
|
+
import {
|
|
5
|
+
getDefaultCredentials,
|
|
6
|
+
buildMapsUrlFromBase,
|
|
7
|
+
buildStatsUrlFromBase,
|
|
8
|
+
CloudNativeCredentials
|
|
9
|
+
} from '../config';
|
|
5
10
|
import {
|
|
6
11
|
API_VERSIONS,
|
|
7
12
|
COLUMNS_SUPPORT,
|
|
@@ -144,6 +149,9 @@ function getParameters({
|
|
|
144
149
|
}
|
|
145
150
|
if (aggregationExp) {
|
|
146
151
|
parameters.push(encodeParameter('aggregationExp', aggregationExp));
|
|
152
|
+
} else if (isSpatialIndexGeoColumn(geoColumn)) {
|
|
153
|
+
// Default aggregationExp required for spatial index layers
|
|
154
|
+
parameters.push(encodeParameter('aggregationExp', '1 AS value'));
|
|
147
155
|
}
|
|
148
156
|
if (aggregationResLevel) {
|
|
149
157
|
parameters.push(encodeParameter('aggregationResLevel', aggregationResLevel));
|
|
@@ -152,6 +160,11 @@ function getParameters({
|
|
|
152
160
|
return parameters.join('&');
|
|
153
161
|
}
|
|
154
162
|
|
|
163
|
+
function isSpatialIndexGeoColumn(geoColumn: string | undefined) {
|
|
164
|
+
const spatialIndex = geoColumn?.split(':')[0];
|
|
165
|
+
return spatialIndex === 'h3' || spatialIndex === 'quadbin';
|
|
166
|
+
}
|
|
167
|
+
|
|
155
168
|
export async function mapInstantiation({
|
|
156
169
|
type,
|
|
157
170
|
source,
|
|
@@ -170,8 +183,8 @@ export async function mapInstantiation({
|
|
|
170
183
|
geoColumn,
|
|
171
184
|
columns,
|
|
172
185
|
clientId,
|
|
173
|
-
|
|
174
|
-
|
|
186
|
+
aggregationResLevel,
|
|
187
|
+
aggregationExp
|
|
175
188
|
})}`;
|
|
176
189
|
const {accessToken} = credentials;
|
|
177
190
|
|
|
@@ -363,9 +376,20 @@ async function _fetchMapDataset(
|
|
|
363
376
|
credentials: CloudNativeCredentials,
|
|
364
377
|
clientId?: string
|
|
365
378
|
) {
|
|
366
|
-
const {
|
|
379
|
+
const {
|
|
380
|
+
aggregationExp,
|
|
381
|
+
aggregationResLevel,
|
|
382
|
+
connectionName: connection,
|
|
383
|
+
columns,
|
|
384
|
+
format,
|
|
385
|
+
geoColumn,
|
|
386
|
+
source,
|
|
387
|
+
type
|
|
388
|
+
} = dataset;
|
|
367
389
|
// First fetch metadata
|
|
368
390
|
const {url, mapFormat} = await _fetchDataUrl({
|
|
391
|
+
aggregationExp,
|
|
392
|
+
aggregationResLevel,
|
|
369
393
|
clientId,
|
|
370
394
|
credentials: {...credentials, accessToken},
|
|
371
395
|
connection,
|
|
@@ -389,6 +413,31 @@ async function _fetchMapDataset(
|
|
|
389
413
|
return true;
|
|
390
414
|
}
|
|
391
415
|
|
|
416
|
+
async function _fetchTilestats(
|
|
417
|
+
attribute,
|
|
418
|
+
dataset,
|
|
419
|
+
accessToken: string,
|
|
420
|
+
credentials: CloudNativeCredentials
|
|
421
|
+
) {
|
|
422
|
+
const {connectionName: connection, source, type} = dataset;
|
|
423
|
+
|
|
424
|
+
const statsUrl = buildStatsUrlFromBase(credentials.apiBaseUrl);
|
|
425
|
+
let url = `${statsUrl}/${connection}/`;
|
|
426
|
+
if (type === MAP_TYPES.QUERY) {
|
|
427
|
+
url += `${attribute}?q=${source}`;
|
|
428
|
+
} else {
|
|
429
|
+
// MAP_TYPE.TABLE
|
|
430
|
+
url += `${source}/${attribute}`;
|
|
431
|
+
}
|
|
432
|
+
const stats = await requestData({url, format: FORMATS.JSON, accessToken});
|
|
433
|
+
|
|
434
|
+
// Replace tilestats for attribute with value from API
|
|
435
|
+
const {attributes} = dataset.data.tilestats.layers[0];
|
|
436
|
+
const index = attributes.findIndex(d => d.attribute === attribute);
|
|
437
|
+
attributes[index] = stats;
|
|
438
|
+
return true;
|
|
439
|
+
}
|
|
440
|
+
|
|
392
441
|
async function fillInMapDatasets(
|
|
393
442
|
{datasets, token},
|
|
394
443
|
clientId: string,
|
|
@@ -398,6 +447,42 @@ async function fillInMapDatasets(
|
|
|
398
447
|
return await Promise.all(promises);
|
|
399
448
|
}
|
|
400
449
|
|
|
450
|
+
async function fillInTileStats(
|
|
451
|
+
{datasets, keplerMapConfig, token},
|
|
452
|
+
credentials: CloudNativeCredentials
|
|
453
|
+
) {
|
|
454
|
+
const attributes: {attribute?: string; dataset?: any}[] = [];
|
|
455
|
+
const {layers} = keplerMapConfig.config.visState;
|
|
456
|
+
for (const layer of layers) {
|
|
457
|
+
for (const channel of Object.keys(layer.visualChannels)) {
|
|
458
|
+
const attribute = layer.visualChannels[channel]?.name;
|
|
459
|
+
if (attribute) {
|
|
460
|
+
const dataset = datasets.find(d => d.id === layer.config.dataId);
|
|
461
|
+
if (dataset.data.tilestats && dataset.type !== MAP_TYPES.TILESET) {
|
|
462
|
+
// Only fetch stats for QUERY & TABLE map types
|
|
463
|
+
attributes.push({attribute, dataset});
|
|
464
|
+
}
|
|
465
|
+
}
|
|
466
|
+
}
|
|
467
|
+
}
|
|
468
|
+
// Remove duplicates to avoid repeated requests
|
|
469
|
+
const filteredAttributes: {attribute?: string; dataset?: any}[] = [];
|
|
470
|
+
for (const a of attributes) {
|
|
471
|
+
if (
|
|
472
|
+
!filteredAttributes.find(
|
|
473
|
+
({attribute, dataset}) => attribute === a.attribute && dataset === a.dataset
|
|
474
|
+
)
|
|
475
|
+
) {
|
|
476
|
+
filteredAttributes.push(a);
|
|
477
|
+
}
|
|
478
|
+
}
|
|
479
|
+
|
|
480
|
+
const promises = filteredAttributes.map(({attribute, dataset}) =>
|
|
481
|
+
_fetchTilestats(attribute, dataset, token, credentials)
|
|
482
|
+
);
|
|
483
|
+
return await Promise.all(promises);
|
|
484
|
+
}
|
|
485
|
+
|
|
401
486
|
export async function fetchMap({
|
|
402
487
|
cartoMapId,
|
|
403
488
|
clientId,
|
|
@@ -466,6 +551,9 @@ export async function fetchMap({
|
|
|
466
551
|
|
|
467
552
|
// Mutates map.datasets so that dataset.data contains data
|
|
468
553
|
await fillInMapDatasets(map, clientId, localCreds);
|
|
554
|
+
|
|
555
|
+
// Mutates attributes in visualChannels to contain tile stats
|
|
556
|
+
await fillInTileStats(map, localCreds);
|
|
469
557
|
return {
|
|
470
558
|
...parseMap(map),
|
|
471
559
|
...{stopAutoRefresh}
|
package/src/api/parseMap.ts
CHANGED
|
@@ -176,10 +176,11 @@ function createChannelProps(visualChannels, type, config, data) {
|
|
|
176
176
|
}
|
|
177
177
|
}
|
|
178
178
|
} else if (colorField) {
|
|
179
|
+
const {colorAggregation: aggregation, colorRange: range} = visConfig;
|
|
179
180
|
result.getFillColor = getColorAccessor(
|
|
180
181
|
colorField,
|
|
181
182
|
colorScale,
|
|
182
|
-
|
|
183
|
+
{aggregation, range},
|
|
183
184
|
visConfig.opacity,
|
|
184
185
|
data
|
|
185
186
|
);
|
|
@@ -189,10 +190,11 @@ function createChannelProps(visualChannels, type, config, data) {
|
|
|
189
190
|
const fallbackOpacity = type === 'point' ? visConfig.opacity : 1;
|
|
190
191
|
const opacity =
|
|
191
192
|
visConfig.strokeOpacity !== undefined ? visConfig.strokeOpacity : fallbackOpacity;
|
|
193
|
+
const {strokeColorAggregation: aggregation, strokeColorRange: range} = visConfig;
|
|
192
194
|
result.getLineColor = getColorAccessor(
|
|
193
195
|
strokeColorField,
|
|
194
196
|
strokeColorScale,
|
|
195
|
-
|
|
197
|
+
{aggregation, range},
|
|
196
198
|
opacity,
|
|
197
199
|
data
|
|
198
200
|
);
|
|
@@ -201,6 +203,7 @@ function createChannelProps(visualChannels, type, config, data) {
|
|
|
201
203
|
result.getElevation = getSizeAccessor(
|
|
202
204
|
heightField,
|
|
203
205
|
heightScale,
|
|
206
|
+
visConfig.heightAggregation,
|
|
204
207
|
visConfig.heightRange || visConfig.sizeRange,
|
|
205
208
|
data
|
|
206
209
|
);
|
|
@@ -209,6 +212,7 @@ function createChannelProps(visualChannels, type, config, data) {
|
|
|
209
212
|
result.getPointRadius = getSizeAccessor(
|
|
210
213
|
sizeField,
|
|
211
214
|
sizeScale,
|
|
215
|
+
visConfig.sizeAggregation,
|
|
212
216
|
visConfig.radiusRange || visConfig.sizeRange,
|
|
213
217
|
data
|
|
214
218
|
);
|
package/src/config.ts
CHANGED
|
@@ -50,11 +50,21 @@ export function getDefaultCredentials(): Credentials {
|
|
|
50
50
|
return credentials;
|
|
51
51
|
}
|
|
52
52
|
|
|
53
|
-
export
|
|
54
|
-
|
|
53
|
+
export type V3Endpoint = 'maps' | 'stats';
|
|
54
|
+
|
|
55
|
+
function buildUrlFromBase(apiBaseUrl: string, endpoint: V3Endpoint) {
|
|
56
|
+
let suffix = `/v3/${endpoint}`;
|
|
55
57
|
if (apiBaseUrl.endsWith('/')) {
|
|
56
58
|
suffix = suffix.substring(1);
|
|
57
59
|
}
|
|
58
60
|
|
|
59
61
|
return `${apiBaseUrl}${suffix}`;
|
|
60
62
|
}
|
|
63
|
+
|
|
64
|
+
export function buildMapsUrlFromBase(apiBaseUrl: string): string {
|
|
65
|
+
return buildUrlFromBase(apiBaseUrl, 'maps');
|
|
66
|
+
}
|
|
67
|
+
|
|
68
|
+
export function buildStatsUrlFromBase(apiBaseUrl: string): string {
|
|
69
|
+
return buildUrlFromBase(apiBaseUrl, 'stats');
|
|
70
|
+
}
|
|
@@ -1,24 +1,22 @@
|
|
|
1
1
|
import {
|
|
2
2
|
CompositeLayer,
|
|
3
|
-
Layer,
|
|
4
|
-
log,
|
|
5
3
|
CompositeLayerProps,
|
|
4
|
+
Layer,
|
|
6
5
|
LayerProps,
|
|
7
|
-
|
|
6
|
+
log,
|
|
7
|
+
UpdateParameters
|
|
8
8
|
} from '@deck.gl/core';
|
|
9
|
-
|
|
10
|
-
import H3TileLayer from './h3-tile-layer';
|
|
11
|
-
import QuadbinTileLayer from './quadbin-tile-layer';
|
|
9
|
+
|
|
12
10
|
import {MVTLayer} from '@deck.gl/geo-layers';
|
|
13
11
|
import {fetchLayerData, getDataV2, API_VERSIONS} from '../api';
|
|
12
|
+
import {layerFromTileDataset} from '../api/layer-map';
|
|
14
13
|
import {
|
|
15
14
|
COLUMNS_SUPPORT,
|
|
16
15
|
FORMATS,
|
|
17
16
|
GEO_COLUMN_SUPPORT,
|
|
18
17
|
MapType,
|
|
19
18
|
MAP_TYPES,
|
|
20
|
-
TileFormat
|
|
21
|
-
TILE_FORMATS
|
|
19
|
+
TileFormat
|
|
22
20
|
} from '../api/maps-api-common';
|
|
23
21
|
import {
|
|
24
22
|
ClassicCredentials,
|
|
@@ -209,16 +207,7 @@ export default class CartoLayer<ExtraProps = {}> extends CompositeLayer<
|
|
|
209
207
|
}
|
|
210
208
|
}
|
|
211
209
|
|
|
212
|
-
updateState({
|
|
213
|
-
props,
|
|
214
|
-
oldProps,
|
|
215
|
-
changeFlags
|
|
216
|
-
}: {
|
|
217
|
-
props: CartoLayerProps;
|
|
218
|
-
oldProps: CartoLayerProps;
|
|
219
|
-
context: any;
|
|
220
|
-
changeFlags: ChangeFlags;
|
|
221
|
-
}): void {
|
|
210
|
+
updateState({props, oldProps, changeFlags}: UpdateParameters<this>) {
|
|
222
211
|
this._checkProps(props);
|
|
223
212
|
const shouldUpdateData =
|
|
224
213
|
changeFlags.dataChanged ||
|
|
@@ -294,19 +283,10 @@ export default class CartoLayer<ExtraProps = {}> extends CompositeLayer<
|
|
|
294
283
|
|
|
295
284
|
/* global URL */
|
|
296
285
|
const tileUrl = new URL(data.tiles[0]);
|
|
297
|
-
|
|
298
286
|
props.formatTiles =
|
|
299
|
-
props.formatTiles ||
|
|
300
|
-
(tileUrl.searchParams.get('formatTiles') as TileFormat) ||
|
|
301
|
-
TILE_FORMATS.MVT;
|
|
287
|
+
props.formatTiles || (tileUrl.searchParams.get('formatTiles') as TileFormat);
|
|
302
288
|
|
|
303
|
-
|
|
304
|
-
return [H3TileLayer, props];
|
|
305
|
-
}
|
|
306
|
-
if (data.scheme === 'quadbin') {
|
|
307
|
-
return [QuadbinTileLayer, props];
|
|
308
|
-
}
|
|
309
|
-
return props.formatTiles === TILE_FORMATS.MVT ? [MVTLayer, props] : [CartoTileLayer, props];
|
|
289
|
+
return [layerFromTileDataset(props.formatTiles, data.scheme), props];
|
|
310
290
|
}
|
|
311
291
|
|
|
312
292
|
renderLayers(): Layer | null {
|
package/typed/api/layer-map.d.ts
CHANGED
|
@@ -1,5 +1,9 @@
|
|
|
1
1
|
import { scaleLinear, scaleOrdinal, scaleLog, scalePoint, scaleQuantile, scaleQuantize, scaleSqrt, scaleThreshold } from 'd3-scale';
|
|
2
2
|
import { Layer, _ConstructorOf as ConstructorOf } from '@deck.gl/core/typed';
|
|
3
|
+
import { MVTLayer } from '@deck.gl/geo-layers/typed';
|
|
4
|
+
import CartoTileLayer from '../layers/carto-tile-layer';
|
|
5
|
+
import H3TileLayer from '../layers/h3-tile-layer';
|
|
6
|
+
import QuadbinTileLayer from '../layers/quadbin-tile-layer';
|
|
3
7
|
declare const SCALE_FUNCS: {
|
|
4
8
|
linear: typeof scaleLinear;
|
|
5
9
|
ordinal: typeof scaleOrdinal;
|
|
@@ -27,6 +31,7 @@ export declare function getLayer(type: string, config: any, dataset: any): {
|
|
|
27
31
|
propMap: any;
|
|
28
32
|
defaultProps: any;
|
|
29
33
|
};
|
|
34
|
+
export declare function layerFromTileDataset(formatTiles: string | null | undefined, scheme: string): typeof CartoTileLayer | typeof H3TileLayer | typeof MVTLayer | typeof QuadbinTileLayer;
|
|
30
35
|
declare function domainFromValues(values: any, scaleType: SCALE_TYPE): any;
|
|
31
36
|
export declare function opacityToAlpha(opacity: any): number;
|
|
32
37
|
export declare function getColorValueAccessor({ name }: {
|
|
@@ -34,13 +39,16 @@ export declare function getColorValueAccessor({ name }: {
|
|
|
34
39
|
}, colorAggregation: any, data: any): any;
|
|
35
40
|
export declare function getColorAccessor({ name }: {
|
|
36
41
|
name: any;
|
|
37
|
-
}, scaleType: SCALE_TYPE, { colors, colorMap }: {
|
|
38
|
-
|
|
39
|
-
|
|
42
|
+
}, scaleType: SCALE_TYPE, { aggregation, range: { colors, colorMap } }: {
|
|
43
|
+
aggregation: any;
|
|
44
|
+
range: {
|
|
45
|
+
colors: any;
|
|
46
|
+
colorMap: any;
|
|
47
|
+
};
|
|
40
48
|
}, opacity: number | undefined, data: any): any;
|
|
41
49
|
export declare function getSizeAccessor({ name }: {
|
|
42
50
|
name: any;
|
|
43
|
-
}, scaleType: SCALE_TYPE, range: Iterable<Range>, data: any): any;
|
|
51
|
+
}, scaleType: SCALE_TYPE, aggregation: any, range: Iterable<Range>, data: any): any;
|
|
44
52
|
export declare function getTextAccessor({ name, type }: {
|
|
45
53
|
name: any;
|
|
46
54
|
type: any;
|
|
@@ -1 +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;
|
|
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;AAGrE,OAAO,EAAiB,QAAQ,EAAC,MAAM,qBAAqB,CAAC;AAE7D,OAAO,cAAc,MAAM,4BAA4B,CAAC;AACxD,OAAO,WAAW,MAAM,yBAAyB,CAAC;AAClD,OAAO,gBAAgB,MAAM,8BAA8B,CAAC;AAI5D,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;AAED,wBAAgB,oBAAoB,CAClC,WAAW,2BAAkC,EAC7C,MAAM,EAAE,MAAM,GACb,OAAO,cAAc,GAAG,OAAO,WAAW,GAAG,OAAO,QAAQ,GAAG,OAAO,gBAAgB,CAaxF;AA2CD,iBAAS,gBAAgB,CAAC,MAAM,KAAA,EAAE,SAAS,EAAE,UAAU,OActD;AA8BD,wBAAgB,cAAc,CAAC,OAAO,KAAA,UAErC;AAqBD,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,WAAW,EAAE,KAAK,EAAE,EAAC,MAAM,EAAE,QAAQ,EAAC,EAAC;;;;;;CAAA,EACxC,OAAO,EAAE,MAAM,GAAG,SAAS,EAC3B,IAAI,EAAE,GAAG,OAmCV;AAED,wBAAgB,eAAe,CAC7B,EAAC,IAAI,EAAC;;CAAA,EACN,SAAS,EAAE,UAAU,EACrB,WAAW,KAAA,EACX,KAAK,EAAE,QAAQ,CAAC,KAAK,CAAC,EACtB,IAAI,EAAE,GAAG,OAeV;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"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"maps-v3-client.d.ts","sourceRoot":"","sources":["../../src/api/maps-v3-client.ts"],"names":[],"mappings":"AAAA;;GAEG;AACH,OAAO,
|
|
1
|
+
{"version":3,"file":"maps-v3-client.d.ts","sourceRoot":"","sources":["../../src/api/maps-v3-client.ts"],"names":[],"mappings":"AAAA;;GAEG;AACH,OAAO,EAIL,sBAAsB,EACvB,MAAM,WAAW,CAAC;AACnB,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;AA2CF,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;AAkMD,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;;;;;;;;;GAiCjC"}
|
package/typed/config.d.ts
CHANGED
|
@@ -22,5 +22,7 @@ export interface CloudNativeCredentials {
|
|
|
22
22
|
export declare type Credentials = ClassicCredentials | CloudNativeCredentials;
|
|
23
23
|
export declare function setDefaultCredentials({ apiVersion, ...rest }: Partial<Credentials>): void;
|
|
24
24
|
export declare function getDefaultCredentials(): Credentials;
|
|
25
|
+
export declare type V3Endpoint = 'maps' | 'stats';
|
|
25
26
|
export declare function buildMapsUrlFromBase(apiBaseUrl: string): string;
|
|
27
|
+
export declare function buildStatsUrlFromBase(apiBaseUrl: string): string;
|
|
26
28
|
//# sourceMappingURL=config.d.ts.map
|
package/typed/config.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"config.d.ts","sourceRoot":"","sources":["../src/config.ts"],"names":[],"mappings":"AAEA,eAAO,MAAM,yBAAyB;;;;CAI5B,CAAC;AAEX,eAAO,MAAM,6BAA6B;;CAEhC,CAAC;AAEX,MAAM,WAAW,kBAAkB;IACjC,UAAU,EAAE,IAAI,GAAG,IAAI,CAAC;IACxB,MAAM,EAAE,MAAM,CAAC;IACf,MAAM,EAAE,MAAM,CAAC;IACf,QAAQ,EAAE,MAAM,CAAC;IACjB,OAAO,CAAC,EAAE,MAAM,CAAC;CAClB;AAED,MAAM,WAAW,sBAAsB;IACrC,UAAU,EAAE,IAAI,CAAC;IACjB,UAAU,EAAE,MAAM,CAAC;IACnB,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,OAAO,CAAC,EAAE,MAAM,CAAC;CAClB;AAED,oBAAY,WAAW,GAAG,kBAAkB,GAAG,sBAAsB,CAAC;AAKtE,wBAAgB,qBAAqB,CAAC,EAAC,UAAU,EAAE,GAAG,IAAI,EAAC,EAAE,OAAO,CAAC,WAAW,CAAC,QAchF;AAED,wBAAgB,qBAAqB,IAAI,WAAW,CAEnD;AAED,wBAAgB,oBAAoB,CAAC,UAAU,EAAE,MAAM,GAAG,MAAM,
|
|
1
|
+
{"version":3,"file":"config.d.ts","sourceRoot":"","sources":["../src/config.ts"],"names":[],"mappings":"AAEA,eAAO,MAAM,yBAAyB;;;;CAI5B,CAAC;AAEX,eAAO,MAAM,6BAA6B;;CAEhC,CAAC;AAEX,MAAM,WAAW,kBAAkB;IACjC,UAAU,EAAE,IAAI,GAAG,IAAI,CAAC;IACxB,MAAM,EAAE,MAAM,CAAC;IACf,MAAM,EAAE,MAAM,CAAC;IACf,QAAQ,EAAE,MAAM,CAAC;IACjB,OAAO,CAAC,EAAE,MAAM,CAAC;CAClB;AAED,MAAM,WAAW,sBAAsB;IACrC,UAAU,EAAE,IAAI,CAAC;IACjB,UAAU,EAAE,MAAM,CAAC;IACnB,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,OAAO,CAAC,EAAE,MAAM,CAAC;CAClB;AAED,oBAAY,WAAW,GAAG,kBAAkB,GAAG,sBAAsB,CAAC;AAKtE,wBAAgB,qBAAqB,CAAC,EAAC,UAAU,EAAE,GAAG,IAAI,EAAC,EAAE,OAAO,CAAC,WAAW,CAAC,QAchF;AAED,wBAAgB,qBAAqB,IAAI,WAAW,CAEnD;AAED,oBAAY,UAAU,GAAG,MAAM,GAAG,OAAO,CAAC;AAW1C,wBAAgB,oBAAoB,CAAC,UAAU,EAAE,MAAM,GAAG,MAAM,CAE/D;AAED,wBAAgB,qBAAqB,CAAC,UAAU,EAAE,MAAM,GAAG,MAAM,CAEhE"}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { CompositeLayer,
|
|
1
|
+
import { CompositeLayer, CompositeLayerProps, Layer, LayerProps, UpdateParameters } from '@deck.gl/core/typed';
|
|
2
2
|
import { MapType, TileFormat } from '../api/maps-api-common';
|
|
3
3
|
import { Credentials } from '../config';
|
|
4
4
|
/** All properties supported by CartoLayer. */
|
|
@@ -78,12 +78,7 @@ export default class CartoLayer<ExtraProps = {}> extends CompositeLayer<Required
|
|
|
78
78
|
initializeState(): void;
|
|
79
79
|
get isLoaded(): boolean;
|
|
80
80
|
_checkProps(props: CartoLayerProps): void;
|
|
81
|
-
updateState({ props, oldProps, changeFlags }:
|
|
82
|
-
props: CartoLayerProps;
|
|
83
|
-
oldProps: CartoLayerProps;
|
|
84
|
-
context: any;
|
|
85
|
-
changeFlags: ChangeFlags;
|
|
86
|
-
}): void;
|
|
81
|
+
updateState({ props, oldProps, changeFlags }: UpdateParameters<this>): void;
|
|
87
82
|
_updateData(): Promise<void>;
|
|
88
83
|
_getSubLayerAndProps(): [any, LayerProps];
|
|
89
84
|
renderLayers(): Layer | null;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"carto-layer.d.ts","sourceRoot":"","sources":["../../src/layers/carto-layer.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,cAAc,EACd,
|
|
1
|
+
{"version":3,"file":"carto-layer.d.ts","sourceRoot":"","sources":["../../src/layers/carto-layer.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,cAAc,EACd,mBAAmB,EACnB,KAAK,EACL,UAAU,EAEV,gBAAgB,EACjB,MAAM,eAAe,CAAC;AAKvB,OAAO,EAIL,OAAO,EAEP,UAAU,EACX,MAAM,wBAAwB,CAAC;AAChC,OAAO,EAGL,WAAW,EAEZ,MAAM,WAAW,CAAC;AA4CnB,8CAA8C;AAC9C,oBAAY,eAAe,CAAC,KAAK,GAAG,GAAG,IAAI,gBAAgB,GAAG,mBAAmB,CAAC,KAAK,CAAC,CAAC;AAEzF,sCAAsC;AACtC,aAAK,gBAAgB,GAAG;IACtB;;OAEG;IACH,IAAI,EAAE,MAAM,CAAC;IAEb;;;;;;;OAOG;IACH,IAAI,EAAE,OAAO,CAAC;IAEd;;;;OAIG;IACH,UAAU,CAAC,EAAE,MAAM,CAAC;IAEpB;;;;;;OAMG;IACH,WAAW,CAAC,EAAE,UAAU,CAAC;IAEzB;;;;;;OAMG;IACH,SAAS,CAAC,EAAE,MAAM,CAAC;IAEnB;;;;;;OAMG;IACH,OAAO,CAAC,EAAE,MAAM,EAAE,CAAC;IAEnB;;;;OAIG;IACH,gBAAgB,CAAC,EAAE,MAAM,CAAC;IAE1B;;;;OAIG;IACH,WAAW,CAAC,EAAE,WAAW,CAAC;IAE1B;;;;OAIG;IACH,WAAW,CAAC,EAAE,CAAC,GAAG,EAAE,OAAO,KAAK,IAAI,CAAC;IAErC,QAAQ,CAAC,EAAE,MAAM,CAAC;IAElB,wEAAwE;IACxE,cAAc,CAAC,EAAE,MAAM,CAAC;IAExB,iHAAiH;IACjH,mBAAmB,CAAC,EAAE,MAAM,CAAC;CAC9B,CAAC;AAEF,MAAM,CAAC,OAAO,OAAO,UAAU,CAAC,UAAU,GAAG,EAAE,CAAE,SAAQ,cAAc,CACrE,QAAQ,CAAC,gBAAgB,CAAC,GAAG,UAAU,CACxC;IACC,MAAM,CAAC,SAAS,SAAgB;IAChC,MAAM,CAAC,YAAY,MAAuB;IAE1C,eAAe,IAAI,IAAI;IAOvB,IAAI,QAAQ,IAAI,OAAO,CAEtB;IAED,WAAW,CAAC,KAAK,EAAE,eAAe,GAAG,IAAI;IAuCzC,WAAW,CAAC,EAAC,KAAK,EAAE,QAAQ,EAAE,WAAW,EAAC,EAAE,gBAAgB,CAAC,IAAI,CAAC;IAoB5D,WAAW,IAAI,OAAO,CAAC,IAAI,CAAC;IAuClC,oBAAoB,IAAI,CAAC,GAAG,EAAE,UAAU,CAAC;IAuBzC,YAAY,IAAI,KAAK,GAAG,IAAI;CAqB7B"}
|