@deck.gl/carto 8.9.0-beta.3 → 8.9.0-beta.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.
- package/dist/dist.dev.js +63 -115
- package/dist/es5/layers/carto-layer.js +1 -3
- package/dist/es5/layers/carto-layer.js.map +1 -1
- package/dist/es5/layers/carto-tile-layer.js.map +1 -1
- package/dist/es5/layers/h3-tile-layer.js.map +1 -1
- package/dist/es5/layers/quadbin-tile-layer.js.map +1 -1
- package/dist/esm/layers/carto-layer.js +1 -3
- package/dist/esm/layers/carto-layer.js.map +1 -1
- package/dist/esm/layers/carto-tile-layer.js.map +1 -1
- package/dist/esm/layers/h3-tile-layer.js.map +1 -1
- package/dist/esm/layers/quadbin-tile-layer.js.map +1 -1
- package/dist.min.js +30 -23
- package/package.json +2 -2
- package/src/layers/carto-layer.ts +3 -3
- package/src/layers/carto-tile-layer.ts +7 -7
- package/src/layers/h3-tile-layer.ts +2 -1
- package/src/layers/quadbin-tile-layer.ts +2 -1
- package/typed/layers/carto-layer.d.ts +1 -3
- package/typed/layers/carto-layer.d.ts.map +1 -1
- package/typed/layers/carto-tile-layer.d.ts +3 -4
- package/typed/layers/carto-tile-layer.d.ts.map +1 -1
- package/typed/layers/h3-tile-layer.d.ts +2 -1
- package/typed/layers/h3-tile-layer.d.ts.map +1 -1
- package/typed/layers/quadbin-tile-layer.d.ts +2 -1
- package/typed/layers/quadbin-tile-layer.d.ts.map +1 -1
- package/LICENSE +0 -19
package/dist/dist.dev.js
CHANGED
|
@@ -1,5 +1,11 @@
|
|
|
1
|
+
(function webpackUniversalModuleDefinition(root, factory) {
|
|
2
|
+
if (typeof exports === 'object' && typeof module === 'object')
|
|
3
|
+
module.exports = factory();
|
|
4
|
+
else if (typeof define === 'function' && define.amd) define([], factory);
|
|
5
|
+
else if (typeof exports === 'object') exports['deck'] = factory();
|
|
6
|
+
else root['deck'] = factory();})(globalThis, function () {
|
|
1
7
|
"use strict";
|
|
2
|
-
var
|
|
8
|
+
var __exports__ = (() => {
|
|
3
9
|
var __create = Object.create;
|
|
4
10
|
var __defProp = Object.defineProperty;
|
|
5
11
|
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
@@ -43,14 +49,14 @@ var deck = (() => {
|
|
|
43
49
|
// external-global-plugin:@deck.gl/core
|
|
44
50
|
var require_core = __commonJS({
|
|
45
51
|
"external-global-plugin:@deck.gl/core"(exports, module) {
|
|
46
|
-
module.exports =
|
|
52
|
+
module.exports = typeof __require === "function" ? require_core() : null;
|
|
47
53
|
}
|
|
48
54
|
});
|
|
49
55
|
|
|
50
56
|
// external-global-plugin:@deck.gl/geo-layers
|
|
51
57
|
var require_geo_layers = __commonJS({
|
|
52
58
|
"external-global-plugin:@deck.gl/geo-layers"(exports, module) {
|
|
53
|
-
module.exports =
|
|
59
|
+
module.exports = typeof __require === "function" ? require_geo_layers() : null;
|
|
54
60
|
}
|
|
55
61
|
});
|
|
56
62
|
|
|
@@ -5318,14 +5324,21 @@ var deck = (() => {
|
|
|
5318
5324
|
// external-global-plugin:@deck.gl/aggregation-layers
|
|
5319
5325
|
var require_aggregation_layers = __commonJS({
|
|
5320
5326
|
"external-global-plugin:@deck.gl/aggregation-layers"(exports, module) {
|
|
5321
|
-
module.exports =
|
|
5327
|
+
module.exports = typeof __require === "function" ? require_aggregation_layers() : null;
|
|
5322
5328
|
}
|
|
5323
5329
|
});
|
|
5324
5330
|
|
|
5325
5331
|
// external-global-plugin:@deck.gl/layers
|
|
5326
5332
|
var require_layers = __commonJS({
|
|
5327
5333
|
"external-global-plugin:@deck.gl/layers"(exports, module) {
|
|
5328
|
-
module.exports =
|
|
5334
|
+
module.exports = typeof __require === "function" ? require_layers() : null;
|
|
5335
|
+
}
|
|
5336
|
+
});
|
|
5337
|
+
|
|
5338
|
+
// external-global-plugin:@loaders.gl/core
|
|
5339
|
+
var require_core2 = __commonJS({
|
|
5340
|
+
"external-global-plugin:@loaders.gl/core"(exports, module) {
|
|
5341
|
+
module.exports = typeof __require === "function" ? require_core2() : null;
|
|
5329
5342
|
}
|
|
5330
5343
|
});
|
|
5331
5344
|
|
|
@@ -6068,14 +6081,14 @@ var deck = (() => {
|
|
|
6068
6081
|
// external-global-plugin:@deck.gl/extensions
|
|
6069
6082
|
var require_extensions = __commonJS({
|
|
6070
6083
|
"external-global-plugin:@deck.gl/extensions"(exports, module) {
|
|
6071
|
-
module.exports =
|
|
6084
|
+
module.exports = typeof __require === "function" ? require_extensions() : null;
|
|
6072
6085
|
}
|
|
6073
6086
|
});
|
|
6074
6087
|
|
|
6075
6088
|
// external-global-plugin:h3-js
|
|
6076
6089
|
var require_h3_js = __commonJS({
|
|
6077
6090
|
"external-global-plugin:h3-js"(exports, module) {
|
|
6078
|
-
module.exports =
|
|
6091
|
+
module.exports = typeof __require === "function" ? require_h3_js() : null;
|
|
6079
6092
|
}
|
|
6080
6093
|
});
|
|
6081
6094
|
|
|
@@ -11111,76 +11124,8 @@ ${formatErrorKey(key)}: ${errorContext[key]}`;
|
|
|
11111
11124
|
var import_layers2 = __toESM(require_layers());
|
|
11112
11125
|
var import_geo_layers7 = __toESM(require_geo_layers());
|
|
11113
11126
|
|
|
11114
|
-
//
|
|
11115
|
-
|
|
11116
|
-
if (!condition) {
|
|
11117
|
-
throw new Error(message || "loader assertion failed.");
|
|
11118
|
-
}
|
|
11119
|
-
}
|
|
11120
|
-
|
|
11121
|
-
// ../../node_modules/@loaders.gl/core/dist/esm/lib/loader-utils/option-utils.js
|
|
11122
|
-
function getGlobalLoaderState() {
|
|
11123
|
-
globalThis.loaders = globalThis.loaders || {};
|
|
11124
|
-
const {
|
|
11125
|
-
loaders
|
|
11126
|
-
} = globalThis;
|
|
11127
|
-
loaders._state = loaders._state || {};
|
|
11128
|
-
return loaders._state;
|
|
11129
|
-
}
|
|
11130
|
-
|
|
11131
|
-
// ../../node_modules/@loaders.gl/core/dist/esm/lib/loader-utils/normalize-loader.js
|
|
11132
|
-
function isLoaderObject(loader) {
|
|
11133
|
-
var _loader;
|
|
11134
|
-
if (!loader) {
|
|
11135
|
-
return false;
|
|
11136
|
-
}
|
|
11137
|
-
if (Array.isArray(loader)) {
|
|
11138
|
-
loader = loader[0];
|
|
11139
|
-
}
|
|
11140
|
-
const hasExtensions = Array.isArray((_loader = loader) === null || _loader === void 0 ? void 0 : _loader.extensions);
|
|
11141
|
-
return hasExtensions;
|
|
11142
|
-
}
|
|
11143
|
-
function normalizeLoader(loader) {
|
|
11144
|
-
var _loader2, _loader3;
|
|
11145
|
-
assert(loader, "null loader");
|
|
11146
|
-
assert(isLoaderObject(loader), "invalid loader");
|
|
11147
|
-
let options;
|
|
11148
|
-
if (Array.isArray(loader)) {
|
|
11149
|
-
options = loader[1];
|
|
11150
|
-
loader = loader[0];
|
|
11151
|
-
loader = {
|
|
11152
|
-
...loader,
|
|
11153
|
-
options: {
|
|
11154
|
-
...loader.options,
|
|
11155
|
-
...options
|
|
11156
|
-
}
|
|
11157
|
-
};
|
|
11158
|
-
}
|
|
11159
|
-
if ((_loader2 = loader) !== null && _loader2 !== void 0 && _loader2.parseTextSync || (_loader3 = loader) !== null && _loader3 !== void 0 && _loader3.parseText) {
|
|
11160
|
-
loader.text = true;
|
|
11161
|
-
}
|
|
11162
|
-
if (!loader.text) {
|
|
11163
|
-
loader.binary = true;
|
|
11164
|
-
}
|
|
11165
|
-
return loader;
|
|
11166
|
-
}
|
|
11167
|
-
|
|
11168
|
-
// ../../node_modules/@loaders.gl/core/dist/esm/lib/api/register-loaders.js
|
|
11169
|
-
var getGlobalLoaderRegistry = () => {
|
|
11170
|
-
const state = getGlobalLoaderState();
|
|
11171
|
-
state.loaderRegistry = state.loaderRegistry || [];
|
|
11172
|
-
return state.loaderRegistry;
|
|
11173
|
-
};
|
|
11174
|
-
function registerLoaders(loaders) {
|
|
11175
|
-
const loaderRegistry = getGlobalLoaderRegistry();
|
|
11176
|
-
loaders = Array.isArray(loaders) ? loaders : [loaders];
|
|
11177
|
-
for (const loader of loaders) {
|
|
11178
|
-
const normalizedLoader = normalizeLoader(loader);
|
|
11179
|
-
if (!loaderRegistry.find((registeredLoader) => normalizedLoader === registeredLoader)) {
|
|
11180
|
-
loaderRegistry.unshift(normalizedLoader);
|
|
11181
|
-
}
|
|
11182
|
-
}
|
|
11183
|
-
}
|
|
11127
|
+
// src/layers/carto-tile-layer.ts
|
|
11128
|
+
var import_core = __toESM(require_core2());
|
|
11184
11129
|
|
|
11185
11130
|
// src/layers/schema/carto-tile.ts
|
|
11186
11131
|
var KeyValueObjectReader = class {
|
|
@@ -11680,7 +11625,7 @@ ${formatErrorKey(key)}: ${errorContext[key]}`;
|
|
|
11680
11625
|
}
|
|
11681
11626
|
|
|
11682
11627
|
// src/layers/carto-tile-layer.ts
|
|
11683
|
-
registerLoaders([carto_vector_tile_loader_default]);
|
|
11628
|
+
(0, import_core.registerLoaders)([carto_vector_tile_loader_default]);
|
|
11684
11629
|
var defaultTileFormat = TILE_FORMATS.BINARY;
|
|
11685
11630
|
var defaultProps = {
|
|
11686
11631
|
...import_geo_layers.MVTLayer.defaultProps,
|
|
@@ -11864,6 +11809,9 @@ ${formatErrorKey(key)}: ${errorContext[key]}`;
|
|
|
11864
11809
|
}
|
|
11865
11810
|
};
|
|
11866
11811
|
|
|
11812
|
+
// src/layers/spatial-index-tile-layer.ts
|
|
11813
|
+
var import_core2 = __toESM(require_core2());
|
|
11814
|
+
|
|
11867
11815
|
// src/layers/schema/carto-spatial-tile.ts
|
|
11868
11816
|
var IndicesReader = class {
|
|
11869
11817
|
static read(pbf, end) {
|
|
@@ -12057,7 +12005,7 @@ ${formatErrorKey(key)}: ${errorContext[key]}`;
|
|
|
12057
12005
|
|
|
12058
12006
|
// src/layers/spatial-index-tile-layer.ts
|
|
12059
12007
|
var import_geo_layers3 = __toESM(require_geo_layers());
|
|
12060
|
-
registerLoaders([carto_spatial_tile_loader_default]);
|
|
12008
|
+
(0, import_core2.registerLoaders)([carto_spatial_tile_loader_default]);
|
|
12061
12009
|
function isFeatureIdDefined(value) {
|
|
12062
12010
|
return value !== void 0 && value !== null && value !== "";
|
|
12063
12011
|
}
|
|
@@ -12397,7 +12345,7 @@ ${formatErrorKey(key)}: ${errorContext[key]}`;
|
|
|
12397
12345
|
|
|
12398
12346
|
// src/utils.ts
|
|
12399
12347
|
var import_core5 = __toESM(require_core());
|
|
12400
|
-
function
|
|
12348
|
+
function assert2(condition, message) {
|
|
12401
12349
|
import_core5.log.assert(condition, message);
|
|
12402
12350
|
}
|
|
12403
12351
|
|
|
@@ -12582,7 +12530,7 @@ ${formatErrorKey(key)}: ${errorContext[key]}`;
|
|
|
12582
12530
|
}
|
|
12583
12531
|
};
|
|
12584
12532
|
const layer = layerTypeDefs[type];
|
|
12585
|
-
|
|
12533
|
+
assert2(layer, `Unsupported layer type: ${type}`);
|
|
12586
12534
|
return {
|
|
12587
12535
|
...layer,
|
|
12588
12536
|
propMap: mergePropMaps(basePropMap, layer.propMap),
|
|
@@ -12863,7 +12811,7 @@ ${formatErrorKey(key)}: ${errorContext[key]}`;
|
|
|
12863
12811
|
datasets,
|
|
12864
12812
|
token
|
|
12865
12813
|
} = json;
|
|
12866
|
-
|
|
12814
|
+
assert2(keplerMapConfig.version === "v1", "Only support Kepler v1");
|
|
12867
12815
|
const {
|
|
12868
12816
|
mapState,
|
|
12869
12817
|
mapStyle
|
|
@@ -12893,11 +12841,11 @@ ${formatErrorKey(key)}: ${errorContext[key]}`;
|
|
|
12893
12841
|
dataId
|
|
12894
12842
|
} = config;
|
|
12895
12843
|
const dataset = datasets.find((d) => d.id === dataId);
|
|
12896
|
-
|
|
12844
|
+
assert2(dataset, `No dataset matching dataId: ${dataId}`);
|
|
12897
12845
|
const {
|
|
12898
12846
|
data
|
|
12899
12847
|
} = dataset;
|
|
12900
|
-
|
|
12848
|
+
assert2(data, `No data loaded for dataId: ${dataId}`);
|
|
12901
12849
|
const {
|
|
12902
12850
|
Layer,
|
|
12903
12851
|
propMap,
|
|
@@ -13372,20 +13320,20 @@ ${formatErrorKey(key)}: ${errorContext[key]}`;
|
|
|
13372
13320
|
aggregationExp,
|
|
13373
13321
|
aggregationResLevel
|
|
13374
13322
|
}) {
|
|
13375
|
-
|
|
13376
|
-
|
|
13377
|
-
|
|
13378
|
-
|
|
13379
|
-
|
|
13380
|
-
|
|
13323
|
+
assert2(connection, "Must define connection");
|
|
13324
|
+
assert2(type, "Must define a type");
|
|
13325
|
+
assert2(source, "Must define a source");
|
|
13326
|
+
assert2(credentials2.apiVersion === API_VERSIONS.V3, "Method only available for v3");
|
|
13327
|
+
assert2(credentials2.apiBaseUrl, "Must define apiBaseUrl");
|
|
13328
|
+
assert2(credentials2.accessToken, "Must define an accessToken");
|
|
13381
13329
|
if (columns) {
|
|
13382
|
-
|
|
13330
|
+
assert2(COLUMNS_SUPPORT.includes(type), `The columns parameter is not supported by type ${type}`);
|
|
13383
13331
|
}
|
|
13384
13332
|
if (geoColumn) {
|
|
13385
|
-
|
|
13333
|
+
assert2(GEO_COLUMN_SUPPORT.includes(type), `The geoColumn parameter is not supported by type ${type}`);
|
|
13386
13334
|
} else {
|
|
13387
|
-
|
|
13388
|
-
|
|
13335
|
+
assert2(!aggregationExp, "Have aggregationExp, but geoColumn parameter is missing");
|
|
13336
|
+
assert2(!aggregationResLevel, "Have aggregationResLevel, but geoColumn parameter is missing");
|
|
13389
13337
|
}
|
|
13390
13338
|
}
|
|
13391
13339
|
async function fetchLayerData({
|
|
@@ -13493,7 +13441,7 @@ ${formatErrorKey(key)}: ${errorContext[key]}`;
|
|
|
13493
13441
|
if (format2) {
|
|
13494
13442
|
mapFormat = format2;
|
|
13495
13443
|
url = getUrlFromMetadata(metadata, format2);
|
|
13496
|
-
|
|
13444
|
+
assert2(url, `Format ${format2} not available`);
|
|
13497
13445
|
} else {
|
|
13498
13446
|
const prioritizedFormats = [FORMATS.GEOJSON, FORMATS.JSON, FORMATS.NDJSON, FORMATS.TILEJSON];
|
|
13499
13447
|
for (const f of prioritizedFormats) {
|
|
@@ -13503,7 +13451,7 @@ ${formatErrorKey(key)}: ${errorContext[key]}`;
|
|
|
13503
13451
|
break;
|
|
13504
13452
|
}
|
|
13505
13453
|
}
|
|
13506
|
-
|
|
13454
|
+
assert2(url && mapFormat, "Unsupported data formats received from backend.");
|
|
13507
13455
|
}
|
|
13508
13456
|
if (format2 === FORMATS.TILEJSON && formatTiles) {
|
|
13509
13457
|
import_core7.log.assert(Object.values(TILE_FORMATS).includes(formatTiles), `Invalid value for formatTiles: ${formatTiles}. Use value from TILE_FORMATS`);
|
|
@@ -13663,16 +13611,16 @@ ${formatErrorKey(key)}: ${errorContext[key]}`;
|
|
|
13663
13611
|
const {
|
|
13664
13612
|
accessToken
|
|
13665
13613
|
} = localCreds;
|
|
13666
|
-
|
|
13667
|
-
|
|
13668
|
-
|
|
13614
|
+
assert2(cartoMapId, 'Must define CARTO map id: fetchMap({cartoMapId: "XXXX-XXXX-XXXX"})');
|
|
13615
|
+
assert2(localCreds.apiVersion === API_VERSIONS.V3, "Method only available for v3");
|
|
13616
|
+
assert2(localCreds.apiBaseUrl, "Must define apiBaseUrl");
|
|
13669
13617
|
if (!localCreds.mapsUrl) {
|
|
13670
13618
|
localCreds.mapsUrl = buildMapsUrlFromBase(localCreds.apiBaseUrl);
|
|
13671
13619
|
}
|
|
13672
13620
|
if (autoRefresh || onNewData) {
|
|
13673
|
-
|
|
13674
|
-
|
|
13675
|
-
|
|
13621
|
+
assert2(onNewData, "Must define `onNewData` when using autoRefresh");
|
|
13622
|
+
assert2(typeof onNewData === "function", "`onNewData` must be a function");
|
|
13623
|
+
assert2(typeof autoRefresh === "number" && autoRefresh > 0, "`autoRefresh` must be a positive number");
|
|
13676
13624
|
}
|
|
13677
13625
|
const url = `${localCreds.mapsUrl}/public/${cartoMapId}`;
|
|
13678
13626
|
const errorContext = {
|
|
@@ -13733,13 +13681,11 @@ ${formatErrorKey(key)}: ${errorContext[key]}`;
|
|
|
13733
13681
|
onDataLoad: {
|
|
13734
13682
|
type: "function",
|
|
13735
13683
|
value: (data) => {
|
|
13736
|
-
}
|
|
13737
|
-
compare: false
|
|
13684
|
+
}
|
|
13738
13685
|
},
|
|
13739
13686
|
onDataError: {
|
|
13740
13687
|
type: "function",
|
|
13741
13688
|
value: null,
|
|
13742
|
-
compare: false,
|
|
13743
13689
|
optional: true
|
|
13744
13690
|
},
|
|
13745
13691
|
uniqueIdProperty: "cartodb_id",
|
|
@@ -13874,7 +13820,7 @@ ${formatErrorKey(key)}: ${errorContext[key]}`;
|
|
|
13874
13820
|
}
|
|
13875
13821
|
}
|
|
13876
13822
|
_getSubLayerAndProps() {
|
|
13877
|
-
|
|
13823
|
+
assert2(this.state);
|
|
13878
13824
|
const {
|
|
13879
13825
|
data,
|
|
13880
13826
|
apiVersion
|
|
@@ -13898,7 +13844,7 @@ ${formatErrorKey(key)}: ${errorContext[key]}`;
|
|
|
13898
13844
|
return [layerFromTileDataset(props.formatTiles, data.scheme), props];
|
|
13899
13845
|
}
|
|
13900
13846
|
renderLayers() {
|
|
13901
|
-
|
|
13847
|
+
assert2(this.state);
|
|
13902
13848
|
const {
|
|
13903
13849
|
apiVersion,
|
|
13904
13850
|
data
|
|
@@ -13953,14 +13899,14 @@ ${formatErrorKey(key)}: ${errorContext[key]}`;
|
|
|
13953
13899
|
// src/style/utils.ts
|
|
13954
13900
|
var ALLOWED_ATTR_TYPES = Object.freeze(["function", "string"]);
|
|
13955
13901
|
function getAttrValue(attr, d) {
|
|
13956
|
-
|
|
13957
|
-
|
|
13902
|
+
assert3(typeof d === "object", 'Expected "data" to be an object');
|
|
13903
|
+
assert3(ALLOWED_ATTR_TYPES.includes(typeof attr), 'Expected "attr" to be a function or string');
|
|
13958
13904
|
if (typeof attr === "function") {
|
|
13959
13905
|
return attr(d);
|
|
13960
13906
|
}
|
|
13961
13907
|
return d?.properties?.[attr];
|
|
13962
13908
|
}
|
|
13963
|
-
function
|
|
13909
|
+
function assert3(condition, message = "") {
|
|
13964
13910
|
if (!condition) {
|
|
13965
13911
|
throw new Error(`CARTO style error: ${message}`);
|
|
13966
13912
|
}
|
|
@@ -13973,7 +13919,7 @@ ${formatErrorKey(key)}: ${errorContext[key]}`;
|
|
|
13973
13919
|
function getPalette(name, numCategories) {
|
|
13974
13920
|
const palette = cartoColors[name];
|
|
13975
13921
|
let paletteIndex = numCategories;
|
|
13976
|
-
|
|
13922
|
+
assert3(palette, `Palette "${name}" not found. Expected a CARTOColors string`);
|
|
13977
13923
|
const palettesColorVariants = Object.keys(palette).filter((p) => p !== "tags").map(Number);
|
|
13978
13924
|
const longestPaletteIndex = Math.max(...palettesColorVariants);
|
|
13979
13925
|
const smallestPaletteIndex = Math.min(...palettesColorVariants);
|
|
@@ -14002,7 +13948,7 @@ ${formatErrorKey(key)}: ${errorContext[key]}`;
|
|
|
14002
13948
|
return [parseInt(result[1], 16), parseInt(result[2], 16), parseInt(result[3], 16), 255];
|
|
14003
13949
|
}
|
|
14004
13950
|
result = /^#?([a-f\d]{2})([a-f\d]{2})([a-f\d]{2})([a-f\d]{2})$/i.exec(hex2);
|
|
14005
|
-
|
|
13951
|
+
assert3(result, `Hexadecimal color "${hex2}" was not parsed correctly`);
|
|
14006
13952
|
return [parseInt(result[1], 16), parseInt(result[2], 16), parseInt(result[3], 16), parseInt(result[4], 16)];
|
|
14007
13953
|
}
|
|
14008
13954
|
|
|
@@ -14013,7 +13959,7 @@ ${formatErrorKey(key)}: ${errorContext[key]}`;
|
|
|
14013
13959
|
colors = DEFAULT_PALETTE,
|
|
14014
13960
|
nullColor = NULL_COLOR
|
|
14015
13961
|
}) {
|
|
14016
|
-
|
|
13962
|
+
assert3(Array.isArray(domain), 'Expected "domain" to be an array of numbers');
|
|
14017
13963
|
const palette = typeof colors === "string" ? getPalette(colors, domain.length + 1) : colors;
|
|
14018
13964
|
const color2 = threshold().domain(domain).range(palette);
|
|
14019
13965
|
return (d) => {
|
|
@@ -14030,7 +13976,7 @@ ${formatErrorKey(key)}: ${errorContext[key]}`;
|
|
|
14030
13976
|
nullColor = NULL_COLOR,
|
|
14031
13977
|
othersColor = OTHERS_COLOR
|
|
14032
13978
|
}) {
|
|
14033
|
-
|
|
13979
|
+
assert3(Array.isArray(domain), 'Expected "domain" to be an array of numbers or strings');
|
|
14034
13980
|
const colorsByCategory = {};
|
|
14035
13981
|
const palette = typeof colors === "string" ? getPalette(colors, domain.length) : colors;
|
|
14036
13982
|
for (const [i, c] of domain.entries()) {
|
|
@@ -14049,7 +13995,7 @@ ${formatErrorKey(key)}: ${errorContext[key]}`;
|
|
|
14049
13995
|
colors = DEFAULT_PALETTE,
|
|
14050
13996
|
nullColor = NULL_COLOR
|
|
14051
13997
|
}) {
|
|
14052
|
-
|
|
13998
|
+
assert3(Array.isArray(domain), 'Expected "domain" to be an array of numbers');
|
|
14053
13999
|
const palette = typeof colors === "string" ? getPalette(colors, domain.length) : colors;
|
|
14054
14000
|
const color2 = linear2().domain(domain).range(palette);
|
|
14055
14001
|
return (d) => {
|
|
@@ -14071,3 +14017,5 @@ ${formatErrorKey(key)}: ${errorContext[key]}`;
|
|
|
14071
14017
|
var carto = src_exports;
|
|
14072
14018
|
return __toCommonJS(bundle_exports);
|
|
14073
14019
|
})();
|
|
14020
|
+
return __exports__;
|
|
14021
|
+
});
|
|
@@ -59,13 +59,11 @@ var defaultProps = {
|
|
|
59
59
|
type: null,
|
|
60
60
|
onDataLoad: {
|
|
61
61
|
type: 'function',
|
|
62
|
-
value: function value(data) {}
|
|
63
|
-
compare: false
|
|
62
|
+
value: function value(data) {}
|
|
64
63
|
},
|
|
65
64
|
onDataError: {
|
|
66
65
|
type: 'function',
|
|
67
66
|
value: null,
|
|
68
|
-
compare: false,
|
|
69
67
|
optional: true
|
|
70
68
|
},
|
|
71
69
|
uniqueIdProperty: 'cartodb_id',
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../src/layers/carto-layer.ts"],"names":["defaultProps","data","type","onDataLoad","value","compare","onDataError","optional","uniqueIdProperty","credentials","connection","format","formatTiles","clientId","geoColumn","columns","headers","aggregationExp","aggregationResLevel","queryParameters","CartoLayer","state","apiVersion","getSubLayers","length","props","localCreds","log","assert","Object","values","API_VERSIONS","includes","V1","V2","MAP_TYPES","QUERY","TILESET","V3","COLUMNS_SUPPORT","join","GEO_COLUMN_SUPPORT","Array","isArray","oldProps","changeFlags","_checkProps","shouldUpdateData","dataChanged","JSON","stringify","setState","_updateData","source","rest","localConfig","result","FORMATS","TILEJSON","propName","layer","_notUsed","propsNoData","MVTLayer","tileUrl","URL","tiles","searchParams","get","scheme","updateTriggers","loadOptions","accessToken","fetch","Authorization","_getSubLayerAndProps","getSubLayerProps","id","layerName","CompositeLayer"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;;AASA;;AACA;;AAEA;;AACA;;AASA;;AAOA;;;;;;;;;;;;;AAEA,IAAMA,YAAY,GAAG;AAEnBC,EAAAA,IAAI,EAAE,IAFa;AAInBC,EAAAA,IAAI,EAAE,IAJa;AAKnBC,EAAAA,UAAU,EAAE;AAACD,IAAAA,IAAI,EAAE,UAAP;AAAmBE,IAAAA,KAAK,EAAE,eAAAH,IAAI,EAAI,CAAE,CAApC;AAAsCI,IAAAA,OAAO,EAAE;AAA/C,GALO;AAMnBC,EAAAA,WAAW,EAAE;AAACJ,IAAAA,IAAI,EAAE,UAAP;AAAmBE,IAAAA,KAAK,EAAE,IAA1B;AAAgCC,IAAAA,OAAO,EAAE,KAAzC;AAAgDE,IAAAA,QAAQ,EAAE;AAA1D,GANM;AAOnBC,EAAAA,gBAAgB,EAAE,YAPC;AAUnBC,EAAAA,WAAW,EAAE,IAVM;AAgBnBC,EAAAA,UAAU,EAAE,IAhBO;AAmBnBC,EAAAA,MAAM,EAAE,IAnBW;AAsBnBC,EAAAA,WAAW,EAAE,IAtBM;AAyBnBC,EAAAA,QAAQ,EAAE,IAzBS;AA4BnBC,EAAAA,SAAS,EAAE,IA5BQ;AA+BnBC,EAAAA,OAAO,EAAE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,EAAE,kBAAWjB,KAAK,CAACkB,SAAjB,CADkB;AAEpB7E,QAAAA,IAAI,EAAJA,IAFoB;AAGpBsE,QAAAA,WAAW,EAAXA,WAHoB;AAIpBD,QAAAA,cAAc,EAAdA;AAJoB,OAAtB,CAFK,CAAP;AASD;;;EArKiES,oB;;;8BAA/C3D,U,eAGA,Y;8BAHAA,U,kBAIGpB,Y","sourcesContent":["import {\n CompositeLayer,\n CompositeLayerProps,\n Layer,\n LayerProps,\n log,\n UpdateParameters\n} from '@deck.gl/core';\n\nimport {MVTLayer} from '@deck.gl/geo-layers';\nimport {fetchLayerData, getDataV2, API_VERSIONS} from '../api';\nimport {CartoAPIError} from '../api/carto-api-error';\nimport {layerFromTileDataset} from '../api/layer-map';\nimport {\n COLUMNS_SUPPORT,\n FORMATS,\n GEO_COLUMN_SUPPORT,\n MapType,\n MAP_TYPES,\n TileFormat,\n QueryParameters\n} from '../api/maps-api-common';\nimport {\n ClassicCredentials,\n CloudNativeCredentials,\n Credentials,\n getDefaultCredentials\n} from '../config';\nimport {FetchLayerDataResult, Headers} from '../api/maps-v3-client';\nimport {assert} from '../utils';\n\nconst defaultProps = {\n // (String, required): data resource to load. table name, sql query or tileset name.\n data: null,\n // (Enum (MAP_TYPES), required)\n type: null,\n onDataLoad: {type: 'function', value: data => {}, compare: false},\n onDataError: {type: 'function', value: null, compare: false, optional: true},\n uniqueIdProperty: 'cartodb_id',\n\n // override carto credentials for the layer, set to null to read from default\n credentials: null,\n\n /*********************/\n /* API v3 PARAMETERS */\n /**********************/\n // (String, required): connection name at CARTO platform\n connection: null,\n\n // (String, optional): format of data\n format: null,\n\n // (String, optional): force format of data for tiles\n formatTiles: null,\n\n // (String, optional): clientId identifier used for internal tracing, place here a string to identify the client who is doing the request.\n clientId: null,\n\n // (String, optional): name of the `geo_column` in the CARTO platform. Use this override the default column ('geom'), from which the geometry information should be fetched.\n geoColumn: null,\n\n // (Array<String>, optional): names of columns to fetch. By default, all columns are fetched.\n columns: {type: 'array', value: null},\n\n // (Headers, optional): Custom headers to include in the map instantiation request.\n headers: {type: 'object', value: {}, optional: true},\n\n // (String, optional): aggregation SQL expression. Only used for spatial index datasets\n aggregationExp: null,\n\n // (Number, optional): aggregation resolution level. Only used for spatial index datasets, defaults to 6 for quadbins, 4 for h3\n aggregationResLevel: null,\n\n // (QueryParameters, optional): query parameters to be sent to the server.\n queryParameters: null\n};\n\n/** All properties supported by CartoLayer. */\nexport type CartoLayerProps<DataT = any> = _CartoLayerProps & CompositeLayerProps<DataT>;\n\n/** Properties added by CartoLayer. */\ntype _CartoLayerProps = {\n /**\n * Either a SQL query or a name of dataset/tileset.\n */\n data: string;\n\n /**\n * Data type.\n *\n * Possible values are:\n * * `MAP_TYPES.QUERY`, if data is a SQL query.\n * * `MAP_TYPES.TILESET`, if data is a tileset name.\n * * `MAP_TYPES.TABLE`, if data is a dataset name. Only supported with API v3.\n */\n type: MapType;\n\n /**\n * Name of the connection registered in the CARTO workspace.\n *\n * Required when apiVersion is `API_VERSIONS.V3`.\n */\n connection?: string;\n\n /**\n * Use to override the default tile data format.\n *\n * Only supported when apiVersion is `API_VERSIONS.V3`.\n *\n * Possible values are: `TILE_FORMATS.BINARY`, `TILE_FORMATS.GEOJSON` and `TILE_FORMATS.MVT`.\n */\n formatTiles?: TileFormat;\n\n /**\n * Name of the geo_column in the CARTO platform.\n *\n * Use this override the default column (`'geom'`), from which the geometry information should be fetched.\n *\n * Only supported when apiVersion is `API_VERSIONS.V3` and type is `MAP_TYPES.TABLE`.\n */\n geoColumn?: string;\n\n /**\n * Names of columns to fetch.\n *\n * By default, all columns are fetched\n *\n * Only supported when apiVersion is `API_VERSIONS.V3` and type is `MAP_TYPES.TABLE`.\n */\n columns?: string[];\n\n /**\n * A string pointing to a unique attribute at the result of the query.\n *\n * A unique attribute is needed for highlighting with vector tiles when a feature is split across two or more tiles.\n */\n uniqueIdProperty?: string;\n\n /**\n * Optional. Overrides the configuration to connect with CARTO.\n *\n * @see Credentials\n */\n credentials?: Credentials;\n\n /**\n * Called when the request to the CARTO Maps API failed.\n *\n * By default the CartoAPIError is thrown.\n */\n onDataError?: (err: CartoAPIError) => void;\n\n clientId?: string;\n\n /** Custom headers to include in the map instantiation request **/\n headers?: Headers;\n\n /** Aggregation SQL expression. Only used for spatial index datasets **/\n aggregationExp?: string;\n\n /** Aggregation resolution level. Only used for spatial index datasets, defaults to 6 for quadbins, 4 for h3. **/\n aggregationResLevel?: number;\n\n /** Query parameters to be sent to the server. **/\n queryParameters?: QueryParameters;\n};\n\nexport default class CartoLayer<ExtraProps extends {} = {}> extends CompositeLayer<\n Required<_CartoLayerProps> & ExtraProps\n> {\n static layerName = 'CartoLayer';\n static defaultProps = defaultProps;\n\n initializeState(): void {\n this.state = {\n data: null,\n apiVersion: null\n };\n }\n\n get isLoaded(): boolean {\n return this.getSubLayers().length > 0 && super.isLoaded;\n }\n\n _checkProps(props: CartoLayerProps): void {\n const {type, credentials, connection, geoColumn, columns} = props;\n const localCreds = {...getDefaultCredentials(), ...credentials};\n const {apiVersion} = localCreds;\n\n log.assert(\n Object.values(API_VERSIONS).includes(apiVersion),\n `Invalid apiVersion ${apiVersion}. Use API_VERSIONS enum.`\n );\n\n if (apiVersion === API_VERSIONS.V1 || apiVersion === API_VERSIONS.V2) {\n log.assert(\n type === MAP_TYPES.QUERY || type === MAP_TYPES.TILESET,\n `Invalid type ${type}. Use type MAP_TYPES.QUERY or MAP_TYPES.TILESET for apiVersion ${apiVersion}`\n );\n log.assert(!connection, `Connection prop is not supported for apiVersion ${apiVersion}`);\n log.assert(!geoColumn, `geoColumn prop is not supported for apiVersion ${apiVersion}`);\n log.assert(!columns, `columns prop is not supported for apiVersion ${apiVersion}`);\n } else if (apiVersion === API_VERSIONS.V3) {\n log.assert(connection, 'Missing mandatory connection parameter');\n log.assert(\n Object.values(MAP_TYPES).includes(type),\n `Invalid type ${type}. Use MAP_TYPES enum.`\n );\n if (!COLUMNS_SUPPORT.includes(type)) {\n log.assert(!columns, `columns prop is only supported for types: ${COLUMNS_SUPPORT.join()}`);\n }\n if (!GEO_COLUMN_SUPPORT.includes(type)) {\n log.assert(\n !geoColumn,\n `geoColumn prop is only supported for types: ${GEO_COLUMN_SUPPORT.join()}`\n );\n }\n if (columns) {\n log.assert(Array.isArray(columns), 'columns prop must be an Array');\n }\n }\n }\n\n updateState({props, oldProps, changeFlags}: UpdateParameters<this>) {\n this._checkProps(props);\n const shouldUpdateData =\n changeFlags.dataChanged ||\n props.aggregationExp !== oldProps.aggregationExp ||\n props.aggregationResLevel !== oldProps.aggregationResLevel ||\n props.connection !== oldProps.connection ||\n props.geoColumn !== oldProps.geoColumn ||\n props.formatTiles !== oldProps.formatTiles ||\n props.type !== oldProps.type ||\n JSON.stringify(props.columns) !== JSON.stringify(oldProps.columns) ||\n JSON.stringify(props.credentials) !== JSON.stringify(oldProps.credentials) ||\n JSON.stringify(props.queryParameters) !== JSON.stringify(oldProps.queryParameters);\n\n if (shouldUpdateData) {\n this.setState({data: null, apiVersion: null});\n // eslint-disable-next-line @typescript-eslint/no-floating-promises\n this._updateData();\n }\n }\n\n async _updateData(): Promise<void> {\n try {\n const {type, data: source, credentials, connection, ...rest} = this.props;\n const localConfig = {...getDefaultCredentials(), ...credentials};\n const {apiVersion} = localConfig;\n\n let result: Partial<FetchLayerDataResult>;\n if (apiVersion === API_VERSIONS.V1 || apiVersion === API_VERSIONS.V2) {\n result = {\n data: await getDataV2({type, source, credentials: credentials as ClassicCredentials})\n };\n } else {\n result = await fetchLayerData({\n type,\n source,\n credentials: credentials as CloudNativeCredentials,\n connection,\n ...rest,\n // CartoLayer only supports tiled output from v8.8, force data format\n format: FORMATS.TILEJSON\n });\n }\n\n this.setState({...result, apiVersion});\n\n this.props.onDataLoad?.(result.data, {\n propName: 'data',\n layer: this\n });\n } catch (err) {\n if (this.props.onDataError) {\n this.props.onDataError(err as CartoAPIError);\n } else {\n throw err;\n }\n }\n }\n\n _getSubLayerAndProps(): [any, LayerProps] {\n assert(this.state);\n\n const {data, apiVersion} = this.state;\n\n const {uniqueIdProperty} = defaultProps;\n // eslint-disable-next-line @typescript-eslint/no-unused-vars\n const {data: _notUsed, ...propsNoData} = this.props;\n // @ts-expect-error 'uniqueIdProperty' is specified more than once, so this usage will be overwritten.\n const props = {uniqueIdProperty, ...propsNoData};\n\n if (apiVersion === API_VERSIONS.V1 || apiVersion === API_VERSIONS.V2) {\n return [MVTLayer, props];\n }\n\n /* global URL */\n const tileUrl = new URL(data.tiles[0]);\n props.formatTiles =\n props.formatTiles || (tileUrl.searchParams.get('formatTiles') as TileFormat);\n\n return [layerFromTileDataset(props.formatTiles, data.scheme), props];\n }\n\n renderLayers(): Layer | null {\n assert(this.state);\n\n const {apiVersion, data} = this.state;\n\n if (!data) return null;\n\n const {credentials, updateTriggers} = this.props;\n const loadOptions: any = {};\n if (apiVersion === API_VERSIONS.V3) {\n const localConfig = {...getDefaultCredentials(), ...credentials} as CloudNativeCredentials;\n const {accessToken} = localConfig;\n loadOptions.fetch = {headers: {Authorization: `Bearer ${accessToken}`}};\n }\n\n const [layer, props] = this._getSubLayerAndProps();\n\n // eslint-disable-next-line new-cap\n return new layer(\n props,\n this.getSubLayerProps({\n id: `carto-${layer.layerName}`,\n data,\n loadOptions,\n updateTriggers\n })\n );\n }\n}\n"],"file":"carto-layer.js"}
|
|
1
|
+
{"version":3,"sources":["../../../src/layers/carto-layer.ts"],"names":["defaultProps","data","type","onDataLoad","value","onDataError","optional","uniqueIdProperty","credentials","connection","format","formatTiles","clientId","geoColumn","columns","headers","aggregationExp","aggregationResLevel","queryParameters","CartoLayer","state","apiVersion","getSubLayers","length","props","localCreds","log","assert","Object","values","API_VERSIONS","includes","V1","V2","MAP_TYPES","QUERY","TILESET","V3","COLUMNS_SUPPORT","join","GEO_COLUMN_SUPPORT","Array","isArray","oldProps","changeFlags","_checkProps","shouldUpdateData","dataChanged","JSON","stringify","setState","_updateData","source","rest","localConfig","result","FORMATS","TILEJSON","propName","layer","_notUsed","propsNoData","MVTLayer","tileUrl","URL","tiles","searchParams","get","scheme","updateTriggers","loadOptions","accessToken","fetch","Authorization","_getSubLayerAndProps","getSubLayerProps","id","layerName","CompositeLayer"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;;AASA;;AACA;;AAEA;;AACA;;AASA;;AAOA;;;;;;;;;;;;;AAEA,IAAMA,YAAY,GAAG;AAEnBC,EAAAA,IAAI,EAAE,IAFa;AAInBC,EAAAA,IAAI,EAAE,IAJa;AAKnBC,EAAAA,UAAU,EAAE;AAACD,IAAAA,IAAI,EAAE,UAAP;AAAmBE,IAAAA,KAAK,EAAE,eAAAH,IAAI,EAAI,CAAE;AAApC,GALO;AAMnBI,EAAAA,WAAW,EAAE;AAACH,IAAAA,IAAI,EAAE,UAAP;AAAmBE,IAAAA,KAAK,EAAE,IAA1B;AAAgCE,IAAAA,QAAQ,EAAE;AAA1C,GANM;AAOnBC,EAAAA,gBAAgB,EAAE,YAPC;AAUnBC,EAAAA,WAAW,EAAE,IAVM;AAgBnBC,EAAAA,UAAU,EAAE,IAhBO;AAmBnBC,EAAAA,MAAM,EAAE,IAnBW;AAsBnBC,EAAAA,WAAW,EAAE,IAtBM;AAyBnBC,EAAAA,QAAQ,EAAE,IAzBS;AA4BnBC,EAAAA,SAAS,EAAE,IA5BQ;AA+BnBC,EAAAA,OAAO,EAAE;AAACZ,IAAAA,IAAI,EAAE,OAAP;AAAgBE,IAAAA,KAAK,EAAE;AAAvB,GA/BU;AAkCnBW,EAAAA,OAAO,EAAE;AAACb,IAAAA,IAAI,EAAE,QAAP;AAAiBE,IAAAA,KAAK,EAAE,EAAxB;AAA4BE,IAAAA,QAAQ,EAAE;AAAtC,GAlCU;AAqCnBU,EAAAA,cAAc,EAAE,IArCG;AAwCnBC,EAAAA,mBAAmB,EAAE,IAxCF;AA2CnBC,EAAAA,eAAe,EAAE;AA3CE,CAArB;;IAwIqBC,U;;;;;;;;;;;;WAMnB,2BAAwB;AACtB,WAA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AACb,WAA3B,EAAwCV,IAAI,CAACmE,MAA7C,CAAD,EAAuD5C,KAAvD,CAAP;AACD;;;WAED,wBAA6B;AAC3B,yBAAO,KAAKJ,KAAZ;AAEA,yBAA2B,KAAKA,KAAhC;AAAA,UAAOC,UAAP,gBAAOA,UAAP;AAAA,UAAmBpB,IAAnB,gBAAmBA,IAAnB;AAEA,UAAI,CAACA,IAAL,EAAW,OAAO,IAAP;AAEX,yBAAsC,KAAKuB,KAA3C;AAAA,UAAOhB,WAAP,gBAAOA,WAAP;AAAA,UAAoB6D,cAApB,gBAAoBA,cAApB;AACA,UAAMC,WAAgB,GAAG,EAAzB;;AACA,UAAIjD,UAAU,KAAKS,kBAAaO,EAAhC,EAAoC;AAClC,YAAMiB,WAAW,mCAAO,oCAAP,GAAmC9C,WAAnC,CAAjB;;AACA,YAAO+D,WAAP,GAAsBjB,WAAtB,CAAOiB,WAAP;AACAD,QAAAA,WAAW,CAACE,KAAZ,GAAoB;AAACzD,UAAAA,OAAO,EAAE;AAAC0D,YAAAA,aAAa,mBAAYF,WAAZ;AAAd;AAAV,SAApB;AACD;;AAED,kCAAuB,KAAKG,oBAAL,EAAvB;AAAA;AAAA,UAAOf,KAAP;AAAA,UAAcnC,KAAd;;AAGA,aAAO,IAAImC,KAAJ,CACLnC,KADK,EAEL,KAAKmD,gBAAL,CAAsB;AACpBC,QAAAA,EAAE,kBAAWjB,KAAK,CAACkB,SAAjB,CADkB;AAEpB5E,QAAAA,IAAI,EAAJA,IAFoB;AAGpBqE,QAAAA,WAAW,EAAXA,WAHoB;AAIpBD,QAAAA,cAAc,EAAdA;AAJoB,OAAtB,CAFK,CAAP;AASD;;;EArKiES,oB;;;8BAA/C3D,U,eAGA,Y;8BAHAA,U,kBAIGnB,Y","sourcesContent":["import {\n CompositeLayer,\n CompositeLayerProps,\n Layer,\n LayerProps,\n log,\n UpdateParameters\n} from '@deck.gl/core';\n\nimport {MVTLayer} from '@deck.gl/geo-layers';\nimport {fetchLayerData, getDataV2, API_VERSIONS} from '../api';\nimport {CartoAPIError} from '../api/carto-api-error';\nimport {layerFromTileDataset} from '../api/layer-map';\nimport {\n COLUMNS_SUPPORT,\n FORMATS,\n GEO_COLUMN_SUPPORT,\n MapType,\n MAP_TYPES,\n TileFormat,\n QueryParameters\n} from '../api/maps-api-common';\nimport {\n ClassicCredentials,\n CloudNativeCredentials,\n Credentials,\n getDefaultCredentials\n} from '../config';\nimport {FetchLayerDataResult, Headers} from '../api/maps-v3-client';\nimport {assert} from '../utils';\n\nconst defaultProps = {\n // (String, required): data resource to load. table name, sql query or tileset name.\n data: null,\n // (Enum (MAP_TYPES), required)\n type: null,\n onDataLoad: {type: 'function', value: data => {}},\n onDataError: {type: 'function', value: null, optional: true},\n uniqueIdProperty: 'cartodb_id',\n\n // override carto credentials for the layer, set to null to read from default\n credentials: null,\n\n /*********************/\n /* API v3 PARAMETERS */\n /**********************/\n // (String, required): connection name at CARTO platform\n connection: null,\n\n // (String, optional): format of data\n format: null,\n\n // (String, optional): force format of data for tiles\n formatTiles: null,\n\n // (String, optional): clientId identifier used for internal tracing, place here a string to identify the client who is doing the request.\n clientId: null,\n\n // (String, optional): name of the `geo_column` in the CARTO platform. Use this override the default column ('geom'), from which the geometry information should be fetched.\n geoColumn: null,\n\n // (Array<String>, optional): names of columns to fetch. By default, all columns are fetched.\n columns: {type: 'array', value: null},\n\n // (Headers, optional): Custom headers to include in the map instantiation request.\n headers: {type: 'object', value: {}, optional: true},\n\n // (String, optional): aggregation SQL expression. Only used for spatial index datasets\n aggregationExp: null,\n\n // (Number, optional): aggregation resolution level. Only used for spatial index datasets, defaults to 6 for quadbins, 4 for h3\n aggregationResLevel: null,\n\n // (QueryParameters, optional): query parameters to be sent to the server.\n queryParameters: null\n};\n\n/** All properties supported by CartoLayer. */\nexport type CartoLayerProps = _CartoLayerProps & CompositeLayerProps;\n\n/** Properties added by CartoLayer. */\ntype _CartoLayerProps = {\n /**\n * Either a SQL query or a name of dataset/tileset.\n */\n data: string;\n\n /**\n * Data type.\n *\n * Possible values are:\n * * `MAP_TYPES.QUERY`, if data is a SQL query.\n * * `MAP_TYPES.TILESET`, if data is a tileset name.\n * * `MAP_TYPES.TABLE`, if data is a dataset name. Only supported with API v3.\n */\n type: MapType;\n\n /**\n * Name of the connection registered in the CARTO workspace.\n *\n * Required when apiVersion is `API_VERSIONS.V3`.\n */\n connection?: string;\n\n /**\n * Use to override the default tile data format.\n *\n * Only supported when apiVersion is `API_VERSIONS.V3`.\n *\n * Possible values are: `TILE_FORMATS.BINARY`, `TILE_FORMATS.GEOJSON` and `TILE_FORMATS.MVT`.\n */\n formatTiles?: TileFormat;\n\n /**\n * Name of the geo_column in the CARTO platform.\n *\n * Use this override the default column (`'geom'`), from which the geometry information should be fetched.\n *\n * Only supported when apiVersion is `API_VERSIONS.V3` and type is `MAP_TYPES.TABLE`.\n */\n geoColumn?: string;\n\n /**\n * Names of columns to fetch.\n *\n * By default, all columns are fetched\n *\n * Only supported when apiVersion is `API_VERSIONS.V3` and type is `MAP_TYPES.TABLE`.\n */\n columns?: string[];\n\n /**\n * A string pointing to a unique attribute at the result of the query.\n *\n * A unique attribute is needed for highlighting with vector tiles when a feature is split across two or more tiles.\n */\n uniqueIdProperty?: string;\n\n /**\n * Optional. Overrides the configuration to connect with CARTO.\n *\n * @see Credentials\n */\n credentials?: Credentials;\n\n /**\n * Called when the request to the CARTO Maps API failed.\n *\n * By default the CartoAPIError is thrown.\n */\n onDataError?: (err: CartoAPIError) => void;\n\n clientId?: string;\n\n /** Custom headers to include in the map instantiation request **/\n headers?: Headers;\n\n /** Aggregation SQL expression. Only used for spatial index datasets **/\n aggregationExp?: string;\n\n /** Aggregation resolution level. Only used for spatial index datasets, defaults to 6 for quadbins, 4 for h3. **/\n aggregationResLevel?: number;\n\n /** Query parameters to be sent to the server. **/\n queryParameters?: QueryParameters;\n};\n\nexport default class CartoLayer<ExtraProps extends {} = {}> extends CompositeLayer<\n Required<_CartoLayerProps> & ExtraProps\n> {\n static layerName = 'CartoLayer';\n static defaultProps = defaultProps;\n\n initializeState(): void {\n this.state = {\n data: null,\n apiVersion: null\n };\n }\n\n get isLoaded(): boolean {\n return this.getSubLayers().length > 0 && super.isLoaded;\n }\n\n _checkProps(props: CartoLayerProps): void {\n const {type, credentials, connection, geoColumn, columns} = props;\n const localCreds = {...getDefaultCredentials(), ...credentials};\n const {apiVersion} = localCreds;\n\n log.assert(\n Object.values(API_VERSIONS).includes(apiVersion),\n `Invalid apiVersion ${apiVersion}. Use API_VERSIONS enum.`\n );\n\n if (apiVersion === API_VERSIONS.V1 || apiVersion === API_VERSIONS.V2) {\n log.assert(\n type === MAP_TYPES.QUERY || type === MAP_TYPES.TILESET,\n `Invalid type ${type}. Use type MAP_TYPES.QUERY or MAP_TYPES.TILESET for apiVersion ${apiVersion}`\n );\n log.assert(!connection, `Connection prop is not supported for apiVersion ${apiVersion}`);\n log.assert(!geoColumn, `geoColumn prop is not supported for apiVersion ${apiVersion}`);\n log.assert(!columns, `columns prop is not supported for apiVersion ${apiVersion}`);\n } else if (apiVersion === API_VERSIONS.V3) {\n log.assert(connection, 'Missing mandatory connection parameter');\n log.assert(\n Object.values(MAP_TYPES).includes(type),\n `Invalid type ${type}. Use MAP_TYPES enum.`\n );\n if (!COLUMNS_SUPPORT.includes(type)) {\n log.assert(!columns, `columns prop is only supported for types: ${COLUMNS_SUPPORT.join()}`);\n }\n if (!GEO_COLUMN_SUPPORT.includes(type)) {\n log.assert(\n !geoColumn,\n `geoColumn prop is only supported for types: ${GEO_COLUMN_SUPPORT.join()}`\n );\n }\n if (columns) {\n log.assert(Array.isArray(columns), 'columns prop must be an Array');\n }\n }\n }\n\n updateState({props, oldProps, changeFlags}: UpdateParameters<this>) {\n this._checkProps(props);\n const shouldUpdateData =\n changeFlags.dataChanged ||\n props.aggregationExp !== oldProps.aggregationExp ||\n props.aggregationResLevel !== oldProps.aggregationResLevel ||\n props.connection !== oldProps.connection ||\n props.geoColumn !== oldProps.geoColumn ||\n props.formatTiles !== oldProps.formatTiles ||\n props.type !== oldProps.type ||\n JSON.stringify(props.columns) !== JSON.stringify(oldProps.columns) ||\n JSON.stringify(props.credentials) !== JSON.stringify(oldProps.credentials) ||\n JSON.stringify(props.queryParameters) !== JSON.stringify(oldProps.queryParameters);\n\n if (shouldUpdateData) {\n this.setState({data: null, apiVersion: null});\n // eslint-disable-next-line @typescript-eslint/no-floating-promises\n this._updateData();\n }\n }\n\n async _updateData(): Promise<void> {\n try {\n const {type, data: source, credentials, connection, ...rest} = this.props;\n const localConfig = {...getDefaultCredentials(), ...credentials};\n const {apiVersion} = localConfig;\n\n let result: Partial<FetchLayerDataResult>;\n if (apiVersion === API_VERSIONS.V1 || apiVersion === API_VERSIONS.V2) {\n result = {\n data: await getDataV2({type, source, credentials: credentials as ClassicCredentials})\n };\n } else {\n result = await fetchLayerData({\n type,\n source,\n credentials: credentials as CloudNativeCredentials,\n connection,\n ...rest,\n // CartoLayer only supports tiled output from v8.8, force data format\n format: FORMATS.TILEJSON\n });\n }\n\n this.setState({...result, apiVersion});\n\n this.props.onDataLoad?.(result.data, {\n propName: 'data',\n layer: this\n });\n } catch (err) {\n if (this.props.onDataError) {\n this.props.onDataError(err as CartoAPIError);\n } else {\n throw err;\n }\n }\n }\n\n _getSubLayerAndProps(): [any, LayerProps] {\n assert(this.state);\n\n const {data, apiVersion} = this.state;\n\n const {uniqueIdProperty} = defaultProps;\n // eslint-disable-next-line @typescript-eslint/no-unused-vars\n const {data: _notUsed, ...propsNoData} = this.props;\n // @ts-expect-error 'uniqueIdProperty' is specified more than once, so this usage will be overwritten.\n const props = {uniqueIdProperty, ...propsNoData};\n\n if (apiVersion === API_VERSIONS.V1 || apiVersion === API_VERSIONS.V2) {\n return [MVTLayer, props];\n }\n\n /* global URL */\n const tileUrl = new URL(data.tiles[0]);\n props.formatTiles =\n props.formatTiles || (tileUrl.searchParams.get('formatTiles') as TileFormat);\n\n return [layerFromTileDataset(props.formatTiles, data.scheme), props];\n }\n\n renderLayers(): Layer | null {\n assert(this.state);\n\n const {apiVersion, data} = this.state;\n\n if (!data) return null;\n\n const {credentials, updateTriggers} = this.props;\n const loadOptions: any = {};\n if (apiVersion === API_VERSIONS.V3) {\n const localConfig = {...getDefaultCredentials(), ...credentials} as CloudNativeCredentials;\n const {accessToken} = localConfig;\n loadOptions.fetch = {headers: {Authorization: `Bearer ${accessToken}`}};\n }\n\n const [layer, props] = this._getSubLayerAndProps();\n\n // eslint-disable-next-line new-cap\n return new layer(\n props,\n this.getSubLayerProps({\n id: `carto-${layer.layerName}`,\n data,\n loadOptions,\n updateTriggers\n })\n );\n }\n}\n"],"file":"carto-layer.js"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../src/layers/carto-tile-layer.ts"],"names":["CartoVectorTileLoader","defaultTileFormat","TILE_FORMATS","BINARY","defaultProps","MVTLayer","formatTiles","CartoTileLayer","binary","props","setState","tile","url","state","data","Promise","reject","loadOptions","getLoadOptions","fetch","signal","mimeType","propName","layer","tileBbox","bbox","west","south","east","north","subLayerProps","autoHighlight","extensions","ClipExtension","clipBounds","subLayer","GeoJsonLayer","params","info","index","sourceLayer","object","globalFeatureId"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;AAAA;;AACA;;AAIA;;AACA;;AAQA;;AACA;;AAEA;;;;;;;;;;AAfA,2BAAgB,CAACA,8BAAD,CAAhB;AAkBA,IAAMC,iBAAiB,GAAGC,4BAAaC,MAAvC;;AAEA,IAAMC,YAA+C,mCAChDC,oBAASD,YADuC;AAEnDE,EAAAA,WAAW,EAAEL;AAFsC,EAArD;;
|
|
1
|
+
{"version":3,"sources":["../../../src/layers/carto-tile-layer.ts"],"names":["CartoVectorTileLoader","defaultTileFormat","TILE_FORMATS","BINARY","defaultProps","MVTLayer","formatTiles","CartoTileLayer","binary","props","setState","tile","url","state","data","Promise","reject","loadOptions","getLoadOptions","fetch","signal","mimeType","propName","layer","tileBbox","bbox","west","south","east","north","subLayerProps","autoHighlight","extensions","ClipExtension","clipBounds","subLayer","GeoJsonLayer","params","info","index","sourceLayer","object","globalFeatureId"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;AAAA;;AACA;;AAIA;;AACA;;AAQA;;AACA;;AAEA;;;;;;;;;;AAfA,2BAAgB,CAACA,8BAAD,CAAhB;AAkBA,IAAMC,iBAAiB,GAAGC,4BAAaC,MAAvC;;AAEA,IAAMC,YAA+C,mCAChDC,oBAASD,YADuC;AAEnDE,EAAAA,WAAW,EAAEL;AAFsC,EAArD;;IAmBqBM,c;;;;;;;;;;;;WAMnB,2BAAwB;AACtB;AACA,UAAMC,MAAM,GAAG,KAAKC,KAAL,CAAWH,WAAX,KAA2BJ,4BAAaC,MAAvD;AACA,WAAKO,QAAL,CAAc;AAACF,QAAAA,MAAM,EAANA;AAAD,OAAd;AACD;;;WAED,qBAAYG,IAAZ,EAAiC;AAC/B,UAAMC,GAAG,GAAG,oCAAoB,KAAKC,KAAL,CAAWC,IAA/B,EAAqCH,IAArC,CAAZ;;AACA,UAAI,CAACC,GAAL,EAAU;AACR,eAAOG,OAAO,CAACC,MAAR,CAAe,aAAf,CAAP;AACD;;AAED,UAAIC,WAAW,GAAG,KAAKC,cAAL,EAAlB;AACA,wBAA6B,KAAKT,KAAlC;AAAA,UAAOU,KAAP,eAAOA,KAAP;AAAA,UAAcb,WAAd,eAAcA,WAAd;AACA,UAAOc,MAAP,GAAiBT,IAAjB,CAAOS,MAAP;;AAIA,UAAId,WAAW,KAAKJ,4BAAaC,MAAjC,EAAyC;AACvCc,QAAAA,WAAW,mCACNA,WADM;AAETI,UAAAA,QAAQ,EAAE;AAFD,UAAX;AAID;;AAED,aAAOF,KAAK,CAACP,GAAD,EAAM;AAACU,QAAAA,QAAQ,EAAE,MAAX;AAAmBC,QAAAA,KAAK,EAAE,IAA1B;AAAgCN,QAAAA,WAAW,EAAXA,WAAhC;AAA6CG,QAAAA,MAAM,EAANA;AAA7C,OAAN,CAAZ;AACD;;;W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carto-vector-tile-loader';\nregisterLoaders([CartoVectorTileLoader]);\n\nimport {DefaultProps} from '@deck.gl/core';\nimport {ClipExtension} from '@deck.gl/extensions';\nimport {\n MVTLayer,\n MVTLayerProps,\n TileLayer,\n _getURLFromTemplate,\n _Tile2DHeader,\n _TileLoadProps as TileLoadProps\n} from '@deck.gl/geo-layers';\nimport {GeoJsonLayer} from '@deck.gl/layers';\nimport {binaryToGeojson} from '@loaders.gl/gis';\nimport type {BinaryFeatures} from '@loaders.gl/schema';\nimport {TileFormat, TILE_FORMATS} from '../api/maps-api-common';\nimport type {Feature} from 'geojson';\n\nconst defaultTileFormat = TILE_FORMATS.BINARY;\n\nconst defaultProps: DefaultProps<CartoTileLayerProps> = {\n ...MVTLayer.defaultProps,\n formatTiles: defaultTileFormat\n};\n\n/** All properties supported by CartoTileLayer. */\nexport type CartoTileLayerProps = _CartoTileLayerProps & MVTLayerProps;\n\n/** Properties added by CartoTileLayer. */\ntype _CartoTileLayerProps = {\n /** Use to override the default tile data format.\n *\n * Possible values are: `TILE_FORMATS.BINARY`, `TILE_FORMATS.GEOJSON` and `TILE_FORMATS.MVT`.\n *\n * Only supported when `apiVersion` is `API_VERSIONS.V3` and `format` is `FORMATS.TILEJSON`.\n */\n formatTiles?: TileFormat;\n};\n\nexport default class CartoTileLayer<ExtraProps extends {} = {}> extends MVTLayer<\n Required<_CartoTileLayerProps> & ExtraProps\n> {\n static layerName = 'CartoTileLayer';\n static defaultProps = defaultProps;\n\n initializeState(): void {\n super.initializeState();\n const binary = this.props.formatTiles === TILE_FORMATS.BINARY;\n this.setState({binary});\n }\n\n getTileData(tile: TileLoadProps) {\n const url = _getURLFromTemplate(this.state.data, tile);\n if (!url) {\n return Promise.reject('Invalid URL');\n }\n\n let loadOptions = this.getLoadOptions();\n const {fetch, formatTiles} = this.props;\n const {signal} = tile;\n\n // The backend doesn't yet support our custom mime-type, so force it here\n // TODO remove once backend sends the correct mime-type\n if (formatTiles === TILE_FORMATS.BINARY) {\n loadOptions = {\n ...loadOptions,\n mimeType: 'application/vnd.carto-vector-tile'\n };\n }\n\n return fetch(url, {propName: 'data', layer: this, loadOptions, signal});\n }\n\n renderSubLayers(\n props: TileLayer['props'] & {\n id: string;\n data: any;\n _offset: number;\n tile: _Tile2DHeader;\n }\n ): GeoJsonLayer | null {\n if (props.data === null) {\n return null;\n }\n\n const tileBbox = props.tile.bbox as any;\n const {west, south, east, north} = tileBbox;\n\n const subLayerProps = {\n ...props,\n autoHighlight: false,\n extensions: [new ClipExtension(), ...(props.extensions || [])],\n clipBounds: [west, south, east, north]\n };\n\n const subLayer = new GeoJsonLayer(subLayerProps);\n return subLayer;\n }\n\n getPickingInfo(params) {\n const info = super.getPickingInfo(params);\n\n if (this.state.binary && info.index !== -1) {\n const {data} = params.sourceLayer!.props;\n info.object = binaryToGeojson(data as BinaryFeatures, {\n globalFeatureId: info.index\n }) as Feature;\n }\n\n return info;\n }\n}\n"],"file":"carto-tile-layer.js"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../src/layers/h3-tile-layer.ts"],"names":["renderSubLayers","props","data","index","tile","length","H3HexagonLayer","getHexagon","d","id","centerHexagon","highPrecision","defaultProps","aggregationResLevel","H3TileLayer","_checkH3Lib","setState","tileJSON","changeFlags","dataChanged","tiles","state","minresolution","parseInt","maxresolution","minZoom","Math","max","zoom","latitude","maxZoom","min","SpatialIndexTileLayer","TilesetClass","H3Tileset2D","loadOptions","getLoadOptions","cartoSpatialTile","scheme","CompositeLayer"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;AAAA;;AAQA;;AACA;;AACA;;;;;;;;;;;;;;AAEA,IAAMA,eAAe,GAAG,SAAlBA,eAAkB,CAAAC,KAAK,EAAI;AAC/B,MAAOC,IAAP,GAAeD,KAAf,CAAOC,IAAP;AACA,MAAOC,KAAP,GAAgBF,KAAK,CAACG,IAAtB,CAAOD,KAAP;AACA,MAAI,CAACD,IAAD,IAAS,CAACA,IAAI,CAACG,MAAnB,EAA2B,OAAO,IAAP;AAE3B,SAAO,IAAIC,yBAAJ,CAAmBL,KAAnB,EAA0B;AAC/BM,IAAAA,UAAU,EAAE,oBAAAC,CAAC;AAAA,aAAIA,CAAC,CAACC,EAAN;AAAA,KADkB;AAE/BC,IAAAA,aAAa,EAAEP,KAFgB;AAG/BQ,IAAAA,aAAa,EAAE;AAHgB,GAA1B,CAAP;AAKD,CAVD;;AAYA,IAAMC,YAA+C,GAAG;AACtDC,EAAAA,mBAAmB,EAAE;AADiC,CAAxD;;
|
|
1
|
+
{"version":3,"sources":["../../../src/layers/h3-tile-layer.ts"],"names":["renderSubLayers","props","data","index","tile","length","H3HexagonLayer","getHexagon","d","id","centerHexagon","highPrecision","defaultProps","aggregationResLevel","H3TileLayer","_checkH3Lib","setState","tileJSON","changeFlags","dataChanged","tiles","state","minresolution","parseInt","maxresolution","minZoom","Math","max","zoom","latitude","maxZoom","min","SpatialIndexTileLayer","TilesetClass","H3Tileset2D","loadOptions","getLoadOptions","cartoSpatialTile","scheme","CompositeLayer"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;AAAA;;AAQA;;AACA;;AACA;;;;;;;;;;;;;;AAEA,IAAMA,eAAe,GAAG,SAAlBA,eAAkB,CAAAC,KAAK,EAAI;AAC/B,MAAOC,IAAP,GAAeD,KAAf,CAAOC,IAAP;AACA,MAAOC,KAAP,GAAgBF,KAAK,CAACG,IAAtB,CAAOD,KAAP;AACA,MAAI,CAACD,IAAD,IAAS,CAACA,IAAI,CAACG,MAAnB,EAA2B,OAAO,IAAP;AAE3B,SAAO,IAAIC,yBAAJ,CAAmBL,KAAnB,EAA0B;AAC/BM,IAAAA,UAAU,EAAE,oBAAAC,CAAC;AAAA,aAAIA,CAAC,CAACC,EAAN;AAAA,KADkB;AAE/BC,IAAAA,aAAa,EAAEP,KAFgB;AAG/BQ,IAAAA,aAAa,EAAE;AAHgB,GAA1B,CAAP;AAKD,CAVD;;AAYA,IAAMC,YAA+C,GAAG;A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AAArC,SAArB,CAFc,CAAhB;AAID;;AAID,aAAO,CACL,IAAIG,8BAAJ,CAA0B,KAAK/B,KAA/B,EAAsC;AACpCQ,QAAAA,EAAE,0BAAmB,KAAKR,KAAL,CAAWQ,EAA9B,CADkC;AAEpCP,QAAAA,IAAI,EAAJA,IAFoC;AAIpC+B,QAAAA,YAAY,EAAEC,oBAJsB;AAKpClC,QAAAA,eAAe,EAAfA,eALoC;AAOpCyB,QAAAA,OAAO,EAAEH,aAP2B;AAQpCQ,QAAAA,OAAO,EAAEN,aAR2B;AASpCW,QAAAA,WAAW,kCACN,KAAKC,cAAL,EADM;AAETC,UAAAA,gBAAgB,EAAE;AAChBC,YAAAA,MAAM,EAAE;AADQ;AAFT;AATyB,OAAtC,CADK,CAAP;AAkBD;;;EAjEgFC,oB;;;8BAA9DzB,W,eAGA,a;8BAHAA,W,kBAIGF,Y","sourcesContent":["import {\n CompositeLayer,\n CompositeLayerProps,\n Layer,\n LayersList,\n UpdateParameters,\n DefaultProps\n} from '@deck.gl/core';\nimport {H3HexagonLayer} from '@deck.gl/geo-layers';\nimport H3Tileset2D, {getHexagonResolution} from './h3-tileset-2d';\nimport SpatialIndexTileLayer from './spatial-index-tile-layer';\n\nconst renderSubLayers = props => {\n const {data} = props;\n const {index} = props.tile;\n if (!data || !data.length) return null;\n\n return new H3HexagonLayer(props, {\n getHexagon: d => d.id,\n centerHexagon: index,\n highPrecision: true\n });\n};\n\nconst defaultProps: DefaultProps<H3HexagonLayerProps> = {\n aggregationResLevel: 4\n};\n\n/** All properties supported by H3TileLayer. */\nexport type H3TileLayerProps<DataT = any> = _H3TileLayerProps<DataT> & CompositeLayerProps;\n\n// TODO: use type from h3-hexagon-layer when available\n// eslint-disable-next-line @typescript-eslint/no-unused-vars\ntype H3HexagonLayerProps<DataT = any> = Record<string, any>;\n\n/** Properties added by H3TileLayer. */\ntype _H3TileLayerProps<DataT> = H3HexagonLayerProps<DataT> & {\n data: string;\n aggregationResLevel?: number;\n};\n\nexport default class H3TileLayer<DataT = any, ExtraPropsT extends {} = {}> extends CompositeLayer<\n ExtraPropsT & Required<_H3TileLayerProps<DataT>>\n> {\n static layerName = 'H3TileLayer';\n static defaultProps = defaultProps;\n\n state!: {\n tileJSON: any;\n data: any;\n };\n\n initializeState(): void {\n H3HexagonLayer._checkH3Lib();\n this.setState({data: null, tileJSON: null});\n }\n\n updateState({changeFlags}: UpdateParameters<this>): void {\n if (changeFlags.dataChanged) {\n let {data} = this.props;\n const tileJSON = data;\n data = (tileJSON as any).tiles;\n this.setState({data, tileJSON});\n }\n }\n\n renderLayers(): Layer | null | LayersList {\n const {data, tileJSON} = this.state;\n let minresolution = parseInt(tileJSON.minresolution);\n let maxresolution = parseInt(tileJSON.maxresolution);\n\n // Convert Mercator zooms provided in props into H3 res levels\n // and clip into valid range provided from the tilejson\n if (this.props.minZoom) {\n minresolution = Math.max(\n minresolution,\n getHexagonResolution({zoom: this.props.minZoom, latitude: 0})\n );\n }\n if (this.props.maxZoom) {\n maxresolution = Math.min(\n maxresolution,\n getHexagonResolution({zoom: this.props.maxZoom, latitude: 0})\n );\n }\n\n // The naming is unfortunate, but minZoom & maxZoom in the context\n // of a Tileset2D refer to the resolution levels, not the Mercator zooms\n return [\n new SpatialIndexTileLayer(this.props, {\n id: `h3-tile-layer-${this.props.id}`,\n data,\n // @ts-expect-error Tileset2D should be generic over TileIndex\n TilesetClass: H3Tileset2D,\n renderSubLayers,\n // minZoom and maxZoom are H3 resolutions, however we must use this naming as that is what the Tileset2D class expects\n minZoom: minresolution,\n maxZoom: maxresolution,\n loadOptions: {\n ...this.getLoadOptions(),\n cartoSpatialTile: {\n scheme: 'h3'\n }\n }\n })\n ];\n }\n}\n"],"file":"h3-tile-layer.js"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../src/layers/quadbin-tile-layer.ts"],"names":["renderSubLayers","props","data","length","isBigInt","id","QuadbinLayer","getQuadbin","d","defaultProps","aggregationResLevel","QuadbinTileLayer","setState","tileJSON","changeFlags","dataChanged","tiles","state","maxZoom","parseInt","maxresolution","SpatialIndexTileLayer","TilesetClass","QuadbinTileset2D","loadOptions","getLoadOptions","cartoSpatialTile","scheme","CompositeLayer"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;AAAA;;AAQA;;AACA;;AACA;;AACA;;;;;;;;;;AAEO,IAAMA,eAAe,GAAG,SAAlBA,eAAkB,CAAAC,KAAK,EAAI;AACtC,MAAOC,IAAP,GAAeD,KAAf,CAAOC,IAAP;AACA,MAAI,CAACA,IAAD,IAAS,CAACA,IAAI,CAACC,MAAnB,EAA2B,OAAO,IAAP;AAC3B,MAAMC,QAAQ,GAAG,OAAOF,IAAI,CAAC,CAAD,CAAJ,CAAQG,EAAf,KAAsB,QAAvC;AACA,SAAO,IAAIC,qBAAJ,CAAiBL,KAAjB,EAAwB;AAC7BM,IAAAA,UAAU,EAAEH,QAAQ,GAAG,UAAAI,CAAC;AAAA,aAAIA,CAAC,CAACH,EAAN;AAAA,KAAJ,GAAe,UAAAG,CAAC;AAAA,aAAI,0BAAYA,CAAC,CAACH,EAAd,CAAJ;AAAA;AADP,GAAxB,CAAP;AAGD,CAPM;;;AASP,IAAMI,YAAiD,GAAG;AACxDC,EAAAA,mBAAmB,EAAE;AADmC,CAA1D;;
|
|
1
|
+
{"version":3,"sources":["../../../src/layers/quadbin-tile-layer.ts"],"names":["renderSubLayers","props","data","length","isBigInt","id","QuadbinLayer","getQuadbin","d","defaultProps","aggregationResLevel","QuadbinTileLayer","setState","tileJSON","changeFlags","dataChanged","tiles","state","maxZoom","parseInt","maxresolution","SpatialIndexTileLayer","TilesetClass","QuadbinTileset2D","loadOptions","getLoadOptions","cartoSpatialTile","scheme","CompositeLayer"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;AAAA;;AAQA;;AACA;;AACA;;AACA;;;;;;;;;;AAEO,IAAMA,eAAe,GAAG,SAAlBA,eAAkB,CAAAC,KAAK,EAAI;AACtC,MAAOC,IAAP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,CAA0B,KAAKpB,KAA/B,EAAsC;AACpCI,QAAAA,EAAE,+BAAwB,KAAKJ,KAAL,CAAWI,EAAnC,CADkC;AAEpCH,QAAAA,IAAI,EAAJA,IAFoC;AAIpCoB,QAAAA,YAAY,EAAEC,yBAJsB;AAKpCvB,QAAAA,eAAe,EAAfA,eALoC;AAMpCkB,QAAAA,OAAO,EAAPA,OANoC;AAOpCM,QAAAA,WAAW,kCACN,KAAKC,cAAL,EADM;AAETC,UAAAA,gBAAgB,EAAE;AAChBC,YAAAA,MAAM,EAAE;AADQ;AAFT;AAPyB,OAAtC,CADK,CAAP;AAgBD;;;EAxCOC,oB;;;8BAHWjB,gB,eAIA,kB;8BAJAA,gB,kBAKGF,Y","sourcesContent":["import {\n CompositeLayer,\n CompositeLayerProps,\n Layer,\n LayersList,\n UpdateParameters,\n DefaultProps\n} from '@deck.gl/core';\nimport QuadbinLayer, {QuadbinLayerProps} from './quadbin-layer';\nimport QuadbinTileset2D from './quadbin-tileset-2d';\nimport SpatialIndexTileLayer from './spatial-index-tile-layer';\nimport {hexToBigInt} from 'quadbin';\n\nexport const renderSubLayers = props => {\n const {data} = props;\n if (!data || !data.length) return null;\n const isBigInt = typeof data[0].id === 'bigint';\n return new QuadbinLayer(props, {\n getQuadbin: isBigInt ? d => d.id : d => hexToBigInt(d.id)\n });\n};\n\nconst defaultProps: DefaultProps<QuadbinTileLayerProps> = {\n aggregationResLevel: 6\n};\n\n/** All properties supported by QuadbinTileLayer. */\nexport type QuadbinTileLayerProps<DataT = any> = _QuadbinTileLayerProps<DataT> &\n CompositeLayerProps;\n\n/** Properties added by QuadbinTileLayer. */\ntype _QuadbinTileLayerProps<DataT> = QuadbinLayerProps<DataT> & {\n data: string;\n aggregationResLevel?: number;\n};\n\nexport default class QuadbinTileLayer<\n DataT = any,\n ExtraProps extends {} = {}\n> extends CompositeLayer<ExtraProps & Required<_QuadbinTileLayerProps<DataT>>> {\n static layerName = 'QuadbinTileLayer';\n static defaultProps = defaultProps;\n\n state!: {\n tileJSON: any;\n data: any;\n };\n initializeState(): void {\n this.setState({data: null, tileJSON: null});\n }\n\n updateState({changeFlags}: UpdateParameters<this>): void {\n if (changeFlags.dataChanged) {\n let {data} = this.props;\n const tileJSON = data;\n data = (tileJSON as any).tiles;\n this.setState({data, tileJSON});\n }\n }\n\n renderLayers(): Layer | null | LayersList {\n const {data, tileJSON} = this.state;\n const maxZoom = parseInt(tileJSON?.maxresolution);\n return [\n new SpatialIndexTileLayer(this.props, {\n id: `quadbin-tile-layer-${this.props.id}`,\n data,\n // TODO: Tileset2D should be generic over TileIndex type\n TilesetClass: QuadbinTileset2D as any,\n renderSubLayers,\n maxZoom,\n loadOptions: {\n ...this.getLoadOptions(),\n cartoSpatialTile: {\n scheme: 'quadbin'\n }\n }\n })\n ];\n }\n}\n"],"file":"quadbin-tile-layer.js"}
|
|
@@ -11,13 +11,11 @@ const defaultProps = {
|
|
|
11
11
|
type: null,
|
|
12
12
|
onDataLoad: {
|
|
13
13
|
type: 'function',
|
|
14
|
-
value: data => {}
|
|
15
|
-
compare: false
|
|
14
|
+
value: data => {}
|
|
16
15
|
},
|
|
17
16
|
onDataError: {
|
|
18
17
|
type: 'function',
|
|
19
18
|
value: null,
|
|
20
|
-
compare: false,
|
|
21
19
|
optional: true
|
|
22
20
|
},
|
|
23
21
|
uniqueIdProperty: 'cartodb_id',
|