@carto/api-client 0.5.0-alpha.4 → 0.5.0-alpha.5
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/build/api-client.cjs +2794 -2698
- package/build/api-client.d.cts +1373 -0
- package/build/api-client.d.ts +1373 -0
- package/build/api-client.js +1712 -0
- package/build/chunk-V3E7BKVR.js +2063 -0
- package/build/worker.d.ts +2 -0
- package/build/worker.js +25 -0
- package/package.json +18 -18
- package/src/constants-internal.ts +0 -6
- package/src/filters/tileFeatures.ts +10 -26
- package/src/global.d.ts +3 -8
- package/src/sources/h3-tileset-source.ts +8 -1
- package/src/sources/quadbin-tileset-source.ts +8 -1
- package/src/sources/raster-source.ts +5 -18
- package/src/sources/types.ts +7 -1
- package/src/sources/vector-tileset-source.ts +8 -1
- package/src/types.ts +0 -6
- package/src/widget-sources/index.ts +1 -1
- package/src/widget-sources/widget-remote-source.ts +35 -2
- package/src/widget-sources/widget-source.ts +1 -38
- package/src/widget-sources/widget-tileset-source.ts +7 -18
- package/src/widget-sources/widget-tileset-worker-source.ts +238 -0
- package/src/workers/constants.ts +13 -0
- package/src/workers/types.ts +20 -0
- package/src/workers/utils.ts +33 -0
- package/src/workers/widget-tileset-worker.ts +36 -0
- package/build/api/carto-api-error.d.ts +0 -26
- package/build/api/endpoints.d.ts +0 -24
- package/build/api/index.d.ts +0 -5
- package/build/api/query.d.ts +0 -3
- package/build/api/request-with-parameters.d.ts +0 -10
- package/build/api-client.cjs.map +0 -1
- package/build/api-client.modern.js +0 -3445
- package/build/api-client.modern.js.map +0 -1
- package/build/client.d.ts +0 -14
- package/build/constants-internal.d.ts +0 -26
- package/build/constants.d.ts +0 -53
- package/build/deck/get-data-filter-extension-props.d.ts +0 -18
- package/build/deck/index.d.ts +0 -1
- package/build/filters/Filter.d.ts +0 -25
- package/build/filters/FilterTypes.d.ts +0 -3
- package/build/filters/geosjonFeatures.d.ts +0 -8
- package/build/filters/index.d.ts +0 -6
- package/build/filters/tileFeatures.d.ts +0 -21
- package/build/filters/tileFeaturesGeometries.d.ts +0 -13
- package/build/filters/tileFeaturesRaster.d.ts +0 -16
- package/build/filters/tileFeaturesSpatialIndex.d.ts +0 -10
- package/build/filters.d.ts +0 -39
- package/build/geo.d.ts +0 -19
- package/build/index.d.ts +0 -16
- package/build/models/common.d.ts +0 -28
- package/build/models/index.d.ts +0 -3
- package/build/models/model.d.ts +0 -37
- package/build/operations/aggregation.d.ts +0 -8
- package/build/operations/applySorting.d.ts +0 -20
- package/build/operations/groupBy.d.ts +0 -15
- package/build/operations/groupByDate.d.ts +0 -11
- package/build/operations/histogram.d.ts +0 -13
- package/build/operations/index.d.ts +0 -6
- package/build/operations/scatterPlot.d.ts +0 -14
- package/build/sources/base-source.d.ts +0 -4
- package/build/sources/boundary-query-source.d.ts +0 -10
- package/build/sources/boundary-table-source.d.ts +0 -8
- package/build/sources/h3-query-source.d.ts +0 -5
- package/build/sources/h3-table-source.d.ts +0 -5
- package/build/sources/h3-tileset-source.d.ts +0 -5
- package/build/sources/index.d.ts +0 -26
- package/build/sources/quadbin-query-source.d.ts +0 -5
- package/build/sources/quadbin-table-source.d.ts +0 -5
- package/build/sources/quadbin-tileset-source.d.ts +0 -5
- package/build/sources/raster-source.d.ts +0 -5
- package/build/sources/types.d.ts +0 -366
- package/build/sources/vector-query-source.d.ts +0 -5
- package/build/sources/vector-table-source.d.ts +0 -5
- package/build/sources/vector-tileset-source.d.ts +0 -5
- package/build/spatial-index.d.ts +0 -14
- package/build/types-internal.d.ts +0 -56
- package/build/types.d.ts +0 -148
- package/build/utils/dateUtils.d.ts +0 -10
- package/build/utils/getTileFormat.d.ts +0 -3
- package/build/utils/makeIntervalComplete.d.ts +0 -2
- package/build/utils/transformTileCoordsToWGS84.d.ts +0 -8
- package/build/utils/transformToTileCoords.d.ts +0 -9
- package/build/utils.d.ts +0 -32
- package/build/widget-sources/index.d.ts +0 -7
- package/build/widget-sources/types.d.ts +0 -160
- package/build/widget-sources/widget-query-source.d.ts +0 -34
- package/build/widget-sources/widget-raster-source.d.ts +0 -11
- package/build/widget-sources/widget-remote-source.d.ts +0 -21
- package/build/widget-sources/widget-source.d.ts +0 -74
- package/build/widget-sources/widget-table-source.d.ts +0 -34
- package/build/widget-sources/widget-tileset-source.d.ts +0 -75
- package/src/filters/tileFeaturesRaster.ts +0 -111
- package/src/widget-sources/widget-raster-source.ts +0 -14
package/build/worker.js
ADDED
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
import {
|
|
2
|
+
WidgetTilesetSource
|
|
3
|
+
} from "./chunk-V3E7BKVR.js";
|
|
4
|
+
|
|
5
|
+
// src/workers/widget-tileset-worker.ts
|
|
6
|
+
var SOURCES_BY_NAME = /* @__PURE__ */ new Map();
|
|
7
|
+
addEventListener("message", (e) => {
|
|
8
|
+
const { tableName, method, params, requestId } = e.data;
|
|
9
|
+
if (method === "init" /* INIT */) {
|
|
10
|
+
const props = params[0];
|
|
11
|
+
SOURCES_BY_NAME.set(tableName, new WidgetTilesetSource(props));
|
|
12
|
+
return;
|
|
13
|
+
}
|
|
14
|
+
const source = SOURCES_BY_NAME.get(tableName);
|
|
15
|
+
if (!source) {
|
|
16
|
+
const error = `Unknown dataset: ${tableName}`;
|
|
17
|
+
postMessage({ ok: false, error, requestId });
|
|
18
|
+
return;
|
|
19
|
+
}
|
|
20
|
+
Promise.resolve(source[method](...params)).then((result) => {
|
|
21
|
+
postMessage({ ok: true, result, requestId });
|
|
22
|
+
}).catch((error) => {
|
|
23
|
+
postMessage({ ok: false, error, requestId });
|
|
24
|
+
});
|
|
25
|
+
});
|
package/package.json
CHANGED
|
@@ -8,7 +8,7 @@
|
|
|
8
8
|
"homepage": "https://github.com/CartoDB/carto-api-client#readme",
|
|
9
9
|
"author": "Don McCurdy <donmccurdy@carto.com>",
|
|
10
10
|
"packageManager": "yarn@4.3.1",
|
|
11
|
-
"version": "0.5.0-alpha.
|
|
11
|
+
"version": "0.5.0-alpha.5",
|
|
12
12
|
"license": "MIT",
|
|
13
13
|
"publishConfig": {
|
|
14
14
|
"access": "public",
|
|
@@ -16,15 +16,20 @@
|
|
|
16
16
|
},
|
|
17
17
|
"type": "module",
|
|
18
18
|
"sideEffects": false,
|
|
19
|
-
"source": "src/index.ts",
|
|
20
|
-
"types": "./build/index.d.ts",
|
|
21
|
-
"main": "./build/api-client.cjs",
|
|
22
|
-
"module": "./build/api-client.modern.js",
|
|
23
19
|
"exports": {
|
|
24
20
|
".": {
|
|
25
|
-
"
|
|
26
|
-
|
|
27
|
-
|
|
21
|
+
"require": {
|
|
22
|
+
"types": "./build/api-client.d.cts",
|
|
23
|
+
"default": "./build/api-client.cjs"
|
|
24
|
+
},
|
|
25
|
+
"default": {
|
|
26
|
+
"types": "./build/api-client.d.ts",
|
|
27
|
+
"default": "./build/api-client.js"
|
|
28
|
+
}
|
|
29
|
+
},
|
|
30
|
+
"./worker": {
|
|
31
|
+
"types": "./build/worker.d.ts",
|
|
32
|
+
"default": "./build/worker.js"
|
|
28
33
|
}
|
|
29
34
|
},
|
|
30
35
|
"browserslist": [
|
|
@@ -33,8 +38,8 @@
|
|
|
33
38
|
"node >= 18"
|
|
34
39
|
],
|
|
35
40
|
"scripts": {
|
|
36
|
-
"build": "
|
|
37
|
-
"build:watch": "
|
|
41
|
+
"build": "tsup",
|
|
42
|
+
"build:watch": "tsup --watch",
|
|
38
43
|
"dev": "concurrently \"yarn build:watch\" \"vite --config examples/vite.config.ts --open\"",
|
|
39
44
|
"test": "vitest run --typecheck",
|
|
40
45
|
"test:watch": "vitest watch --typecheck",
|
|
@@ -44,7 +49,7 @@
|
|
|
44
49
|
"format:check": "prettier \"**/*.{cjs,html,js,json,md,ts}\" --check",
|
|
45
50
|
"clean": "rimraf build/*",
|
|
46
51
|
"postversion": "yarn postversion:check && yarn postversion:commit && yarn postversion:push",
|
|
47
|
-
"postversion:check": "yarn lint && yarn
|
|
52
|
+
"postversion:check": "yarn lint && yarn test",
|
|
48
53
|
"postversion:commit": "node scripts/postversion-commit.js",
|
|
49
54
|
"postversion:push": "git push && git push --tags",
|
|
50
55
|
"prepublish": "yarn lint && yarn test",
|
|
@@ -68,8 +73,7 @@
|
|
|
68
73
|
"@turf/invariant": "^7.2.0",
|
|
69
74
|
"@turf/union": "^7.2.0",
|
|
70
75
|
"@types/geojson": "^7946.0.16",
|
|
71
|
-
"h3-js": "4.1.0"
|
|
72
|
-
"quadbin": "^0.4.0-alpha.2"
|
|
76
|
+
"h3-js": "4.1.0"
|
|
73
77
|
},
|
|
74
78
|
"devDependencies": {
|
|
75
79
|
"@deck.gl/aggregation-layers": "~9.1.0",
|
|
@@ -86,7 +90,6 @@
|
|
|
86
90
|
"@luma.gl/core": "~9.1.0",
|
|
87
91
|
"@luma.gl/engine": "~9.1.0",
|
|
88
92
|
"@luma.gl/shadertools": "~9.1.0",
|
|
89
|
-
"@turf/buffer": "^7.2.0",
|
|
90
93
|
"@types/json-schema": "^7.0.15",
|
|
91
94
|
"@types/react": "^18.3.18",
|
|
92
95
|
"@types/semver": "^7.5.8",
|
|
@@ -98,18 +101,15 @@
|
|
|
98
101
|
"lit": "^3.2.1",
|
|
99
102
|
"lit-analyzer": "^2.0.3",
|
|
100
103
|
"maplibre-gl": "^5.1.0",
|
|
101
|
-
"microbundle": "^0.15.1",
|
|
102
104
|
"prettier": "^3.4.2",
|
|
103
105
|
"rimraf": "^6.0.1",
|
|
104
106
|
"semver": "^7.7.1",
|
|
105
107
|
"thenby": "^1.3.4",
|
|
108
|
+
"tsup": "^8.3.6",
|
|
106
109
|
"typescript": "~5.7.3",
|
|
107
110
|
"typescript-eslint": "^8.24.0",
|
|
108
111
|
"vite": "^6.1.0",
|
|
109
112
|
"vitest": "3.0.5"
|
|
110
113
|
},
|
|
111
|
-
"resolutions": {
|
|
112
|
-
"rollup": "^4.20.0"
|
|
113
|
-
},
|
|
114
114
|
"stableVersion": "0.4.6"
|
|
115
115
|
}
|
|
@@ -1,12 +1,10 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import {SpatialFilter, SpatialIndexTile, Tile} from '../types.js';
|
|
2
2
|
import {tileFeaturesGeometries} from './tileFeaturesGeometries.js';
|
|
3
3
|
import {tileFeaturesSpatialIndex} from './tileFeaturesSpatialIndex.js';
|
|
4
4
|
import {TileFormat} from '../constants.js';
|
|
5
5
|
import {DEFAULT_GEO_COLUMN} from '../constants-internal.js';
|
|
6
6
|
import {FeatureData} from '../types-internal.js';
|
|
7
|
-
import {
|
|
8
|
-
import {isRasterTile, tileFeaturesRaster} from './tileFeaturesRaster.js';
|
|
9
|
-
import {assert} from '../utils.js';
|
|
7
|
+
import {SpatialDataType} from '../sources/types.js';
|
|
10
8
|
|
|
11
9
|
/** @privateRemarks Source: @carto/react-core */
|
|
12
10
|
export type TileFeatures = {
|
|
@@ -16,7 +14,6 @@ export type TileFeatures = {
|
|
|
16
14
|
spatialDataColumn?: string;
|
|
17
15
|
spatialFilter: SpatialFilter;
|
|
18
16
|
uniqueIdProperty?: string;
|
|
19
|
-
rasterMetadata?: RasterMetadata;
|
|
20
17
|
options?: TileFeatureExtractOptions;
|
|
21
18
|
};
|
|
22
19
|
|
|
@@ -33,34 +30,21 @@ export function tileFeatures({
|
|
|
33
30
|
tileFormat,
|
|
34
31
|
spatialDataColumn = DEFAULT_GEO_COLUMN,
|
|
35
32
|
spatialDataType,
|
|
36
|
-
rasterMetadata,
|
|
37
33
|
options = {},
|
|
38
34
|
}: TileFeatures): FeatureData[] {
|
|
39
|
-
if (spatialDataType
|
|
40
|
-
return
|
|
41
|
-
tiles,
|
|
42
|
-
tileFormat,
|
|
43
|
-
spatialFilter,
|
|
44
|
-
uniqueIdProperty,
|
|
45
|
-
options,
|
|
46
|
-
});
|
|
47
|
-
}
|
|
48
|
-
|
|
49
|
-
if (tiles.some(isRasterTile)) {
|
|
50
|
-
assert(rasterMetadata, 'Missing raster metadata');
|
|
51
|
-
return tileFeaturesRaster({
|
|
52
|
-
tiles: tiles as RasterTile[],
|
|
35
|
+
if (spatialDataType !== 'geo') {
|
|
36
|
+
return tileFeaturesSpatialIndex({
|
|
37
|
+
tiles: tiles as SpatialIndexTile[],
|
|
53
38
|
spatialFilter,
|
|
54
39
|
spatialDataColumn,
|
|
55
40
|
spatialDataType,
|
|
56
|
-
rasterMetadata,
|
|
57
41
|
});
|
|
58
42
|
}
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
43
|
+
return tileFeaturesGeometries({
|
|
44
|
+
tiles,
|
|
45
|
+
tileFormat,
|
|
62
46
|
spatialFilter,
|
|
63
|
-
|
|
64
|
-
|
|
47
|
+
uniqueIdProperty,
|
|
48
|
+
options,
|
|
65
49
|
});
|
|
66
50
|
}
|
package/src/global.d.ts
CHANGED
|
@@ -1,10 +1,5 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Injected by microbundle, with:
|
|
3
|
-
* ```
|
|
4
|
-
* --define __CARTO_API_CLIENT_VERSION=$npm_package_version
|
|
5
|
-
* ```
|
|
6
|
-
*/
|
|
7
|
-
declare const __CARTO_API_CLIENT_VERSION: string;
|
|
8
|
-
|
|
9
1
|
/** Defined by @deck.gl/core. */
|
|
10
2
|
declare const deck: {VERSION: string | undefined} | undefined;
|
|
3
|
+
|
|
4
|
+
/** Defined by tsup. */
|
|
5
|
+
declare const TSUP_FORMAT: 'esm' | 'cjs';
|
|
@@ -6,7 +6,9 @@ import {getTileFormat} from '../utils/getTileFormat.js';
|
|
|
6
6
|
import {
|
|
7
7
|
WidgetTilesetSource,
|
|
8
8
|
WidgetTilesetSourceResult,
|
|
9
|
+
WidgetTilesetWorkerSource,
|
|
9
10
|
} from '../widget-sources/index.js';
|
|
11
|
+
import {isModuleWorkerSupported} from '../workers/utils.js';
|
|
10
12
|
import {baseSource} from './base-source.js';
|
|
11
13
|
import type {
|
|
12
14
|
SourceOptions,
|
|
@@ -26,10 +28,15 @@ export const h3TilesetSource = async function (
|
|
|
26
28
|
const {tableName, spatialDataColumn = 'h3'} = options;
|
|
27
29
|
const urlParameters: UrlParameters = {name: tableName};
|
|
28
30
|
|
|
31
|
+
const WidgetSourceClass =
|
|
32
|
+
options.widgetSourceWorker !== false && isModuleWorkerSupported()
|
|
33
|
+
? WidgetTilesetWorkerSource
|
|
34
|
+
: WidgetTilesetSource;
|
|
35
|
+
|
|
29
36
|
return baseSource<UrlParameters>('tileset', options, urlParameters).then(
|
|
30
37
|
(result) => ({
|
|
31
38
|
...(result as TilejsonResult),
|
|
32
|
-
widgetSource: new
|
|
39
|
+
widgetSource: new WidgetSourceClass({
|
|
33
40
|
...options,
|
|
34
41
|
tileFormat: getTileFormat(result as TilejsonResult),
|
|
35
42
|
spatialDataColumn,
|
|
@@ -6,7 +6,9 @@ import {getTileFormat} from '../utils/getTileFormat.js';
|
|
|
6
6
|
import {
|
|
7
7
|
WidgetTilesetSource,
|
|
8
8
|
WidgetTilesetSourceResult,
|
|
9
|
+
WidgetTilesetWorkerSource,
|
|
9
10
|
} from '../widget-sources/index.js';
|
|
11
|
+
import {isModuleWorkerSupported} from '../workers/utils.js';
|
|
10
12
|
import {baseSource} from './base-source.js';
|
|
11
13
|
import type {
|
|
12
14
|
SourceOptions,
|
|
@@ -26,10 +28,15 @@ export const quadbinTilesetSource = async function (
|
|
|
26
28
|
const {tableName, spatialDataColumn = 'quadbin'} = options;
|
|
27
29
|
const urlParameters: UrlParameters = {name: tableName};
|
|
28
30
|
|
|
31
|
+
const WidgetSourceClass =
|
|
32
|
+
options.widgetSourceWorker !== false && isModuleWorkerSupported()
|
|
33
|
+
? WidgetTilesetWorkerSource
|
|
34
|
+
: WidgetTilesetSource;
|
|
35
|
+
|
|
29
36
|
return baseSource<UrlParameters>('tileset', options, urlParameters).then(
|
|
30
37
|
(result) => ({
|
|
31
38
|
...(result as TilejsonResult),
|
|
32
|
-
widgetSource: new
|
|
39
|
+
widgetSource: new WidgetSourceClass({
|
|
33
40
|
...options,
|
|
34
41
|
tileFormat: getTileFormat(result as TilejsonResult),
|
|
35
42
|
spatialDataColumn,
|
|
@@ -3,12 +3,6 @@
|
|
|
3
3
|
// Copyright (c) vis.gl contributors
|
|
4
4
|
|
|
5
5
|
import {baseSource} from './base-source.js';
|
|
6
|
-
import {getTileFormat} from '../utils/getTileFormat.js';
|
|
7
|
-
import {
|
|
8
|
-
WidgetRasterSource,
|
|
9
|
-
WidgetRasterSourceResult,
|
|
10
|
-
} from '../widget-sources/index.js';
|
|
11
|
-
|
|
12
6
|
import type {
|
|
13
7
|
FilterOptions,
|
|
14
8
|
SourceOptions,
|
|
@@ -24,7 +18,7 @@ type UrlParameters = {
|
|
|
24
18
|
filters?: Record<string, unknown>;
|
|
25
19
|
};
|
|
26
20
|
|
|
27
|
-
export type RasterSourceResponse = TilejsonResult
|
|
21
|
+
export type RasterSourceResponse = TilejsonResult;
|
|
28
22
|
|
|
29
23
|
export const rasterSource = async function (
|
|
30
24
|
options: RasterSourceOptions
|
|
@@ -35,16 +29,9 @@ export const rasterSource = async function (
|
|
|
35
29
|
urlParameters.filters = filters;
|
|
36
30
|
}
|
|
37
31
|
|
|
38
|
-
return baseSource<UrlParameters>(
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
...options,
|
|
43
|
-
tileFormat: getTileFormat(result as TilejsonResult),
|
|
44
|
-
spatialDataColumn: 'quadbin',
|
|
45
|
-
spatialDataType: 'quadbin',
|
|
46
|
-
rasterMetadata: (result as TilejsonResult).raster_metadata!,
|
|
47
|
-
}),
|
|
48
|
-
})
|
|
32
|
+
return baseSource<UrlParameters>(
|
|
33
|
+
'raster',
|
|
34
|
+
options,
|
|
35
|
+
urlParameters
|
|
49
36
|
) as Promise<RasterSourceResponse>;
|
|
50
37
|
};
|
package/src/sources/types.ts
CHANGED
|
@@ -191,6 +191,12 @@ export type TilesetSourceOptions = {
|
|
|
191
191
|
* Fully qualified name of tileset.
|
|
192
192
|
*/
|
|
193
193
|
tableName: string;
|
|
194
|
+
|
|
195
|
+
/**
|
|
196
|
+
* Whether to use Web Workers for local widget calculations. Workers
|
|
197
|
+
* are used by default if the runtime environment supports ES Module Workers.
|
|
198
|
+
*/
|
|
199
|
+
widgetSourceWorker?: boolean;
|
|
194
200
|
};
|
|
195
201
|
|
|
196
202
|
export type ColumnsOption = {
|
|
@@ -373,7 +379,7 @@ export type RasterMetadataBand = {
|
|
|
373
379
|
/**
|
|
374
380
|
* Default color mapping for unique values (or if coloprinterp is `palette`)
|
|
375
381
|
*/
|
|
376
|
-
colortable?: Record<string, [
|
|
382
|
+
colortable?: Record<string, number[]>;
|
|
377
383
|
|
|
378
384
|
/**
|
|
379
385
|
* No value representation.
|
|
@@ -7,7 +7,9 @@ import {getTileFormat} from '../utils/getTileFormat.js';
|
|
|
7
7
|
import {
|
|
8
8
|
WidgetTilesetSource,
|
|
9
9
|
WidgetTilesetSourceResult,
|
|
10
|
+
WidgetTilesetWorkerSource,
|
|
10
11
|
} from '../widget-sources/index.js';
|
|
12
|
+
import {isModuleWorkerSupported} from '../workers/utils.js';
|
|
11
13
|
import {baseSource} from './base-source.js';
|
|
12
14
|
import type {
|
|
13
15
|
SourceOptions,
|
|
@@ -27,10 +29,15 @@ export const vectorTilesetSource = async function (
|
|
|
27
29
|
const {tableName, spatialDataColumn = DEFAULT_GEO_COLUMN} = options;
|
|
28
30
|
const urlParameters: UrlParameters = {name: tableName};
|
|
29
31
|
|
|
32
|
+
const WidgetSourceClass =
|
|
33
|
+
options.widgetSourceWorker !== false && isModuleWorkerSupported()
|
|
34
|
+
? WidgetTilesetWorkerSource
|
|
35
|
+
: WidgetTilesetSource;
|
|
36
|
+
|
|
30
37
|
return baseSource<UrlParameters>('tileset', options, urlParameters).then(
|
|
31
38
|
(result) => ({
|
|
32
39
|
...(result as TilejsonResult),
|
|
33
|
-
widgetSource: new
|
|
40
|
+
widgetSource: new WidgetSourceClass({
|
|
34
41
|
...options,
|
|
35
42
|
tileFormat: getTileFormat(result as TilejsonResult),
|
|
36
43
|
spatialDataColumn,
|
package/src/types.ts
CHANGED
|
@@ -40,12 +40,6 @@ export type SpatialIndexTile = Tile & {
|
|
|
40
40
|
data?: (Feature & {id: bigint})[];
|
|
41
41
|
};
|
|
42
42
|
|
|
43
|
-
export type RasterTile = Tile & {
|
|
44
|
-
id: string;
|
|
45
|
-
index: {q: bigint; i: string};
|
|
46
|
-
data?: Raster;
|
|
47
|
-
};
|
|
48
|
-
|
|
49
43
|
/** @privateRemarks Source: @deck.gl/carto */
|
|
50
44
|
export type Raster = {
|
|
51
45
|
blockSize: number;
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
export * from './widget-source.js';
|
|
2
2
|
export * from './widget-query-source.js';
|
|
3
|
-
export * from './widget-raster-source.js';
|
|
4
3
|
export * from './widget-remote-source.js';
|
|
5
4
|
export * from './widget-table-source.js';
|
|
6
5
|
export * from './widget-tileset-source.js';
|
|
6
|
+
export * from './widget-tileset-worker-source.js';
|
|
7
7
|
export * from './types.js';
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import {executeModel} from '../models/index.js';
|
|
1
|
+
import {executeModel, ModelSource} from '../models/index.js';
|
|
2
2
|
import {
|
|
3
3
|
CategoryRequestOptions,
|
|
4
4
|
CategoryResponse,
|
|
@@ -17,9 +17,12 @@ import {
|
|
|
17
17
|
TimeSeriesRequestOptions,
|
|
18
18
|
TimeSeriesResponse,
|
|
19
19
|
} from './types.js';
|
|
20
|
-
import {normalizeObjectKeys} from '../utils.js';
|
|
20
|
+
import {getApplicableFilters, normalizeObjectKeys} from '../utils.js';
|
|
21
21
|
import {DEFAULT_TILE_RESOLUTION} from '../constants-internal.js';
|
|
22
22
|
import {WidgetSource, WidgetSourceProps} from './widget-source.js';
|
|
23
|
+
import {Filters} from '../types.js';
|
|
24
|
+
import {ApiVersion} from '../constants.js';
|
|
25
|
+
import {AggregationOptions} from '../sources/types.js';
|
|
23
26
|
|
|
24
27
|
export type WidgetRemoteSourceProps = WidgetSourceProps;
|
|
25
28
|
|
|
@@ -38,6 +41,36 @@ export abstract class WidgetRemoteSource<
|
|
|
38
41
|
this._headers = headers;
|
|
39
42
|
}
|
|
40
43
|
|
|
44
|
+
/**
|
|
45
|
+
* Subclasses of {@link WidgetRemoteSource} must implement this method, calling
|
|
46
|
+
* {@link WidgetRemoteSource.prototype._getModelSource} for common source
|
|
47
|
+
* properties, and adding additional required properties including 'type' and
|
|
48
|
+
* 'data'.
|
|
49
|
+
*/
|
|
50
|
+
protected abstract getModelSource(
|
|
51
|
+
filters: Filters | undefined,
|
|
52
|
+
filterOwner?: string
|
|
53
|
+
): ModelSource;
|
|
54
|
+
|
|
55
|
+
protected _getModelSource(
|
|
56
|
+
filters: Filters | undefined,
|
|
57
|
+
filterOwner?: string
|
|
58
|
+
): Omit<ModelSource, 'type' | 'data'> {
|
|
59
|
+
const props = this.props;
|
|
60
|
+
return {
|
|
61
|
+
apiVersion: props.apiVersion as ApiVersion,
|
|
62
|
+
apiBaseUrl: props.apiBaseUrl as string,
|
|
63
|
+
clientId: props.clientId as string,
|
|
64
|
+
accessToken: props.accessToken,
|
|
65
|
+
connectionName: props.connectionName,
|
|
66
|
+
filters: getApplicableFilters(filterOwner, filters || props.filters),
|
|
67
|
+
filtersLogicalOperator: props.filtersLogicalOperator,
|
|
68
|
+
spatialDataType: props.spatialDataType,
|
|
69
|
+
spatialDataColumn: props.spatialDataColumn,
|
|
70
|
+
dataResolution: (props as Partial<AggregationOptions>).dataResolution,
|
|
71
|
+
};
|
|
72
|
+
}
|
|
73
|
+
|
|
41
74
|
async getCategories(
|
|
42
75
|
options: CategoryRequestOptions
|
|
43
76
|
): Promise<CategoryResponse> {
|
|
@@ -17,19 +17,12 @@ import {
|
|
|
17
17
|
TimeSeriesResponse,
|
|
18
18
|
ViewState,
|
|
19
19
|
} from './types.js';
|
|
20
|
-
import {
|
|
21
|
-
FilterLogicalOperator,
|
|
22
|
-
Filter,
|
|
23
|
-
SpatialFilter,
|
|
24
|
-
Filters,
|
|
25
|
-
} from '../types.js';
|
|
26
|
-
import {getApplicableFilters} from '../utils.js';
|
|
20
|
+
import {FilterLogicalOperator, Filter, SpatialFilter} from '../types.js';
|
|
27
21
|
import {getClient} from '../client.js';
|
|
28
22
|
import {ModelSource} from '../models/model.js';
|
|
29
23
|
import {SourceOptions} from '../sources/index.js';
|
|
30
24
|
import {ApiVersion, DEFAULT_API_BASE_URL} from '../constants.js';
|
|
31
25
|
import {getSpatialFiltersResolution} from '../spatial-index.js';
|
|
32
|
-
import {AggregationOptions} from '../sources/types.js';
|
|
33
26
|
|
|
34
27
|
export interface WidgetSourceProps extends Omit<SourceOptions, 'filters'> {
|
|
35
28
|
apiVersion?: ApiVersion;
|
|
@@ -57,36 +50,6 @@ export abstract class WidgetSource<Props extends WidgetSourceProps> {
|
|
|
57
50
|
this.props = {...WidgetSource.defaultProps, ...props};
|
|
58
51
|
}
|
|
59
52
|
|
|
60
|
-
/**
|
|
61
|
-
* Subclasses of {@link WidgetRemoteSource} must implement this method, calling
|
|
62
|
-
* {@link WidgetRemoteSource.prototype._getModelSource} for common source
|
|
63
|
-
* properties, and adding additional required properties including 'type' and
|
|
64
|
-
* 'data'.
|
|
65
|
-
*/
|
|
66
|
-
protected abstract getModelSource(
|
|
67
|
-
filters: Filters | undefined,
|
|
68
|
-
filterOwner?: string
|
|
69
|
-
): ModelSource;
|
|
70
|
-
|
|
71
|
-
protected _getModelSource(
|
|
72
|
-
filters: Filters | undefined,
|
|
73
|
-
filterOwner?: string
|
|
74
|
-
): Omit<ModelSource, 'type' | 'data'> {
|
|
75
|
-
const props = this.props;
|
|
76
|
-
return {
|
|
77
|
-
apiVersion: props.apiVersion as ApiVersion,
|
|
78
|
-
apiBaseUrl: props.apiBaseUrl as string,
|
|
79
|
-
clientId: props.clientId as string,
|
|
80
|
-
accessToken: props.accessToken,
|
|
81
|
-
connectionName: props.connectionName,
|
|
82
|
-
filters: getApplicableFilters(filterOwner, filters || props.filters),
|
|
83
|
-
filtersLogicalOperator: props.filtersLogicalOperator,
|
|
84
|
-
spatialDataType: props.spatialDataType,
|
|
85
|
-
spatialDataColumn: props.spatialDataColumn,
|
|
86
|
-
dataResolution: (props as Partial<AggregationOptions>).dataResolution,
|
|
87
|
-
};
|
|
88
|
-
}
|
|
89
|
-
|
|
90
53
|
protected _getSpatialFiltersResolution(
|
|
91
54
|
source: Omit<ModelSource, 'type' | 'data'>,
|
|
92
55
|
spatialFilter?: SpatialFilter,
|
|
@@ -1,6 +1,5 @@
|
|
|
1
1
|
/* eslint-disable @typescript-eslint/require-await */
|
|
2
2
|
import {TilesetSourceOptions} from '../sources/index.js';
|
|
3
|
-
import type {ModelSource} from '../models/index.js';
|
|
4
3
|
import {
|
|
5
4
|
CategoryRequestOptions,
|
|
6
5
|
CategoryResponse,
|
|
@@ -20,7 +19,7 @@ import {
|
|
|
20
19
|
} from './types.js';
|
|
21
20
|
import {InvalidColumnError, assert, getApplicableFilters} from '../utils.js';
|
|
22
21
|
import {TileFormat} from '../constants.js';
|
|
23
|
-
import {Filter,
|
|
22
|
+
import {Filter, SpatialFilter, Tile} from '../types.js';
|
|
24
23
|
import {
|
|
25
24
|
TileFeatureExtractOptions,
|
|
26
25
|
applyFilters,
|
|
@@ -76,26 +75,13 @@ export type WidgetTilesetSourceResult = {widgetSource: WidgetTilesetSource};
|
|
|
76
75
|
* const { widgetSource } = await data;
|
|
77
76
|
* ```
|
|
78
77
|
*/
|
|
79
|
-
export class WidgetTilesetSource<
|
|
80
|
-
Props extends WidgetTilesetSourceProps = WidgetTilesetSourceProps,
|
|
81
|
-
> extends WidgetSource<Props> {
|
|
78
|
+
export class WidgetTilesetSource extends WidgetSource<WidgetTilesetSourceProps> {
|
|
82
79
|
private _tiles: Tile[] = [];
|
|
83
80
|
private _features: FeatureData[] = [];
|
|
84
81
|
private _tileFeatureExtractOptions: TileFeatureExtractOptions = {};
|
|
85
82
|
private _tileFeatureExtractPreviousInputs: {spatialFilter?: SpatialFilter} =
|
|
86
83
|
{};
|
|
87
84
|
|
|
88
|
-
protected override getModelSource(
|
|
89
|
-
filters: Filters | undefined,
|
|
90
|
-
filterOwner: string
|
|
91
|
-
): ModelSource {
|
|
92
|
-
return {
|
|
93
|
-
...super._getModelSource(filters, filterOwner),
|
|
94
|
-
type: 'tileset',
|
|
95
|
-
data: this.props.tableName,
|
|
96
|
-
};
|
|
97
|
-
}
|
|
98
|
-
|
|
99
85
|
/**
|
|
100
86
|
* Loads features as a list of tiles (typically provided by deck.gl).
|
|
101
87
|
* After tiles are loaded, {@link extractTileFeatures} must be called
|
|
@@ -125,10 +111,13 @@ export class WidgetTilesetSource<
|
|
|
125
111
|
}
|
|
126
112
|
|
|
127
113
|
this._features = tileFeatures({
|
|
128
|
-
...this.props,
|
|
129
|
-
...this._tileFeatureExtractOptions,
|
|
130
114
|
tiles: this._tiles,
|
|
115
|
+
tileFormat: this.props.tileFormat,
|
|
116
|
+
...this._tileFeatureExtractOptions,
|
|
117
|
+
|
|
131
118
|
spatialFilter,
|
|
119
|
+
spatialDataColumn: this.props.spatialDataColumn,
|
|
120
|
+
spatialDataType: this.props.spatialDataType,
|
|
132
121
|
});
|
|
133
122
|
|
|
134
123
|
prevInputs.spatialFilter = spatialFilter;
|