@carto/api-client 0.5.15-alpha.raster-3 → 0.5.15-alpha.raster-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.
@@ -9736,25 +9736,26 @@ function findAccessorKey(keys, properties) {
9736
9736
  function getColorAccessor({ name, colorColumn }, scaleType, { aggregation, range }, opacity, data) {
9737
9737
  const { scale: scale2, domain } = calculateLayerScale(
9738
9738
  colorColumn || name,
9739
- scaleType,
9739
+ colorColumn ? "identity" : scaleType,
9740
9740
  range,
9741
9741
  data
9742
9742
  );
9743
9743
  const alpha = opacityToAlpha(opacity);
9744
- let accessorKeys = getAccessorKeys(name, aggregation);
9744
+ let accessorKeys = getAccessorKeys(colorColumn || name, aggregation);
9745
9745
  const accessor = (properties) => {
9746
9746
  if (!(accessorKeys[0] in properties)) {
9747
9747
  accessorKeys = findAccessorKey(accessorKeys, properties);
9748
9748
  }
9749
9749
  const propertyValue = properties[accessorKeys[0]];
9750
- const [r, g, b] = scale2(propertyValue);
9751
- return [r, g, b, propertyValue === null ? 0 : alpha];
9750
+ const scaled = scale2(propertyValue);
9751
+ const rgb2 = typeof scaled === "string" ? hexToRGB(scaled) : scaled;
9752
+ return [...rgb2, propertyValue === null ? 0 : alpha];
9752
9753
  };
9753
9754
  return {
9754
9755
  accessor: normalizeAccessor(accessor, data),
9755
9756
  scaleDomain: scale2.domain(),
9756
9757
  domain,
9757
- range: scale2.range().map(rgbToHex)
9758
+ range: (scale2.range() || []).map(rgbToHex)
9758
9759
  };
9759
9760
  }
9760
9761
  function calculateLayerScale(name, scaleType, range, data) {
@@ -9763,9 +9764,9 @@ function calculateLayerScale(name, scaleType, range, data) {
9763
9764
  let scaleColor = [];
9764
9765
  const { colors } = range;
9765
9766
  if (scaleType === "custom") {
9767
+ domain = calculateDomain(data, name, scaleType, colors.length);
9768
+ const [min2, max2] = domain;
9766
9769
  if (range.uiCustomScaleType === "logarithmic") {
9767
- domain = calculateDomain(data, name, scaleType, colors.length);
9768
- const [min2, max2] = domain;
9769
9770
  scaleDomain = getLog10ScaleSteps({
9770
9771
  min: min2,
9771
9772
  max: max2,
@@ -9774,8 +9775,9 @@ function calculateLayerScale(name, scaleType, range, data) {
9774
9775
  scaleColor = colors;
9775
9776
  } else if (range.colorMap) {
9776
9777
  const { colorMap } = range;
9778
+ scaleDomain = [];
9777
9779
  colorMap.forEach(([value, color2]) => {
9778
- domain.push(value);
9780
+ scaleDomain.push(Number(value));
9779
9781
  scaleColor.push(color2);
9780
9782
  });
9781
9783
  }