@carto/api-client 0.5.2-alpha.0 → 0.5.2-alpha.1
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/build/api-client.cjs +120 -12
- package/build/api-client.cjs.map +1 -1
- package/build/api-client.d.cts +20 -1
- package/build/api-client.d.ts +20 -1
- package/build/api-client.js +114 -12
- package/build/api-client.js.map +1 -1
- package/build/worker.js +28 -19
- package/build/worker.js.map +1 -1
- package/package.json +3 -2
- package/src/api/carto-api-error.ts +1 -1
- package/src/api/endpoints.ts +1 -1
- package/src/api/index.ts +2 -2
- package/src/api/query.ts +1 -1
- package/src/api/request-with-parameters.ts +2 -2
- package/src/deck/get-data-filter-extension-props.ts +3 -3
- package/src/fetch-map/basemap-styles.ts +2 -2
- package/src/fetch-map/basemap.ts +2 -2
- package/src/fetch-map/fetch-map.ts +3 -3
- package/src/fetch-map/layer-map.ts +81 -5
- package/src/fetch-map/parse-map.ts +71 -7
- package/src/fetch-map/source.ts +10 -10
- package/src/fetch-map/types.ts +7 -3
- package/src/filters/Filter.ts +4 -4
- package/src/filters/FilterTypes.ts +1 -1
- package/src/filters/geosjonFeatures.ts +3 -3
- package/src/filters/tileFeatures.ts +8 -3
- package/src/filters/tileFeaturesGeometries.ts +5 -5
- package/src/filters/tileFeaturesRaster.ts +3 -3
- package/src/filters/tileFeaturesSpatialIndex.ts +4 -4
- package/src/filters.ts +1 -1
- package/src/geo.ts +1 -1
- package/src/index.ts +3 -3
- package/src/models/model.ts +6 -3
- package/src/operations/aggregation.ts +14 -4
- package/src/operations/applySorting.ts +2 -2
- package/src/operations/groupBy.ts +2 -2
- package/src/operations/groupByDate.ts +2 -2
- package/src/operations/histogram.ts +2 -2
- package/src/operations/scatterPlot.ts +2 -2
- package/src/sources/base-source.ts +2 -2
- package/src/sources/boundary-query-source.ts +1 -1
- package/src/sources/h3-query-source.ts +1 -1
- package/src/sources/h3-table-source.ts +1 -1
- package/src/sources/h3-tileset-source.ts +1 -1
- package/src/sources/quadbin-query-source.ts +1 -1
- package/src/sources/quadbin-table-source.ts +1 -1
- package/src/sources/quadbin-tileset-source.ts +1 -1
- package/src/sources/raster-source.ts +1 -1
- package/src/sources/types.ts +2 -2
- package/src/sources/vector-query-source.ts +1 -1
- package/src/sources/vector-table-source.ts +1 -1
- package/src/sources/vector-tileset-source.ts +1 -1
- package/src/utils/getTileFormat.ts +1 -1
- package/src/utils/makeIntervalComplete.ts +1 -1
- package/src/utils/transformTileCoordsToWGS84.ts +1 -1
- package/src/utils/transformToTileCoords.ts +1 -1
- package/src/utils.ts +35 -0
- package/src/widget-sources/types.ts +5 -2
- package/src/widget-sources/widget-query-source.ts +4 -4
- package/src/widget-sources/widget-raster-source.ts +2 -2
- package/src/widget-sources/widget-remote-source.ts +4 -4
- package/src/widget-sources/widget-source.ts +3 -3
- package/src/widget-sources/widget-table-source.ts +4 -4
- package/src/widget-sources/widget-tileset-source-impl.ts +6 -5
- package/src/widget-sources/widget-tileset-source.ts +7 -7
package/build/api-client.cjs
CHANGED
|
@@ -5510,6 +5510,9 @@ __export(src_exports, {
|
|
|
5510
5510
|
SOURCE_DEFAULTS: () => SOURCE_DEFAULTS,
|
|
5511
5511
|
SpatialIndex: () => SpatialIndex,
|
|
5512
5512
|
SpatialIndexColumn: () => SpatialIndexColumn,
|
|
5513
|
+
TEXT_LABEL_INDEX: () => TEXT_LABEL_INDEX,
|
|
5514
|
+
TEXT_NUMBER_FORMATTER: () => TEXT_NUMBER_FORMATTER,
|
|
5515
|
+
TEXT_OUTLINE_OPACITY: () => TEXT_OUTLINE_OPACITY,
|
|
5513
5516
|
TileFormat: () => TileFormat,
|
|
5514
5517
|
WidgetQuerySource: () => WidgetQuerySource,
|
|
5515
5518
|
WidgetRasterSource: () => WidgetRasterSource,
|
|
@@ -5530,6 +5533,8 @@ __export(src_exports, {
|
|
|
5530
5533
|
buildBinaryFeatureFilter: () => buildBinaryFeatureFilter,
|
|
5531
5534
|
buildPublicMapUrl: () => buildPublicMapUrl,
|
|
5532
5535
|
buildStatsUrl: () => buildStatsUrl,
|
|
5536
|
+
calculateClusterRadius: () => calculateClusterRadius,
|
|
5537
|
+
calculateClusterTextFontSize: () => calculateClusterTextFontSize,
|
|
5533
5538
|
clearFilters: () => clearFilters,
|
|
5534
5539
|
configureSource: () => configureSource,
|
|
5535
5540
|
createPolygonSpatialFilter: () => createPolygonSpatialFilter,
|
|
@@ -5544,6 +5549,7 @@ __export(src_exports, {
|
|
|
5544
5549
|
getColorValueAccessor: () => getColorValueAccessor,
|
|
5545
5550
|
getColumnNameFromGeoColumn: () => getColumnNameFromGeoColumn,
|
|
5546
5551
|
getDataFilterExtensionProps: () => getDataFilterExtensionProps,
|
|
5552
|
+
getDefaultAggregationExpColumnAliasForLayerType: () => getDefaultAggregationExpColumnAliasForLayerType,
|
|
5547
5553
|
getFilter: () => getFilter,
|
|
5548
5554
|
getIconUrlAccessor: () => getIconUrlAccessor,
|
|
5549
5555
|
getLayerProps: () => getLayerProps,
|
|
@@ -11097,6 +11103,7 @@ function isValidBandValue(value, nodata) {
|
|
|
11097
11103
|
|
|
11098
11104
|
// src/utils.ts
|
|
11099
11105
|
init_cjs_shims();
|
|
11106
|
+
var FILTER_TYPES = new Set(Object.values(FilterType));
|
|
11100
11107
|
function normalizeObjectKeys(el) {
|
|
11101
11108
|
if (Array.isArray(el)) {
|
|
11102
11109
|
return el.map((value) => normalizeObjectKeys(value));
|
|
@@ -11785,8 +11792,8 @@ function objectToURLSearchParams(object) {
|
|
|
11785
11792
|
|
|
11786
11793
|
// src/filters.ts
|
|
11787
11794
|
init_cjs_shims();
|
|
11788
|
-
var
|
|
11789
|
-
var isFilterType = (type) =>
|
|
11795
|
+
var FILTER_TYPES2 = new Set(Object.values(FilterType));
|
|
11796
|
+
var isFilterType = (type) => FILTER_TYPES2.has(type);
|
|
11790
11797
|
function addFilter(filters, { column, type, values, owner }) {
|
|
11791
11798
|
if (!filters[column]) {
|
|
11792
11799
|
filters[column] = {};
|
|
@@ -11801,7 +11808,7 @@ function removeFilter(filters, { column, owner }) {
|
|
|
11801
11808
|
return filters;
|
|
11802
11809
|
}
|
|
11803
11810
|
if (owner) {
|
|
11804
|
-
for (const type of
|
|
11811
|
+
for (const type of FILTER_TYPES2) {
|
|
11805
11812
|
if (owner === filter[type]?.owner) {
|
|
11806
11813
|
delete filter[type];
|
|
11807
11814
|
}
|
|
@@ -11826,7 +11833,7 @@ function hasFilter(filters, { column, owner }) {
|
|
|
11826
11833
|
if (!owner) {
|
|
11827
11834
|
return true;
|
|
11828
11835
|
}
|
|
11829
|
-
for (const type of
|
|
11836
|
+
for (const type of FILTER_TYPES2) {
|
|
11830
11837
|
if (owner === filter[type]?.owner) {
|
|
11831
11838
|
return true;
|
|
11832
11839
|
}
|
|
@@ -12195,7 +12202,11 @@ function min(values, keys, joinOperation) {
|
|
|
12195
12202
|
Infinity
|
|
12196
12203
|
);
|
|
12197
12204
|
}
|
|
12198
|
-
|
|
12205
|
+
let min3 = Number.POSITIVE_INFINITY;
|
|
12206
|
+
for (const value of values) {
|
|
12207
|
+
min3 = Math.min(min3, value);
|
|
12208
|
+
}
|
|
12209
|
+
return min3;
|
|
12199
12210
|
}
|
|
12200
12211
|
function max(values, keys, joinOperation) {
|
|
12201
12212
|
const normalizedKeys = normalizeKeys(keys);
|
|
@@ -12205,7 +12216,11 @@ function max(values, keys, joinOperation) {
|
|
|
12205
12216
|
-Infinity
|
|
12206
12217
|
);
|
|
12207
12218
|
}
|
|
12208
|
-
|
|
12219
|
+
let max3 = Number.NEGATIVE_INFINITY;
|
|
12220
|
+
for (const value of values) {
|
|
12221
|
+
max3 = Math.max(max3, value);
|
|
12222
|
+
}
|
|
12223
|
+
return max3;
|
|
12209
12224
|
}
|
|
12210
12225
|
function normalizeKeys(keys) {
|
|
12211
12226
|
return Array.isArray(keys) ? keys : typeof keys === "string" ? [keys] : void 0;
|
|
@@ -14557,7 +14572,8 @@ var customMarkersPropsMap = {
|
|
|
14557
14572
|
var heatmapTilePropsMap = {
|
|
14558
14573
|
visConfig: {
|
|
14559
14574
|
colorRange: (x) => ({ colorRange: x.colors.map(hexToRGBA) }),
|
|
14560
|
-
radius:
|
|
14575
|
+
radius: (radius) => ({ radiusPixels: 20 + radius }),
|
|
14576
|
+
opacity: "opacity"
|
|
14561
14577
|
}
|
|
14562
14578
|
};
|
|
14563
14579
|
var defaultProps = {
|
|
@@ -14578,6 +14594,12 @@ var deprecatedLayerTypes = [
|
|
|
14578
14594
|
"hexagonId",
|
|
14579
14595
|
"point"
|
|
14580
14596
|
];
|
|
14597
|
+
var TEXT_LABEL_INDEX = 0;
|
|
14598
|
+
var TEXT_OUTLINE_OPACITY = 64;
|
|
14599
|
+
var TEXT_NUMBER_FORMATTER = new Intl.NumberFormat("en-US", {
|
|
14600
|
+
maximumFractionDigits: 2,
|
|
14601
|
+
notation: "compact"
|
|
14602
|
+
});
|
|
14581
14603
|
function getLayerProps(type, config2, dataset) {
|
|
14582
14604
|
if (deprecatedLayerTypes.includes(type)) {
|
|
14583
14605
|
throw new Error(
|
|
@@ -14669,9 +14691,7 @@ function findAccessorKey(keys, properties) {
|
|
|
14669
14691
|
return [key];
|
|
14670
14692
|
}
|
|
14671
14693
|
}
|
|
14672
|
-
|
|
14673
|
-
`Could not find property for any accessor key: ${keys.join(", ")}`
|
|
14674
|
-
);
|
|
14694
|
+
return keys;
|
|
14675
14695
|
}
|
|
14676
14696
|
function getColorValueAccessor({ name }, colorAggregation, data) {
|
|
14677
14697
|
const aggregator = AGGREGATION_FUNC[colorAggregation];
|
|
@@ -14798,6 +14818,40 @@ function getTextAccessor({ name, type }, data) {
|
|
|
14798
14818
|
};
|
|
14799
14819
|
return normalizeAccessor(accessor, data);
|
|
14800
14820
|
}
|
|
14821
|
+
function calculateClusterRadius(properties, stats, radiusRange, column) {
|
|
14822
|
+
const { min: min3, max: max3 } = stats[column];
|
|
14823
|
+
const value = properties[column];
|
|
14824
|
+
if (min3 === max3) return radiusRange[1];
|
|
14825
|
+
const normalizedValue = (value - min3) / (max3 - min3);
|
|
14826
|
+
return radiusRange[0] + normalizedValue * (radiusRange[1] - radiusRange[0]);
|
|
14827
|
+
}
|
|
14828
|
+
function getDefaultAggregationExpColumnAliasForLayerType(layerType, provider, columns) {
|
|
14829
|
+
if (columns && layerType === "clusterTile") {
|
|
14830
|
+
return getColumnAliasForAggregationExp(
|
|
14831
|
+
getDefaultColumnFromSchemaForAggregationExp(columns),
|
|
14832
|
+
"count",
|
|
14833
|
+
provider
|
|
14834
|
+
);
|
|
14835
|
+
} else {
|
|
14836
|
+
return DEFAULT_AGGREGATION_EXP_ALIAS;
|
|
14837
|
+
}
|
|
14838
|
+
}
|
|
14839
|
+
function getColumnAliasForAggregationExp(name, aggregation, provider) {
|
|
14840
|
+
const columnAlias = `${name}_${aggregation}`;
|
|
14841
|
+
return provider === "snowflake" ? columnAlias.toUpperCase() : columnAlias;
|
|
14842
|
+
}
|
|
14843
|
+
function getDefaultColumnFromSchemaForAggregationExp(columns) {
|
|
14844
|
+
return columns ? columns[0] : "";
|
|
14845
|
+
}
|
|
14846
|
+
function calculateClusterTextFontSize(radius) {
|
|
14847
|
+
if (radius >= 80) return 24;
|
|
14848
|
+
if (radius >= 72) return 24;
|
|
14849
|
+
if (radius >= 56) return 20;
|
|
14850
|
+
if (radius >= 40) return 16;
|
|
14851
|
+
if (radius >= 24) return 13;
|
|
14852
|
+
if (radius >= 8) return 11;
|
|
14853
|
+
return 11;
|
|
14854
|
+
}
|
|
14801
14855
|
|
|
14802
14856
|
// src/fetch-map/parse-map.ts
|
|
14803
14857
|
function parseMap(json) {
|
|
@@ -14838,7 +14892,14 @@ function parseMap(json) {
|
|
|
14838
14892
|
...defaultProps2,
|
|
14839
14893
|
...createInteractionProps(interactionConfig),
|
|
14840
14894
|
...styleProps,
|
|
14841
|
-
...createChannelProps(
|
|
14895
|
+
...createChannelProps(
|
|
14896
|
+
id,
|
|
14897
|
+
type,
|
|
14898
|
+
config3,
|
|
14899
|
+
visualChannels,
|
|
14900
|
+
data,
|
|
14901
|
+
dataset
|
|
14902
|
+
),
|
|
14842
14903
|
// Must come after style
|
|
14843
14904
|
...createParametersProp(
|
|
14844
14905
|
layerBlending,
|
|
@@ -14913,7 +14974,7 @@ function createStyleProps(config2, mapping) {
|
|
|
14913
14974
|
result.highlightColor = config2.visConfig.enable3d ? [255, 255, 255, 60] : [252, 242, 26, 255];
|
|
14914
14975
|
return result;
|
|
14915
14976
|
}
|
|
14916
|
-
function createChannelProps(id, type, config2, visualChannels, data) {
|
|
14977
|
+
function createChannelProps(id, type, config2, visualChannels, data, dataset) {
|
|
14917
14978
|
const {
|
|
14918
14979
|
colorField,
|
|
14919
14980
|
colorScale,
|
|
@@ -14973,6 +15034,47 @@ function createChannelProps(id, type, config2, visualChannels, data) {
|
|
|
14973
15034
|
};
|
|
14974
15035
|
}
|
|
14975
15036
|
}
|
|
15037
|
+
if (type === "clusterTile") {
|
|
15038
|
+
const aggregationExpAlias = getDefaultAggregationExpColumnAliasForLayerType(
|
|
15039
|
+
type,
|
|
15040
|
+
dataset.providerId,
|
|
15041
|
+
dataset.columns
|
|
15042
|
+
);
|
|
15043
|
+
result.pointType = visConfig.isTextVisible ? "circle+text" : "circle";
|
|
15044
|
+
result.clusterLevel = visConfig.clusterLevel;
|
|
15045
|
+
result.getWeight = (d) => {
|
|
15046
|
+
return d.properties[aggregationExpAlias];
|
|
15047
|
+
};
|
|
15048
|
+
result.getPointRadius = (d, info) => {
|
|
15049
|
+
return calculateClusterRadius(
|
|
15050
|
+
d.properties,
|
|
15051
|
+
info.data.attributes.stats,
|
|
15052
|
+
visConfig.radiusRange,
|
|
15053
|
+
aggregationExpAlias
|
|
15054
|
+
);
|
|
15055
|
+
};
|
|
15056
|
+
result.textCharacterSet = "auto";
|
|
15057
|
+
result.textFontFamily = "Inter, sans";
|
|
15058
|
+
result.textFontSettings = { sdf: true };
|
|
15059
|
+
result.textFontWeight = 600;
|
|
15060
|
+
result.getText = (d) => TEXT_NUMBER_FORMATTER.format(d.properties[aggregationExpAlias]);
|
|
15061
|
+
result.getTextColor = config2.textLabel[TEXT_LABEL_INDEX].color;
|
|
15062
|
+
result.textOutlineColor = [
|
|
15063
|
+
...config2.textLabel[TEXT_LABEL_INDEX].outlineColor,
|
|
15064
|
+
TEXT_OUTLINE_OPACITY
|
|
15065
|
+
];
|
|
15066
|
+
result.textOutlineWidth = 5;
|
|
15067
|
+
result.textSizeUnits = "pixels";
|
|
15068
|
+
result.getTextSize = (d, info) => {
|
|
15069
|
+
const radius = calculateClusterRadius(
|
|
15070
|
+
d.properties,
|
|
15071
|
+
info.data.attributes.stats,
|
|
15072
|
+
visConfig.radiusRange,
|
|
15073
|
+
aggregationExpAlias
|
|
15074
|
+
);
|
|
15075
|
+
return calculateClusterTextFontSize(radius);
|
|
15076
|
+
};
|
|
15077
|
+
}
|
|
14976
15078
|
if (radiusField || sizeField) {
|
|
14977
15079
|
result.getPointRadius = getSizeAccessor(
|
|
14978
15080
|
// @ts-ignore
|
|
@@ -15691,6 +15793,9 @@ function _getHexagonResolution(viewport, tileSize) {
|
|
|
15691
15793
|
SOURCE_DEFAULTS,
|
|
15692
15794
|
SpatialIndex,
|
|
15693
15795
|
SpatialIndexColumn,
|
|
15796
|
+
TEXT_LABEL_INDEX,
|
|
15797
|
+
TEXT_NUMBER_FORMATTER,
|
|
15798
|
+
TEXT_OUTLINE_OPACITY,
|
|
15694
15799
|
TileFormat,
|
|
15695
15800
|
WidgetQuerySource,
|
|
15696
15801
|
WidgetRasterSource,
|
|
@@ -15711,6 +15816,8 @@ function _getHexagonResolution(viewport, tileSize) {
|
|
|
15711
15816
|
buildBinaryFeatureFilter,
|
|
15712
15817
|
buildPublicMapUrl,
|
|
15713
15818
|
buildStatsUrl,
|
|
15819
|
+
calculateClusterRadius,
|
|
15820
|
+
calculateClusterTextFontSize,
|
|
15714
15821
|
clearFilters,
|
|
15715
15822
|
configureSource,
|
|
15716
15823
|
createPolygonSpatialFilter,
|
|
@@ -15725,6 +15832,7 @@ function _getHexagonResolution(viewport, tileSize) {
|
|
|
15725
15832
|
getColorValueAccessor,
|
|
15726
15833
|
getColumnNameFromGeoColumn,
|
|
15727
15834
|
getDataFilterExtensionProps,
|
|
15835
|
+
getDefaultAggregationExpColumnAliasForLayerType,
|
|
15728
15836
|
getFilter,
|
|
15729
15837
|
getIconUrlAccessor,
|
|
15730
15838
|
getLayerProps,
|