@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.
@@ -125,9 +125,16 @@ __export(src_exports, {
125
125
  WidgetSource: () => WidgetSource,
126
126
  WidgetTableSource: () => WidgetTableSource,
127
127
  WidgetTilesetSource: () => WidgetTilesetSource,
128
+ _ErrorCode: () => ErrorCode,
129
+ _applyLayerGroupFilters: () => applyLayerGroupFilters,
128
130
  _buildFeatureFilter: () => _buildFeatureFilter,
131
+ _createVecExprEvaluator: () => createVecExprEvaluator,
129
132
  _domainFromValues: () => domainFromValues,
133
+ _evaluateVecExpr: () => evaluateVecExpr,
130
134
  _getHexagonResolution: () => _getHexagonResolution,
135
+ _getLog10ScaleSteps: () => getLog10ScaleSteps,
136
+ _getRasterTileLayerStyleProps: () => getRasterTileLayerStyleProps,
137
+ _validateVecExprSyntax: () => validateVecExprSyntax,
131
138
  addFilter: () => addFilter,
132
139
  aggregate: () => aggregate,
133
140
  aggregationFunctions: () => aggregationFunctions,
@@ -140,9 +147,11 @@ __export(src_exports, {
140
147
  buildStatsUrl: () => buildStatsUrl,
141
148
  calculateClusterRadius: () => calculateClusterRadius,
142
149
  calculateClusterTextFontSize: () => calculateClusterTextFontSize,
150
+ calculateLayerScale: () => calculateLayerScale,
143
151
  clearDefaultRequestCache: () => clearDefaultRequestCache,
144
152
  clearFilters: () => clearFilters,
145
153
  configureSource: () => configureSource,
154
+ createColorScale: () => createColorScale,
146
155
  createPolygonSpatialFilter: () => createPolygonSpatialFilter,
147
156
  createViewportSpatialFilter: () => createViewportSpatialFilter,
148
157
  fetchBasemapProps: () => fetchBasemapProps,
@@ -157,6 +166,7 @@ __export(src_exports, {
157
166
  getDefaultAggregationExpColumnAliasForLayerType: () => getDefaultAggregationExpColumnAliasForLayerType,
158
167
  getFilter: () => getFilter,
159
168
  getIconUrlAccessor: () => getIconUrlAccessor,
169
+ getLayerDescriptor: () => getLayerDescriptor,
160
170
  getLayerProps: () => getLayerProps,
161
171
  getMaxMarkerSize: () => getMaxMarkerSize,
162
172
  getSizeAccessor: () => getSizeAccessor,
@@ -8808,11 +8818,253 @@ var basemap_styles_default = {
8808
8818
  DARK_MATTER_NOLABELS: getStyleUrl("dark-matter-nolabels")
8809
8819
  };
8810
8820
 
8811
- // src/fetch-map/fetch-map.ts
8821
+ // src/fetch-map/raster-layer.ts
8812
8822
  init_cjs_shims();
8813
8823
 
8814
- // src/fetch-map/parse-map.ts
8824
+ // src/fetch-map/vec-expr-evaluator.ts
8815
8825
  init_cjs_shims();
8826
+ var import_jsep = __toESM(require("jsep"), 1);
8827
+ function createVecExprEvaluator(expression) {
8828
+ try {
8829
+ const parsed = compile(expression);
8830
+ const evalFun = (context) => evaluate(parsed, context);
8831
+ evalFun.symbols = getSymbols(parsed);
8832
+ return evalFun;
8833
+ } catch {
8834
+ return null;
8835
+ }
8836
+ }
8837
+ function evaluateVecExpr(expression, context) {
8838
+ try {
8839
+ return createVecExprEvaluator(expression)?.(context);
8840
+ } catch {
8841
+ return null;
8842
+ }
8843
+ }
8844
+ var ErrorCode = /* @__PURE__ */ ((ErrorCode2) => {
8845
+ ErrorCode2[ErrorCode2["InvalidSyntax"] = 0] = "InvalidSyntax";
8846
+ ErrorCode2[ErrorCode2["UnknownIdentifier"] = 1] = "UnknownIdentifier";
8847
+ return ErrorCode2;
8848
+ })(ErrorCode || {});
8849
+ function validateVecExprSyntax(expression, context) {
8850
+ let parsed;
8851
+ try {
8852
+ parsed = compile(expression);
8853
+ } catch (e) {
8854
+ return {
8855
+ valid: false,
8856
+ errorCode: 0 /* InvalidSyntax */,
8857
+ errorMessage: e && "message" in e ? String(e.message) : String(e)
8858
+ };
8859
+ }
8860
+ return validate(parsed, context);
8861
+ }
8862
+ function createResultArray(typeTemplate, length2 = typeTemplate.length) {
8863
+ return new Array(length2);
8864
+ }
8865
+ function isVecLike(a) {
8866
+ return Array.isArray(a) || ArrayBuffer.isView(a);
8867
+ }
8868
+ var createBinopVec = (scalarBinOp) => (left, right) => {
8869
+ const length2 = Math.min(left.length, right.length);
8870
+ const r = createResultArray(left, length2);
8871
+ for (let i = 0; i < length2; i++) {
8872
+ r[i] = scalarBinOp(left[i], right[i]);
8873
+ }
8874
+ return r;
8875
+ };
8876
+ var createBinopVecNum = (scalarBinOp) => (left, right) => {
8877
+ const length2 = left.length;
8878
+ const r = createResultArray(left, length2);
8879
+ for (let i = 0; i < length2; i++) {
8880
+ r[i] = scalarBinOp(left[i], right);
8881
+ }
8882
+ return r;
8883
+ };
8884
+ var createBinopNumVec = (scalarBinOp) => (left, right) => {
8885
+ const length2 = right.length;
8886
+ const r = createResultArray(right, length2);
8887
+ for (let i = 0; i < length2; i++) {
8888
+ r[i] = scalarBinOp(left, right[i]);
8889
+ }
8890
+ return r;
8891
+ };
8892
+ var createUnopVec = (scalarUnop) => (a) => {
8893
+ const length2 = a.length;
8894
+ const r = createResultArray(a, length2);
8895
+ for (let i = 0; i < length2; i++) {
8896
+ r[i] = scalarUnop(a[i]);
8897
+ }
8898
+ return r;
8899
+ };
8900
+ function mapDictValues(dict, fun) {
8901
+ return Object.keys(dict).reduce(
8902
+ (acc, key) => {
8903
+ acc[key] = fun(dict[key]);
8904
+ return acc;
8905
+ },
8906
+ {}
8907
+ );
8908
+ }
8909
+ var binopsNum = {
8910
+ "||": (a, b) => a || b,
8911
+ "&&": (a, b) => a && b,
8912
+ "|": (a, b) => a | b,
8913
+ "^": (a, b) => a ^ b,
8914
+ "&": (a, b) => a & b,
8915
+ "==": (a, b) => Number(a == b),
8916
+ "!=": (a, b) => Number(a != b),
8917
+ "===": (a, b) => Number(a === b),
8918
+ "!==": (a, b) => Number(a !== b),
8919
+ "<": (a, b) => Number(a < b),
8920
+ ">": (a, b) => Number(a > b),
8921
+ "<=": (a, b) => Number(a <= b),
8922
+ ">=": (a, b) => Number(a >= b),
8923
+ "<<": (a, b) => a << b,
8924
+ ">>": (a, b) => a >> b,
8925
+ ">>>": (a, b) => a >>> b,
8926
+ "+": (a, b) => a + b,
8927
+ "-": (a, b) => a - b,
8928
+ "*": (a, b) => a * b,
8929
+ "/": (a, b) => a / b,
8930
+ "%": (a, b) => a % b
8931
+ };
8932
+ var unopsNum = {
8933
+ "-": (a) => -a,
8934
+ "+": (a) => +a,
8935
+ "~": (a) => ~a,
8936
+ "!": (a) => Number(!a)
8937
+ };
8938
+ var binopsVector = mapDictValues(binopsNum, createBinopVec);
8939
+ var binopsNumVec = mapDictValues(binopsNum, createBinopNumVec);
8940
+ var binopsVecNum = mapDictValues(binopsNum, createBinopVecNum);
8941
+ var unopsVector = mapDictValues(unopsNum, createUnopVec);
8942
+ function getBinop(operator, left, right) {
8943
+ const isLeftVec = isVecLike(left);
8944
+ const isRightVec = isVecLike(right);
8945
+ if (isLeftVec && isRightVec) {
8946
+ return binopsVector[operator];
8947
+ } else if (isLeftVec) {
8948
+ return binopsVecNum[operator];
8949
+ } else if (isRightVec) {
8950
+ return binopsNumVec[operator];
8951
+ } else {
8952
+ return binopsNum[operator];
8953
+ }
8954
+ }
8955
+ function evaluate(_node, context) {
8956
+ const node = _node;
8957
+ switch (node.type) {
8958
+ case "BinaryExpression": {
8959
+ const left = evaluate(node.left, context);
8960
+ const right = evaluate(node.right, context);
8961
+ const binopFun = getBinop(node.operator, left, right);
8962
+ return binopFun(left, right);
8963
+ }
8964
+ case "ConditionalExpression": {
8965
+ const val = evaluate(node.test, context);
8966
+ if (isVecLike(val)) {
8967
+ const length2 = val.length;
8968
+ const consequentVal = evaluate(node.consequent, context);
8969
+ const alternateVal = evaluate(node.alternate, context);
8970
+ const r = createResultArray(val);
8971
+ for (let i = 0; i < length2; i++) {
8972
+ const entryVal = val[i] ? consequentVal : alternateVal;
8973
+ r[i] = isVecLike(entryVal) ? entryVal[i] ?? NaN : entryVal;
8974
+ }
8975
+ return r;
8976
+ } else {
8977
+ return val ? evaluate(node.consequent, context) : evaluate(node.alternate, context);
8978
+ }
8979
+ }
8980
+ case "Identifier":
8981
+ return context[node.name];
8982
+ case "Literal":
8983
+ return node.value;
8984
+ case "UnaryExpression": {
8985
+ const val = evaluate(node.argument, context);
8986
+ const unopFun = isVecLike(val) ? unopsVector[node.operator] : unopsNum[node.operator];
8987
+ return unopFun(val);
8988
+ }
8989
+ default:
8990
+ return void 0;
8991
+ }
8992
+ }
8993
+ var validResult = { valid: true };
8994
+ function visit(_node, visitor) {
8995
+ const node = _node;
8996
+ visitor(node);
8997
+ switch (node.type) {
8998
+ case "BinaryExpression": {
8999
+ visit(node.left, visitor);
9000
+ visit(node.right, visitor);
9001
+ break;
9002
+ }
9003
+ case "ConditionalExpression": {
9004
+ visit(node.test, visitor);
9005
+ visit(node.consequent, visitor);
9006
+ visit(node.alternate, visitor);
9007
+ break;
9008
+ }
9009
+ case "UnaryExpression": {
9010
+ visit(node.argument, visitor);
9011
+ break;
9012
+ }
9013
+ }
9014
+ }
9015
+ var supportedExpressionTypes = [
9016
+ "BinaryExpression",
9017
+ "UnaryExpression",
9018
+ "ConditionalExpression",
9019
+ "LogicalExpression",
9020
+ "Identifier",
9021
+ "Literal"
9022
+ ];
9023
+ function validate(_node, context) {
9024
+ const node = _node;
9025
+ const errors = [];
9026
+ visit(node, (node2) => {
9027
+ if (!supportedExpressionTypes.includes(node2.type)) {
9028
+ errors.push({
9029
+ valid: false,
9030
+ errorCode: 0 /* InvalidSyntax */,
9031
+ errorMessage: `Not allowed`
9032
+ });
9033
+ return;
9034
+ }
9035
+ if (node2.type === "Identifier") {
9036
+ if (!Object.prototype.hasOwnProperty.call(context, node2.name)) {
9037
+ return errors.push({
9038
+ valid: false,
9039
+ errorCode: 1 /* UnknownIdentifier */,
9040
+ errorMessage: `"${node2.name}" not found`
9041
+ });
9042
+ }
9043
+ }
9044
+ if (node2.type === "Literal") {
9045
+ if (typeof node2.value !== "number") {
9046
+ return errors.push({
9047
+ valid: false,
9048
+ errorCode: 0 /* InvalidSyntax */,
9049
+ errorMessage: `Only number literals are supported`
9050
+ });
9051
+ }
9052
+ }
9053
+ });
9054
+ return errors.length ? errors[0] : validResult;
9055
+ }
9056
+ function getSymbols(node) {
9057
+ const symbols = /* @__PURE__ */ new Set();
9058
+ visit(node, (node2) => {
9059
+ if (node2.type === "Identifier") {
9060
+ symbols.add(node2.name);
9061
+ }
9062
+ });
9063
+ return Array.from(symbols);
9064
+ }
9065
+ function compile(expression) {
9066
+ return (0, import_jsep.default)(expression);
9067
+ }
8816
9068
 
8817
9069
  // src/fetch-map/layer-map.ts
8818
9070
  init_cjs_shims();
@@ -9411,6 +9663,37 @@ function formatDate(value) {
9411
9663
  function formatTimestamp(value) {
9412
9664
  return String(Math.floor(new Date(value).getTime() / 1e3));
9413
9665
  }
9666
+ function roundedPow10(exp) {
9667
+ const raw = Math.pow(10, exp);
9668
+ if (exp < 0) {
9669
+ const shift = Math.pow(10, -exp);
9670
+ return Math.round(raw * shift) / shift;
9671
+ }
9672
+ return raw;
9673
+ }
9674
+ function getLog10ScaleSteps({
9675
+ min: min2,
9676
+ max: max2,
9677
+ steps
9678
+ }) {
9679
+ if (min2 === 0) {
9680
+ if (max2 === Infinity) {
9681
+ return [...Array(steps - 1)].map((_v, i) => roundedPow10(i + 1));
9682
+ }
9683
+ const maxLog = Math.log10(max2);
9684
+ const endExponent = Math.ceil(maxLog);
9685
+ const startExponent = endExponent - steps + 1;
9686
+ return [...Array(steps - 1)].map(
9687
+ (_v, i) => roundedPow10(startExponent + i)
9688
+ );
9689
+ } else {
9690
+ const minLog = Math.log10(min2);
9691
+ const startExponent = Math.ceil(minLog) === minLog ? minLog + 1 : Math.ceil(minLog);
9692
+ return [...Array(steps - 1)].map(
9693
+ (_v, i) => roundedPow10(startExponent + i)
9694
+ );
9695
+ }
9696
+ }
9414
9697
 
9415
9698
  // src/fetch-map/layer-map.ts
9416
9699
  var SCALE_FUNCS = {
@@ -9427,7 +9710,19 @@ var SCALE_FUNCS = {
9427
9710
  function identity2(v2) {
9428
9711
  return v2;
9429
9712
  }
9713
+ var hexToRGB = (c) => {
9714
+ const { r, g, b } = rgb(c);
9715
+ return [r, g, b];
9716
+ };
9717
+ var rgbToHex = (c) => {
9718
+ const [r, g, b] = c;
9719
+ const rStr = r.toString(16).padStart(2, "0");
9720
+ const gStr = g.toString(16).padStart(2, "0");
9721
+ const bStr = b.toString(16).padStart(2, "0");
9722
+ return `#${rStr}${gStr}${bStr}`.toUpperCase();
9723
+ };
9430
9724
  var UNKNOWN_COLOR = "#868d91";
9725
+ var UNKNOWN_COLOR_RGB = hexToRGB(UNKNOWN_COLOR);
9431
9726
  var OPACITY_MAP = {
9432
9727
  getFillColor: "opacity",
9433
9728
  getLineColor: "strokeOpacity",
@@ -9460,6 +9755,12 @@ var sharedPropMap = {
9460
9755
  wireframe: "wireframe"
9461
9756
  }
9462
9757
  };
9758
+ var rasterPropsMap = {
9759
+ isVisible: "visible",
9760
+ visConfig: {
9761
+ opacity: "opacity"
9762
+ }
9763
+ };
9463
9764
  var customMarkersPropsMap = {
9464
9765
  color: "getIconColor",
9465
9766
  visConfig: {
@@ -9503,6 +9804,12 @@ function getLayerProps(type, config2, dataset) {
9503
9804
  `Outdated layer type: ${type}. Please open map in CARTO Builder to automatically migrate.`
9504
9805
  );
9505
9806
  }
9807
+ if (type === "raster") {
9808
+ return {
9809
+ propMap: rasterPropsMap,
9810
+ defaultProps: {}
9811
+ };
9812
+ }
9506
9813
  let basePropMap = sharedPropMap;
9507
9814
  if (config2.visConfig?.customMarkers) {
9508
9815
  basePropMap = mergePropMaps(basePropMap, customMarkersPropsMap);
@@ -9523,16 +9830,19 @@ function getLayerProps(type, config2, dataset) {
9523
9830
  }
9524
9831
  function domainFromAttribute(attribute, scaleType, scaleLength) {
9525
9832
  if (scaleType === "ordinal" || scaleType === "point") {
9833
+ if (!attribute.categories) {
9834
+ return [0, 1];
9835
+ }
9526
9836
  return attribute.categories.map((c) => c.category).filter((c) => c !== void 0 && c !== null);
9527
9837
  }
9528
9838
  if (scaleType === "quantile" && attribute.quantiles) {
9529
- return attribute.quantiles.global ? attribute.quantiles.global[scaleLength] : attribute.quantiles[scaleLength];
9839
+ return "global" in attribute.quantiles ? attribute.quantiles.global[scaleLength] : attribute.quantiles[scaleLength];
9530
9840
  }
9531
9841
  let { min: min2 } = attribute;
9532
9842
  if (scaleType === "log" && min2 === 0) {
9533
9843
  min2 = 1e-5;
9534
9844
  }
9535
- return [min2, attribute.max];
9845
+ return [min2 ?? 0, attribute.max ?? 1];
9536
9846
  }
9537
9847
  function domainFromValues(values, scaleType) {
9538
9848
  if (scaleType === "ordinal" || scaleType === "point") {
@@ -9553,12 +9863,14 @@ function calculateDomain(data, name, scaleType, scaleLength) {
9553
9863
  if (data.tilestats) {
9554
9864
  const { attributes } = data.tilestats.layers[0];
9555
9865
  const attribute = attributes.find((a) => a.attribute === name);
9556
- return domainFromAttribute(attribute, scaleType, scaleLength);
9866
+ if (attribute) {
9867
+ return domainFromAttribute(attribute, scaleType, scaleLength);
9868
+ }
9557
9869
  }
9558
9870
  return [0, 1];
9559
9871
  }
9560
9872
  function normalizeAccessor(accessor, data) {
9561
- if (data.features || data.tilestats) {
9873
+ if (data.features || data.tilestats || data.raster_metadata) {
9562
9874
  return (object, info) => {
9563
9875
  if (object) {
9564
9876
  return accessor(object.properties || object.__source.object.properties);
@@ -9591,46 +9903,75 @@ function findAccessorKey(keys, properties) {
9591
9903
  return keys;
9592
9904
  }
9593
9905
  function getColorAccessor({ name, colorColumn }, scaleType, { aggregation, range }, opacity, data) {
9594
- const scale2 = calculateLayerScale(
9906
+ const { scale: scale2, domain } = calculateLayerScale(
9595
9907
  colorColumn || name,
9596
- scaleType,
9908
+ colorColumn ? "identity" : scaleType,
9597
9909
  range,
9598
9910
  data
9599
9911
  );
9600
9912
  const alpha = opacityToAlpha(opacity);
9601
- let accessorKeys = getAccessorKeys(name, aggregation);
9913
+ let accessorKeys = getAccessorKeys(colorColumn || name, aggregation);
9602
9914
  const accessor = (properties) => {
9603
9915
  if (!(accessorKeys[0] in properties)) {
9604
9916
  accessorKeys = findAccessorKey(accessorKeys, properties);
9605
9917
  }
9606
9918
  const propertyValue = properties[accessorKeys[0]];
9607
- const { r, g, b } = rgb(scale2(propertyValue));
9608
- return [r, g, b, propertyValue === null ? 0 : alpha];
9919
+ const scaled = scale2(propertyValue);
9920
+ const rgb2 = typeof scaled === "string" ? hexToRGB(scaled) : scaled;
9921
+ return [...rgb2, propertyValue === null ? 0 : alpha];
9922
+ };
9923
+ return {
9924
+ accessor: normalizeAccessor(accessor, data),
9925
+ scaleDomain: scale2.domain(),
9926
+ domain,
9927
+ range: (scale2.range() || []).map(rgbToHex)
9609
9928
  };
9610
- return { accessor: normalizeAccessor(accessor, data), scale: scale2 };
9611
9929
  }
9612
9930
  function calculateLayerScale(name, scaleType, range, data) {
9613
- const scale2 = SCALE_FUNCS[scaleType]();
9614
9931
  let domain = [];
9932
+ let scaleDomain;
9615
9933
  let scaleColor = [];
9616
- if (scaleType !== "identity") {
9617
- const { colorMap, colors } = range;
9618
- if (Array.isArray(colorMap)) {
9934
+ const { colors } = range;
9935
+ if (scaleType === "custom") {
9936
+ domain = calculateDomain(data, name, scaleType, colors.length);
9937
+ const [min2, max2] = domain;
9938
+ if (range.uiCustomScaleType === "logarithmic") {
9939
+ scaleDomain = getLog10ScaleSteps({
9940
+ min: min2,
9941
+ max: max2,
9942
+ steps: colors.length
9943
+ });
9944
+ scaleColor = colors;
9945
+ } else if (range.colorMap) {
9946
+ const { colorMap } = range;
9947
+ scaleDomain = [];
9619
9948
  colorMap.forEach(([value, color2]) => {
9620
- domain.push(value);
9949
+ scaleDomain.push(Number(value));
9621
9950
  scaleColor.push(color2);
9622
9951
  });
9623
- } else {
9624
- domain = calculateDomain(data, name, scaleType, colors.length);
9625
- scaleColor = colors;
9626
9952
  }
9953
+ } else if (scaleType !== "identity") {
9954
+ domain = calculateDomain(data, name, scaleType, colors.length);
9955
+ scaleColor = colors;
9627
9956
  if (scaleType === "ordinal") {
9628
9957
  domain = domain.slice(0, scaleColor.length);
9629
9958
  }
9630
9959
  }
9960
+ return {
9961
+ scale: createColorScale(
9962
+ scaleType,
9963
+ scaleDomain || domain,
9964
+ scaleColor.map(hexToRGB),
9965
+ UNKNOWN_COLOR_RGB
9966
+ ),
9967
+ domain
9968
+ };
9969
+ }
9970
+ function createColorScale(scaleType, domain, range, unknown) {
9971
+ const scale2 = SCALE_FUNCS[scaleType]();
9631
9972
  scale2.domain(domain);
9632
- scale2.range(scaleColor);
9633
- scale2.unknown(UNKNOWN_COLOR);
9973
+ scale2.range(range);
9974
+ scale2.unknown(unknown);
9634
9975
  return scale2;
9635
9976
  }
9636
9977
  var FALLBACK_ICON = "data:image/svg+xml;charset=utf-8;base64,PHN2ZyB2aWV3Qm94PSIwIDAgMTAwIDEwMCIgeG1sbnM9Imh0dHA6Ly93d3cudzMub3JnLzIwMDAvc3ZnIj4NCiAgPGNpcmNsZSBjeD0iNTAiIGN5PSI1MCIgcj0iNTAiLz4NCjwvc3ZnPg==";
@@ -9680,9 +10021,13 @@ function negateAccessor(accessor) {
9680
10021
  }
9681
10022
  function getSizeAccessor({ name }, scaleType, aggregation, range, data) {
9682
10023
  const scale2 = scaleType ? SCALE_FUNCS[scaleType]() : identity2;
9683
- if (scaleType) {
10024
+ let domain = [];
10025
+ if (scaleType && range) {
9684
10026
  if (aggregation !== AggregationTypes.Count) {
9685
- scale2.domain(calculateDomain(data, name, scaleType));
10027
+ domain = calculateDomain(data, name, scaleType);
10028
+ scale2.domain(domain);
10029
+ } else {
10030
+ domain = scale2.domain();
9686
10031
  }
9687
10032
  scale2.range(range);
9688
10033
  }
@@ -9694,7 +10039,12 @@ function getSizeAccessor({ name }, scaleType, aggregation, range, data) {
9694
10039
  const propertyValue = properties[accessorKeys[0]];
9695
10040
  return scale2(propertyValue);
9696
10041
  };
9697
- return { accessor: normalizeAccessor(accessor, data), scale: scale2 };
10042
+ return {
10043
+ accessor: normalizeAccessor(accessor, data),
10044
+ domain,
10045
+ scaleDomain: domain,
10046
+ range
10047
+ };
9698
10048
  }
9699
10049
  var FORMATS = {
9700
10050
  date: formatDate,
@@ -9745,13 +10095,424 @@ function calculateClusterTextFontSize(radius) {
9745
10095
  return 11;
9746
10096
  }
9747
10097
 
10098
+ // src/fetch-map/raster-layer.ts
10099
+ var UNKNOWN_COLOR2 = [134, 141, 145];
10100
+ var RASTER_COLOR_BANDS = ["red", "green", "blue"];
10101
+ function getHasDataPredicate(noData) {
10102
+ if (noData === "nan") {
10103
+ return (v2) => !isNaN(v2);
10104
+ }
10105
+ if (typeof noData === "string") {
10106
+ noData = parseFloat(noData);
10107
+ }
10108
+ if (typeof noData === "number") {
10109
+ return (v2) => v2 !== noData && !isNaN(v2);
10110
+ }
10111
+ return () => true;
10112
+ }
10113
+ function createRasterColumnLayerDataTransform(transform) {
10114
+ return (data) => {
10115
+ if (!data || !("data" in data) || !data?.data?.cells?.numericProps) {
10116
+ return data;
10117
+ }
10118
+ return transform(data);
10119
+ };
10120
+ }
10121
+ function createEvaluationContext(numericProps, noData) {
10122
+ const hasData = getHasDataPredicate(noData);
10123
+ const bands = Object.entries(numericProps).map(([bandName, { value }]) => ({
10124
+ bandName,
10125
+ values: value,
10126
+ copied: false
10127
+ }));
10128
+ const length2 = bands[0].values.length;
10129
+ for (let i = 0; i < length2; i++) {
10130
+ let hasSomeData = false;
10131
+ for (let j = 0; j < bands.length; j++) {
10132
+ hasSomeData = hasSomeData || hasData(bands[j].values[i]);
10133
+ }
10134
+ if (!hasSomeData) {
10135
+ for (let j = 0; j < bands.length; j++) {
10136
+ if (!bands[j].copied) {
10137
+ bands[j].copied = true;
10138
+ bands[j].values = Array.from(bands[j].values);
10139
+ }
10140
+ bands[j].values[i] = NaN;
10141
+ }
10142
+ }
10143
+ }
10144
+ const context = bands.reduce(
10145
+ (agg, { bandName, values }) => {
10146
+ agg[bandName] = values;
10147
+ return agg;
10148
+ },
10149
+ {}
10150
+ );
10151
+ return context;
10152
+ }
10153
+ function createExprDataTransform({
10154
+ colorBand,
10155
+ rasterMetadata,
10156
+ usedSymbols
10157
+ }) {
10158
+ if (!colorBand || !colorBand.type || colorBand.type === "none") {
10159
+ return void 0;
10160
+ }
10161
+ const expr = colorBand?.type === "expression" ? colorBand.value : void 0;
10162
+ const vecExprEvaluator = expr ? createVecExprEvaluator(expr) : void 0;
10163
+ const dataTransform = createRasterColumnLayerDataTransform(
10164
+ (dataWrapped) => {
10165
+ const data = dataWrapped.data;
10166
+ if (expr) {
10167
+ const cachedResult = dataWrapped.customExpressionResults?.[expr];
10168
+ if (cachedResult) {
10169
+ return dataWrapped;
10170
+ }
10171
+ }
10172
+ let context = dataWrapped.expressionEvalContext;
10173
+ if (!context) {
10174
+ const usedNumericProps = usedSymbols.reduce(
10175
+ (acc, symbol) => {
10176
+ acc[symbol] = data.cells.numericProps[symbol];
10177
+ return acc;
10178
+ },
10179
+ {}
10180
+ );
10181
+ context = createEvaluationContext(
10182
+ usedNumericProps,
10183
+ rasterMetadata.nodata
10184
+ );
10185
+ dataWrapped = {
10186
+ ...dataWrapped,
10187
+ expressionEvalContext: context
10188
+ };
10189
+ }
10190
+ if (!vecExprEvaluator || !expr) return dataWrapped;
10191
+ const evalResult = vecExprEvaluator(context);
10192
+ return {
10193
+ ...dataWrapped,
10194
+ customExpressionResults: {
10195
+ ...dataWrapped.customExpressionResults,
10196
+ [expr]: evalResult
10197
+ }
10198
+ };
10199
+ }
10200
+ );
10201
+ return dataTransform;
10202
+ }
10203
+ function combineDataTransforms(dataTransforms) {
10204
+ const actualTransforms = dataTransforms.filter((v2) => v2);
10205
+ if (actualTransforms.length === 0) return void 0;
10206
+ if (actualTransforms.length === 1) return actualTransforms[0];
10207
+ return (data) => actualTransforms.reduce(
10208
+ (aggData, transformFun) => transformFun(aggData),
10209
+ data
10210
+ );
10211
+ }
10212
+ function createRgbToColorBufferDataTransform({
10213
+ bandDefs,
10214
+ attribute
10215
+ }) {
10216
+ return createRasterColumnLayerDataTransform(
10217
+ (dataWrapped) => {
10218
+ const length2 = dataWrapped.length;
10219
+ const getBandBufferOrValue = (colorBand) => {
10220
+ if (colorBand?.type === "expression") {
10221
+ return dataWrapped.customExpressionResults?.[colorBand.value];
10222
+ }
10223
+ if (colorBand?.type === "band") {
10224
+ return dataWrapped.expressionEvalContext?.[colorBand.value];
10225
+ }
10226
+ return 0;
10227
+ };
10228
+ const red = getBandBufferOrValue(bandDefs.red);
10229
+ const green = getBandBufferOrValue(bandDefs.green);
10230
+ const blue = getBandBufferOrValue(bandDefs.blue);
10231
+ const colorBuffer = new Uint8Array(length2 * 4);
10232
+ for (let inputIndex = 0, outputIndex = 0; inputIndex < length2; inputIndex++, outputIndex += 4) {
10233
+ const redRaw = typeof red === "number" ? red : red ? red[inputIndex] : NaN;
10234
+ const greenRaw = typeof green === "number" ? green : green ? green[inputIndex] : NaN;
10235
+ const blueRaw = typeof blue === "number" ? blue : blue ? blue[inputIndex] : NaN;
10236
+ if (isNaN(redRaw) && isNaN(greenRaw) && isNaN(blueRaw)) {
10237
+ bufferSetRgba(colorBuffer, outputIndex, 0, 0, 0, 0);
10238
+ } else {
10239
+ bufferSetRgba(
10240
+ colorBuffer,
10241
+ outputIndex,
10242
+ redRaw,
10243
+ greenRaw,
10244
+ blueRaw,
10245
+ 255
10246
+ );
10247
+ }
10248
+ }
10249
+ dataWrapped.customExpressionResults = void 0;
10250
+ dataWrapped.expressionEvalContext = void 0;
10251
+ return {
10252
+ ...dataWrapped,
10253
+ attributes: {
10254
+ [attribute]: colorBuffer
10255
+ }
10256
+ };
10257
+ }
10258
+ );
10259
+ }
10260
+ function getUsedSymbols(colorBands) {
10261
+ return Array.from(
10262
+ colorBands.reduce((symbols, band) => {
10263
+ if (band.type === "expression") {
10264
+ const expressionSymbols = createVecExprEvaluator(band.value)?.symbols || [];
10265
+ expressionSymbols.forEach((symbol) => symbols.add(symbol));
10266
+ }
10267
+ if (band.type === "band") {
10268
+ symbols.add(band.value);
10269
+ }
10270
+ return symbols;
10271
+ }, /* @__PURE__ */ new Set())
10272
+ );
10273
+ }
10274
+ function getRasterTileLayerStylePropsRgb({
10275
+ layerConfig,
10276
+ rasterMetadata,
10277
+ visualChannels
10278
+ }) {
10279
+ const { visConfig } = layerConfig;
10280
+ const { colorBands } = visConfig;
10281
+ const bandDefs = {
10282
+ red: colorBands?.find((band) => band.band === "red"),
10283
+ green: colorBands?.find((band) => band.band === "green"),
10284
+ blue: colorBands?.find((band) => band.band === "blue")
10285
+ };
10286
+ const rgbToInstanceFillColorsDataTransform = createRgbToColorBufferDataTransform({
10287
+ bandDefs,
10288
+ attribute: "instanceFillColors"
10289
+ });
10290
+ const usedSymbols = colorBands ? getUsedSymbols(colorBands) : [];
10291
+ const bandTransforms = RASTER_COLOR_BANDS.map(
10292
+ (band) => createExprDataTransform({
10293
+ colorBand: bandDefs[band],
10294
+ rasterMetadata,
10295
+ usedSymbols
10296
+ })
10297
+ );
10298
+ const combinedDataTransform = combineDataTransforms([
10299
+ ...bandTransforms,
10300
+ rgbToInstanceFillColorsDataTransform
10301
+ ]);
10302
+ return {
10303
+ dataTransform: combinedDataTransform,
10304
+ updateTriggers: getRasterTileLayerUpdateTriggers({
10305
+ layerConfig,
10306
+ visualChannels
10307
+ })
10308
+ };
10309
+ }
10310
+ function createBandColorScaleDataTransform({
10311
+ bandName,
10312
+ scaleFun,
10313
+ nodata,
10314
+ attribute
10315
+ }) {
10316
+ const hasData = getHasDataPredicate(nodata);
10317
+ return createRasterColumnLayerDataTransform(
10318
+ (dataWrapped) => {
10319
+ const length2 = dataWrapped.length;
10320
+ const bandBuffer = dataWrapped.data.cells.numericProps[bandName].value;
10321
+ const colorBuffer = new Uint8Array(length2 * 4);
10322
+ for (let i = 0; i < length2; i++) {
10323
+ const rawValue = bandBuffer[i];
10324
+ if (!hasData(rawValue)) {
10325
+ bufferSetRgba(colorBuffer, i * 4, 0, 0, 0, 0);
10326
+ } else {
10327
+ const colorRgb = scaleFun(rawValue);
10328
+ bufferSetRgba(
10329
+ colorBuffer,
10330
+ i * 4,
10331
+ colorRgb[0],
10332
+ colorRgb[1],
10333
+ colorRgb[2],
10334
+ 255
10335
+ );
10336
+ }
10337
+ }
10338
+ return {
10339
+ ...dataWrapped,
10340
+ attributes: {
10341
+ [attribute]: colorBuffer
10342
+ }
10343
+ };
10344
+ }
10345
+ );
10346
+ }
10347
+ function domainFromRasterMetadataBand(band, scaleType, colorRange) {
10348
+ if (scaleType === "ordinal") {
10349
+ return colorRange.colorMap?.map(([value]) => value) || [];
10350
+ }
10351
+ if (scaleType === "custom") {
10352
+ if (colorRange.uiCustomScaleType === "logarithmic") {
10353
+ return getLog10ScaleSteps({
10354
+ min: band.stats.min,
10355
+ max: band.stats.max,
10356
+ steps: colorRange.colors.length
10357
+ });
10358
+ } else {
10359
+ return colorRange.colorMap?.map(([value]) => value) || [];
10360
+ }
10361
+ }
10362
+ const scaleLength = colorRange.colors.length;
10363
+ if (scaleType === "quantile") {
10364
+ const quantiles = band.stats.quantiles?.[scaleLength];
10365
+ if (!quantiles) {
10366
+ return [0, 1];
10367
+ }
10368
+ return [band.stats.min, ...quantiles, band.stats.max];
10369
+ }
10370
+ return [band.stats.min, band.stats.max];
10371
+ }
10372
+ function getRasterTileLayerStylePropsScaledBand({
10373
+ layerConfig,
10374
+ rasterMetadata,
10375
+ visualChannels
10376
+ }) {
10377
+ const { visConfig } = layerConfig;
10378
+ const { colorField } = visualChannels;
10379
+ const { rasterStyleType } = visConfig;
10380
+ const colorRange = rasterStyleType === "ColorRange" ? visConfig.colorRange : visConfig.uniqueValuesColorRange;
10381
+ const scaleType = rasterStyleType === "ColorRange" ? visualChannels.colorScale : "ordinal";
10382
+ const bandInfo = rasterMetadata.bands.find(
10383
+ (band) => band.name === colorField?.name
10384
+ );
10385
+ if (!colorField?.name || !scaleType || !colorRange || !bandInfo) {
10386
+ return {};
10387
+ }
10388
+ const domain = domainFromRasterMetadataBand(bandInfo, scaleType, colorRange);
10389
+ const scaleFun = createColorScale(
10390
+ scaleType,
10391
+ domain,
10392
+ colorRange.colors.map(hexToRGB2),
10393
+ UNKNOWN_COLOR2
10394
+ );
10395
+ const bandColorScaleDataTransform = createBandColorScaleDataTransform({
10396
+ bandName: bandInfo.name,
10397
+ scaleFun,
10398
+ nodata: bandInfo?.nodata ?? rasterMetadata.nodata,
10399
+ attribute: "instanceFillColors"
10400
+ });
10401
+ return {
10402
+ dataTransform: bandColorScaleDataTransform,
10403
+ updateTriggers: getRasterTileLayerUpdateTriggers({
10404
+ layerConfig,
10405
+ visualChannels
10406
+ })
10407
+ };
10408
+ }
10409
+ function getRasterTileLayerStyleProps({
10410
+ layerConfig,
10411
+ visualChannels,
10412
+ rasterMetadata
10413
+ }) {
10414
+ const { visConfig } = layerConfig;
10415
+ const { rasterStyleType } = visConfig;
10416
+ if (rasterStyleType === "Rgb") {
10417
+ return getRasterTileLayerStylePropsRgb({
10418
+ layerConfig,
10419
+ rasterMetadata,
10420
+ visualChannels
10421
+ });
10422
+ } else {
10423
+ return getRasterTileLayerStylePropsScaledBand({
10424
+ layerConfig,
10425
+ rasterMetadata,
10426
+ visualChannels
10427
+ });
10428
+ }
10429
+ }
10430
+ function getRasterTileLayerUpdateTriggers({
10431
+ layerConfig,
10432
+ visualChannels
10433
+ }) {
10434
+ const { visConfig } = layerConfig;
10435
+ const { rasterStyleType } = visConfig;
10436
+ const getFillColorUpdateTriggers = {
10437
+ rasterStyleType
10438
+ };
10439
+ if (rasterStyleType === "ColorRange") {
10440
+ getFillColorUpdateTriggers.colorRange = visConfig.colorRange?.colors;
10441
+ getFillColorUpdateTriggers.colorMap = visConfig.colorRange?.colorMap;
10442
+ getFillColorUpdateTriggers.colorScale = visualChannels.colorScale;
10443
+ getFillColorUpdateTriggers.colorFieldId = visualChannels.colorField?.name;
10444
+ } else if (rasterStyleType === "UniqueValues") {
10445
+ getFillColorUpdateTriggers.colorMap = visConfig.uniqueValuesColorRange?.colorMap;
10446
+ getFillColorUpdateTriggers.colorFieldId = visualChannels.colorField?.name;
10447
+ } else if (rasterStyleType === "Rgb") {
10448
+ getFillColorUpdateTriggers.colorBands = visConfig.colorBands;
10449
+ }
10450
+ return {
10451
+ getFillColor: getFillColorUpdateTriggers
10452
+ };
10453
+ }
10454
+ function bufferSetRgba(target, index, r, g, b, a) {
10455
+ target[index + 0] = r;
10456
+ target[index + 1] = g;
10457
+ target[index + 2] = b;
10458
+ target[index + 3] = a;
10459
+ }
10460
+ function hexToRGB2(hexColor) {
10461
+ const r = parseInt(hexColor.slice(1, 3), 16);
10462
+ const g = parseInt(hexColor.slice(3, 5), 16);
10463
+ const b = parseInt(hexColor.slice(5, 7), 16);
10464
+ return [r, g, b];
10465
+ }
10466
+
10467
+ // src/fetch-map/fetch-map.ts
10468
+ init_cjs_shims();
10469
+
9748
10470
  // src/fetch-map/parse-map.ts
10471
+ init_cjs_shims();
10472
+ function getLayerDescriptor({
10473
+ mapConfig,
10474
+ layer,
10475
+ dataset
10476
+ }) {
10477
+ const { filters, visState } = mapConfig;
10478
+ const { layerBlending, interactionConfig } = visState;
10479
+ const { id, type, config: config2, visualChannels } = layer;
10480
+ const { data, id: datasetId } = dataset;
10481
+ const { propMap, defaultProps: defaultProps2 } = getLayerProps(type, config2, dataset);
10482
+ const styleProps = createStyleProps(config2, propMap);
10483
+ const { channelProps, scales } = createChannelProps(
10484
+ id,
10485
+ type,
10486
+ config2,
10487
+ visualChannels,
10488
+ data,
10489
+ dataset
10490
+ );
10491
+ const layerDescriptor = {
10492
+ type,
10493
+ filters: isEmptyObject(filters) || isRemoteCalculationSupported(dataset) ? void 0 : filters[datasetId],
10494
+ props: {
10495
+ id,
10496
+ data,
10497
+ ...defaultProps2,
10498
+ ...createInteractionProps(interactionConfig),
10499
+ ...styleProps,
10500
+ ...channelProps,
10501
+ ...createParametersProp(layerBlending, styleProps.parameters || {}),
10502
+ // Must come after style
10503
+ ...createLoadOptions(data.accessToken)
10504
+ },
10505
+ scales
10506
+ };
10507
+ return layerDescriptor;
10508
+ }
9749
10509
  function parseMap(json) {
9750
10510
  const { keplerMapConfig, datasets, token } = json;
9751
10511
  assert2(keplerMapConfig.version === "v1", "Only support Kepler v1");
9752
- const config2 = keplerMapConfig.config;
9753
- const { filters, mapState, mapStyle, popupSettings, legendSettings } = config2;
9754
- const { layers, layerBlending, interactionConfig } = config2.visState;
10512
+ const mapConfig = keplerMapConfig.config;
10513
+ const { mapState, mapStyle, popupSettings, legendSettings, visState } = mapConfig;
10514
+ const { layers } = visState;
10515
+ const layersReverse = [...layers].reverse();
9755
10516
  return {
9756
10517
  id: json.id,
9757
10518
  title: json.title,
@@ -9764,45 +10525,19 @@ function parseMap(json) {
9764
10525
  popupSettings,
9765
10526
  legendSettings,
9766
10527
  token,
9767
- layers: layers.reverse().map(({ id, type, config: config3, visualChannels }) => {
10528
+ layers: layersReverse.map((layer) => {
9768
10529
  try {
9769
- const { dataId } = config3;
10530
+ const { dataId } = layer.config;
9770
10531
  const dataset = datasets.find(
9771
10532
  (d) => d.id === dataId
9772
10533
  );
9773
10534
  assert2(dataset, `No dataset matching dataId: ${dataId}`);
9774
- const { data } = dataset;
9775
- assert2(data, `No data loaded for dataId: ${dataId}`);
9776
- const { propMap, defaultProps: defaultProps2 } = getLayerProps(type, config3, dataset);
9777
- const styleProps = createStyleProps(config3, propMap);
9778
- const { channelProps, scales } = createChannelProps(
9779
- id,
9780
- type,
9781
- config3,
9782
- visualChannels,
9783
- data,
10535
+ const layerDescriptor = getLayerDescriptor({
10536
+ mapConfig,
10537
+ layer,
9784
10538
  dataset
9785
- );
9786
- const layer = {
9787
- type,
9788
- filters: isEmptyObject(filters) || isRemoteCalculationSupported(dataset) ? void 0 : filters[dataId],
9789
- props: {
9790
- id,
9791
- data,
9792
- ...defaultProps2,
9793
- ...createInteractionProps(interactionConfig),
9794
- ...styleProps,
9795
- ...channelProps,
9796
- ...createParametersProp(
9797
- layerBlending,
9798
- styleProps.parameters || {}
9799
- ),
9800
- // Must come after style
9801
- ...createLoadOptions(token)
9802
- },
9803
- scales
9804
- };
9805
- return layer;
10539
+ });
10540
+ return layerDescriptor;
9806
10541
  } catch (e) {
9807
10542
  console.error(e.message);
9808
10543
  return void 0;
@@ -9867,43 +10602,63 @@ function createStyleProps(config2, mapping) {
9867
10602
  result.highlightColor = config2.visConfig.enable3d ? [255, 255, 255, 60] : [252, 242, 26, 255];
9868
10603
  return result;
9869
10604
  }
9870
- function domainAndRangeFromScale(scale2) {
9871
- return {
9872
- domain: scale2.domain(),
9873
- range: scale2.range()
9874
- };
9875
- }
9876
10605
  function createChannelProps(id, layerType, config2, visualChannels, data, dataset) {
9877
- const {
9878
- colorField,
9879
- colorScale,
9880
- radiusField,
9881
- radiusScale,
9882
- strokeColorField,
9883
- strokeColorScale,
9884
- weightField
9885
- } = visualChannels;
9886
- const { heightField, heightScale } = visualChannels;
10606
+ if (layerType === "raster") {
10607
+ const rasterMetadata = data.raster_metadata;
10608
+ if (!rasterMetadata) {
10609
+ return {
10610
+ channelProps: {},
10611
+ scales: {}
10612
+ };
10613
+ }
10614
+ const rasterStyleType = config2.visConfig.rasterStyleType;
10615
+ if (rasterStyleType === "Rgb") {
10616
+ return {
10617
+ channelProps: getRasterTileLayerStylePropsRgb({
10618
+ layerConfig: config2,
10619
+ rasterMetadata,
10620
+ visualChannels
10621
+ }),
10622
+ scales: {}
10623
+ // TODO
10624
+ };
10625
+ } else {
10626
+ return {
10627
+ channelProps: getRasterTileLayerStylePropsScaledBand({
10628
+ layerConfig: config2,
10629
+ visualChannels,
10630
+ rasterMetadata
10631
+ }),
10632
+ scales: {
10633
+ // TODO
10634
+ }
10635
+ };
10636
+ }
10637
+ }
9887
10638
  const { textLabel, visConfig } = config2;
9888
10639
  const result = {};
10640
+ const updateTriggers = {};
9889
10641
  const scales = {};
9890
- if (colorField) {
9891
- const { colorAggregation: aggregation, colorRange: range } = visConfig;
9892
- const { accessor, scale: scale2 } = getColorAccessor(
9893
- colorField,
9894
- colorScale,
9895
- { aggregation, range },
9896
- visConfig.opacity,
9897
- data
9898
- );
9899
- result.getFillColor = accessor;
9900
- scales.fillColor = {
9901
- field: colorField,
9902
- type: colorScale,
9903
- ...domainAndRangeFromScale(scale2)
9904
- };
9905
- } else if (visConfig.filled) {
9906
- scales.fillColor = {};
10642
+ {
10643
+ const { colorField, colorScale } = visualChannels;
10644
+ const { colorRange, colorAggregation } = visConfig;
10645
+ if (colorField && colorScale && colorRange) {
10646
+ const { accessor, ...scaleProps } = getColorAccessor(
10647
+ colorField,
10648
+ colorScale,
10649
+ { aggregation: colorAggregation, range: colorRange },
10650
+ visConfig.opacity,
10651
+ data
10652
+ );
10653
+ result.getFillColor = accessor;
10654
+ scales.fillColor = updateTriggers.getFillColor = {
10655
+ field: colorField,
10656
+ type: colorScale,
10657
+ ...scaleProps
10658
+ };
10659
+ } else {
10660
+ scales.fillColor = {};
10661
+ }
9907
10662
  }
9908
10663
  if (layerType === "clusterTile") {
9909
10664
  const aggregationExpAlias = getDefaultAggregationExpColumnAliasForLayerType(
@@ -9916,6 +10671,7 @@ function createChannelProps(id, layerType, config2, visualChannels, data, datase
9916
10671
  result.getWeight = (d) => {
9917
10672
  return d.properties[aggregationExpAlias];
9918
10673
  };
10674
+ updateTriggers.getWeight = aggregationExpAlias;
9919
10675
  result.getPointRadius = (d, info) => {
9920
10676
  return calculateClusterRadius(
9921
10677
  d.properties,
@@ -9924,11 +10680,16 @@ function createChannelProps(id, layerType, config2, visualChannels, data, datase
9924
10680
  aggregationExpAlias
9925
10681
  );
9926
10682
  };
10683
+ updateTriggers.getPointRadius = {
10684
+ aggregationExpAlias,
10685
+ radiusRange: visConfig.radiusRange
10686
+ };
9927
10687
  result.textCharacterSet = "auto";
9928
10688
  result.textFontFamily = "Inter, sans";
9929
10689
  result.textFontSettings = { sdf: true };
9930
10690
  result.textFontWeight = 600;
9931
10691
  result.getText = (d) => TEXT_NUMBER_FORMATTER.format(d.properties[aggregationExpAlias]);
10692
+ updateTriggers.getText = aggregationExpAlias;
9932
10693
  result.getTextColor = config2.textLabel[TEXT_LABEL_INDEX].color;
9933
10694
  result.textOutlineColor = [
9934
10695
  ...config2.textLabel[TEXT_LABEL_INDEX].outlineColor,
@@ -9945,68 +10706,107 @@ function createChannelProps(id, layerType, config2, visualChannels, data, datase
9945
10706
  );
9946
10707
  return calculateClusterTextFontSize(radius);
9947
10708
  };
9948
- }
9949
- if (radiusField) {
9950
- const { accessor, scale: scale2 } = getSizeAccessor(
9951
- radiusField,
9952
- radiusScale,
9953
- visConfig.sizeAggregation,
9954
- visConfig.radiusRange || visConfig.sizeRange,
9955
- data
9956
- );
9957
- result.getPointRadius = accessor;
9958
- scales.pointRadius = {
9959
- field: radiusField,
9960
- type: radiusScale || "identity",
9961
- ...domainAndRangeFromScale(scale2)
10709
+ updateTriggers.getTextSize = {
10710
+ aggregationExpAlias,
10711
+ radiusRange: visConfig.radiusRange
9962
10712
  };
9963
10713
  }
9964
- if (strokeColorField) {
9965
- const opacity = visConfig.strokeOpacity !== void 0 ? visConfig.strokeOpacity : 1;
9966
- const { strokeColorAggregation: aggregation, strokeColorRange: range } = visConfig;
9967
- const { accessor, scale: scale2 } = getColorAccessor(
9968
- strokeColorField,
9969
- strokeColorScale,
9970
- { aggregation, range },
9971
- opacity,
9972
- data
9973
- );
9974
- result.getLineColor = accessor;
9975
- scales.lineColor = {
9976
- field: strokeColorField,
9977
- type: strokeColorScale,
9978
- ...domainAndRangeFromScale(scale2)
9979
- };
10714
+ {
10715
+ const radiusRange = visConfig.radiusRange;
10716
+ const { radiusField, radiusScale } = visualChannels;
10717
+ if (radiusField && radiusRange && radiusScale) {
10718
+ const { accessor, ...scaleProps } = getSizeAccessor(
10719
+ radiusField,
10720
+ radiusScale,
10721
+ visConfig.sizeAggregation,
10722
+ radiusRange,
10723
+ data
10724
+ );
10725
+ result.getPointRadius = accessor;
10726
+ scales.pointRadius = updateTriggers.getPointRadius = {
10727
+ field: radiusField,
10728
+ type: radiusScale,
10729
+ ...scaleProps
10730
+ };
10731
+ }
9980
10732
  }
9981
- if (heightField && visConfig.enable3d) {
9982
- const { accessor, scale: scale2 } = getSizeAccessor(
9983
- heightField,
9984
- heightScale,
9985
- visConfig.heightAggregation,
9986
- visConfig.heightRange || visConfig.sizeRange,
9987
- data
9988
- );
9989
- result.getElevation = accessor;
9990
- scales.elevation = {
9991
- field: heightField,
9992
- type: heightScale || "identity",
9993
- ...domainAndRangeFromScale(scale2)
9994
- };
10733
+ {
10734
+ const strokeColorRange = visConfig.strokeColorRange;
10735
+ const { strokeColorScale, strokeColorField } = visualChannels;
10736
+ if (strokeColorField && strokeColorRange && strokeColorScale) {
10737
+ const { strokeColorAggregation: aggregation } = visConfig;
10738
+ const opacity = visConfig.strokeOpacity !== void 0 ? visConfig.strokeOpacity : 1;
10739
+ const { accessor, ...scaleProps } = getColorAccessor(
10740
+ strokeColorField,
10741
+ strokeColorScale,
10742
+ { aggregation, range: strokeColorRange },
10743
+ opacity,
10744
+ data
10745
+ );
10746
+ result.getLineColor = accessor;
10747
+ scales.lineColor = updateTriggers.getLineColor = {
10748
+ field: strokeColorField,
10749
+ type: strokeColorScale,
10750
+ ...scaleProps
10751
+ };
10752
+ }
9995
10753
  }
9996
- if (weightField) {
9997
- const { accessor, scale: scale2 } = getSizeAccessor(
9998
- weightField,
9999
- void 0,
10000
- visConfig.weightAggregation,
10001
- void 0,
10002
- data
10003
- );
10004
- result.getWeight = accessor;
10005
- scales.weight = {
10006
- field: weightField,
10007
- type: "identity",
10008
- ...domainAndRangeFromScale(scale2)
10009
- };
10754
+ {
10755
+ const { sizeField: strokeWidthField, sizeScale: strokeWidthScale } = visualChannels;
10756
+ const { sizeRange, sizeAggregation } = visConfig;
10757
+ if (strokeWidthField && sizeRange) {
10758
+ const { accessor, ...scaleProps } = getSizeAccessor(
10759
+ strokeWidthField,
10760
+ strokeWidthScale,
10761
+ sizeAggregation,
10762
+ sizeRange,
10763
+ data
10764
+ );
10765
+ result.getLineWidth = accessor;
10766
+ scales.lineWidth = updateTriggers.getLineWidth = {
10767
+ field: strokeWidthField,
10768
+ type: strokeWidthScale || "identity",
10769
+ ...scaleProps
10770
+ };
10771
+ }
10772
+ }
10773
+ {
10774
+ const { enable3d, heightRange } = visConfig;
10775
+ const { heightField, heightScale } = visualChannels;
10776
+ if (heightField && heightRange && enable3d) {
10777
+ const { accessor, ...scaleProps } = getSizeAccessor(
10778
+ heightField,
10779
+ heightScale,
10780
+ visConfig.heightAggregation,
10781
+ heightRange,
10782
+ data
10783
+ );
10784
+ result.getElevation = accessor;
10785
+ scales.elevation = updateTriggers.getElevation = {
10786
+ field: heightField,
10787
+ type: heightScale || "identity",
10788
+ ...scaleProps
10789
+ };
10790
+ }
10791
+ }
10792
+ {
10793
+ const { weightField } = visualChannels;
10794
+ const { weightAggregation } = visConfig;
10795
+ if (weightField && weightAggregation) {
10796
+ const { accessor, ...scaleProps } = getSizeAccessor(
10797
+ weightField,
10798
+ void 0,
10799
+ weightAggregation,
10800
+ void 0,
10801
+ data
10802
+ );
10803
+ result.getWeight = accessor;
10804
+ scales.weight = updateTriggers.getWeight = {
10805
+ field: weightField,
10806
+ type: "identity",
10807
+ ...scaleProps
10808
+ };
10809
+ }
10010
10810
  }
10011
10811
  if (visConfig.customMarkers) {
10012
10812
  const maxIconSize = getMaxMarkerSize(visConfig, visualChannels);
@@ -10023,6 +10823,12 @@ function createChannelProps(id, layerType, config2, visualChannels, data, datase
10023
10823
  { fallbackUrl: customMarkersUrl, maxIconSize, useMaskedIcons },
10024
10824
  data
10025
10825
  );
10826
+ updateTriggers.getIcon = {
10827
+ customMarkersUrl,
10828
+ customMarkersRange,
10829
+ maxIconSize,
10830
+ useMaskedIcons
10831
+ };
10026
10832
  result._subLayerProps = {
10027
10833
  "points-icon": {
10028
10834
  loadOptions: {
@@ -10039,9 +10845,11 @@ function createChannelProps(id, layerType, config2, visualChannels, data, datase
10039
10845
  };
10040
10846
  if (getFillColor && useMaskedIcons) {
10041
10847
  result.getIconColor = getFillColor;
10848
+ updateTriggers.getIconColor = updateTriggers.getFillColor;
10042
10849
  }
10043
10850
  if (getPointRadius) {
10044
10851
  result.getIconSize = getPointRadius;
10852
+ updateTriggers.getIconSize = updateTriggers.getPointRadius;
10045
10853
  }
10046
10854
  if (visualChannels.rotationField) {
10047
10855
  const { accessor } = getSizeAccessor(
@@ -10052,6 +10860,7 @@ function createChannelProps(id, layerType, config2, visualChannels, data, datase
10052
10860
  data
10053
10861
  );
10054
10862
  result.getIconAngle = negateAccessor(accessor);
10863
+ updateTriggers.getIconAngle = updateTriggers.getRotationField;
10055
10864
  }
10056
10865
  } else if (layerType === "tileset") {
10057
10866
  result.pointType = "circle";
@@ -10096,7 +10905,13 @@ function createChannelProps(id, layerType, config2, visualChannels, data, datase
10096
10905
  }
10097
10906
  };
10098
10907
  }
10099
- return { channelProps: result, scales };
10908
+ return {
10909
+ channelProps: {
10910
+ ...result,
10911
+ updateTriggers
10912
+ },
10913
+ scales
10914
+ };
10100
10915
  }
10101
10916
  function createLoadOptions(accessToken) {
10102
10917
  return {
@@ -10752,9 +11567,16 @@ function hashBuckets(initialCount) {
10752
11567
  WidgetSource,
10753
11568
  WidgetTableSource,
10754
11569
  WidgetTilesetSource,
11570
+ _ErrorCode,
11571
+ _applyLayerGroupFilters,
10755
11572
  _buildFeatureFilter,
11573
+ _createVecExprEvaluator,
10756
11574
  _domainFromValues,
11575
+ _evaluateVecExpr,
10757
11576
  _getHexagonResolution,
11577
+ _getLog10ScaleSteps,
11578
+ _getRasterTileLayerStyleProps,
11579
+ _validateVecExprSyntax,
10758
11580
  addFilter,
10759
11581
  aggregate,
10760
11582
  aggregationFunctions,
@@ -10767,9 +11589,11 @@ function hashBuckets(initialCount) {
10767
11589
  buildStatsUrl,
10768
11590
  calculateClusterRadius,
10769
11591
  calculateClusterTextFontSize,
11592
+ calculateLayerScale,
10770
11593
  clearDefaultRequestCache,
10771
11594
  clearFilters,
10772
11595
  configureSource,
11596
+ createColorScale,
10773
11597
  createPolygonSpatialFilter,
10774
11598
  createViewportSpatialFilter,
10775
11599
  fetchBasemapProps,
@@ -10784,6 +11608,7 @@ function hashBuckets(initialCount) {
10784
11608
  getDefaultAggregationExpColumnAliasForLayerType,
10785
11609
  getFilter,
10786
11610
  getIconUrlAccessor,
11611
+ getLayerDescriptor,
10787
11612
  getLayerProps,
10788
11613
  getMaxMarkerSize,
10789
11614
  getSizeAccessor,