@carto/api-client 0.5.21 → 0.5.22-0.alpha.raster-scales.0

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.
@@ -10372,19 +10372,8 @@ function domainFromRasterMetadataBand(band, scaleType, colorRange) {
10372
10372
  if (scaleType === "ordinal") {
10373
10373
  return colorRange.colorMap?.map(([value]) => value) || [];
10374
10374
  }
10375
- if (scaleType === "custom") {
10376
- if (colorRange.uiCustomScaleType === "logarithmic") {
10377
- return getLog10ScaleSteps({
10378
- min: band.stats.min,
10379
- max: band.stats.max,
10380
- steps: colorRange.colors.length
10381
- });
10382
- } else {
10383
- return colorRange.colorMap?.map(([value]) => value) || [];
10384
- }
10385
- }
10386
- const scaleLength = colorRange.colors.length;
10387
10375
  if (scaleType === "quantile") {
10376
+ const scaleLength = colorRange.colors.length;
10388
10377
  const quantiles = band.stats.quantiles?.[scaleLength];
10389
10378
  if (!quantiles) {
10390
10379
  return [0, 1];
@@ -10410,9 +10399,21 @@ function getRasterTileLayerStylePropsScaledBand({
10410
10399
  return {};
10411
10400
  }
10412
10401
  const domain = domainFromRasterMetadataBand(bandInfo, scaleType, colorRange);
10402
+ let scaleDomain = domain;
10403
+ if (scaleType === "custom") {
10404
+ if (colorRange.uiCustomScaleType === "logarithmic") {
10405
+ scaleDomain = getLog10ScaleSteps({
10406
+ min: bandInfo.stats.min,
10407
+ max: bandInfo.stats.max,
10408
+ steps: colorRange.colors.length
10409
+ });
10410
+ } else {
10411
+ scaleDomain = colorRange.colorMap?.map(([value]) => value) || [];
10412
+ }
10413
+ }
10413
10414
  const scaleFun = createColorScale(
10414
10415
  scaleType,
10415
- domain,
10416
+ scaleDomain,
10416
10417
  colorRange.colors.map(hexToRGB2),
10417
10418
  UNKNOWN_COLOR2
10418
10419
  );
@@ -10427,7 +10428,12 @@ function getRasterTileLayerStylePropsScaledBand({
10427
10428
  updateTriggers: getRasterTileLayerUpdateTriggers({
10428
10429
  layerConfig,
10429
10430
  visualChannels
10430
- })
10431
+ }),
10432
+ domain,
10433
+ scaleDomain: scaleFun.domain(),
10434
+ range: colorRange.colors,
10435
+ type: scaleType,
10436
+ field: colorField
10431
10437
  };
10432
10438
  }
10433
10439
  function getRasterTileLayerStyleProps({
@@ -10643,18 +10649,27 @@ function createChannelProps(id, layerType, config2, visualChannels, data, datase
10643
10649
  rasterMetadata,
10644
10650
  visualChannels
10645
10651
  }),
10646
- scales: {}
10647
- // TODO
10652
+ scales: {
10653
+ fillColor: {
10654
+ type: "identity"
10655
+ }
10656
+ }
10648
10657
  };
10649
10658
  } else {
10659
+ const { dataTransform, updateTriggers: updateTriggers2, ...scaleProps } = getRasterTileLayerStylePropsScaledBand({
10660
+ layerConfig: config2,
10661
+ visualChannels,
10662
+ rasterMetadata
10663
+ });
10650
10664
  return {
10651
- channelProps: getRasterTileLayerStylePropsScaledBand({
10652
- layerConfig: config2,
10653
- visualChannels,
10654
- rasterMetadata
10655
- }),
10665
+ channelProps: {
10666
+ dataTransform,
10667
+ updateTriggers: updateTriggers2
10668
+ },
10656
10669
  scales: {
10657
- // TODO
10670
+ ...scaleProps.type && {
10671
+ fillColor: scaleProps
10672
+ }
10658
10673
  }
10659
10674
  };
10660
10675
  }