@carto/api-client 0.5.28 → 0.5.29
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 +28 -3
- package/build/api-client.cjs.map +1 -1
- package/build/api-client.d.cts +19 -2
- package/build/api-client.d.ts +19 -2
- package/build/api-client.js +28 -3
- package/build/api-client.js.map +1 -1
- package/package.json +1 -1
- package/src/fetch-map/fetch-map.ts +22 -0
- package/src/fetch-map/source.ts +2 -0
- package/src/fetch-map/types.ts +1 -0
- package/src/sources/vector-query-source.ts +14 -1
- package/src/sources/vector-table-source.ts +14 -1
package/package.json
CHANGED
|
@@ -8,7 +8,7 @@
|
|
|
8
8
|
"homepage": "https://github.com/CartoDB/carto-api-client#readme",
|
|
9
9
|
"author": "Don McCurdy <donmccurdy@carto.com>",
|
|
10
10
|
"packageManager": "yarn@4.3.1",
|
|
11
|
-
"version": "0.5.
|
|
11
|
+
"version": "0.5.29",
|
|
12
12
|
"license": "MIT",
|
|
13
13
|
"publishConfig": {
|
|
14
14
|
"access": "public"
|
|
@@ -302,6 +302,28 @@ export async function fetchMap({
|
|
|
302
302
|
}
|
|
303
303
|
});
|
|
304
304
|
|
|
305
|
+
// Flag datasets that need feature bounding boxes for label positioning.
|
|
306
|
+
// Some data waraehouse (notably when using MVT) only support clipped
|
|
307
|
+
// geometry. The server-provided bbox enables stable label placement.
|
|
308
|
+
const layers = map.keplerMapConfig.config.visState.layers;
|
|
309
|
+
const datasetsWithLabels = new Set<string>();
|
|
310
|
+
for (const layer of layers) {
|
|
311
|
+
const hasTextLabel = layer.config?.textLabel?.some(
|
|
312
|
+
(t: any) => t.field?.name
|
|
313
|
+
);
|
|
314
|
+
if (hasTextLabel) {
|
|
315
|
+
datasetsWithLabels.add(layer.config.dataId);
|
|
316
|
+
}
|
|
317
|
+
}
|
|
318
|
+
map.datasets.forEach((dataset: any) => {
|
|
319
|
+
if (
|
|
320
|
+
datasetsWithLabels.has(dataset.id) &&
|
|
321
|
+
(dataset.type === 'table' || dataset.type === 'query')
|
|
322
|
+
) {
|
|
323
|
+
dataset.featureBbox = true;
|
|
324
|
+
}
|
|
325
|
+
});
|
|
326
|
+
|
|
305
327
|
const [basemap] = await Promise.all([
|
|
306
328
|
fetchBasemapProps({config: map.keplerMapConfig.config, errorContext}),
|
|
307
329
|
|
package/src/fetch-map/source.ts
CHANGED
|
@@ -106,11 +106,13 @@ export function configureSource({
|
|
|
106
106
|
tileResolution,
|
|
107
107
|
...(queryParameters && {queryParameters}),
|
|
108
108
|
} as QuerySourceOptions;
|
|
109
|
+
const {featureBbox} = dataset;
|
|
109
110
|
const vectorOptions = {
|
|
110
111
|
spatialDataColumn,
|
|
111
112
|
...(columns && {columns}),
|
|
112
113
|
...(filters && {filters}),
|
|
113
114
|
...(aggregationExp && {aggregationExp}),
|
|
115
|
+
...(featureBbox && {featureBbox}),
|
|
114
116
|
} as VectorTableSourceOptions;
|
|
115
117
|
|
|
116
118
|
if (type === 'raster') {
|
package/src/fetch-map/types.ts
CHANGED
|
@@ -23,7 +23,15 @@ import type {
|
|
|
23
23
|
export type VectorQuerySourceOptions = SourceOptions &
|
|
24
24
|
QuerySourceOptions &
|
|
25
25
|
FilterOptions &
|
|
26
|
-
ColumnsOption
|
|
26
|
+
ColumnsOption & {
|
|
27
|
+
/**
|
|
28
|
+
* If `true`, the server includes a `_carto_bbox` property on each polygon
|
|
29
|
+
* feature, containing the bounding box of the full (unclipped) geometry as
|
|
30
|
+
* a `"west,south,east,north"` string in WGS84. Used by clients to compute
|
|
31
|
+
* stable label positions for polygons that span multiple tiles.
|
|
32
|
+
*/
|
|
33
|
+
featureBbox?: boolean;
|
|
34
|
+
};
|
|
27
35
|
|
|
28
36
|
type UrlParameters = {
|
|
29
37
|
columns?: string;
|
|
@@ -34,6 +42,7 @@ type UrlParameters = {
|
|
|
34
42
|
q: string;
|
|
35
43
|
queryParameters?: Record<string, unknown> | unknown[];
|
|
36
44
|
aggregationExp?: string;
|
|
45
|
+
featureBbox?: boolean;
|
|
37
46
|
};
|
|
38
47
|
|
|
39
48
|
export type VectorQuerySourceResponse = TilejsonResult &
|
|
@@ -50,6 +59,7 @@ export const vectorQuerySource = async function (
|
|
|
50
59
|
tileResolution = DEFAULT_TILE_RESOLUTION,
|
|
51
60
|
queryParameters,
|
|
52
61
|
aggregationExp,
|
|
62
|
+
featureBbox,
|
|
53
63
|
} = options;
|
|
54
64
|
|
|
55
65
|
const spatialDataType = 'geo';
|
|
@@ -73,6 +83,9 @@ export const vectorQuerySource = async function (
|
|
|
73
83
|
if (aggregationExp) {
|
|
74
84
|
urlParameters.aggregationExp = aggregationExp;
|
|
75
85
|
}
|
|
86
|
+
if (featureBbox) {
|
|
87
|
+
urlParameters.featureBbox = true;
|
|
88
|
+
}
|
|
76
89
|
|
|
77
90
|
return baseSource<UrlParameters>('query', options, urlParameters).then(
|
|
78
91
|
(result) => ({
|
|
@@ -23,7 +23,15 @@ import type {
|
|
|
23
23
|
export type VectorTableSourceOptions = SourceOptions &
|
|
24
24
|
TableSourceOptions &
|
|
25
25
|
FilterOptions &
|
|
26
|
-
ColumnsOption
|
|
26
|
+
ColumnsOption & {
|
|
27
|
+
/**
|
|
28
|
+
* If `true`, the server includes a `_carto_bbox` property on each polygon
|
|
29
|
+
* feature, containing the bounding box of the full (unclipped) geometry as
|
|
30
|
+
* a `"west,south,east,north"` string in WGS84. Used by clients to compute
|
|
31
|
+
* stable label positions for polygons that span multiple tiles.
|
|
32
|
+
*/
|
|
33
|
+
featureBbox?: boolean;
|
|
34
|
+
};
|
|
27
35
|
|
|
28
36
|
type UrlParameters = {
|
|
29
37
|
columns?: string;
|
|
@@ -33,6 +41,7 @@ type UrlParameters = {
|
|
|
33
41
|
tileResolution?: string;
|
|
34
42
|
name: string;
|
|
35
43
|
aggregationExp?: string;
|
|
44
|
+
featureBbox?: boolean;
|
|
36
45
|
};
|
|
37
46
|
|
|
38
47
|
export type VectorTableSourceResponse = TilejsonResult &
|
|
@@ -48,6 +57,7 @@ export const vectorTableSource = async function (
|
|
|
48
57
|
tableName,
|
|
49
58
|
tileResolution = DEFAULT_TILE_RESOLUTION,
|
|
50
59
|
aggregationExp,
|
|
60
|
+
featureBbox,
|
|
51
61
|
} = options;
|
|
52
62
|
|
|
53
63
|
const spatialDataType = 'geo';
|
|
@@ -68,6 +78,9 @@ export const vectorTableSource = async function (
|
|
|
68
78
|
if (aggregationExp) {
|
|
69
79
|
urlParameters.aggregationExp = aggregationExp;
|
|
70
80
|
}
|
|
81
|
+
if (featureBbox) {
|
|
82
|
+
urlParameters.featureBbox = true;
|
|
83
|
+
}
|
|
71
84
|
|
|
72
85
|
return baseSource<UrlParameters>('table', options, urlParameters).then(
|
|
73
86
|
(result) => ({
|