@carto/api-client 0.5.0-alpha.7 → 0.5.0-alpha.9
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/build/api-client.cjs +58 -45
- package/build/api-client.d.cts +61 -54
- package/build/api-client.d.ts +61 -54
- package/build/api-client.js +2091 -104
- package/build/worker.js +1929 -4
- package/package.json +5 -1
- package/src/sources/h3-tileset-source.ts +1 -8
- package/src/sources/quadbin-tileset-source.ts +1 -8
- package/src/sources/vector-tileset-source.ts +1 -8
- package/src/widget-sources/index.ts +0 -1
- package/src/widget-sources/widget-source.ts +11 -0
- package/src/widget-sources/widget-tileset-source-impl.ts +417 -0
- package/src/widget-sources/widget-tileset-source.ts +194 -330
- package/src/workers/widget-tileset-worker.ts +9 -8
- package/build/chunk-LEI5PI5X.js +0 -2063
- package/src/widget-sources/widget-tileset-worker-source.ts +0 -240
- package/src/workers/utils.ts +0 -33
package/build/api-client.cjs
CHANGED
|
@@ -433,7 +433,6 @@ __export(src_exports, {
|
|
|
433
433
|
WidgetSource: () => WidgetSource,
|
|
434
434
|
WidgetTableSource: () => WidgetTableSource,
|
|
435
435
|
WidgetTilesetSource: () => WidgetTilesetSource,
|
|
436
|
-
WidgetTilesetWorkerSource: () => WidgetTilesetWorkerSource,
|
|
437
436
|
_buildFeatureFilter: () => _buildFeatureFilter,
|
|
438
437
|
_getHexagonResolution: () => _getHexagonResolution,
|
|
439
438
|
addFilter: () => addFilter,
|
|
@@ -2105,6 +2104,15 @@ var _WidgetSource = class _WidgetSource {
|
|
|
2105
2104
|
__publicField(this, "props");
|
|
2106
2105
|
this.props = { ..._WidgetSource.defaultProps, ...props };
|
|
2107
2106
|
}
|
|
2107
|
+
/**
|
|
2108
|
+
* Destroys the widget source and releases allocated resources.
|
|
2109
|
+
*
|
|
2110
|
+
* For remote sources (tables, queries) this has no effect, but for local
|
|
2111
|
+
* sources (tilesets, rasters) these resources will affect performance
|
|
2112
|
+
* and stability if many (10+) sources are created and not released.
|
|
2113
|
+
*/
|
|
2114
|
+
destroy() {
|
|
2115
|
+
}
|
|
2108
2116
|
_getSpatialFiltersResolution(source, spatialFilter, referenceViewState) {
|
|
2109
2117
|
if (!spatialFilter || source.spatialDataType === "geo") {
|
|
2110
2118
|
return;
|
|
@@ -2639,6 +2647,9 @@ var WidgetTableSource = class extends WidgetRemoteSource {
|
|
|
2639
2647
|
// src/widget-sources/widget-tileset-source.ts
|
|
2640
2648
|
init_cjs_shims();
|
|
2641
2649
|
|
|
2650
|
+
// src/widget-sources/widget-tileset-source-impl.ts
|
|
2651
|
+
init_cjs_shims();
|
|
2652
|
+
|
|
2642
2653
|
// src/operations/aggregation.ts
|
|
2643
2654
|
init_cjs_shims();
|
|
2644
2655
|
var aggregationFunctions = {
|
|
@@ -2987,9 +2998,9 @@ function scatterPlot({
|
|
|
2987
2998
|
);
|
|
2988
2999
|
}
|
|
2989
3000
|
|
|
2990
|
-
// src/widget-sources/widget-tileset-source.ts
|
|
3001
|
+
// src/widget-sources/widget-tileset-source-impl.ts
|
|
2991
3002
|
var import_boolean_equal = require("@turf/boolean-equal");
|
|
2992
|
-
var
|
|
3003
|
+
var WidgetTilesetSourceImpl = class extends WidgetSource {
|
|
2993
3004
|
constructor() {
|
|
2994
3005
|
super(...arguments);
|
|
2995
3006
|
__publicField(this, "_tiles", []);
|
|
@@ -3274,39 +3285,54 @@ function normalizeColumns(columns) {
|
|
|
3274
3285
|
return Array.isArray(columns) ? columns : typeof columns === "string" ? [columns] : [];
|
|
3275
3286
|
}
|
|
3276
3287
|
|
|
3277
|
-
// src/widget-sources/widget-tileset-
|
|
3278
|
-
|
|
3279
|
-
var WidgetTilesetWorkerSource = class extends WidgetSource {
|
|
3288
|
+
// src/widget-sources/widget-tileset-source.ts
|
|
3289
|
+
var WidgetTilesetSource = class extends WidgetSource {
|
|
3280
3290
|
constructor(props) {
|
|
3281
3291
|
super(props);
|
|
3282
|
-
|
|
3283
|
-
|
|
3284
|
-
__publicField(this, "
|
|
3292
|
+
__publicField(this, "_localImpl", null);
|
|
3293
|
+
__publicField(this, "_workerImpl", null);
|
|
3294
|
+
__publicField(this, "_workerEnabled");
|
|
3285
3295
|
__publicField(this, "_workerNextRequestId", 1);
|
|
3296
|
+
this._workerEnabled = (props.widgetSourceWorker ?? true) && false;
|
|
3297
|
+
if (!this._workerEnabled) {
|
|
3298
|
+
this._localImpl = new WidgetTilesetSourceImpl(this.props);
|
|
3299
|
+
}
|
|
3286
3300
|
}
|
|
3301
|
+
destroy() {
|
|
3302
|
+
this._localImpl?.destroy();
|
|
3303
|
+
this._localImpl = null;
|
|
3304
|
+
this._workerImpl?.terminate();
|
|
3305
|
+
this._workerImpl = null;
|
|
3306
|
+
super.destroy();
|
|
3307
|
+
}
|
|
3308
|
+
/////////////////////////////////////////////////////////////////////////////
|
|
3309
|
+
// WEB WORKER MANAGEMENT
|
|
3287
3310
|
/**
|
|
3288
3311
|
* Returns an initialized Worker, to be reused for the lifecycle of this
|
|
3289
3312
|
* source instance.
|
|
3290
3313
|
*/
|
|
3291
3314
|
_getWorker() {
|
|
3292
|
-
if (this.
|
|
3293
|
-
return this.
|
|
3315
|
+
if (this._workerImpl) {
|
|
3316
|
+
return this._workerImpl;
|
|
3294
3317
|
}
|
|
3295
|
-
this.
|
|
3318
|
+
this._workerImpl = new Worker(
|
|
3296
3319
|
new URL("@carto/api-client/worker", importMetaUrl),
|
|
3297
3320
|
{
|
|
3298
3321
|
type: "module",
|
|
3299
3322
|
name: "cartowidgettileset"
|
|
3300
3323
|
}
|
|
3301
3324
|
);
|
|
3302
|
-
this.
|
|
3325
|
+
this._workerImpl.postMessage({
|
|
3303
3326
|
method: "init" /* INIT */,
|
|
3304
3327
|
params: [this.props]
|
|
3305
3328
|
});
|
|
3306
|
-
return this.
|
|
3329
|
+
return this._workerImpl;
|
|
3307
3330
|
}
|
|
3308
3331
|
/** Executes a given method on the worker. */
|
|
3309
3332
|
_executeWorkerMethod(method, params, signal) {
|
|
3333
|
+
if (!this._workerEnabled) {
|
|
3334
|
+
return this._localImpl[method](...params);
|
|
3335
|
+
}
|
|
3310
3336
|
const worker = this._getWorker();
|
|
3311
3337
|
const requestId = this._workerNextRequestId++;
|
|
3312
3338
|
const options = params[0];
|
|
@@ -3355,19 +3381,27 @@ var WidgetTilesetWorkerSource = class extends WidgetSource {
|
|
|
3355
3381
|
* before computing statistics on the tiles.
|
|
3356
3382
|
*/
|
|
3357
3383
|
loadTiles(tiles2) {
|
|
3384
|
+
if (!this._workerEnabled) {
|
|
3385
|
+
return this._localImpl.loadTiles(tiles2);
|
|
3386
|
+
}
|
|
3387
|
+
const worker = this._getWorker();
|
|
3358
3388
|
tiles2 = tiles2.map(({ id, bbox, data }) => ({
|
|
3359
3389
|
id,
|
|
3360
3390
|
bbox,
|
|
3361
3391
|
data
|
|
3362
3392
|
}));
|
|
3363
|
-
|
|
3393
|
+
worker.postMessage({
|
|
3364
3394
|
method: "loadTiles" /* LOAD_TILES */,
|
|
3365
3395
|
params: [tiles2]
|
|
3366
3396
|
});
|
|
3367
3397
|
}
|
|
3368
3398
|
/** Configures options used to extract features from tiles. */
|
|
3369
3399
|
setTileFeatureExtractOptions(options) {
|
|
3370
|
-
this.
|
|
3400
|
+
if (!this._workerEnabled) {
|
|
3401
|
+
return this._localImpl?.setTileFeatureExtractOptions(options);
|
|
3402
|
+
}
|
|
3403
|
+
const worker = this._getWorker();
|
|
3404
|
+
worker.postMessage({
|
|
3371
3405
|
type: "setTileFeatureExtractOptions" /* SET_TILE_FEATURE_EXTRACT_OPTIONS */,
|
|
3372
3406
|
params: [options]
|
|
3373
3407
|
});
|
|
@@ -3381,7 +3415,11 @@ var WidgetTilesetWorkerSource = class extends WidgetSource {
|
|
|
3381
3415
|
geojson,
|
|
3382
3416
|
spatialFilter
|
|
3383
3417
|
}) {
|
|
3384
|
-
this.
|
|
3418
|
+
if (!this._workerEnabled) {
|
|
3419
|
+
return this._localImpl.loadGeoJSON({ geojson, spatialFilter });
|
|
3420
|
+
}
|
|
3421
|
+
const worker = this._getWorker();
|
|
3422
|
+
worker.postMessage({
|
|
3385
3423
|
method: "loadGeoJSON" /* LOAD_GEOJSON */,
|
|
3386
3424
|
params: [{ geojson, spatialFilter }]
|
|
3387
3425
|
});
|
|
@@ -3521,36 +3559,14 @@ function getTileFormat(tilejson) {
|
|
|
3521
3559
|
return tileParams.get("formatTiles") === "mvt" ? "mvt" /* MVT */ : "binary" /* BINARY */;
|
|
3522
3560
|
}
|
|
3523
3561
|
|
|
3524
|
-
// src/workers/utils.ts
|
|
3525
|
-
init_cjs_shims();
|
|
3526
|
-
var _isModuleWorkerSupported = true ? false : null;
|
|
3527
|
-
function isModuleWorkerSupported() {
|
|
3528
|
-
if (_isModuleWorkerSupported !== null) {
|
|
3529
|
-
return _isModuleWorkerSupported;
|
|
3530
|
-
}
|
|
3531
|
-
try {
|
|
3532
|
-
new Worker("blob://", {
|
|
3533
|
-
get type() {
|
|
3534
|
-
_isModuleWorkerSupported = true;
|
|
3535
|
-
return "module";
|
|
3536
|
-
}
|
|
3537
|
-
});
|
|
3538
|
-
} catch {
|
|
3539
|
-
} finally {
|
|
3540
|
-
_isModuleWorkerSupported || (_isModuleWorkerSupported = false);
|
|
3541
|
-
}
|
|
3542
|
-
return _isModuleWorkerSupported;
|
|
3543
|
-
}
|
|
3544
|
-
|
|
3545
3562
|
// src/sources/h3-tileset-source.ts
|
|
3546
3563
|
var h3TilesetSource = async function(options) {
|
|
3547
3564
|
const { tableName, spatialDataColumn = "h3" } = options;
|
|
3548
3565
|
const urlParameters = { name: tableName };
|
|
3549
|
-
const WidgetSourceClass = options.widgetSourceWorker !== false && isModuleWorkerSupported() ? WidgetTilesetWorkerSource : WidgetTilesetSource;
|
|
3550
3566
|
return baseSource("tileset", options, urlParameters).then(
|
|
3551
3567
|
(result) => ({
|
|
3552
3568
|
...result,
|
|
3553
|
-
widgetSource: new
|
|
3569
|
+
widgetSource: new WidgetTilesetSource({
|
|
3554
3570
|
...options,
|
|
3555
3571
|
tileFormat: getTileFormat(result),
|
|
3556
3572
|
spatialDataColumn,
|
|
@@ -3656,11 +3672,10 @@ init_cjs_shims();
|
|
|
3656
3672
|
var quadbinTilesetSource = async function(options) {
|
|
3657
3673
|
const { tableName, spatialDataColumn = "quadbin" } = options;
|
|
3658
3674
|
const urlParameters = { name: tableName };
|
|
3659
|
-
const WidgetSourceClass = options.widgetSourceWorker !== false && isModuleWorkerSupported() ? WidgetTilesetWorkerSource : WidgetTilesetSource;
|
|
3660
3675
|
return baseSource("tileset", options, urlParameters).then(
|
|
3661
3676
|
(result) => ({
|
|
3662
3677
|
...result,
|
|
3663
|
-
widgetSource: new
|
|
3678
|
+
widgetSource: new WidgetTilesetSource({
|
|
3664
3679
|
...options,
|
|
3665
3680
|
tileFormat: getTileFormat(result),
|
|
3666
3681
|
spatialDataColumn,
|
|
@@ -3761,11 +3776,10 @@ init_cjs_shims();
|
|
|
3761
3776
|
var vectorTilesetSource = async function(options) {
|
|
3762
3777
|
const { tableName, spatialDataColumn = DEFAULT_GEO_COLUMN } = options;
|
|
3763
3778
|
const urlParameters = { name: tableName };
|
|
3764
|
-
const WidgetSourceClass = options.widgetSourceWorker !== false && isModuleWorkerSupported() ? WidgetTilesetWorkerSource : WidgetTilesetSource;
|
|
3765
3779
|
return baseSource("tileset", options, urlParameters).then(
|
|
3766
3780
|
(result) => ({
|
|
3767
3781
|
...result,
|
|
3768
|
-
widgetSource: new
|
|
3782
|
+
widgetSource: new WidgetTilesetSource({
|
|
3769
3783
|
...options,
|
|
3770
3784
|
tileFormat: getTileFormat(result),
|
|
3771
3785
|
spatialDataColumn,
|
|
@@ -3831,7 +3845,6 @@ var query = async function(options) {
|
|
|
3831
3845
|
WidgetSource,
|
|
3832
3846
|
WidgetTableSource,
|
|
3833
3847
|
WidgetTilesetSource,
|
|
3834
|
-
WidgetTilesetWorkerSource,
|
|
3835
3848
|
_buildFeatureFilter,
|
|
3836
3849
|
_getHexagonResolution,
|
|
3837
3850
|
addFilter,
|
package/build/api-client.d.cts
CHANGED
|
@@ -863,6 +863,14 @@ declare abstract class WidgetSource<Props extends WidgetSourceProps> {
|
|
|
863
863
|
readonly props: Props;
|
|
864
864
|
static defaultProps: Partial<WidgetSourceProps>;
|
|
865
865
|
constructor(props: Props);
|
|
866
|
+
/**
|
|
867
|
+
* Destroys the widget source and releases allocated resources.
|
|
868
|
+
*
|
|
869
|
+
* For remote sources (tables, queries) this has no effect, but for local
|
|
870
|
+
* sources (tilesets, rasters) these resources will affect performance
|
|
871
|
+
* and stability if many (10+) sources are created and not released.
|
|
872
|
+
*/
|
|
873
|
+
destroy(): void;
|
|
866
874
|
protected _getSpatialFiltersResolution(source: Omit<ModelSource, 'type' | 'data'>, spatialFilter?: SpatialFilter, referenceViewState?: ViewState): number | undefined;
|
|
867
875
|
/**
|
|
868
876
|
* Returns a list of labeled datapoints for categorical data. Suitable for
|
|
@@ -1066,36 +1074,26 @@ type TileFeaturesSpatialIndexOptions = {
|
|
|
1066
1074
|
};
|
|
1067
1075
|
declare function tileFeaturesSpatialIndex({ tiles, spatialFilter, spatialDataColumn, spatialDataType, }: TileFeaturesSpatialIndexOptions): FeatureData[];
|
|
1068
1076
|
|
|
1069
|
-
|
|
1070
|
-
|
|
1071
|
-
|
|
1072
|
-
|
|
1073
|
-
|
|
1074
|
-
|
|
1075
|
-
|
|
1077
|
+
declare enum Method {
|
|
1078
|
+
INIT = "init",
|
|
1079
|
+
LOAD_TILES = "loadTiles",
|
|
1080
|
+
SET_TILE_FEATURE_EXTRACT_OPTIONS = "setTileFeatureExtractOptions",
|
|
1081
|
+
LOAD_GEOJSON = "loadGeoJSON",
|
|
1082
|
+
GET_FORMULA = "getFormula",
|
|
1083
|
+
GET_HISTOGRAM = "getHistogram",
|
|
1084
|
+
GET_CATEGORIES = "getCategories",
|
|
1085
|
+
GET_SCATTER = "getScatter",
|
|
1086
|
+
GET_TABLE = "getTable",
|
|
1087
|
+
GET_TIME_SERIES = "getTimeSeries",
|
|
1088
|
+
GET_RANGE = "getRange"
|
|
1089
|
+
}
|
|
1090
|
+
|
|
1076
1091
|
/**
|
|
1077
|
-
*
|
|
1078
|
-
*
|
|
1079
|
-
*
|
|
1080
|
-
* {@link vectorTilesetSource}, {@link h3TilesetSource}, or {@link quadbinTilesetSource},
|
|
1081
|
-
* which can be shared with map layers. Sources contain a `widgetSource`
|
|
1082
|
-
* property, for use by widget implementations.
|
|
1083
|
-
*
|
|
1084
|
-
* Example:
|
|
1085
|
-
*
|
|
1086
|
-
* ```javascript
|
|
1087
|
-
* import { vectorTilesetSource } from '@carto/api-client';
|
|
1088
|
-
*
|
|
1089
|
-
* const data = vectorTilesetSource({
|
|
1090
|
-
* accessToken: '••••',
|
|
1091
|
-
* connectionName: 'carto_dw',
|
|
1092
|
-
* tableName: 'carto-demo-data.demo_rasters.my_tileset_source'
|
|
1093
|
-
* });
|
|
1094
|
-
*
|
|
1095
|
-
* const { widgetSource } = await data;
|
|
1096
|
-
* ```
|
|
1092
|
+
* Local (in-memory) implementation of tileset widget calculations. This class
|
|
1093
|
+
* may be instantiated by {@link WidgetTilesetSource} in a Web Worker when
|
|
1094
|
+
* supported, or on the main thread.
|
|
1097
1095
|
*/
|
|
1098
|
-
declare class
|
|
1096
|
+
declare class WidgetTilesetSourceImpl extends WidgetSource<WidgetTilesetSourceProps> {
|
|
1099
1097
|
private _tiles;
|
|
1100
1098
|
private _features;
|
|
1101
1099
|
private _tileFeatureExtractOptions;
|
|
@@ -1132,40 +1130,49 @@ declare class WidgetTilesetSource extends WidgetSource<WidgetTilesetSourceProps>
|
|
|
1132
1130
|
private _getFilteredFeatures;
|
|
1133
1131
|
}
|
|
1134
1132
|
|
|
1135
|
-
|
|
1136
|
-
|
|
1137
|
-
|
|
1138
|
-
|
|
1139
|
-
|
|
1140
|
-
|
|
1141
|
-
|
|
1142
|
-
GET_CATEGORIES = "getCategories",
|
|
1143
|
-
GET_SCATTER = "getScatter",
|
|
1144
|
-
GET_TABLE = "getTable",
|
|
1145
|
-
GET_TIME_SERIES = "getTimeSeries",
|
|
1146
|
-
GET_RANGE = "getRange"
|
|
1147
|
-
}
|
|
1148
|
-
|
|
1133
|
+
type WidgetTilesetSourceProps = WidgetSourceProps & Omit<TilesetSourceOptions, 'filters'> & {
|
|
1134
|
+
tileFormat: TileFormat;
|
|
1135
|
+
spatialDataType: SpatialDataType;
|
|
1136
|
+
};
|
|
1137
|
+
type WidgetTilesetSourceResult = {
|
|
1138
|
+
widgetSource: WidgetTilesetSource;
|
|
1139
|
+
};
|
|
1149
1140
|
/**
|
|
1150
|
-
*
|
|
1151
|
-
*
|
|
1141
|
+
* Source for Widget API requests on a data source defined by a tileset.
|
|
1142
|
+
*
|
|
1143
|
+
* Generally not intended to be constructed directly. Instead, call
|
|
1144
|
+
* {@link vectorTilesetSource}, {@link h3TilesetSource}, or {@link quadbinTilesetSource},
|
|
1145
|
+
* which can be shared with map layers. Sources contain a `widgetSource`
|
|
1146
|
+
* property, for use by widget implementations.
|
|
1147
|
+
*
|
|
1148
|
+
* Example:
|
|
1149
|
+
*
|
|
1150
|
+
* ```javascript
|
|
1151
|
+
* import { vectorTilesetSource } from '@carto/api-client';
|
|
1152
1152
|
*
|
|
1153
|
-
*
|
|
1154
|
-
*
|
|
1155
|
-
*
|
|
1156
|
-
*
|
|
1153
|
+
* const data = vectorTilesetSource({
|
|
1154
|
+
* accessToken: '••••',
|
|
1155
|
+
* connectionName: 'carto_dw',
|
|
1156
|
+
* tableName: 'carto-demo-data.demo_rasters.my_tileset_source'
|
|
1157
|
+
* });
|
|
1158
|
+
*
|
|
1159
|
+
* const { widgetSource } = await data;
|
|
1160
|
+
* ```
|
|
1157
1161
|
*/
|
|
1158
|
-
declare class
|
|
1159
|
-
|
|
1160
|
-
protected
|
|
1162
|
+
declare class WidgetTilesetSource extends WidgetSource<WidgetTilesetSourceProps> {
|
|
1163
|
+
protected _localImpl: WidgetTilesetSourceImpl | null;
|
|
1164
|
+
protected _workerImpl: Worker | null;
|
|
1165
|
+
protected _workerEnabled: boolean;
|
|
1161
1166
|
protected _workerNextRequestId: number;
|
|
1167
|
+
constructor(props: WidgetTilesetSourceProps);
|
|
1168
|
+
destroy(): void;
|
|
1162
1169
|
/**
|
|
1163
1170
|
* Returns an initialized Worker, to be reused for the lifecycle of this
|
|
1164
1171
|
* source instance.
|
|
1165
1172
|
*/
|
|
1166
|
-
_getWorker(): Worker;
|
|
1173
|
+
protected _getWorker(): Worker;
|
|
1167
1174
|
/** Executes a given method on the worker. */
|
|
1168
|
-
_executeWorkerMethod<T>(method: Method, params: unknown[], signal?: AbortSignal): Promise<T>;
|
|
1175
|
+
protected _executeWorkerMethod<T>(method: Method, params: unknown[], signal?: AbortSignal): Promise<T>;
|
|
1169
1176
|
/**
|
|
1170
1177
|
* Loads features as a list of tiles (typically provided by deck.gl).
|
|
1171
1178
|
* After tiles are loaded, {@link extractTileFeatures} must be called
|
|
@@ -1381,4 +1388,4 @@ declare function makeIntervalComplete(intervals: FilterInterval[]): FilterInterv
|
|
|
1381
1388
|
*/
|
|
1382
1389
|
declare function transformToTileCoords<T extends Geometry>(geometry: T, bbox: BBox): T;
|
|
1383
1390
|
|
|
1384
|
-
export { type APIErrorContext, type APIRequestType, type AddFilterOptions, type AggregationFunction, type AggregationType, ApiVersion, type BoundaryQuerySourceOptions, type BoundaryQuerySourceResponse, type BoundaryTableSourceOptions, type BoundaryTableSourceResponse, CartoAPIError, type CategoryRequestOptions, type CategoryResponse, DEFAULT_API_BASE_URL, FEATURE_GEOM_PROPERTY, type FeaturesRequestOptions, type FeaturesResponse, type Filter, type FilterFunction, type FilterInterval, type FilterIntervalComplete, type FilterIntervalExtremum, type FilterLogicalOperator, FilterType, type Filters, type Format, type FormulaRequestOptions, type FormulaResponse, type GeojsonResult, type GetFilterOptions, type GroupByFeature, type GroupDateType, type H3QuerySourceOptions, type H3QuerySourceResponse, type H3TableSourceOptions, type H3TableSourceResponse, type H3TilesetSourceOptions, type H3TilesetSourceResponse, type HasFilterOptions, type HistogramRequestOptions, type HistogramResponse, type JsonResult, type MapType, type NamedQueryParameter, type PositionalQueryParameter, Provider, type QuadbinQuerySourceOptions, type QuadbinQuerySourceResponse, type QuadbinTableSourceOptions, type QuadbinTableSourceResponse, type QuadbinTilesetSourceOptions, type QuadbinTilesetSourceResponse, type QueryOptions, type QueryParameterValue, type QueryParameters, type QueryResult, type QuerySourceOptions, type RangeRequestOptions, type RangeResponse, type Raster, RasterBandColorinterp, type RasterMetadata, type RasterMetadataBand, type RasterMetadataBandStats, type RasterSourceOptions, type RemoveFilterOptions, SOURCE_DEFAULTS, type ScatterPlotFeature, type ScatterRequestOptions, type ScatterResponse, type SortColumnType, type SortDirection, type SourceOptions, type SpatialFilter, type SpatialFilterPolyfillMode, SpatialIndex, type SpatialIndexTile, type StringSearchOptions, type TableRequestOptions, type TableResponse, type TableSourceOptions, type Tile, type TileFeatureExtractOptions, type TileFeatures, type TileFeaturesSpatialIndexOptions, TileFormat, type TileResolution, type TilejsonResult, type TilesetSourceOptions, type TimeSeriesRequestOptions, type TimeSeriesResponse, type VectorLayer, type VectorQuerySourceOptions, type VectorQuerySourceResponse, type VectorTableSourceOptions, type VectorTableSourceResponse, type VectorTilesetSourceOptions, type VectorTilesetSourceResponse, type ViewState, type Viewport, WidgetQuerySource, type WidgetQuerySourceResult, WidgetRemoteSource, type WidgetRemoteSourceProps, WidgetSource, type WidgetSourceProps, WidgetTableSource, type WidgetTableSourceResult, WidgetTilesetSource, type WidgetTilesetSourceProps, type WidgetTilesetSourceResult,
|
|
1391
|
+
export { type APIErrorContext, type APIRequestType, type AddFilterOptions, type AggregationFunction, type AggregationType, ApiVersion, type BoundaryQuerySourceOptions, type BoundaryQuerySourceResponse, type BoundaryTableSourceOptions, type BoundaryTableSourceResponse, CartoAPIError, type CategoryRequestOptions, type CategoryResponse, DEFAULT_API_BASE_URL, FEATURE_GEOM_PROPERTY, type FeaturesRequestOptions, type FeaturesResponse, type Filter, type FilterFunction, type FilterInterval, type FilterIntervalComplete, type FilterIntervalExtremum, type FilterLogicalOperator, FilterType, type Filters, type Format, type FormulaRequestOptions, type FormulaResponse, type GeojsonResult, type GetFilterOptions, type GroupByFeature, type GroupDateType, type H3QuerySourceOptions, type H3QuerySourceResponse, type H3TableSourceOptions, type H3TableSourceResponse, type H3TilesetSourceOptions, type H3TilesetSourceResponse, type HasFilterOptions, type HistogramRequestOptions, type HistogramResponse, type JsonResult, type MapType, type NamedQueryParameter, type PositionalQueryParameter, Provider, type QuadbinQuerySourceOptions, type QuadbinQuerySourceResponse, type QuadbinTableSourceOptions, type QuadbinTableSourceResponse, type QuadbinTilesetSourceOptions, type QuadbinTilesetSourceResponse, type QueryOptions, type QueryParameterValue, type QueryParameters, type QueryResult, type QuerySourceOptions, type RangeRequestOptions, type RangeResponse, type Raster, RasterBandColorinterp, type RasterMetadata, type RasterMetadataBand, type RasterMetadataBandStats, type RasterSourceOptions, type RemoveFilterOptions, SOURCE_DEFAULTS, type ScatterPlotFeature, type ScatterRequestOptions, type ScatterResponse, type SortColumnType, type SortDirection, type SourceOptions, type SpatialFilter, type SpatialFilterPolyfillMode, SpatialIndex, type SpatialIndexTile, type StringSearchOptions, type TableRequestOptions, type TableResponse, type TableSourceOptions, type Tile, type TileFeatureExtractOptions, type TileFeatures, type TileFeaturesSpatialIndexOptions, TileFormat, type TileResolution, type TilejsonResult, type TilesetSourceOptions, type TimeSeriesRequestOptions, type TimeSeriesResponse, type VectorLayer, type VectorQuerySourceOptions, type VectorQuerySourceResponse, type VectorTableSourceOptions, type VectorTableSourceResponse, type VectorTilesetSourceOptions, type VectorTilesetSourceResponse, type ViewState, type Viewport, WidgetQuerySource, type WidgetQuerySourceResult, WidgetRemoteSource, type WidgetRemoteSourceProps, WidgetSource, type WidgetSourceProps, WidgetTableSource, type WidgetTableSourceResult, WidgetTilesetSource, type WidgetTilesetSourceProps, type WidgetTilesetSourceResult, type _DataFilterExtensionProps, _buildFeatureFilter, _getHexagonResolution, addFilter, aggregate, aggregationFunctions, applyFilters, applySorting, boundaryQuerySource, boundaryTableSource, buildBinaryFeatureFilter, buildPublicMapUrl, buildStatsUrl, clearFilters, createPolygonSpatialFilter, createViewportSpatialFilter, filterFunctions, geojsonFeatures, getClient, getDataFilterExtensionProps, getFilter, groupValuesByColumn, groupValuesByDateColumn, h3QuerySource, h3TableSource, h3TilesetSource, hasFilter, histogram, makeIntervalComplete, quadbinQuerySource, quadbinTableSource, quadbinTilesetSource, query, rasterSource, removeFilter, requestWithParameters, scatterPlot, setClient, tileFeatures, tileFeaturesGeometries, tileFeaturesSpatialIndex, transformToTileCoords, vectorQuerySource, vectorTableSource, vectorTilesetSource };
|
package/build/api-client.d.ts
CHANGED
|
@@ -863,6 +863,14 @@ declare abstract class WidgetSource<Props extends WidgetSourceProps> {
|
|
|
863
863
|
readonly props: Props;
|
|
864
864
|
static defaultProps: Partial<WidgetSourceProps>;
|
|
865
865
|
constructor(props: Props);
|
|
866
|
+
/**
|
|
867
|
+
* Destroys the widget source and releases allocated resources.
|
|
868
|
+
*
|
|
869
|
+
* For remote sources (tables, queries) this has no effect, but for local
|
|
870
|
+
* sources (tilesets, rasters) these resources will affect performance
|
|
871
|
+
* and stability if many (10+) sources are created and not released.
|
|
872
|
+
*/
|
|
873
|
+
destroy(): void;
|
|
866
874
|
protected _getSpatialFiltersResolution(source: Omit<ModelSource, 'type' | 'data'>, spatialFilter?: SpatialFilter, referenceViewState?: ViewState): number | undefined;
|
|
867
875
|
/**
|
|
868
876
|
* Returns a list of labeled datapoints for categorical data. Suitable for
|
|
@@ -1066,36 +1074,26 @@ type TileFeaturesSpatialIndexOptions = {
|
|
|
1066
1074
|
};
|
|
1067
1075
|
declare function tileFeaturesSpatialIndex({ tiles, spatialFilter, spatialDataColumn, spatialDataType, }: TileFeaturesSpatialIndexOptions): FeatureData[];
|
|
1068
1076
|
|
|
1069
|
-
|
|
1070
|
-
|
|
1071
|
-
|
|
1072
|
-
|
|
1073
|
-
|
|
1074
|
-
|
|
1075
|
-
|
|
1077
|
+
declare enum Method {
|
|
1078
|
+
INIT = "init",
|
|
1079
|
+
LOAD_TILES = "loadTiles",
|
|
1080
|
+
SET_TILE_FEATURE_EXTRACT_OPTIONS = "setTileFeatureExtractOptions",
|
|
1081
|
+
LOAD_GEOJSON = "loadGeoJSON",
|
|
1082
|
+
GET_FORMULA = "getFormula",
|
|
1083
|
+
GET_HISTOGRAM = "getHistogram",
|
|
1084
|
+
GET_CATEGORIES = "getCategories",
|
|
1085
|
+
GET_SCATTER = "getScatter",
|
|
1086
|
+
GET_TABLE = "getTable",
|
|
1087
|
+
GET_TIME_SERIES = "getTimeSeries",
|
|
1088
|
+
GET_RANGE = "getRange"
|
|
1089
|
+
}
|
|
1090
|
+
|
|
1076
1091
|
/**
|
|
1077
|
-
*
|
|
1078
|
-
*
|
|
1079
|
-
*
|
|
1080
|
-
* {@link vectorTilesetSource}, {@link h3TilesetSource}, or {@link quadbinTilesetSource},
|
|
1081
|
-
* which can be shared with map layers. Sources contain a `widgetSource`
|
|
1082
|
-
* property, for use by widget implementations.
|
|
1083
|
-
*
|
|
1084
|
-
* Example:
|
|
1085
|
-
*
|
|
1086
|
-
* ```javascript
|
|
1087
|
-
* import { vectorTilesetSource } from '@carto/api-client';
|
|
1088
|
-
*
|
|
1089
|
-
* const data = vectorTilesetSource({
|
|
1090
|
-
* accessToken: '••••',
|
|
1091
|
-
* connectionName: 'carto_dw',
|
|
1092
|
-
* tableName: 'carto-demo-data.demo_rasters.my_tileset_source'
|
|
1093
|
-
* });
|
|
1094
|
-
*
|
|
1095
|
-
* const { widgetSource } = await data;
|
|
1096
|
-
* ```
|
|
1092
|
+
* Local (in-memory) implementation of tileset widget calculations. This class
|
|
1093
|
+
* may be instantiated by {@link WidgetTilesetSource} in a Web Worker when
|
|
1094
|
+
* supported, or on the main thread.
|
|
1097
1095
|
*/
|
|
1098
|
-
declare class
|
|
1096
|
+
declare class WidgetTilesetSourceImpl extends WidgetSource<WidgetTilesetSourceProps> {
|
|
1099
1097
|
private _tiles;
|
|
1100
1098
|
private _features;
|
|
1101
1099
|
private _tileFeatureExtractOptions;
|
|
@@ -1132,40 +1130,49 @@ declare class WidgetTilesetSource extends WidgetSource<WidgetTilesetSourceProps>
|
|
|
1132
1130
|
private _getFilteredFeatures;
|
|
1133
1131
|
}
|
|
1134
1132
|
|
|
1135
|
-
|
|
1136
|
-
|
|
1137
|
-
|
|
1138
|
-
|
|
1139
|
-
|
|
1140
|
-
|
|
1141
|
-
|
|
1142
|
-
GET_CATEGORIES = "getCategories",
|
|
1143
|
-
GET_SCATTER = "getScatter",
|
|
1144
|
-
GET_TABLE = "getTable",
|
|
1145
|
-
GET_TIME_SERIES = "getTimeSeries",
|
|
1146
|
-
GET_RANGE = "getRange"
|
|
1147
|
-
}
|
|
1148
|
-
|
|
1133
|
+
type WidgetTilesetSourceProps = WidgetSourceProps & Omit<TilesetSourceOptions, 'filters'> & {
|
|
1134
|
+
tileFormat: TileFormat;
|
|
1135
|
+
spatialDataType: SpatialDataType;
|
|
1136
|
+
};
|
|
1137
|
+
type WidgetTilesetSourceResult = {
|
|
1138
|
+
widgetSource: WidgetTilesetSource;
|
|
1139
|
+
};
|
|
1149
1140
|
/**
|
|
1150
|
-
*
|
|
1151
|
-
*
|
|
1141
|
+
* Source for Widget API requests on a data source defined by a tileset.
|
|
1142
|
+
*
|
|
1143
|
+
* Generally not intended to be constructed directly. Instead, call
|
|
1144
|
+
* {@link vectorTilesetSource}, {@link h3TilesetSource}, or {@link quadbinTilesetSource},
|
|
1145
|
+
* which can be shared with map layers. Sources contain a `widgetSource`
|
|
1146
|
+
* property, for use by widget implementations.
|
|
1147
|
+
*
|
|
1148
|
+
* Example:
|
|
1149
|
+
*
|
|
1150
|
+
* ```javascript
|
|
1151
|
+
* import { vectorTilesetSource } from '@carto/api-client';
|
|
1152
1152
|
*
|
|
1153
|
-
*
|
|
1154
|
-
*
|
|
1155
|
-
*
|
|
1156
|
-
*
|
|
1153
|
+
* const data = vectorTilesetSource({
|
|
1154
|
+
* accessToken: '••••',
|
|
1155
|
+
* connectionName: 'carto_dw',
|
|
1156
|
+
* tableName: 'carto-demo-data.demo_rasters.my_tileset_source'
|
|
1157
|
+
* });
|
|
1158
|
+
*
|
|
1159
|
+
* const { widgetSource } = await data;
|
|
1160
|
+
* ```
|
|
1157
1161
|
*/
|
|
1158
|
-
declare class
|
|
1159
|
-
|
|
1160
|
-
protected
|
|
1162
|
+
declare class WidgetTilesetSource extends WidgetSource<WidgetTilesetSourceProps> {
|
|
1163
|
+
protected _localImpl: WidgetTilesetSourceImpl | null;
|
|
1164
|
+
protected _workerImpl: Worker | null;
|
|
1165
|
+
protected _workerEnabled: boolean;
|
|
1161
1166
|
protected _workerNextRequestId: number;
|
|
1167
|
+
constructor(props: WidgetTilesetSourceProps);
|
|
1168
|
+
destroy(): void;
|
|
1162
1169
|
/**
|
|
1163
1170
|
* Returns an initialized Worker, to be reused for the lifecycle of this
|
|
1164
1171
|
* source instance.
|
|
1165
1172
|
*/
|
|
1166
|
-
_getWorker(): Worker;
|
|
1173
|
+
protected _getWorker(): Worker;
|
|
1167
1174
|
/** Executes a given method on the worker. */
|
|
1168
|
-
_executeWorkerMethod<T>(method: Method, params: unknown[], signal?: AbortSignal): Promise<T>;
|
|
1175
|
+
protected _executeWorkerMethod<T>(method: Method, params: unknown[], signal?: AbortSignal): Promise<T>;
|
|
1169
1176
|
/**
|
|
1170
1177
|
* Loads features as a list of tiles (typically provided by deck.gl).
|
|
1171
1178
|
* After tiles are loaded, {@link extractTileFeatures} must be called
|
|
@@ -1381,4 +1388,4 @@ declare function makeIntervalComplete(intervals: FilterInterval[]): FilterInterv
|
|
|
1381
1388
|
*/
|
|
1382
1389
|
declare function transformToTileCoords<T extends Geometry>(geometry: T, bbox: BBox): T;
|
|
1383
1390
|
|
|
1384
|
-
export { type APIErrorContext, type APIRequestType, type AddFilterOptions, type AggregationFunction, type AggregationType, ApiVersion, type BoundaryQuerySourceOptions, type BoundaryQuerySourceResponse, type BoundaryTableSourceOptions, type BoundaryTableSourceResponse, CartoAPIError, type CategoryRequestOptions, type CategoryResponse, DEFAULT_API_BASE_URL, FEATURE_GEOM_PROPERTY, type FeaturesRequestOptions, type FeaturesResponse, type Filter, type FilterFunction, type FilterInterval, type FilterIntervalComplete, type FilterIntervalExtremum, type FilterLogicalOperator, FilterType, type Filters, type Format, type FormulaRequestOptions, type FormulaResponse, type GeojsonResult, type GetFilterOptions, type GroupByFeature, type GroupDateType, type H3QuerySourceOptions, type H3QuerySourceResponse, type H3TableSourceOptions, type H3TableSourceResponse, type H3TilesetSourceOptions, type H3TilesetSourceResponse, type HasFilterOptions, type HistogramRequestOptions, type HistogramResponse, type JsonResult, type MapType, type NamedQueryParameter, type PositionalQueryParameter, Provider, type QuadbinQuerySourceOptions, type QuadbinQuerySourceResponse, type QuadbinTableSourceOptions, type QuadbinTableSourceResponse, type QuadbinTilesetSourceOptions, type QuadbinTilesetSourceResponse, type QueryOptions, type QueryParameterValue, type QueryParameters, type QueryResult, type QuerySourceOptions, type RangeRequestOptions, type RangeResponse, type Raster, RasterBandColorinterp, type RasterMetadata, type RasterMetadataBand, type RasterMetadataBandStats, type RasterSourceOptions, type RemoveFilterOptions, SOURCE_DEFAULTS, type ScatterPlotFeature, type ScatterRequestOptions, type ScatterResponse, type SortColumnType, type SortDirection, type SourceOptions, type SpatialFilter, type SpatialFilterPolyfillMode, SpatialIndex, type SpatialIndexTile, type StringSearchOptions, type TableRequestOptions, type TableResponse, type TableSourceOptions, type Tile, type TileFeatureExtractOptions, type TileFeatures, type TileFeaturesSpatialIndexOptions, TileFormat, type TileResolution, type TilejsonResult, type TilesetSourceOptions, type TimeSeriesRequestOptions, type TimeSeriesResponse, type VectorLayer, type VectorQuerySourceOptions, type VectorQuerySourceResponse, type VectorTableSourceOptions, type VectorTableSourceResponse, type VectorTilesetSourceOptions, type VectorTilesetSourceResponse, type ViewState, type Viewport, WidgetQuerySource, type WidgetQuerySourceResult, WidgetRemoteSource, type WidgetRemoteSourceProps, WidgetSource, type WidgetSourceProps, WidgetTableSource, type WidgetTableSourceResult, WidgetTilesetSource, type WidgetTilesetSourceProps, type WidgetTilesetSourceResult,
|
|
1391
|
+
export { type APIErrorContext, type APIRequestType, type AddFilterOptions, type AggregationFunction, type AggregationType, ApiVersion, type BoundaryQuerySourceOptions, type BoundaryQuerySourceResponse, type BoundaryTableSourceOptions, type BoundaryTableSourceResponse, CartoAPIError, type CategoryRequestOptions, type CategoryResponse, DEFAULT_API_BASE_URL, FEATURE_GEOM_PROPERTY, type FeaturesRequestOptions, type FeaturesResponse, type Filter, type FilterFunction, type FilterInterval, type FilterIntervalComplete, type FilterIntervalExtremum, type FilterLogicalOperator, FilterType, type Filters, type Format, type FormulaRequestOptions, type FormulaResponse, type GeojsonResult, type GetFilterOptions, type GroupByFeature, type GroupDateType, type H3QuerySourceOptions, type H3QuerySourceResponse, type H3TableSourceOptions, type H3TableSourceResponse, type H3TilesetSourceOptions, type H3TilesetSourceResponse, type HasFilterOptions, type HistogramRequestOptions, type HistogramResponse, type JsonResult, type MapType, type NamedQueryParameter, type PositionalQueryParameter, Provider, type QuadbinQuerySourceOptions, type QuadbinQuerySourceResponse, type QuadbinTableSourceOptions, type QuadbinTableSourceResponse, type QuadbinTilesetSourceOptions, type QuadbinTilesetSourceResponse, type QueryOptions, type QueryParameterValue, type QueryParameters, type QueryResult, type QuerySourceOptions, type RangeRequestOptions, type RangeResponse, type Raster, RasterBandColorinterp, type RasterMetadata, type RasterMetadataBand, type RasterMetadataBandStats, type RasterSourceOptions, type RemoveFilterOptions, SOURCE_DEFAULTS, type ScatterPlotFeature, type ScatterRequestOptions, type ScatterResponse, type SortColumnType, type SortDirection, type SourceOptions, type SpatialFilter, type SpatialFilterPolyfillMode, SpatialIndex, type SpatialIndexTile, type StringSearchOptions, type TableRequestOptions, type TableResponse, type TableSourceOptions, type Tile, type TileFeatureExtractOptions, type TileFeatures, type TileFeaturesSpatialIndexOptions, TileFormat, type TileResolution, type TilejsonResult, type TilesetSourceOptions, type TimeSeriesRequestOptions, type TimeSeriesResponse, type VectorLayer, type VectorQuerySourceOptions, type VectorQuerySourceResponse, type VectorTableSourceOptions, type VectorTableSourceResponse, type VectorTilesetSourceOptions, type VectorTilesetSourceResponse, type ViewState, type Viewport, WidgetQuerySource, type WidgetQuerySourceResult, WidgetRemoteSource, type WidgetRemoteSourceProps, WidgetSource, type WidgetSourceProps, WidgetTableSource, type WidgetTableSourceResult, WidgetTilesetSource, type WidgetTilesetSourceProps, type WidgetTilesetSourceResult, type _DataFilterExtensionProps, _buildFeatureFilter, _getHexagonResolution, addFilter, aggregate, aggregationFunctions, applyFilters, applySorting, boundaryQuerySource, boundaryTableSource, buildBinaryFeatureFilter, buildPublicMapUrl, buildStatsUrl, clearFilters, createPolygonSpatialFilter, createViewportSpatialFilter, filterFunctions, geojsonFeatures, getClient, getDataFilterExtensionProps, getFilter, groupValuesByColumn, groupValuesByDateColumn, h3QuerySource, h3TableSource, h3TilesetSource, hasFilter, histogram, makeIntervalComplete, quadbinQuerySource, quadbinTableSource, quadbinTilesetSource, query, rasterSource, removeFilter, requestWithParameters, scatterPlot, setClient, tileFeatures, tileFeaturesGeometries, tileFeaturesSpatialIndex, transformToTileCoords, vectorQuerySource, vectorTableSource, vectorTilesetSource };
|