@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/CHANGELOG.md +4 -0
- package/build/api-client.cjs +37 -22
- package/build/api-client.cjs.map +1 -1
- package/build/api-client.d.cts +8 -2
- package/build/api-client.d.ts +8 -2
- package/build/api-client.js +37 -22
- package/build/api-client.js.map +1 -1
- package/package.json +1 -1
- package/src/fetch-map/parse-map.ts +19 -7
- package/src/fetch-map/raster-layer.ts +20 -14
- package/src/fetch-map/types.ts +1 -0
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.
|
|
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
|
|
42
|
+
field?: VisualChannelField;
|
|
43
43
|
|
|
44
44
|
/** Natural domain of the scale, as defined by the data */
|
|
45
|
-
domain
|
|
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: {
|
|
280
|
+
scales: {
|
|
281
|
+
fillColor: {
|
|
282
|
+
type: 'identity',
|
|
283
|
+
},
|
|
284
|
+
},
|
|
281
285
|
};
|
|
282
286
|
} else {
|
|
283
|
-
|
|
284
|
-
|
|
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
|
-
|
|
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
|
-
|
|
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
|
-
|
|
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
|
|