@carto/api-client 0.5.16 → 0.5.18-alpha.colormapfix-1

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,78 @@ 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 = [];
9934
+ const { colors } = range;
9616
9935
  if (scaleType !== "identity") {
9617
- const { colorMap, colors } = range;
9618
- if (Array.isArray(colorMap)) {
9936
+ if (range.colorMap) {
9937
+ const { colorMap } = range;
9938
+ scaleDomain = [];
9619
9939
  colorMap.forEach(([value, color2]) => {
9620
- domain.push(value);
9940
+ scaleDomain.push(value);
9621
9941
  scaleColor.push(color2);
9622
9942
  });
9943
+ domain = scaleDomain;
9623
9944
  } else {
9624
- domain = calculateDomain(data, name, scaleType, colors.length);
9625
- scaleColor = colors;
9945
+ if (scaleType === "custom" && range.uiCustomScaleType === "logarithmic") {
9946
+ domain = calculateDomain(data, name, scaleType, colors.length);
9947
+ const [min2, max2] = domain;
9948
+ scaleDomain = getLog10ScaleSteps({
9949
+ min: min2,
9950
+ max: max2,
9951
+ steps: colors.length
9952
+ });
9953
+ scaleColor = colors;
9954
+ } else {
9955
+ domain = calculateDomain(data, name, scaleType, colors.length);
9956
+ scaleColor = colors;
9957
+ }
9626
9958
  }
9627
9959
  if (scaleType === "ordinal") {
9628
9960
  domain = domain.slice(0, scaleColor.length);
9629
9961
  }
9630
9962
  }
9963
+ return {
9964
+ scale: createColorScale(
9965
+ scaleType,
9966
+ scaleDomain || domain,
9967
+ scaleColor.map(hexToRGB),
9968
+ UNKNOWN_COLOR_RGB
9969
+ ),
9970
+ domain
9971
+ };
9972
+ }
9973
+ function createColorScale(scaleType, domain, range, unknown) {
9974
+ const scale2 = SCALE_FUNCS[scaleType]();
9631
9975
  scale2.domain(domain);
9632
- scale2.range(scaleColor);
9633
- scale2.unknown(UNKNOWN_COLOR);
9976
+ scale2.range(range);
9977
+ scale2.unknown(unknown);
9634
9978
  return scale2;
9635
9979
  }
9636
9980
  var FALLBACK_ICON = "data:image/svg+xml;charset=utf-8;base64,PHN2ZyB2aWV3Qm94PSIwIDAgMTAwIDEwMCIgeG1sbnM9Imh0dHA6Ly93d3cudzMub3JnLzIwMDAvc3ZnIj4NCiAgPGNpcmNsZSBjeD0iNTAiIGN5PSI1MCIgcj0iNTAiLz4NCjwvc3ZnPg==";
@@ -9680,9 +10024,13 @@ function negateAccessor(accessor) {
9680
10024
  }
