@carto/api-client 0.5.27 → 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 +11 -0
- package/build/api-client.cjs +63 -6
- package/build/api-client.cjs.map +1 -1
- package/build/api-client.d.cts +24 -2
- package/build/api-client.d.ts +24 -2
- package/build/api-client.js +63 -6
- 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/layer-map.ts +3 -2
- package/src/fetch-map/parse-map.ts +51 -1
- package/src/fetch-map/source.ts +2 -0
- package/src/fetch-map/types.ts +7 -0
- package/src/sources/vector-query-source.ts +14 -1
- package/src/sources/vector-table-source.ts +14 -1
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,16 @@
|
|
|
1
1
|
# CHANGELOG
|
|
2
2
|
|
|
3
|
+
## Unreleased
|
|
4
|
+
|
|
5
|
+
### 0.5.29
|
|
6
|
+
|
|
7
|
+
- feat(sources): Support featureBbox parameter (#289)
|
|
8
|
+
|
|
9
|
+
### 0.5.28
|
|
10
|
+
|
|
11
|
+
- feat(fetchMap): Support zoom-dependent point styling (#287)
|
|
12
|
+
- feat(fetchMap): Support autoLabels (#288)
|
|
13
|
+
|
|
3
14
|
### 0.5.27
|
|
4
15
|
|
|
5
16
|
- feat(parseMap): custom aggregation support on spatial-index and geometry-aggregated layers. Adds `compileCustomAggregation(expression, { provider })` helper, `VisualChannelField.accessorKey`, and `{channel}AggregationExp` / `{channel}AggregationDomain` on `VisConfig` for all 6 channels.
|
package/build/api-client.cjs
CHANGED
|
@@ -8564,7 +8564,8 @@ var vectorQuerySource = async function(options) {
|
|
|
8564
8564
|
sqlQuery,
|
|
8565
8565
|
tileResolution = DEFAULT_TILE_RESOLUTION,
|
|
8566
8566
|
queryParameters,
|
|
8567
|
-
aggregationExp
|
|
8567
|
+
aggregationExp,
|
|
8568
|
+
featureBbox
|
|
8568
8569
|
} = options;
|
|
8569
8570
|
const spatialDataType = "geo";
|
|
8570
8571
|
const urlParameters = {
|
|
@@ -8585,6 +8586,9 @@ var vectorQuerySource = async function(options) {
|
|
|
8585
8586
|
if (aggregationExp) {
|
|
8586
8587
|
urlParameters.aggregationExp = aggregationExp;
|
|
8587
8588
|
}
|
|
8589
|
+
if (featureBbox) {
|
|
8590
|
+
urlParameters.featureBbox = true;
|
|
8591
|
+
}
|
|
8588
8592
|
return baseSource("query", options, urlParameters).then(
|
|
8589
8593
|
(result) => ({
|
|
8590
8594
|
...result,
|
|
@@ -8608,7 +8612,8 @@ var vectorTableSource = async function(options) {
|
|
|
8608
8612
|
spatialDataColumn = DEFAULT_GEO_COLUMN,
|
|
8609
8613
|
tableName,
|
|
8610
8614
|
tileResolution = DEFAULT_TILE_RESOLUTION,
|
|
8611
|
-
aggregationExp
|
|
8615
|
+
aggregationExp,
|
|
8616
|
+
featureBbox
|
|
8612
8617
|
} = options;
|
|
8613
8618
|
const spatialDataType = "geo";
|
|
8614
8619
|
const urlParameters = {
|
|
@@ -8626,6 +8631,9 @@ var vectorTableSource = async function(options) {
|
|
|
8626
8631
|
if (aggregationExp) {
|
|
8627
8632
|
urlParameters.aggregationExp = aggregationExp;
|
|
8628
8633
|
}
|
|
8634
|
+
if (featureBbox) {
|
|
8635
|
+
urlParameters.featureBbox = true;
|
|
8636
|
+
}
|
|
8629
8637
|
return baseSource("table", options, urlParameters).then(
|
|
8630
8638
|
(result) => ({
|
|
8631
8639
|
...result,
|
|
@@ -10047,10 +10055,11 @@ function getIconUrlAccessor(field, range, {
|
|
|
10047
10055
|
return normalizeAccessor(accessor, data);
|
|
10048
10056
|
}
|
|
10049
10057
|
function getMaxMarkerSize(visConfig, visualChannels) {
|
|
10050
|
-
const { radiusRange, radius } = visConfig;
|
|
10058
|
+
const { radiusRange, radius, sizeMaxPixels } = visConfig;
|
|
10051
10059
|
const { radiusField, sizeField } = visualChannels;
|
|
10052
10060
|
const field = radiusField || sizeField;
|
|
10053
|
-
|
|
10061
|
+
const baseSize = radiusRange && field ? radiusRange[1] : radius;
|
|
10062
|
+
return Math.ceil(sizeMaxPixels ?? baseSize);
|
|
10054
10063
|
}
|
|
10055
10064
|
function negateAccessor(accessor) {
|
|
10056
10065
|
if (typeof accessor === "function") {
|
|
@@ -10565,6 +10574,7 @@ function getLayerDescriptor({
|
|
|
10565
10574
|
...createInteractionProps(interactionConfig),
|
|
10566
10575
|
...styleProps,
|
|
10567
10576
|
...channelProps,
|
|
10577
|
+
...createZoomScaleProps(config2, visualChannels),
|
|
10568
10578
|
...createParametersProp(layerBlending, styleProps.parameters || {}),
|
|
10569
10579
|
// Must come after style
|
|
10570
10580
|
...createLoadOptions(data.accessToken)
|
|
@@ -10634,6 +10644,28 @@ function createInteractionProps(interactionConfig) {
|
|
|
10634
10644
|
pickable
|
|
10635
10645
|
};
|
|
10636
10646
|
}
|
|
10647
|
+
function createZoomScaleProps(config2, visualChannels) {
|
|
10648
|
+
const { visConfig } = config2;
|
|
10649
|
+
if (!visConfig.radiusScaleWithZoom || visualChannels.radiusField || visualChannels.sizeField) {
|
|
10650
|
+
return {};
|
|
10651
|
+
}
|
|
10652
|
+
const scale2 = Math.pow(2, -visConfig.radiusReferenceZoom);
|
|
10653
|
+
const result = {
|
|
10654
|
+
pointRadiusUnits: "common",
|
|
10655
|
+
pointRadiusScale: scale2,
|
|
10656
|
+
iconSizeUnits: "common",
|
|
10657
|
+
iconSizeScale: scale2
|
|
10658
|
+
};
|
|
10659
|
+
if (visConfig.sizeMinPixels !== void 0) {
|
|
10660
|
+
result.pointRadiusMinPixels = visConfig.sizeMinPixels;
|
|
10661
|
+
result.iconSizeMinPixels = visConfig.sizeMinPixels;
|
|
10662
|
+
}
|
|
10663
|
+
if (visConfig.sizeMaxPixels !== void 0) {
|
|
10664
|
+
result.pointRadiusMaxPixels = visConfig.sizeMaxPixels;
|
|
10665
|
+
result.iconSizeMaxPixels = visConfig.sizeMaxPixels;
|
|
10666
|
+
}
|
|
10667
|
+
return result;
|
|
10668
|
+
}
|
|
10637
10669
|
function mapProps(source, target, mapping) {
|
|
10638
10670
|
for (const sourceKey in mapping) {
|
|
10639
10671
|
const sourceValue = source[sourceKey];
|
|
@@ -11023,7 +11055,15 @@ function createChannelProps(id, layerType, config2, visualChannels, data, datase
|
|
|
11023
11055
|
} = secondaryLabel || {};
|
|
11024
11056
|
result.getText = mainLabel.field && getTextAccessor(mainLabel.field, data);
|
|
11025
11057
|
const getSecondaryText = secondaryField && getTextAccessor(secondaryField, data);
|
|
11026
|
-
|
|
11058
|
+
const geometry = data.tilestats?.layers?.[0]?.geometry;
|
|
11059
|
+
const isLineOrPolygon = geometry === "Polygon" || geometry === "MultiPolygon" || geometry === "Line" || geometry === "LineString" || geometry === "MultiLineString";
|
|
11060
|
+
if (isLineOrPolygon && (layerType === "tileset" || layerType === "mvt")) {
|
|
11061
|
+
const uniqueIdProperty = visConfig.textLabelUniqueIdField;
|
|
11062
|
+
result.autoLabels = uniqueIdProperty ? { uniqueIdProperty } : true;
|
|
11063
|
+
result.pointType = "text";
|
|
11064
|
+
} else {
|
|
11065
|
+
result.pointType = `${result.pointType}+text`;
|
|
11066
|
+
}
|
|
11027
11067
|
result.textCharacterSet = "auto";
|
|
11028
11068
|
result.textFontFamily = "Inter, sans";
|
|
11029
11069
|
result.textFontSettings = { sdf: true };
|
|
@@ -11184,11 +11224,13 @@ function configureSource({
|
|
|
11184
11224
|
tileResolution,
|
|
11185
11225
|
...queryParameters && { queryParameters }
|
|
11186
11226
|
};
|
|
11227
|
+
const { featureBbox } = dataset;
|
|
11187
11228
|
const vectorOptions = {
|
|
11188
11229
|
spatialDataColumn,
|
|
11189
11230
|
...columns && { columns },
|
|
11190
11231
|
...filters && { filters },
|
|
11191
|
-
...aggregationExp && { aggregationExp }
|
|
11232
|
+
...aggregationExp && { aggregationExp },
|
|
11233
|
+
...featureBbox && { featureBbox }
|
|
11192
11234
|
};
|
|
11193
11235
|
if (type === "raster") {
|
|
11194
11236
|
return rasterSource({
|
|
@@ -11472,6 +11514,21 @@ async function fetchMap({
|
|
|
11472
11514
|
}
|
|
11473
11515
|
}
|
|
11474
11516
|
});
|
|
11517
|
+
const layers = map.keplerMapConfig.config.visState.layers;
|
|
11518
|
+
const datasetsWithLabels = /* @__PURE__ */ new Set();
|
|
11519
|
+
for (const layer of layers) {
|
|
11520
|
+
const hasTextLabel = layer.config?.textLabel?.some(
|
|
11521
|
+
(t) => t.field?.name
|
|
11522
|
+
);
|
|
11523
|
+
if (hasTextLabel) {
|
|
11524
|
+
datasetsWithLabels.add(layer.config.dataId);
|
|
11525
|
+
}
|
|
11526
|
+
}
|
|
11527
|
+
map.datasets.forEach((dataset) => {
|
|
11528
|
+
if (datasetsWithLabels.has(dataset.id) && (dataset.type === "table" || dataset.type === "query")) {
|
|
11529
|
+
dataset.featureBbox = true;
|
|
11530
|
+
}
|
|
11531
|
+
});
|
|
11475
11532
|
const [basemap] = await Promise.all([
|
|
11476
11533
|
fetchBasemapProps({ config: map.keplerMapConfig.config, errorContext }),
|
|
11477
11534
|
// Mutates map.datasets so that dataset.data contains data
|