@carto/api-client 0.4.8 → 0.4.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/CHANGELOG.md +4 -0
- package/build/api-client.cjs +31 -100
- package/build/api-client.cjs.map +1 -1
- package/build/api-client.modern.js +46 -114
- package/build/api-client.modern.js.map +1 -1
- package/build/models/model.d.ts +0 -1
- package/build/spatial-index.d.ts +1 -4
- package/build/widget-sources/types.d.ts +6 -1
- package/build/widget-sources/widget-source.d.ts +2 -3
- package/package.json +6 -1
- package/src/models/model.ts +0 -5
- package/src/spatial-index.ts +3 -84
- package/src/widget-sources/types.ts +6 -1
- package/src/widget-sources/widget-remote-source.ts +8 -74
- package/src/widget-sources/widget-source.ts +1 -27
package/build/models/model.d.ts
CHANGED
|
@@ -19,7 +19,6 @@ export interface ModelSource {
|
|
|
19
19
|
queryParameters?: QueryParameters;
|
|
20
20
|
spatialDataColumn?: string;
|
|
21
21
|
spatialDataType?: SpatialDataType;
|
|
22
|
-
spatialFiltersResolution?: number;
|
|
23
22
|
spatialFiltersMode?: SpatialFilterPolyfillMode;
|
|
24
23
|
/** original resolution of the spatial index data as stored in the DW */
|
|
25
24
|
dataResolution?: number;
|
package/build/spatial-index.d.ts
CHANGED
|
@@ -1,12 +1,9 @@
|
|
|
1
|
-
import type { ModelSource } from './models/model.js';
|
|
2
|
-
import type { AggregationOptions } from './sources/types.js';
|
|
3
|
-
import type { ViewState } from './widget-sources/index.js';
|
|
4
|
-
export declare function getSpatialFiltersResolution(source: Partial<ModelSource & AggregationOptions>, viewState: ViewState): number | undefined;
|
|
5
1
|
/**
|
|
6
2
|
* Resolution conversion function. Takes a WebMercatorViewport and returns
|
|
7
3
|
* a H3 resolution such that the screen space size of the hexagons is
|
|
8
4
|
* "similar" to the given tileSize on screen. Intended for use with deck.gl.
|
|
9
5
|
* @internal
|
|
6
|
+
* @privateRemarks Source: https://github.com/visgl/deck.gl/blob/master/modules/carto/src/layers/h3-tileset-2d.ts
|
|
10
7
|
*/
|
|
11
8
|
export declare function _getHexagonResolution(viewport: {
|
|
12
9
|
zoom: number;
|
|
@@ -15,7 +15,12 @@ interface BaseRequestOptions {
|
|
|
15
15
|
signal?: AbortSignal;
|
|
16
16
|
spatialFilter?: SpatialFilter;
|
|
17
17
|
spatialFiltersMode?: SpatialFilterPolyfillMode;
|
|
18
|
-
/**
|
|
18
|
+
/**
|
|
19
|
+
* Deprecated parameter previously used for H3 and Quadbin widgets. Now has
|
|
20
|
+
* no effect and will be removed in a future version.
|
|
21
|
+
* @deprecated Parameter has no effect.
|
|
22
|
+
* @todo TODO(v0.5): Remove spatialIndexReferenceViewState parameter.
|
|
23
|
+
*/
|
|
19
24
|
spatialIndexReferenceViewState?: ViewState;
|
|
20
25
|
/** Overrides source filters, if any. */
|
|
21
26
|
filters?: Filters;
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { CategoryRequestOptions, CategoryResponse, FeaturesRequestOptions, FeaturesResponse, FormulaRequestOptions, FormulaResponse, HistogramRequestOptions, HistogramResponse, RangeRequestOptions, RangeResponse, ScatterRequestOptions, ScatterResponse, TableRequestOptions, TableResponse, TimeSeriesRequestOptions, TimeSeriesResponse
|
|
2
|
-
import { FilterLogicalOperator, Filter,
|
|
1
|
+
import { CategoryRequestOptions, CategoryResponse, FeaturesRequestOptions, FeaturesResponse, FormulaRequestOptions, FormulaResponse, HistogramRequestOptions, HistogramResponse, RangeRequestOptions, RangeResponse, ScatterRequestOptions, ScatterResponse, TableRequestOptions, TableResponse, TimeSeriesRequestOptions, TimeSeriesResponse } from './types.js';
|
|
2
|
+
import { FilterLogicalOperator, Filter, Filters } from '../types.js';
|
|
3
3
|
import { ModelSource } from '../models/model.js';
|
|
4
4
|
import { SourceOptions } from '../sources/index.js';
|
|
5
5
|
import { ApiVersion } from '../constants.js';
|
|
@@ -25,7 +25,6 @@ export declare abstract class WidgetSource<Props extends WidgetSourceProps> {
|
|
|
25
25
|
*/
|
|
26
26
|
protected abstract getModelSource(filters: Filters | undefined, filterOwner?: string): ModelSource;
|
|
27
27
|
protected _getModelSource(filters: Filters | undefined, filterOwner?: string): Omit<ModelSource, 'type' | 'data'>;
|
|
28
|
-
protected _getSpatialFiltersResolution(source: Omit<ModelSource, 'type' | 'data'>, spatialFilter?: SpatialFilter, referenceViewState?: ViewState): number | undefined;
|
|
29
28
|
/**
|
|
30
29
|
* Returns a list of labeled datapoints for categorical data. Suitable for
|
|
31
30
|
* charts including grouped bar charts, pie charts, and tree charts.
|
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.4.
|
|
11
|
+
"version": "0.4.9",
|
|
12
12
|
"license": "MIT",
|
|
13
13
|
"publishConfig": {
|
|
14
14
|
"access": "public"
|
|
@@ -68,6 +68,7 @@
|
|
|
68
68
|
"@turf/invariant": "^7.2.0",
|
|
69
69
|
"@turf/union": "^7.2.0",
|
|
70
70
|
"@types/geojson": "^7946.0.16",
|
|
71
|
+
"d3-scale": "^4.0.2",
|
|
71
72
|
"h3-js": "4.1.0"
|
|
72
73
|
},
|
|
73
74
|
"devDependencies": {
|
|
@@ -76,9 +77,12 @@
|
|
|
76
77
|
"@deck.gl/core": "~9.1.0",
|
|
77
78
|
"@deck.gl/extensions": "~9.1.0",
|
|
78
79
|
"@deck.gl/geo-layers": "~9.1.0",
|
|
80
|
+
"@deck.gl/google-maps": "~9.1.0",
|
|
79
81
|
"@deck.gl/layers": "~9.1.0",
|
|
82
|
+
"@deck.gl/mapbox": "~9.1.0",
|
|
80
83
|
"@deck.gl/mesh-layers": "~9.1.0",
|
|
81
84
|
"@eslint/js": "^9.20.0",
|
|
85
|
+
"@googlemaps/js-api-loader": "^1.16.6",
|
|
82
86
|
"@lit/react": "^1.0.7",
|
|
83
87
|
"@lit/task": "^1.0.2",
|
|
84
88
|
"@loaders.gl/core": "^4.3.3",
|
|
@@ -87,6 +91,7 @@
|
|
|
87
91
|
"@luma.gl/shadertools": "~9.1.0",
|
|
88
92
|
"@turf/buffer": "^7.2.0",
|
|
89
93
|
"@turf/random": "^7.2.0",
|
|
94
|
+
"@types/d3-scale": "^4.0.9",
|
|
90
95
|
"@types/json-schema": "^7.0.15",
|
|
91
96
|
"@types/react": "^18.3.18",
|
|
92
97
|
"@types/semver": "^7.5.8",
|
package/src/models/model.ts
CHANGED
|
@@ -39,7 +39,6 @@ export interface ModelSource {
|
|
|
39
39
|
queryParameters?: QueryParameters;
|
|
40
40
|
spatialDataColumn?: string;
|
|
41
41
|
spatialDataType?: SpatialDataType;
|
|
42
|
-
spatialFiltersResolution?: number;
|
|
43
42
|
spatialFiltersMode?: SpatialFilterPolyfillMode;
|
|
44
43
|
/** original resolution of the spatial index data as stored in the DW */
|
|
45
44
|
dataResolution?: number;
|
|
@@ -86,7 +85,6 @@ export function executeModel(props: {
|
|
|
86
85
|
filtersLogicalOperator = 'and',
|
|
87
86
|
spatialDataType = 'geo',
|
|
88
87
|
spatialFiltersMode = 'intersects',
|
|
89
|
-
spatialFiltersResolution = 0,
|
|
90
88
|
} = source;
|
|
91
89
|
|
|
92
90
|
const queryParams: Record<string, unknown> = {
|
|
@@ -118,9 +116,6 @@ export function executeModel(props: {
|
|
|
118
116
|
}
|
|
119
117
|
|
|
120
118
|
if (spatialDataType !== 'geo') {
|
|
121
|
-
if (spatialFiltersResolution > 0) {
|
|
122
|
-
queryParams.spatialFiltersResolution = spatialFiltersResolution;
|
|
123
|
-
}
|
|
124
119
|
queryParams.spatialFiltersMode = spatialFiltersMode;
|
|
125
120
|
}
|
|
126
121
|
|
package/src/spatial-index.ts
CHANGED
|
@@ -1,88 +1,6 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
DEFAULT_AGGREGATION_RES_LEVEL_QUADBIN,
|
|
4
|
-
} from './constants-internal.js';
|
|
5
|
-
import type {ModelSource} from './models/model.js';
|
|
6
|
-
import type {AggregationOptions} from './sources/types.js';
|
|
7
|
-
import type {ViewState} from './widget-sources/index.js';
|
|
8
|
-
|
|
1
|
+
// Default tile display size in deck.gl, in viewport pixels. May differ
|
|
2
|
+
// from size or resolution assumed when generating the tile data,
|
|
9
3
|
const DEFAULT_TILE_SIZE = 512;
|
|
10
|
-
const QUADBIN_ZOOM_MAX_OFFSET = 4;
|
|
11
|
-
|
|
12
|
-
export function getSpatialFiltersResolution(
|
|
13
|
-
source: Partial<ModelSource & AggregationOptions>,
|
|
14
|
-
viewState: ViewState
|
|
15
|
-
): number | undefined {
|
|
16
|
-
const dataResolution = source.dataResolution ?? Number.MAX_VALUE;
|
|
17
|
-
|
|
18
|
-
const aggregationResLevel =
|
|
19
|
-
source.aggregationResLevel ??
|
|
20
|
-
(source.spatialDataType === 'h3'
|
|
21
|
-
? DEFAULT_AGGREGATION_RES_LEVEL_H3
|
|
22
|
-
: DEFAULT_AGGREGATION_RES_LEVEL_QUADBIN);
|
|
23
|
-
|
|
24
|
-
const aggregationResLevelOffset = Math.max(
|
|
25
|
-
0,
|
|
26
|
-
Math.floor(aggregationResLevel)
|
|
27
|
-
);
|
|
28
|
-
|
|
29
|
-
const currentZoomInt = Math.ceil(viewState.zoom);
|
|
30
|
-
if (source.spatialDataType === 'h3') {
|
|
31
|
-
const tileSize = DEFAULT_TILE_SIZE;
|
|
32
|
-
const maxResolutionForZoom =
|
|
33
|
-
maxH3SpatialFiltersResolutions.find(
|
|
34
|
-
([zoom]) => zoom === currentZoomInt
|
|
35
|
-
)?.[1] ?? Math.max(0, currentZoomInt - 3);
|
|
36
|
-
|
|
37
|
-
const maxSpatialFiltersResolution = maxResolutionForZoom
|
|
38
|
-
? Math.min(dataResolution, maxResolutionForZoom)
|
|
39
|
-
: dataResolution;
|
|
40
|
-
|
|
41
|
-
const hexagonResolution =
|
|
42
|
-
_getHexagonResolution(viewState, tileSize) + aggregationResLevelOffset;
|
|
43
|
-
|
|
44
|
-
return Math.min(hexagonResolution, maxSpatialFiltersResolution);
|
|
45
|
-
}
|
|
46
|
-
|
|
47
|
-
if (source.spatialDataType === 'quadbin') {
|
|
48
|
-
const maxResolutionForZoom = currentZoomInt + QUADBIN_ZOOM_MAX_OFFSET;
|
|
49
|
-
const maxSpatialFiltersResolution = Math.min(
|
|
50
|
-
dataResolution,
|
|
51
|
-
maxResolutionForZoom
|
|
52
|
-
);
|
|
53
|
-
|
|
54
|
-
const quadsResolution =
|
|
55
|
-
Math.floor(viewState.zoom) + aggregationResLevelOffset;
|
|
56
|
-
return Math.min(quadsResolution, maxSpatialFiltersResolution);
|
|
57
|
-
}
|
|
58
|
-
|
|
59
|
-
return undefined;
|
|
60
|
-
}
|
|
61
|
-
|
|
62
|
-
const maxH3SpatialFiltersResolutions = [
|
|
63
|
-
[20, 14],
|
|
64
|
-
[19, 13],
|
|
65
|
-
[18, 12],
|
|
66
|
-
[17, 11],
|
|
67
|
-
[16, 10],
|
|
68
|
-
[15, 9],
|
|
69
|
-
[14, 8],
|
|
70
|
-
[13, 7],
|
|
71
|
-
[12, 7],
|
|
72
|
-
[11, 7],
|
|
73
|
-
[10, 6],
|
|
74
|
-
[9, 6],
|
|
75
|
-
[8, 5],
|
|
76
|
-
[7, 4],
|
|
77
|
-
[6, 4],
|
|
78
|
-
[5, 3],
|
|
79
|
-
[4, 2],
|
|
80
|
-
[3, 1],
|
|
81
|
-
[2, 1],
|
|
82
|
-
[1, 0],
|
|
83
|
-
];
|
|
84
|
-
|
|
85
|
-
// stolen from https://github.com/visgl/deck.gl/blob/master/modules/carto/src/layers/h3-tileset-2d.ts
|
|
86
4
|
|
|
87
5
|
// Relative scale factor (0 = no biasing, 2 = a few hexagons cover view)
|
|
88
6
|
const BIAS = 2;
|
|
@@ -92,6 +10,7 @@ const BIAS = 2;
|
|
|
92
10
|
* a H3 resolution such that the screen space size of the hexagons is
|
|
93
11
|
* "similar" to the given tileSize on screen. Intended for use with deck.gl.
|
|
94
12
|
* @internal
|
|
13
|
+
* @privateRemarks Source: https://github.com/visgl/deck.gl/blob/master/modules/carto/src/layers/h3-tileset-2d.ts
|
|
95
14
|
*/
|
|
96
15
|
export function _getHexagonResolution(
|
|
97
16
|
viewport: {zoom: number; latitude: number},
|
|
@@ -24,7 +24,12 @@ interface BaseRequestOptions {
|
|
|
24
24
|
signal?: AbortSignal;
|
|
25
25
|
spatialFilter?: SpatialFilter;
|
|
26
26
|
spatialFiltersMode?: SpatialFilterPolyfillMode;
|
|
27
|
-
/**
|
|
27
|
+
/**
|
|
28
|
+
* Deprecated parameter previously used for H3 and Quadbin widgets. Now has
|
|
29
|
+
* no effect and will be removed in a future version.
|
|
30
|
+
* @deprecated Parameter has no effect.
|
|
31
|
+
* @todo TODO(v0.5): Remove spatialIndexReferenceViewState parameter.
|
|
32
|
+
*/
|
|
28
33
|
spatialIndexReferenceViewState?: ViewState;
|
|
29
34
|
/** Overrides source filters, if any. */
|
|
30
35
|
filters?: Filters;
|
|
@@ -40,24 +40,16 @@ export abstract class WidgetRemoteSource<
|
|
|
40
40
|
filterOwner,
|
|
41
41
|
spatialFilter,
|
|
42
42
|
spatialFiltersMode,
|
|
43
|
-
spatialIndexReferenceViewState,
|
|
44
43
|
...params
|
|
45
44
|
} = options;
|
|
46
45
|
const {column, operation, operationColumn} = params;
|
|
47
|
-
const source = this.getModelSource(filters, filterOwner);
|
|
48
|
-
const spatialFiltersResolution = this._getSpatialFiltersResolution(
|
|
49
|
-
source,
|
|
50
|
-
spatialFilter,
|
|
51
|
-
spatialIndexReferenceViewState
|
|
52
|
-
);
|
|
53
46
|
|
|
54
47
|
type CategoriesModelResponse = {rows: {name: string; value: number}[]};
|
|
55
48
|
|
|
56
49
|
return executeModel({
|
|
57
50
|
model: 'category',
|
|
58
51
|
source: {
|
|
59
|
-
...
|
|
60
|
-
spatialFiltersResolution,
|
|
52
|
+
...this.getModelSource(filters, filterOwner),
|
|
61
53
|
spatialFiltersMode,
|
|
62
54
|
spatialFilter,
|
|
63
55
|
},
|
|
@@ -80,24 +72,16 @@ export abstract class WidgetRemoteSource<
|
|
|
80
72
|
filterOwner,
|
|
81
73
|
spatialFilter,
|
|
82
74
|
spatialFiltersMode,
|
|
83
|
-
spatialIndexReferenceViewState,
|
|
84
75
|
...params
|
|
85
76
|
} = options;
|
|
86
77
|
const {columns, dataType, featureIds, z, limit, tileResolution} = params;
|
|
87
|
-
const source = this.getModelSource(filters, filterOwner);
|
|
88
|
-
const spatialFiltersResolution = this._getSpatialFiltersResolution(
|
|
89
|
-
source,
|
|
90
|
-
spatialFilter,
|
|
91
|
-
spatialIndexReferenceViewState
|
|
92
|
-
);
|
|
93
78
|
|
|
94
79
|
type FeaturesModelResponse = {rows: Record<string, unknown>[]};
|
|
95
80
|
|
|
96
81
|
return executeModel({
|
|
97
82
|
model: 'pick',
|
|
98
83
|
source: {
|
|
99
|
-
...
|
|
100
|
-
spatialFiltersResolution,
|
|
84
|
+
...this.getModelSource(filters, filterOwner),
|
|
101
85
|
spatialFiltersMode,
|
|
102
86
|
spatialFilter,
|
|
103
87
|
},
|
|
@@ -122,25 +106,17 @@ export abstract class WidgetRemoteSource<
|
|
|
122
106
|
filterOwner,
|
|
123
107
|
spatialFilter,
|
|
124
108
|
spatialFiltersMode,
|
|
125
|
-
spatialIndexReferenceViewState,
|
|
126
109
|
operationExp,
|
|
127
110
|
...params
|
|
128
111
|
} = options;
|
|
129
112
|
const {column, operation} = params;
|
|
130
|
-
const source = this.getModelSource(filters, filterOwner);
|
|
131
|
-
const spatialFiltersResolution = this._getSpatialFiltersResolution(
|
|
132
|
-
source,
|
|
133
|
-
spatialFilter,
|
|
134
|
-
spatialIndexReferenceViewState
|
|
135
|
-
);
|
|
136
113
|
|
|
137
114
|
type FormulaModelResponse = {rows: {value: number}[]};
|
|
138
115
|
|
|
139
116
|
return executeModel({
|
|
140
117
|
model: 'formula',
|
|
141
118
|
source: {
|
|
142
|
-
...
|
|
143
|
-
spatialFiltersResolution,
|
|
119
|
+
...this.getModelSource(filters, filterOwner),
|
|
144
120
|
spatialFiltersMode,
|
|
145
121
|
spatialFilter,
|
|
146
122
|
},
|
|
@@ -163,24 +139,16 @@ export abstract class WidgetRemoteSource<
|
|
|
163
139
|
filterOwner,
|
|
164
140
|
spatialFilter,
|
|
165
141
|
spatialFiltersMode,
|
|
166
|
-
spatialIndexReferenceViewState,
|
|
167
142
|
...params
|
|
168
143
|
} = options;
|
|
169
144
|
const {column, operation, ticks} = params;
|
|
170
|
-
const source = this.getModelSource(filters, filterOwner);
|
|
171
|
-
const spatialFiltersResolution = this._getSpatialFiltersResolution(
|
|
172
|
-
source,
|
|
173
|
-
spatialFilter,
|
|
174
|
-
spatialIndexReferenceViewState
|
|
175
|
-
);
|
|
176
145
|
|
|
177
146
|
type HistogramModelResponse = {rows: {tick: number; value: number}[]};
|
|
178
147
|
|
|
179
148
|
const data = await executeModel({
|
|
180
149
|
model: 'histogram',
|
|
181
150
|
source: {
|
|
182
|
-
...
|
|
183
|
-
spatialFiltersResolution,
|
|
151
|
+
...this.getModelSource(filters, filterOwner),
|
|
184
152
|
spatialFiltersMode,
|
|
185
153
|
spatialFilter,
|
|
186
154
|
},
|
|
@@ -209,24 +177,16 @@ export abstract class WidgetRemoteSource<
|
|
|
209
177
|
filterOwner,
|
|
210
178
|
spatialFilter,
|
|
211
179
|
spatialFiltersMode,
|
|
212
|
-
spatialIndexReferenceViewState,
|
|
213
180
|
...params
|
|
214
181
|
} = options;
|
|
215
182
|
const {column} = params;
|
|
216
|
-
const source = this.getModelSource(filters, filterOwner);
|
|
217
|
-
const spatialFiltersResolution = this._getSpatialFiltersResolution(
|
|
218
|
-
source,
|
|
219
|
-
spatialFilter,
|
|
220
|
-
spatialIndexReferenceViewState
|
|
221
|
-
);
|
|
222
183
|
|
|
223
184
|
type RangeModelResponse = {rows: {min: number; max: number}[]};
|
|
224
185
|
|
|
225
186
|
return executeModel({
|
|
226
187
|
model: 'range',
|
|
227
188
|
source: {
|
|
228
|
-
...
|
|
229
|
-
spatialFiltersResolution,
|
|
189
|
+
...this.getModelSource(filters, filterOwner),
|
|
230
190
|
spatialFiltersMode,
|
|
231
191
|
spatialFilter,
|
|
232
192
|
},
|
|
@@ -243,19 +203,11 @@ export abstract class WidgetRemoteSource<
|
|
|
243
203
|
filterOwner,
|
|
244
204
|
spatialFilter,
|
|
245
205
|
spatialFiltersMode,
|
|
246
|
-
spatialIndexReferenceViewState,
|
|
247
206
|
...params
|
|
248
207
|
} = options;
|
|
249
208
|
const {xAxisColumn, xAxisJoinOperation, yAxisColumn, yAxisJoinOperation} =
|
|
250
209
|
params;
|
|
251
210
|
|
|
252
|
-
const source = this.getModelSource(filters, filterOwner);
|
|
253
|
-
const spatialFiltersResolution = this._getSpatialFiltersResolution(
|
|
254
|
-
source,
|
|
255
|
-
spatialFilter,
|
|
256
|
-
spatialIndexReferenceViewState
|
|
257
|
-
);
|
|
258
|
-
|
|
259
211
|
// Make sure this is sync with the same constant in cloud-native/maps-api
|
|
260
212
|
const HARD_LIMIT = 500;
|
|
261
213
|
|
|
@@ -264,8 +216,7 @@ export abstract class WidgetRemoteSource<
|
|
|
264
216
|
return executeModel({
|
|
265
217
|
model: 'scatterplot',
|
|
266
218
|
source: {
|
|
267
|
-
...
|
|
268
|
-
spatialFiltersResolution,
|
|
219
|
+
...this.getModelSource(filters, filterOwner),
|
|
269
220
|
spatialFiltersMode,
|
|
270
221
|
spatialFilter,
|
|
271
222
|
},
|
|
@@ -290,16 +241,9 @@ export abstract class WidgetRemoteSource<
|
|
|
290
241
|
filterOwner,
|
|
291
242
|
spatialFilter,
|
|
292
243
|
spatialFiltersMode,
|
|
293
|
-
spatialIndexReferenceViewState,
|
|
294
244
|
...params
|
|
295
245
|
} = options;
|
|
296
246
|
const {columns, sortBy, sortDirection, offset = 0, limit = 10} = params;
|
|
297
|
-
const source = this.getModelSource(filters, filterOwner);
|
|
298
|
-
const spatialFiltersResolution = this._getSpatialFiltersResolution(
|
|
299
|
-
source,
|
|
300
|
-
spatialFilter,
|
|
301
|
-
spatialIndexReferenceViewState
|
|
302
|
-
);
|
|
303
247
|
|
|
304
248
|
type TableModelResponse = {
|
|
305
249
|
rows: Record<string, number | string>[];
|
|
@@ -309,8 +253,7 @@ export abstract class WidgetRemoteSource<
|
|
|
309
253
|
return executeModel({
|
|
310
254
|
model: 'table',
|
|
311
255
|
source: {
|
|
312
|
-
...
|
|
313
|
-
spatialFiltersResolution,
|
|
256
|
+
...this.getModelSource(filters, filterOwner),
|
|
314
257
|
spatialFiltersMode,
|
|
315
258
|
spatialFilter,
|
|
316
259
|
},
|
|
@@ -339,7 +282,6 @@ export abstract class WidgetRemoteSource<
|
|
|
339
282
|
filterOwner,
|
|
340
283
|
spatialFilter,
|
|
341
284
|
spatialFiltersMode,
|
|
342
|
-
spatialIndexReferenceViewState,
|
|
343
285
|
...params
|
|
344
286
|
} = options;
|
|
345
287
|
const {
|
|
@@ -354,13 +296,6 @@ export abstract class WidgetRemoteSource<
|
|
|
354
296
|
splitByCategoryValues,
|
|
355
297
|
} = params;
|
|
356
298
|
|
|
357
|
-
const source = this.getModelSource(filters, filterOwner);
|
|
358
|
-
const spatialFiltersResolution = this._getSpatialFiltersResolution(
|
|
359
|
-
source,
|
|
360
|
-
spatialFilter,
|
|
361
|
-
spatialIndexReferenceViewState
|
|
362
|
-
);
|
|
363
|
-
|
|
364
299
|
type TimeSeriesModelResponse = {
|
|
365
300
|
rows: {name: string; value: number}[];
|
|
366
301
|
metadata: {categories: string[]};
|
|
@@ -369,8 +304,7 @@ export abstract class WidgetRemoteSource<
|
|
|
369
304
|
return executeModel({
|
|
370
305
|
model: 'timeseries',
|
|
371
306
|
source: {
|
|
372
|
-
...
|
|
373
|
-
spatialFiltersResolution,
|
|
307
|
+
...this.getModelSource(filters, filterOwner),
|
|
374
308
|
spatialFiltersMode,
|
|
375
309
|
spatialFilter,
|
|
376
310
|
},
|
|
@@ -15,20 +15,13 @@ import {
|
|
|
15
15
|
TableResponse,
|
|
16
16
|
TimeSeriesRequestOptions,
|
|
17
17
|
TimeSeriesResponse,
|
|
18
|
-
ViewState,
|
|
19
18
|
} from './types.js';
|
|
20
|
-
import {
|
|
21
|
-
FilterLogicalOperator,
|
|
22
|
-
Filter,
|
|
23
|
-
SpatialFilter,
|
|
24
|
-
Filters,
|
|
25
|
-
} from '../types.js';
|
|
19
|
+
import {FilterLogicalOperator, Filter, Filters} from '../types.js';
|
|
26
20
|
import {getApplicableFilters} from '../utils.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
|
-
import {getSpatialFiltersResolution} from '../spatial-index.js';
|
|
32
25
|
import {AggregationOptions} from '../sources/types.js';
|
|
33
26
|
|
|
34
27
|
export interface WidgetSourceProps extends Omit<SourceOptions, 'filters'> {
|
|
@@ -91,25 +84,6 @@ export abstract class WidgetSource<Props extends WidgetSourceProps> {
|
|
|
91
84
|
};
|
|
92
85
|
}
|
|
93
86
|
|
|
94
|
-
protected _getSpatialFiltersResolution(
|
|
95
|
-
source: Omit<ModelSource, 'type' | 'data'>,
|
|
96
|
-
spatialFilter?: SpatialFilter,
|
|
97
|
-
referenceViewState?: ViewState
|
|
98
|
-
): number | undefined {
|
|
99
|
-
// spatialFiltersResolution applies only to spatial index sources.
|
|
100
|
-
if (!spatialFilter || source.spatialDataType === 'geo') {
|
|
101
|
-
return;
|
|
102
|
-
}
|
|
103
|
-
|
|
104
|
-
if (!referenceViewState) {
|
|
105
|
-
throw new Error(
|
|
106
|
-
'Missing required option, "spatialIndexReferenceViewState".'
|
|
107
|
-
);
|
|
108
|
-
}
|
|
109
|
-
|
|
110
|
-
return getSpatialFiltersResolution(source, referenceViewState);
|
|
111
|
-
}
|
|
112
|
-
|
|
113
87
|
/**
|
|
114
88
|
* Returns a list of labeled datapoints for categorical data. Suitable for
|
|
115
89
|
* charts including grouped bar charts, pie charts, and tree charts.
|