9681
10025
  function getSizeAccessor({ name }, scaleType, aggregation, range, data) {
9682
10026
  const scale2 = scaleType ? SCALE_FUNCS[scaleType]() : identity2;
9683
- if (scaleType) {
10027
+ let domain = [];
10028
+ if (scaleType && range) {
9684
10029
  if (aggregation !== AggregationTypes.Count) {
9685
- scale2.domain(calculateDomain(data, name, scaleType));
10030
+ domain = calculateDomain(data, name, scaleType);
10031
+ scale2.domain(domain);
10032
+ } else {
10033
+ domain = scale2.domain();
9686
10034
  }
9687
10035
  scale2.range(range);
9688
10036
  }
@@ -9694,7 +10042,12 @@ function getSizeAccessor({ name }, scaleType, aggregation, range, data) {
9694
10042
  const propertyValue = properties[accessorKeys[0]];
9695
10043
  return scale2(propertyValue);
9696
10044
  };
9697
- return { accessor: normalizeAccessor(accessor, data), scale: scale2 };
10045
+ return {
10046
+ accessor: normalizeAccessor(accessor, data),
10047
+ domain,
10048
+ scaleDomain: domain,
10049
+ range
10050
+ };
9698
10051
  }
9699
10052
  var FORMATS = {
9700
10053
  date: formatDate,
@@ -9745,13 +10098,424 @@ function calculateClusterTextFontSize(radius) {
9745
10098
  return 11;
9746
10099
  }
9747
10100
 
10101
+ // src/fetch-map/raster-layer.ts
10102
+ var UNKNOWN_COLOR2 = [134, 141, 145];
10103
+ var RASTER_COLOR_BANDS = ["red", "green", "blue"];
10104
+ function getHasDataPredicate(noData) {
10105
+ if (noData === "nan") {
10106
+ return (v2) => !isNaN(v2);
10107
+ }
10108
+ if (typeof noData === "string") {
10109
+ noData = parseFloat(noData);
10110
+ }
10111
+ if (typeof noData === "number") {
10112
+ return (v2) => v2 !== noData && !isNaN(v2);
10113
+ }
10114
+ return () => true;
10115
+ }
10116
+ function createRasterColumnLayerDataTransform(transform) {
10117
+ return (data) => {
10118
+ if (!data || !("data" in data) || !data?.data?.cells?.numericProps) {
10119
+ return data;
10120
+ }
10121
+ return transform(data);
10122
+ };
10123
+ }
10124
+ function createEvaluationContext(numericProps, noData) {
10125
+ const hasData = getHasDataPredicate(noData);
10126
+ const bands = Object.entries(numericProps).map(([bandName, { value }]) => ({
10127
+ bandName,
10128
+ values: value,
10129
+ copied: false
10130
+ }));
10131
+ const length2 = bands[0].values.length;
10132
+ for (let i = 0; i < length2; i++) {
10133
+ let hasSomeData = false;
10134
+ for (let j = 0; j < bands.length; j++) {
10135
+ hasSomeData = hasSomeData || hasData(bands[j].values[i]);
10136
+ }
10137
+ if (!hasSomeData) {
10138
+ for (let j = 0; j < bands.length; j++) {
10139
+ if (!bands[j].copied) {
10140
+ bands[j].copied = true;
10141
+ bands[j].values = Array.from(bands[j].values);
10142
+ }
10143
+ bands[j].values[i] = NaN;
10144
+ }
10145
+ }
10146
+ }
10147
+ const context = bands.reduce(
10148
+ (agg, { bandName, values }) => {
10149
+ agg[bandName] = values;
10150
+ return agg;
10151
+ },
10152
+ {}
10153
+ );
10154
+ return context;
10155
+ }
10156
+ function createExprDataTransform({
10157
+ colorBand,
10158
+ rasterMetadata,
10159
+ usedSymbols
10160
+ }) {
10161
+ if (!colorBand || !colorBand.type || colorBand.type === "none") {
10162
+ return void 0;
10163
+ }
10164
+ const expr = colorBand?.type === "expression" ? colorBand.value : void 0;
10165
+ const vecExprEvaluator = expr ? createVecExprEvaluator(expr) : void 0;
10166
+ const dataTransform = createRasterColumnLayerDataTransform(
10167
+ (dataWrapped) => {
10168
+ const data = dataWrapped.data;
10169
+ if (expr) {
10170
+ const cachedResult = dataWrapped.customExpressionResults?.[expr];
10171
+ if (cachedResult) {
10172
+ return dataWrapped;
10173
+ }
10174
+ }
10175
+ let context = dataWrapped.expressionEvalContext;
10176
+ if (!context) {
10177
+ const usedNumericProps = usedSymbols.reduce(
10178
+ (acc, symbol) => {
10179
+ acc[symbol] = data.cells.numericProps[symbol];
10180
+ return acc;
10181
+ },
10182
+ {}
10183
+ );
10184
+ context = createEvaluationContext(
10185
+ usedNumericProps,
10186
+ rasterMetadata.nodata
10187
+ );
10188
+ dataWrapped = {
10189
+ ...dataWrapped,
10190
+ expressionEvalContext: context
10191
+ };
10192
+ }
10193
+ if (!vecExprEvaluator || !expr) return dataWrapped;
10194
+ const evalResult = vecExprEvaluator(context);
10195
+ return {
10196
+ ...dataWrapped,
10197
+ customExpressionResults: {
10198
+ ...dataWrapped.customExpressionResults,
10199
+ [expr]: evalResult
10200
+ }
10201
+ };
10202
+ }
10203
+ );
10204
+ return dataTransform;
10205
+ }
10206
+ function combineDataTransforms(dataTransforms) {
10207
+ const actualTransforms = dataTransforms.filter((v2) => v2);
10208
+ if (actualTransforms.length === 0) return void 0;
10209
+ if (actualTransforms.length === 1) return actualTransforms[0];
10210
+ return (data) => actualTransforms.reduce(
10211
+ (aggData, transformFun) => transformFun(aggData),
10212
+ data
10213
+ );
10214
+ }
10215
+ function createRgbToColorBufferDataTransform({
10216
+ bandDefs,
10217
+ attribute
10218
+ }) {
10219
+ return createRasterColumnLayerDataTransform(
10220
+ (dataWrapped) => {
10221
+ const length2 = dataWrapped.length;
10222
+ const getBandBufferOrValue = (colorBand) => {
10223
+ if (colorBand?.type === "expression") {
10224
+ return dataWrapped.customExpressionResults?.[colorBand.value];
10225
+ }
10226
+ if (colorBand?.type === "band") {
10227
+ return dataWrapped.expressionEvalContext?.[colorBand.value];
10228
+ }
10229
+ return 0;
10230
+ };
10231
+ const red = getBandBufferOrValue(bandDefs.red);
10232
+ const green = getBandBufferOrValue(bandDefs.green);
10233
+ const blue = getBandBufferOrValue(bandDefs.blue);
10234
+ const colorBuffer = new Uint8Array(length2 * 4);
10235
+ for (let inputIndex = 0, outputIndex = 0; inputIndex < length2; inputIndex++, outputIndex += 4) {
10236
+ const redRaw = typeof red === "number" ? red : red ? red[inputIndex] : NaN;
10237
+ const greenRaw = typeof green === "number" ? green : green ? green[inputIndex] : NaN;
10238
+ const blueRaw = typeof blue === "number" ? blue : blue ? blue[inputIndex] : NaN;
10239
+ if (isNaN(redRaw) && isNaN(greenRaw) && isNaN(blueRaw)) {
10240
+ bufferSetRgba(colorBuffer, outputIndex, 0, 0, 0, 0);
10241
+ } else {
10242
+ bufferSetRgba(
10243
+ colorBuffer,
10244
+ outputIndex,
10245
+ redRaw,
10246
+ greenRaw,
10247
+ blueRaw,
10248
+ 255
10249
+ );
10250
+ }
10251
+ }
10252
+ dataWrapped.customExpressionResults = void 0;
10253
+ dataWrapped.expressionEvalContext = void 0;
10254
+ return {
10255
+ ...dataWrapped,
10256
+ attributes: {
10257
+ [attribute]: colorBuffer
10258
+ }
10259
+ };
10260
+ }
10261
+ );
10262
+ }
10263
+ function getUsedSymbols(colorBands) {
10264
+ return Array.from(
10265
+ colorBands.reduce((symbols, band) => {
10266
+ if (band.type === "expression") {
10267
+ const expressionSymbols = createVecExprEvaluator(band.value)?.symbols || [];
10268
+ expressionSymbols.forEach((symbol) => symbols.add(symbol));
10269
+ }
10270
+ if (band.type === "band") {
10271
+ symbols.add(band.value);
10272
+ }
10273
+ return symbols;
10274
+ }, /* @__PURE__ */ new Set())
10275
+ );
10276
+ }
10277
+ function getRasterTileLayerStylePropsRgb({
10278
+ layerConfig,
10279
+ rasterMetadata,
10280
+ visualChannels
10281
+ }) {
10282
+ const { visConfig } = layerConfig;
10283
+ const { colorBands } = visConfig;
10284
+ const bandDefs = {
10285
+ red: colorBands?.find((band) => band.band === "red"),
10286
+ green: colorBands?.find((band) => band.band === "green"),
10287
+ blue: colorBands?.find((band) => band.band === "blue")
10288
+ };
10289
+ const rgbToInstanceFillColorsDataTransform = createRgbToColorBufferDataTransform({
10290
+ bandDefs,
10291
+ attribute: "instanceFillColors"
10292
+ });
10293
+ const usedSymbols = colorBands ? getUsedSymbols(colorBands) : [];
10294
+ const bandTransforms = RASTER_COLOR_BANDS.map(
10295
+ (band) => createExprDataTransform({
10296
+ colorBand: bandDefs[band],
10297
+ rasterMetadata,
10298
+ usedSymbols
10299
+ })
10300
+ );
10301
+ const combinedDataTransform = combineDataTransforms([
10302
+ ...bandTransforms,
10303
+ rgbToInstanceFillColorsDataTransform
10304
+ ]);
10305
+ return {
10306
+ dataTransform: combinedDataTransform,
10307
+ updateTriggers: getRasterTileLayerUpdateTriggers({
10308
+ layerConfig,
10309
+ visualChannels
10310
+ })
10311
+ };
10312
+ }
10313
+ function createBandColorScaleDataTransform({
10314
+ bandName,
10315
+ scaleFun,
10316
+ nodata,
10317
+ attribute
10318
+ }) {
10319
+ const hasData = getHasDataPredicate(nodata);
10320
+ return createRasterColumnLayerDataTransform(
10321
+ (dataWrapped) => {
10322
+ const length2 = dataWrapped.length;
10323
+ const bandBuffer = dataWrapped.data.cells.numericProps[bandName].value;
10324
+ const colorBuffer = new Uint8Array(length2 * 4);
10325
+ for (let i = 0; i < length2; i++) {
10326
+ const rawValue = bandBuffer[i];
10327
+ if (!hasData(rawValue)) {
10328
+ bufferSetRgba(colorBuffer, i * 4, 0, 0, 0, 0);
10329
+ } else {
10330
+ const colorRgb = scaleFun(rawValue);
10331
+ bufferSetRgba(
10332
+ colorBuffer,
10333
+ i * 4,
10334
+ colorRgb[0],
10335
+ colorRgb[1],
10336
+ colorRgb[2],
10337
+ 255
10338
+ );
10339
+ }
10340
+ }
10341
+ return {
10342
+ ...dataWrapped,
10343
+ attributes: {
10344
+ [attribute]: colorBuffer
10345
+ }
10346
+ };
10347
+ }
10348
+ );
10349
+ }
10350
+ function domainFromRasterMetadataBand(band, scaleType, colorRange) {
10351
+ if (scaleType === "ordinal") {
10352
+ return colorRange.colorMap?.map(([value]) => value) || [];
10353
+ }
10354
+ if (scaleType === "custom") {
10355
+ if (colorRange.uiCustomScaleType === "logarithmic") {
10356
+ return getLog10ScaleSteps({
10357
+ min: band.stats.min,
10358
+ max: band.stats.max,
10359
+ steps: colorRange.colors.length
10360
+ });
10361
+ } else {
10362
+ return colorRange.colorMap?.map(([value]) => value) || [];
10363
+ }
10364
+ }
10365
+ const scaleLength = colorRange.colors.length;
10366
+ if (scaleType === "quantile") {
10367
+ const quantiles = band.stats.quantiles?.[scaleLength];
10368
+ if (!quantiles) {
10369
+ return [0, 1];
10370
+ }
10371
+ return [band.stats.min, ...quantiles, band.stats.max];
10372
+ }
10373
+ return [band.stats.min, band.stats.max];
10374
+ }
10375
+ function getRasterTileLayerStylePropsScaledBand({
10376
+ layerConfig,
10377
+ rasterMetadata,
10378
+ visualChannels
10379
+ }) {
10380
+ const { visConfig } = layerConfig;
10381
+ const { colorField } = visualChannels;
10382
+ const { rasterStyleType } = visConfig;
10383
+ const colorRange = rasterStyleType === "ColorRange" ? visConfig.colorRange : visConfig.uniqueValuesColorRange;
10384
+ const scaleType = rasterStyleType === "ColorRange" ? visualChannels.colorScale : "ordinal";
10385
+ const bandInfo = rasterMetadata.bands.find(
10386
+ (band) => band.name === colorField?.name
10387
+ );
10388
+ if (!colorField?.name || !scaleType || !colorRange || !bandInfo) {
10389
+ return {};
10390
+ }
10391
+ const domain = domainFromRasterMetadataBand(bandInfo, scaleType, colorRange);
10392
+ const scaleFun = createColorScale(
10393
+ scaleType,
10394
+ domain,
10395
+ colorRange.colors.map(hexToRGB2),
10396
+ UNKNOWN_COLOR2
10397
+ );
10398
+ const bandColorScaleDataTransform = createBandColorScaleDataTransform({
10399
+ bandName: bandInfo.name,
10400
+ scaleFun,
10401
+ nodata: bandInfo?.nodata ?? rasterMetadata.nodata,
10402
+ attribute: "instanceFillColors"
10403
+ });
10404
+ return {
10405
+ dataTransform: bandColorScaleDataTransform,
10406
+ updateTriggers: getRasterTileLayerUpdateTriggers({
10407
+ layerConfig,
10408
+ visualChannels
10409
+ })
10410
+ };
10411
+ }
10412
+ function getRasterTileLayerStyleProps({
10413
+ layerConfig,
10414
+ visualChannels,
10415
+ rasterMetadata
10416
+ }) {
10417
+ const { visConfig } = layerConfig;
10418
+ const { rasterStyleType } = visConfig;
10419
+ if (rasterStyleType === "Rgb") {
10420
+ return getRasterTileLayerStylePropsRgb({
10421
+ layerConfig,
10422
+ rasterMetadata,
10423
+ visualChannels
10424
+ });
10425
+ } else {
10426
+ return getRasterTileLayerStylePropsScaledBand({
10427
+ layerConfig,
10428
+ rasterMetadata,
10429
+ visualChannels
10430
+ });
10431
+ }
10432
+ }
10433
+ function getRasterTileLayerUpdateTriggers({
10434
+ layerConfig,
10435
+ visualChannels
10436
+ }) {
10437
+ const { visConfig } = layerConfig;
10438
+ const { rasterStyleType } = visConfig;
10439
+ const getFillColorUpdateTriggers = {
10440
+ rasterStyleType
10441
+ };
10442
+ if (rasterStyleType === "ColorRange") {
10443
+ getFillColorUpdateTriggers.colorRange = visConfig.colorRange?.colors;
10444
+ getFillColorUpdateTriggers.colorMap = visConfig.colorRange?.colorMap;
10445
+ getFillColorUpdateTriggers.colorScale = visualChannels.colorScale;
10446
+ getFillColorUpdateTriggers.colorFieldId = visualChannels.colorField?.name;
10447
+ } else if (rasterStyleType === "UniqueValues") {
10448
+ getFillColorUpdateTriggers.colorMap = visConfig.uniqueValuesColorRange?.colorMap;
10449
+ getFillColorUpdateTriggers.colorFieldId = visualChannels.colorField?.name;
10450
+ } else if (rasterStyleType === "Rgb") {
10451
+ getFillColorUpdateTriggers.colorBands = visConfig.colorBands;
10452
+ }
10453
+ return {
10454
+ getFillColor: getFillColorUpdateTriggers
10455
+ };
10456
+ }
10457
+ function bufferSetRgba(target, index, r, g, b, a) {
10458
+ target[index + 0] = r;
10459
+ target[index + 1] = g;
10460
+ target[index + 2] = b;
10461
+ target[index + 3] = a;
10462
+ }
10463
+ function hexToRGB2(hexColor) {
10464
+ const r = parseInt(hexColor.slice(1, 3), 16);
10465
+ const g = parseInt(hexColor.slice(3, 5), 16);
10466
+ const b = parseInt(hexColor.slice(5, 7), 16);
10467
+ return [r, g, b];
10468
+ }
10469
+
10470
+ // src/fetch-map/fetch-map.ts
10471
+ init_cjs_shims();
10472
+
9748
10473
  // src/fetch-map/parse-map.ts
10474
+ init_cjs_shims();
10475
+ function getLayerDescriptor({
10476
+ mapConfig,
10477
+ layer,
10478
+ dataset
10479
+ }) {
10480
+ const { filters, visState } = mapConfig;
10481
+ const { layerBlending, interactionConfig } = visState;
10482
+ const { id, type, config: config2, visualChannels } = layer;
10483
+ const { data, id: datasetId } = dataset;
10484
+ const { propMap, defaultProps: defaultProps2 } = getLayerProps(type, config2, dataset);
10485
+ const styleProps = createStyleProps(config2, propMap);
10486
+ const { channelProps, scales } = createChannelProps(
10487
+ id,
10488
+ type,
10489
+ config2,
10490
+ visualChannels,
10491
+ data,
10492
+ dataset
10493
+ );
10494
+ const layerDescriptor = {
10495
+ type,
10496
+ filters: isEmptyObject(filters) || isRemoteCalculationSupported(dataset) ? void 0 : filters[datasetId],
10497
+ props: {
10498
+ id,
10499
+ data,
10500
+ ...defaultProps2,
10501
+ ...createInteractionProps(interactionConfig),
10502
+ ...styleProps,
10503
+ ...channelProps,
10504
+ ...createParametersProp(layerBlending, styleProps.parameters || {}),
10505
+ // Must come after style
10506
+ ...createLoadOptions(data.accessToken)
10507
+ },
10508
+ scales
10509
+ };
10510
+ return layerDescriptor;
10511
+ }
9749
10512
  function parseMap(json) {
9750
10513
  const { keplerMapConfig, datasets, token } = json;
9751
10514
  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;
10515
+ const mapConfig = keplerMapConfig.config;
10516
+ const { mapState, mapStyle, popupSettings, legendSettings, visState } = mapConfig;
10517
+ const { layers } = visState;
10518
+ const layersReverse = [...layers].reverse();
9755
10519
  return {
9756
10520
  id: json.id,
9757
10521
  title: json.title,
@@ -9764,45 +10528,19 @@ function parseMap(json) {
9764
10528
  popupSettings,
9765
10529
  legendSettings,
9766
10530
  token,
9767
- layers: layers.reverse().map(({ id, type, config: config3, visualChannels }) => {
10531
+ layers: layersReverse.map((layer) => {
9768
10532
  try {
9769
- const { dataId } = config3;
10533
+ const { dataId } = layer.config;
9770
10534
  const dataset = datasets.find(
9771
10535
  (d) => d.id === dataId
9772
10536
  );
9773
10537
  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,
10538
+ const layerDescriptor = getLayerDescriptor({
10539
+ mapConfig,
10540
+ layer,
9784
10541
  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;
10542
+ });
10543
+ return layerDescriptor;
9806
10544
  } catch (e) {
9807
10545
  console.error(e.message);
9808
10546
  return void 0;
@@ -9867,43 +10605,63 @@ function createStyleProps(config2, mapping) {
9867
10605
  result.highlightColor = config2.visConfig.enable3d ? [255, 255, 255, 60] : [252, 242, 26, 255];
9868
10606
  return result;
9869
10607
  }
9870
- function domainAndRangeFromScale(scale2) {
9871
- return {
9872
- domain: scale2.domain(),
9873
- range: scale2.range()
9874
- };
9875
- }
9876
10608
  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;
10609
+ if (layerType === "raster") {
10610
+ const rasterMetadata = data.raster_metadata;
10611
+ if (!rasterMetadata) {
10612
+ return {
10613
+ channelProps: {},
10614
+ scales: {}
10615
+ };
10616
+ }
10617
+ const rasterStyleType = config2.visConfig.rasterStyleType;
10618
+ if (rasterStyleType === "Rgb") {
10619
+ return {
10620
+ channelProps: getRasterTileLayerStylePropsRgb({
10621
+ layerConfig: config2,
10622
+ rasterMetadata,
10623
+ visualChannels
10624
+ }),
10625
+ scales: {}
10626
+ // TODO
10627
+ };
10628
+ } else {
10629
+ return {
10630
+ channelProps: getRasterTileLayerStylePropsScaledBand({
10631
+ layerConfig: config2,
10632
+ visualChannels,
10633
+ rasterMetadata
10634
+ }),
10635
+ scales: {
10636
+ // TODO
10637
+ }
10638
+ };
10639
+ }
10640
+ }
9887
10641
  const { textLabel, visConfig } = config2;
9888
10642
  const result = {};
10643
+ const updateTriggers = {};
9889
10644
  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 = {};
10645
+ {
10646
+ const { colorField, colorScale } = visualChannels;
10647
+ const { colorRange, colorAggregation } = visConfig;
10648
+ if (colorField && colorScale && colorRange) {
10649
+ const { accessor, ...scaleProps } = getColorAccessor(
10650
+ colorField,
10651
+ colorScale,
10652
+ { aggregation: colorAggregation, range: colorRange },
10653
+ visConfig.opacity,
10654
+ data
10655
+ );
10656
+ result.getFillColor = accessor;
10657
+ scales.fillColor = updateTriggers.getFillColor = {
10658
+ field: colorField,
10659
+ type: colorScale,
10660
+ ...scaleProps
10661
+ };
10662
+ } else {
10663
+ scales.fillColor = {};
10664
+ }
9907
10665
  }
9908
10666
  if (layerType === "clusterTile") {
9909
10667
  const aggregationExpAlias = getDefaultAggregationExpColumnAliasForLayerType(
@@ -9916,6 +10674,7 @@ function createChannelProps(id, layerType, config2, visualChannels, data, datase
9916
10674
  result.getWeight = (d) => {
9917
10675
  return d.properties[aggregationExpAlias];
9918
10676
  };
10677
+ updateTriggers.getWeight = aggregationExpAlias;
9919
10678
  result.getPointRadius = (d, info) => {
9920
10679
  return calculateClusterRadius(
9921
10680
  d.properties,
@@ -9924,11 +10683,16 @@ function createChannelProps(id, layerType, config2, visualChannels, data, datase
9924
10683
  aggregationExpAlias
9925
10684
  );
9926
10685
  };
10686
+ updateTriggers.getPointRadius = {
10687
+ aggregationExpAlias,
10688
+ radiusRange: visConfig.radiusRange
10689
+ };
9927
10690
  result.textCharacterSet = "auto";
9928
10691
  result.textFontFamily = "Inter, sans";
9929
10692
  result.textFontSettings = { sdf: true };
9930
10693
  result.textFontWeight = 600;
9931
10694
  result.getText = (d) => TEXT_NUMBER_FORMATTER.format(d.properties[aggregationExpAlias]);
10695
+ updateTriggers.getText = aggregationExpAlias;
9932
10696
  result.getTextColor = config2.textLabel[TEXT_LABEL_INDEX].color;
9933
10697
  result.textOutlineColor = [
9934
10698
  ...config2.textLabel[TEXT_LABEL_INDEX].outlineColor,
@@ -9945,68 +10709,107 @@ function createChannelProps(id, layerType, config2, visualChannels, data, datase
9945
10709
  );
9946
10710
  return calculateClusterTextFontSize(radius);
9947
10711
  };
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)
10712
+ updateTriggers.getTextSize = {
10713
+ aggregationExpAlias,
10714
+ radiusRange: visConfig.radiusRange
9962
10715
  };
9963
10716
  }
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
- };
10717
+ {
10718
+ const radiusRange = visConfig.radiusRange;
10719
+ const { radiusField, radiusScale } = visualChannels;
10720
+ if (radiusField && radiusRange && radiusScale) {
10721
+ const { accessor, ...scaleProps } = getSizeAccessor(
10722
+ radiusField,
10723
+ radiusScale,
10724
+ visConfig.sizeAggregation,
10725
+ radiusRange,
10726
+ data
10727
+ );
10728
+ result.getPointRadius = accessor;
10729
+ scales.pointRadius = updateTriggers.getPointRadius = {
10730
+ field: radiusField,
10731
+ type: radiusScale,
10732
+ ...scaleProps
10733
+ };
10734
+ }
9980
10735
  }
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
- };
10736
+ {
10737
+ const strokeColorRange = visConfig.strokeColorRange;
10738
+ const { strokeColorScale, strokeColorField } = visualChannels;
10739
+ if (strokeColorField && strokeColorRange && strokeColorScale) {
10740
+ const { strokeColorAggregation: aggregation } = visConfig;
10741
+ const opacity = visConfig.strokeOpacity !== void 0 ? visConfig.strokeOpacity : 1;
10742
+ const { accessor, ...scaleProps } = getColorAccessor(
10743
+ strokeColorField,
10744
+ strokeColorScale,
10745
+ { aggregation, range: strokeColorRange },
10746
+ opacity,
10747
+ data
10748
+ );
10749
+ result.getLineColor = accessor;
10750
+ scales.lineColor = updateTriggers.getLineColor = {
10751
+ field: strokeColorField,
10752
+ type: strokeColorScale,
10753
+ ...scaleProps
10754
+ };
10755
+ }
9995
10756
  }
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
- };
10757
+ {
10758
+ const { sizeField: strokeWidthField, sizeScale: strokeWidthScale } = visualChannels;
10759
+ const { sizeRange, sizeAggregation } = visConfig;
10760
+ if (strokeWidthField && sizeRange) {
10761
+ const { accessor, ...scaleProps } = getSizeAccessor(
10762
+ strokeWidthField,
10763
+ strokeWidthScale,
10764
+ sizeAggregation,
10765
+ sizeRange,
10766
+ data
10767
+ );
10768
+ result.getLineWidth = accessor;
10769
+ scales.lineWidth = updateTriggers.getLineWidth = {
10770
+ field: strokeWidthField,
10771
+ type: strokeWidthScale || "identity",
10772
+ ...scaleProps
10773
+ };
10774
+ }
10775
+ }
10776
+ {
10777
+ const { enable3d, heightRange } = visConfig;
10778
+ const { heightField, heightScale } = visualChannels;
10779
+ if (heightField && heightRange && enable3d) {
10780
+ const { accessor, ...scaleProps } = getSizeAccessor(
10781
+ heightField,
10782
+ heightScale,
10783
+ visConfig.heightAggregation,
10784
+ heightRange,
10785
+ data
10786
+ );
10787
+ result.getElevation = accessor;
10788
+ scales.elevation = updateTriggers.getElevation = {
10789
+ field: heightField,
10790
+ type: heightScale || "identity",
10791
+ ...scaleProps
10792
+ };
10793
+ }
10794
+ }
10795
+ {
10796
+ const { weightField } = visualChannels;
10797
+ const { weightAggregation } = visConfig;
10798
+ if (weightField && weightAggregation) {
10799
+ const { accessor, ...scaleProps } = getSizeAccessor(
10800
+ weightField,
10801
+ void 0,
10802
+ weightAggregation,
10803
+ void 0,
10804
+ data
10805
+ );
10806
+ result.getWeight = accessor;
10807
+ scales.weight = updateTriggers.getWeight = {
10808
+ field: weightField,
10809
+ type: "identity",
10810
+ ...scaleProps
10811
+ };
10812
+ }
10010
10813
  }
10011
10814
  if (visConfig.customMarkers) {
10012
10815
  const maxIconSize = getMaxMarkerSize(visConfig, visualChannels);
@@ -10023,6 +10826,12 @@ function createChannelProps(id, layerType, config2, visualChannels, data, datase
10023
10826
  { fallbackUrl: customMarkersUrl, maxIconSize, useMaskedIcons },
10024
10827
  data
10025
10828
  );
10829
+ updateTriggers.getIcon = {
10830
+ customMarkersUrl,
10831
+ customMarkersRange,
10832
+ maxIconSize,
10833
+ useMaskedIcons
10834
+ };
10026
10835
  result._subLayerProps = {
10027
10836
  "points-icon": {
10028
10837
  loadOptions: {
@@ -10039,9 +10848,11 @@ function createChannelProps(id, layerType, config2, visualChannels, data, datase
10039
10848
  };
10040
10849
  if (getFillColor && useMaskedIcons) {
10041
10850
  result.getIconColor = getFillColor;
10851
+ updateTriggers.getIconColor = updateTriggers.getFillColor;
10042
10852
  }
10043
10853
  if (getPointRadius) {
10044
10854
  result.getIconSize = getPointRadius;
10855
+ updateTriggers.getIconSize = updateTriggers.getPointRadius;
10045
10856
  }
10046
10857
  if (visualChannels.rotationField) {
10047
10858
  const { accessor } = getSizeAccessor(
@@ -10052,6 +10863,7 @@ function createChannelProps(id, layerType, config2, visualChannels, data, datase
10052
10863
  data
10053
10864
  );
10054
10865
  result.getIconAngle = negateAccessor(accessor);
10866
+ updateTriggers.getIconAngle = updateTriggers.getRotationField;
10055
10867
  }
10056
10868
  } else if (layerType === "tileset") {
10057
10869
  result.pointType = "circle";
@@ -10096,7 +10908,13 @@ function createChannelProps(id, layerType, config2, visualChannels, data, datase
10096
10908
  }
10097
10909
  };
10098
10910
  }
10099
- return { channelProps: result, scales };
10911
+ return {
10912
+ channelProps: {
10913
+ ...result,
10914
+ updateTriggers
10915
+ },
10916
+ scales
10917
+ };
10100
10918
  }
10101
10919
  function createLoadOptions(accessToken) {
10102
10920
  return {
@@ -10752,9 +11570,16 @@ function hashBuckets(initialCount) {
10752
11570
  WidgetSource,
10753
11571
  WidgetTableSource,
10754
11572
  WidgetTilesetSource,
11573
+ _ErrorCode,
11574
+ _applyLayerGroupFilters,
10755
11575
  _buildFeatureFilter,
11576
+ _createVecExprEvaluator,
10756
11577
  _domainFromValues,
11578
+ _evaluateVecExpr,
10757
11579
  _getHexagonResolution,
11580
+ _getLog10ScaleSteps,
11581
+ _getRasterTileLayerStyleProps,
11582
+ _validateVecExprSyntax,
10758
11583
  addFilter,
10759
11584
  aggregate,
10760
11585
  aggregationFunctions,
@@ -10767,9 +11592,11 @@ function hashBuckets(initialCount) {
10767
11592
  buildStatsUrl,
10768
11593
  calculateClusterRadius,
10769
11594
  calculateClusterTextFontSize,
11595
+ calculateLayerScale,
10770
11596
  clearDefaultRequestCache,
10771
11597
  clearFilters,
10772
11598
  configureSource,
11599
+ createColorScale,
10773
11600
  createPolygonSpatialFilter,
10774
11601
  createViewportSpatialFilter,
10775
11602
  fetchBasemapProps,
@@ -10784,6 +11611,7 @@ function hashBuckets(initialCount) {
10784
11611
  getDefaultAggregationExpColumnAliasForLayerType,
10785
11612
  getFilter,
10786
11613
  getIconUrlAccessor,
11614
+ getLayerDescriptor,
10787
11615
  getLayerProps,
10788
11616
  getMaxMarkerSize,
10789
11617
  getSizeAccessor,