@deck.gl/carto 8.8.5 → 8.8.6
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/dist/dist.dev.js +1086 -1073
- package/dist/es5/api/index.js.map +1 -1
- package/dist/es5/api/maps-api-common.js.map +1 -1
- package/dist/es5/api/maps-v3-client.js +28 -18
- package/dist/es5/api/maps-v3-client.js.map +1 -1
- package/dist/es5/index.js.map +1 -1
- package/dist/es5/layers/carto-layer.js +6 -6
- package/dist/es5/layers/carto-layer.js.map +1 -1
- package/dist/esm/api/index.js.map +1 -1
- package/dist/esm/api/maps-api-common.js.map +1 -1
- package/dist/esm/api/maps-v3-client.js +23 -10
- package/dist/esm/api/maps-v3-client.js.map +1 -1
- package/dist/esm/index.js.map +1 -1
- package/dist/esm/layers/carto-layer.js +3 -4
- package/dist/esm/layers/carto-layer.js.map +1 -1
- package/dist.min.js +1 -1
- package/package.json +2 -2
- package/src/api/index.ts +1 -0
- package/src/api/maps-api-common.ts +8 -0
- package/src/api/maps-v3-client.ts +26 -10
- package/src/index.ts +1 -1
- package/src/layers/carto-layer.ts +12 -5
- package/typed/api/index.d.ts +1 -0
- package/typed/api/index.d.ts.map +1 -1
- package/typed/api/maps-api-common.d.ts +4 -0
- package/typed/api/maps-api-common.d.ts.map +1 -1
- package/typed/api/maps-v3-client.d.ts +4 -3
- package/typed/api/maps-v3-client.d.ts.map +1 -1
- package/typed/index.d.ts +1 -0
- package/typed/index.d.ts.map +1 -1
- package/typed/layers/carto-layer.d.ts +3 -1
- package/typed/layers/carto-layer.d.ts.map +1 -1
- package/typed/api/index.js +0 -3
- package/typed/api/layer-map.js +0 -264
- package/typed/api/maps-api-common.js +0 -50
- package/typed/api/maps-client.js +0 -125
- package/typed/api/maps-v3-client.js +0 -304
- package/typed/api/parseMap.js +0 -178
- package/typed/basemap.js +0 -9
- package/typed/config.js +0 -35
- package/typed/index.js +0 -10
- package/typed/layers/carto-layer.js +0 -173
- package/typed/layers/carto-tile-layer.js +0 -105
- package/typed/layers/h3-tile-layer.js +0 -47
- package/typed/layers/h3-tileset-2d.js +0 -85
- package/typed/layers/quadkey-tile-layer.js +0 -42
- package/typed/layers/quadkey-tileset-2d.js +0 -36
- package/typed/layers/schema/carto-tile.js +0 -161
- package/typed/layers/spatial-index-tile-layer.js +0 -40
- package/typed/style/color-bins-style.js +0 -12
- package/typed/style/color-categories-style.js +0 -16
- package/typed/style/color-continuous-style.js +0 -12
- package/typed/style/palette.js +0 -62
- package/typed/style/utils.js +0 -15
- package/typed/utils.js +0 -4
package/package.json
CHANGED
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
"name": "@deck.gl/carto",
|
|
3
3
|
"description": "CARTO official integration with Deck.gl. Build geospatial applications using CARTO and Deck.gl.",
|
|
4
4
|
"license": "MIT",
|
|
5
|
-
"version": "8.8.
|
|
5
|
+
"version": "8.8.6",
|
|
6
6
|
"publishConfig": {
|
|
7
7
|
"access": "public"
|
|
8
8
|
},
|
|
@@ -61,5 +61,5 @@
|
|
|
61
61
|
"@deck.gl/layers": "^8.0.0",
|
|
62
62
|
"@loaders.gl/core": "^3.0.0"
|
|
63
63
|
},
|
|
64
|
-
"gitHead": "
|
|
64
|
+
"gitHead": "a0e9fda8ed34ad91a6b25451c8df290ae025028f"
|
|
65
65
|
}
|
package/src/api/index.ts
CHANGED
|
@@ -1,3 +1,4 @@
|
|
|
1
1
|
export {FORMATS, TILE_FORMATS, MAP_TYPES, API_VERSIONS} from './maps-api-common';
|
|
2
|
+
export type {QueryParameters} from './maps-api-common';
|
|
2
3
|
export {getDataV2, CONNECTIONS} from './maps-client';
|
|
3
4
|
export {fetchLayerData, fetchMap, mapInstantiation} from './maps-v3-client';
|
|
@@ -77,3 +77,11 @@ type MapInstantiationFormats = Record<
|
|
|
77
77
|
export function encodeParameter(name: string, value: string | boolean | number): string {
|
|
78
78
|
return `${name}=${encodeURIComponent(value)}`;
|
|
79
79
|
}
|
|
80
|
+
|
|
81
|
+
export type QueryParameterValue = string | number | boolean | Array<QueryParameterValue> | object;
|
|
82
|
+
|
|
83
|
+
export type NamedQueryParameter = Record<string, QueryParameterValue>;
|
|
84
|
+
|
|
85
|
+
export type PositionalQueryParameter = QueryParameterValue[];
|
|
86
|
+
|
|
87
|
+
export type QueryParameters = NamedQueryParameter | PositionalQueryParameter;
|
|
@@ -17,6 +17,7 @@ import {
|
|
|
17
17
|
MapInstantiation,
|
|
18
18
|
MapType,
|
|
19
19
|
MAP_TYPES,
|
|
20
|
+
QueryParameters,
|
|
20
21
|
SchemaField,
|
|
21
22
|
TileFormat,
|
|
22
23
|
TILE_FORMATS
|
|
@@ -122,6 +123,7 @@ type FetchLayerDataParams = {
|
|
|
122
123
|
formatTiles?: TileFormat;
|
|
123
124
|
aggregationExp?: string;
|
|
124
125
|
aggregationResLevel?: number;
|
|
126
|
+
queryParameters?: QueryParameters;
|
|
125
127
|
};
|
|
126
128
|
|
|
127
129
|
/**
|
|
@@ -134,13 +136,18 @@ function getParameters({
|
|
|
134
136
|
columns,
|
|
135
137
|
clientId,
|
|
136
138
|
aggregationExp,
|
|
137
|
-
aggregationResLevel
|
|
139
|
+
aggregationResLevel,
|
|
140
|
+
queryParameters
|
|
138
141
|
}: Omit<FetchLayerDataParams, 'connection' | 'credentials'>) {
|
|
139
142
|
const parameters = [encodeParameter('client', clientId || DEFAULT_CLIENT)];
|
|
140
143
|
|
|
141
144
|
const sourceName = type === MAP_TYPES.QUERY ? 'q' : 'name';
|
|
142
145
|
parameters.push(encodeParameter(sourceName, source));
|
|
143
146
|
|
|
147
|
+
if (queryParameters) {
|
|
148
|
+
parameters.push(encodeParameter('queryParameters', JSON.stringify(queryParameters)));
|
|
149
|
+
}
|
|
150
|
+
|
|
144
151
|
if (geoColumn) {
|
|
145
152
|
parameters.push(encodeParameter('geo_column', geoColumn));
|
|
146
153
|
}
|
|
@@ -174,7 +181,8 @@ export async function mapInstantiation({
|
|
|
174
181
|
columns,
|
|
175
182
|
clientId,
|
|
176
183
|
aggregationExp,
|
|
177
|
-
aggregationResLevel
|
|
184
|
+
aggregationResLevel,
|
|
185
|
+
queryParameters
|
|
178
186
|
}: FetchLayerDataParams): Promise<MapInstantiation> {
|
|
179
187
|
const baseUrl = `${credentials.mapsUrl}/${connection}/${type}`;
|
|
180
188
|
const url = `${baseUrl}?${getParameters({
|
|
@@ -184,7 +192,8 @@ export async function mapInstantiation({
|
|
|
184
192
|
columns,
|
|
185
193
|
clientId,
|
|
186
194
|
aggregationResLevel,
|
|
187
|
-
aggregationExp
|
|
195
|
+
aggregationExp,
|
|
196
|
+
queryParameters
|
|
188
197
|
})}`;
|
|
189
198
|
const {accessToken} = credentials;
|
|
190
199
|
|
|
@@ -192,7 +201,8 @@ export async function mapInstantiation({
|
|
|
192
201
|
// need to be a POST request
|
|
193
202
|
const body = JSON.stringify({
|
|
194
203
|
q: source,
|
|
195
|
-
client: clientId || DEFAULT_CLIENT
|
|
204
|
+
client: clientId || DEFAULT_CLIENT,
|
|
205
|
+
queryParameters
|
|
196
206
|
});
|
|
197
207
|
return await requestJson({method: 'POST', url: baseUrl, accessToken, body});
|
|
198
208
|
}
|
|
@@ -268,7 +278,8 @@ export async function fetchLayerData({
|
|
|
268
278
|
formatTiles,
|
|
269
279
|
clientId,
|
|
270
280
|
aggregationExp,
|
|
271
|
-
aggregationResLevel
|
|
281
|
+
aggregationResLevel,
|
|
282
|
+
queryParameters
|
|
272
283
|
}: FetchLayerDataParams): Promise<FetchLayerDataResult> {
|
|
273
284
|
// Internally we split data fetching into two parts to allow us to
|
|
274
285
|
// conditionally fetch the actual data, depending on the metadata state
|
|
@@ -283,7 +294,8 @@ export async function fetchLayerData({
|
|
|
283
294
|
formatTiles,
|
|
284
295
|
clientId,
|
|
285
296
|
aggregationExp,
|
|
286
|
-
aggregationResLevel
|
|
297
|
+
aggregationResLevel,
|
|
298
|
+
queryParameters
|
|
287
299
|
});
|
|
288
300
|
|
|
289
301
|
const data = await requestData({url, format: mapFormat, accessToken});
|
|
@@ -302,7 +314,8 @@ async function _fetchDataUrl({
|
|
|
302
314
|
formatTiles,
|
|
303
315
|
clientId,
|
|
304
316
|
aggregationExp,
|
|
305
|
-
aggregationResLevel
|
|
317
|
+
aggregationResLevel,
|
|
318
|
+
queryParameters
|
|
306
319
|
}: FetchLayerDataParams) {
|
|
307
320
|
const defaultCredentials = getDefaultCredentials();
|
|
308
321
|
// Only pick up default credentials if they have been defined for
|
|
@@ -335,7 +348,8 @@ async function _fetchDataUrl({
|
|
|
335
348
|
columns,
|
|
336
349
|
clientId,
|
|
337
350
|
aggregationExp,
|
|
338
|
-
aggregationResLevel
|
|
351
|
+
aggregationResLevel,
|
|
352
|
+
queryParameters
|
|
339
353
|
});
|
|
340
354
|
let url: string | null = null;
|
|
341
355
|
let mapFormat: Format | undefined;
|
|
@@ -374,7 +388,8 @@ async function _fetchMapDataset(
|
|
|
374
388
|
dataset,
|
|
375
389
|
accessToken: string,
|
|
376
390
|
credentials: CloudNativeCredentials,
|
|
377
|
-
clientId?: string
|
|
391
|
+
clientId?: string,
|
|
392
|
+
queryParameters?: QueryParameters
|
|
378
393
|
) {
|
|
379
394
|
const {
|
|
380
395
|
aggregationExp,
|
|
@@ -397,7 +412,8 @@ async function _fetchMapDataset(
|
|
|
397
412
|
format,
|
|
398
413
|
geoColumn,
|
|
399
414
|
source,
|
|
400
|
-
type
|
|
415
|
+
type,
|
|
416
|
+
queryParameters
|
|
401
417
|
});
|
|
402
418
|
|
|
403
419
|
// Extract the last time the data changed
|
package/src/index.ts
CHANGED
|
@@ -16,7 +16,8 @@ import {
|
|
|
16
16
|
GEO_COLUMN_SUPPORT,
|
|
17
17
|
MapType,
|
|
18
18
|
MAP_TYPES,
|
|
19
|
-
TileFormat
|
|
19
|
+
TileFormat,
|
|
20
|
+
QueryParameters
|
|
20
21
|
} from '../api/maps-api-common';
|
|
21
22
|
import {
|
|
22
23
|
ClassicCredentials,
|
|
@@ -64,7 +65,10 @@ const defaultProps = {
|
|
|
64
65
|
aggregationExp: null,
|
|
65
66
|
|
|
66
67
|
// (Number, optional): aggregation resolution level. Only used for spatial index datasets, defaults to 6 for quadbins, 4 for h3
|
|
67
|
-
aggregationResLevel: null
|
|
68
|
+
aggregationResLevel: null,
|
|
69
|
+
|
|
70
|
+
// (QueryParameters, optional): query parameters to be sent to the server.
|
|
71
|
+
queryParameters: null
|
|
68
72
|
};
|
|
69
73
|
|
|
70
74
|
/** All properties supported by CartoLayer. */
|
|
@@ -149,6 +153,9 @@ type _CartoLayerProps = {
|
|
|
149
153
|
|
|
150
154
|
/** Aggregation resolution level. Only used for spatial index datasets, defaults to 6 for quadbins, 4 for h3. **/
|
|
151
155
|
aggregationResLevel?: number;
|
|
156
|
+
|
|
157
|
+
/** Query parameters to be sent to the server. **/
|
|
158
|
+
queryParameters?: QueryParameters;
|
|
152
159
|
};
|
|
153
160
|
|
|
154
161
|
export default class CartoLayer<ExtraProps = {}> extends CompositeLayer<
|
|
@@ -218,7 +225,8 @@ export default class CartoLayer<ExtraProps = {}> extends CompositeLayer<
|
|
|
218
225
|
props.formatTiles !== oldProps.formatTiles ||
|
|
219
226
|
props.type !== oldProps.type ||
|
|
220
227
|
JSON.stringify(props.columns) !== JSON.stringify(oldProps.columns) ||
|
|
221
|
-
JSON.stringify(props.credentials) !== JSON.stringify(oldProps.credentials)
|
|
228
|
+
JSON.stringify(props.credentials) !== JSON.stringify(oldProps.credentials) ||
|
|
229
|
+
JSON.stringify(props.queryParameters) !== JSON.stringify(oldProps.queryParameters);
|
|
222
230
|
|
|
223
231
|
if (shouldUpdateData) {
|
|
224
232
|
this.setState({data: null, apiVersion: null});
|
|
@@ -229,7 +237,7 @@ export default class CartoLayer<ExtraProps = {}> extends CompositeLayer<
|
|
|
229
237
|
|
|
230
238
|
async _updateData(): Promise<void> {
|
|
231
239
|
try {
|
|
232
|
-
const {type, data: source,
|
|
240
|
+
const {type, data: source, credentials, connection, ...rest} = this.props;
|
|
233
241
|
const localConfig = {...getDefaultCredentials(), ...credentials};
|
|
234
242
|
const {apiVersion} = localConfig;
|
|
235
243
|
|
|
@@ -242,7 +250,6 @@ export default class CartoLayer<ExtraProps = {}> extends CompositeLayer<
|
|
|
242
250
|
result = await fetchLayerData({
|
|
243
251
|
type,
|
|
244
252
|
source,
|
|
245
|
-
clientId,
|
|
246
253
|
credentials: credentials as CloudNativeCredentials,
|
|
247
254
|
connection,
|
|
248
255
|
...rest,
|
package/typed/api/index.d.ts
CHANGED
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
export { FORMATS, TILE_FORMATS, MAP_TYPES, API_VERSIONS } from './maps-api-common';
|
|
2
|
+
export type { QueryParameters } from './maps-api-common';
|
|
2
3
|
export { getDataV2, CONNECTIONS } from './maps-client';
|
|
3
4
|
export { fetchLayerData, fetchMap, mapInstantiation } from './maps-v3-client';
|
|
4
5
|
//# sourceMappingURL=index.d.ts.map
|
package/typed/api/index.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/api/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAC,OAAO,EAAE,YAAY,EAAE,SAAS,EAAE,YAAY,EAAC,MAAM,mBAAmB,CAAC;AACjF,OAAO,EAAC,SAAS,EAAE,WAAW,EAAC,MAAM,eAAe,CAAC;AACrD,OAAO,EAAC,cAAc,EAAE,QAAQ,EAAE,gBAAgB,EAAC,MAAM,kBAAkB,CAAC"}
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/api/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAC,OAAO,EAAE,YAAY,EAAE,SAAS,EAAE,YAAY,EAAC,MAAM,mBAAmB,CAAC;AACjF,YAAY,EAAC,eAAe,EAAC,MAAM,mBAAmB,CAAC;AACvD,OAAO,EAAC,SAAS,EAAE,WAAW,EAAC,MAAM,eAAe,CAAC;AACrD,OAAO,EAAC,cAAc,EAAE,QAAQ,EAAE,gBAAgB,EAAC,MAAM,kBAAkB,CAAC"}
|
|
@@ -61,5 +61,9 @@ declare type MapInstantiationFormats = Record<Format, {
|
|
|
61
61
|
* Simple encode parameter
|
|
62
62
|
*/
|
|
63
63
|
export declare function encodeParameter(name: string, value: string | boolean | number): string;
|
|
64
|
+
export declare type QueryParameterValue = string | number | boolean | Array<QueryParameterValue> | object;
|
|
65
|
+
export declare type NamedQueryParameter = Record<string, QueryParameterValue>;
|
|
66
|
+
export declare type PositionalQueryParameter = QueryParameterValue[];
|
|
67
|
+
export declare type QueryParameters = NamedQueryParameter | PositionalQueryParameter;
|
|
64
68
|
export {};
|
|
65
69
|
//# sourceMappingURL=maps-api-common.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"maps-api-common.d.ts","sourceRoot":"","sources":["../../src/api/maps-api-common.ts"],"names":[],"mappings":"AAAA,eAAO,MAAM,6BAA6B,WAAW,CAAC;AACtD,eAAO,MAAM,+BAA+B,aAAa,CAAC;AAE1D,oBAAY,QAAQ,CAAC,CAAC,SAAS,EAAE,IAAI,CAAC,CAAC,MAAM,CAAC,CAAC,CAAC;AAChD,eAAO,MAAM,YAAY;;;;CAIf,CAAC;AACX,oBAAY,UAAU,GAAG,QAAQ,CAAC,OAAO,YAAY,CAAC,CAAC;AAEvD,eAAO,MAAM,uBAAuB;;;CAG1B,CAAC;AAEX,eAAO,MAAM,SAAS;;;;CAIZ,CAAC;AACX,oBAAY,OAAO,GAAG,QAAQ,CAAC,OAAO,SAAS,CAAC,CAAC;AACjD,eAAO,MAAM,eAAe,EAAE,OAAO,EAAsB,CAAC;AAC5D,eAAO,MAAM,kBAAkB,EAAE,OAAO,EAAuC,CAAC;AAGhF,eAAO,MAAM,OAAO;;;;;CAKV,CAAC;AACX,oBAAY,MAAM,GAAG,QAAQ,CAAC,OAAO,OAAO,CAAC,CAAC;AAG9C,eAAO,MAAM,YAAY;;;;;CAKf,CAAC;AACX,oBAAY,UAAU,GAAG,QAAQ,CAAC,OAAO,YAAY,CAAC,CAAC;AAEvD,oBAAY,eAAe;IACzB,MAAM,WAAW;IACjB,MAAM,WAAW;IACjB,MAAM,WAAW;IACjB,QAAQ,aAAa;IACrB,SAAS,cAAc;IACvB,MAAM,WAAW;IACjB,OAAO,YAAY;IACnB,OAAO,YAAY;IACnB,OAAO,YAAY;CACpB;AACD,MAAM,WAAW,WAAW;IAC1B,IAAI,EAAE,MAAM,CAAC;IACb,IAAI,EAAE,eAAe,CAAC;CACvB;AAED,MAAM,WAAW,gBAAiB,SAAQ,uBAAuB;IAC/D,KAAK,EAAE,MAAM,CAAC;IACd,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,MAAM,EAAE,WAAW,EAAE,CAAC;CACvB;AAED,aAAK,uBAAuB,GAAG,MAAM,CACnC,MAAM,EACN;IACE,GAAG,EAAE,MAAM,EAAE,CAAC;IACd,KAAK,CAAC,EAAE,GAAG,CAAC;CACb,CACF,CAAC;AAEF;;GAEG;AACH,wBAAgB,eAAe,CAAC,IAAI,EAAE,MAAM,EAAE,KAAK,EAAE,MAAM,GAAG,OAAO,GAAG,MAAM,GAAG,MAAM,CAEtF"}
|
|
1
|
+
{"version":3,"file":"maps-api-common.d.ts","sourceRoot":"","sources":["../../src/api/maps-api-common.ts"],"names":[],"mappings":"AAAA,eAAO,MAAM,6BAA6B,WAAW,CAAC;AACtD,eAAO,MAAM,+BAA+B,aAAa,CAAC;AAE1D,oBAAY,QAAQ,CAAC,CAAC,SAAS,EAAE,IAAI,CAAC,CAAC,MAAM,CAAC,CAAC,CAAC;AAChD,eAAO,MAAM,YAAY;;;;CAIf,CAAC;AACX,oBAAY,UAAU,GAAG,QAAQ,CAAC,OAAO,YAAY,CAAC,CAAC;AAEvD,eAAO,MAAM,uBAAuB;;;CAG1B,CAAC;AAEX,eAAO,MAAM,SAAS;;;;CAIZ,CAAC;AACX,oBAAY,OAAO,GAAG,QAAQ,CAAC,OAAO,SAAS,CAAC,CAAC;AACjD,eAAO,MAAM,eAAe,EAAE,OAAO,EAAsB,CAAC;AAC5D,eAAO,MAAM,kBAAkB,EAAE,OAAO,EAAuC,CAAC;AAGhF,eAAO,MAAM,OAAO;;;;;CAKV,CAAC;AACX,oBAAY,MAAM,GAAG,QAAQ,CAAC,OAAO,OAAO,CAAC,CAAC;AAG9C,eAAO,MAAM,YAAY;;;;;CAKf,CAAC;AACX,oBAAY,UAAU,GAAG,QAAQ,CAAC,OAAO,YAAY,CAAC,CAAC;AAEvD,oBAAY,eAAe;IACzB,MAAM,WAAW;IACjB,MAAM,WAAW;IACjB,MAAM,WAAW;IACjB,QAAQ,aAAa;IACrB,SAAS,cAAc;IACvB,MAAM,WAAW;IACjB,OAAO,YAAY;IACnB,OAAO,YAAY;IACnB,OAAO,YAAY;CACpB;AACD,MAAM,WAAW,WAAW;IAC1B,IAAI,EAAE,MAAM,CAAC;IACb,IAAI,EAAE,eAAe,CAAC;CACvB;AAED,MAAM,WAAW,gBAAiB,SAAQ,uBAAuB;IAC/D,KAAK,EAAE,MAAM,CAAC;IACd,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,MAAM,EAAE,WAAW,EAAE,CAAC;CACvB;AAED,aAAK,uBAAuB,GAAG,MAAM,CACnC,MAAM,EACN;IACE,GAAG,EAAE,MAAM,EAAE,CAAC;IACd,KAAK,CAAC,EAAE,GAAG,CAAC;CACb,CACF,CAAC;AAEF;;GAEG;AACH,wBAAgB,eAAe,CAAC,IAAI,EAAE,MAAM,EAAE,KAAK,EAAE,MAAM,GAAG,OAAO,GAAG,MAAM,GAAG,MAAM,CAEtF;AAED,oBAAY,mBAAmB,GAAG,MAAM,GAAG,MAAM,GAAG,OAAO,GAAG,KAAK,CAAC,mBAAmB,CAAC,GAAG,MAAM,CAAC;AAElG,oBAAY,mBAAmB,GAAG,MAAM,CAAC,MAAM,EAAE,mBAAmB,CAAC,CAAC;AAEtE,oBAAY,wBAAwB,GAAG,mBAAmB,EAAE,CAAC;AAE7D,oBAAY,eAAe,GAAG,mBAAmB,GAAG,wBAAwB,CAAC"}
|
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
* Maps API Client for Carto 3
|
|
3
3
|
*/
|
|
4
4
|
import { CloudNativeCredentials } from '../config';
|
|
5
|
-
import { Format, MapInstantiation, MapType, SchemaField, TileFormat } from './maps-api-common';
|
|
5
|
+
import { Format, MapInstantiation, MapType, QueryParameters, SchemaField, TileFormat } from './maps-api-common';
|
|
6
6
|
declare type FetchLayerDataParams = {
|
|
7
7
|
type: MapType;
|
|
8
8
|
source: string;
|
|
@@ -15,14 +15,15 @@ declare type FetchLayerDataParams = {
|
|
|
15
15
|
formatTiles?: TileFormat;
|
|
16
16
|
aggregationExp?: string;
|
|
17
17
|
aggregationResLevel?: number;
|
|
18
|
+
queryParameters?: QueryParameters;
|
|
18
19
|
};
|
|
19
|
-
export declare function mapInstantiation({ type, source, connection, credentials, geoColumn, columns, clientId, aggregationExp, aggregationResLevel }: FetchLayerDataParams): Promise<MapInstantiation>;
|
|
20
|
+
export declare function mapInstantiation({ type, source, connection, credentials, geoColumn, columns, clientId, aggregationExp, aggregationResLevel, queryParameters }: FetchLayerDataParams): Promise<MapInstantiation>;
|
|
20
21
|
export interface FetchLayerDataResult {
|
|
21
22
|
data: any;
|
|
22
23
|
format?: Format;
|
|
23
24
|
schema: SchemaField[];
|
|
24
25
|
}
|
|
25
|
-
export declare function fetchLayerData({ type, source, connection, credentials, geoColumn, columns, format, formatTiles, clientId, aggregationExp, aggregationResLevel }: FetchLayerDataParams): Promise<FetchLayerDataResult>;
|
|
26
|
+
export declare function fetchLayerData({ type, source, connection, credentials, geoColumn, columns, format, formatTiles, clientId, aggregationExp, aggregationResLevel, queryParameters }: FetchLayerDataParams): Promise<FetchLayerDataResult>;
|
|
26
27
|
export declare function fetchMap({ cartoMapId, clientId, credentials, autoRefresh, onNewData }: {
|
|
27
28
|
cartoMapId: string;
|
|
28
29
|
clientId: string;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"maps-v3-client.d.ts","sourceRoot":"","sources":["../../src/api/maps-v3-client.ts"],"names":[],"mappings":"AAAA;;GAEG;AACH,OAAO,EAIL,sBAAsB,EACvB,MAAM,WAAW,CAAC;AACnB,OAAO,EAIL,MAAM,EAGN,gBAAgB,EAChB,OAAO,EAEP,WAAW,EACX,UAAU,EAEX,MAAM,mBAAmB,CAAC;AA0F3B,aAAK,oBAAoB,GAAG;IAC1B,IAAI,EAAE,OAAO,CAAC;IACd,MAAM,EAAE,MAAM,CAAC;IACf,UAAU,EAAE,MAAM,CAAC;IACnB,WAAW,EAAE,sBAAsB,CAAC;IACpC,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,OAAO,CAAC,EAAE,MAAM,EAAE,CAAC;IACnB,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB,WAAW,CAAC,EAAE,UAAU,CAAC;IACzB,cAAc,CAAC,EAAE,MAAM,CAAC;IACxB,mBAAmB,CAAC,EAAE,MAAM,CAAC;
|
|
1
|
+
{"version":3,"file":"maps-v3-client.d.ts","sourceRoot":"","sources":["../../src/api/maps-v3-client.ts"],"names":[],"mappings":"AAAA;;GAEG;AACH,OAAO,EAIL,sBAAsB,EACvB,MAAM,WAAW,CAAC;AACnB,OAAO,EAIL,MAAM,EAGN,gBAAgB,EAChB,OAAO,EAEP,eAAe,EACf,WAAW,EACX,UAAU,EAEX,MAAM,mBAAmB,CAAC;AA0F3B,aAAK,oBAAoB,GAAG;IAC1B,IAAI,EAAE,OAAO,CAAC;IACd,MAAM,EAAE,MAAM,CAAC;IACf,UAAU,EAAE,MAAM,CAAC;IACnB,WAAW,EAAE,sBAAsB,CAAC;IACpC,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,OAAO,CAAC,EAAE,MAAM,EAAE,CAAC;IACnB,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB,WAAW,CAAC,EAAE,UAAU,CAAC;IACzB,cAAc,CAAC,EAAE,MAAM,CAAC;IACxB,mBAAmB,CAAC,EAAE,MAAM,CAAC;IAC7B,eAAe,CAAC,EAAE,eAAe,CAAC;CACnC,CAAC;AAgDF,wBAAsB,gBAAgB,CAAC,EACrC,IAAI,EACJ,MAAM,EACN,UAAU,EACV,WAAW,EACX,SAAS,EACT,OAAO,EACP,QAAQ,EACR,cAAc,EACd,mBAAmB,EACnB,eAAe,EAChB,EAAE,oBAAoB,GAAG,OAAO,CAAC,gBAAgB,CAAC,CAyBlD;AAsDD,MAAM,WAAW,oBAAoB;IACnC,IAAI,EAAE,GAAG,CAAC;IACV,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB,MAAM,EAAE,WAAW,EAAE,CAAC;CACvB;AACD,wBAAsB,cAAc,CAAC,EACnC,IAAI,EACJ,MAAM,EACN,UAAU,EACV,WAAW,EACX,SAAS,EACT,OAAO,EACP,MAAM,EACN,WAAW,EACX,QAAQ,EACR,cAAc,EACd,mBAAmB,EACnB,eAAe,EAChB,EAAE,oBAAoB,GAAG,OAAO,CAAC,oBAAoB,CAAC,CAqBtD;AAsMD,wBAAsB,QAAQ,CAAC,EAC7B,UAAU,EACV,QAAQ,EACR,WAAW,EACX,WAAW,EACX,SAAS,EACV,EAAE;IACD,UAAU,EAAE,MAAM,CAAC;IACnB,QAAQ,EAAE,MAAM,CAAC;IACjB,WAAW,CAAC,EAAE,sBAAsB,CAAC;IACrC,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,SAAS,CAAC,EAAE,CAAC,GAAG,EAAE,GAAG,KAAK,IAAI,CAAC;CAChC;4BA8B6B,IAAI;;;;;;;;;GAiCjC"}
|
package/typed/index.d.ts
CHANGED
|
@@ -9,5 +9,6 @@ export { default as colorBins } from './style/color-bins-style';
|
|
|
9
9
|
export { default as colorCategories } from './style/color-categories-style';
|
|
10
10
|
export { default as colorContinuous } from './style/color-continuous-style';
|
|
11
11
|
export { FORMATS, TILE_FORMATS, MAP_TYPES, API_VERSIONS, fetchLayerData, fetchMap, getDataV2 as _getDataV2, mapInstantiation as _mapInstantiation } from './api';
|
|
12
|
+
export type { QueryParameters } from './api';
|
|
12
13
|
export type { CartoLayerProps } from './layers/carto-layer';
|
|
13
14
|
//# sourceMappingURL=index.d.ts.map
|
package/typed/index.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAC,qBAAqB,EAAE,qBAAqB,EAAC,MAAM,UAAU,CAAC;AACtE,OAAO,EAAC,OAAO,IAAI,UAAU,EAAC,MAAM,sBAAsB,CAAC;AAC3D,OAAO,EAAC,OAAO,IAAI,eAAe,EAAC,MAAM,2BAA2B,CAAC;AACrE,OAAO,EAAC,OAAO,IAAI,YAAY,EAAC,MAAM,wBAAwB,CAAC;AAC/D,OAAO,EAAC,OAAO,IAAI,iBAAiB,EAAC,MAAM,6BAA6B,CAAC;AACzE,OAAO,EACL,aAAa,IAAI,cAAc,EAC/B,aAAa,IAAI,cAAc,EAC/B,WAAW,IAAI,YAAY,EAC5B,MAAM,wBAAwB,CAAC;AAChC,OAAO,EAAC,OAAO,IAAI,OAAO,EAAC,MAAM,WAAW,CAAC;AAC7C,OAAO,EAAC,OAAO,IAAI,SAAS,EAAC,MAAM,0BAA0B,CAAC;AAC9D,OAAO,EAAC,OAAO,IAAI,eAAe,EAAC,MAAM,gCAAgC,CAAC;AAC1E,OAAO,EAAC,OAAO,IAAI,eAAe,EAAC,MAAM,gCAAgC,CAAC;AAC1E,OAAO,EACL,OAAO,EACP,YAAY,EACZ,SAAS,EACT,YAAY,EACZ,cAAc,EACd,QAAQ,EACR,SAAS,IAAI,UAAU,EACvB,gBAAgB,IAAI,iBAAiB,EACtC,MAAM,OAAO,CAAC;
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAC,qBAAqB,EAAE,qBAAqB,EAAC,MAAM,UAAU,CAAC;AACtE,OAAO,EAAC,OAAO,IAAI,UAAU,EAAC,MAAM,sBAAsB,CAAC;AAC3D,OAAO,EAAC,OAAO,IAAI,eAAe,EAAC,MAAM,2BAA2B,CAAC;AACrE,OAAO,EAAC,OAAO,IAAI,YAAY,EAAC,MAAM,wBAAwB,CAAC;AAC/D,OAAO,EAAC,OAAO,IAAI,iBAAiB,EAAC,MAAM,6BAA6B,CAAC;AACzE,OAAO,EACL,aAAa,IAAI,cAAc,EAC/B,aAAa,IAAI,cAAc,EAC/B,WAAW,IAAI,YAAY,EAC5B,MAAM,wBAAwB,CAAC;AAChC,OAAO,EAAC,OAAO,IAAI,OAAO,EAAC,MAAM,WAAW,CAAC;AAC7C,OAAO,EAAC,OAAO,IAAI,SAAS,EAAC,MAAM,0BAA0B,CAAC;AAC9D,OAAO,EAAC,OAAO,IAAI,eAAe,EAAC,MAAM,gCAAgC,CAAC;AAC1E,OAAO,EAAC,OAAO,IAAI,eAAe,EAAC,MAAM,gCAAgC,CAAC;AAC1E,OAAO,EACL,OAAO,EACP,YAAY,EACZ,SAAS,EACT,YAAY,EACZ,cAAc,EACd,QAAQ,EACR,SAAS,IAAI,UAAU,EACvB,gBAAgB,IAAI,iBAAiB,EACtC,MAAM,OAAO,CAAC;AACf,YAAY,EAAC,eAAe,EAAC,MAAM,OAAO,CAAC;AAC3C,YAAY,EAAC,eAAe,EAAC,MAAM,sBAAsB,CAAC"}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { CompositeLayer, CompositeLayerProps, Layer, LayerProps, UpdateParameters } from '@deck.gl/core/typed';
|
|
2
|
-
import { MapType, TileFormat } from '../api/maps-api-common';
|
|
2
|
+
import { MapType, TileFormat, QueryParameters } from '../api/maps-api-common';
|
|
3
3
|
import { Credentials } from '../config';
|
|
4
4
|
/** All properties supported by CartoLayer. */
|
|
5
5
|
export declare type CartoLayerProps<DataT = any> = _CartoLayerProps & CompositeLayerProps<DataT>;
|
|
@@ -71,6 +71,8 @@ declare type _CartoLayerProps = {
|
|
|
71
71
|
aggregationExp?: string;
|
|
72
72
|
/** Aggregation resolution level. Only used for spatial index datasets, defaults to 6 for quadbins, 4 for h3. **/
|
|
73
73
|
aggregationResLevel?: number;
|
|
74
|
+
/** Query parameters to be sent to the server. **/
|
|
75
|
+
queryParameters?: QueryParameters;
|
|
74
76
|
};
|
|
75
77
|
export default class CartoLayer<ExtraProps = {}> extends CompositeLayer<Required<_CartoLayerProps> & ExtraProps> {
|
|
76
78
|
static layerName: string;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"carto-layer.d.ts","sourceRoot":"","sources":["../../src/layers/carto-layer.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,cAAc,EACd,mBAAmB,EACnB,KAAK,EACL,UAAU,EAEV,gBAAgB,EACjB,MAAM,eAAe,CAAC;AAKvB,OAAO,EAIL,OAAO,EAEP,UAAU,
|
|
1
|
+
{"version":3,"file":"carto-layer.d.ts","sourceRoot":"","sources":["../../src/layers/carto-layer.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,cAAc,EACd,mBAAmB,EACnB,KAAK,EACL,UAAU,EAEV,gBAAgB,EACjB,MAAM,eAAe,CAAC;AAKvB,OAAO,EAIL,OAAO,EAEP,UAAU,EACV,eAAe,EAChB,MAAM,wBAAwB,CAAC;AAChC,OAAO,EAGL,WAAW,EAEZ,MAAM,WAAW,CAAC;AA+CnB,8CAA8C;AAC9C,oBAAY,eAAe,CAAC,KAAK,GAAG,GAAG,IAAI,gBAAgB,GAAG,mBAAmB,CAAC,KAAK,CAAC,CAAC;AAEzF,sCAAsC;AACtC,aAAK,gBAAgB,GAAG;IACtB;;OAEG;IACH,IAAI,EAAE,MAAM,CAAC;IAEb;;;;;;;OAOG;IACH,IAAI,EAAE,OAAO,CAAC;IAEd;;;;OAIG;IACH,UAAU,CAAC,EAAE,MAAM,CAAC;IAEpB;;;;;;OAMG;IACH,WAAW,CAAC,EAAE,UAAU,CAAC;IAEzB;;;;;;OAMG;IACH,SAAS,CAAC,EAAE,MAAM,CAAC;IAEnB;;;;;;OAMG;IACH,OAAO,CAAC,EAAE,MAAM,EAAE,CAAC;IAEnB;;;;OAIG;IACH,gBAAgB,CAAC,EAAE,MAAM,CAAC;IAE1B;;;;OAIG;IACH,WAAW,CAAC,EAAE,WAAW,CAAC;IAE1B;;;;OAIG;IACH,WAAW,CAAC,EAAE,CAAC,GAAG,EAAE,OAAO,KAAK,IAAI,CAAC;IAErC,QAAQ,CAAC,EAAE,MAAM,CAAC;IAElB,wEAAwE;IACxE,cAAc,CAAC,EAAE,MAAM,CAAC;IAExB,iHAAiH;IACjH,mBAAmB,CAAC,EAAE,MAAM,CAAC;IAE7B,kDAAkD;IAClD,eAAe,CAAC,EAAE,eAAe,CAAC;CACnC,CAAC;AAEF,MAAM,CAAC,OAAO,OAAO,UAAU,CAAC,UAAU,GAAG,EAAE,CAAE,SAAQ,cAAc,CACrE,QAAQ,CAAC,gBAAgB,CAAC,GAAG,UAAU,CACxC;IACC,MAAM,CAAC,SAAS,SAAgB;IAChC,MAAM,CAAC,YAAY,MAAuB;IAE1C,eAAe,IAAI,IAAI;IAOvB,IAAI,QAAQ,IAAI,OAAO,CAEtB;IAED,WAAW,CAAC,KAAK,EAAE,eAAe,GAAG,IAAI;IAuCzC,WAAW,CAAC,EAAC,KAAK,EAAE,QAAQ,EAAE,WAAW,EAAC,EAAE,gBAAgB,CAAC,IAAI,CAAC;IAqB5D,WAAW,IAAI,OAAO,CAAC,IAAI,CAAC;IAsClC,oBAAoB,IAAI,CAAC,GAAG,EAAE,UAAU,CAAC;IAuBzC,YAAY,IAAI,KAAK,GAAG,IAAI;CAqB7B"}
|
package/typed/api/index.js
DELETED
package/typed/api/layer-map.js
DELETED
|
@@ -1,264 +0,0 @@
|
|
|
1
|
-
import { deviation, extent, groupSort, median, variance } from 'd3-array';
|
|
2
|
-
import { rgb } from 'd3-color';
|
|
3
|
-
import { scaleLinear, scaleOrdinal, scaleLog, scalePoint, scaleQuantile, scaleQuantize, scaleSqrt, scaleThreshold } from 'd3-scale';
|
|
4
|
-
import { format as d3Format } from 'd3-format';
|
|
5
|
-
import moment from 'moment-timezone';
|
|
6
|
-
import { CPUGridLayer, HeatmapLayer, HexagonLayer } from '@deck.gl/aggregation-layers';
|
|
7
|
-
import { GeoJsonLayer } from '@deck.gl/layers';
|
|
8
|
-
import { H3HexagonLayer, MVTLayer } from '@deck.gl/geo-layers';
|
|
9
|
-
import CartoTileLayer from '../layers/carto-tile-layer';
|
|
10
|
-
import { TILE_FORMATS } from './maps-api-common';
|
|
11
|
-
import { assert } from '../utils';
|
|
12
|
-
const SCALE_FUNCS = {
|
|
13
|
-
linear: scaleLinear,
|
|
14
|
-
ordinal: scaleOrdinal,
|
|
15
|
-
log: scaleLog,
|
|
16
|
-
point: scalePoint,
|
|
17
|
-
quantile: scaleQuantile,
|
|
18
|
-
quantize: scaleQuantize,
|
|
19
|
-
sqrt: scaleSqrt,
|
|
20
|
-
custom: scaleThreshold
|
|
21
|
-
};
|
|
22
|
-
const UNKNOWN_COLOR = '#868d91';
|
|
23
|
-
export const AGGREGATION = {
|
|
24
|
-
average: 'MEAN',
|
|
25
|
-
maximum: 'MAX',
|
|
26
|
-
minimum: 'MIN',
|
|
27
|
-
sum: 'SUM'
|
|
28
|
-
};
|
|
29
|
-
export const OPACITY_MAP = {
|
|
30
|
-
getFillColor: 'opacity',
|
|
31
|
-
getLineColor: 'strokeOpacity',
|
|
32
|
-
getTextColor: 'opacity'
|
|
33
|
-
};
|
|
34
|
-
const AGGREGATION_FUNC = {
|
|
35
|
-
'count unique': (values, accessor) => groupSort(values, v => v.length, accessor).length,
|
|
36
|
-
median,
|
|
37
|
-
// Unfortunately mode() is only available in d3-array@3+ which is ESM only
|
|
38
|
-
mode: (values, accessor) => groupSort(values, v => v.length, accessor).pop(),
|
|
39
|
-
stddev: deviation,
|
|
40
|
-
variance
|
|
41
|
-
};
|
|
42
|
-
const hexToRGBA = c => {
|
|
43
|
-
const { r, g, b, opacity } = rgb(c);
|
|
44
|
-
return [r, g, b, 255 * opacity];
|
|
45
|
-
};
|
|
46
|
-
// Kepler -> Deck.gl
|
|
47
|
-
const sharedPropMap = {
|
|
48
|
-
color: 'getFillColor',
|
|
49
|
-
isVisible: 'visible',
|
|
50
|
-
label: 'cartoLabel',
|
|
51
|
-
textLabel: {
|
|
52
|
-
alignment: 'getTextAlignmentBaseline',
|
|
53
|
-
anchor: 'getTextAnchor',
|
|
54
|
-
color: 'getTextColor',
|
|
55
|
-
size: 'getTextSize'
|
|
56
|
-
},
|
|
57
|
-
visConfig: {
|
|
58
|
-
enable3d: 'extruded',
|
|
59
|
-
elevationScale: 'elevationScale',
|
|
60
|
-
filled: 'filled',
|
|
61
|
-
strokeColor: 'getLineColor',
|
|
62
|
-
stroked: 'stroked',
|
|
63
|
-
thickness: 'getLineWidth',
|
|
64
|
-
radius: 'getPointRadius',
|
|
65
|
-
wireframe: 'wireframe'
|
|
66
|
-
}
|
|
67
|
-
};
|
|
68
|
-
const aggregationVisConfig = {
|
|
69
|
-
colorAggregation: x => ({ colorAggregation: AGGREGATION[x] || AGGREGATION.sum }),
|
|
70
|
-
colorRange: x => ({ colorRange: x.colors.map(hexToRGBA) }),
|
|
71
|
-
coverage: 'coverage',
|
|
72
|
-
elevationPercentile: ['elevationLowerPercentile', 'elevationUpperPercentile'],
|
|
73
|
-
percentile: ['lowerPercentile', 'upperPercentile']
|
|
74
|
-
};
|
|
75
|
-
const defaultProps = {
|
|
76
|
-
lineMiterLimit: 2,
|
|
77
|
-
lineWidthUnits: 'pixels',
|
|
78
|
-
pointRadiusUnits: 'pixels',
|
|
79
|
-
rounded: true,
|
|
80
|
-
wrapLongitude: false
|
|
81
|
-
};
|
|
82
|
-
function mergePropMaps(a = {}, b = {}) {
|
|
83
|
-
return { ...a, ...b, visConfig: { ...a.visConfig, ...b.visConfig } };
|
|
84
|
-
}
|
|
85
|
-
export function getLayer(type, config, dataset) {
|
|
86
|
-
if (type === 'mvt' || type === 'tileset') {
|
|
87
|
-
return getTileLayer(dataset);
|
|
88
|
-
}
|
|
89
|
-
const geoColumn = dataset?.geoColumn;
|
|
90
|
-
const getPosition = d => d[geoColumn].coordinates;
|
|
91
|
-
const hexagonId = config.columns?.hex_id;
|
|
92
|
-
const layerTypeDefs = {
|
|
93
|
-
point: {
|
|
94
|
-
Layer: GeoJsonLayer,
|
|
95
|
-
propMap: { visConfig: { outline: 'stroked' } }
|
|
96
|
-
},
|
|
97
|
-
geojson: {
|
|
98
|
-
Layer: GeoJsonLayer
|
|
99
|
-
},
|
|
100
|
-
grid: {
|
|
101
|
-
Layer: CPUGridLayer,
|
|
102
|
-
propMap: { visConfig: { ...aggregationVisConfig, worldUnitSize: x => ({ cellSize: 1000 * x }) } },
|
|
103
|
-
defaultProps: { getPosition }
|
|
104
|
-
},
|
|
105
|
-
heatmap: {
|
|
106
|
-
Layer: HeatmapLayer,
|
|
107
|
-
propMap: { visConfig: { ...aggregationVisConfig, radius: 'radiusPixels' } },
|
|
108
|
-
defaultProps: { getPosition }
|
|
109
|
-
},
|
|
110
|
-
hexagon: {
|
|
111
|
-
Layer: HexagonLayer,
|
|
112
|
-
propMap: { visConfig: { ...aggregationVisConfig, worldUnitSize: x => ({ radius: 1000 * x }) } },
|
|
113
|
-
defaultProps: { getPosition }
|
|
114
|
-
},
|
|
115
|
-
hexagonId: {
|
|
116
|
-
Layer: H3HexagonLayer,
|
|
117
|
-
propMap: { visConfig: { coverage: 'coverage' } },
|
|
118
|
-
defaultProps: { getHexagon: d => d[hexagonId], stroked: false }
|
|
119
|
-
}
|
|
120
|
-
};
|
|
121
|
-
const layer = layerTypeDefs[type];
|
|
122
|
-
assert(layer, `Unsupported layer type: ${type}`);
|
|
123
|
-
return {
|
|
124
|
-
...layer,
|
|
125
|
-
propMap: mergePropMaps(sharedPropMap, layer.propMap),
|
|
126
|
-
defaultProps: { ...defaultProps, ...layer.defaultProps }
|
|
127
|
-
};
|
|
128
|
-
}
|
|
129
|
-
function getTileLayer(dataset) {
|
|
130
|
-
const { data: { tiles: [tileUrl] } } = dataset;
|
|
131
|
-
/* global URL */
|
|
132
|
-
const formatTiles = new URL(tileUrl).searchParams.get('formatTiles') || TILE_FORMATS.MVT;
|
|
133
|
-
return {
|
|
134
|
-
Layer: formatTiles === TILE_FORMATS.MVT ? MVTLayer : CartoTileLayer,
|
|
135
|
-
propMap: sharedPropMap,
|
|
136
|
-
defaultProps: {
|
|
137
|
-
...defaultProps,
|
|
138
|
-
uniqueIdProperty: 'geoid',
|
|
139
|
-
formatTiles
|
|
140
|
-
}
|
|
141
|
-
};
|
|
142
|
-
}
|
|
143
|
-
function domainFromAttribute(attribute, scaleType) {
|
|
144
|
-
if (scaleType === 'ordinal' || scaleType === 'point') {
|
|
145
|
-
return attribute.categories.map(c => c.category).filter(c => c !== undefined && c !== null);
|
|
146
|
-
}
|
|
147
|
-
let { min } = attribute;
|
|
148
|
-
if (scaleType === 'log' && min === 0) {
|
|
149
|
-
min = 1e-5;
|
|
150
|
-
}
|
|
151
|
-
return [min, attribute.max];
|
|
152
|
-
}
|
|
153
|
-
function domainFromValues(values, scaleType) {
|
|
154
|
-
if (scaleType === 'ordinal') {
|
|
155
|
-
return groupSort(values, g => -g.length, d => d);
|
|
156
|
-
}
|
|
157
|
-
else if (scaleType === 'quantile') {
|
|
158
|
-
return values.sort((a, b) => a - b);
|
|
159
|
-
}
|
|
160
|
-
else if (scaleType === 'log') {
|
|
161
|
-
const [d0, d1] = extent(values);
|
|
162
|
-
return [d0 === 0 ? 1e-5 : d0, d1];
|
|
163
|
-
}
|
|
164
|
-
return extent(values);
|
|
165
|
-
}
|
|
166
|
-
function calculateDomain(data, name, scaleType) {
|
|
167
|
-
if (data.tilestats) {
|
|
168
|
-
// Tileset data type
|
|
169
|
-
const { attributes } = data.tilestats.layers[0];
|
|
170
|
-
const attribute = attributes.find(a => a.attribute === name);
|
|
171
|
-
return domainFromAttribute(attribute, scaleType);
|
|
172
|
-
}
|
|
173
|
-
else if (data.features) {
|
|
174
|
-
// GeoJSON data type
|
|
175
|
-
const values = data.features.map(({ properties }) => properties[name]);
|
|
176
|
-
return domainFromValues(values, scaleType);
|
|
177
|
-
}
|
|
178
|
-
else if (Array.isArray(data) && data[0][name] !== undefined) {
|
|
179
|
-
// JSON data type
|
|
180
|
-
const values = data.map(properties => properties[name]);
|
|
181
|
-
return domainFromValues(values, scaleType);
|
|
182
|
-
}
|
|
183
|
-
return [0, 1];
|
|
184
|
-
}
|
|
185
|
-
function normalizeAccessor(accessor, data) {
|
|
186
|
-
if (data.features || data.tilestats) {
|
|
187
|
-
return ({ properties }) => {
|
|
188
|
-
return accessor(properties);
|
|
189
|
-
};
|
|
190
|
-
}
|
|
191
|
-
return accessor;
|
|
192
|
-
}
|
|
193
|
-
export function opacityToAlpha(opacity) {
|
|
194
|
-
return opacity !== undefined ? Math.round(255 * Math.pow(opacity, 1 / 2.2)) : 255;
|
|
195
|
-
}
|
|
196
|
-
export function getColorValueAccessor({ name }, colorAggregation, data) {
|
|
197
|
-
const aggregator = AGGREGATION_FUNC[colorAggregation];
|
|
198
|
-
const accessor = values => aggregator(values, p => p[name]);
|
|
199
|
-
return normalizeAccessor(accessor, data);
|
|
200
|
-
}
|
|
201
|
-
export function getColorAccessor({ name }, scaleType, { colors, colorMap }, opacity, data) {
|
|
202
|
-
const scale = SCALE_FUNCS[scaleType]();
|
|
203
|
-
let domain = [];
|
|
204
|
-
let scaleColor = [];
|
|
205
|
-
if (Array.isArray(colorMap)) {
|
|
206
|
-
colorMap.forEach(([value, color]) => {
|
|
207
|
-
domain.push(value);
|
|
208
|
-
scaleColor.push(color);
|
|
209
|
-
});
|
|
210
|
-
}
|
|
211
|
-
else {
|
|
212
|
-
domain = calculateDomain(data, name, scaleType);
|
|
213
|
-
scaleColor = colors;
|
|
214
|
-
}
|
|
215
|
-
if (scaleType === 'ordinal') {
|
|
216
|
-
domain = domain.slice(0, scaleColor.length);
|
|
217
|
-
}
|
|
218
|
-
scale.domain(domain);
|
|
219
|
-
scale.range(scaleColor);
|
|
220
|
-
scale.unknown(UNKNOWN_COLOR);
|
|
221
|
-
const alpha = opacityToAlpha(opacity);
|
|
222
|
-
const accessor = properties => {
|
|
223
|
-
const propertyValue = properties[name];
|
|
224
|
-
const { r, g, b } = rgb(scale(propertyValue));
|
|
225
|
-
return [r, g, b, propertyValue === null ? 0 : alpha];
|
|
226
|
-
};
|
|
227
|
-
return normalizeAccessor(accessor, data);
|
|
228
|
-
}
|
|
229
|
-
export function getSizeAccessor({ name }, scaleType, range, data) {
|
|
230
|
-
const scale = SCALE_FUNCS[scaleType]();
|
|
231
|
-
scale.domain(calculateDomain(data, name, scaleType));
|
|
232
|
-
scale.range(range);
|
|
233
|
-
const accessor = properties => {
|
|
234
|
-
return scale(properties[name]);
|
|
235
|
-
};
|
|
236
|
-
return normalizeAccessor(accessor, data);
|
|
237
|
-
}
|
|
238
|
-
const FORMATS = {
|
|
239
|
-
date: s => moment.utc(s).format('MM/DD/YY HH:mm:ssa'),
|
|
240
|
-
integer: d3Format('i'),
|
|
241
|
-
float: d3Format('.5f'),
|
|
242
|
-
timestamp: s => moment.utc(s).format('X'),
|
|
243
|
-
default: String
|
|
244
|
-
};
|
|
245
|
-
export function getTextAccessor({ name, type }, data) {
|
|
246
|
-
const format = FORMATS[type] || FORMATS.default;
|
|
247
|
-
const accessor = properties => {
|
|
248
|
-
return format(properties[name]);
|
|
249
|
-
};
|
|
250
|
-
return normalizeAccessor(accessor, data);
|
|
251
|
-
}
|
|
252
|
-
export function getTextPixelOffsetAccessor({ alignment, anchor, size }, radius) {
|
|
253
|
-
const padding = 20;
|
|
254
|
-
const signX = anchor === 'middle' ? 0 : anchor === 'start' ? 1 : -1;
|
|
255
|
-
const signY = alignment === 'center' ? 0 : alignment === 'bottom' ? 1 : -1;
|
|
256
|
-
const sizeOffset = alignment === 'center' ? 0 : size;
|
|
257
|
-
const calculateOffset = r => [signX * (r + padding), signY * (r + padding + sizeOffset)];
|
|
258
|
-
return typeof radius === 'function'
|
|
259
|
-
? d => {
|
|
260
|
-
return calculateOffset(radius(d));
|
|
261
|
-
}
|
|
262
|
-
: calculateOffset(radius);
|
|
263
|
-
}
|
|
264
|
-
export { domainFromValues as _domainFromValues };
|
|
@@ -1,50 +0,0 @@
|
|
|
1
|
-
export const DEFAULT_USER_COMPONENT_IN_URL = '{user}';
|
|
2
|
-
export const DEFAULT_REGION_COMPONENT_IN_URL = '{region}';
|
|
3
|
-
export const API_VERSIONS = {
|
|
4
|
-
V1: 'v1',
|
|
5
|
-
V2: 'v2',
|
|
6
|
-
V3: 'v3'
|
|
7
|
-
};
|
|
8
|
-
export const DEFAULT_MAPS_URL_FORMAT = {
|
|
9
|
-
[API_VERSIONS.V1]: `https://${DEFAULT_USER_COMPONENT_IN_URL}.carto.com/api/v1/map`,
|
|
10
|
-
[API_VERSIONS.V2]: `https://maps-api-v2.${DEFAULT_REGION_COMPONENT_IN_URL}.carto.com/user/${DEFAULT_USER_COMPONENT_IN_URL}`
|
|
11
|
-
};
|
|
12
|
-
export const MAP_TYPES = {
|
|
13
|
-
QUERY: 'query',
|
|
14
|
-
TABLE: 'table',
|
|
15
|
-
TILESET: 'tileset'
|
|
16
|
-
};
|
|
17
|
-
export const COLUMNS_SUPPORT = [MAP_TYPES.TABLE];
|
|
18
|
-
export const GEO_COLUMN_SUPPORT = [MAP_TYPES.QUERY, MAP_TYPES.TABLE];
|
|
19
|
-
// AVAILABLE FORMATS
|
|
20
|
-
export const FORMATS = {
|
|
21
|
-
GEOJSON: 'geojson',
|
|
22
|
-
NDJSON: 'ndjson',
|
|
23
|
-
TILEJSON: 'tilejson',
|
|
24
|
-
JSON: 'json'
|
|
25
|
-
};
|
|
26
|
-
// AVAILABLE FORMATS FOR TILES
|
|
27
|
-
export const TILE_FORMATS = {
|
|
28
|
-
MVT: 'mvt',
|
|
29
|
-
JSON: 'json',
|
|
30
|
-
GEOJSON: 'geojson',
|
|
31
|
-
BINARY: 'binary'
|
|
32
|
-
};
|
|
33
|
-
export var SchemaFieldType;
|
|
34
|
-
(function (SchemaFieldType) {
|
|
35
|
-
SchemaFieldType["Number"] = "number";
|
|
36
|
-
SchemaFieldType["Bigint"] = "bigint";
|
|
37
|
-
SchemaFieldType["String"] = "string";
|
|
38
|
-
SchemaFieldType["Geometry"] = "geometry";
|
|
39
|
-
SchemaFieldType["Timestamp"] = "timestamp";
|
|
40
|
-
SchemaFieldType["Object"] = "object";
|
|
41
|
-
SchemaFieldType["Boolean"] = "boolean";
|
|
42
|
-
SchemaFieldType["Variant"] = "variant";
|
|
43
|
-
SchemaFieldType["Unknown"] = "unknown";
|
|
44
|
-
})(SchemaFieldType || (SchemaFieldType = {}));
|
|
45
|
-
/**
|
|
46
|
-
* Simple encode parameter
|
|
47
|
-
*/
|
|
48
|
-
export function encodeParameter(name, value) {
|
|
49
|
-
return `${name}=${encodeURIComponent(value)}`;
|
|
50
|
-
}
|