@carto/api-client 0.5.15-alpha.raster-2 → 0.5.15-alpha.raster-4
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 +167 -133
- package/build/api-client.cjs.map +1 -1
- package/build/api-client.d.cts +28 -17
- package/build/api-client.d.ts +28 -17
- package/build/api-client.js +167 -133
- package/build/api-client.js.map +1 -1
- package/package.json +1 -1
- package/src/fetch-map/layer-map.ts +71 -27
- package/src/fetch-map/parse-map.ts +136 -126
- package/src/fetch-map/types.ts +7 -7
package/build/api-client.cjs
CHANGED
|
@@ -9541,7 +9541,19 @@ var SCALE_FUNCS = {
|
|
|
9541
9541
|
function identity2(v2) {
|
|
9542
9542
|
return v2;
|
|
9543
9543
|
}
|
|
9544
|
+
var hexToRGB = (c) => {
|
|
9545
|
+
const { r, g, b } = rgb(c);
|
|
9546
|
+
return [r, g, b];
|
|
9547
|
+
};
|
|
9548
|
+
var rgbToHex = (c) => {
|
|
9549
|
+
const [r, g, b] = c;
|
|
9550
|
+
const rStr = r.toString(16).padStart(2, "0");
|
|
9551
|
+
const gStr = g.toString(16).padStart(2, "0");
|
|
9552
|
+
const bStr = b.toString(16).padStart(2, "0");
|
|
9553
|
+
return `#${rStr}${gStr}${bStr}`.toUpperCase();
|
|
9554
|
+
};
|
|
9544
9555
|
var UNKNOWN_COLOR = "#868d91";
|
|
9556
|
+
var UNKNOWN_COLOR_RGB = hexToRGB(UNKNOWN_COLOR);
|
|
9545
9557
|
var OPACITY_MAP = {
|
|
9546
9558
|
getFillColor: "opacity",
|
|
9547
9559
|
getLineColor: "strokeOpacity",
|
|
@@ -9648,13 +9660,6 @@ function getLayerProps(type, config2, dataset) {
|
|
|
9648
9660
|
};
|
|
9649
9661
|
}
|
|
9650
9662
|
function domainFromAttribute(attribute, scaleType, scaleLength) {
|
|
9651
|
-
if (scaleType === "log10steps" && attribute.min !== void 0 && attribute.max !== void 0) {
|
|
9652
|
-
return getLog10ScaleSteps({
|
|
9653
|
-
min: attribute.min,
|
|
9654
|
-
max: attribute.max,
|
|
9655
|
-
steps: scaleLength
|
|
9656
|
-
});
|
|
9657
|
-
}
|
|
9658
9663
|
if (scaleType === "ordinal" || scaleType === "point") {
|
|
9659
9664
|
if (!attribute.categories) {
|
|
9660
9665
|
return [0, 1];
|
|
@@ -9729,7 +9734,7 @@ function findAccessorKey(keys, properties) {
|
|
|
9729
9734
|
return keys;
|
|
9730
9735
|
}
|
|
9731
9736
|
function getColorAccessor({ name, colorColumn }, scaleType, { aggregation, range }, opacity, data) {
|
|
9732
|
-
const scale2 = calculateLayerScale(
|
|
9737
|
+
const { scale: scale2, domain } = calculateLayerScale(
|
|
9733
9738
|
colorColumn || name,
|
|
9734
9739
|
scaleType,
|
|
9735
9740
|
range,
|
|
@@ -9742,23 +9747,36 @@ function getColorAccessor({ name, colorColumn }, scaleType, { aggregation, range
|
|
|
9742
9747
|
accessorKeys = findAccessorKey(accessorKeys, properties);
|
|
9743
9748
|
}
|
|
9744
9749
|
const propertyValue = properties[accessorKeys[0]];
|
|
9745
|
-
const
|
|
9750
|
+
const [r, g, b] = scale2(propertyValue);
|
|
9746
9751
|
return [r, g, b, propertyValue === null ? 0 : alpha];
|
|
9747
9752
|
};
|
|
9748
|
-
return {
|
|
9753
|
+
return {
|
|
9754
|
+
accessor: normalizeAccessor(accessor, data),
|
|
9755
|
+
scaleDomain: scale2.domain(),
|
|
9756
|
+
domain,
|
|
9757
|
+
range: scale2.range().map(rgbToHex)
|
|
9758
|
+
};
|
|
9749
9759
|
}
|
|
9750
9760
|
function calculateLayerScale(name, scaleType, range, data) {
|
|
9751
9761
|
let domain = [];
|
|
9762
|
+
let scaleDomain;
|
|
9752
9763
|
let scaleColor = [];
|
|
9753
9764
|
const { colors } = range;
|
|
9754
9765
|
if (scaleType === "custom") {
|
|
9766
|
+
domain = calculateDomain(data, name, scaleType, colors.length);
|
|
9767
|
+
const [min2, max2] = domain;
|
|
9755
9768
|
if (range.uiCustomScaleType === "logarithmic") {
|
|
9756
|
-
|
|
9769
|
+
scaleDomain = getLog10ScaleSteps({
|
|
9770
|
+
min: min2,
|
|
9771
|
+
max: max2,
|
|
9772
|
+
steps: colors.length
|
|
9773
|
+
});
|
|
9757
9774
|
scaleColor = colors;
|
|
9758
9775
|
} else if (range.colorMap) {
|
|
9759
9776
|
const { colorMap } = range;
|
|
9777
|
+
scaleDomain = [];
|
|
9760
9778
|
colorMap.forEach(([value, color2]) => {
|
|
9761
|
-
|
|
9779
|
+
scaleDomain.push(Number(value));
|
|
9762
9780
|
scaleColor.push(color2);
|
|
9763
9781
|
});
|
|
9764
9782
|
}
|
|
@@ -9769,7 +9787,15 @@ function calculateLayerScale(name, scaleType, range, data) {
|
|
|
9769
9787
|
domain = domain.slice(0, scaleColor.length);
|
|
9770
9788
|
}
|
|
9771
9789
|
}
|
|
9772
|
-
return
|
|
9790
|
+
return {
|
|
9791
|
+
scale: createColorScale(
|
|
9792
|
+
scaleType,
|
|
9793
|
+
scaleDomain || domain,
|
|
9794
|
+
scaleColor.map(hexToRGB),
|
|
9795
|
+
UNKNOWN_COLOR_RGB
|
|
9796
|
+
),
|
|
9797
|
+
domain
|
|
9798
|
+
};
|
|
9773
9799
|
}
|
|
9774
9800
|
function createColorScale(scaleType, domain, range, unknown) {
|
|
9775
9801
|
const scale2 = SCALE_FUNCS[scaleType]();
|
|
@@ -9825,9 +9851,13 @@ function negateAccessor(accessor) {
|
|
|
9825
9851
|
}
|
|
9826
9852
|
function getSizeAccessor({ name }, scaleType, aggregation, range, data) {
|
|
9827
9853
|
const scale2 = scaleType ? SCALE_FUNCS[scaleType]() : identity2;
|
|
9828
|
-
|
|
9854
|
+
let domain = [];
|
|
9855
|
+
if (scaleType && range) {
|
|
9829
9856
|
if (aggregation !== AggregationTypes.Count) {
|
|
9830
|
-
|
|
9857
|
+
domain = calculateDomain(data, name, scaleType);
|
|
9858
|
+
scale2.domain(domain);
|
|
9859
|
+
} else {
|
|
9860
|
+
domain = scale2.domain();
|
|
9831
9861
|
}
|
|
9832
9862
|
scale2.range(range);
|
|
9833
9863
|
}
|
|
@@ -9839,7 +9869,12 @@ function getSizeAccessor({ name }, scaleType, aggregation, range, data) {
|
|
|
9839
9869
|
const propertyValue = properties[accessorKeys[0]];
|
|
9840
9870
|
return scale2(propertyValue);
|
|
9841
9871
|
};
|
|
9842
|
-
return {
|
|
9872
|
+
return {
|
|
9873
|
+
accessor: normalizeAccessor(accessor, data),
|
|
9874
|
+
domain,
|
|
9875
|
+
scaleDomain: domain,
|
|
9876
|
+
range
|
|
9877
|
+
};
|
|
9843
9878
|
}
|
|
9844
9879
|
var FORMATS = {
|
|
9845
9880
|
date: formatDate,
|
|
@@ -10184,7 +10219,7 @@ function getRasterTileLayerStylePropsScaledBand({
|
|
|
10184
10219
|
const scaleFun = createColorScale(
|
|
10185
10220
|
scaleType,
|
|
10186
10221
|
domain,
|
|
10187
|
-
colorRange.colors.map(
|
|
10222
|
+
colorRange.colors.map(hexToRGB2),
|
|
10188
10223
|
UNKNOWN_COLOR2
|
|
10189
10224
|
);
|
|
10190
10225
|
const bandColorScaleDataTransform = createBandColorScaleDataTransform({
|
|
@@ -10252,7 +10287,7 @@ function bufferSetRgba(target, index, r, g, b, a) {
|
|
|
10252
10287
|
target[index + 2] = b;
|
|
10253
10288
|
target[index + 3] = a;
|
|
10254
10289
|
}
|
|
10255
|
-
function
|
|
10290
|
+
function hexToRGB2(hexColor) {
|
|
10256
10291
|
const r = parseInt(hexColor.slice(1, 3), 16);
|
|
10257
10292
|
const g = parseInt(hexColor.slice(3, 5), 16);
|
|
10258
10293
|
const b = parseInt(hexColor.slice(5, 7), 16);
|
|
@@ -10397,24 +10432,7 @@ function createStyleProps(config2, mapping) {
|
|
|
10397
10432
|
result.highlightColor = config2.visConfig.enable3d ? [255, 255, 255, 60] : [252, 242, 26, 255];
|
|
10398
10433
|
return result;
|
|
10399
10434
|
}
|
|
10400
|
-
function domainAndRangeFromScale(scale2) {
|
|
10401
|
-
return {
|
|
10402
|
-
domain: scale2.domain(),
|
|
10403
|
-
range: scale2.range()
|
|
10404
|
-
};
|
|
10405
|
-
}
|
|
10406
10435
|
function createChannelProps(id, layerType, config2, visualChannels, data, dataset) {
|
|
10407
|
-
const {
|
|
10408
|
-
colorField,
|
|
10409
|
-
colorScale,
|
|
10410
|
-
radiusField,
|
|
10411
|
-
radiusScale,
|
|
10412
|
-
strokeColorField,
|
|
10413
|
-
strokeColorScale,
|
|
10414
|
-
sizeField: strokeWidthField,
|
|
10415
|
-
sizeScale: strokeWidthScale,
|
|
10416
|
-
weightField
|
|
10417
|
-
} = visualChannels;
|
|
10418
10436
|
if (layerType === "raster") {
|
|
10419
10437
|
const rasterMetadata = data.raster_metadata;
|
|
10420
10438
|
if (!rasterMetadata) {
|
|
@@ -10432,6 +10450,7 @@ function createChannelProps(id, layerType, config2, visualChannels, data, datase
|
|
|
10432
10450
|
visualChannels
|
|
10433
10451
|
}),
|
|
10434
10452
|
scales: {}
|
|
10453
|
+
// TODO
|
|
10435
10454
|
};
|
|
10436
10455
|
} else {
|
|
10437
10456
|
return {
|
|
@@ -10441,40 +10460,35 @@ function createChannelProps(id, layerType, config2, visualChannels, data, datase
|
|
|
10441
10460
|
rasterMetadata
|
|
10442
10461
|
}),
|
|
10443
10462
|
scales: {
|
|
10444
|
-
|
|
10445
|
-
fillColor: {
|
|
10446
|
-
field: colorField,
|
|
10447
|
-
type: "ordinal",
|
|
10448
|
-
domain: [],
|
|
10449
|
-
range: []
|
|
10450
|
-
}
|
|
10451
|
-
}
|
|
10463
|
+
// TODO
|
|
10452
10464
|
}
|
|
10453
10465
|
};
|
|
10454
10466
|
}
|
|
10455
10467
|
}
|
|
10456
|
-
const { heightField, heightScale } = visualChannels;
|
|
10457
10468
|
const { textLabel, visConfig } = config2;
|
|
10458
10469
|
const result = {};
|
|
10459
10470
|
const updateTriggers = {};
|
|
10460
10471
|
const scales = {};
|
|
10461
|
-
|
|
10462
|
-
const {
|
|
10463
|
-
const {
|
|
10464
|
-
|
|
10465
|
-
|
|
10466
|
-
|
|
10467
|
-
|
|
10468
|
-
|
|
10469
|
-
|
|
10470
|
-
|
|
10471
|
-
|
|
10472
|
-
|
|
10473
|
-
|
|
10474
|
-
|
|
10475
|
-
|
|
10476
|
-
|
|
10477
|
-
|
|
10472
|
+
{
|
|
10473
|
+
const { colorField, colorScale } = visualChannels;
|
|
10474
|
+
const { colorRange, colorAggregation } = visConfig;
|
|
10475
|
+
if (colorField && colorScale && colorRange) {
|
|
10476
|
+
const { accessor, ...scaleProps } = getColorAccessor(
|
|
10477
|
+
colorField,
|
|
10478
|
+
colorScale,
|
|
10479
|
+
{ aggregation: colorAggregation, range: colorRange },
|
|
10480
|
+
visConfig.opacity,
|
|
10481
|
+
data
|
|
10482
|
+
);
|
|
10483
|
+
result.getFillColor = accessor;
|
|
10484
|
+
scales.fillColor = updateTriggers.getFillColor = {
|
|
10485
|
+
field: colorField,
|
|
10486
|
+
type: colorScale,
|
|
10487
|
+
...scaleProps
|
|
10488
|
+
};
|
|
10489
|
+
} else {
|
|
10490
|
+
scales.fillColor = {};
|
|
10491
|
+
}
|
|
10478
10492
|
}
|
|
10479
10493
|
if (layerType === "clusterTile") {
|
|
10480
10494
|
const aggregationExpAlias = getDefaultAggregationExpColumnAliasForLayerType(
|
|
@@ -10527,82 +10541,102 @@ function createChannelProps(id, layerType, config2, visualChannels, data, datase
|
|
|
10527
10541
|
radiusRange: visConfig.radiusRange
|
|
10528
10542
|
};
|
|
10529
10543
|
}
|
|
10530
|
-
|
|
10531
|
-
const
|
|
10532
|
-
|
|
10533
|
-
|
|
10534
|
-
|
|
10535
|
-
|
|
10536
|
-
|
|
10537
|
-
|
|
10538
|
-
|
|
10539
|
-
|
|
10540
|
-
|
|
10541
|
-
|
|
10542
|
-
|
|
10543
|
-
|
|
10544
|
+
{
|
|
10545
|
+
const radiusRange = visConfig.radiusRange;
|
|
10546
|
+
const { radiusField, radiusScale } = visualChannels;
|
|
10547
|
+
if (radiusField && radiusRange && radiusScale) {
|
|
10548
|
+
const { accessor, ...scaleProps } = getSizeAccessor(
|
|
10549
|
+
radiusField,
|
|
10550
|
+
radiusScale,
|
|
10551
|
+
visConfig.sizeAggregation,
|
|
10552
|
+
radiusRange,
|
|
10553
|
+
data
|
|
10554
|
+
);
|
|
10555
|
+
result.getPointRadius = accessor;
|
|
10556
|
+
scales.pointRadius = updateTriggers.getPointRadius = {
|
|
10557
|
+
field: radiusField,
|
|
10558
|
+
type: radiusScale,
|
|
10559
|
+
...scaleProps
|
|
10560
|
+
};
|
|
10561
|
+
}
|
|
10544
10562
|
}
|
|
10545
|
-
|
|
10546
|
-
const
|
|
10547
|
-
const {
|
|
10548
|
-
|
|
10549
|
-
|
|
10550
|
-
|
|
10551
|
-
{
|
|
10552
|
-
|
|
10553
|
-
|
|
10554
|
-
|
|
10555
|
-
|
|
10556
|
-
|
|
10557
|
-
|
|
10558
|
-
|
|
10559
|
-
|
|
10560
|
-
|
|
10563
|
+
{
|
|
10564
|
+
const strokeColorRange = visConfig.strokeColorRange;
|
|
10565
|
+
const { strokeColorScale, strokeColorField } = visualChannels;
|
|
10566
|
+
if (strokeColorField && strokeColorRange && strokeColorScale) {
|
|
10567
|
+
const { strokeColorAggregation: aggregation } = visConfig;
|
|
10568
|
+
const opacity = visConfig.strokeOpacity !== void 0 ? visConfig.strokeOpacity : 1;
|
|
10569
|
+
const { accessor, ...scaleProps } = getColorAccessor(
|
|
10570
|
+
strokeColorField,
|
|
10571
|
+
strokeColorScale,
|
|
10572
|
+
{ aggregation, range: strokeColorRange },
|
|
10573
|
+
opacity,
|
|
10574
|
+
data
|
|
10575
|
+
);
|
|
10576
|
+
result.getLineColor = accessor;
|
|
10577
|
+
scales.lineColor = updateTriggers.getLineColor = {
|
|
10578
|
+
field: strokeColorField,
|
|
10579
|
+
type: strokeColorScale,
|
|
10580
|
+
...scaleProps
|
|
10581
|
+
};
|
|
10582
|
+
}
|
|
10561
10583
|
}
|
|
10562
|
-
|
|
10563
|
-
const {
|
|
10564
|
-
|
|
10565
|
-
|
|
10566
|
-
|
|
10567
|
-
|
|
10568
|
-
|
|
10569
|
-
|
|
10570
|
-
|
|
10571
|
-
|
|
10572
|
-
|
|
10573
|
-
|
|
10574
|
-
|
|
10575
|
-
|
|
10584
|
+
{
|
|
10585
|
+
const { sizeField: strokeWidthField, sizeScale: strokeWidthScale } = visualChannels;
|
|
10586
|
+
const { sizeRange, sizeAggregation } = visConfig;
|
|
10587
|
+
if (strokeWidthField && sizeRange) {
|
|
10588
|
+
const { accessor, ...scaleProps } = getSizeAccessor(
|
|
10589
|
+
strokeWidthField,
|
|
10590
|
+
strokeWidthScale,
|
|
10591
|
+
sizeAggregation,
|
|
10592
|
+
sizeRange,
|
|
10593
|
+
data
|
|
10594
|
+
);
|
|
10595
|
+
result.getLineWidth = accessor;
|
|
10596
|
+
scales.lineWidth = updateTriggers.getLineWidth = {
|
|
10597
|
+
field: strokeWidthField,
|
|
10598
|
+
type: strokeWidthScale || "identity",
|
|
10599
|
+
...scaleProps
|
|
10600
|
+
};
|
|
10601
|
+
}
|
|
10576
10602
|
}
|
|
10577
|
-
|
|
10578
|
-
const {
|
|
10579
|
-
|
|
10580
|
-
|
|
10581
|
-
|
|
10582
|
-
|
|
10583
|
-
|
|
10584
|
-
|
|
10585
|
-
|
|
10586
|
-
|
|
10587
|
-
|
|
10588
|
-
|
|
10589
|
-
|
|
10590
|
-
|
|
10603
|
+
{
|
|
10604
|
+
const { enable3d, heightRange } = visConfig;
|
|
10605
|
+
const { heightField, heightScale } = visualChannels;
|
|
10606
|
+
if (heightField && heightRange && enable3d) {
|
|
10607
|
+
const { accessor, ...scaleProps } = getSizeAccessor(
|
|
10608
|
+
heightField,
|
|
10609
|
+
heightScale,
|
|
10610
|
+
visConfig.heightAggregation,
|
|
10611
|
+
heightRange,
|
|
10612
|
+
data
|
|
10613
|
+
);
|
|
10614
|
+
result.getElevation = accessor;
|
|
10615
|
+
scales.elevation = updateTriggers.getElevation = {
|
|
10616
|
+
field: heightField,
|
|
10617
|
+
type: heightScale || "identity",
|
|
10618
|
+
...scaleProps
|
|
10619
|
+
};
|
|
10620
|
+
}
|
|
10591
10621
|
}
|
|
10592
|
-
|
|
10593
|
-
const {
|
|
10594
|
-
|
|
10595
|
-
|
|
10596
|
-
|
|
10597
|
-
|
|
10598
|
-
|
|
10599
|
-
|
|
10600
|
-
|
|
10601
|
-
|
|
10602
|
-
|
|
10603
|
-
|
|
10604
|
-
|
|
10605
|
-
|
|
10622
|
+
{
|
|
10623
|
+
const { weightField } = visualChannels;
|
|
10624
|
+
const { weightAggregation } = visConfig;
|
|
10625
|
+
if (weightField && weightAggregation) {
|
|
10626
|
+
const { accessor, ...scaleProps } = getSizeAccessor(
|
|
10627
|
+
weightField,
|
|
10628
|
+
void 0,
|
|
10629
|
+
weightAggregation,
|
|
10630
|
+
void 0,
|
|
10631
|
+
data
|
|
10632
|
+
);
|
|
10633
|
+
result.getWeight = accessor;
|
|
10634
|
+
scales.weight = updateTriggers.getWeight = {
|
|
10635
|
+
field: weightField,
|
|
10636
|
+
type: "identity",
|
|
10637
|
+
...scaleProps
|
|
10638
|
+
};
|
|
10639
|
+
}
|
|
10606
10640
|
}
|
|
10607
10641
|
if (visConfig.customMarkers) {
|
|
10608
10642
|
const maxIconSize = getMaxMarkerSize(visConfig, visualChannels);
|