@carto/api-client 0.5.4 → 0.5.5
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 -0
- package/build/api-client.cjs +114 -304
- package/build/api-client.cjs.map +1 -1
- package/build/api-client.d.cts +32 -16
- package/build/api-client.d.ts +32 -16
- package/build/api-client.js +114 -290
- package/build/api-client.js.map +1 -1
- package/package.json +3 -2
- package/src/fetch-map/layer-map.ts +33 -45
- package/src/fetch-map/parse-map.ts +97 -83
- package/src/fetch-map/types.ts +8 -8
- package/src/models/model.ts +9 -19
package/CHANGELOG.md
CHANGED
|
@@ -2,6 +2,11 @@
|
|
|
2
2
|
|
|
3
3
|
## 0.5
|
|
4
4
|
|
|
5
|
+
### 0.5.5
|
|
6
|
+
|
|
7
|
+
- feat(fetchmap): Expose legend info from fetchMap (#179)
|
|
8
|
+
- fix(widgets): Fix inference of 'spatialDataColumn' in some table and query widgets (#183)
|
|
9
|
+
|
|
5
10
|
### 0.5.4
|
|
6
11
|
|
|
7
12
|
- fix(widgets): Fix support for 'storeGeometry' on tileset widgets (#181)
|
package/build/api-client.cjs
CHANGED
|
@@ -99,7 +99,6 @@ var require_thenBy_module = __commonJS({
|
|
|
99
99
|
// src/index.ts
|
|
100
100
|
var src_exports = {};
|
|
101
101
|
__export(src_exports, {
|
|
102
|
-
AGGREGATION: () => AGGREGATION,
|
|
103
102
|
ApiVersion: () => ApiVersion,
|
|
104
103
|
BASEMAP: () => basemap_styles_default,
|
|
105
104
|
CartoAPIError: () => CartoAPIError,
|
|
@@ -149,7 +148,6 @@ __export(src_exports, {
|
|
|
149
148
|
getApplicableFilters: () => getApplicableFilters,
|
|
150
149
|
getClient: () => getClient,
|
|
151
150
|
getColorAccessor: () => getColorAccessor,
|
|
152
|
-
getColorValueAccessor: () => getColorValueAccessor,
|
|
153
151
|
getColumnNameFromGeoColumn: () => getColumnNameFromGeoColumn,
|
|
154
152
|
getDataFilterExtensionProps: () => getDataFilterExtensionProps,
|
|
155
153
|
getDefaultAggregationExpColumnAliasForLayerType: () => getDefaultAggregationExpColumnAliasForLayerType,
|
|
@@ -3351,9 +3349,9 @@ function compare(x, y) {
|
|
|
3351
3349
|
for (i = 0; i < j; i++) if (xc[i] != yc[i]) return xc[i] > yc[i] ^ a ? 1 : -1;
|
|
3352
3350
|
return k == l ? 0 : k > l ^ a ? 1 : -1;
|
|
3353
3351
|
}
|
|
3354
|
-
function intCheck(n,
|
|
3355
|
-
if (n <
|
|
3356
|
-
throw Error(bignumberError + (name || "Argument") + (typeof n == "number" ? n <
|
|
3352
|
+
function intCheck(n, min2, max2, name) {
|
|
3353
|
+
if (n < min2 || n > max2 || n !== mathfloor(n)) {
|
|
3354
|
+
throw Error(bignumberError + (name || "Argument") + (typeof n == "number" ? n < min2 || n > max2 ? " out of range: " : " not an integer: " : " not a primitive number: ") + String(n));
|
|
3357
3355
|
}
|
|
3358
3356
|
}
|
|
3359
3357
|
function isOdd(n) {
|
|
@@ -6368,6 +6366,7 @@ function executeModel(props) {
|
|
|
6368
6366
|
filters,
|
|
6369
6367
|
filtersLogicalOperator = "and",
|
|
6370
6368
|
spatialDataType = "geo",
|
|
6369
|
+
spatialDataColumn = DEFAULT_GEO_COLUMN,
|
|
6371
6370
|
spatialFiltersMode = "intersects"
|
|
6372
6371
|
} = source;
|
|
6373
6372
|
const queryParams = {
|
|
@@ -6379,18 +6378,13 @@ function executeModel(props) {
|
|
|
6379
6378
|
filters,
|
|
6380
6379
|
filtersLogicalOperator
|
|
6381
6380
|
};
|
|
6382
|
-
|
|
6383
|
-
|
|
6384
|
-
|
|
6385
|
-
|
|
6386
|
-
|
|
6387
|
-
|
|
6388
|
-
|
|
6389
|
-
queryParams.spatialDataColumn = spatialDataColumn;
|
|
6390
|
-
queryParams.spatialDataType = spatialDataType;
|
|
6391
|
-
}
|
|
6392
|
-
if (spatialDataType !== "geo") {
|
|
6393
|
-
queryParams.spatialFiltersMode = spatialFiltersMode;
|
|
6381
|
+
queryParams.spatialDataType = spatialDataType;
|
|
6382
|
+
queryParams.spatialDataColumn = spatialDataColumn;
|
|
6383
|
+
if (source.spatialFilter) {
|
|
6384
|
+
queryParams.spatialFilters = { [spatialDataColumn]: source.spatialFilter };
|
|
6385
|
+
if (spatialDataType !== "geo") {
|
|
6386
|
+
queryParams.spatialFiltersMode = spatialFiltersMode;
|
|
6387
|
+
}
|
|
6394
6388
|
}
|
|
6395
6389
|
const urlWithSearchParams = url + "?" + objectToURLSearchParams(queryParams).toString();
|
|
6396
6390
|
const isGet = urlWithSearchParams.length <= REQUEST_GET_MAX_URL_LENGTH;
|
|
@@ -6835,11 +6829,11 @@ function min(values, keys, joinOperation) {
|
|
|
6835
6829
|
Infinity
|
|
6836
6830
|
);
|
|
6837
6831
|
}
|
|
6838
|
-
let
|
|
6832
|
+
let min2 = Number.POSITIVE_INFINITY;
|
|
6839
6833
|
for (const value of values) {
|
|
6840
|
-
|
|
6834
|
+
min2 = Math.min(min2, value);
|
|
6841
6835
|
}
|
|
6842
|
-
return
|
|
6836
|
+
return min2;
|
|
6843
6837
|
}
|
|
6844
6838
|
function max(values, keys, joinOperation) {
|
|
6845
6839
|
const normalizedKeys = normalizeKeys(keys);
|
|
@@ -6849,11 +6843,11 @@ function max(values, keys, joinOperation) {
|
|
|
6849
6843
|
-Infinity
|
|
6850
6844
|
);
|
|
6851
6845
|
}
|
|
6852
|
-
let
|
|
6846
|
+
let max2 = Number.NEGATIVE_INFINITY;
|
|
6853
6847
|
for (const value of values) {
|
|
6854
|
-
|
|
6848
|
+
max2 = Math.max(max2, value);
|
|
6855
6849
|
}
|
|
6856
|
-
return
|
|
6850
|
+
return max2;
|
|
6857
6851
|
}
|
|
6858
6852
|
function normalizeKeys(keys) {
|
|
6859
6853
|
return Array.isArray(keys) ? keys : typeof keys === "string" ? [keys] : void 0;
|
|
@@ -8419,75 +8413,19 @@ function ascending(a, b) {
|
|
|
8419
8413
|
return a == null || b == null ? NaN : a < b ? -1 : a > b ? 1 : a >= b ? 0 : NaN;
|
|
8420
8414
|
}
|
|
8421
8415
|
|
|
8422
|
-
// node_modules/d3-array/src/number.js
|
|
8423
|
-
init_cjs_shims();
|
|
8424
|
-
function* numbers(values, valueof) {
|
|
8425
|
-
if (valueof === void 0) {
|
|
8426
|
-
for (let value of values) {
|
|
8427
|
-
if (value != null && (value = +value) >= value) {
|
|
8428
|
-
yield value;
|
|
8429
|
-
}
|
|
8430
|
-
}
|
|
8431
|
-
} else {
|
|
8432
|
-
let index = -1;
|
|
8433
|
-
for (let value of values) {
|
|
8434
|
-
if ((value = valueof(value, ++index, values)) != null && (value = +value) >= value) {
|
|
8435
|
-
yield value;
|
|
8436
|
-
}
|
|
8437
|
-
}
|
|
8438
|
-
}
|
|
8439
|
-
}
|
|
8440
|
-
|
|
8441
|
-
// node_modules/d3-array/src/deviation.js
|
|
8442
|
-
init_cjs_shims();
|
|
8443
|
-
|
|
8444
|
-
// node_modules/d3-array/src/variance.js
|
|
8445
|
-
init_cjs_shims();
|
|
8446
|
-
function variance(values, valueof) {
|
|
8447
|
-
let count = 0;
|
|
8448
|
-
let delta;
|
|
8449
|
-
let mean = 0;
|
|
8450
|
-
let sum3 = 0;
|
|
8451
|
-
if (valueof === void 0) {
|
|
8452
|
-
for (let value of values) {
|
|
8453
|
-
if (value != null && (value = +value) >= value) {
|
|
8454
|
-
delta = value - mean;
|
|
8455
|
-
mean += delta / ++count;
|
|
8456
|
-
sum3 += delta * (value - mean);
|
|
8457
|
-
}
|
|
8458
|
-
}
|
|
8459
|
-
} else {
|
|
8460
|
-
let index = -1;
|
|
8461
|
-
for (let value of values) {
|
|
8462
|
-
if ((value = valueof(value, ++index, values)) != null && (value = +value) >= value) {
|
|
8463
|
-
delta = value - mean;
|
|
8464
|
-
mean += delta / ++count;
|
|
8465
|
-
sum3 += delta * (value - mean);
|
|
8466
|
-
}
|
|
8467
|
-
}
|
|
8468
|
-
}
|
|
8469
|
-
if (count > 1) return sum3 / (count - 1);
|
|
8470
|
-
}
|
|
8471
|
-
|
|
8472
|
-
// node_modules/d3-array/src/deviation.js
|
|
8473
|
-
function deviation(values, valueof) {
|
|
8474
|
-
const v2 = variance(values, valueof);
|
|
8475
|
-
return v2 ? Math.sqrt(v2) : v2;
|
|
8476
|
-
}
|
|
8477
|
-
|
|
8478
8416
|
// node_modules/d3-array/src/extent.js
|
|
8479
8417
|
init_cjs_shims();
|
|
8480
8418
|
function extent(values, valueof) {
|
|
8481
|
-
let
|
|
8482
|
-
let
|
|
8419
|
+
let min2;
|
|
8420
|
+
let max2;
|
|
8483
8421
|
if (valueof === void 0) {
|
|
8484
8422
|
for (const value of values) {
|
|
8485
8423
|
if (value != null) {
|
|
8486
|
-
if (
|
|
8487
|
-
if (value >= value)
|
|
8424
|
+
if (min2 === void 0) {
|
|
8425
|
+
if (value >= value) min2 = max2 = value;
|
|
8488
8426
|
} else {
|
|
8489
|
-
if (
|
|
8490
|
-
if (
|
|
8427
|
+
if (min2 > value) min2 = value;
|
|
8428
|
+
if (max2 < value) max2 = value;
|
|
8491
8429
|
}
|
|
8492
8430
|
}
|
|
8493
8431
|
}
|
|
@@ -8495,16 +8433,16 @@ function extent(values, valueof) {
|
|
|
8495
8433
|
let index = -1;
|
|
8496
8434
|
for (let value of values) {
|
|
8497
8435
|
if ((value = valueof(value, ++index, values)) != null) {
|
|
8498
|
-
if (
|
|
8499
|
-
if (value >= value)
|
|
8436
|
+
if (min2 === void 0) {
|
|
8437
|
+
if (value >= value) min2 = max2 = value;
|
|
8500
8438
|
} else {
|
|
8501
|
-
if (
|
|
8502
|
-
if (
|
|
8439
|
+
if (min2 > value) min2 = value;
|
|
8440
|
+
if (max2 < value) max2 = value;
|
|
8503
8441
|
}
|
|
8504
8442
|
}
|
|
8505
8443
|
}
|
|
8506
8444
|
}
|
|
8507
|
-
return [
|
|
8445
|
+
return [min2, max2];
|
|
8508
8446
|
}
|
|
8509
8447
|
|
|
8510
8448
|
// node_modules/d3-array/src/group.js
|
|
@@ -8638,109 +8576,6 @@ function groupSort(values, reduce, key) {
|
|
|
8638
8576
|
return (reduce.length !== 2 ? sort(rollup(values, reduce, key), ([ak, av], [bk, bv]) => ascending(av, bv) || ascending(ak, bk)) : sort(group(values, key), ([ak, av], [bk, bv]) => reduce(av, bv) || ascending(ak, bk))).map(([key2]) => key2);
|
|
8639
8577
|
}
|
|
8640
8578
|
|
|
8641
|
-
// node_modules/d3-array/src/quantile.js
|
|
8642
|
-
init_cjs_shims();
|
|
8643
|
-
|
|
8644
|
-
// node_modules/d3-array/src/max.js
|
|
8645
|
-
init_cjs_shims();
|
|
8646
|
-
function max2(values, valueof) {
|
|
8647
|
-
let max3;
|
|
8648
|
-
if (valueof === void 0) {
|
|
8649
|
-
for (const value of values) {
|
|
8650
|
-
if (value != null && (max3 < value || max3 === void 0 && value >= value)) {
|
|
8651
|
-
max3 = value;
|
|
8652
|
-
}
|
|
8653
|
-
}
|
|
8654
|
-
} else {
|
|
8655
|
-
let index = -1;
|
|
8656
|
-
for (let value of values) {
|
|
8657
|
-
if ((value = valueof(value, ++index, values)) != null && (max3 < value || max3 === void 0 && value >= value)) {
|
|
8658
|
-
max3 = value;
|
|
8659
|
-
}
|
|
8660
|
-
}
|
|
8661
|
-
}
|
|
8662
|
-
return max3;
|
|
8663
|
-
}
|
|
8664
|
-
|
|
8665
|
-
// node_modules/d3-array/src/min.js
|
|
8666
|
-
init_cjs_shims();
|
|
8667
|
-
function min2(values, valueof) {
|
|
8668
|
-
let min3;
|
|
8669
|
-
if (valueof === void 0) {
|
|
8670
|
-
for (const value of values) {
|
|
8671
|
-
if (value != null && (min3 > value || min3 === void 0 && value >= value)) {
|
|
8672
|
-
min3 = value;
|
|
8673
|
-
}
|
|
8674
|
-
}
|
|
8675
|
-
} else {
|
|
8676
|
-
let index = -1;
|
|
8677
|
-
for (let value of values) {
|
|
8678
|
-
if ((value = valueof(value, ++index, values)) != null && (min3 > value || min3 === void 0 && value >= value)) {
|
|
8679
|
-
min3 = value;
|
|
8680
|
-
}
|
|
8681
|
-
}
|
|
8682
|
-
}
|
|
8683
|
-
return min3;
|
|
8684
|
-
}
|
|
8685
|
-
|
|
8686
|
-
// node_modules/d3-array/src/quickselect.js
|
|
8687
|
-
init_cjs_shims();
|
|
8688
|
-
function quickselect(array, k, left = 0, right = Infinity, compare2) {
|
|
8689
|
-
k = Math.floor(k);
|
|
8690
|
-
left = Math.floor(Math.max(0, left));
|
|
8691
|
-
right = Math.floor(Math.min(array.length - 1, right));
|
|
8692
|
-
if (!(left <= k && k <= right)) return array;
|
|
8693
|
-
compare2 = compare2 === void 0 ? ascendingDefined : compareDefined(compare2);
|
|
8694
|
-
while (right > left) {
|
|
8695
|
-
if (right - left > 600) {
|
|
8696
|
-
const n = right - left + 1;
|
|
8697
|
-
const m = k - left + 1;
|
|
8698
|
-
const z = Math.log(n);
|
|
8699
|
-
const s = 0.5 * Math.exp(2 * z / 3);
|
|
8700
|
-
const sd = 0.5 * Math.sqrt(z * s * (n - s) / n) * (m - n / 2 < 0 ? -1 : 1);
|
|
8701
|
-
const newLeft = Math.max(left, Math.floor(k - m * s / n + sd));
|
|
8702
|
-
const newRight = Math.min(right, Math.floor(k + (n - m) * s / n + sd));
|
|
8703
|
-
quickselect(array, k, newLeft, newRight, compare2);
|
|
8704
|
-
}
|
|
8705
|
-
const t = array[k];
|
|
8706
|
-
let i = left;
|
|
8707
|
-
let j = right;
|
|
8708
|
-
swap(array, left, k);
|
|
8709
|
-
if (compare2(array[right], t) > 0) swap(array, left, right);
|
|
8710
|
-
while (i < j) {
|
|
8711
|
-
swap(array, i, j), ++i, --j;
|
|
8712
|
-
while (compare2(array[i], t) < 0) ++i;
|
|
8713
|
-
while (compare2(array[j], t) > 0) --j;
|
|
8714
|
-
}
|
|
8715
|
-
if (compare2(array[left], t) === 0) swap(array, left, j);
|
|
8716
|
-
else ++j, swap(array, j, right);
|
|
8717
|
-
if (j <= k) left = j + 1;
|
|
8718
|
-
if (k <= j) right = j - 1;
|
|
8719
|
-
}
|
|
8720
|
-
return array;
|
|
8721
|
-
}
|
|
8722
|
-
function swap(array, i, j) {
|
|
8723
|
-
const t = array[i];
|
|
8724
|
-
array[i] = array[j];
|
|
8725
|
-
array[j] = t;
|
|
8726
|
-
}
|
|
8727
|
-
|
|
8728
|
-
// node_modules/d3-array/src/quantile.js
|
|
8729
|
-
function quantile(values, p, valueof) {
|
|
8730
|
-
values = Float64Array.from(numbers(values, valueof));
|
|
8731
|
-
if (!(n = values.length) || isNaN(p = +p)) return;
|
|
8732
|
-
if (p <= 0 || n < 2) return min2(values);
|
|
8733
|
-
if (p >= 1) return max2(values);
|
|
8734
|
-
var n, i = (n - 1) * p, i0 = Math.floor(i), value0 = max2(quickselect(values, i0).subarray(0, i0 + 1)), value1 = min2(values.subarray(i0 + 1));
|
|
8735
|
-
return value0 + (value1 - value0) * (i - i0);
|
|
8736
|
-
}
|
|
8737
|
-
|
|
8738
|
-
// node_modules/d3-array/src/median.js
|
|
8739
|
-
init_cjs_shims();
|
|
8740
|
-
function median(values, valueof) {
|
|
8741
|
-
return quantile(values, 0.5, valueof);
|
|
8742
|
-
}
|
|
8743
|
-
|
|
8744
8579
|
// node_modules/d3-color/src/index.js
|
|
8745
8580
|
init_cjs_shims();
|
|
8746
8581
|
|
|
@@ -9035,12 +8870,12 @@ function hslConvert(o) {
|
|
|
9035
8870
|
if (!o) return new Hsl();
|
|
9036
8871
|
if (o instanceof Hsl) return o;
|
|
9037
8872
|
o = o.rgb();
|
|
9038
|
-
var r = o.r / 255, g = o.g / 255, b = o.b / 255,
|
|
8873
|
+
var r = o.r / 255, g = o.g / 255, b = o.b / 255, min2 = Math.min(r, g, b), max2 = Math.max(r, g, b), h = NaN, s = max2 - min2, l = (max2 + min2) / 2;
|
|
9039
8874
|
if (s) {
|
|
9040
|
-
if (r ===
|
|
9041
|
-
else if (g ===
|
|
8875
|
+
if (r === max2) h = (g - b) / s + (g < b) * 6;
|
|
8876
|
+
else if (g === max2) h = (b - r) / s + 2;
|
|
9042
8877
|
else h = (r - g) / s + 4;
|
|
9043
|
-
s /= l < 0.5 ?
|
|
8878
|
+
s /= l < 0.5 ? max2 + min2 : 2 - max2 - min2;
|
|
9044
8879
|
h *= 60;
|
|
9045
8880
|
} else {
|
|
9046
8881
|
s = l > 0 && l < 1 ? 0 : h;
|
|
@@ -9180,25 +9015,11 @@ function identity2(v2) {
|
|
|
9180
9015
|
return v2;
|
|
9181
9016
|
}
|
|
9182
9017
|
var UNKNOWN_COLOR = "#868d91";
|
|
9183
|
-
var AGGREGATION = {
|
|
9184
|
-
average: "MEAN",
|
|
9185
|
-
maximum: "MAX",
|
|
9186
|
-
minimum: "MIN",
|
|
9187
|
-
sum: "SUM"
|
|
9188
|
-
};
|
|
9189
9018
|
var OPACITY_MAP = {
|
|
9190
9019
|
getFillColor: "opacity",
|
|
9191
9020
|
getLineColor: "strokeOpacity",
|
|
9192
9021
|
getTextColor: "opacity"
|
|
9193
9022
|
};
|
|
9194
|
-
var AGGREGATION_FUNC = {
|
|
9195
|
-
"count unique": (values, accessor) => groupSort(values, (v2) => v2.length, accessor).length,
|
|
9196
|
-
median,
|
|
9197
|
-
// Unfortunately mode() is only available in d3-array@3+ which is ESM only
|
|
9198
|
-
mode: (values, accessor) => groupSort(values, (v2) => v2.length, accessor).pop(),
|
|
9199
|
-
stddev: deviation,
|
|
9200
|
-
variance
|
|
9201
|
-
};
|
|
9202
9023
|
var hexToRGBA = (c) => {
|
|
9203
9024
|
const { r, g, b, opacity } = rgb(c);
|
|
9204
9025
|
return [r, g, b, 255 * opacity];
|
|
@@ -9294,11 +9115,11 @@ function domainFromAttribute(attribute, scaleType, scaleLength) {
|
|
|
9294
9115
|
if (scaleType === "quantile" && attribute.quantiles) {
|
|
9295
9116
|
return attribute.quantiles.global ? attribute.quantiles.global[scaleLength] : attribute.quantiles[scaleLength];
|
|
9296
9117
|
}
|
|
9297
|
-
let { min:
|
|
9298
|
-
if (scaleType === "log" &&
|
|
9299
|
-
|
|
9118
|
+
let { min: min2 } = attribute;
|
|
9119
|
+
if (scaleType === "log" && min2 === 0) {
|
|
9120
|
+
min2 = 1e-5;
|
|
9300
9121
|
}
|
|
9301
|
-
return [
|
|
9122
|
+
return [min2, attribute.max];
|
|
9302
9123
|
}
|
|
9303
9124
|
function domainFromValues(values, scaleType) {
|
|
9304
9125
|
if (scaleType === "ordinal" || scaleType === "point") {
|
|
@@ -9356,11 +9177,6 @@ function findAccessorKey(keys, properties) {
|
|
|
9356
9177
|
}
|
|
9357
9178
|
return keys;
|
|
9358
9179
|
}
|
|
9359
|
-
function getColorValueAccessor({ name }, colorAggregation, data) {
|
|
9360
|
-
const aggregator = AGGREGATION_FUNC[colorAggregation];
|
|
9361
|
-
const accessor = (values) => aggregator(values, (p) => p[name]);
|
|
9362
|
-
return normalizeAccessor(accessor, data);
|
|
9363
|
-
}
|
|
9364
9180
|
function getColorAccessor({ name, colorColumn }, scaleType, { aggregation, range }, opacity, data) {
|
|
9365
9181
|
const scale2 = calculateLayerScale(
|
|
9366
9182
|
colorColumn || name,
|
|
@@ -9378,7 +9194,7 @@ function getColorAccessor({ name, colorColumn }, scaleType, { aggregation, range
|
|
|
9378
9194
|
const { r, g, b } = rgb(scale2(propertyValue));
|
|
9379
9195
|
return [r, g, b, propertyValue === null ? 0 : alpha];
|
|
9380
9196
|
};
|
|
9381
|
-
return normalizeAccessor(accessor, data);
|
|
9197
|
+
return { accessor: normalizeAccessor(accessor, data), scale: scale2 };
|
|
9382
9198
|
}
|
|
9383
9199
|
function calculateLayerScale(name, scaleType, range, data) {
|
|
9384
9200
|
const scale2 = SCALE_FUNCS[scaleType]();
|
|
@@ -9465,7 +9281,7 @@ function getSizeAccessor({ name }, scaleType, aggregation, range, data) {
|
|
|
9465
9281
|
const propertyValue = properties[accessorKeys[0]];
|
|
9466
9282
|
return scale2(propertyValue);
|
|
9467
9283
|
};
|
|
9468
|
-
return normalizeAccessor(accessor, data);
|
|
9284
|
+
return { accessor: normalizeAccessor(accessor, data), scale: scale2 };
|
|
9469
9285
|
}
|
|
9470
9286
|
var FORMATS = {
|
|
9471
9287
|
date: formatDate,
|
|
@@ -9482,10 +9298,10 @@ function getTextAccessor({ name, type }, data) {
|
|
|
9482
9298
|
return normalizeAccessor(accessor, data);
|
|
9483
9299
|
}
|
|
9484
9300
|
function calculateClusterRadius(properties, stats, radiusRange, column) {
|
|
9485
|
-
const { min:
|
|
9301
|
+
const { min: min2, max: max2 } = stats[column];
|
|
9486
9302
|
const value = properties[column];
|
|
9487
|
-
if (
|
|
9488
|
-
const normalizedValue = (value -
|
|
9303
|
+
if (min2 === max2) return radiusRange[1];
|
|
9304
|
+
const normalizedValue = (value - min2) / (max2 - min2);
|
|
9489
9305
|
return radiusRange[0] + normalizedValue * (radiusRange[1] - radiusRange[0]);
|
|
9490
9306
|
}
|
|
9491
9307
|
function getDefaultAggregationExpColumnAliasForLayerType(layerType, provider, schema) {
|
|
@@ -9546,6 +9362,14 @@ function parseMap(json) {
|
|
|
9546
9362
|
assert2(data, `No data loaded for dataId: ${dataId}`);
|
|
9547
9363
|
const { propMap, defaultProps: defaultProps2 } = getLayerProps(type, config3, dataset);
|
|
9548
9364
|
const styleProps = createStyleProps(config3, propMap);
|
|
9365
|
+
const { channelProps, scales } = createChannelProps(
|
|
9366
|
+
id,
|
|
9367
|
+
type,
|
|
9368
|
+
config3,
|
|
9369
|
+
visualChannels,
|
|
9370
|
+
data,
|
|
9371
|
+
dataset
|
|
9372
|
+
);
|
|
9549
9373
|
const layer = {
|
|
9550
9374
|
type,
|
|
9551
9375
|
filters: isEmptyObject(filters) || isRemoteCalculationSupported(dataset) ? void 0 : filters[dataId],
|
|
@@ -9555,22 +9379,15 @@ function parseMap(json) {
|
|
|
9555
9379
|
...defaultProps2,
|
|
9556
9380
|
...createInteractionProps(interactionConfig),
|
|
9557
9381
|
...styleProps,
|
|
9558
|
-
...
|
|
9559
|
-
id,
|
|
9560
|
-
type,
|
|
9561
|
-
config3,
|
|
9562
|
-
visualChannels,
|
|
9563
|
-
data,
|
|
9564
|
-
dataset
|
|
9565
|
-
),
|
|
9566
|
-
// Must come after style
|
|
9382
|
+
...channelProps,
|
|
9567
9383
|
...createParametersProp(
|
|
9568
9384
|
layerBlending,
|
|
9569
9385
|
styleProps.parameters || {}
|
|
9570
9386
|
),
|
|
9571
9387
|
// Must come after style
|
|
9572
9388
|
...createLoadOptions(token)
|
|
9573
|
-
}
|
|
9389
|
+
},
|
|
9390
|
+
scales
|
|
9574
9391
|
};
|
|
9575
9392
|
return layer;
|
|
9576
9393
|
} catch (e) {
|
|
@@ -9637,69 +9454,47 @@ function createStyleProps(config2, mapping) {
|
|
|
9637
9454
|
result.highlightColor = config2.visConfig.enable3d ? [255, 255, 255, 60] : [252, 242, 26, 255];
|
|
9638
9455
|
return result;
|
|
9639
9456
|
}
|
|
9640
|
-
function
|
|
9457
|
+
function domainAndRangeFromScale(scale2) {
|
|
9458
|
+
return {
|
|
9459
|
+
domain: scale2.domain(),
|
|
9460
|
+
range: scale2.range()
|
|
9461
|
+
};
|
|
9462
|
+
}
|
|
9463
|
+
function createChannelProps(id, layerType, config2, visualChannels, data, dataset) {
|
|
9641
9464
|
const {
|
|
9642
9465
|
colorField,
|
|
9643
9466
|
colorScale,
|
|
9644
9467
|
radiusField,
|
|
9645
9468
|
radiusScale,
|
|
9646
|
-
sizeField,
|
|
9647
|
-
sizeScale,
|
|
9648
9469
|
strokeColorField,
|
|
9649
9470
|
strokeColorScale,
|
|
9650
9471
|
weightField
|
|
9651
9472
|
} = visualChannels;
|
|
9652
|
-
|
|
9653
|
-
if (type === "hexagonId") {
|
|
9654
|
-
heightField = sizeField;
|
|
9655
|
-
heightScale = sizeScale;
|
|
9656
|
-
}
|
|
9473
|
+
const { heightField, heightScale } = visualChannels;
|
|
9657
9474
|
const { textLabel, visConfig } = config2;
|
|
9658
9475
|
const result = {};
|
|
9659
|
-
|
|
9660
|
-
|
|
9661
|
-
if (colorField) {
|
|
9662
|
-
const { colorAggregation } = config2.visConfig;
|
|
9663
|
-
if (!AGGREGATION[colorAggregation]) {
|
|
9664
|
-
result.getColorValue = getColorValueAccessor(
|
|
9665
|
-
colorField,
|
|
9666
|
-
colorAggregation,
|
|
9667
|
-
data
|
|
9668
|
-
);
|
|
9669
|
-
} else {
|
|
9670
|
-
result.getColorWeight = (d) => d[colorField.name];
|
|
9671
|
-
}
|
|
9672
|
-
}
|
|
9673
|
-
} else if (colorField) {
|
|
9476
|
+
const scales = {};
|
|
9477
|
+
if (colorField) {
|
|
9674
9478
|
const { colorAggregation: aggregation, colorRange: range } = visConfig;
|
|
9675
|
-
|
|
9479
|
+
const { accessor, scale: scale2 } = getColorAccessor(
|
|
9676
9480
|
colorField,
|
|
9677
|
-
// @ts-ignore
|
|
9678
9481
|
colorScale,
|
|
9679
9482
|
{ aggregation, range },
|
|
9680
9483
|
visConfig.opacity,
|
|
9681
9484
|
data
|
|
9682
9485
|
);
|
|
9486
|
+
result.getFillColor = accessor;
|
|
9487
|
+
scales.fillColor = {
|
|
9488
|
+
field: colorField,
|
|
9489
|
+
type: colorScale,
|
|
9490
|
+
...domainAndRangeFromScale(scale2)
|
|
9491
|
+
};
|
|
9492
|
+
} else if (visConfig.filled) {
|
|
9493
|
+
scales.fillColor = {};
|
|
9683
9494
|
}
|
|
9684
|
-
if (
|
|
9685
|
-
const altitude = config2.columns?.altitude;
|
|
9686
|
-
if (altitude) {
|
|
9687
|
-
result.dataTransform = (data2) => {
|
|
9688
|
-
data2.features.forEach(
|
|
9689
|
-
({ geometry, properties }) => {
|
|
9690
|
-
const { type: type2, coordinates } = geometry;
|
|
9691
|
-
if (type2 === "Point") {
|
|
9692
|
-
coordinates[2] = properties[altitude];
|
|
9693
|
-
}
|
|
9694
|
-
}
|
|
9695
|
-
);
|
|
9696
|
-
return data2;
|
|
9697
|
-
};
|
|
9698
|
-
}
|
|
9699
|
-
}
|
|
9700
|
-
if (type === "clusterTile") {
|
|
9495
|
+
if (layerType === "clusterTile") {
|
|
9701
9496
|
const aggregationExpAlias = getDefaultAggregationExpColumnAliasForLayerType(
|
|
9702
|
-
|
|
9497
|
+
layerType,
|
|
9703
9498
|
dataset.providerId,
|
|
9704
9499
|
data.schema
|
|
9705
9500
|
);
|
|
@@ -9738,49 +9533,67 @@ function createChannelProps(id, type, config2, visualChannels, data, dataset) {
|
|
|
9738
9533
|
return calculateClusterTextFontSize(radius);
|
|
9739
9534
|
};
|
|
9740
9535
|
}
|
|
9741
|
-
if (radiusField
|
|
9742
|
-
|
|
9743
|
-
|
|
9744
|
-
|
|
9745
|
-
// @ts-ignore
|
|
9746
|
-
radiusScale || sizeScale,
|
|
9536
|
+
if (radiusField) {
|
|
9537
|
+
const { accessor, scale: scale2 } = getSizeAccessor(
|
|
9538
|
+
radiusField,
|
|
9539
|
+
radiusScale,
|
|
9747
9540
|
visConfig.sizeAggregation,
|
|
9748
9541
|
visConfig.radiusRange || visConfig.sizeRange,
|
|
9749
9542
|
data
|
|
9750
9543
|
);
|
|
9544
|
+
result.getPointRadius = accessor;
|
|
9545
|
+
scales.pointRadius = {
|
|
9546
|
+
field: radiusField,
|
|
9547
|
+
type: radiusScale || "identity",
|
|
9548
|
+
...domainAndRangeFromScale(scale2)
|
|
9549
|
+
};
|
|
9751
9550
|
}
|
|
9752
9551
|
if (strokeColorField) {
|
|
9753
|
-
const
|
|
9754
|
-
const opacity = visConfig.strokeOpacity !== void 0 ? visConfig.strokeOpacity : fallbackOpacity;
|
|
9552
|
+
const opacity = visConfig.strokeOpacity !== void 0 ? visConfig.strokeOpacity : 1;
|
|
9755
9553
|
const { strokeColorAggregation: aggregation, strokeColorRange: range } = visConfig;
|
|
9756
|
-
|
|
9554
|
+
const { accessor, scale: scale2 } = getColorAccessor(
|
|
9757
9555
|
strokeColorField,
|
|
9758
|
-
// @ts-ignore
|
|
9759
9556
|
strokeColorScale,
|
|
9760
|
-
// @ts-ignore
|
|
9761
9557
|
{ aggregation, range },
|
|
9762
9558
|
opacity,
|
|
9763
9559
|
data
|
|
9764
9560
|
);
|
|
9561
|
+
result.getLineColor = accessor;
|
|
9562
|
+
scales.lineColor = {
|
|
9563
|
+
field: strokeColorField,
|
|
9564
|
+
type: strokeColorScale,
|
|
9565
|
+
...domainAndRangeFromScale(scale2)
|
|
9566
|
+
};
|
|
9765
9567
|
}
|
|
9766
9568
|
if (heightField && visConfig.enable3d) {
|
|
9767
|
-
|
|
9569
|
+
const { accessor, scale: scale2 } = getSizeAccessor(
|
|
9768
9570
|
heightField,
|
|
9769
|
-
// @ts-ignore
|
|
9770
9571
|
heightScale,
|
|
9771
9572
|
visConfig.heightAggregation,
|
|
9772
9573
|
visConfig.heightRange || visConfig.sizeRange,
|
|
9773
9574
|
data
|
|
9774
9575
|
);
|
|
9576
|
+
result.getElevation = accessor;
|
|
9577
|
+
scales.elevation = {
|
|
9578
|
+
field: heightField,
|
|
9579
|
+
type: heightScale || "identity",
|
|
9580
|
+
...domainAndRangeFromScale(scale2)
|
|
9581
|
+
};
|
|
9775
9582
|
}
|
|
9776
9583
|
if (weightField) {
|
|
9777
|
-
|
|
9584
|
+
const { accessor, scale: scale2 } = getSizeAccessor(
|
|
9778
9585
|
weightField,
|
|
9779
9586
|
void 0,
|
|
9780
9587
|
visConfig.weightAggregation,
|
|
9781
9588
|
void 0,
|
|
9782
9589
|
data
|
|
9783
9590
|
);
|
|
9591
|
+
result.getWeight = accessor;
|
|
9592
|
+
scales.weight = {
|
|
9593
|
+
field: weightField,
|
|
9594
|
+
type: "identity",
|
|
9595
|
+
...domainAndRangeFromScale(scale2)
|
|
9596
|
+
};
|
|
9784
9597
|
}
|
|
9785
9598
|
if (visConfig.customMarkers) {
|
|
9786
9599
|
const maxIconSize = getMaxMarkerSize(visConfig, visualChannels);
|
|
@@ -9818,17 +9631,16 @@ function createChannelProps(id, type, config2, visualChannels, data, dataset) {
|
|
|
9818
9631
|
result.getIconSize = getPointRadius;
|
|
9819
9632
|
}
|
|
9820
9633
|
if (visualChannels.rotationField) {
|
|
9821
|
-
|
|
9822
|
-
|
|
9823
|
-
|
|
9824
|
-
|
|
9825
|
-
|
|
9826
|
-
|
|
9827
|
-
data
|
|
9828
|
-
)
|
|
9634
|
+
const { accessor } = getSizeAccessor(
|
|
9635
|
+
visualChannels.rotationField,
|
|
9636
|
+
void 0,
|
|
9637
|
+
null,
|
|
9638
|
+
void 0,
|
|
9639
|
+
data
|
|
9829
9640
|
);
|
|
9641
|
+
result.getIconAngle = negateAccessor(accessor);
|
|
9830
9642
|
}
|
|
9831
|
-
} else if (
|
|
9643
|
+
} else if (layerType === "tileset") {
|
|
9832
9644
|
result.pointType = "circle";
|
|
9833
9645
|
}
|
|
9834
9646
|
if (textLabel && textLabel.length && textLabel[0].field) {
|
|
@@ -9871,7 +9683,7 @@ function createChannelProps(id, type, config2, visualChannels, data, dataset) {
|
|
|
9871
9683
|
}
|
|
9872
9684
|
};
|
|
9873
9685
|
}
|
|
9874
|
-
return result;
|
|
9686
|
+
return { channelProps: result, scales };
|
|
9875
9687
|
}
|
|
9876
9688
|
function createLoadOptions(accessToken) {
|
|
9877
9689
|
return {
|
|
@@ -10444,7 +10256,6 @@ function _getHexagonResolution(viewport, tileSize) {
|
|
|
10444
10256
|
}
|
|
10445
10257
|
// Annotate the CommonJS export names for ESM import in node:
|
|
10446
10258
|
0 && (module.exports = {
|
|
10447
|
-
AGGREGATION,
|
|
10448
10259
|
ApiVersion,
|
|
10449
10260
|
BASEMAP,
|
|
10450
10261
|
CartoAPIError,
|
|
@@ -10494,7 +10305,6 @@ function _getHexagonResolution(viewport, tileSize) {
|
|
|
10494
10305
|
getApplicableFilters,
|
|
10495
10306
|
getClient,
|
|
10496
10307
|
getColorAccessor,
|
|
10497
|
-
getColorValueAccessor,
|
|
10498
10308
|
getColumnNameFromGeoColumn,
|
|
10499
10309
|
getDataFilterExtensionProps,
|
|
10500
10310
|
getDefaultAggregationExpColumnAliasForLayerType,
|