@carto/api-client 0.5.16 → 0.5.17

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.
@@ -8500,6 +8500,250 @@ var basemap_styles_default = {
8500
8500
  DARK_MATTER_NOLABELS: getStyleUrl("dark-matter-nolabels")
8501
8501
  };
8502
8502
 
8503
+ // src/fetch-map/vec-expr-evaluator.ts
8504
+ import jsep from "jsep";
8505
+ function createVecExprEvaluator(expression) {
8506
+ try {
8507
+ const parsed = compile(expression);
8508
+ const evalFun = (context) => evaluate(parsed, context);
8509
+ evalFun.symbols = getSymbols(parsed);
8510
+ return evalFun;
8511
+ } catch {
8512
+ return null;
8513
+ }
8514
+ }
8515
+ function evaluateVecExpr(expression, context) {
8516
+ try {
8517
+ return createVecExprEvaluator(expression)?.(context);
8518
+ } catch {
8519
+ return null;
8520
+ }
8521
+ }
8522
+ var ErrorCode = /* @__PURE__ */ ((ErrorCode2) => {
8523
+ ErrorCode2[ErrorCode2["InvalidSyntax"] = 0] = "InvalidSyntax";
8524
+ ErrorCode2[ErrorCode2["UnknownIdentifier"] = 1] = "UnknownIdentifier";
8525
+ return ErrorCode2;
8526
+ })(ErrorCode || {});
8527
+ function validateVecExprSyntax(expression, context) {
8528
+ let parsed;
8529
+ try {
8530
+ parsed = compile(expression);
8531
+ } catch (e) {
8532
+ return {
8533
+ valid: false,
8534
+ errorCode: 0 /* InvalidSyntax */,
8535
+ errorMessage: e && "message" in e ? String(e.message) : String(e)
8536
+ };
8537
+ }
8538
+ return validate(parsed, context);
8539
+ }
8540
+ function createResultArray(typeTemplate, length2 = typeTemplate.length) {
8541
+ return new Array(length2);
8542
+ }
8543
+ function isVecLike(a) {
8544
+ return Array.isArray(a) || ArrayBuffer.isView(a);
8545
+ }
8546
+ var createBinopVec = (scalarBinOp) => (left, right) => {
8547
+ const length2 = Math.min(left.length, right.length);
8548
+ const r = createResultArray(left, length2);
8549
+ for (let i = 0; i < length2; i++) {
8550
+ r[i] = scalarBinOp(left[i], right[i]);
8551
+ }
8552
+ return r;
8553
+ };
8554
+ var createBinopVecNum = (scalarBinOp) => (left, right) => {
8555
+ const length2 = left.length;
8556
+ const r = createResultArray(left, length2);
8557
+ for (let i = 0; i < length2; i++) {
8558
+ r[i] = scalarBinOp(left[i], right);
8559
+ }
8560
+ return r;
8561
+ };
8562
+ var createBinopNumVec = (scalarBinOp) => (left, right) => {
8563
+ const length2 = right.length;
8564
+ const r = createResultArray(right, length2);
8565
+ for (let i = 0; i < length2; i++) {
8566
+ r[i] = scalarBinOp(left, right[i]);
8567
+ }
8568
+ return r;
8569
+ };
8570
+ var createUnopVec = (scalarUnop) => (a) => {
8571
+ const length2 = a.length;
8572
+ const r = createResultArray(a, length2);
8573
+ for (let i = 0; i < length2; i++) {
8574
+ r[i] = scalarUnop(a[i]);
8575
+ }
8576
+ return r;
8577
+ };
8578
+ function mapDictValues(dict, fun) {
8579
+ return Object.keys(dict).reduce(
8580
+ (acc, key) => {
8581
+ acc[key] = fun(dict[key]);
8582
+ return acc;
8583
+ },
8584
+ {}
8585
+ );
8586
+ }
8587
+ var binopsNum = {
8588
+ "||": (a, b) => a || b,
8589
+ "&&": (a, b) => a && b,
8590
+ "|": (a, b) => a | b,
8591
+ "^": (a, b) => a ^ b,
8592
+ "&": (a, b) => a & b,
8593
+ "==": (a, b) => Number(a == b),
8594
+ "!=": (a, b) => Number(a != b),
8595
+ "===": (a, b) => Number(a === b),
8596
+ "!==": (a, b) => Number(a !== b),
8597
+ "<": (a, b) => Number(a < b),
8598
+ ">": (a, b) => Number(a > b),
8599
+ "<=": (a, b) => Number(a <= b),
8600
+ ">=": (a, b) => Number(a >= b),
8601
+ "<<": (a, b) => a << b,
8602
+ ">>": (a, b) => a >> b,
8603
+ ">>>": (a, b) => a >>> b,
8604
+ "+": (a, b) => a + b,
8605
+ "-": (a, b) => a - b,
8606
+ "*": (a, b) => a * b,
8607
+ "/": (a, b) => a / b,
8608
+ "%": (a, b) => a % b
8609
+ };
8610
+ var unopsNum = {
8611
+ "-": (a) => -a,
8612
+ "+": (a) => +a,
8613
+ "~": (a) => ~a,
8614
+ "!": (a) => Number(!a)
8615
+ };
8616
+ var binopsVector = mapDictValues(binopsNum, createBinopVec);
8617
+ var binopsNumVec = mapDictValues(binopsNum, createBinopNumVec);
8618
+ var binopsVecNum = mapDictValues(binopsNum, createBinopVecNum);
8619
+ var unopsVector = mapDictValues(unopsNum, createUnopVec);
8620
+ function getBinop(operator, left, right) {
8621
+ const isLeftVec = isVecLike(left);
8622
+ const isRightVec = isVecLike(right);
8623
+ if (isLeftVec && isRightVec) {
8624
+ return binopsVector[operator];
8625
+ } else if (isLeftVec) {
8626
+ return binopsVecNum[operator];
8627
+ } else if (isRightVec) {
8628
+ return binopsNumVec[operator];
8629
+ } else {
8630
+ return binopsNum[operator];
8631
+ }
8632
+ }
8633
+ function evaluate(_node, context) {
8634
+ const node = _node;
8635
+ switch (node.type) {
8636
+ case "BinaryExpression": {
8637
+ const left = evaluate(node.left, context);
8638
+ const right = evaluate(node.right, context);
8639
+ const binopFun = getBinop(node.operator, left, right);
8640
+ return binopFun(left, right);
8641
+ }
8642
+ case "ConditionalExpression": {
8643
+ const val = evaluate(node.test, context);
8644
+ if (isVecLike(val)) {
8645
+ const length2 = val.length;
8646
+ const consequentVal = evaluate(node.consequent, context);
8647
+ const alternateVal = evaluate(node.alternate, context);
8648
+ const r = createResultArray(val);
8649
+ for (let i = 0; i < length2; i++) {
8650
+ const entryVal = val[i] ? consequentVal : alternateVal;
8651
+ r[i] = isVecLike(entryVal) ? entryVal[i] ?? NaN : entryVal;
8652
+ }
8653
+ return r;
8654
+ } else {
8655
+ return val ? evaluate(node.consequent, context) : evaluate(node.alternate, context);
8656
+ }
8657
+ }
8658
+ case "Identifier":
8659
+ return context[node.name];
8660
+ case "Literal":
8661
+ return node.value;
8662
+ case "UnaryExpression": {
8663
+ const val = evaluate(node.argument, context);
8664
+ const unopFun = isVecLike(val) ? unopsVector[node.operator] : unopsNum[node.operator];
8665
+ return unopFun(val);
8666
+ }
8667
+ default:
8668
+ return void 0;
8669
+ }
8670
+ }
8671
+ var validResult = { valid: true };
8672
+ function visit(_node, visitor) {
8673
+ const node = _node;
8674
+ visitor(node);
8675
+ switch (node.type) {
8676
+ case "BinaryExpression": {
8677
+ visit(node.left, visitor);
8678
+ visit(node.right, visitor);
8679
+ break;
8680
+ }
8681
+ case "ConditionalExpression": {
8682
+ visit(node.test, visitor);
8683
+ visit(node.consequent, visitor);
8684
+ visit(node.alternate, visitor);
8685
+ break;
8686
+ }
8687
+ case "UnaryExpression": {
8688
+ visit(node.argument, visitor);
8689
+ break;
8690
+ }
8691
+ }
8692
+ }
8693
+ var supportedExpressionTypes = [
8694
+ "BinaryExpression",
8695
+ "UnaryExpression",
8696
+ "ConditionalExpression",
8697
+ "LogicalExpression",
8698
+ "Identifier",
8699
+ "Literal"
8700
+ ];
8701
+ function validate(_node, context) {
8702
+ const node = _node;
8703
+ const errors = [];
8704
+ visit(node, (node2) => {
8705
+ if (!supportedExpressionTypes.includes(node2.type)) {
8706
+ errors.push({
8707
+ valid: false,
8708
+ errorCode: 0 /* InvalidSyntax */,
8709
+ errorMessage: `Not allowed`
8710
+ });
8711
+ return;
8712
+ }
8713
+ if (node2.type === "Identifier") {
8714
+ if (!Object.prototype.hasOwnProperty.call(context, node2.name)) {
8715
+ return errors.push({
8716
+ valid: false,
8717
+ errorCode: 1 /* UnknownIdentifier */,
8718
+ errorMessage: `"${node2.name}" not found`
8719
+ });
8720
+ }
8721
+ }
8722
+ if (node2.type === "Literal") {
8723
+ if (typeof node2.value !== "number") {
8724
+ return errors.push({
8725
+ valid: false,
8726
+ errorCode: 0 /* InvalidSyntax */,
8727
+ errorMessage: `Only number literals are supported`
8728
+ });
8729
+ }
8730
+ }
8731
+ });
8732
+ return errors.length ? errors[0] : validResult;
8733
+ }
8734
+ function getSymbols(node) {
8735
+ const symbols = /* @__PURE__ */ new Set();
8736
+ visit(node, (node2) => {
8737
+ if (node2.type === "Identifier") {
8738
+ symbols.add(node2.name);
8739
+ }
8740
+ });
8741
+ return Array.from(symbols);
8742
+ }
8743
+ function compile(expression) {
8744
+ return jsep(expression);
8745
+ }
8746
+
8503
8747
  // node_modules/d3-array/src/ascending.js
