@carto/api-client 0.5.0-alpha.3 → 0.5.0-alpha.5
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +4 -0
- package/build/api-client.cjs +3332 -3100
- package/build/api-client.d.cts +1373 -0
- package/build/api-client.d.ts +1373 -0
- package/build/api-client.js +1712 -0
- package/build/chunk-V3E7BKVR.js +2063 -0
- package/build/worker.d.ts +2 -0
- package/build/worker.js +25 -0
- package/package.json +51 -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 +19 -41
- package/src/filters.ts +4 -4
- package/src/geo.ts +12 -14
- package/src/global.d.ts +3 -8
- package/src/index.ts +1 -0
- package/src/models/common.ts +9 -7
- 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 +12 -5
- 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 +12 -5
- package/src/sources/raster-source.ts +7 -16
- package/src/sources/types.ts +10 -4
- 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 +13 -6
- package/src/spatial-index.ts +4 -4
- package/src/types-internal.ts +5 -5
- package/src/types.ts +15 -21
- package/src/utils/makeIntervalComplete.ts +1 -1
- package/src/utils.ts +3 -3
- package/src/widget-sources/index.ts +1 -1
- package/src/widget-sources/types.ts +5 -3
- package/src/widget-sources/widget-query-source.ts +6 -2
- package/src/widget-sources/widget-remote-source.ts +66 -18
- package/src/widget-sources/widget-source.ts +0 -28
- package/src/widget-sources/widget-table-source.ts +6 -2
- package/src/widget-sources/widget-tileset-source.ts +130 -90
- package/src/widget-sources/widget-tileset-worker-source.ts +238 -0
- package/src/workers/constants.ts +13 -0
- package/src/workers/types.ts +20 -0
- package/src/workers/utils.ts +33 -0
- package/src/workers/widget-tileset-worker.ts +36 -0
- package/build/api/carto-api-error.d.ts +0 -26
- package/build/api/endpoints.d.ts +0 -24
- package/build/api/index.d.ts +0 -5
- package/build/api/query.d.ts +0 -3
- package/build/api/request-with-parameters.d.ts +0 -10
- package/build/api-client.cjs.map +0 -1
- package/build/api-client.modern.js +0 -3304
- 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 -21
- package/build/filters/tileFeaturesGeometries.d.ts +0 -13
- package/build/filters/tileFeaturesRaster.d.ts +0 -16
- package/build/filters/tileFeaturesSpatialIndex.d.ts +0 -10
- package/build/filters.d.ts +0 -39
- package/build/geo.d.ts +0 -19
- package/build/index.d.ts +0 -15
- 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 -5
- package/build/sources/types.d.ts +0 -366
- package/build/sources/vector-query-source.d.ts +0 -5
- package/build/sources/vector-table-source.d.ts +0 -5
- package/build/sources/vector-tileset-source.d.ts +0 -5
- package/build/spatial-index.d.ts +0 -14
- package/build/types-internal.d.ts +0 -56
- package/build/types.d.ts +0 -148
- package/build/utils/dateUtils.d.ts +0 -10
- package/build/utils/getTileFormat.d.ts +0 -3
- package/build/utils/makeIntervalComplete.d.ts +0 -2
- package/build/utils/transformTileCoordsToWGS84.d.ts +0 -8
- package/build/utils/transformToTileCoords.d.ts +0 -9
- package/build/utils.d.ts +0 -32
- package/build/widget-sources/index.d.ts +0 -7
- package/build/widget-sources/types.d.ts +0 -158
- package/build/widget-sources/widget-query-source.d.ts +0 -33
- package/build/widget-sources/widget-raster-source.d.ts +0 -11
- 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 -77
- package/src/filters/tileFeaturesRaster.ts +0 -111
- package/src/widget-sources/widget-raster-source.ts +0 -14
|
@@ -1,158 +0,0 @@
|
|
|
1
|
-
import { SpatialFilterPolyfillMode, TileResolution } from '../sources/types';
|
|
2
|
-
import { GroupDateType, SortColumnType, SortDirection, SpatialFilter } from '../types';
|
|
3
|
-
/******************************************************************************
|
|
4
|
-
* WIDGET API REQUESTS
|
|
5
|
-
*/
|
|
6
|
-
export interface ViewState {
|
|
7
|
-
zoom: number;
|
|
8
|
-
latitude: number;
|
|
9
|
-
longitude: number;
|
|
10
|
-
}
|
|
11
|
-
/** Common options for {@link WidgetRemoteSource} requests. */
|
|
12
|
-
interface BaseRequestOptions {
|
|
13
|
-
spatialFilter?: SpatialFilter;
|
|
14
|
-
spatialFiltersMode?: SpatialFilterPolyfillMode;
|
|
15
|
-
/** Required for table- and query-based spatial index sources (H3, Quadbin). */
|
|
16
|
-
spatialIndexReferenceViewState?: ViewState;
|
|
17
|
-
abortController?: AbortController;
|
|
18
|
-
filterOwner?: string;
|
|
19
|
-
}
|
|
20
|
-
/** Options for {@link WidgetRemoteSource#getCategories}. */
|
|
21
|
-
export interface CategoryRequestOptions extends BaseRequestOptions {
|
|
22
|
-
column: string;
|
|
23
|
-
operation?: 'count' | 'avg' | 'min' | 'max' | 'sum';
|
|
24
|
-
operationColumn?: string;
|
|
25
|
-
/** Local only. */
|
|
26
|
-
joinOperation?: 'count' | 'avg' | 'min' | 'max' | 'sum';
|
|
27
|
-
}
|
|
28
|
-
/**
|
|
29
|
-
* Options for {@link WidgetRemoteSource#getFeatures}.
|
|
30
|
-
* @experimental
|
|
31
|
-
* @internal
|
|
32
|
-
*/
|
|
33
|
-
export interface FeaturesRequestOptions extends BaseRequestOptions {
|
|
34
|
-
/**
|
|
35
|
-
* Feature IDs, as found in `_carto_feature_id`. Feature IDs are a hash
|
|
36
|
-
* of geometry, and features with identical geometry will have the same
|
|
37
|
-
* feature ID. Order is important; features in the result set will be
|
|
38
|
-
* sorted according to the order of IDs in the request.
|
|
39
|
-
*/
|
|
40
|
-
featureIds: string[];
|
|
41
|
-
/**
|
|
42
|
-
* Columns to be returned for each picked object. Note that for datasets
|
|
43
|
-
* containing features with identical geometry, more than one result per
|
|
44
|
-
* requested feature ID may be returned. To match results back to the
|
|
45
|
-
* requested feature ID, include `_carto_feature_id` in the columns list.
|
|
46
|
-
*/
|
|
47
|
-
columns: string[];
|
|
48
|
-
/** Topology of objects to be picked. */
|
|
49
|
-
dataType: 'points' | 'lines' | 'polygons';
|
|
50
|
-
/** Zoom level, required if using 'points' data type. */
|
|
51
|
-
z?: number;
|
|
52
|
-
/**
|
|
53
|
-
* Maximum number of objects to return in the result set. For datasets
|
|
54
|
-
* containing features with identical geometry, those features will have
|
|
55
|
-
* the same feature IDs, and so more results may be returned than feature IDs
|
|
56
|
-
* given in the request.
|
|
57
|
-
*/
|
|
58
|
-
limit?: number;
|
|
59
|
-
/**
|
|
60
|
-
* Must match `tileResolution` used when obtaining the `_carto_feature_id`
|
|
61
|
-
* column, typically in a layer's tile requests.
|
|
62
|
-
*/
|
|
63
|
-
tileResolution?: TileResolution;
|
|
64
|
-
}
|
|
65
|
-
/** Options for {@link WidgetRemoteSource#getFormula}. */
|
|
66
|
-
export interface FormulaRequestOptions extends BaseRequestOptions {
|
|
67
|
-
column: string;
|
|
68
|
-
operation?: 'count' | 'avg' | 'min' | 'max' | 'sum' | 'custom';
|
|
69
|
-
operationExp?: string;
|
|
70
|
-
joinOperation?: 'count' | 'avg' | 'min' | 'max' | 'sum';
|
|
71
|
-
}
|
|
72
|
-
/** Options for {@link WidgetRemoteSource#getHistogram}. */
|
|
73
|
-
export interface HistogramRequestOptions extends BaseRequestOptions {
|
|
74
|
-
column: string;
|
|
75
|
-
ticks: number[];
|
|
76
|
-
operation?: 'count' | 'avg' | 'min' | 'max' | 'sum';
|
|
77
|
-
/** Local only. */
|
|
78
|
-
joinOperation?: 'count' | 'avg' | 'min' | 'max' | 'sum';
|
|
79
|
-
}
|
|
80
|
-
/** Options for {@link WidgetRemoteSource#getRange}. */
|
|
81
|
-
export interface RangeRequestOptions extends BaseRequestOptions {
|
|
82
|
-
column: string;
|
|
83
|
-
}
|
|
84
|
-
/** Options for {@link WidgetRemoteSource#getScatter}. */
|
|
85
|
-
export interface ScatterRequestOptions extends BaseRequestOptions {
|
|
86
|
-
xAxisColumn: string;
|
|
87
|
-
xAxisJoinOperation?: 'count' | 'avg' | 'min' | 'max' | 'sum';
|
|
88
|
-
yAxisColumn: string;
|
|
89
|
-
yAxisJoinOperation?: 'count' | 'avg' | 'min' | 'max' | 'sum';
|
|
90
|
-
}
|
|
91
|
-
/** Options for {@link WidgetRemoteSource#getTable}. */
|
|
92
|
-
export interface TableRequestOptions extends BaseRequestOptions {
|
|
93
|
-
columns: string[];
|
|
94
|
-
sortBy?: string;
|
|
95
|
-
sortDirection?: SortDirection;
|
|
96
|
-
sortByColumnType?: SortColumnType;
|
|
97
|
-
offset?: number;
|
|
98
|
-
limit?: number;
|
|
99
|
-
/** Local only. */
|
|
100
|
-
searchFilterColumn?: string;
|
|
101
|
-
/** Local only. */
|
|
102
|
-
searchFilterText?: string;
|
|
103
|
-
}
|
|
104
|
-
/** Options for {@link WidgetRemoteSource#getTimeSeries}. */
|
|
105
|
-
export interface TimeSeriesRequestOptions extends BaseRequestOptions {
|
|
106
|
-
column: string;
|
|
107
|
-
stepSize: GroupDateType;
|
|
108
|
-
stepMultiplier?: number;
|
|
109
|
-
operation?: 'count' | 'avg' | 'min' | 'max' | 'sum';
|
|
110
|
-
operationColumn?: string;
|
|
111
|
-
joinOperation?: 'count' | 'avg' | 'min' | 'max' | 'sum';
|
|
112
|
-
splitByCategory?: string;
|
|
113
|
-
splitByCategoryLimit?: number;
|
|
114
|
-
splitByCategoryValues?: string[];
|
|
115
|
-
}
|
|
116
|
-
/******************************************************************************
|
|
117
|
-
* WIDGET API RESPONSES
|
|
118
|
-
*/
|
|
119
|
-
/**
|
|
120
|
-
* Response from {@link WidgetRemoteSource#getFeatures}.
|
|
121
|
-
* @experimental
|
|
122
|
-
* @internal
|
|
123
|
-
*/
|
|
124
|
-
export type FeaturesResponse = {
|
|
125
|
-
rows: Record<string, unknown>[];
|
|
126
|
-
};
|
|
127
|
-
/** Response from {@link WidgetRemoteSource#getFormula}. */
|
|
128
|
-
export type FormulaResponse = {
|
|
129
|
-
value: number | null;
|
|
130
|
-
};
|
|
131
|
-
/** Response from {@link WidgetRemoteSource#getCategories}. */
|
|
132
|
-
export type CategoryResponse = {
|
|
133
|
-
name: string;
|
|
134
|
-
value: number;
|
|
135
|
-
}[];
|
|
136
|
-
/** Response from {@link WidgetRemoteSource#getRange}. */
|
|
137
|
-
export type RangeResponse = {
|
|
138
|
-
min: number;
|
|
139
|
-
max: number;
|
|
140
|
-
} | null;
|
|
141
|
-
/** Response from {@link WidgetRemoteSource#getTable}. */
|
|
142
|
-
export type TableResponse = {
|
|
143
|
-
totalCount: number;
|
|
144
|
-
rows: Record<string, number | string>[];
|
|
145
|
-
};
|
|
146
|
-
/** Response from {@link WidgetRemoteSource#getScatter}. */
|
|
147
|
-
export type ScatterResponse = [number, number][];
|
|
148
|
-
/** Response from {@link WidgetRemoteSource#getTimeSeries}. */
|
|
149
|
-
export type TimeSeriesResponse = {
|
|
150
|
-
rows: {
|
|
151
|
-
name: string;
|
|
152
|
-
value: number;
|
|
153
|
-
}[];
|
|
154
|
-
categories?: string[];
|
|
155
|
-
};
|
|
156
|
-
/** Response from {@link WidgetRemoteSource#getHistogram}. */
|
|
157
|
-
export type HistogramResponse = number[];
|
|
158
|
-
export {};
|
|
@@ -1,33 +0,0 @@
|
|
|
1
|
-
import { H3QuerySourceOptions, QuadbinQuerySourceOptions, VectorQuerySourceOptions } from '../sources/index.js';
|
|
2
|
-
import { WidgetRemoteSource, WidgetRemoteSourceProps } from './widget-remote-source.js';
|
|
3
|
-
import { ModelSource } from '../models/model.js';
|
|
4
|
-
type LayerQuerySourceOptions = Omit<VectorQuerySourceOptions, 'filters'> | Omit<H3QuerySourceOptions, 'filters'> | Omit<QuadbinQuerySourceOptions, 'filters'>;
|
|
5
|
-
export type WidgetQuerySourceResult = {
|
|
6
|
-
widgetSource: WidgetQuerySource;
|
|
7
|
-
};
|
|
8
|
-
/**
|
|
9
|
-
* Source for Widget API requests on a data source defined by a SQL query.
|
|
10
|
-
*
|
|
11
|
-
* Generally not intended to be constructed directly. Instead, call
|
|
12
|
-
* {@link vectorQuerySource}, {@link h3QuerySource}, or {@link quadbinQuerySource},
|
|
13
|
-
* which can be shared with map layers. Sources contain a `widgetSource` property,
|
|
14
|
-
* for use by widget implementations.
|
|
15
|
-
*
|
|
16
|
-
* Example:
|
|
17
|
-
*
|
|
18
|
-
* ```javascript
|
|
19
|
-
* import { vectorQuerySource } from '@carto/api-client';
|
|
20
|
-
*
|
|
21
|
-
* const data = vectorQuerySource({
|
|
22
|
-
* accessToken: '••••',
|
|
23
|
-
* connectionName: 'carto_dw',
|
|
24
|
-
* sqlQuery: 'SELECT * FROM carto-demo-data.demo_tables.retail_stores'
|
|
25
|
-
* });
|
|
26
|
-
*
|
|
27
|
-
* const { widgetSource } = await data;
|
|
28
|
-
* ```
|
|
29
|
-
*/
|
|
30
|
-
export declare class WidgetQuerySource extends WidgetRemoteSource<LayerQuerySourceOptions & WidgetRemoteSourceProps> {
|
|
31
|
-
protected getModelSource(owner: string): ModelSource;
|
|
32
|
-
}
|
|
33
|
-
export {};
|
|
@@ -1,11 +0,0 @@
|
|
|
1
|
-
import { RasterMetadata } from '../sources/index.js';
|
|
2
|
-
import { WidgetTilesetSource, WidgetTilesetSourceProps } from './widget-tileset-source.js';
|
|
3
|
-
export type WidgetRasterSourceProps = WidgetTilesetSourceProps & {
|
|
4
|
-
rasterMetadata: RasterMetadata;
|
|
5
|
-
spatialDataType: 'quadbin';
|
|
6
|
-
};
|
|
7
|
-
export type WidgetRasterSourceResult = {
|
|
8
|
-
widgetSource: WidgetRasterSource;
|
|
9
|
-
};
|
|
10
|
-
export declare class WidgetRasterSource extends WidgetTilesetSource<WidgetRasterSourceProps> {
|
|
11
|
-
}
|
|
@@ -1,18 +0,0 @@
|
|
|
1
|
-
import { CategoryRequestOptions, CategoryResponse, FeaturesRequestOptions, FeaturesResponse, FormulaRequestOptions, FormulaResponse, HistogramRequestOptions, HistogramResponse, RangeRequestOptions, RangeResponse, ScatterRequestOptions, ScatterResponse, TableRequestOptions, TableResponse, TimeSeriesRequestOptions, TimeSeriesResponse } from './types.js';
|
|
2
|
-
import { WidgetSource, WidgetSourceProps } from './widget-source.js';
|
|
3
|
-
export type WidgetRemoteSourceProps = WidgetSourceProps;
|
|
4
|
-
/**
|
|
5
|
-
* Source for Widget API requests.
|
|
6
|
-
*
|
|
7
|
-
* Abstract class. Use {@link WidgetQuerySource} or {@link WidgetTableSource}.
|
|
8
|
-
*/
|
|
9
|
-
export declare abstract class WidgetRemoteSource<Props extends WidgetRemoteSourceProps> extends WidgetSource<Props> {
|
|
10
|
-
getCategories(options: CategoryRequestOptions): Promise<CategoryResponse>;
|
|
11
|
-
getFeatures(options: FeaturesRequestOptions): Promise<FeaturesResponse>;
|
|
12
|
-
getFormula(options: FormulaRequestOptions): Promise<FormulaResponse>;
|
|
13
|
-
getHistogram(options: HistogramRequestOptions): Promise<HistogramResponse>;
|
|
14
|
-
getRange(options: RangeRequestOptions): Promise<RangeResponse>;
|
|
15
|
-
getScatter(options: ScatterRequestOptions): Promise<ScatterResponse>;
|
|
16
|
-
getTable(options: TableRequestOptions): Promise<TableResponse>;
|
|
17
|
-
getTimeSeries(options: TimeSeriesRequestOptions): Promise<TimeSeriesResponse>;
|
|
18
|
-
}
|
|
@@ -1,74 +0,0 @@
|
|
|
1
|
-
import { CategoryRequestOptions, CategoryResponse, FeaturesRequestOptions, FeaturesResponse, FormulaRequestOptions, FormulaResponse, HistogramRequestOptions, HistogramResponse, RangeRequestOptions, RangeResponse, ScatterRequestOptions, ScatterResponse, TableRequestOptions, TableResponse, TimeSeriesRequestOptions, TimeSeriesResponse, ViewState } from './types.js';
|
|
2
|
-
import { FilterLogicalOperator, Filter, SpatialFilter } from '../types.js';
|
|
3
|
-
import { ModelSource } from '../models/model.js';
|
|
4
|
-
import { SourceOptions } from '../sources/index.js';
|
|
5
|
-
import { ApiVersion } from '../constants.js';
|
|
6
|
-
export interface WidgetSourceProps extends Omit<SourceOptions, 'filters'> {
|
|
7
|
-
apiVersion?: ApiVersion;
|
|
8
|
-
filters?: Record<string, Filter>;
|
|
9
|
-
filtersLogicalOperator?: FilterLogicalOperator;
|
|
10
|
-
}
|
|
11
|
-
/**
|
|
12
|
-
* Source for Widget API requests on a data source defined by a SQL query.
|
|
13
|
-
*
|
|
14
|
-
* Abstract class. Use {@link WidgetQuerySource} or {@link WidgetTableSource}.
|
|
15
|
-
*/
|
|
16
|
-
export declare abstract class WidgetSource<Props extends WidgetSourceProps> {
|
|
17
|
-
readonly props: Props;
|
|
18
|
-
static defaultProps: Partial<WidgetSourceProps>;
|
|
19
|
-
constructor(props: Props);
|
|
20
|
-
/**
|
|
21
|
-
* Subclasses of {@link WidgetRemoteSource} must implement this method, calling
|
|
22
|
-
* {@link WidgetRemoteSource.prototype._getModelSource} for common source
|
|
23
|
-
* properties, and adding additional required properties including 'type' and
|
|
24
|
-
* 'data'.
|
|
25
|
-
*/
|
|
26
|
-
protected abstract getModelSource(owner: string | undefined): ModelSource;
|
|
27
|
-
protected _getModelSource(owner?: string): Omit<ModelSource, 'type' | 'data'>;
|
|
28
|
-
protected _getSpatialFiltersResolution(source: Omit<ModelSource, 'type' | 'data'>, spatialFilter?: SpatialFilter, referenceViewState?: ViewState): number | undefined;
|
|
29
|
-
/**
|
|
30
|
-
* Returns a list of labeled datapoints for categorical data. Suitable for
|
|
31
|
-
* charts including grouped bar charts, pie charts, and tree charts.
|
|
32
|
-
*/
|
|
33
|
-
abstract getCategories(options: CategoryRequestOptions): Promise<CategoryResponse>;
|
|
34
|
-
/**
|
|
35
|
-
* Given a list of feature IDs (as found in `_carto_feature_id`) returns all
|
|
36
|
-
* matching features. In datasets containing features with duplicate geometries,
|
|
37
|
-
* feature IDs may be duplicated (IDs are a hash of geometry) and so more
|
|
38
|
-
* results may be returned than IDs in the request.
|
|
39
|
-
* @internal
|
|
40
|
-
* @experimental
|
|
41
|
-
*/
|
|
42
|
-
abstract getFeatures(options: FeaturesRequestOptions): Promise<FeaturesResponse>;
|
|
43
|
-
/**
|
|
44
|
-
* Returns a scalar numerical statistic over all matching data. Suitable
|
|
45
|
-
* for 'headline' or 'scorecard' figures such as counts and sums.
|
|
46
|
-
*/
|
|
47
|
-
abstract getFormula(options: FormulaRequestOptions): Promise<FormulaResponse>;
|
|
48
|
-
/**
|
|
49
|
-
* Returns a list of labeled datapoints for 'bins' of data defined as ticks
|
|
50
|
-
* over a numerical range. Suitable for histogram charts.
|
|
51
|
-
*/
|
|
52
|
-
abstract getHistogram(options: HistogramRequestOptions): Promise<HistogramResponse>;
|
|
53
|
-
/**
|
|
54
|
-
* Returns a range (min and max) for a numerical column of matching rows.
|
|
55
|
-
* Suitable for displaying certain 'headline' or 'scorecard' statistics,
|
|
56
|
-
* or rendering a range slider UI for filtering.
|
|
57
|
-
*/
|
|
58
|
-
abstract getRange(options: RangeRequestOptions): Promise<RangeResponse>;
|
|
59
|
-
/**
|
|
60
|
-
* Returns a list of bivariate datapoints defined as numerical 'x' and 'y'
|
|
61
|
-
* values. Suitable for rendering scatter plots.
|
|
62
|
-
*/
|
|
63
|
-
abstract getScatter(options: ScatterRequestOptions): Promise<ScatterResponse>;
|
|
64
|
-
/**
|
|
65
|
-
* Returns a list of arbitrary data rows, with support for pagination and
|
|
66
|
-
* sorting. Suitable for displaying tables and lists.
|
|
67
|
-
*/
|
|
68
|
-
abstract getTable(options: TableRequestOptions): Promise<TableResponse>;
|
|
69
|
-
/**
|
|
70
|
-
* Returns a series of labeled numerical values, grouped into equally-sized
|
|
71
|
-
* time intervals. Suitable for rendering time series charts.
|
|
72
|
-
*/
|
|
73
|
-
abstract getTimeSeries(options: TimeSeriesRequestOptions): Promise<TimeSeriesResponse>;
|
|
74
|
-
}
|
|
@@ -1,33 +0,0 @@
|
|
|
1
|
-
import { H3TableSourceOptions, QuadbinTableSourceOptions, VectorTableSourceOptions } from '../sources/index.js';
|
|
2
|
-
import { WidgetRemoteSource, WidgetRemoteSourceProps } from './widget-remote-source.js';
|
|
3
|
-
import { ModelSource } from '../models/model.js';
|
|
4
|
-
type LayerTableSourceOptions = Omit<VectorTableSourceOptions, 'filters'> | Omit<H3TableSourceOptions, 'filters'> | Omit<QuadbinTableSourceOptions, 'filters'>;
|
|
5
|
-
export type WidgetTableSourceResult = {
|
|
6
|
-
widgetSource: WidgetTableSource;
|
|
7
|
-
};
|
|
8
|
-
/**
|
|
9
|
-
* Source for Widget API requests on a data source defined as a table.
|
|
10
|
-
*
|
|
11
|
-
* Generally not intended to be constructed directly. Instead, call
|
|
12
|
-
* {@link vectorTableSource}, {@link h3TableSource}, or {@link quadbinTableSource},
|
|
13
|
-
* which can be shared with map layers. Sources contain a `widgetSource` property,
|
|
14
|
-
* for use by widget implementations.
|
|
15
|
-
*
|
|
16
|
-
* Example:
|
|
17
|
-
*
|
|
18
|
-
* ```javascript
|
|
19
|
-
* import { vectorTableSource } from '@carto/api-client';
|
|
20
|
-
*
|
|
21
|
-
* const data = vectorTableSource({
|
|
22
|
-
* accessToken: '••••',
|
|
23
|
-
* connectionName: 'carto_dw',
|
|
24
|
-
* tableName: 'carto-demo-data.demo_tables.retail_stores'
|
|
25
|
-
* });
|
|
26
|
-
*
|
|
27
|
-
* const { widgetSource } = await data;
|
|
28
|
-
* ```
|
|
29
|
-
*/
|
|
30
|
-
export declare class WidgetTableSource extends WidgetRemoteSource<LayerTableSourceOptions & WidgetRemoteSourceProps> {
|
|
31
|
-
protected getModelSource(owner: string): ModelSource;
|
|
32
|
-
}
|
|
33
|
-
export {};
|
|
@@ -1,77 +0,0 @@
|
|
|
1
|
-
import { TilesetSourceOptions } from '../sources/index.js';
|
|
2
|
-
import type { ModelSource } from '../models/index.js';
|
|
3
|
-
import { CategoryRequestOptions, CategoryResponse, FeaturesRequestOptions, FeaturesResponse, FormulaRequestOptions, FormulaResponse, HistogramRequestOptions, HistogramResponse, RangeRequestOptions, RangeResponse, ScatterRequestOptions, ScatterResponse, TableRequestOptions, TableResponse, TimeSeriesRequestOptions, TimeSeriesResponse } from './types.js';
|
|
4
|
-
import { TileFormat } from '../constants.js';
|
|
5
|
-
import { SpatialFilter, Tile } from '../types.js';
|
|
6
|
-
import { TileFeatureExtractOptions } from '../filters/index.js';
|
|
7
|
-
import { FeatureData } from '../types-internal.js';
|
|
8
|
-
import { FeatureCollection } from 'geojson';
|
|
9
|
-
import { SpatialDataType } from '../sources/types.js';
|
|
10
|
-
import { WidgetSource, WidgetSourceProps } from './widget-source.js';
|
|
11
|
-
export type WidgetTilesetSourceProps = WidgetSourceProps & Omit<TilesetSourceOptions, 'filters'> & {
|
|
12
|
-
tileFormat: TileFormat;
|
|
13
|
-
spatialDataType: SpatialDataType;
|
|
14
|
-
};
|
|
15
|
-
export type WidgetTilesetSourceResult = {
|
|
16
|
-
widgetSource: WidgetTilesetSource;
|
|
17
|
-
};
|
|
18
|
-
/**
|
|
19
|
-
* Source for Widget API requests on a data source defined by a tileset.
|
|
20
|
-
*
|
|
21
|
-
* Generally not intended to be constructed directly. Instead, call
|
|
22
|
-
* {@link vectorTilesetSource}, {@link h3TilesetSource}, or {@link quadbinTilesetSource},
|
|
23
|
-
* which can be shared with map layers. Sources contain a `widgetSource`
|
|
24
|
-
* property, for use by widget implementations.
|
|
25
|
-
*
|
|
26
|
-
* Example:
|
|
27
|
-
*
|
|
28
|
-
* ```javascript
|
|
29
|
-
* import { vectorTilesetSource } from '@carto/api-client';
|
|
30
|
-
*
|
|
31
|
-
* const data = vectorTilesetSource({
|
|
32
|
-
* accessToken: '••••',
|
|
33
|
-
* connectionName: 'carto_dw',
|
|
34
|
-
* tableName: 'carto-demo-data.demo_rasters.my_tileset_source'
|
|
35
|
-
* });
|
|
36
|
-
*
|
|
37
|
-
* const { widgetSource } = await data;
|
|
38
|
-
* ```
|
|
39
|
-
*/
|
|
40
|
-
export declare class WidgetTilesetSource<Props extends WidgetTilesetSourceProps = WidgetTilesetSourceProps> extends WidgetSource<Props> {
|
|
41
|
-
protected _tiles: Tile[];
|
|
42
|
-
protected _features: FeatureData[];
|
|
43
|
-
protected getModelSource(owner: string): ModelSource;
|
|
44
|
-
/**
|
|
45
|
-
* Loads features as a list of tiles (typically provided by deck.gl).
|
|
46
|
-
* After tiles are loaded, {@link extractTileFeatures} must be called
|
|
47
|
-
* before computing statistics on the tiles.
|
|
48
|
-
*/
|
|
49
|
-
loadTiles(tiles: unknown[]): void;
|
|
50
|
-
/**
|
|
51
|
-
* Extracts feature data from tiles previously loaded with {@link loadTiles}.
|
|
52
|
-
* Must be called before computing statistics on tiles.
|
|
53
|
-
*/
|
|
54
|
-
extractTileFeatures({ spatialFilter, uniqueIdProperty, options, }: {
|
|
55
|
-
spatialFilter: SpatialFilter;
|
|
56
|
-
uniqueIdProperty?: string;
|
|
57
|
-
options?: TileFeatureExtractOptions;
|
|
58
|
-
}): void;
|
|
59
|
-
/** Loads features as GeoJSON (used for testing). */
|
|
60
|
-
loadGeoJSON({ geojson, spatialFilter, uniqueIdProperty, }: {
|
|
61
|
-
geojson: FeatureCollection;
|
|
62
|
-
spatialFilter: SpatialFilter;
|
|
63
|
-
uniqueIdProperty?: string;
|
|
64
|
-
}): void;
|
|
65
|
-
getFeatures(options: FeaturesRequestOptions): Promise<FeaturesResponse>;
|
|
66
|
-
getFormula({ column, operation, joinOperation, filterOwner, }: FormulaRequestOptions): Promise<FormulaResponse>;
|
|
67
|
-
getHistogram({ operation, ticks, column, joinOperation, filterOwner, }: HistogramRequestOptions): Promise<HistogramResponse>;
|
|
68
|
-
getCategories({ column, operation, operationColumn, joinOperation, filterOwner, }: CategoryRequestOptions): Promise<CategoryResponse>;
|
|
69
|
-
getScatter({ xAxisColumn, yAxisColumn, xAxisJoinOperation, yAxisJoinOperation, filterOwner, }: ScatterRequestOptions): Promise<ScatterResponse>;
|
|
70
|
-
getTable(options: TableRequestOptions): Promise<TableResponse>;
|
|
71
|
-
getTimeSeries({ column, stepSize, operation, operationColumn, joinOperation, filterOwner, }: TimeSeriesRequestOptions): Promise<TimeSeriesResponse>;
|
|
72
|
-
getRange({ column, filterOwner, }: RangeRequestOptions): Promise<RangeResponse>;
|
|
73
|
-
/****************************************************************************
|
|
74
|
-
* INTERNAL
|
|
75
|
-
*/
|
|
76
|
-
private _getFilteredFeatures;
|
|
77
|
-
}
|
|
@@ -1,111 +0,0 @@
|
|
|
1
|
-
import {
|
|
2
|
-
cellToChildren as _cellToChildren,
|
|
3
|
-
cellToTile,
|
|
4
|
-
geometryToCells,
|
|
5
|
-
getResolution,
|
|
6
|
-
} from 'quadbin';
|
|
7
|
-
import {RasterTile, SpatialFilter, Tile} from '../types';
|
|
8
|
-
import {FeatureData} from '../types-internal';
|
|
9
|
-
import {
|
|
10
|
-
RasterMetadata,
|
|
11
|
-
RasterMetadataBand,
|
|
12
|
-
SpatialDataType,
|
|
13
|
-
} from '../sources/types';
|
|
14
|
-
|
|
15
|
-
export type TileFeaturesRasterOptions = {
|
|
16
|
-
tiles: RasterTile[];
|
|
17
|
-
spatialFilter: SpatialFilter;
|
|
18
|
-
spatialDataColumn: string;
|
|
19
|
-
spatialDataType: SpatialDataType;
|
|
20
|
-
rasterMetadata: RasterMetadata;
|
|
21
|
-
};
|
|
22
|
-
|
|
23
|
-
export function tileFeaturesRaster({
|
|
24
|
-
tiles,
|
|
25
|
-
...options
|
|
26
|
-
}: TileFeaturesRasterOptions): FeatureData[] {
|
|
27
|
-
// Cache band metadata for faster lookup while iterating over pixels.
|
|
28
|
-
const bandMetadataByName: Record<string, RasterMetadataBand> = {};
|
|
29
|
-
for (const band of options.rasterMetadata.bands) {
|
|
30
|
-
bandMetadataByName[band.name] = band;
|
|
31
|
-
}
|
|
32
|
-
|
|
33
|
-
// Omit empty and invisible tiles for simpler processing and types.
|
|
34
|
-
tiles = tiles.filter(isRasterTileVisible);
|
|
35
|
-
if (tiles.length === 0) return [];
|
|
36
|
-
|
|
37
|
-
// Raster tiles, and all pixels, are quadbin cells. Resolution of a pixel is
|
|
38
|
-
// the resolution of the tile, plus the number of subdivisions. Block size
|
|
39
|
-
// must be square, N x N, where N is a power of two.
|
|
40
|
-
const tileResolution = getResolution(tiles[0].index.q as bigint);
|
|
41
|
-
const tileBlockSize = tiles[0].data!.blockSize;
|
|
42
|
-
const cellResolution = tileResolution + BigInt(Math.log2(tileBlockSize));
|
|
43
|
-
|
|
44
|
-
// Compute covering cells for the spatial filter, at same resolution as the
|
|
45
|
-
// raster pixels, to be used as a mask.
|
|
46
|
-
const spatialFilterCells = new Set(
|
|
47
|
-
geometryToCells(options.spatialFilter, cellResolution)
|
|
48
|
-
);
|
|
49
|
-
|
|
50
|
-
const data = new Map<bigint, FeatureData>();
|
|
51
|
-
|
|
52
|
-
for (const tile of tiles as Required<RasterTile>[]) {
|
|
53
|
-
const parent = tile.index.q as bigint;
|
|
54
|
-
|
|
55
|
-
const children = cellToChildrenSorted(parent, cellResolution);
|
|
56
|
-
|
|
57
|
-
// For each pixel/cell within the spatial filter, create a FeatureData.
|
|
58
|
-
// Order is row-major, starting from NW and ending at SE.
|
|
59
|
-
for (let i = 0; i < children.length; i++) {
|
|
60
|
-
if (!spatialFilterCells.has(children[i])) continue;
|
|
61
|
-
|
|
62
|
-
const cellData: FeatureData = {};
|
|
63
|
-
let cellDataExists = false;
|
|
64
|
-
|
|
65
|
-
for (const band in tile.data.cells.numericProps) {
|
|
66
|
-
const value = tile.data.cells.numericProps[band].value[i];
|
|
67
|
-
// TODO(cleanup): nodata should be a number, not a string.
|
|
68
|
-
if (Number(bandMetadataByName[band].nodata) !== value) {
|
|
69
|
-
cellData[band] = tile.data!.cells.numericProps[band].value[i];
|
|
70
|
-
cellDataExists = true;
|
|
71
|
-
}
|
|
72
|
-
}
|
|
73
|
-
|
|
74
|
-
if (cellDataExists) {
|
|
75
|
-
data.set(children[i], cellData);
|
|
76
|
-
}
|
|
77
|
-
}
|
|
78
|
-
}
|
|
79
|
-
|
|
80
|
-
return Array.from(data.values());
|
|
81
|
-
}
|
|
82
|
-
|
|
83
|
-
/**
|
|
84
|
-
* Detects whether a given {@link Tile} is a {@link RasterTile}.
|
|
85
|
-
* @privateRemarks Method of detection is arbitrary, and may be changed.
|
|
86
|
-
*/
|
|
87
|
-
export function isRasterTile(tile: Tile): tile is RasterTile {
|
|
88
|
-
return tile.data ? tile.data.hasOwnProperty('cells') : false;
|
|
89
|
-
}
|
|
90
|
-
|
|
91
|
-
function isRasterTileVisible(tile: RasterTile): tile is Required<RasterTile> {
|
|
92
|
-
return !!(tile.isVisible && tile.data?.cells?.numericProps);
|
|
93
|
-
}
|
|
94
|
-
|
|
95
|
-
/**
|
|
96
|
-
* For the raster format, children are sorted in row-major order, starting from
|
|
97
|
-
* NW and ending at SE. Order returned by quadbin's cellToChildren() is not
|
|
98
|
-
* defined (and not related to the raster format), so sort explicitly here.
|
|
99
|
-
*/
|
|
100
|
-
function cellToChildrenSorted(parent: bigint, resolution: bigint): bigint[] {
|
|
101
|
-
return _cellToChildren(parent, resolution).sort(
|
|
102
|
-
(cellA: bigint, cellB: bigint) => {
|
|
103
|
-
const tileA = cellToTile(cellA);
|
|
104
|
-
const tileB = cellToTile(cellB);
|
|
105
|
-
if (tileA.y !== tileB.y) {
|
|
106
|
-
return tileA.y > tileB.y ? 1 : -1;
|
|
107
|
-
}
|
|
108
|
-
return tileA.x > tileB.x ? 1 : -1;
|
|
109
|
-
}
|
|
110
|
-
);
|
|
111
|
-
}
|
|
@@ -1,14 +0,0 @@
|
|
|
1
|
-
import {RasterMetadata} from '../sources/index.js';
|
|
2
|
-
import {
|
|
3
|
-
WidgetTilesetSource,
|
|
4
|
-
WidgetTilesetSourceProps,
|
|
5
|
-
} from './widget-tileset-source.js';
|
|
6
|
-
|
|
7
|
-
export type WidgetRasterSourceProps = WidgetTilesetSourceProps & {
|
|
8
|
-
rasterMetadata: RasterMetadata;
|
|
9
|
-
spatialDataType: 'quadbin';
|
|
10
|
-
};
|
|
11
|
-
|
|
12
|
-
export type WidgetRasterSourceResult = {widgetSource: WidgetRasterSource};
|
|
13
|
-
|
|
14
|
-
export class WidgetRasterSource extends WidgetTilesetSource<WidgetRasterSourceProps> {}
|