@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.
@@ -9399,25 +9399,26 @@ function findAccessorKey(keys, properties) {
9399
9399
  function getColorAccessor({ name, colorColumn }, scaleType, { aggregation, range }, opacity, data) {
9400
9400
  const { scale: scale2, domain } = calculateLayerScale(
9401
9401
  colorColumn || name,
9402
- scaleType,
9402
+ colorColumn ? "identity" : scaleType,
9403
9403
  range,
9404
9404
  data
9405
9405
  );
9406
9406
  const alpha = opacityToAlpha(opacity);
9407
- let accessorKeys = getAccessorKeys(name, aggregation);
9407
+ let accessorKeys = getAccessorKeys(colorColumn || name, aggregation);
9408
9408
  const accessor = (properties) => {
9409
9409
  if (!(accessorKeys[0] in properties)) {
9410
9410
  accessorKeys = findAccessorKey(accessorKeys, properties);
9411
9411
  }
9412
9412
  const propertyValue = properties[accessorKeys[0]];
9413
- const [r, g, b] = scale2(propertyValue);
9414
- return [r, g, b, propertyValue === null ? 0 : alpha];
9413
+ const scaled = scale2(propertyValue);
9414
+ const rgb2 = typeof scaled === "string" ? hexToRGB(scaled) : scaled;
9415
+ return [...rgb2, propertyValue === null ? 0 : alpha];
9415
9416
  };
9416
9417
  return {
9417
9418
  accessor: normalizeAccessor(accessor, data),
9418
9419
  scaleDomain: scale2.domain(),
9419
9420
  domain,
9420
- range: scale2.range().map(rgbToHex)
9421
+ range: (scale2.range() || []).map(rgbToHex)
9421
9422
  };
9422
9423
  }
9423
9424
  function calculateLayerScale(name, scaleType, range, data) {
@@ -9426,9 +9427,9 @@ function calculateLayerScale(name, scaleType, range, data) {
9426
9427
  let scaleColor = [];
9427
9428
  const { colors } = range;
9428
9429
  if (scaleType === "custom") {
9430
+ domain = calculateDomain(data, name, scaleType, colors.length);
9431
+ const [min2, max2] = domain;
9429
9432
  if (range.uiCustomScaleType === "logarithmic") {
9430
- domain = calculateDomain(data, name, scaleType, colors.length);
9431
- const [min2, max2] = domain;
9432
9433
  scaleDomain = getLog10ScaleSteps({
9433
9434
  min: min2,
9434
9435
  max: max2,
@@ -9437,8 +9438,9 @@ function calculateLayerScale(name, scaleType, range, data) {
9437
9438
  scaleColor = colors;
9438
9439
  } else if (range.colorMap) {
9439
9440
  const { colorMap } = range;
9441
+ scaleDomain = [];
9440
9442
  colorMap.forEach(([value, color2]) => {
9441
- domain.push(value);
9443
+ scaleDomain.push(Number(value));
9442
9444
  scaleColor.push(color2);
9443
9445
  });
9444
9446
  }