@carto/api-client 0.5.0-alpha.1 → 0.5.0-alpha.11
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 +3163 -3206
- package/build/api-client.cjs.map +1 -1
- package/build/api-client.d.cts +1389 -0
- package/build/api-client.d.ts +1389 -0
- package/build/api-client.js +3674 -0
- package/build/api-client.js.map +1 -0
- package/build/worker.d.ts +2 -0
- package/build/worker.js +1949 -0
- package/build/worker.js.map +1 -0
- package/package.json +60 -45
- package/src/api/carto-api-error.ts +1 -1
- package/src/api/query.ts +5 -5
- package/src/api/request-with-parameters.ts +6 -6
- package/src/client.ts +3 -3
- package/src/constants-internal.ts +5 -11
- package/src/constants.ts +6 -6
- package/src/deck/get-data-filter-extension-props.ts +146 -0
- package/src/deck/index.ts +1 -0
- package/src/filters/Filter.ts +18 -8
- package/src/filters/FilterTypes.ts +2 -2
- package/src/filters/geosjonFeatures.ts +2 -2
- package/src/filters/tileFeatures.ts +12 -17
- package/src/filters.ts +4 -4
- package/src/geo.ts +12 -14
- package/src/global.d.ts +3 -8
- package/src/index.ts +3 -0
- package/src/models/common.ts +11 -9
- package/src/models/model.ts +3 -4
- package/src/operations/aggregation.ts +5 -5
- package/src/operations/applySorting.ts +4 -4
- package/src/operations/groupBy.ts +4 -4
- package/src/operations/groupByDate.ts +1 -1
- package/src/operations/histogram.ts +4 -4
- package/src/operations/scatterPlot.ts +4 -4
- package/src/sources/base-source.ts +8 -8
- package/src/sources/boundary-query-source.ts +2 -2
- package/src/sources/boundary-table-source.ts +2 -2
- package/src/sources/h3-query-source.ts +7 -5
- package/src/sources/h3-table-source.ts +7 -5
- package/src/sources/h3-tileset-source.ts +4 -4
- package/src/sources/index.ts +26 -26
- package/src/sources/quadbin-query-source.ts +7 -5
- package/src/sources/quadbin-table-source.ts +7 -5
- package/src/sources/quadbin-tileset-source.ts +4 -4
- package/src/sources/raster-source.ts +2 -2
- package/src/sources/types.ts +9 -3
- package/src/sources/vector-query-source.ts +2 -3
- package/src/sources/vector-table-source.ts +2 -3
- package/src/sources/vector-tileset-source.ts +5 -5
- package/src/spatial-index.ts +12 -10
- package/src/types-internal.ts +5 -5
- package/src/types.ts +15 -15
- package/src/utils/makeIntervalComplete.ts +1 -1
- package/src/utils.ts +3 -3
- package/src/widget-sources/index.ts +1 -0
- package/src/widget-sources/types.ts +6 -4
- package/src/widget-sources/widget-query-source.ts +6 -2
- package/src/widget-sources/widget-remote-source.ts +67 -26
- package/src/widget-sources/widget-source.ts +10 -25
- package/src/widget-sources/widget-table-source.ts +6 -2
- package/src/widget-sources/widget-tileset-source-impl.ts +417 -0
- package/src/widget-sources/widget-tileset-source.ts +200 -299
- package/src/workers/constants.ts +13 -0
- package/src/workers/types.ts +19 -0
- package/src/workers/widget-tileset-worker.ts +40 -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.modern.js +0 -3574
- 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/filters/Filter.d.ts +0 -13
- 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 -20
- package/build/filters/tileFeaturesGeometries.d.ts +0 -13
- 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 -14
- package/build/models/common.d.ts +0 -27
- 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 -4
- 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 -8
- package/build/types-internal.d.ts +0 -56
- package/build/types.d.ts +0 -140
- 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 -5
- package/build/widget-sources/types.d.ts +0 -158
- package/build/widget-sources/widget-query-source.d.ts +0 -33
- package/build/widget-sources/widget-remote-source.d.ts +0 -18
- package/build/widget-sources/widget-source.d.ts +0 -74
- package/build/widget-sources/widget-table-source.d.ts +0 -33
- package/build/widget-sources/widget-tileset-source.d.ts +0 -76
|
@@ -0,0 +1,1389 @@
|
|
|
1
|
+
import { Polygon, MultiPolygon, Feature, BBox, FeatureCollection, Geometry } from 'geojson';
|
|
2
|
+
import { BinaryFeatureCollection, BinaryFeature } from '@loaders.gl/schema';
|
|
3
|
+
|
|
4
|
+
/**
|
|
5
|
+
* Returns current client ID, used to categorize API requests. For internal use only.
|
|
6
|
+
*
|
|
7
|
+
* @internal
|
|
8
|
+
* @privateRemarks Source: @carto/react-core
|
|
9
|
+
*/
|
|
10
|
+
declare function getClient(): string;
|
|
11
|
+
/**
|
|
12
|
+
* Sets current client ID, used to categorize API requests. For internal use only.
|
|
13
|
+
*
|
|
14
|
+
* @internal
|
|
15
|
+
* @privateRemarks Source: @carto/react-core
|
|
16
|
+
*/
|
|
17
|
+
declare function setClient(c: string): void;
|
|
18
|
+
|
|
19
|
+
/**
|
|
20
|
+
* Defines a comparator used when matching a column's values against given filter values.
|
|
21
|
+
*
|
|
22
|
+
* Example:
|
|
23
|
+
*
|
|
24
|
+
* ```javascript
|
|
25
|
+
* import { FilterType } from '@carto/api-client';
|
|
26
|
+
* const filters = {
|
|
27
|
+
* column_name: { [FilterType.IN]: { values: ['a', 'b', 'c'] } }
|
|
28
|
+
* };
|
|
29
|
+
* ```
|
|
30
|
+
*
|
|
31
|
+
* @privateRemarks Source: @carto/react-api, @deck.gl/carto
|
|
32
|
+
*/
|
|
33
|
+
declare enum FilterType {
|
|
34
|
+
IN = "in",
|
|
35
|
+
/** [a, b] both are included. */
|
|
36
|
+
BETWEEN = "between",
|
|
37
|
+
/** [a, b) a is included, b is not. */
|
|
38
|
+
CLOSED_OPEN = "closed_open",
|
|
39
|
+
TIME = "time",
|
|
40
|
+
STRING_SEARCH = "stringSearch"
|
|
41
|
+
}
|
|
42
|
+
/** @privateRemarks Source: @carto/constants */
|
|
43
|
+
declare enum ApiVersion {
|
|
44
|
+
V1 = "v1",
|
|
45
|
+
V2 = "v2",
|
|
46
|
+
V3 = "v3"
|
|
47
|
+
}
|
|
48
|
+
/** @privateRemarks Source: @carto/constants, @deck.gl/carto */
|
|
49
|
+
declare const DEFAULT_API_BASE_URL = "https://gcp-us-east1.api.carto.com";
|
|
50
|
+
/** @privateRemarks Source: @carto/react-core */
|
|
51
|
+
declare enum TileFormat {
|
|
52
|
+
MVT = "mvt",
|
|
53
|
+
JSON = "json",
|
|
54
|
+
GEOJSON = "geojson",
|
|
55
|
+
BINARY = "binary"
|
|
56
|
+
}
|
|
57
|
+
/** @privateRemarks Source: @carto/react-core */
|
|
58
|
+
declare enum SpatialIndex {
|
|
59
|
+
H3 = "h3",
|
|
60
|
+
S2 = "s2",
|
|
61
|
+
QUADBIN = "quadbin"
|
|
62
|
+
}
|
|
63
|
+
/** @privateRemarks Source: @carto/react-core */
|
|
64
|
+
declare enum Provider {
|
|
65
|
+
BIGQUERY = "bigquery",
|
|
66
|
+
REDSHIFT = "redshift",
|
|
67
|
+
POSTGRES = "postgres",
|
|
68
|
+
SNOWFLAKE = "snowflake",
|
|
69
|
+
DATABRICKS = "databricks",
|
|
70
|
+
DATABRICKS_REST = "databricksRest"
|
|
71
|
+
}
|
|
72
|
+
|
|
73
|
+
/******************************************************************************
|
|
74
|
+
* MAPS AND TILES
|
|
75
|
+
*/
|
|
76
|
+
/** @privateRemarks Source: @deck.gl/carto */
|
|
77
|
+
type Format = 'json' | 'geojson' | 'tilejson';
|
|
78
|
+
/** @privateRemarks Source: @carto/constants, @deck.gl/carto */
|
|
79
|
+
type MapType = 'boundary' | 'query' | 'table' | 'tileset' | 'raster';
|
|
80
|
+
/**
|
|
81
|
+
* Alias for GeoJSON 'BBox' type, semantically representing a viewport.
|
|
82
|
+
* Order of values is "west", "south", "east", "north".
|
|
83
|
+
*/
|
|
84
|
+
type Viewport = [number, number, number, number];
|
|
85
|
+
/**
|
|
86
|
+
* Subset of deck.gl's Tile2DHeader type, containing only the properties
|
|
87
|
+
* required for local widget calculations. Deeper dependencies on deck.gl
|
|
88
|
+
* APIs should be minimized within this library: @deck.gl/carto depends
|
|
89
|
+
* on the API client, not the other way around.
|
|
90
|
+
* @privateRemarks Source: @deck.gl/geo-layers
|
|
91
|
+
*/
|
|
92
|
+
type Tile = {
|
|
93
|
+
index: {
|
|
94
|
+
x: number;
|
|
95
|
+
y: number;
|
|
96
|
+
z: number;
|
|
97
|
+
};
|
|
98
|
+
id: string;
|
|
99
|
+
content: unknown;
|
|
100
|
+
zoom: number;
|
|
101
|
+
bbox: {
|
|
102
|
+
west: number;
|
|
103
|
+
east: number;
|
|
104
|
+
north: number;
|
|
105
|
+
south: number;
|
|
106
|
+
};
|
|
107
|
+
isVisible: boolean;
|
|
108
|
+
data?: BinaryFeatureCollection;
|
|
109
|
+
};
|
|
110
|
+
/** Subset of deck.gl's Tile2DHeader type, for spatial indexes. */
|
|
111
|
+
type SpatialIndexTile = Tile & {
|
|
112
|
+
data?: (Feature & {
|
|
113
|
+
id: bigint;
|
|
114
|
+
})[];
|
|
115
|
+
};
|
|
116
|
+
/** @privateRemarks Source: @deck.gl/carto */
|
|
117
|
+
type Raster = {
|
|
118
|
+
blockSize: number;
|
|
119
|
+
cells: {
|
|
120
|
+
numericProps: BinaryFeature['numericProps'];
|
|
121
|
+
properties: BinaryFeature['properties'];
|
|
122
|
+
};
|
|
123
|
+
};
|
|
124
|
+
/******************************************************************************
|
|
125
|
+
* AGGREGATION
|
|
126
|
+
*/
|
|
127
|
+
/**
|
|
128
|
+
* Enum for the different types of aggregations available for widgets.
|
|
129
|
+
*
|
|
130
|
+
* @privateRemarks Source: @carto/constants
|
|
131
|
+
* @privateRemarks Converted from enum to type union, for improved declarative API.
|
|
132
|
+
*/
|
|
133
|
+
type AggregationType = 'count' | 'avg' | 'min' | 'max' | 'sum' | 'custom';
|
|
134
|
+
/******************************************************************************
|
|
135
|
+
* FILTERS
|
|
136
|
+
*/
|
|
137
|
+
/** @privateRemarks Source: @carto/react-api */
|
|
138
|
+
type SpatialFilter = Polygon | MultiPolygon;
|
|
139
|
+
/** @privateRemarks Source: @deck.gl/carto */
|
|
140
|
+
interface Filters {
|
|
141
|
+
[column: string]: Filter;
|
|
142
|
+
}
|
|
143
|
+
/** @privateRemarks Source: @carto/react-api, @deck.gl/carto */
|
|
144
|
+
interface Filter {
|
|
145
|
+
[FilterType.IN]?: {
|
|
146
|
+
owner?: string;
|
|
147
|
+
values: number[] | string[];
|
|
148
|
+
};
|
|
149
|
+
/** [a, b] both are included. */
|
|
150
|
+
[FilterType.BETWEEN]?: {
|
|
151
|
+
owner?: string;
|
|
152
|
+
values: number[][];
|
|
153
|
+
};
|
|
154
|
+
/** [a, b) a is included, b is not. */
|
|
155
|
+
[FilterType.CLOSED_OPEN]?: {
|
|
156
|
+
owner?: string;
|
|
157
|
+
values: number[][];
|
|
158
|
+
};
|
|
159
|
+
[FilterType.TIME]?: {
|
|
160
|
+
owner?: string;
|
|
161
|
+
values: number[][];
|
|
162
|
+
};
|
|
163
|
+
[FilterType.STRING_SEARCH]?: {
|
|
164
|
+
owner?: string;
|
|
165
|
+
values: string[];
|
|
166
|
+
params?: StringSearchOptions;
|
|
167
|
+
};
|
|
168
|
+
}
|
|
169
|
+
/** @privateRemarks Source: @carto/react-core */
|
|
170
|
+
type FilterLogicalOperator = 'and' | 'or';
|
|
171
|
+
/**
|
|
172
|
+
* Type for minimum or maximum value of an interval. Values 'null' and
|
|
173
|
+
* 'undefined' are intentionally allowed, and represent an unbounded value.
|
|
174
|
+
*/
|
|
175
|
+
type FilterIntervalExtremum = number | null | undefined;
|
|
176
|
+
type FilterInterval = [FilterIntervalExtremum, FilterIntervalExtremum];
|
|
177
|
+
type FilterIntervalComplete = [number, number];
|
|
178
|
+
type StringSearchOptions = {
|
|
179
|
+
useRegExp?: boolean;
|
|
180
|
+
mustStart?: boolean;
|
|
181
|
+
mustEnd?: boolean;
|
|
182
|
+
caseSensitive?: boolean;
|
|
183
|
+
keepSpecialCharacters?: boolean;
|
|
184
|
+
};
|
|
185
|
+
/******************************************************************************
|
|
186
|
+
* GROUPING
|
|
187
|
+
*/
|
|
188
|
+
/**
|
|
189
|
+
* Defines a step size increment for use with {@link TimeSeriesRequestOptions}.
|
|
190
|
+
*
|
|
191
|
+
* @privateRemarks Source: @carto/react-core
|
|
192
|
+
*/
|
|
193
|
+
type GroupDateType = 'year' | 'month' | 'week' | 'day' | 'hour' | 'minute' | 'second';
|
|
194
|
+
/******************************************************************************
|
|
195
|
+
* SORTING
|
|
196
|
+
*/
|
|
197
|
+
type SortDirection = 'asc' | 'desc';
|
|
198
|
+
type SortColumnType = 'number' | 'string' | 'date';
|
|
199
|
+
/******************************************************************************
|
|
200
|
+
* SQL QUERY PARAMETERS
|
|
201
|
+
*/
|
|
202
|
+
/** @privateRemarks Source: @deck.gl/carto */
|
|
203
|
+
type QueryParameterValue = string | number | boolean | Array<QueryParameterValue> | object;
|
|
204
|
+
/** @privateRemarks Source: @deck.gl/carto */
|
|
205
|
+
type NamedQueryParameter = Record<string, QueryParameterValue>;
|
|
206
|
+
/** @privateRemarks Source: @deck.gl/carto */
|
|
207
|
+
type PositionalQueryParameter = QueryParameterValue[];
|
|
208
|
+
/** @privateRemarks Source: @deck.gl/carto */
|
|
209
|
+
type QueryParameters = NamedQueryParameter | PositionalQueryParameter;
|
|
210
|
+
|
|
211
|
+
/******************************************************************************
|
|
212
|
+
* COMMON
|
|
213
|
+
*/
|
|
214
|
+
|
|
215
|
+
/******************************************************************************
|
|
216
|
+
* LOCAL CALCULATIONS
|
|
217
|
+
*/
|
|
218
|
+
type FeatureData = Record<string, unknown>;
|
|
219
|
+
|
|
220
|
+
/** @experimental Prefer type definition from deck.gl. */
|
|
221
|
+
type _DataFilterExtensionProps = {
|
|
222
|
+
filterRange: number[][];
|
|
223
|
+
updateTriggers: Record<string, string>;
|
|
224
|
+
getFilterValue: (feature: Feature | FeatureData) => number[];
|
|
225
|
+
};
|
|
226
|
+
/**
|
|
227
|
+
* Creates props for DataFilterExtension, from `@deck.gl/extensions`, given
|
|
228
|
+
* a set of filters.
|
|
229
|
+
*
|
|
230
|
+
* @privateRemarks DataFilterExtension accepts up to 4 values to filter. This
|
|
231
|
+
* implementation uses the 1st for all filters except the time filter, and the
|
|
232
|
+
* 2nd for the time filter.
|
|
233
|
+
*/
|
|
234
|
+
declare function getDataFilterExtensionProps(filters: Filters, filtersLogicalOperator?: FilterLogicalOperator, filterSize?: 0 | 1 | 2 | 3 | 4): _DataFilterExtensionProps;
|
|
235
|
+
|
|
236
|
+
type FilterTypeOptions<T extends FilterType> = {
|
|
237
|
+
type: T;
|
|
238
|
+
column: string;
|
|
239
|
+
} & Filter[T];
|
|
240
|
+
type AddFilterOptions = FilterTypeOptions<FilterType.IN> | FilterTypeOptions<FilterType.BETWEEN> | FilterTypeOptions<FilterType.CLOSED_OPEN> | FilterTypeOptions<FilterType.TIME> | FilterTypeOptions<FilterType.STRING_SEARCH>;
|
|
241
|
+
/**
|
|
242
|
+
* Adds a {@link Filter} to the filter set. Any previous filters with the same
|
|
243
|
+
* `column` and `type` will be replaced.
|
|
244
|
+
*/
|
|
245
|
+
declare function addFilter(filters: Record<string, Filter>, { column, type, values, owner }: AddFilterOptions): Record<string, Filter>;
|
|
246
|
+
type RemoveFilterOptions = {
|
|
247
|
+
column: string;
|
|
248
|
+
owner?: string;
|
|
249
|
+
};
|
|
250
|
+
/**
|
|
251
|
+
* Removes one or more {@link Filter filters} from the filter set. If only
|
|
252
|
+
* `column` is specified, then all filters on that column are removed. If both
|
|
253
|
+
* `column` and `owner` are specified, then only filters for that column
|
|
254
|
+
* associated with the owner are removed.
|
|
255
|
+
*/
|
|
256
|
+
declare function removeFilter(filters: Record<string, Filter>, { column, owner }: RemoveFilterOptions): Record<string, Filter>;
|
|
257
|
+
/**
|
|
258
|
+
* Clears all {@link Filter filters} from the filter set.
|
|
259
|
+
*/
|
|
260
|
+
declare function clearFilters(filters: Record<string, Filter>): Record<string, Filter>;
|
|
261
|
+
type HasFilterOptions = {
|
|
262
|
+
column: string;
|
|
263
|
+
owner?: string;
|
|
264
|
+
};
|
|
265
|
+
declare function hasFilter(filters: Record<string, Filter>, { column, owner }: HasFilterOptions): boolean;
|
|
266
|
+
type GetFilterOptions<T extends FilterType> = {
|
|
267
|
+
column: string;
|
|
268
|
+
type: T;
|
|
269
|
+
owner?: string;
|
|
270
|
+
};
|
|
271
|
+
declare function getFilter<T extends FilterType>(filters: Record<string, Filter>, { column, type, owner }: GetFilterOptions<T>): Filter[T] | null;
|
|
272
|
+
|
|
273
|
+
/**
|
|
274
|
+
* Returns a {@link SpatialFilter} for a given viewport, typically obtained
|
|
275
|
+
* from deck.gl's `viewport.getBounds()` method ([west, south, east, north]).
|
|
276
|
+
* If the viewport covers the entire world (to some margin of error in Web
|
|
277
|
+
* Mercator space), `undefined` is returned instead.
|
|
278
|
+
*
|
|
279
|
+
* If the viewport extends beyond longitude range [-180, +180], the polygon
|
|
280
|
+
* may be reformatted for compatibility with CARTO APIs.
|
|
281
|
+
*/
|
|
282
|
+
declare function createViewportSpatialFilter(viewport: BBox): SpatialFilter | undefined;
|
|
283
|
+
/**
|
|
284
|
+
* Returns a {@link SpatialFilter} for a given {@link Polygon} or
|
|
285
|
+
* {@link MultiPolygon}. If the polygon(s) extend outside longitude
|
|
286
|
+
* range [-180, +180], the result may be reformatted for compatibility
|
|
287
|
+
* with CARTO APIs.
|
|
288
|
+
*/
|
|
289
|
+
declare function createPolygonSpatialFilter(spatialFilter: Polygon | MultiPolygon): SpatialFilter | undefined;
|
|
290
|
+
|
|
291
|
+
type SourceRequiredOptions = {
|
|
292
|
+
/** Carto platform access token. */
|
|
293
|
+
accessToken: string;
|
|
294
|
+
/** Data warehouse connection name in Carto platform. */
|
|
295
|
+
connectionName: string;
|
|
296
|
+
};
|
|
297
|
+
type SourceOptionalOptions = {
|
|
298
|
+
/**
|
|
299
|
+
* Base URL of the CARTO Maps API.
|
|
300
|
+
*
|
|
301
|
+
* Example for account located in EU-west region: `https://gcp-eu-west1.api.carto.com`
|
|
302
|
+
*
|
|
303
|
+
* @default https://gcp-us-east1.api.carto.com
|
|
304
|
+
*/
|
|
305
|
+
apiBaseUrl: string;
|
|
306
|
+
/**
|
|
307
|
+
* Custom HTTP headers added to map instantiation and data requests.
|
|
308
|
+
*/
|
|
309
|
+
headers: Record<string, string>;
|
|
310
|
+
/**
|
|
311
|
+
* Cache buster value returned by map instantiation.
|
|
312
|
+
*
|
|
313
|
+
* Carto source saves `cache` value of map instantiation response in `cache.value`, so it can be used to
|
|
314
|
+
* check if underlying map data has changed between distinct source requests.
|
|
315
|
+
*/
|
|
316
|
+
cache?: {
|
|
317
|
+
value?: number;
|
|
318
|
+
};
|
|
319
|
+
clientId: string;
|
|
320
|
+
/** @deprecated use `query` instead **/
|
|
321
|
+
format: Format;
|
|
322
|
+
/**
|
|
323
|
+
* Maximum URL character length. Above this limit, requests use POST.
|
|
324
|
+
* Used to avoid browser and CDN limits.
|
|
325
|
+
* @default {@link DEFAULT_MAX_LENGTH_URL}
|
|
326
|
+
*/
|
|
327
|
+
maxLengthURL?: number;
|
|
328
|
+
/**
|
|
329
|
+
* The column name and the type of geospatial support.
|
|
330
|
+
*
|
|
331
|
+
* If not present, defaults to `'geom'` for generic queries, `'quadbin'` for Quadbin sources and `'h3'` for H3 sources.
|
|
332
|
+
*/
|
|
333
|
+
spatialDataColumn?: string;
|
|
334
|
+
/**
|
|
335
|
+
* The type of geospatial support. Defaults to `'geo'`.
|
|
336
|
+
*/
|
|
337
|
+
spatialDataType?: SpatialDataType;
|
|
338
|
+
/**
|
|
339
|
+
* Relative resolution of a tile. Higher values increase density and data size. At `tileResolution = 1`, tile geometry is
|
|
340
|
+
* quantized to a 1024x1024 grid. Increasing or decreasing the resolution will increase or decrease the dimensions of
|
|
341
|
+
* the quantization grid proportionately.
|
|
342
|
+
*
|
|
343
|
+
* Supported `tileResolution` values, with corresponding grid sizes:
|
|
344
|
+
*
|
|
345
|
+
* - 0.25: 256x256
|
|
346
|
+
* - 0.5: 512x512
|
|
347
|
+
* - 1: 1024x1024
|
|
348
|
+
* - 2: 2048x2048
|
|
349
|
+
* - 4: 4096x4096
|
|
350
|
+
*/
|
|
351
|
+
tileResolution?: TileResolution;
|
|
352
|
+
/**
|
|
353
|
+
* By default, local in-memory caching is enabled.
|
|
354
|
+
*/
|
|
355
|
+
localCache?: LocalCacheOptions;
|
|
356
|
+
};
|
|
357
|
+
type LocalCacheOptions = {
|
|
358
|
+
/**
|
|
359
|
+
* Map that stores requests and their responses.
|
|
360
|
+
*/
|
|
361
|
+
cache?: Map<string, Promise<unknown>>;
|
|
362
|
+
/**
|
|
363
|
+
* Cache control
|
|
364
|
+
* * `no-cache`: If present, the source will always fetch from original source.
|
|
365
|
+
* * `no-store`: If present, source will not store result in cache (for later reuse).
|
|
366
|
+
*
|
|
367
|
+
* See https://developer.mozilla.org/en-US/docs/Web/HTTP/Headers/Cache-Control#directives
|
|
368
|
+
*/
|
|
369
|
+
cacheControl?: ('no-cache' | 'no-store')[];
|
|
370
|
+
};
|
|
371
|
+
type SourceOptions = SourceRequiredOptions & Partial<SourceOptionalOptions>;
|
|
372
|
+
type AggregationOptions = {
|
|
373
|
+
/**
|
|
374
|
+
* Defines the aggregation expressions that will be calculated from the resulting columns on each grid cell.
|
|
375
|
+
*
|
|
376
|
+
* Example:
|
|
377
|
+
*
|
|
378
|
+
* sum(pop) as total_population, avg(rev) as average_revenue
|
|
379
|
+
*/
|
|
380
|
+
aggregationExp: string;
|
|
381
|
+
/**
|
|
382
|
+
* Defines the tile aggregation resolution.
|
|
383
|
+
*
|
|
384
|
+
* @default 6 for quadbin and 4 for h3 sources
|
|
385
|
+
*/
|
|
386
|
+
aggregationResLevel?: number;
|
|
387
|
+
/**
|
|
388
|
+
* Original resolution of the spatial index data as stored in the DW
|
|
389
|
+
*/
|
|
390
|
+
dataResolution?: number;
|
|
391
|
+
};
|
|
392
|
+
type FilterOptions = {
|
|
393
|
+
/**
|
|
394
|
+
* Filters to apply to the data source on the server
|
|
395
|
+
*/
|
|
396
|
+
filters?: Filters;
|
|
397
|
+
};
|
|
398
|
+
type QuerySourceOptions = {
|
|
399
|
+
/** Full SQL query with query paremeter placeholders (if any). */
|
|
400
|
+
sqlQuery: string;
|
|
401
|
+
/**
|
|
402
|
+
* Values for named or positional paramteres in the query.
|
|
403
|
+
*
|
|
404
|
+
* The way query parameters are determined by data warehouse.
|
|
405
|
+
*
|
|
406
|
+
* * BigQuery has named query parameters, specified with a dictionary, and referenced by key (`@key`)
|
|
407
|
+
*
|
|
408
|
+
* ```
|
|
409
|
+
* sqlQuery: "SELECT * FROM carto-demo-data.demo_tables.retail_stores WHERE storetype = @type AND revenue > @minRevenue"
|
|
410
|
+
* queryParameters: { type: 'Supermarket', minRevenue: 1000000 }
|
|
411
|
+
* ```
|
|
412
|
+
* * Snowflake supports positional parameters, in the form `:1`, `:2`, etc.
|
|
413
|
+
*
|
|
414
|
+
* ```
|
|
415
|
+
* sqlQuery: "SELECT * FROM demo_db.public.import_retail_stores WHERE storetype = :2 AND revenue > :1
|
|
416
|
+
* queryParameters: [100000, "Supermarket"]
|
|
417
|
+
* ```
|
|
418
|
+
* * Postgres and Redhisft supports positional parameters, but in the form `$1`, `$2`, etc.
|
|
419
|
+
*
|
|
420
|
+
* ```
|
|
421
|
+
* sqlQuery: "SELECT * FROM carto_demo_data.demo_tables.retail_stores WHERE storetype = $2 AND revenue > $1
|
|
422
|
+
* queryParameters: [100000, "Supermarket"]
|
|
423
|
+
* ```
|
|
424
|
+
*/
|
|
425
|
+
queryParameters?: QueryParameters;
|
|
426
|
+
/**
|
|
427
|
+
* Comma-separated aggregation expressions. If assigned on a vector source, source is grouped by geometry and then aggregated.
|
|
428
|
+
*
|
|
429
|
+
* Example:
|
|
430
|
+
*
|
|
431
|
+
* 1 as value, avg(rev) as average_revenue
|
|
432
|
+
*/
|
|
433
|
+
aggregationExp?: string;
|
|
434
|
+
};
|
|
435
|
+
type TableSourceOptions = {
|
|
436
|
+
/**
|
|
437
|
+
* Fully qualified name of table.
|
|
438
|
+
*/
|
|
439
|
+
tableName: string;
|
|
440
|
+
/**
|
|
441
|
+
* Comma-separated aggregation expressions. If assigned on a vector source, source is grouped by geometry and then aggregated.
|
|
442
|
+
*
|
|
443
|
+
* Example:
|
|
444
|
+
*
|
|
445
|
+
* 1 as value, avg(rev) as average_revenue
|
|
446
|
+
*/
|
|
447
|
+
aggregationExp?: string;
|
|
448
|
+
};
|
|
449
|
+
type TilesetSourceOptions = {
|
|
450
|
+
/**
|
|
451
|
+
* Fully qualified name of tileset.
|
|
452
|
+
*/
|
|
453
|
+
tableName: string;
|
|
454
|
+
/**
|
|
455
|
+
* Whether to use Web Workers for local widget calculations. Workers
|
|
456
|
+
* are used by default if the runtime environment supports ES Module Workers.
|
|
457
|
+
*/
|
|
458
|
+
widgetWorker?: boolean;
|
|
459
|
+
};
|
|
460
|
+
type ColumnsOption = {
|
|
461
|
+
/**
|
|
462
|
+
* Columns to retrieve from the table.
|
|
463
|
+
*
|
|
464
|
+
* If not present, all columns are returned.
|
|
465
|
+
*/
|
|
466
|
+
columns?: string[];
|
|
467
|
+
};
|
|
468
|
+
type SpatialDataType = 'geo' | 'h3' | 'quadbin';
|
|
469
|
+
/**
|
|
470
|
+
* Strategy used for covering spatial filter geometry with spatial indexes.
|
|
471
|
+
* See https://docs.carto.com/data-and-analysis/analytics-toolbox-for-bigquery/sql-reference/quadbin#quadbin_polyfill_mode
|
|
472
|
+
* or https://docs.carto.com/data-and-analysis/analytics-toolbox-for-bigquery/sql-reference/h3#h3_polyfill_mode for more information.
|
|
473
|
+
* @privateRemarks Source: cloud-native maps-api
|
|
474
|
+
* */
|
|
475
|
+
type SpatialFilterPolyfillMode = 'center' | 'intersects' | 'contains';
|
|
476
|
+
type TileResolution = 0.25 | 0.5 | 1 | 2 | 4;
|
|
477
|
+
interface Tilejson {
|
|
478
|
+
tilejson: string;
|
|
479
|
+
name: string;
|
|
480
|
+
description: string;
|
|
481
|
+
version: string;
|
|
482
|
+
attribution: string;
|
|
483
|
+
scheme: string;
|
|
484
|
+
tiles: string[];
|
|
485
|
+
minzoom: number;
|
|
486
|
+
maxzoom: number;
|
|
487
|
+
bounds: [left: number, bottom: number, right: number, top: number];
|
|
488
|
+
center: [longitute: number, latitude: number, zoom: number];
|
|
489
|
+
vector_layers: VectorLayer[];
|
|
490
|
+
minresolution: number;
|
|
491
|
+
maxresolution: number;
|
|
492
|
+
properties_tiles: string[];
|
|
493
|
+
tilestats: Tilestats;
|
|
494
|
+
tileResolution?: TileResolution;
|
|
495
|
+
/**
|
|
496
|
+
* Resolution of data in spatial-index dataset (e.g. H3, Quadbin).
|
|
497
|
+
*
|
|
498
|
+
* @internal
|
|
499
|
+
*/
|
|
500
|
+
dataresolution?: number;
|
|
501
|
+
/**
|
|
502
|
+
* Array of ratios of dropped features per zoom level.
|
|
503
|
+
*
|
|
504
|
+
* Example: `[0,0,0.5]` - means that 50% of features are dropped at zoom 2 and bigger.
|
|
505
|
+
*
|
|
506
|
+
* @internal
|
|
507
|
+
*/
|
|
508
|
+
fraction_dropped_per_zoom?: number[];
|
|
509
|
+
/**
|
|
510
|
+
* Names of bands - rasters only.
|
|
511
|
+
*
|
|
512
|
+
* @internal
|
|
513
|
+
*/
|
|
514
|
+
raster_bands?: string[];
|
|
515
|
+
/**
|
|
516
|
+
* Raster metadata - rasters only.
|
|
517
|
+
*
|
|
518
|
+
* @internal
|
|
519
|
+
*/
|
|
520
|
+
raster_metadata?: RasterMetadata;
|
|
521
|
+
}
|
|
522
|
+
interface Tilestats {
|
|
523
|
+
layerCount: number;
|
|
524
|
+
layers: Layer[];
|
|
525
|
+
}
|
|
526
|
+
interface Layer {
|
|
527
|
+
layer: string;
|
|
528
|
+
count: number;
|
|
529
|
+
attributeCount: number;
|
|
530
|
+
attributes: Attribute[];
|
|
531
|
+
}
|
|
532
|
+
interface Attribute {
|
|
533
|
+
attribute: string;
|
|
534
|
+
type: string;
|
|
535
|
+
}
|
|
536
|
+
interface VectorLayer {
|
|
537
|
+
id: string;
|
|
538
|
+
minzoom: number;
|
|
539
|
+
maxzoom: number;
|
|
540
|
+
fields: Record<string, string>;
|
|
541
|
+
geometry_type?: string;
|
|
542
|
+
}
|
|
543
|
+
type RasterMetadataBandStats = {
|
|
544
|
+
approximated_stats?: boolean;
|
|
545
|
+
min: number;
|
|
546
|
+
max: number;
|
|
547
|
+
mean: number;
|
|
548
|
+
stddev: number;
|
|
549
|
+
sum: number;
|
|
550
|
+
sum_squares: number;
|
|
551
|
+
count: number;
|
|
552
|
+
/**
|
|
553
|
+
* Quantiles by number of buckets.
|
|
554
|
+
*
|
|
555
|
+
* Example:
|
|
556
|
+
* ```ts
|
|
557
|
+
* {
|
|
558
|
+
* // for 3 buckets, first 1/3 of items lies in range [min, 20], second 1/3 is in [20, 40], and last 1/3 is in [40, max]
|
|
559
|
+
* 3: [20, 40],
|
|
560
|
+
* 4: [20, 30, 50], for 4 buckets ...
|
|
561
|
+
* }
|
|
562
|
+
* ```
|
|
563
|
+
*/
|
|
564
|
+
quantiles?: Record<number, number[]>;
|
|
565
|
+
/**
|
|
566
|
+
* Top values by number of values.
|
|
567
|
+
*
|
|
568
|
+
* Key of dictionary is value, value is count.
|
|
569
|
+
* Key order is random.
|
|
570
|
+
*
|
|
571
|
+
* Example:
|
|
572
|
+
* ```
|
|
573
|
+
* {
|
|
574
|
+
* 3: 5, // means there are 5 pixels with value 3
|
|
575
|
+
* 11: 222,
|
|
576
|
+
* 12: 333, // means that 12 is most common value with count 333
|
|
577
|
+
* ... // (assuming 333 was largest value in dict)
|
|
578
|
+
* }
|
|
579
|
+
* ```
|
|
580
|
+
*/
|
|
581
|
+
top_values?: Record<number, number>;
|
|
582
|
+
/**
|
|
583
|
+
* Raster loader version.
|
|
584
|
+
*/
|
|
585
|
+
version?: string;
|
|
586
|
+
};
|
|
587
|
+
declare enum RasterBandColorinterp {
|
|
588
|
+
Gray = "gray",
|
|
589
|
+
Red = "red",
|
|
590
|
+
Green = "green",
|
|
591
|
+
Blue = "blue",
|
|
592
|
+
Alpha = "alpha",
|
|
593
|
+
Palette = "palette"
|
|
594
|
+
}
|
|
595
|
+
type RasterMetadataBand = {
|
|
596
|
+
type: string;
|
|
597
|
+
name: string;
|
|
598
|
+
stats: RasterMetadataBandStats;
|
|
599
|
+
/**
|
|
600
|
+
* Known values:
|
|
601
|
+
* * `palette`: use unique value and `colortable` ad default mapping
|
|
602
|
+
* * `red`, `green`, `blue`: use the band as color channel
|
|
603
|
+
* * `gray`: use the band as grayscale
|
|
604
|
+
*/
|
|
605
|
+
colorinterp?: string | RasterBandColorinterp;
|
|
606
|
+
/**
|
|
607
|
+
* Default color mapping for unique values (or if coloprinterp is `palette`)
|
|
608
|
+
*/
|
|
609
|
+
colortable?: Record<string, number[]>;
|
|
610
|
+
/**
|
|
611
|
+
* No value representation.
|
|
612
|
+
* Observed values:
|
|
613
|
+
* * `'nan'` for `NaN`
|
|
614
|
+
* * `number`: both as string as number, so parsing is needed
|
|
615
|
+
*/
|
|
616
|
+
nodata: string | number;
|
|
617
|
+
};
|
|
618
|
+
type RasterMetadata = {
|
|
619
|
+
block_resolution: number;
|
|
620
|
+
minresolution: number;
|
|
621
|
+
maxresolution: number;
|
|
622
|
+
nodata: number | string;
|
|
623
|
+
bands: RasterMetadataBand[];
|
|
624
|
+
bounds: [left: number, bottom: number, right: number, top: number];
|
|
625
|
+
center: [longitute: number, latitude: number, zoom: number];
|
|
626
|
+
width: number;
|
|
627
|
+
height: number;
|
|
628
|
+
block_width: number;
|
|
629
|
+
block_height: number;
|
|
630
|
+
num_blocks: number;
|
|
631
|
+
num_pixels: number;
|
|
632
|
+
pixel_resolution: number;
|
|
633
|
+
};
|
|
634
|
+
type TilejsonResult = Tilejson & {
|
|
635
|
+
accessToken: string;
|
|
636
|
+
};
|
|
637
|
+
type GeojsonResult = {
|
|
638
|
+
type: 'FeatureCollection';
|
|
639
|
+
features: Feature[];
|
|
640
|
+
};
|
|
641
|
+
type JsonResult = any[];
|
|
642
|
+
type QueryResult = {
|
|
643
|
+
meta: {
|
|
644
|
+
cacheHit: boolean;
|
|
645
|
+
location: string;
|
|
646
|
+
totalBytesProcessed: string;
|
|
647
|
+
};
|
|
648
|
+
rows: Record<string, any>[];
|
|
649
|
+
schema: {
|
|
650
|
+
name: string;
|
|
651
|
+
type: string;
|
|
652
|
+
}[];
|
|
653
|
+
};
|
|
654
|
+
|
|
655
|
+
declare const SOURCE_DEFAULTS: SourceOptionalOptions;
|
|
656
|
+
|
|
657
|
+
type BoundaryQuerySourceOptions = SourceOptions & FilterOptions & {
|
|
658
|
+
columns?: string[];
|
|
659
|
+
tilesetTableName: string;
|
|
660
|
+
propertiesSqlQuery: string;
|
|
661
|
+
queryParameters?: QueryParameters;
|
|
662
|
+
};
|
|
663
|
+
type BoundaryQuerySourceResponse = TilejsonResult;
|
|
664
|
+
declare const boundaryQuerySource: (options: BoundaryQuerySourceOptions) => Promise<BoundaryQuerySourceResponse>;
|
|
665
|
+
|
|
666
|
+
type BoundaryTableSourceOptions = SourceOptions & FilterOptions & {
|
|
667
|
+
tilesetTableName: string;
|
|
668
|
+
columns?: string[];
|
|
669
|
+
propertiesTableName: string;
|
|
670
|
+
};
|
|
671
|
+
type BoundaryTableSourceResponse = TilejsonResult;
|
|
672
|
+
declare const boundaryTableSource: (options: BoundaryTableSourceOptions) => Promise<BoundaryTableSourceResponse>;
|
|
673
|
+
|
|
674
|
+
/******************************************************************************
|
|
675
|
+
* WIDGET API REQUESTS
|
|
676
|
+
*/
|
|
677
|
+
interface ViewState {
|
|
678
|
+
zoom: number;
|
|
679
|
+
latitude: number;
|
|
680
|
+
longitude: number;
|
|
681
|
+
}
|
|
682
|
+
/** Common options for {@link WidgetRemoteSource} requests. */
|
|
683
|
+
interface BaseRequestOptions {
|
|
684
|
+
signal?: AbortSignal;
|
|
685
|
+
spatialFilter?: SpatialFilter;
|
|
686
|
+
spatialFiltersMode?: SpatialFilterPolyfillMode;
|
|
687
|
+
/** Required for table- and query-based spatial index sources (H3, Quadbin). */
|
|
688
|
+
spatialIndexReferenceViewState?: ViewState;
|
|
689
|
+
/** Overrides source filters, if any. */
|
|
690
|
+
filters?: Filters;
|
|
691
|
+
filterOwner?: string;
|
|
692
|
+
}
|
|
693
|
+
/** Options for {@link WidgetRemoteSource#getCategories}. */
|
|
694
|
+
interface CategoryRequestOptions extends BaseRequestOptions {
|
|
695
|
+
column: string;
|
|
696
|
+
operation?: 'count' | 'avg' | 'min' | 'max' | 'sum';
|
|
697
|
+
operationColumn?: string;
|
|
698
|
+
/** Local only. */
|
|
699
|
+
joinOperation?: 'count' | 'avg' | 'min' | 'max' | 'sum';
|
|
700
|
+
}
|
|
701
|
+
/**
|
|
702
|
+
* Options for {@link WidgetRemoteSource#getFeatures}.
|
|
703
|
+
* @experimental
|
|
704
|
+
* @internal
|
|
705
|
+
*/
|
|
706
|
+
interface FeaturesRequestOptions extends BaseRequestOptions {
|
|
707
|
+
/**
|
|
708
|
+
* Feature IDs, as found in `_carto_feature_id`. Feature IDs are a hash
|
|
709
|
+
* of geometry, and features with identical geometry will have the same
|
|
710
|
+
* feature ID. Order is important; features in the result set will be
|
|
711
|
+
* sorted according to the order of IDs in the request.
|
|
712
|
+
*/
|
|
713
|
+
featureIds: string[];
|
|
714
|
+
/**
|
|
715
|
+
* Columns to be returned for each picked object. Note that for datasets
|
|
716
|
+
* containing features with identical geometry, more than one result per
|
|
717
|
+
* requested feature ID may be returned. To match results back to the
|
|
718
|
+
* requested feature ID, include `_carto_feature_id` in the columns list.
|
|
719
|
+
*/
|
|
720
|
+
columns: string[];
|
|
721
|
+
/** Topology of objects to be picked. */
|
|
722
|
+
dataType: 'points' | 'lines' | 'polygons';
|
|
723
|
+
/** Zoom level, required if using 'points' data type. */
|
|
724
|
+
z?: number;
|
|
725
|
+
/**
|
|
726
|
+
* Maximum number of objects to return in the result set. For datasets
|
|
727
|
+
* containing features with identical geometry, those features will have
|
|
728
|
+
* the same feature IDs, and so more results may be returned than feature IDs
|
|
729
|
+
* given in the request.
|
|
730
|
+
*/
|
|
731
|
+
limit?: number;
|
|
732
|
+
/**
|
|
733
|
+
* Must match `tileResolution` used when obtaining the `_carto_feature_id`
|
|
734
|
+
* column, typically in a layer's tile requests.
|
|
735
|
+
*/
|
|
736
|
+
tileResolution?: TileResolution;
|
|
737
|
+
}
|
|
738
|
+
/** Options for {@link WidgetRemoteSource#getFormula}. */
|
|
739
|
+
interface FormulaRequestOptions extends BaseRequestOptions {
|
|
740
|
+
column: string;
|
|
741
|
+
operation?: 'count' | 'avg' | 'min' | 'max' | 'sum' | 'custom';
|
|
742
|
+
operationExp?: string;
|
|
743
|
+
joinOperation?: 'count' | 'avg' | 'min' | 'max' | 'sum';
|
|
744
|
+
}
|
|
745
|
+
/** Options for {@link WidgetRemoteSource#getHistogram}. */
|
|
746
|
+
interface HistogramRequestOptions extends BaseRequestOptions {
|
|
747
|
+
column: string;
|
|
748
|
+
ticks: number[];
|
|
749
|
+
operation?: 'count' | 'avg' | 'min' | 'max' | 'sum';
|
|
750
|
+
/** Local only. */
|
|
751
|
+
joinOperation?: 'count' | 'avg' | 'min' | 'max' | 'sum';
|
|
752
|
+
}
|
|
753
|
+
/** Options for {@link WidgetRemoteSource#getRange}. */
|
|
754
|
+
interface RangeRequestOptions extends BaseRequestOptions {
|
|
755
|
+
column: string;
|
|
756
|
+
}
|
|
757
|
+
/** Options for {@link WidgetRemoteSource#getScatter}. */
|
|
758
|
+
interface ScatterRequestOptions extends BaseRequestOptions {
|
|
759
|
+
xAxisColumn: string;
|
|
760
|
+
xAxisJoinOperation?: 'count' | 'avg' | 'min' | 'max' | 'sum';
|
|
761
|
+
yAxisColumn: string;
|
|
762
|
+
yAxisJoinOperation?: 'count' | 'avg' | 'min' | 'max' | 'sum';
|
|
763
|
+
}
|
|
764
|
+
/** Options for {@link WidgetRemoteSource#getTable}. */
|
|
765
|
+
interface TableRequestOptions extends BaseRequestOptions {
|
|
766
|
+
columns: string[];
|
|
767
|
+
sortBy?: string;
|
|
768
|
+
sortDirection?: SortDirection;
|
|
769
|
+
sortByColumnType?: SortColumnType;
|
|
770
|
+
offset?: number;
|
|
771
|
+
limit?: number;
|
|
772
|
+
/** Local only. */
|
|
773
|
+
searchFilterColumn?: string;
|
|
774
|
+
/** Local only. */
|
|
775
|
+
searchFilterText?: string;
|
|
776
|
+
}
|
|
777
|
+
/** Options for {@link WidgetRemoteSource#getTimeSeries}. */
|
|
778
|
+
interface TimeSeriesRequestOptions extends BaseRequestOptions {
|
|
779
|
+
column: string;
|
|
780
|
+
stepSize: GroupDateType;
|
|
781
|
+
stepMultiplier?: number;
|
|
782
|
+
operation?: 'count' | 'avg' | 'min' | 'max' | 'sum';
|
|
783
|
+
operationColumn?: string;
|
|
784
|
+
joinOperation?: 'count' | 'avg' | 'min' | 'max' | 'sum';
|
|
785
|
+
splitByCategory?: string;
|
|
786
|
+
splitByCategoryLimit?: number;
|
|
787
|
+
splitByCategoryValues?: string[];
|
|
788
|
+
}
|
|
789
|
+
/******************************************************************************
|
|
790
|
+
* WIDGET API RESPONSES
|
|
791
|
+
*/
|
|
792
|
+
/**
|
|
793
|
+
* Response from {@link WidgetRemoteSource#getFeatures}.
|
|
794
|
+
* @experimental
|
|
795
|
+
* @internal
|
|
796
|
+
*/
|
|
797
|
+
type FeaturesResponse = {
|
|
798
|
+
rows: Record<string, unknown>[];
|
|
799
|
+
};
|
|
800
|
+
/** Response from {@link WidgetRemoteSource#getFormula}. */
|
|
801
|
+
type FormulaResponse = {
|
|
802
|
+
value: number | null;
|
|
803
|
+
};
|
|
804
|
+
/** Response from {@link WidgetRemoteSource#getCategories}. */
|
|
805
|
+
type CategoryResponse = {
|
|
806
|
+
name: string;
|
|
807
|
+
value: number;
|
|
808
|
+
}[];
|
|
809
|
+
/** Response from {@link WidgetRemoteSource#getRange}. */
|
|
810
|
+
type RangeResponse = {
|
|
811
|
+
min: number;
|
|
812
|
+
max: number;
|
|
813
|
+
} | null;
|
|
814
|
+
/** Response from {@link WidgetRemoteSource#getTable}. */
|
|
815
|
+
type TableResponse = {
|
|
816
|
+
totalCount: number;
|
|
817
|
+
rows: Record<string, number | string>[];
|
|
818
|
+
};
|
|
819
|
+
/** Response from {@link WidgetRemoteSource#getScatter}. */
|
|
820
|
+
type ScatterResponse = [number, number][];
|
|
821
|
+
/** Response from {@link WidgetRemoteSource#getTimeSeries}. */
|
|
822
|
+
type TimeSeriesResponse = {
|
|
823
|
+
rows: {
|
|
824
|
+
name: string;
|
|
825
|
+
value: number;
|
|
826
|
+
}[];
|
|
827
|
+
categories?: string[];
|
|
828
|
+
};
|
|
829
|
+
/** Response from {@link WidgetRemoteSource#getHistogram}. */
|
|
830
|
+
type HistogramResponse = number[];
|
|
831
|
+
|
|
832
|
+
interface ModelSource {
|
|
833
|
+
type: MapType;
|
|
834
|
+
apiVersion: ApiVersion;
|
|
835
|
+
apiBaseUrl: string;
|
|
836
|
+
accessToken: string;
|
|
837
|
+
clientId: string;
|
|
838
|
+
connectionName: string;
|
|
839
|
+
data: string;
|
|
840
|
+
filters?: Record<string, Filter>;
|
|
841
|
+
filtersLogicalOperator?: FilterLogicalOperator;
|
|
842
|
+
spatialFilter?: SpatialFilter;
|
|
843
|
+
queryParameters?: QueryParameters;
|
|
844
|
+
spatialDataColumn?: string;
|
|
845
|
+
spatialDataType?: SpatialDataType;
|
|
846
|
+
spatialFiltersResolution?: number;
|
|
847
|
+
spatialFiltersMode?: SpatialFilterPolyfillMode;
|
|
848
|
+
/** original resolution of the spatial index data as stored in the DW */
|
|
849
|
+
dataResolution?: number;
|
|
850
|
+
}
|
|
851
|
+
|
|
852
|
+
interface WidgetSourceProps extends Omit<SourceOptions, 'filters'> {
|
|
853
|
+
apiVersion?: ApiVersion;
|
|
854
|
+
filters?: Record<string, Filter>;
|
|
855
|
+
filtersLogicalOperator?: FilterLogicalOperator;
|
|
856
|
+
}
|
|
857
|
+
/**
|
|
858
|
+
* Source for Widget API requests on a data source defined by a SQL query.
|
|
859
|
+
*
|
|
860
|
+
* Abstract class. Use {@link WidgetQuerySource} or {@link WidgetTableSource}.
|
|
861
|
+
*/
|
|
862
|
+
declare abstract class WidgetSource<Props extends WidgetSourceProps = WidgetSourceProps> {
|
|
863
|
+
readonly props: Props;
|
|
864
|
+
static defaultProps: Partial<WidgetSourceProps>;
|
|
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;
|
|
874
|
+
protected _getSpatialFiltersResolution(source: Omit<ModelSource, 'type' | 'data'>, spatialFilter?: SpatialFilter, referenceViewState?: ViewState): number | undefined;
|
|
875
|
+
/**
|
|
876
|
+
* Returns a list of labeled datapoints for categorical data. Suitable for
|
|
877
|
+
* charts including grouped bar charts, pie charts, and tree charts.
|
|
878
|
+
*/
|
|
879
|
+
abstract getCategories(options: CategoryRequestOptions): Promise<CategoryResponse>;
|
|
880
|
+
/**
|
|
881
|
+
* Given a list of feature IDs (as found in `_carto_feature_id`) returns all
|
|
882
|
+
* matching features. In datasets containing features with duplicate geometries,
|
|
883
|
+
* feature IDs may be duplicated (IDs are a hash of geometry) and so more
|
|
884
|
+
* results may be returned than IDs in the request.
|
|
885
|
+
* @internal
|
|
886
|
+
* @experimental
|
|
887
|
+
*/
|
|
888
|
+
abstract getFeatures(options: FeaturesRequestOptions): Promise<FeaturesResponse>;
|
|
889
|
+
/**
|
|
890
|
+
* Returns a scalar numerical statistic over all matching data. Suitable
|
|
891
|
+
* for 'headline' or 'scorecard' figures such as counts and sums.
|
|
892
|
+
*/
|
|
893
|
+
abstract getFormula(options: FormulaRequestOptions): Promise<FormulaResponse>;
|
|
894
|
+
/**
|
|
895
|
+
* Returns a list of labeled datapoints for 'bins' of data defined as ticks
|
|
896
|
+
* over a numerical range. Suitable for histogram charts.
|
|
897
|
+
*/
|
|
898
|
+
abstract getHistogram(options: HistogramRequestOptions): Promise<HistogramResponse>;
|
|
899
|
+
/**
|
|
900
|
+
* Returns a range (min and max) for a numerical column of matching rows.
|
|
901
|
+
* Suitable for displaying certain 'headline' or 'scorecard' statistics,
|
|
902
|
+
* or rendering a range slider UI for filtering.
|
|
903
|
+
*/
|
|
904
|
+
abstract getRange(options: RangeRequestOptions): Promise<RangeResponse>;
|
|
905
|
+
/**
|
|
906
|
+
* Returns a list of bivariate datapoints defined as numerical 'x' and 'y'
|
|
907
|
+
* values. Suitable for rendering scatter plots.
|
|
908
|
+
*/
|
|
909
|
+
abstract getScatter(options: ScatterRequestOptions): Promise<ScatterResponse>;
|
|
910
|
+
/**
|
|
911
|
+
* Returns a list of arbitrary data rows, with support for pagination and
|
|
912
|
+
* sorting. Suitable for displaying tables and lists.
|
|
913
|
+
*/
|
|
914
|
+
abstract getTable(options: TableRequestOptions): Promise<TableResponse>;
|
|
915
|
+
/**
|
|
916
|
+
* Returns a series of labeled numerical values, grouped into equally-sized
|
|
917
|
+
* time intervals. Suitable for rendering time series charts.
|
|
918
|
+
*/
|
|
919
|
+
abstract getTimeSeries(options: TimeSeriesRequestOptions): Promise<TimeSeriesResponse>;
|
|
920
|
+
}
|
|
921
|
+
|
|
922
|
+
type WidgetRemoteSourceProps = WidgetSourceProps;
|
|
923
|
+
/**
|
|
924
|
+
* Source for Widget API requests.
|
|
925
|
+
*
|
|
926
|
+
* Abstract class. Use {@link WidgetQuerySource} or {@link WidgetTableSource}.
|
|
927
|
+
*/
|
|
928
|
+
declare abstract class WidgetRemoteSource<Props extends WidgetRemoteSourceProps> extends WidgetSource<Props> {
|
|
929
|
+
/**
|
|
930
|
+
* Subclasses of {@link WidgetRemoteSource} must implement this method, calling
|
|
931
|
+
* {@link WidgetRemoteSource.prototype._getModelSource} for common source
|
|
932
|
+
* properties, and adding additional required properties including 'type' and
|
|
933
|
+
* 'data'.
|
|
934
|
+
*/
|
|
935
|
+
protected abstract getModelSource(filters: Filters | undefined, filterOwner?: string): ModelSource;
|
|
936
|
+
protected _getModelSource(filters: Filters | undefined, filterOwner?: string): Omit<ModelSource, 'type' | 'data'>;
|
|
937
|
+
getCategories(options: CategoryRequestOptions): Promise<CategoryResponse>;
|
|
938
|
+
getFeatures(options: FeaturesRequestOptions): Promise<FeaturesResponse>;
|
|
939
|
+
getFormula(options: FormulaRequestOptions): Promise<FormulaResponse>;
|
|
940
|
+
getHistogram(options: HistogramRequestOptions): Promise<HistogramResponse>;
|
|
941
|
+
getRange(options: RangeRequestOptions): Promise<RangeResponse>;
|
|
942
|
+
getScatter(options: ScatterRequestOptions): Promise<ScatterResponse>;
|
|
943
|
+
getTable(options: TableRequestOptions): Promise<TableResponse>;
|
|
944
|
+
getTimeSeries(options: TimeSeriesRequestOptions): Promise<TimeSeriesResponse>;
|
|
945
|
+
}
|
|
946
|
+
|
|
947
|
+
type LayerQuerySourceOptions = Omit<VectorQuerySourceOptions, 'filters'> | Omit<H3QuerySourceOptions, 'filters'> | Omit<QuadbinQuerySourceOptions, 'filters'>;
|
|
948
|
+
type WidgetQuerySourceResult = {
|
|
949
|
+
widgetSource: WidgetQuerySource;
|
|
950
|
+
};
|
|
951
|
+
/**
|
|
952
|
+
* Source for Widget API requests on a data source defined by a SQL query.
|
|
953
|
+
*
|
|
954
|
+
* Generally not intended to be constructed directly. Instead, call
|
|
955
|
+
* {@link vectorQuerySource}, {@link h3QuerySource}, or {@link quadbinQuerySource},
|
|
956
|
+
* which can be shared with map layers. Sources contain a `widgetSource` property,
|
|
957
|
+
* for use by widget implementations.
|
|
958
|
+
*
|
|
959
|
+
* Example:
|
|
960
|
+
*
|
|
961
|
+
* ```javascript
|
|
962
|
+
* import { vectorQuerySource } from '@carto/api-client';
|
|
963
|
+
*
|
|
964
|
+
* const data = vectorQuerySource({
|
|
965
|
+
* accessToken: '••••',
|
|
966
|
+
* connectionName: 'carto_dw',
|
|
967
|
+
* sqlQuery: 'SELECT * FROM carto-demo-data.demo_tables.retail_stores'
|
|
968
|
+
* });
|
|
969
|
+
*
|
|
970
|
+
* const { widgetSource } = await data;
|
|
971
|
+
* ```
|
|
972
|
+
*/
|
|
973
|
+
declare class WidgetQuerySource extends WidgetRemoteSource<LayerQuerySourceOptions & WidgetRemoteSourceProps> {
|
|
974
|
+
protected getModelSource(filters: Filters | undefined, filterOwner?: string): ModelSource;
|
|
975
|
+
}
|
|
976
|
+
|
|
977
|
+
type LayerTableSourceOptions = Omit<VectorTableSourceOptions, 'filters'> | Omit<H3TableSourceOptions, 'filters'> | Omit<QuadbinTableSourceOptions, 'filters'>;
|
|
978
|
+
type WidgetTableSourceResult = {
|
|
979
|
+
widgetSource: WidgetTableSource;
|
|
980
|
+
};
|
|
981
|
+
/**
|
|
982
|
+
* Source for Widget API requests on a data source defined as a table.
|
|
983
|
+
*
|
|
984
|
+
* Generally not intended to be constructed directly. Instead, call
|
|
985
|
+
* {@link vectorTableSource}, {@link h3TableSource}, or {@link quadbinTableSource},
|
|
986
|
+
* which can be shared with map layers. Sources contain a `widgetSource` property,
|
|
987
|
+
* for use by widget implementations.
|
|
988
|
+
*
|
|
989
|
+
* Example:
|
|
990
|
+
*
|
|
991
|
+
* ```javascript
|
|
992
|
+
* import { vectorTableSource } from '@carto/api-client';
|
|
993
|
+
*
|
|
994
|
+
* const data = vectorTableSource({
|
|
995
|
+
* accessToken: '••••',
|
|
996
|
+
* connectionName: 'carto_dw',
|
|
997
|
+
* tableName: 'carto-demo-data.demo_tables.retail_stores'
|
|
998
|
+
* });
|
|
999
|
+
*
|
|
1000
|
+
* const { widgetSource } = await data;
|
|
1001
|
+
* ```
|
|
1002
|
+
*/
|
|
1003
|
+
declare class WidgetTableSource extends WidgetRemoteSource<LayerTableSourceOptions & WidgetRemoteSourceProps> {
|
|
1004
|
+
protected getModelSource(filters: Filters | undefined, filterOwner?: string): ModelSource;
|
|
1005
|
+
}
|
|
1006
|
+
|
|
1007
|
+
/**
|
|
1008
|
+
* @internal
|
|
1009
|
+
* @privateRemarks Exported for use in @deck.gl/carto's getDataFilterExtensionProps.
|
|
1010
|
+
*/
|
|
1011
|
+
declare function _buildFeatureFilter({ filters, type, filtersLogicalOperator, }: {
|
|
1012
|
+
filters?: Filters;
|
|
1013
|
+
type?: 'number' | 'boolean';
|
|
1014
|
+
filtersLogicalOperator?: FilterLogicalOperator;
|
|
1015
|
+
}): (feature: Feature | FeatureData) => number | boolean;
|
|
1016
|
+
/**
|
|
1017
|
+
* Apply certain filters to a collection of features.
|
|
1018
|
+
* @internal
|
|
1019
|
+
*/
|
|
1020
|
+
declare function applyFilters(features: FeatureData[], filters: Filters, filtersLogicalOperator: FilterLogicalOperator): FeatureData[];
|
|
1021
|
+
/**
|
|
1022
|
+
* Binary.
|
|
1023
|
+
* @internal
|
|
1024
|
+
*/
|
|
1025
|
+
declare function buildBinaryFeatureFilter({ filters }: {
|
|
1026
|
+
filters: Filters;
|
|
1027
|
+
}): (() => number) | ((featureIdIdx: number, binaryData: BinaryFeature) => boolean);
|
|
1028
|
+
|
|
1029
|
+
type FilterFunction = (filterValues: unknown[], featureValue: unknown, params?: Record<string, unknown>) => boolean;
|
|
1030
|
+
declare const filterFunctions: Record<FilterType, FilterFunction>;
|
|
1031
|
+
|
|
1032
|
+
declare function geojsonFeatures({ geojson, spatialFilter, uniqueIdProperty, }: {
|
|
1033
|
+
geojson: FeatureCollection;
|
|
1034
|
+
spatialFilter: SpatialFilter;
|
|
1035
|
+
uniqueIdProperty?: string;
|
|
1036
|
+
}): FeatureData[];
|
|
1037
|
+
|
|
1038
|
+
/** @privateRemarks Source: @carto/react-core */
|
|
1039
|
+
type TileFeatures = {
|
|
1040
|
+
tiles: Tile[];
|
|
1041
|
+
tileFormat: TileFormat;
|
|
1042
|
+
spatialDataType: SpatialDataType;
|
|
1043
|
+
spatialDataColumn?: string;
|
|
1044
|
+
spatialFilter: SpatialFilter;
|
|
1045
|
+
uniqueIdProperty?: string;
|
|
1046
|
+
options?: TileFeatureExtractOptions;
|
|
1047
|
+
};
|
|
1048
|
+
/** @privateRemarks Source: @carto/react-core */
|
|
1049
|
+
type TileFeatureExtractOptions = {
|
|
1050
|
+
storeGeometry?: boolean;
|
|
1051
|
+
uniqueIdProperty?: string;
|
|
1052
|
+
};
|
|
1053
|
+
/** @privateRemarks Source: @carto/react-core */
|
|
1054
|
+
declare function tileFeatures({ tiles, spatialFilter, uniqueIdProperty, tileFormat, spatialDataColumn, spatialDataType, options, }: TileFeatures): FeatureData[];
|
|
1055
|
+
|
|
1056
|
+
declare const FEATURE_GEOM_PROPERTY = "__geomValue";
|
|
1057
|
+
declare function tileFeaturesGeometries({ tiles, tileFormat, spatialFilter, uniqueIdProperty, options, }: {
|
|
1058
|
+
tiles: Tile[];
|
|
1059
|
+
tileFormat?: TileFormat;
|
|
1060
|
+
spatialFilter: SpatialFilter;
|
|
1061
|
+
uniqueIdProperty?: string;
|
|
1062
|
+
options?: {
|
|
1063
|
+
storeGeometry?: boolean;
|
|
1064
|
+
};
|
|
1065
|
+
}): FeatureData[];
|
|
1066
|
+
|
|
1067
|
+
type TileFeaturesSpatialIndexOptions = {
|
|
1068
|
+
tiles: SpatialIndexTile[];
|
|
1069
|
+
spatialFilter: SpatialFilter;
|
|
1070
|
+
spatialDataColumn: string;
|
|
1071
|
+
spatialDataType: SpatialDataType;
|
|
1072
|
+
};
|
|
1073
|
+
declare function tileFeaturesSpatialIndex({ tiles, spatialFilter, spatialDataColumn, spatialDataType, }: TileFeaturesSpatialIndexOptions): FeatureData[];
|
|
1074
|
+
|
|
1075
|
+
declare enum Method {
|
|
1076
|
+
INIT = "init",
|
|
1077
|
+
LOAD_TILES = "loadTiles",
|
|
1078
|
+
SET_TILE_FEATURE_EXTRACT_OPTIONS = "setTileFeatureExtractOptions",
|
|
1079
|
+
LOAD_GEOJSON = "loadGeoJSON",
|
|
1080
|
+
GET_FORMULA = "getFormula",
|
|
1081
|
+
GET_HISTOGRAM = "getHistogram",
|
|
1082
|
+
GET_CATEGORIES = "getCategories",
|
|
1083
|
+
GET_SCATTER = "getScatter",
|
|
1084
|
+
GET_TABLE = "getTable",
|
|
1085
|
+
GET_TIME_SERIES = "getTimeSeries",
|
|
1086
|
+
GET_RANGE = "getRange"
|
|
1087
|
+
}
|
|
1088
|
+
|
|
1089
|
+
/**
|
|
1090
|
+
* Local (in-memory) implementation of tileset widget calculations. This class
|
|
1091
|
+
* may be instantiated by {@link WidgetTilesetSource} in a Web Worker when
|
|
1092
|
+
* supported, or on the main thread.
|
|
1093
|
+
*/
|
|
1094
|
+
declare class WidgetTilesetSourceImpl extends WidgetSource<WidgetTilesetSourceProps> {
|
|
1095
|
+
private _tiles;
|
|
1096
|
+
private _features;
|
|
1097
|
+
private _tileFeatureExtractOptions;
|
|
1098
|
+
private _tileFeatureExtractPreviousInputs;
|
|
1099
|
+
/**
|
|
1100
|
+
* Loads features as a list of tiles (typically provided by deck.gl).
|
|
1101
|
+
* After tiles are loaded, {@link extractTileFeatures} must be called
|
|
1102
|
+
* before computing statistics on the tiles.
|
|
1103
|
+
*/
|
|
1104
|
+
loadTiles(tiles: unknown[]): void;
|
|
1105
|
+
/** Configures options used to extract features from tiles. */
|
|
1106
|
+
setTileFeatureExtractOptions(options: TileFeatureExtractOptions): void;
|
|
1107
|
+
protected _extractTileFeatures(spatialFilter: SpatialFilter): void;
|
|
1108
|
+
/**
|
|
1109
|
+
* Loads features as GeoJSON (used for testing).
|
|
1110
|
+
* @experimental
|
|
1111
|
+
* @internal Not for public use. Spatial filters in other method calls will be ignored.
|
|
1112
|
+
*/
|
|
1113
|
+
loadGeoJSON({ geojson, spatialFilter, }: {
|
|
1114
|
+
geojson: FeatureCollection;
|
|
1115
|
+
spatialFilter: SpatialFilter;
|
|
1116
|
+
}): void;
|
|
1117
|
+
getFeatures(): Promise<FeaturesResponse>;
|
|
1118
|
+
getFormula({ column, operation, joinOperation, filters, filterOwner, spatialFilter, }: FormulaRequestOptions): Promise<FormulaResponse>;
|
|
1119
|
+
getHistogram({ operation, ticks, column, joinOperation, filters, filterOwner, spatialFilter, }: HistogramRequestOptions): Promise<HistogramResponse>;
|
|
1120
|
+
getCategories({ column, operation, operationColumn, joinOperation, filters, filterOwner, spatialFilter, }: CategoryRequestOptions): Promise<CategoryResponse>;
|
|
1121
|
+
getScatter({ xAxisColumn, yAxisColumn, xAxisJoinOperation, yAxisJoinOperation, filters, filterOwner, spatialFilter, }: ScatterRequestOptions): Promise<ScatterResponse>;
|
|
1122
|
+
getTable({ columns, searchFilterColumn, searchFilterText, sortBy, sortDirection, sortByColumnType, offset, limit, filters, filterOwner, spatialFilter, }: TableRequestOptions): Promise<TableResponse>;
|
|
1123
|
+
getTimeSeries({ column, stepSize, operation, operationColumn, joinOperation, filters, filterOwner, spatialFilter, }: TimeSeriesRequestOptions): Promise<TimeSeriesResponse>;
|
|
1124
|
+
getRange({ column, filters, filterOwner, spatialFilter, }: RangeRequestOptions): Promise<RangeResponse>;
|
|
1125
|
+
/****************************************************************************
|
|
1126
|
+
* INTERNAL
|
|
1127
|
+
*/
|
|
1128
|
+
private _getFilteredFeatures;
|
|
1129
|
+
}
|
|
1130
|
+
|
|
1131
|
+
type WidgetTilesetSourceProps = WidgetSourceProps & Omit<TilesetSourceOptions, 'filters'> & {
|
|
1132
|
+
tileFormat: TileFormat;
|
|
1133
|
+
spatialDataType: SpatialDataType;
|
|
1134
|
+
};
|
|
1135
|
+
type WidgetTilesetSourceResult = {
|
|
1136
|
+
widgetSource: WidgetTilesetSource;
|
|
1137
|
+
};
|
|
1138
|
+
/**
|
|
1139
|
+
* Source for Widget API requests on a data source defined by a tileset.
|
|
1140
|
+
*
|
|
1141
|
+
* Generally not intended to be constructed directly. Instead, call
|
|
1142
|
+
* {@link vectorTilesetSource}, {@link h3TilesetSource}, or {@link quadbinTilesetSource},
|
|
1143
|
+
* which can be shared with map layers. Sources contain a `widgetSource`
|
|
1144
|
+
* property, for use by widget implementations.
|
|
1145
|
+
*
|
|
1146
|
+
* Example:
|
|
1147
|
+
*
|
|
1148
|
+
* ```javascript
|
|
1149
|
+
* import { vectorTilesetSource } from '@carto/api-client';
|
|
1150
|
+
*
|
|
1151
|
+
* const data = vectorTilesetSource({
|
|
1152
|
+
* accessToken: '••••',
|
|
1153
|
+
* connectionName: 'carto_dw',
|
|
1154
|
+
* tableName: 'carto-demo-data.demo_rasters.my_tileset_source'
|
|
1155
|
+
* });
|
|
1156
|
+
*
|
|
1157
|
+
* const { widgetSource } = await data;
|
|
1158
|
+
* ```
|
|
1159
|
+
*/
|
|
1160
|
+
declare class WidgetTilesetSource extends WidgetSource<WidgetTilesetSourceProps> {
|
|
1161
|
+
protected _localImpl: WidgetTilesetSourceImpl | null;
|
|
1162
|
+
protected _workerImpl: Worker | null;
|
|
1163
|
+
protected _workerEnabled: boolean;
|
|
1164
|
+
protected _workerNextRequestId: number;
|
|
1165
|
+
constructor(props: WidgetTilesetSourceProps);
|
|
1166
|
+
destroy(): void;
|
|
1167
|
+
/**
|
|
1168
|
+
* Returns an initialized Worker, to be reused for the lifecycle of this
|
|
1169
|
+
* source instance.
|
|
1170
|
+
*/
|
|
1171
|
+
protected _getWorker(): Worker;
|
|
1172
|
+
/** Executes a given method on the worker. */
|
|
1173
|
+
protected _executeWorkerMethod<T>(method: Method, params: unknown[], signal?: AbortSignal): Promise<T>;
|
|
1174
|
+
/**
|
|
1175
|
+
* Loads features as a list of tiles (typically provided by deck.gl).
|
|
1176
|
+
* After tiles are loaded, {@link extractTileFeatures} must be called
|
|
1177
|
+
* before computing statistics on the tiles.
|
|
1178
|
+
*/
|
|
1179
|
+
loadTiles(tiles: unknown[]): void;
|
|
1180
|
+
/** Configures options used to extract features from tiles. */
|
|
1181
|
+
setTileFeatureExtractOptions(options: TileFeatureExtractOptions): void;
|
|
1182
|
+
/**
|
|
1183
|
+
* Loads features as GeoJSON (used for testing).
|
|
1184
|
+
* @experimental
|
|
1185
|
+
* @internal Not for public use. Spatial filters in other method calls will be ignored.
|
|
1186
|
+
*/
|
|
1187
|
+
loadGeoJSON({ geojson, spatialFilter, }: {
|
|
1188
|
+
geojson: FeatureCollection;
|
|
1189
|
+
spatialFilter: SpatialFilter;
|
|
1190
|
+
}): void;
|
|
1191
|
+
getFeatures(): Promise<FeaturesResponse>;
|
|
1192
|
+
getFormula({ signal, ...options }: FormulaRequestOptions): Promise<FormulaResponse>;
|
|
1193
|
+
getHistogram({ signal, ...options }: HistogramRequestOptions): Promise<HistogramResponse>;
|
|
1194
|
+
getCategories({ signal, ...options }: CategoryRequestOptions): Promise<CategoryResponse>;
|
|
1195
|
+
getScatter({ signal, ...options }: ScatterRequestOptions): Promise<ScatterResponse>;
|
|
1196
|
+
getTable({ signal, ...options }: TableRequestOptions): Promise<TableResponse>;
|
|
1197
|
+
getTimeSeries({ signal, ...options }: TimeSeriesRequestOptions): Promise<TimeSeriesResponse>;
|
|
1198
|
+
getRange({ signal, ...options }: RangeRequestOptions): Promise<RangeResponse>;
|
|
1199
|
+
}
|
|
1200
|
+
|
|
1201
|
+
type H3QuerySourceOptions = SourceOptions & QuerySourceOptions & AggregationOptions & FilterOptions;
|
|
1202
|
+
type H3QuerySourceResponse = TilejsonResult & WidgetQuerySourceResult;
|
|
1203
|
+
declare const h3QuerySource: (options: H3QuerySourceOptions) => Promise<H3QuerySourceResponse>;
|
|
1204
|
+
|
|
1205
|
+
type H3TableSourceOptions = SourceOptions & TableSourceOptions & AggregationOptions & FilterOptions;
|
|
1206
|
+
type H3TableSourceResponse = TilejsonResult & WidgetTableSourceResult;
|
|
1207
|
+
declare const h3TableSource: (options: H3TableSourceOptions) => Promise<H3TableSourceResponse>;
|
|
1208
|
+
|
|
1209
|
+
type H3TilesetSourceOptions = SourceOptions & TilesetSourceOptions;
|
|
1210
|
+
type H3TilesetSourceResponse = TilejsonResult & WidgetTilesetSourceResult;
|
|
1211
|
+
declare const h3TilesetSource: (options: H3TilesetSourceOptions) => Promise<H3TilesetSourceResponse>;
|
|
1212
|
+
|
|
1213
|
+
type RasterSourceOptions = SourceOptions & TilesetSourceOptions & FilterOptions;
|
|
1214
|
+
type RasterSourceResponse = TilejsonResult;
|
|
1215
|
+
declare const rasterSource: (options: RasterSourceOptions) => Promise<RasterSourceResponse>;
|
|
1216
|
+
|
|
1217
|
+
type QuadbinQuerySourceOptions = SourceOptions & QuerySourceOptions & AggregationOptions & FilterOptions;
|
|
1218
|
+
type QuadbinQuerySourceResponse = TilejsonResult & WidgetQuerySourceResult;
|
|
1219
|
+
declare const quadbinQuerySource: (options: QuadbinQuerySourceOptions) => Promise<QuadbinQuerySourceResponse>;
|
|
1220
|
+
|
|
1221
|
+
type QuadbinTableSourceOptions = SourceOptions & TableSourceOptions & AggregationOptions & FilterOptions;
|
|
1222
|
+
type QuadbinTableSourceResponse = TilejsonResult & WidgetTableSourceResult;
|
|
1223
|
+
declare const quadbinTableSource: (options: QuadbinTableSourceOptions) => Promise<QuadbinTableSourceResponse>;
|
|
1224
|
+
|
|
1225
|
+
type QuadbinTilesetSourceOptions = SourceOptions & TilesetSourceOptions;
|
|
1226
|
+
type QuadbinTilesetSourceResponse = TilejsonResult & WidgetTilesetSourceResult;
|
|
1227
|
+
declare const quadbinTilesetSource: (options: QuadbinTilesetSourceOptions) => Promise<QuadbinTilesetSourceResponse>;
|
|
1228
|
+
|
|
1229
|
+
type VectorQuerySourceOptions = SourceOptions & QuerySourceOptions & FilterOptions & ColumnsOption;
|
|
1230
|
+
type VectorQuerySourceResponse = TilejsonResult & WidgetQuerySourceResult;
|
|
1231
|
+
declare const vectorQuerySource: (options: VectorQuerySourceOptions) => Promise<VectorQuerySourceResponse>;
|
|
1232
|
+
|
|
1233
|
+
type VectorTableSourceOptions = SourceOptions & TableSourceOptions & FilterOptions & ColumnsOption;
|
|
1234
|
+
type VectorTableSourceResponse = TilejsonResult & WidgetTableSourceResult;
|
|
1235
|
+
declare const vectorTableSource: (options: VectorTableSourceOptions) => Promise<VectorTableSourceResponse>;
|
|
1236
|
+
|
|
1237
|
+
type VectorTilesetSourceOptions = SourceOptions & TilesetSourceOptions;
|
|
1238
|
+
type VectorTilesetSourceResponse = TilejsonResult & WidgetTilesetSourceResult;
|
|
1239
|
+
declare const vectorTilesetSource: (options: VectorTilesetSourceOptions) => Promise<VectorTilesetSourceResponse>;
|
|
1240
|
+
|
|
1241
|
+
type APIRequestType = 'Map data' | 'Map instantiation' | 'Public map' | 'Tile stats' | 'SQL' | 'Basemap style';
|
|
1242
|
+
type APIErrorContext = {
|
|
1243
|
+
requestType: APIRequestType;
|
|
1244
|
+
mapId?: string;
|
|
1245
|
+
connection?: string;
|
|
1246
|
+
source?: string;
|
|
1247
|
+
type?: MapType;
|
|
1248
|
+
};
|
|
1249
|
+
/**
|
|
1250
|
+
*
|
|
1251
|
+
* Custom error for reported errors in CARTO Maps API.
|
|
1252
|
+
* Provides useful debugging information in console and context for applications.
|
|
1253
|
+
*
|
|
1254
|
+
*/
|
|
1255
|
+
declare class CartoAPIError extends Error {
|
|
1256
|
+
/** Source error from server */
|
|
1257
|
+
error: Error;
|
|
1258
|
+
/** Context (API call & parameters) in which error occured */
|
|
1259
|
+
errorContext: APIErrorContext;
|
|
1260
|
+
/** Response from server */
|
|
1261
|
+
response?: Response;
|
|
1262
|
+
/** JSON Response from server */
|
|
1263
|
+
responseJson?: any;
|
|
1264
|
+
constructor(error: Error, errorContext: APIErrorContext, response?: Response, responseJson?: any);
|
|
1265
|
+
}
|
|
1266
|
+
|
|
1267
|
+
/** @internal Required by fetchMap(). */
|
|
1268
|
+
declare function buildPublicMapUrl({ apiBaseUrl, cartoMapId, }: {
|
|
1269
|
+
apiBaseUrl: string;
|
|
1270
|
+
cartoMapId: string;
|
|
1271
|
+
}): string;
|
|
1272
|
+
/** @internal Required by fetchMap(). */
|
|
1273
|
+
declare function buildStatsUrl({ attribute, apiBaseUrl, connectionName, source, type, }: {
|
|
1274
|
+
attribute: string;
|
|
1275
|
+
apiBaseUrl: string;
|
|
1276
|
+
connectionName: string;
|
|
1277
|
+
source: string;
|
|
1278
|
+
type: MapType;
|
|
1279
|
+
}): string;
|
|
1280
|
+
|
|
1281
|
+
type QueryOptions = SourceOptions & QuerySourceOptions;
|
|
1282
|
+
declare const query: (options: QueryOptions) => Promise<QueryResult>;
|
|
1283
|
+
|
|
1284
|
+
declare function requestWithParameters<T = any>({ baseUrl, parameters, headers: customHeaders, errorContext, maxLengthURL, localCache, }: {
|
|
1285
|
+
baseUrl: string;
|
|
1286
|
+
parameters?: Record<string, unknown>;
|
|
1287
|
+
headers?: Record<string, string>;
|
|
1288
|
+
errorContext: APIErrorContext;
|
|
1289
|
+
maxLengthURL?: number;
|
|
1290
|
+
localCache?: LocalCacheOptions;
|
|
1291
|
+
}): Promise<T>;
|
|
1292
|
+
|
|
1293
|
+
/**
|
|
1294
|
+
* Resolution conversion function. Takes a WebMercatorViewport and returns
|
|
1295
|
+
* a H3 resolution such that the screen space size of the hexagons is
|
|
1296
|
+
* "similar" to the given tileSize on screen. Intended for use with deck.gl.
|
|
1297
|
+
* @internal
|
|
1298
|
+
*/
|
|
1299
|
+
declare function _getHexagonResolution(viewport: {
|
|
1300
|
+
zoom: number;
|
|
1301
|
+
latitude: number;
|
|
1302
|
+
}, tileSize: number): number;
|
|
1303
|
+
|
|
1304
|
+
/** @privateRemarks Source: @carto/react-core */
|
|
1305
|
+
type AggregationFunction = (values: unknown[] | FeatureData[], keys?: string[] | string, joinOperation?: AggregationType) => number;
|
|
1306
|
+
/** @privateRemarks Source: @carto/react-core */
|
|
1307
|
+
declare const aggregationFunctions: Record<Exclude<AggregationType, 'custom'>, AggregationFunction>;
|
|
1308
|
+
/** @privateRemarks Source: @carto/react-core */
|
|
1309
|
+
declare function aggregate(feature: FeatureData, keys?: string[], operation?: AggregationType): unknown;
|
|
1310
|
+
|
|
1311
|
+
type SortColumns = string | string[] | object[];
|
|
1312
|
+
interface SortOptions {
|
|
1313
|
+
sortBy?: SortColumns;
|
|
1314
|
+
sortByDirection?: SortDirection;
|
|
1315
|
+
sortByColumnType?: 'number' | 'string' | 'date';
|
|
1316
|
+
}
|
|
1317
|
+
/**
|
|
1318
|
+
* Apply sort structure to a collection of features
|
|
1319
|
+
* @param features
|
|
1320
|
+
* @param [sortOptions]
|
|
1321
|
+
* @param [sortOptions.sortBy] - One or more columns to sort by
|
|
1322
|
+
* @param [sortOptions.sortByDirection] - Direction by the columns will be sorted
|
|
1323
|
+
* @param [sortOptions.sortByColumnType] - Column type
|
|
1324
|
+
* @internal
|
|
1325
|
+
* @privateRemarks Source: @carto/react-core
|
|
1326
|
+
*/
|
|
1327
|
+
declare function applySorting(features: FeatureData[], { sortBy, sortByDirection, sortByColumnType, }?: SortOptions): FeatureData[];
|
|
1328
|
+
|
|
1329
|
+
/** @privateRemarks Source: @carto/react-core */
|
|
1330
|
+
type GroupByFeature = {
|
|
1331
|
+
name: string;
|
|
1332
|
+
value: number;
|
|
1333
|
+
}[];
|
|
1334
|
+
/** @privateRemarks Source: @carto/react-core */
|
|
1335
|
+
declare function groupValuesByColumn({ data, valuesColumns, joinOperation, keysColumn, operation, }: {
|
|
1336
|
+
data: FeatureData[];
|
|
1337
|
+
valuesColumns?: string[];
|
|
1338
|
+
joinOperation?: AggregationType;
|
|
1339
|
+
keysColumn: string;
|
|
1340
|
+
operation: AggregationType;
|
|
1341
|
+
}): GroupByFeature | null;
|
|
1342
|
+
|
|
1343
|
+
/** @privateRemarks Source: @carto/react-core */
|
|
1344
|
+
declare function groupValuesByDateColumn({ data, valuesColumns, joinOperation, keysColumn, groupType, operation, }: {
|
|
1345
|
+
data: Record<string, unknown>[];
|
|
1346
|
+
valuesColumns?: string[];
|
|
1347
|
+
joinOperation?: Exclude<AggregationType, 'custom'>;
|
|
1348
|
+
keysColumn: string;
|
|
1349
|
+
groupType: GroupDateType;
|
|
1350
|
+
operation?: Exclude<AggregationType, 'custom'>;
|
|
1351
|
+
}): GroupByFeature | null;
|
|
1352
|
+
|
|
1353
|
+
/**
|
|
1354
|
+
* Histogram computation.
|
|
1355
|
+
* @privateRemarks Source: @carto/react-core
|
|
1356
|
+
*/
|
|
1357
|
+
declare function histogram({ data, valuesColumns, joinOperation, ticks, operation, }: {
|
|
1358
|
+
data: FeatureData[];
|
|
1359
|
+
valuesColumns?: string[];
|
|
1360
|
+
joinOperation?: Exclude<AggregationType, 'custom'>;
|
|
1361
|
+
ticks: number[];
|
|
1362
|
+
operation: Exclude<AggregationType, 'custom'>;
|
|
1363
|
+
}): number[];
|
|
1364
|
+
|
|
1365
|
+
type ScatterPlotFeature = [number, number][];
|
|
1366
|
+
/**
|
|
1367
|
+
* Filters invalid features and formats data.
|
|
1368
|
+
* @privateRemarks Source: @carto/react-core
|
|
1369
|
+
*/
|
|
1370
|
+
declare function scatterPlot({ data, xAxisColumns, xAxisJoinOperation, yAxisColumns, yAxisJoinOperation, }: {
|
|
1371
|
+
data: FeatureData[];
|
|
1372
|
+
xAxisColumns: string[];
|
|
1373
|
+
xAxisJoinOperation?: AggregationType;
|
|
1374
|
+
yAxisColumns: string[];
|
|
1375
|
+
yAxisJoinOperation?: AggregationType;
|
|
1376
|
+
}): ScatterPlotFeature;
|
|
1377
|
+
|
|
1378
|
+
declare function makeIntervalComplete(intervals: FilterInterval[]): FilterIntervalComplete[];
|
|
1379
|
+
|
|
1380
|
+
/**
|
|
1381
|
+
* Transform WGS84 coordinates to tile coords.
|
|
1382
|
+
* It's the inverse of deck.gl coordinate-transform (https://github.com/visgl/deck.gl/blob/master/modules/geo-layers/src/mvt-layer/coordinate-transform.js)
|
|
1383
|
+
*
|
|
1384
|
+
* @param geometry - any valid geojson geometry
|
|
1385
|
+
* @param bbox - geojson bbox
|
|
1386
|
+
*/
|
|
1387
|
+
declare function transformToTileCoords<T extends Geometry>(geometry: T, bbox: BBox): T;
|
|
1388
|
+
|
|
1389
|
+
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 };
|