8504
8748
  function ascending(a, b) {
8505
8749
  return a == null || b == null ? NaN : a < b ? -1 : a > b ? 1 : a >= b ? 0 : NaN;
@@ -9078,6 +9322,37 @@ function formatDate(value) {
9078
9322
  function formatTimestamp(value) {
9079
9323
  return String(Math.floor(new Date(value).getTime() / 1e3));
9080
9324
  }
9325
+ function roundedPow10(exp) {
9326
+ const raw = Math.pow(10, exp);
9327
+ if (exp < 0) {
9328
+ const shift = Math.pow(10, -exp);
9329
+ return Math.round(raw * shift) / shift;
9330
+ }
9331
+ return raw;
9332
+ }
9333
+ function getLog10ScaleSteps({
9334
+ min: min2,
9335
+ max: max2,
9336
+ steps
9337
+ }) {
9338
+ if (min2 === 0) {
9339
+ if (max2 === Infinity) {
9340
+ return [...Array(steps - 1)].map((_v, i) => roundedPow10(i + 1));
9341
+ }
9342
+ const maxLog = Math.log10(max2);
9343
+ const endExponent = Math.ceil(maxLog);
9344
+ const startExponent = endExponent - steps + 1;
9345
+ return [...Array(steps - 1)].map(
9346
+ (_v, i) => roundedPow10(startExponent + i)
9347
+ );
9348
+ } else {
9349
+ const minLog = Math.log10(min2);
9350
+ const startExponent = Math.ceil(minLog) === minLog ? minLog + 1 : Math.ceil(minLog);
9351
+ return [...Array(steps - 1)].map(
9352
+ (_v, i) => roundedPow10(startExponent + i)
9353
+ );
9354
+ }
9355
+ }
9081
9356
 
9082
9357
  // src/fetch-map/layer-map.ts
9083
9358
  var SCALE_FUNCS = {
@@ -9094,7 +9369,19 @@ var SCALE_FUNCS = {
9094
9369
  function identity2(v2) {
9095
9370
  return v2;
9096
9371
  }
9372
+ var hexToRGB = (c) => {
9373
+ const { r, g, b } = rgb(c);
9374
+ return [r, g, b];
9375
+ };
9376
+ var rgbToHex = (c) => {
9377
+ const [r, g, b] = c;
9378
+ const rStr = r.toString(16).padStart(2, "0");
9379
+ const gStr = g.toString(16).padStart(2, "0");
9380
+ const bStr = b.toString(16).padStart(2, "0");
9381
+ return `#${rStr}${gStr}${bStr}`.toUpperCase();
9382
+ };
9097
9383
  var UNKNOWN_COLOR = "#868d91";
9384
+ var UNKNOWN_COLOR_RGB = hexToRGB(UNKNOWN_COLOR);
9098
9385
  var OPACITY_MAP = {
9099
9386
  getFillColor: "opacity",
9100
9387
  getLineColor: "strokeOpacity",
@@ -9127,6 +9414,12 @@ var sharedPropMap = {
9127
9414
  wireframe: "wireframe"
9128
9415
  }
9129
9416
  };
9417
+ var rasterPropsMap = {
9418
+ isVisible: "visible",
9419
+ visConfig: {
9420
+ opacity: "opacity"
9421
+ }
9422
+ };
9130
9423
  var customMarkersPropsMap = {
9131
9424
  color: "getIconColor",
9132
9425
  visConfig: {
@@ -9170,6 +9463,12 @@ function getLayerProps(type, config2, dataset) {
9170
9463
  `Outdated layer type: ${type}. Please open map in CARTO Builder to automatically migrate.`
9171
9464
  );
9172
9465
  }
9466
+ if (type === "raster") {
9467
+ return {
9468
+ propMap: rasterPropsMap,
9469
+ defaultProps: {}
9470
+ };
9471
+ }
9173
9472
  let basePropMap = sharedPropMap;
9174
9473
  if (config2.visConfig?.customMarkers) {
9175
9474
  basePropMap = mergePropMaps(basePropMap, customMarkersPropsMap);
@@ -9190,16 +9489,19 @@ function getLayerProps(type, config2, dataset) {
9190
9489
  }
9191
9490
  function domainFromAttribute(attribute, scaleType, scaleLength) {
9192
9491
  if (scaleType === "ordinal" || scaleType === "point") {
9492
+ if (!attribute.categories) {
9493
+ return [0, 1];
9494
+ }
9193
9495
  return attribute.categories.map((c) => c.category).filter((c) => c !== void 0 && c !== null);
9194
9496
  }
9195
9497
  if (scaleType === "quantile" && attribute.quantiles) {
9196
- return attribute.quantiles.global ? attribute.quantiles.global[scaleLength] : attribute.quantiles[scaleLength];
9498
+ return "global" in attribute.quantiles ? attribute.quantiles.global[scaleLength] : attribute.quantiles[scaleLength];
9197
9499
  }
9198
9500
  let { min: min2 } = attribute;
9199
9501
  if (scaleType === "log" && min2 === 0) {
9200
9502
  min2 = 1e-5;
9201
9503
  }
9202
- return [min2, attribute.max];
9504
+ return [min2 ?? 0, attribute.max ?? 1];
9203
9505
  }
9204
9506
  function domainFromValues(values, scaleType) {
9205
9507
  if (scaleType === "ordinal" || scaleType === "point") {
@@ -9220,12 +9522,14 @@ function calculateDomain(data, name, scaleType, scaleLength) {
9220
9522
  if (data.tilestats) {
9221
9523
  const { attributes } = data.tilestats.layers[0];
9222
9524
  const attribute = attributes.find((a) => a.attribute === name);
9223
- return domainFromAttribute(attribute, scaleType, scaleLength);
9525
+ if (attribute) {
9526
+ return domainFromAttribute(attribute, scaleType, scaleLength);
9527
+ }
9224
9528
  }
9225
9529
  return [0, 1];
9226
9530
  }
9227
9531
  function normalizeAccessor(accessor, data) {
9228
- if (data.features || data.tilestats) {
9532
+ if (data.features || data.tilestats || data.raster_metadata) {
9229
9533
  return (object, info) => {
9230
9534
  if (object) {
9231
9535
  return accessor(object.properties || object.__source.object.properties);
@@ -9258,46 +9562,75 @@ function findAccessorKey(keys, properties) {
9258
9562
  return keys;
9259
9563
  }
9260
9564
  function getColorAccessor({ name, colorColumn }, scaleType, { aggregation, range }, opacity, data) {
9261
- const scale2 = calculateLayerScale(
9565
+ const { scale: scale2, domain } = calculateLayerScale(
9262
9566
  colorColumn || name,
9263
- scaleType,
9567
+ colorColumn ? "identity" : scaleType,
9264
9568
  range,
9265
9569
  data
9266
9570
  );
9267
9571
  const alpha = opacityToAlpha(opacity);
9268
- let accessorKeys = getAccessorKeys(name, aggregation);
9572
+ let accessorKeys = getAccessorKeys(colorColumn || name, aggregation);
9269
9573
  const accessor = (properties) => {
9270
9574
  if (!(accessorKeys[0] in properties)) {
9271
9575
  accessorKeys = findAccessorKey(accessorKeys, properties);
9272
9576
  }
9273
9577
  const propertyValue = properties[accessorKeys[0]];
9274
- const { r, g, b } = rgb(scale2(propertyValue));
9275
- return [r, g, b, propertyValue === null ? 0 : alpha];
9578
+ const scaled = scale2(propertyValue);
9579
+ const rgb2 = typeof scaled === "string" ? hexToRGB(scaled) : scaled;
9580
+ return [...rgb2, propertyValue === null ? 0 : alpha];
9581
+ };
9582
+ return {
9583
+ accessor: normalizeAccessor(accessor, data),
9584
+ scaleDomain: scale2.domain(),
9585
+ domain,
9586
+ range: (scale2.range() || []).map(rgbToHex)
9276
9587
  };
9277
- return { accessor: normalizeAccessor(accessor, data), scale: scale2 };
9278
9588
  }
9279
9589
  function calculateLayerScale(name, scaleType, range, data) {
9280
- const scale2 = SCALE_FUNCS[scaleType]();
9281
9590
  let domain = [];
9591
+ let scaleDomain;
9282
9592
  let scaleColor = [];
9283
- if (scaleType !== "identity") {
9284
- const { colorMap, colors } = range;
9285
- if (Array.isArray(colorMap)) {
9593
+ const { colors } = range;
9594
+ if (scaleType === "custom") {
9595
+ domain = calculateDomain(data, name, scaleType, colors.length);
9596
+ const [min2, max2] = domain;
9597
+ if (range.uiCustomScaleType === "logarithmic") {
9598
+ scaleDomain = getLog10ScaleSteps({
9599
+ min: min2,
9600
+ max: max2,
9601
+ steps: colors.length
9602
+ });
9603
+ scaleColor = colors;
9604
+ } else if (range.colorMap) {
9605
+ const { colorMap } = range;
9606
+ scaleDomain = [];
9286
9607
  colorMap.forEach(([value, color2]) => {
9287
- domain.push(value);
9608
+ scaleDomain.push(Number(value));
9288
9609
  scaleColor.push(color2);
9289
9610
  });
9290
- } else {
9291
- domain = calculateDomain(data, name, scaleType, colors.length);
9292
- scaleColor = colors;
9293
9611
  }
9612
+ } else if (scaleType !== "identity") {
9613
+ domain = calculateDomain(data, name, scaleType, colors.length);
9614
+ scaleColor = colors;
9294
9615
  if (scaleType === "ordinal") {
9295
9616
  domain = domain.slice(0, scaleColor.length);
9296
9617
  }
9297
9618
  }
9619
+ return {
9620
+ scale: createColorScale(
9621
+ scaleType,
9622
+ scaleDomain || domain,
9623
+ scaleColor.map(hexToRGB),
9624
+ UNKNOWN_COLOR_RGB
9625
+ ),
9626
+ domain
9627
+ };
9628
+ }
9629
+ function createColorScale(scaleType, domain, range, unknown) {
9630
+ const scale2 = SCALE_FUNCS[scaleType]();
9298
9631
  scale2.domain(domain);
9299
- scale2.range(scaleColor);
9300
- scale2.unknown(UNKNOWN_COLOR);
9632
+ scale2.range(range);
9633
+ scale2.unknown(unknown);
9301
9634
  return scale2;
9302
9635
  }
9303
9636
  var FALLBACK_ICON = "data:image/svg+xml;charset=utf-8;base64,PHN2ZyB2aWV3Qm94PSIwIDAgMTAwIDEwMCIgeG1sbnM9Imh0dHA6Ly93d3cudzMub3JnLzIwMDAvc3ZnIj4NCiAgPGNpcmNsZSBjeD0iNTAiIGN5PSI1MCIgcj0iNTAiLz4NCjwvc3ZnPg==";
@@ -9347,9 +9680,13 @@ function negateAccessor(accessor) {
9347
9680
  }
9348
9681
  function getSizeAccessor({ name }, scaleType, aggregation, range, data) {
9349
9682
  const scale2 = scaleType ? SCALE_FUNCS[scaleType]() : identity2;
9350
- if (scaleType) {
9683
+ let domain = [];
9684
+ if (scaleType && range) {
9351
9685
  if (aggregation !== AggregationTypes.Count) {
9352
- scale2.domain(calculateDomain(data, name, scaleType));
9686
+ domain = calculateDomain(data, name, scaleType);
9687
+ scale2.domain(domain);
9688
+ } else {
9689
+ domain = scale2.domain();
9353
9690
  }
9354
9691
  scale2.range(range);
9355
9692
  }
@@ -9361,7 +9698,12 @@ function getSizeAccessor({ name }, scaleType, aggregation, range, data) {
9361
9698
  const propertyValue = properties[accessorKeys[0]];
9362
9699
  return scale2(propertyValue);
9363
9700
  };
9364
- return { accessor: normalizeAccessor(accessor, data), scale: scale2 };
9701
+ return {
9702
+ accessor: normalizeAccessor(accessor, data),
9703
+ domain,
9704
+ scaleDomain: domain,
9705
+ range
9706
+ };
9365
9707
  }
9366
9708
  var FORMATS = {
9367
9709
  date: formatDate,
@@ -9412,13 +9754,420 @@ function calculateClusterTextFontSize(radius) {
9412
9754
  return 11;
9413
9755
  }
9414
9756
 
9757
+ // src/fetch-map/raster-layer.ts
9758
+ var UNKNOWN_COLOR2 = [134, 141, 145];
9759
+ var RASTER_COLOR_BANDS = ["red", "green", "blue"];
9760
+ function getHasDataPredicate(noData) {
9761
+ if (noData === "nan") {
9762
+ return (v2) => !isNaN(v2);
9763
+ }
9764
+ if (typeof noData === "string") {
9765
+ noData = parseFloat(noData);
9766
+ }
9767
+ if (typeof noData === "number") {
9768
+ return (v2) => v2 !== noData && !isNaN(v2);
9769
+ }
9770
+ return () => true;
9771
+ }
9772
+ function createRasterColumnLayerDataTransform(transform) {
9773
+ return (data) => {
9774
+ if (!data || !("data" in data) || !data?.data?.cells?.numericProps) {
9775
+ return data;
9776
+ }
9777
+ return transform(data);
9778
+ };
9779
+ }
9780
+ function createEvaluationContext(numericProps, noData) {
9781
+ const hasData = getHasDataPredicate(noData);
9782
+ const bands = Object.entries(numericProps).map(([bandName, { value }]) => ({
9783
+ bandName,
9784
+ values: value,
9785
+ copied: false
9786
+ }));
9787
+ const length2 = bands[0].values.length;
9788
+ for (let i = 0; i < length2; i++) {
9789
+ let hasSomeData = false;
9790
+ for (let j = 0; j < bands.length; j++) {
9791
+ hasSomeData = hasSomeData || hasData(bands[j].values[i]);
9792
+ }
9793
+ if (!hasSomeData) {
9794
+ for (let j = 0; j < bands.length; j++) {
9795
+ if (!bands[j].copied) {
9796
+ bands[j].copied = true;
9797
+ bands[j].values = Array.from(bands[j].values);
9798
+ }
9799
+ bands[j].values[i] = NaN;
9800
+ }
9801
+ }
9802
+ }
9803
+ const context = bands.reduce(
9804
+ (agg, { bandName, values }) => {
9805
+ agg[bandName] = values;
9806
+ return agg;
9807
+ },
9808
+ {}
9809
+ );
9810
+ return context;
9811
+ }
9812
+ function createExprDataTransform({
9813
+ colorBand,
9814
+ rasterMetadata,
9815
+ usedSymbols
9816
+ }) {
9817
+ if (!colorBand || !colorBand.type || colorBand.type === "none") {
9818
+ return void 0;
9819
+ }
9820
+ const expr = colorBand?.type === "expression" ? colorBand.value : void 0;
9821
+ const vecExprEvaluator = expr ? createVecExprEvaluator(expr) : void 0;
9822
+ const dataTransform = createRasterColumnLayerDataTransform(
9823
+ (dataWrapped) => {
9824
+ const data = dataWrapped.data;
9825
+ if (expr) {
9826
+ const cachedResult = dataWrapped.customExpressionResults?.[expr];
9827
+ if (cachedResult) {
9828
+ return dataWrapped;
9829
+ }
9830
+ }
9831
+ let context = dataWrapped.expressionEvalContext;
9832
+ if (!context) {
9833
+ const usedNumericProps = usedSymbols.reduce(
9834
+ (acc, symbol) => {
9835
+ acc[symbol] = data.cells.numericProps[symbol];
9836
+ return acc;
9837
+ },
9838
+ {}
9839
+ );
9840
+ context = createEvaluationContext(
9841
+ usedNumericProps,
9842
+ rasterMetadata.nodata
9843
+ );
9844
+ dataWrapped = {
9845
+ ...dataWrapped,
9846
+ expressionEvalContext: context
9847
+ };
9848
+ }
9849
+ if (!vecExprEvaluator || !expr) return dataWrapped;
9850
+ const evalResult = vecExprEvaluator(context);
9851
+ return {
9852
+ ...dataWrapped,
9853
+ customExpressionResults: {
9854
+ ...dataWrapped.customExpressionResults,
9855
+ [expr]: evalResult
9856
+ }
9857
+ };
9858
+ }
9859
+ );
9860
+ return dataTransform;
9861
+ }
9862
+ function combineDataTransforms(dataTransforms) {
9863
+ const actualTransforms = dataTransforms.filter((v2) => v2);
9864
+ if (actualTransforms.length === 0) return void 0;
9865
+ if (actualTransforms.length === 1) return actualTransforms[0];
9866
+ return (data) => actualTransforms.reduce(
9867
+ (aggData, transformFun) => transformFun(aggData),
9868
+ data
9869
+ );
9870
+ }
9871
+ function createRgbToColorBufferDataTransform({
9872
+ bandDefs,
9873
+ attribute
9874
+ }) {
9875
+ return createRasterColumnLayerDataTransform(
9876
+ (dataWrapped) => {
9877
+ const length2 = dataWrapped.length;
9878
+ const getBandBufferOrValue = (colorBand) => {
9879
+ if (colorBand?.type === "expression") {
9880
+ return dataWrapped.customExpressionResults?.[colorBand.value];
9881
+ }
9882
+ if (colorBand?.type === "band") {
9883
+ return dataWrapped.expressionEvalContext?.[colorBand.value];
9884
+ }
9885
+ return 0;
9886
+ };
9887
+ const red = getBandBufferOrValue(bandDefs.red);
9888
+ const green = getBandBufferOrValue(bandDefs.green);
9889
+ const blue = getBandBufferOrValue(bandDefs.blue);
9890
+ const colorBuffer = new Uint8Array(length2 * 4);
9891
+ for (let inputIndex = 0, outputIndex = 0; inputIndex < length2; inputIndex++, outputIndex += 4) {
9892
+ const redRaw = typeof red === "number" ? red : red ? red[inputIndex] : NaN;
9893
+ const greenRaw = typeof green === "number" ? green : green ? green[inputIndex] : NaN;
9894
+ const blueRaw = typeof blue === "number" ? blue : blue ? blue[inputIndex] : NaN;
9895
+ if (isNaN(redRaw) && isNaN(greenRaw) && isNaN(blueRaw)) {
9896
+ bufferSetRgba(colorBuffer, outputIndex, 0, 0, 0, 0);
9897
+ } else {
9898
+ bufferSetRgba(
9899
+ colorBuffer,
9900
+ outputIndex,
9901
+ redRaw,
9902
+ greenRaw,
9903
+ blueRaw,
9904
+ 255
9905
+ );
9906
+ }
9907
+ }
9908
+ dataWrapped.customExpressionResults = void 0;
9909
+ dataWrapped.expressionEvalContext = void 0;
9910
+ return {
9911
+ ...dataWrapped,
9912
+ attributes: {
9913
+ [attribute]: colorBuffer
9914
+ }
9915
+ };
9916
+ }
9917
+ );
9918
+ }
9919
+ function getUsedSymbols(colorBands) {
9920
+ return Array.from(
9921
+ colorBands.reduce((symbols, band) => {
9922
+ if (band.type === "expression") {
9923
+ const expressionSymbols = createVecExprEvaluator(band.value)?.symbols || [];
9924
+ expressionSymbols.forEach((symbol) => symbols.add(symbol));
9925
+ }
9926
+ if (band.type === "band") {
9927
+ symbols.add(band.value);
9928
+ }
9929
+ return symbols;
9930
+ }, /* @__PURE__ */ new Set())
9931
+ );
9932
+ }
9933
+ function getRasterTileLayerStylePropsRgb({
9934
+ layerConfig,
9935
+ rasterMetadata,
9936
+ visualChannels
9937
+ }) {
9938
+ const { visConfig } = layerConfig;
9939
+ const { colorBands } = visConfig;
9940
+ const bandDefs = {
9941
+ red: colorBands?.find((band) => band.band === "red"),
9942
+ green: colorBands?.find((band) => band.band === "green"),
9943
+ blue: colorBands?.find((band) => band.band === "blue")
9944
+ };
9945
+ const rgbToInstanceFillColorsDataTransform = createRgbToColorBufferDataTransform({
9946
+ bandDefs,
9947
+ attribute: "instanceFillColors"
9948
+ });
9949
+ const usedSymbols = colorBands ? getUsedSymbols(colorBands) : [];
9950
+ const bandTransforms = RASTER_COLOR_BANDS.map(
9951
+ (band) => createExprDataTransform({
9952
+ colorBand: bandDefs[band],
9953
+ rasterMetadata,
9954
+ usedSymbols
9955
+ })
9956
+ );
9957
+ const combinedDataTransform = combineDataTransforms([
9958
+ ...bandTransforms,
9959
+ rgbToInstanceFillColorsDataTransform
9960
+ ]);
9961
+ return {
9962
+ dataTransform: combinedDataTransform,
9963
+ updateTriggers: getRasterTileLayerUpdateTriggers({
9964
+ layerConfig,
9965
+ visualChannels
9966
+ })
9967
+ };
9968
+ }
9969
+ function createBandColorScaleDataTransform({
9970
+ bandName,
9971
+ scaleFun,
9972
+ nodata,
9973
+ attribute
9974
+ }) {
9975
+ const hasData = getHasDataPredicate(nodata);
9976
+ return createRasterColumnLayerDataTransform(
9977
+ (dataWrapped) => {
9978
+ const length2 = dataWrapped.length;
9979
+ const bandBuffer = dataWrapped.data.cells.numericProps[bandName].value;
9980
+ const colorBuffer = new Uint8Array(length2 * 4);
9981
+ for (let i = 0; i < length2; i++) {
9982
+ const rawValue = bandBuffer[i];
9983
+ if (!hasData(rawValue)) {
9984
+ bufferSetRgba(colorBuffer, i * 4, 0, 0, 0, 0);
9985
+ } else {
9986
+ const colorRgb = scaleFun(rawValue);
9987
+ bufferSetRgba(
9988
+ colorBuffer,
9989
+ i * 4,
9990
+ colorRgb[0],
9991
+ colorRgb[1],
9992
+ colorRgb[2],
9993
+ 255
9994
+ );
9995
+ }
9996
+ }
9997
+ return {
9998
+ ...dataWrapped,
9999
+ attributes: {
10000
+ [attribute]: colorBuffer
10001
+ }
10002
+ };
10003
+ }
10004
+ );
10005
+ }
10006
+ function domainFromRasterMetadataBand(band, scaleType, colorRange) {
10007
+ if (scaleType === "ordinal") {
10008
+ return colorRange.colorMap?.map(([value]) => value) || [];
10009
+ }
10010
+ if (scaleType === "custom") {
10011
+ if (colorRange.uiCustomScaleType === "logarithmic") {
10012
+ return getLog10ScaleSteps({
10013
+ min: band.stats.min,
10014
+ max: band.stats.max,
10015
+ steps: colorRange.colors.length
10016
+ });
10017
+ } else {
10018
+ return colorRange.colorMap?.map(([value]) => value) || [];
10019
+ }
10020
+ }
10021
+ const scaleLength = colorRange.colors.length;
10022
+ if (scaleType === "quantile") {
10023
+ const quantiles = band.stats.quantiles?.[scaleLength];
10024
+ if (!quantiles) {
10025
+ return [0, 1];
10026
+ }
10027
+ return [band.stats.min, ...quantiles, band.stats.max];
10028
+ }
10029
+ return [band.stats.min, band.stats.max];
10030
+ }
10031
+ function getRasterTileLayerStylePropsScaledBand({
10032
+ layerConfig,
10033
+ rasterMetadata,
10034
+ visualChannels
10035
+ }) {
10036
+ const { visConfig } = layerConfig;
10037
+ const { colorField } = visualChannels;
10038
+ const { rasterStyleType } = visConfig;
10039
+ const colorRange = rasterStyleType === "ColorRange" ? visConfig.colorRange : visConfig.uniqueValuesColorRange;
10040
+ const scaleType = rasterStyleType === "ColorRange" ? visualChannels.colorScale : "ordinal";
10041
+ const bandInfo = rasterMetadata.bands.find(
10042
+ (band) => band.name === colorField?.name
10043
+ );
10044
+ if (!colorField?.name || !scaleType || !colorRange || !bandInfo) {
10045
+ return {};
10046
+ }
10047
+ const domain = domainFromRasterMetadataBand(bandInfo, scaleType, colorRange);
10048
+ const scaleFun = createColorScale(
10049
+ scaleType,
10050
+ domain,
10051
+ colorRange.colors.map(hexToRGB2),
10052
+ UNKNOWN_COLOR2
10053
+ );
10054
+ const bandColorScaleDataTransform = createBandColorScaleDataTransform({
10055
+ bandName: bandInfo.name,
10056
+ scaleFun,
10057
+ nodata: bandInfo?.nodata ?? rasterMetadata.nodata,
10058
+ attribute: "instanceFillColors"
10059
+ });
10060
+ return {
10061
+ dataTransform: bandColorScaleDataTransform,
10062
+ updateTriggers: getRasterTileLayerUpdateTriggers({
10063
+ layerConfig,
10064
+ visualChannels
10065
+ })
10066
+ };
10067
+ }
10068
+ function getRasterTileLayerStyleProps({
10069
+ layerConfig,
10070
+ visualChannels,
10071
+ rasterMetadata
10072
+ }) {
10073
+ const { visConfig } = layerConfig;
10074
+ const { rasterStyleType } = visConfig;
10075
+ if (rasterStyleType === "Rgb") {
10076
+ return getRasterTileLayerStylePropsRgb({
10077
+ layerConfig,
10078
+ rasterMetadata,
10079
+ visualChannels
10080
+ });
10081
+ } else {
10082
+ return getRasterTileLayerStylePropsScaledBand({
10083
+ layerConfig,
10084
+ rasterMetadata,
10085
+ visualChannels
10086
+ });
10087
+ }
10088
+ }
10089
+ function getRasterTileLayerUpdateTriggers({
10090
+ layerConfig,
10091
+ visualChannels
10092
+ }) {
10093
+ const { visConfig } = layerConfig;
10094
+ const { rasterStyleType } = visConfig;
10095
+ const getFillColorUpdateTriggers = {
10096
+ rasterStyleType
10097
+ };
10098
+ if (rasterStyleType === "ColorRange") {
10099
+ getFillColorUpdateTriggers.colorRange = visConfig.colorRange?.colors;
10100
+ getFillColorUpdateTriggers.colorMap = visConfig.colorRange?.colorMap;
10101
+ getFillColorUpdateTriggers.colorScale = visualChannels.colorScale;
10102
+ getFillColorUpdateTriggers.colorFieldId = visualChannels.colorField?.name;
10103
+ } else if (rasterStyleType === "UniqueValues") {
10104
+ getFillColorUpdateTriggers.colorMap = visConfig.uniqueValuesColorRange?.colorMap;
10105
+ getFillColorUpdateTriggers.colorFieldId = visualChannels.colorField?.name;
10106
+ } else if (rasterStyleType === "Rgb") {
10107
+ getFillColorUpdateTriggers.colorBands = visConfig.colorBands;
10108
+ }
10109
+ return {
10110
+ getFillColor: getFillColorUpdateTriggers
10111
+ };
10112
+ }
10113
+ function bufferSetRgba(target, index, r, g, b, a) {
10114
+ target[index + 0] = r;
10115
+ target[index + 1] = g;
10116
+ target[index + 2] = b;
10117
+ target[index + 3] = a;
10118
+ }
10119
+ function hexToRGB2(hexColor) {
10120
+ const r = parseInt(hexColor.slice(1, 3), 16);
10121
+ const g = parseInt(hexColor.slice(3, 5), 16);
10122
+ const b = parseInt(hexColor.slice(5, 7), 16);
10123
+ return [r, g, b];
10124
+ }
10125
+
9415
10126
  // src/fetch-map/parse-map.ts
10127
+ function getLayerDescriptor({
10128
+ mapConfig,
10129
+ layer,
10130
+ dataset
10131
+ }) {
10132
+ const { filters, visState } = mapConfig;
10133
+ const { layerBlending, interactionConfig } = visState;
10134
+ const { id, type, config: config2, visualChannels } = layer;
10135
+ const { data, id: datasetId } = dataset;
10136
+ const { propMap, defaultProps: defaultProps2 } = getLayerProps(type, config2, dataset);
10137
+ const styleProps = createStyleProps(config2, propMap);
10138
+ const { channelProps, scales } = createChannelProps(
10139
+ id,
10140
+ type,
10141
+ config2,
10142
+ visualChannels,
10143
+ data,
10144
+ dataset
10145
+ );
10146
+ const layerDescriptor = {
10147
+ type,
10148
+ filters: isEmptyObject(filters) || isRemoteCalculationSupported(dataset) ? void 0 : filters[datasetId],
10149
+ props: {
10150
+ id,
10151
+ data,
10152
+ ...defaultProps2,
10153
+ ...createInteractionProps(interactionConfig),
10154
+ ...styleProps,
10155
+ ...channelProps,
10156
+ ...createParametersProp(layerBlending, styleProps.parameters || {}),
10157
+ // Must come after style
10158
+ ...createLoadOptions(data.accessToken)
10159
+ },
10160
+ scales
10161
+ };
10162
+ return layerDescriptor;
10163
+ }
9416
10164
  function parseMap(json) {
9417
10165
  const { keplerMapConfig, datasets, token } = json;
9418
10166
  assert2(keplerMapConfig.version === "v1", "Only support Kepler v1");
9419
- const config2 = keplerMapConfig.config;
9420
- const { filters, mapState, mapStyle, popupSettings, legendSettings } = config2;
9421
- const { layers, layerBlending, interactionConfig } = config2.visState;
10167
+ const mapConfig = keplerMapConfig.config;
10168
+ const { mapState, mapStyle, popupSettings, legendSettings, visState } = mapConfig;
10169
+ const { layers } = visState;
10170
+ const layersReverse = [...layers].reverse();
9422
10171
  return {
9423
10172
  id: json.id,
9424
10173
  title: json.title,
@@ -9431,45 +10180,19 @@ function parseMap(json) {
9431
10180
  popupSettings,
9432
10181
  legendSettings,
9433
10182
  token,
9434
- layers: layers.reverse().map(({ id, type, config: config3, visualChannels }) => {
10183
+ layers: layersReverse.map((layer) => {
9435
10184
  try {
9436
- const { dataId } = config3;
10185
+ const { dataId } = layer.config;
9437
10186
  const dataset = datasets.find(
9438
10187
  (d) => d.id === dataId
9439
10188
  );
9440
10189
  assert2(dataset, `No dataset matching dataId: ${dataId}`);
9441
- const { data } = dataset;
9442
- assert2(data, `No data loaded for dataId: ${dataId}`);
9443
- const { propMap, defaultProps: defaultProps2 } = getLayerProps(type, config3, dataset);
9444
- const styleProps = createStyleProps(config3, propMap);
9445
- const { channelProps, scales } = createChannelProps(
9446
- id,
9447
- type,
9448
- config3,
9449
- visualChannels,
9450
- data,
10190
+ const layerDescriptor = getLayerDescriptor({
10191
+ mapConfig,
10192
+ layer,
9451
10193
  dataset
9452
- );
9453
- const layer = {
9454
- type,
9455
- filters: isEmptyObject(filters) || isRemoteCalculationSupported(dataset) ? void 0 : filters[dataId],
9456
- props: {
9457
- id,
9458
- data,
9459
- ...defaultProps2,
9460
- ...createInteractionProps(interactionConfig),
9461
- ...styleProps,
9462
- ...channelProps,
9463
- ...createParametersProp(
9464
- layerBlending,
9465
- styleProps.parameters || {}
9466
- ),
9467
- // Must come after style
9468
- ...createLoadOptions(token)
9469
- },
9470
- scales
9471
- };
9472
- return layer;
10194
+ });
10195
+ return layerDescriptor;
9473
10196
  } catch (e) {
9474
10197
  console.error(e.message);
9475
10198
  return void 0;
@@ -9534,43 +10257,63 @@ function createStyleProps(config2, mapping) {
9534
10257
  result.highlightColor = config2.visConfig.enable3d ? [255, 255, 255, 60] : [252, 242, 26, 255];
9535
10258
  return result;
9536
10259
  }
9537
- function domainAndRangeFromScale(scale2) {
9538
- return {
9539
- domain: scale2.domain(),
9540
- range: scale2.range()
9541
- };
9542
- }
9543
10260
  function createChannelProps(id, layerType, config2, visualChannels, data, dataset) {
9544
- const {
9545
- colorField,
9546
- colorScale,
9547
- radiusField,
9548
- radiusScale,
9549
- strokeColorField,
9550
- strokeColorScale,
9551
- weightField
9552
- } = visualChannels;
9553
- const { heightField, heightScale } = visualChannels;
10261
+ if (layerType === "raster") {
10262
+ const rasterMetadata = data.raster_metadata;
10263
+ if (!rasterMetadata) {
10264
+ return {
10265
+ channelProps: {},
10266
+ scales: {}
10267
+ };
10268
+ }
10269
+ const rasterStyleType = config2.visConfig.rasterStyleType;
10270
+ if (rasterStyleType === "Rgb") {
10271
+ return {
10272
+ channelProps: getRasterTileLayerStylePropsRgb({
10273
+ layerConfig: config2,
10274
+ rasterMetadata,
10275
+ visualChannels
10276
+ }),
10277
+ scales: {}
10278
+ // TODO
10279
+ };
10280
+ } else {
10281
+ return {
10282
+ channelProps: getRasterTileLayerStylePropsScaledBand({
10283
+ layerConfig: config2,
10284
+ visualChannels,
10285
+ rasterMetadata
10286
+ }),
10287
+ scales: {
10288
+ // TODO
10289
+ }
10290
+ };
10291
+ }
10292
+ }
9554
10293
  const { textLabel, visConfig } = config2;
9555
10294
  const result = {};
10295
+ const updateTriggers = {};
9556
10296
  const scales = {};
9557
- if (colorField) {
9558
- const { colorAggregation: aggregation, colorRange: range } = visConfig;
9559
- const { accessor, scale: scale2 } = getColorAccessor(
9560
- colorField,
9561
- colorScale,
9562
- { aggregation, range },
9563
- visConfig.opacity,
9564
- data
9565
- );
9566
- result.getFillColor = accessor;
9567
- scales.fillColor = {
9568
- field: colorField,
9569
- type: colorScale,
9570
- ...domainAndRangeFromScale(scale2)
9571
- };
9572
- } else if (visConfig.filled) {
9573
- scales.fillColor = {};
10297
+ {
10298
+ const { colorField, colorScale } = visualChannels;
10299
+ const { colorRange, colorAggregation } = visConfig;
10300
+ if (colorField && colorScale && colorRange) {
10301
+ const { accessor, ...scaleProps } = getColorAccessor(
10302
+ colorField,
10303
+ colorScale,
10304
+ { aggregation: colorAggregation, range: colorRange },
10305
+ visConfig.opacity,
10306
+ data
10307
+ );
10308
+ result.getFillColor = accessor;
10309
+ scales.fillColor = updateTriggers.getFillColor = {
10310
+ field: colorField,
10311
+ type: colorScale,
10312
+ ...scaleProps
10313
+ };
10314
+ } else {
10315
+ scales.fillColor = {};
10316
+ }
9574
10317
  }
9575
10318
  if (layerType === "clusterTile") {
9576
10319
  const aggregationExpAlias = getDefaultAggregationExpColumnAliasForLayerType(
@@ -9583,6 +10326,7 @@ function createChannelProps(id, layerType, config2, visualChannels, data, datase
9583
10326
  result.getWeight = (d) => {
9584
10327
  return d.properties[aggregationExpAlias];
9585
10328
  };
10329
+ updateTriggers.getWeight = aggregationExpAlias;
9586
10330
  result.getPointRadius = (d, info) => {
9587
10331
  return calculateClusterRadius(
9588
10332
  d.properties,
@@ -9591,11 +10335,16 @@ function createChannelProps(id, layerType, config2, visualChannels, data, datase
9591
10335
  aggregationExpAlias
9592
10336
  );
9593
10337
  };
10338
+ updateTriggers.getPointRadius = {
10339
+ aggregationExpAlias,
10340
+ radiusRange: visConfig.radiusRange
10341
+ };
9594
10342
  result.textCharacterSet = "auto";
9595
10343
  result.textFontFamily = "Inter, sans";
9596
10344
  result.textFontSettings = { sdf: true };
9597
10345
  result.textFontWeight = 600;
9598
10346
  result.getText = (d) => TEXT_NUMBER_FORMATTER.format(d.properties[aggregationExpAlias]);
10347
+ updateTriggers.getText = aggregationExpAlias;
9599
10348
  result.getTextColor = config2.textLabel[TEXT_LABEL_INDEX].color;
9600
10349
  result.textOutlineColor = [
9601
10350
  ...config2.textLabel[TEXT_LABEL_INDEX].outlineColor,
@@ -9612,68 +10361,107 @@ function createChannelProps(id, layerType, config2, visualChannels, data, datase
9612
10361
  );
9613
10362
  return calculateClusterTextFontSize(radius);
9614
10363
  };
9615
- }
9616
- if (radiusField) {
9617
- const { accessor, scale: scale2 } = getSizeAccessor(
9618
- radiusField,
9619
- radiusScale,
9620
- visConfig.sizeAggregation,
9621
- visConfig.radiusRange || visConfig.sizeRange,
9622
- data
9623
- );
9624
- result.getPointRadius = accessor;
9625
- scales.pointRadius = {
9626
- field: radiusField,
9627
- type: radiusScale || "identity",
9628
- ...domainAndRangeFromScale(scale2)
10364
+ updateTriggers.getTextSize = {
10365
+ aggregationExpAlias,
10366
+ radiusRange: visConfig.radiusRange
9629
10367
  };
9630
10368
  }
9631
- if (strokeColorField) {
9632
- const opacity = visConfig.strokeOpacity !== void 0 ? visConfig.strokeOpacity : 1;
9633
- const { strokeColorAggregation: aggregation, strokeColorRange: range } = visConfig;
9634
- const { accessor, scale: scale2 } = getColorAccessor(
9635
- strokeColorField,
9636
- strokeColorScale,
9637
- { aggregation, range },
9638
- opacity,
9639
- data
9640
- );
9641
- result.getLineColor = accessor;
9642
- scales.lineColor = {
9643
- field: strokeColorField,
9644
- type: strokeColorScale,
9645
- ...domainAndRangeFromScale(scale2)
9646
- };
10369
+ {
10370
+ const radiusRange = visConfig.radiusRange;
10371
+ const { radiusField, radiusScale } = visualChannels;
10372
+ if (radiusField && radiusRange && radiusScale) {
10373
+ const { accessor, ...scaleProps } = getSizeAccessor(
10374
+ radiusField,
10375
+ radiusScale,
10376
+ visConfig.sizeAggregation,
10377
+ radiusRange,
10378
+ data
10379
+ );
10380
+ result.getPointRadius = accessor;
10381
+ scales.pointRadius = updateTriggers.getPointRadius = {
10382
+ field: radiusField,
10383
+ type: radiusScale,
10384
+ ...scaleProps
10385
+ };
10386
+ }
9647
10387
  }
9648
- if (heightField && visConfig.enable3d) {
9649
- const { accessor, scale: scale2 } = getSizeAccessor(
9650
- heightField,
9651
- heightScale,
9652
- visConfig.heightAggregation,
9653
- visConfig.heightRange || visConfig.sizeRange,
9654
- data
9655
- );
9656
- result.getElevation = accessor;
9657
- scales.elevation = {
9658
- field: heightField,
9659
- type: heightScale || "identity",
9660
- ...domainAndRangeFromScale(scale2)
9661
- };
10388
+ {
10389
+ const strokeColorRange = visConfig.strokeColorRange;
10390
+ const { strokeColorScale, strokeColorField } = visualChannels;
10391
+ if (strokeColorField && strokeColorRange && strokeColorScale) {
10392
+ const { strokeColorAggregation: aggregation } = visConfig;
10393
+ const opacity = visConfig.strokeOpacity !== void 0 ? visConfig.strokeOpacity : 1;
10394
+ const { accessor, ...scaleProps } = getColorAccessor(
10395
+ strokeColorField,
10396
+ strokeColorScale,
10397
+ { aggregation, range: strokeColorRange },
10398
+ opacity,
10399
+ data
10400
+ );
10401
+ result.getLineColor = accessor;
10402
+ scales.lineColor = updateTriggers.getLineColor = {
10403
+ field: strokeColorField,
10404
+ type: strokeColorScale,
10405
+ ...scaleProps
10406
+ };
10407
+ }
9662
10408
  }
9663
- if (weightField) {
9664
- const { accessor, scale: scale2 } = getSizeAccessor(
9665
- weightField,
9666
- void 0,
9667
- visConfig.weightAggregation,
9668
- void 0,
9669
- data
9670
- );
9671
- result.getWeight = accessor;
9672
- scales.weight = {
9673
- field: weightField,
9674
- type: "identity",
9675
- ...domainAndRangeFromScale(scale2)
9676
- };
10409
+ {
10410
+ const { sizeField: strokeWidthField, sizeScale: strokeWidthScale } = visualChannels;
10411
+ const { sizeRange, sizeAggregation } = visConfig;
10412
+ if (strokeWidthField && sizeRange) {
10413
+ const { accessor, ...scaleProps } = getSizeAccessor(
10414
+ strokeWidthField,
10415
+ strokeWidthScale,
10416
+ sizeAggregation,
10417
+ sizeRange,
10418
+ data
10419
+ );
10420
+ result.getLineWidth = accessor;
10421
+ scales.lineWidth = updateTriggers.getLineWidth = {
10422
+ field: strokeWidthField,
10423
+ type: strokeWidthScale || "identity",
10424
+ ...scaleProps
10425
+ };
10426
+ }
10427
+ }
10428
+ {
10429
+ const { enable3d, heightRange } = visConfig;
10430
+ const { heightField, heightScale } = visualChannels;
10431
+ if (heightField && heightRange && enable3d) {
10432
+ const { accessor, ...scaleProps } = getSizeAccessor(
10433
+ heightField,
10434
+ heightScale,
10435
+ visConfig.heightAggregation,
10436
+ heightRange,
10437
+ data
10438
+ );
10439
+ result.getElevation = accessor;
10440
+ scales.elevation = updateTriggers.getElevation = {
10441
+ field: heightField,
10442
+ type: heightScale || "identity",
10443
+ ...scaleProps
10444
+ };
10445
+ }
10446
+ }
10447
+ {
10448
+ const { weightField } = visualChannels;
10449
+ const { weightAggregation } = visConfig;
10450
+ if (weightField && weightAggregation) {
10451
+ const { accessor, ...scaleProps } = getSizeAccessor(
10452
+ weightField,
10453
+ void 0,
10454
+ weightAggregation,
10455
+ void 0,
10456
+ data
10457
+ );
10458
+ result.getWeight = accessor;
10459
+ scales.weight = updateTriggers.getWeight = {
10460
+ field: weightField,
10461
+ type: "identity",
10462
+ ...scaleProps
10463
+ };
10464
+ }
9677
10465
  }
9678
10466
  if (visConfig.customMarkers) {
9679
10467
  const maxIconSize = getMaxMarkerSize(visConfig, visualChannels);
@@ -9690,6 +10478,12 @@ function createChannelProps(id, layerType, config2, visualChannels, data, datase
9690
10478
  { fallbackUrl: customMarkersUrl, maxIconSize, useMaskedIcons },
9691
10479
  data
9692
10480
  );
10481
+ updateTriggers.getIcon = {
10482
+ customMarkersUrl,
10483
+ customMarkersRange,
10484
+ maxIconSize,
10485
+ useMaskedIcons
10486
+ };
9693
10487
  result._subLayerProps = {
9694
10488
  "points-icon": {
9695
10489
  loadOptions: {
@@ -9706,9 +10500,11 @@ function createChannelProps(id, layerType, config2, visualChannels, data, datase
9706
10500
  };
9707
10501
  if (getFillColor && useMaskedIcons) {
9708
10502
  result.getIconColor = getFillColor;
10503
+ updateTriggers.getIconColor = updateTriggers.getFillColor;
9709
10504
  }
9710
10505
  if (getPointRadius) {
9711
10506
  result.getIconSize = getPointRadius;
10507
+ updateTriggers.getIconSize = updateTriggers.getPointRadius;
9712
10508
  }
9713
10509
  if (visualChannels.rotationField) {
9714
10510
  const { accessor } = getSizeAccessor(
@@ -9719,6 +10515,7 @@ function createChannelProps(id, layerType, config2, visualChannels, data, datase
9719
10515
  data
9720
10516
  );
9721
10517
  result.getIconAngle = negateAccessor(accessor);
10518
+ updateTriggers.getIconAngle = updateTriggers.getRotationField;
9722
10519
  }
9723
10520
  } else if (layerType === "tileset") {
9724
10521
  result.pointType = "circle";
@@ -9763,7 +10560,13 @@ function createChannelProps(id, layerType, config2, visualChannels, data, datase
9763
10560
  }
9764
10561
  };
9765
10562
  }
9766
- return { channelProps: result, scales };
10563
+ return {
10564
+ channelProps: {
10565
+ ...result,
10566
+ updateTriggers
10567
+ },
10568
+ scales
10569
+ };
9767
10570
  }
9768
10571
  function createLoadOptions(accessToken) {
9769
10572
  return {
@@ -10410,9 +11213,16 @@ export {
10410
11213
  WidgetSource,
10411
11214
  WidgetTableSource,
10412
11215
  WidgetTilesetSource,
11216
+ ErrorCode as _ErrorCode,
11217
+ applyLayerGroupFilters as _applyLayerGroupFilters,
10413
11218
  _buildFeatureFilter,
11219
+ createVecExprEvaluator as _createVecExprEvaluator,
10414
11220
  domainFromValues as _domainFromValues,
11221
+ evaluateVecExpr as _evaluateVecExpr,
10415
11222
  _getHexagonResolution,
11223
+ getLog10ScaleSteps as _getLog10ScaleSteps,
11224
+ getRasterTileLayerStyleProps as _getRasterTileLayerStyleProps,
11225
+ validateVecExprSyntax as _validateVecExprSyntax,
10416
11226
  addFilter,
10417
11227
  aggregate,
10418
11228
  aggregationFunctions,
@@ -10425,9 +11235,11 @@ export {
10425
11235
  buildStatsUrl,
10426
11236
  calculateClusterRadius,
10427
11237
  calculateClusterTextFontSize,
11238
+ calculateLayerScale,
10428
11239
  clearDefaultRequestCache,
10429
11240
  clearFilters,
10430
11241
  configureSource,
11242
+ createColorScale,
10431
11243
  createPolygonSpatialFilter,
10432
11244
  createViewportSpatialFilter,
10433
11245
  fetchBasemapProps,
@@ -10442,6 +11254,7 @@ export {
10442
11254
  getDefaultAggregationExpColumnAliasForLayerType,
10443
11255
  getFilter,
10444
11256
  getIconUrlAccessor,
11257
+ getLayerDescriptor,
10445
11258
  getLayerProps,
10446
11259
  getMaxMarkerSize,
10447
11260
  getSizeAccessor,