@carto/api-client 0.5.21 → 0.5.22

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/package.json CHANGED
@@ -8,7 +8,7 @@
8
8
  "homepage": "https://github.com/CartoDB/carto-api-client#readme",
9
9
  "author": "Don McCurdy <donmccurdy@carto.com>",
10
10
  "packageManager": "yarn@4.3.1",
11
- "version": "0.5.21",
11
+ "version": "0.5.22",
12
12
  "license": "MIT",
13
13
  "publishConfig": {
14
14
  "access": "public"
@@ -39,10 +39,10 @@ import type {TilejsonResult} from '../sources/types.js';
39
39
 
40
40
  export type Scale = {
41
41
  type: ScaleType;
42
- field: VisualChannelField;
42
+ field?: VisualChannelField;
43
43
 
44
44
  /** Natural domain of the scale, as defined by the data */
45
- domain: string[] | number[];
45
+ domain?: string[] | number[];
46
46
 
47
47
  /** Domain of the user to construct d3 scale */
48
48
  scaleDomain?: string[] | number[];
@@ -277,17 +277,29 @@ function createChannelProps(
277
277
  rasterMetadata,
278
278
  visualChannels,
279
279
  }),
280
- scales: {}, // TODO
280
+ scales: {
281
+ fillColor: {
282
+ type: 'identity',
283
+ },
284
+ },
281
285
  };
282
286
  } else {
283
- return {
284
- channelProps: getRasterTileLayerStylePropsScaledBand({
287
+ const {dataTransform, updateTriggers, ...scaleProps} =
288
+ getRasterTileLayerStylePropsScaledBand({
285
289
  layerConfig: config,
286
290
  visualChannels,
287
291
  rasterMetadata,
288
- }),
292
+ });
293
+
294
+ return {
295
+ channelProps: {
296
+ dataTransform,
297
+ updateTriggers,
298
+ },
289
299
  scales: {
290
- // TODO
300
+ ...(scaleProps.type && {
301
+ fillColor: scaleProps,
302
+ }),
291
303
  },
292
304
  };
293
305
  }
@@ -376,20 +376,9 @@ export function domainFromRasterMetadataBand(
376
376
  if (scaleType === 'ordinal') {
377
377
  return colorRange.colorMap?.map(([value]) => value) || [];
378
378
  }
379
- if (scaleType === 'custom') {
380
- if (colorRange.uiCustomScaleType === 'logarithmic') {
381
- return getLog10ScaleSteps({
382
- min: band.stats.min,
383
- max: band.stats.max,
384
- steps: colorRange.colors.length,
385
- });
386
- } else {
387
- // actually custom, read colorMap
388
- return colorRange.colorMap?.map(([value]) => value) || [];
389
- }
390
- }
391
- const scaleLength = colorRange.colors.length;
379
+
392
380
  if (scaleType === 'quantile') {
381
+ const scaleLength = colorRange.colors.length;
393
382
  const quantiles = band.stats.quantiles?.[scaleLength];
394
383
  if (!quantiles) {
395
384
  return [0, 1];
@@ -433,9 +422,21 @@ export function getRasterTileLayerStylePropsScaledBand({
433
422
 
434
423
  const domain = domainFromRasterMetadataBand(bandInfo, scaleType, colorRange);
435
424
 
425
+ let scaleDomain = domain;
426
+ if (scaleType === 'custom') {
427
+ if (colorRange.uiCustomScaleType === 'logarithmic') {
428
+ scaleDomain = getLog10ScaleSteps({
429
+ min: bandInfo.stats.min,
430
+ max: bandInfo.stats.max,
431
+ steps: colorRange.colors.length,
432
+ });
433
+ } else {
434
+ scaleDomain = colorRange.colorMap?.map(([value]) => value) || [];
435
+ }
436
+ }
436
437
  const scaleFun = createColorScale(
437
438
  scaleType,
438
- domain,
439
+ scaleDomain,
439
440
  colorRange.colors.map(hexToRGB),
440
441
  UNKNOWN_COLOR
441
442
  );
@@ -453,6 +454,11 @@ export function getRasterTileLayerStylePropsScaledBand({
453
454
  layerConfig,
454
455
  visualChannels,
455
456
  }),
457
+ domain: domain,
458
+ scaleDomain: scaleFun.domain(),
459
+ range: colorRange.colors,
460
+ type: scaleType,
461
+ field: colorField,
456
462
  };
457
463
  }
458
464
 
@@ -31,6 +31,7 @@ export type VisualChannels = {
31
31
  heightScale?: ScaleType;
32
32
 
33
33
  weightField?: VisualChannelField;
34
+ uniqueValuesColorScale?: ScaleType;
34
35
  };
35
36
 
36
37
  export type ColorRange = {