@carto/api-client 0.4.2-alpha.0 → 0.4.2
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 +5 -1
- package/build/api/query.d.ts +1 -1
- package/build/api-client.cjs +48 -229
- package/build/api-client.cjs.map +1 -1
- package/build/api-client.modern.js +56 -232
- package/build/api-client.modern.js.map +1 -1
- package/build/models/model.d.ts +1 -7
- package/build/sources/types.d.ts +41 -36
- package/build/utils.d.ts +1 -1
- package/build/widget-sources/types.d.ts +1 -8
- package/build/widget-sources/widget-base-source.d.ts +1 -0
- package/package.json +1 -1
- package/src/api/query.ts +2 -1
- package/src/models/model.ts +24 -47
- package/src/sources/h3-query-source.ts +1 -7
- package/src/sources/h3-table-source.ts +1 -6
- package/src/sources/quadbin-query-source.ts +1 -6
- package/src/sources/quadbin-table-source.ts +1 -6
- package/src/sources/types.ts +45 -41
- package/src/sources/vector-query-source.ts +1 -4
- package/src/sources/vector-table-source.ts +1 -5
- package/src/utils.ts +1 -1
- package/src/widget-sources/types.ts +1 -9
- package/src/widget-sources/widget-base-source.ts +21 -190
- package/build/spatial-index.d.ts +0 -11
- package/src/spatial-index.ts +0 -119
package/build/models/model.d.ts
CHANGED
|
@@ -1,7 +1,6 @@
|
|
|
1
1
|
import { Filter, FilterLogicalOperator, MapType, QueryParameters, SpatialFilter } from '../types.js';
|
|
2
2
|
import { ModelRequestOptions } from './common.js';
|
|
3
3
|
import { ApiVersion } from '../constants.js';
|
|
4
|
-
import { SpatialDataType, SpatialFilterPolyfillMode } from '../sources/types.js';
|
|
5
4
|
/** @internalRemarks Source: @carto/react-api */
|
|
6
5
|
declare const AVAILABLE_MODELS: readonly ["category", "histogram", "formula", "pick", "timeseries", "range", "scatterplot", "table"];
|
|
7
6
|
export type Model = (typeof AVAILABLE_MODELS)[number];
|
|
@@ -15,14 +14,9 @@ export interface ModelSource {
|
|
|
15
14
|
data: string;
|
|
16
15
|
filters?: Record<string, Filter>;
|
|
17
16
|
filtersLogicalOperator?: FilterLogicalOperator;
|
|
17
|
+
geoColumn?: string;
|
|
18
18
|
spatialFilter?: SpatialFilter;
|
|
19
19
|
queryParameters?: QueryParameters;
|
|
20
|
-
spatialDataColumn?: string;
|
|
21
|
-
spatialDataType?: SpatialDataType;
|
|
22
|
-
spatialFiltersResolution?: number;
|
|
23
|
-
spatialFiltersMode?: SpatialFilterPolyfillMode;
|
|
24
|
-
/** original resolution of the spatial index data as stored in the DW */
|
|
25
|
-
dataResolution?: number;
|
|
26
20
|
}
|
|
27
21
|
/**
|
|
28
22
|
* Execute a SQL model request.
|
package/build/sources/types.d.ts
CHANGED
|
@@ -38,30 +38,6 @@ export type SourceOptionalOptions = {
|
|
|
38
38
|
* @default {@link DEFAULT_MAX_LENGTH_URL}
|
|
39
39
|
*/
|
|
40
40
|
maxLengthURL?: number;
|
|
41
|
-
/**
|
|
42
|
-
* The column name and the type of geospatial support.
|
|
43
|
-
*
|
|
44
|
-
* If not present, defaults to `'geom'` for generic queries, `'quadbin'` for Quadbin sources and `'h3'` for H3 sources.
|
|
45
|
-
*/
|
|
46
|
-
spatialDataColumn?: string;
|
|
47
|
-
/**
|
|
48
|
-
* The type of geospatial support. Defaults to `'geo'`.
|
|
49
|
-
*/
|
|
50
|
-
spatialDataType?: SpatialDataType;
|
|
51
|
-
/**
|
|
52
|
-
* Relative resolution of a tile. Higher values increase density and data size. At `tileResolution = 1`, tile geometry is
|
|
53
|
-
* quantized to a 1024x1024 grid. Increasing or decreasing the resolution will increase or decrease the dimensions of
|
|
54
|
-
* the quantization grid proportionately.
|
|
55
|
-
*
|
|
56
|
-
* Supported `tileResolution` values, with corresponding grid sizes:
|
|
57
|
-
*
|
|
58
|
-
* - 0.25: 256x256
|
|
59
|
-
* - 0.5: 512x512
|
|
60
|
-
* - 1: 1024x1024
|
|
61
|
-
* - 2: 2048x2048
|
|
62
|
-
* - 4: 4096x4096
|
|
63
|
-
*/
|
|
64
|
-
tileResolution?: TileResolution;
|
|
65
41
|
/**
|
|
66
42
|
* By default, local in-memory caching is enabled.
|
|
67
43
|
*/
|
|
@@ -97,10 +73,6 @@ export type AggregationOptions = {
|
|
|
97
73
|
* @default 6 for quadbin and 4 for h3 sources
|
|
98
74
|
*/
|
|
99
75
|
aggregationResLevel?: number;
|
|
100
|
-
/**
|
|
101
|
-
* Original resolution of the spatial index data as stored in the DW
|
|
102
|
-
*/
|
|
103
|
-
dataResolution?: number;
|
|
104
76
|
};
|
|
105
77
|
export type FilterOptions = {
|
|
106
78
|
/**
|
|
@@ -109,8 +81,28 @@ export type FilterOptions = {
|
|
|
109
81
|
filters?: Filters;
|
|
110
82
|
};
|
|
111
83
|
export type QuerySourceOptions = {
|
|
112
|
-
/**
|
|
84
|
+
/**
|
|
85
|
+
* The column name and the type of geospatial support.
|
|
86
|
+
*
|
|
87
|
+
* If not present, defaults to `'geom'` for generic queries, `'quadbin'` for Quadbin sources and `'h3'` for H3 sources.
|
|
88
|
+
*/
|
|
89
|
+
spatialDataColumn?: string;
|
|
90
|
+
/** SQL query. */
|
|
113
91
|
sqlQuery: string;
|
|
92
|
+
/**
|
|
93
|
+
* Relative resolution of a tile. Higher values increase density and data size. At `tileResolution = 1`, tile geometry is
|
|
94
|
+
* quantized to a 1024x1024 grid. Increasing or decreasing the resolution will increase or decrease the dimensions of
|
|
95
|
+
* the quantization grid proportionately.
|
|
96
|
+
*
|
|
97
|
+
* Supported `tileResolution` values, with corresponding grid sizes:
|
|
98
|
+
*
|
|
99
|
+
* - 0.25: 256x256
|
|
100
|
+
* - 0.5: 512x512
|
|
101
|
+
* - 1: 1024x1024
|
|
102
|
+
* - 2: 2048x2048
|
|
103
|
+
* - 4: 4096x4096
|
|
104
|
+
*/
|
|
105
|
+
tileResolution?: TileResolution;
|
|
114
106
|
/**
|
|
115
107
|
* Values for named or positional paramteres in the query.
|
|
116
108
|
*
|
|
@@ -142,6 +134,26 @@ export type TableSourceOptions = {
|
|
|
142
134
|
* Fully qualified name of table.
|
|
143
135
|
*/
|
|
144
136
|
tableName: string;
|
|
137
|
+
/**
|
|
138
|
+
* The column name and the type of geospatial support.
|
|
139
|
+
*
|
|
140
|
+
* If not present, defaults to `'geom'` for generic tables, `'quadbin'` for Quadbin sources and `'h3'` for H3 sources.
|
|
141
|
+
*/
|
|
142
|
+
spatialDataColumn?: string;
|
|
143
|
+
/**
|
|
144
|
+
* Relative resolution of a tile. Higher values increase density and data size. At `tileResolution = 1`, tile geometry is
|
|
145
|
+
* quantized to a 1024x1024 grid. Increasing or decreasing the resolution will increase or decrease the dimensions of
|
|
146
|
+
* the quantization grid proportionately.
|
|
147
|
+
*
|
|
148
|
+
* Supported `tileResolution` values, with corresponding grid sizes:
|
|
149
|
+
*
|
|
150
|
+
* - 0.25: 256x256
|
|
151
|
+
* - 0.5: 512x512
|
|
152
|
+
* - 1: 1024x1024
|
|
153
|
+
* - 2: 2048x2048
|
|
154
|
+
* - 4: 4096x4096
|
|
155
|
+
*/
|
|
156
|
+
tileResolution?: TileResolution;
|
|
145
157
|
};
|
|
146
158
|
export type TilesetSourceOptions = {
|
|
147
159
|
/**
|
|
@@ -158,13 +170,6 @@ export type ColumnsOption = {
|
|
|
158
170
|
columns?: string[];
|
|
159
171
|
};
|
|
160
172
|
export type SpatialDataType = 'geo' | 'h3' | 'quadbin';
|
|
161
|
-
/**
|
|
162
|
-
* Strategy used for covering spatial filter geometry with spatial indexes.
|
|
163
|
-
* See https://docs.carto.com/data-and-analysis/analytics-toolbox-for-bigquery/sql-reference/quadbin#quadbin_polyfill_mode
|
|
164
|
-
* or https://docs.carto.com/data-and-analysis/analytics-toolbox-for-bigquery/sql-reference/h3#h3_polyfill_mode for more information.
|
|
165
|
-
* @internalRemarks Source: cloud-native maps-api
|
|
166
|
-
* */
|
|
167
|
-
export type SpatialFilterPolyfillMode = 'center' | 'intersects' | 'contains';
|
|
168
173
|
export type TilejsonMapInstantiation = MapInstantiation & {
|
|
169
174
|
tilejson: {
|
|
170
175
|
url: string[];
|
package/build/utils.d.ts
CHANGED
|
@@ -14,7 +14,7 @@ type Row<T> = Record<string, T> | Record<string, T>[] | T[] | T;
|
|
|
14
14
|
*/
|
|
15
15
|
export declare function normalizeObjectKeys<T, R extends Row<T>>(el: R): R;
|
|
16
16
|
/** @internalRemarks Source: @carto/react-core */
|
|
17
|
-
export declare function assert(condition: unknown, message: string):
|
|
17
|
+
export declare function assert(condition: unknown, message: string): void;
|
|
18
18
|
/**
|
|
19
19
|
* @internalRemarks Source: @carto/react-core
|
|
20
20
|
* @internal
|
|
@@ -1,20 +1,13 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { TileResolution } from '../sources/types';
|
|
2
2
|
import { GroupDateType, SortColumnType, SortDirection, SpatialFilter } from '../types';
|
|
3
3
|
/******************************************************************************
|
|
4
4
|
* WIDGET API REQUESTS
|
|
5
5
|
*/
|
|
6
|
-
export interface ViewState {
|
|
7
|
-
zoom: number;
|
|
8
|
-
latitude: number;
|
|
9
|
-
longitude: number;
|
|
10
|
-
}
|
|
11
6
|
/** Common options for {@link WidgetBaseSource} requests. */
|
|
12
7
|
interface BaseRequestOptions {
|
|
13
8
|
spatialFilter?: SpatialFilter;
|
|
14
|
-
spatialFiltersMode?: SpatialFilterPolyfillMode;
|
|
15
9
|
abortController?: AbortController;
|
|
16
10
|
filterOwner?: string;
|
|
17
|
-
viewState?: ViewState;
|
|
18
11
|
}
|
|
19
12
|
/** Options for {@link WidgetBaseSource#getCategories}. */
|
|
20
13
|
export interface CategoryRequestOptions extends BaseRequestOptions {
|
|
@@ -5,6 +5,7 @@ import { SourceOptions } from '../sources/index.js';
|
|
|
5
5
|
import { ApiVersion } from '../constants.js';
|
|
6
6
|
export interface WidgetBaseSourceProps extends Omit<SourceOptions, 'filters'> {
|
|
7
7
|
apiVersion?: ApiVersion;
|
|
8
|
+
geoColumn?: string;
|
|
8
9
|
filters?: Record<string, Filter>;
|
|
9
10
|
filtersLogicalOperator?: FilterLogicalOperator;
|
|
10
11
|
}
|
package/package.json
CHANGED
package/src/api/query.ts
CHANGED
|
@@ -12,7 +12,8 @@ import {buildQueryUrl} from './endpoints';
|
|
|
12
12
|
import {requestWithParameters} from './request-with-parameters';
|
|
13
13
|
import {APIErrorContext} from './carto-api-error';
|
|
14
14
|
|
|
15
|
-
export type QueryOptions = SourceOptions &
|
|
15
|
+
export type QueryOptions = SourceOptions &
|
|
16
|
+
Omit<QuerySourceOptions, 'spatialDataColumn'>;
|
|
16
17
|
type UrlParameters = {q: string; queryParameters?: string};
|
|
17
18
|
|
|
18
19
|
export const query = async function (
|
package/src/models/model.ts
CHANGED
|
@@ -7,10 +7,9 @@ import {
|
|
|
7
7
|
SpatialFilter,
|
|
8
8
|
} from '../types.js';
|
|
9
9
|
import {$TODO} from '../types-internal.js';
|
|
10
|
-
import {assert
|
|
10
|
+
import {assert} from '../utils.js';
|
|
11
11
|
import {ModelRequestOptions, makeCall} from './common.js';
|
|
12
12
|
import {ApiVersion} from '../constants.js';
|
|
13
|
-
import {SpatialDataType, SpatialFilterPolyfillMode} from '../sources/types.js';
|
|
14
13
|
|
|
15
14
|
/** @internalRemarks Source: @carto/react-api */
|
|
16
15
|
const AVAILABLE_MODELS = [
|
|
@@ -36,14 +35,9 @@ export interface ModelSource {
|
|
|
36
35
|
data: string;
|
|
37
36
|
filters?: Record<string, Filter>;
|
|
38
37
|
filtersLogicalOperator?: FilterLogicalOperator;
|
|
38
|
+
geoColumn?: string;
|
|
39
39
|
spatialFilter?: SpatialFilter;
|
|
40
40
|
queryParameters?: QueryParameters;
|
|
41
|
-
spatialDataColumn?: string;
|
|
42
|
-
spatialDataType?: SpatialDataType;
|
|
43
|
-
spatialFiltersResolution?: number;
|
|
44
|
-
spatialFiltersMode?: SpatialFilterPolyfillMode;
|
|
45
|
-
/** original resolution of the spatial index data as stored in the DW */
|
|
46
|
-
dataResolution?: number;
|
|
47
41
|
}
|
|
48
42
|
|
|
49
43
|
const {V3} = ApiVersion;
|
|
@@ -85,51 +79,50 @@ export function executeModel(props: {
|
|
|
85
79
|
data,
|
|
86
80
|
filters,
|
|
87
81
|
filtersLogicalOperator = 'and',
|
|
88
|
-
|
|
89
|
-
spatialFiltersMode = 'intersects',
|
|
90
|
-
spatialFiltersResolution = 0,
|
|
82
|
+
geoColumn = DEFAULT_GEO_COLUMN,
|
|
91
83
|
} = source;
|
|
92
84
|
|
|
93
|
-
const
|
|
85
|
+
const queryParameters = source.queryParameters
|
|
86
|
+
? JSON.stringify(source.queryParameters)
|
|
87
|
+
: '';
|
|
88
|
+
|
|
89
|
+
const queryParams: Record<string, string> = {
|
|
94
90
|
type,
|
|
95
91
|
client: clientId,
|
|
96
92
|
source: data,
|
|
97
|
-
params,
|
|
98
|
-
queryParameters
|
|
99
|
-
filters,
|
|
93
|
+
params: JSON.stringify(params),
|
|
94
|
+
queryParameters,
|
|
95
|
+
filters: JSON.stringify(filters),
|
|
100
96
|
filtersLogicalOperator,
|
|
101
97
|
};
|
|
102
98
|
|
|
103
|
-
const spatialDataColumn = source.spatialDataColumn || DEFAULT_GEO_COLUMN;
|
|
104
|
-
|
|
105
99
|
// Picking Model API requires 'spatialDataColumn'.
|
|
106
100
|
if (model === 'pick') {
|
|
107
|
-
queryParams.spatialDataColumn =
|
|
101
|
+
queryParams.spatialDataColumn = geoColumn;
|
|
108
102
|
}
|
|
109
103
|
|
|
110
|
-
// API supports multiple filters, we apply it only to
|
|
104
|
+
// API supports multiple filters, we apply it only to geoColumn
|
|
111
105
|
const spatialFilters = source.spatialFilter
|
|
112
|
-
? {[
|
|
106
|
+
? {[geoColumn]: source.spatialFilter}
|
|
113
107
|
: undefined;
|
|
114
108
|
|
|
115
109
|
if (spatialFilters) {
|
|
116
|
-
queryParams.spatialFilters =
|
|
117
|
-
queryParams.spatialDataColumn = spatialDataColumn;
|
|
118
|
-
queryParams.spatialDataType = spatialDataType;
|
|
119
|
-
}
|
|
120
|
-
|
|
121
|
-
if (spatialDataType !== 'geo') {
|
|
122
|
-
if (spatialFiltersResolution > 0) {
|
|
123
|
-
queryParams.spatialFiltersResolution = spatialFiltersResolution;
|
|
124
|
-
}
|
|
125
|
-
queryParams.spatialFiltersMode = spatialFiltersMode;
|
|
110
|
+
queryParams.spatialFilters = JSON.stringify(spatialFilters);
|
|
126
111
|
}
|
|
127
112
|
|
|
128
113
|
const urlWithSearchParams =
|
|
129
|
-
url + '?' +
|
|
114
|
+
url + '?' + new URLSearchParams(queryParams).toString();
|
|
130
115
|
const isGet = urlWithSearchParams.length <= REQUEST_GET_MAX_URL_LENGTH;
|
|
131
116
|
if (isGet) {
|
|
132
117
|
url = urlWithSearchParams;
|
|
118
|
+
} else {
|
|
119
|
+
// undo the JSON.stringify, @TODO find a better pattern
|
|
120
|
+
queryParams.params = params as $TODO;
|
|
121
|
+
queryParams.filters = filters as $TODO;
|
|
122
|
+
queryParams.queryParameters = source.queryParameters as $TODO;
|
|
123
|
+
if (spatialFilters) {
|
|
124
|
+
queryParams.spatialFilters = spatialFilters as $TODO;
|
|
125
|
+
}
|
|
133
126
|
}
|
|
134
127
|
return makeCall({
|
|
135
128
|
url,
|
|
@@ -141,19 +134,3 @@ export function executeModel(props: {
|
|
|
141
134
|
},
|
|
142
135
|
});
|
|
143
136
|
}
|
|
144
|
-
|
|
145
|
-
function objectToURLSearchParams(object: Record<string, unknown>) {
|
|
146
|
-
const params = new URLSearchParams();
|
|
147
|
-
for (const key in object) {
|
|
148
|
-
if (isPureObject(object[key])) {
|
|
149
|
-
params.append(key, JSON.stringify(object[key]));
|
|
150
|
-
} else if (Array.isArray(object[key])) {
|
|
151
|
-
params.append(key, JSON.stringify(object[key]));
|
|
152
|
-
} else if (object[key] === null) {
|
|
153
|
-
params.append(key, 'null');
|
|
154
|
-
} else if (object[key] !== undefined) {
|
|
155
|
-
params.append(key, String(object[key]));
|
|
156
|
-
}
|
|
157
|
-
}
|
|
158
|
-
return params;
|
|
159
|
-
}
|
|
@@ -19,7 +19,6 @@ export type H3QuerySourceOptions = SourceOptions &
|
|
|
19
19
|
QuerySourceOptions &
|
|
20
20
|
AggregationOptions &
|
|
21
21
|
FilterOptions;
|
|
22
|
-
|
|
23
22
|
type UrlParameters = {
|
|
24
23
|
aggregationExp: string;
|
|
25
24
|
aggregationResLevel?: string;
|
|
@@ -60,12 +59,7 @@ export const h3QuerySource = async function (
|
|
|
60
59
|
return baseSource<UrlParameters>('query', options, urlParameters).then(
|
|
61
60
|
(result) => ({
|
|
62
61
|
...(result as TilejsonResult),
|
|
63
|
-
widgetSource: new WidgetQuerySource(
|
|
64
|
-
...options,
|
|
65
|
-
// NOTE: passing redundant spatialDataColumn here to apply the default value 'h3'
|
|
66
|
-
spatialDataColumn,
|
|
67
|
-
spatialDataType: 'h3',
|
|
68
|
-
}),
|
|
62
|
+
widgetSource: new WidgetQuerySource(options),
|
|
69
63
|
})
|
|
70
64
|
);
|
|
71
65
|
};
|
|
@@ -55,12 +55,7 @@ export const h3TableSource = async function (
|
|
|
55
55
|
return baseSource<UrlParameters>('table', options, urlParameters).then(
|
|
56
56
|
(result) => ({
|
|
57
57
|
...(result as TilejsonResult),
|
|
58
|
-
widgetSource: new WidgetTableSource(
|
|
59
|
-
...options,
|
|
60
|
-
// NOTE: passing redundant spatialDataColumn here to apply the default value 'h3'
|
|
61
|
-
spatialDataColumn,
|
|
62
|
-
spatialDataType: 'h3',
|
|
63
|
-
}),
|
|
58
|
+
widgetSource: new WidgetTableSource(options),
|
|
64
59
|
})
|
|
65
60
|
);
|
|
66
61
|
};
|
|
@@ -60,12 +60,7 @@ export const quadbinQuerySource = async function (
|
|
|
60
60
|
return baseSource<UrlParameters>('query', options, urlParameters).then(
|
|
61
61
|
(result) => ({
|
|
62
62
|
...(result as TilejsonResult),
|
|
63
|
-
widgetSource: new WidgetQuerySource(
|
|
64
|
-
...options,
|
|
65
|
-
// NOTE: passing redundant spatialDataColumn here to apply the default value 'quadbin'
|
|
66
|
-
spatialDataColumn,
|
|
67
|
-
spatialDataType: 'quadbin',
|
|
68
|
-
}),
|
|
63
|
+
widgetSource: new WidgetQuerySource(options),
|
|
69
64
|
})
|
|
70
65
|
);
|
|
71
66
|
};
|
|
@@ -56,12 +56,7 @@ export const quadbinTableSource = async function (
|
|
|
56
56
|
return baseSource<UrlParameters>('table', options, urlParameters).then(
|
|
57
57
|
(result) => ({
|
|
58
58
|
...(result as TilejsonResult),
|
|
59
|
-
widgetSource: new WidgetTableSource(
|
|
60
|
-
...options,
|
|
61
|
-
// NOTE: passing redundant spatialDataColumn here to apply the default value 'quadbin'
|
|
62
|
-
spatialDataColumn,
|
|
63
|
-
spatialDataType: 'quadbin',
|
|
64
|
-
}),
|
|
59
|
+
widgetSource: new WidgetTableSource(options),
|
|
65
60
|
})
|
|
66
61
|
);
|
|
67
62
|
};
|
package/src/sources/types.ts
CHANGED
|
@@ -48,33 +48,6 @@ export type SourceOptionalOptions = {
|
|
|
48
48
|
*/
|
|
49
49
|
maxLengthURL?: number;
|
|
50
50
|
|
|
51
|
-
/**
|
|
52
|
-
* The column name and the type of geospatial support.
|
|
53
|
-
*
|
|
54
|
-
* If not present, defaults to `'geom'` for generic queries, `'quadbin'` for Quadbin sources and `'h3'` for H3 sources.
|
|
55
|
-
*/
|
|
56
|
-
spatialDataColumn?: string;
|
|
57
|
-
|
|
58
|
-
/**
|
|
59
|
-
* The type of geospatial support. Defaults to `'geo'`.
|
|
60
|
-
*/
|
|
61
|
-
spatialDataType?: SpatialDataType;
|
|
62
|
-
|
|
63
|
-
/**
|
|
64
|
-
* Relative resolution of a tile. Higher values increase density and data size. At `tileResolution = 1`, tile geometry is
|
|
65
|
-
* quantized to a 1024x1024 grid. Increasing or decreasing the resolution will increase or decrease the dimensions of
|
|
66
|
-
* the quantization grid proportionately.
|
|
67
|
-
*
|
|
68
|
-
* Supported `tileResolution` values, with corresponding grid sizes:
|
|
69
|
-
*
|
|
70
|
-
* - 0.25: 256x256
|
|
71
|
-
* - 0.5: 512x512
|
|
72
|
-
* - 1: 1024x1024
|
|
73
|
-
* - 2: 2048x2048
|
|
74
|
-
* - 4: 4096x4096
|
|
75
|
-
*/
|
|
76
|
-
tileResolution?: TileResolution;
|
|
77
|
-
|
|
78
51
|
/**
|
|
79
52
|
* By default, local in-memory caching is enabled.
|
|
80
53
|
*/
|
|
@@ -116,11 +89,6 @@ export type AggregationOptions = {
|
|
|
116
89
|
* @default 6 for quadbin and 4 for h3 sources
|
|
117
90
|
*/
|
|
118
91
|
aggregationResLevel?: number;
|
|
119
|
-
|
|
120
|
-
/**
|
|
121
|
-
* Original resolution of the spatial index data as stored in the DW
|
|
122
|
-
*/
|
|
123
|
-
dataResolution?: number;
|
|
124
92
|
};
|
|
125
93
|
|
|
126
94
|
export type FilterOptions = {
|
|
@@ -131,9 +99,31 @@ export type FilterOptions = {
|
|
|
131
99
|
};
|
|
132
100
|
|
|
133
101
|
export type QuerySourceOptions = {
|
|
134
|
-
/**
|
|
102
|
+
/**
|
|
103
|
+
* The column name and the type of geospatial support.
|
|
104
|
+
*
|
|
105
|
+
* If not present, defaults to `'geom'` for generic queries, `'quadbin'` for Quadbin sources and `'h3'` for H3 sources.
|
|
106
|
+
*/
|
|
107
|
+
spatialDataColumn?: string;
|
|
108
|
+
|
|
109
|
+
/** SQL query. */
|
|
135
110
|
sqlQuery: string;
|
|
136
111
|
|
|
112
|
+
/**
|
|
113
|
+
* Relative resolution of a tile. Higher values increase density and data size. At `tileResolution = 1`, tile geometry is
|
|
114
|
+
* quantized to a 1024x1024 grid. Increasing or decreasing the resolution will increase or decrease the dimensions of
|
|
115
|
+
* the quantization grid proportionately.
|
|
116
|
+
*
|
|
117
|
+
* Supported `tileResolution` values, with corresponding grid sizes:
|
|
118
|
+
*
|
|
119
|
+
* - 0.25: 256x256
|
|
120
|
+
* - 0.5: 512x512
|
|
121
|
+
* - 1: 1024x1024
|
|
122
|
+
* - 2: 2048x2048
|
|
123
|
+
* - 4: 4096x4096
|
|
124
|
+
*/
|
|
125
|
+
tileResolution?: TileResolution;
|
|
126
|
+
|
|
137
127
|
/**
|
|
138
128
|
* Values for named or positional paramteres in the query.
|
|
139
129
|
*
|
|
@@ -166,6 +156,28 @@ export type TableSourceOptions = {
|
|
|
166
156
|
* Fully qualified name of table.
|
|
167
157
|
*/
|
|
168
158
|
tableName: string;
|
|
159
|
+
|
|
160
|
+
/**
|
|
161
|
+
* The column name and the type of geospatial support.
|
|
162
|
+
*
|
|
163
|
+
* If not present, defaults to `'geom'` for generic tables, `'quadbin'` for Quadbin sources and `'h3'` for H3 sources.
|
|
164
|
+
*/
|
|
165
|
+
spatialDataColumn?: string;
|
|
166
|
+
|
|
167
|
+
/**
|
|
168
|
+
* Relative resolution of a tile. Higher values increase density and data size. At `tileResolution = 1`, tile geometry is
|
|
169
|
+
* quantized to a 1024x1024 grid. Increasing or decreasing the resolution will increase or decrease the dimensions of
|
|
170
|
+
* the quantization grid proportionately.
|
|
171
|
+
*
|
|
172
|
+
* Supported `tileResolution` values, with corresponding grid sizes:
|
|
173
|
+
*
|
|
174
|
+
* - 0.25: 256x256
|
|
175
|
+
* - 0.5: 512x512
|
|
176
|
+
* - 1: 1024x1024
|
|
177
|
+
* - 2: 2048x2048
|
|
178
|
+
* - 4: 4096x4096
|
|
179
|
+
*/
|
|
180
|
+
tileResolution?: TileResolution;
|
|
169
181
|
};
|
|
170
182
|
|
|
171
183
|
export type TilesetSourceOptions = {
|
|
@@ -186,14 +198,6 @@ export type ColumnsOption = {
|
|
|
186
198
|
|
|
187
199
|
export type SpatialDataType = 'geo' | 'h3' | 'quadbin';
|
|
188
200
|
|
|
189
|
-
/**
|
|
190
|
-
* Strategy used for covering spatial filter geometry with spatial indexes.
|
|
191
|
-
* See https://docs.carto.com/data-and-analysis/analytics-toolbox-for-bigquery/sql-reference/quadbin#quadbin_polyfill_mode
|
|
192
|
-
* or https://docs.carto.com/data-and-analysis/analytics-toolbox-for-bigquery/sql-reference/h3#h3_polyfill_mode for more information.
|
|
193
|
-
* @internalRemarks Source: cloud-native maps-api
|
|
194
|
-
* */
|
|
195
|
-
export type SpatialFilterPolyfillMode = 'center' | 'intersects' | 'contains';
|
|
196
|
-
|
|
197
201
|
export type TilejsonMapInstantiation = MapInstantiation & {
|
|
198
202
|
tilejson: {url: string[]};
|
|
199
203
|
};
|
|
@@ -64,10 +64,7 @@ export const vectorQuerySource = async function (
|
|
|
64
64
|
return baseSource<UrlParameters>('query', options, urlParameters).then(
|
|
65
65
|
(result) => ({
|
|
66
66
|
...(result as TilejsonResult),
|
|
67
|
-
widgetSource: new WidgetQuerySource(
|
|
68
|
-
...options,
|
|
69
|
-
spatialDataType: 'geo',
|
|
70
|
-
}),
|
|
67
|
+
widgetSource: new WidgetQuerySource(options),
|
|
71
68
|
})
|
|
72
69
|
);
|
|
73
70
|
};
|
|
@@ -22,7 +22,6 @@ export type VectorTableSourceOptions = SourceOptions &
|
|
|
22
22
|
TableSourceOptions &
|
|
23
23
|
FilterOptions &
|
|
24
24
|
ColumnsOption;
|
|
25
|
-
|
|
26
25
|
type UrlParameters = {
|
|
27
26
|
columns?: string;
|
|
28
27
|
filters?: Record<string, unknown>;
|
|
@@ -59,10 +58,7 @@ export const vectorTableSource = async function (
|
|
|
59
58
|
return baseSource<UrlParameters>('table', options, urlParameters).then(
|
|
60
59
|
(result) => ({
|
|
61
60
|
...(result as TilejsonResult),
|
|
62
|
-
widgetSource: new WidgetTableSource(
|
|
63
|
-
...options,
|
|
64
|
-
spatialDataType: 'geo',
|
|
65
|
-
}),
|
|
61
|
+
widgetSource: new WidgetTableSource(options),
|
|
66
62
|
})
|
|
67
63
|
);
|
|
68
64
|
};
|
package/src/utils.ts
CHANGED
|
@@ -57,7 +57,7 @@ export function normalizeObjectKeys<T, R extends Row<T>>(el: R): R {
|
|
|
57
57
|
}
|
|
58
58
|
|
|
59
59
|
/** @internalRemarks Source: @carto/react-core */
|
|
60
|
-
export function assert(condition: unknown, message: string)
|
|
60
|
+
export function assert(condition: unknown, message: string) {
|
|
61
61
|
if (!condition) {
|
|
62
62
|
throw new Error(message);
|
|
63
63
|
}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import {TileResolution} from '../sources/types';
|
|
2
2
|
import {
|
|
3
3
|
GroupDateType,
|
|
4
4
|
SortColumnType,
|
|
@@ -10,19 +10,11 @@ import {
|
|
|
10
10
|
* WIDGET API REQUESTS
|
|
11
11
|
*/
|
|
12
12
|
|
|
13
|
-
export interface ViewState {
|
|
14
|
-
zoom: number;
|
|
15
|
-
latitude: number;
|
|
16
|
-
longitude: number;
|
|
17
|
-
}
|
|
18
|
-
|
|
19
13
|
/** Common options for {@link WidgetBaseSource} requests. */
|
|
20
14
|
interface BaseRequestOptions {
|
|
21
15
|
spatialFilter?: SpatialFilter;
|
|
22
|
-
spatialFiltersMode?: SpatialFilterPolyfillMode;
|
|
23
16
|
abortController?: AbortController;
|
|
24
17
|
filterOwner?: string;
|
|
25
|
-
viewState?: ViewState;
|
|
26
18
|
}
|
|
27
19
|
|
|
28
20
|
/** Options for {@link WidgetBaseSource#getCategories}. */
|