@carto/api-client 0.5.15-alpha.raster-5 → 0.5.15

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,16 +125,9 @@ __export(src_exports, {
125
125
  WidgetSource: () => WidgetSource,
126
126
  WidgetTableSource: () => WidgetTableSource,
127
127
  WidgetTilesetSource: () => WidgetTilesetSource,
128
- _ErrorCode: () => ErrorCode,
129
- _applyLayerGroupFilters: () => applyLayerGroupFilters,
130
128
  _buildFeatureFilter: () => _buildFeatureFilter,
131
- _createVecExprEvaluator: () => createVecExprEvaluator,
132
129
  _domainFromValues: () => domainFromValues,
133
- _evaluateVecExpr: () => evaluateVecExpr,
134
130
  _getHexagonResolution: () => _getHexagonResolution,
135
- _getLog10ScaleSteps: () => getLog10ScaleSteps,
136
- _getRasterTileLayerStyleProps: () => getRasterTileLayerStyleProps,
137
- _validateVecExprSyntax: () => validateVecExprSyntax,
138
131
  addFilter: () => addFilter,
139
132
  aggregate: () => aggregate,
140
133
  aggregationFunctions: () => aggregationFunctions,
@@ -147,11 +140,9 @@ __export(src_exports, {
147
140
  buildStatsUrl: () => buildStatsUrl,
148
141
  calculateClusterRadius: () => calculateClusterRadius,
149
142
  calculateClusterTextFontSize: () => calculateClusterTextFontSize,
150
- calculateLayerScale: () => calculateLayerScale,
151
143
  clearDefaultRequestCache: () => clearDefaultRequestCache,
152
144
  clearFilters: () => clearFilters,
153
145
  configureSource: () => configureSource,
154
- createColorScale: () => createColorScale,
155
146
  createPolygonSpatialFilter: () => createPolygonSpatialFilter,
156
147
  createViewportSpatialFilter: () => createViewportSpatialFilter,
157
148
  fetchBasemapProps: () => fetchBasemapProps,
@@ -166,7 +157,6 @@ __export(src_exports, {
166
157
  getDefaultAggregationExpColumnAliasForLayerType: () => getDefaultAggregationExpColumnAliasForLayerType,
167
158
  getFilter: () => getFilter,
168
159
  getIconUrlAccessor: () => getIconUrlAccessor,
169
- getLayerDescriptor: () => getLayerDescriptor,
170
160
  getLayerProps: () => getLayerProps,
171
161
  getMaxMarkerSize: () => getMaxMarkerSize,
172
162
  getSizeAccessor: () => getSizeAccessor,
@@ -197,6 +187,8 @@ __export(src_exports, {
197
187
  tileFeatures: () => tileFeatures,
198
188
  tileFeaturesGeometries: () => tileFeaturesGeometries,
199
189
  tileFeaturesSpatialIndex: () => tileFeaturesSpatialIndex,
190
+ trajectoryQuerySource: () => trajectoryQuerySource,
191
+ trajectoryTableSource: () => trajectoryTableSource,
200
192
  transformToTileCoords: () => transformToTileCoords,
201
193
  vectorQuerySource: () => vectorQuerySource,
202
194
  vectorTableSource: () => vectorTableSource,
@@ -8491,6 +8483,104 @@ var vectorTilesetSource = async function(options) {
8491
8483
  );
8492
8484
  };
8493
8485
 
8486
+ // src/sources/trajectory-query-source.ts
8487
+ init_cjs_shims();
8488
+ var trajectoryQuerySource = async function(options) {
8489
+ const {
8490
+ columns,
8491
+ spatialDataColumn = DEFAULT_GEO_COLUMN,
8492
+ sqlQuery,
8493
+ tileResolution = DEFAULT_TILE_RESOLUTION,
8494
+ queryParameters,
8495
+ aggregationExp,
8496
+ trajectoryIdColumn,
8497
+ timestampColumn
8498
+ } = options;
8499
+ const spatialDataType = "trajectory";
8500
+ const urlParameters = {
8501
+ spatialDataColumn,
8502
+ spatialDataType,
8503
+ tileResolution: tileResolution.toString(),
8504
+ q: sqlQuery,
8505
+ trajectoryIdColumn,
8506
+ timestampColumn
8507
+ };
8508
+ if (columns) {
8509
+ urlParameters.columns = columns.join(",");
8510
+ }
8511
+ if (queryParameters) {
8512
+ urlParameters.queryParameters = queryParameters;
8513
+ }
8514
+ if (aggregationExp) {
8515
+ urlParameters.aggregationExp = aggregationExp;
8516
+ }
8517
+ const result = await baseSource(
8518
+ "query",
8519
+ options,
8520
+ urlParameters
8521
+ );
8522
+ const widgetSource = new WidgetQuerySource({
8523
+ ...options,
8524
+ // NOTE: Parameters with default values above must be explicitly passed here.
8525
+ spatialDataColumn,
8526
+ spatialDataType,
8527
+ tileResolution
8528
+ });
8529
+ const timestampRange = await widgetSource.getRange({ column: timestampColumn });
8530
+ return {
8531
+ ...result,
8532
+ widgetSource,
8533
+ timestampRange
8534
+ };
8535
+ };
8536
+
8537
+ // src/sources/trajectory-table-source.ts
8538
+ init_cjs_shims();
8539
+ var trajectoryTableSource = async function(options) {
8540
+ const {
8541
+ columns,
8542
+ spatialDataColumn = DEFAULT_GEO_COLUMN,
8543
+ tableName,
8544
+ tileResolution = DEFAULT_TILE_RESOLUTION,
8545
+ aggregationExp,
8546
+ trajectoryIdColumn,
8547
+ timestampColumn
8548
+ } = options;
8549
+ const spatialDataType = "trajectory";
8550
+ const urlParameters = {
8551
+ name: tableName,
8552
+ spatialDataColumn,
8553
+ spatialDataType,
8554
+ tileResolution: tileResolution.toString(),
8555
+ trajectoryIdColumn,
8556
+ timestampColumn
8557
+ };
8558
+ if (columns) {
8559
+ urlParameters.columns = columns.join(",");
8560
+ }
8561
+ if (aggregationExp) {
8562
+ urlParameters.aggregationExp = aggregationExp;
8563
+ }
8564
+ const result = await baseSource(
8565
+ "table",
8566
+ options,
8567
+ urlParameters
8568
+ );
8569
+ const widgetSource = new WidgetTableSource({
8570
+ ...options,
8571
+ // NOTE: Parameters with default values above must be explicitly passed here.
8572
+ spatialDataColumn,
8573
+ spatialDataType,
8574
+ tileResolution
8575
+ });
8576
+ const timestampRange = await widgetSource.getRange({ column: timestampColumn });
8577
+ return {
8578
+ ...result,
8579
+ widgetSource,
8580
+ timestampRange
8581
+ };
8582
+ };
8583
+
8494
8584
  // src/api/query.ts
8495
8585
  var query = async function(options) {
8496
8586
  const {
@@ -8649,253 +8739,11 @@ var basemap_styles_default = {
8649
8739
  DARK_MATTER_NOLABELS: getStyleUrl("dark-matter-nolabels")
8650
8740
  };
8651
8741
 
8652
- // src/fetch-map/raster-layer.ts
8742
+ // src/fetch-map/fetch-map.ts
8653
8743
  init_cjs_shims();
8654
8744
 
8655
- // src/fetch-map/vec-expr-evaluator.ts
8745
+ // src/fetch-map/parse-map.ts
8656
8746
  init_cjs_shims();
8657
- var import_jsep = __toESM(require("jsep"), 1);
8658
- function createVecExprEvaluator(expression) {
8659
- try {
8660
- const parsed = compile(expression);
8661
- const evalFun = (context) => evaluate(parsed, context);
8662
- evalFun.symbols = getSymbols(parsed);
8663
- return evalFun;
8664
- } catch {
8665
- return null;
8666
- }
8667
- }
8668
- function evaluateVecExpr(expression, context) {
8669
- try {
8670
- return createVecExprEvaluator(expression)?.(context);
8671
- } catch {
8672
- return null;
8673
- }
8674
- }
8675
- var ErrorCode = /* @__PURE__ */ ((ErrorCode2) => {
8676
- ErrorCode2[ErrorCode2["InvalidSyntax"] = 0] = "InvalidSyntax";
8677
- ErrorCode2[ErrorCode2["UnknownIdentifier"] = 1] = "UnknownIdentifier";
8678
- return ErrorCode2;
8679
- })(ErrorCode || {});
8680
- function validateVecExprSyntax(expression, context) {
8681
- let parsed;
8682
- try {
8683
- parsed = compile(expression);
8684
- } catch (e) {
8685
- return {
8686
- valid: false,
8687
- errorCode: 0 /* InvalidSyntax */,
8688
- errorMessage: e && "message" in e ? String(e.message) : String(e)
8689
- };
8690
- }
8691
- return validate(parsed, context);
8692
- }
8693
- function createResultArray(typeTemplate, length2 = typeTemplate.length) {
8694
- return new Array(length2);
8695
- }
8696
- function isVecLike(a) {
8697
- return Array.isArray(a) || ArrayBuffer.isView(a);
8698
- }
8699
- var createBinopVec = (scalarBinOp) => (left, right) => {
8700
- const length2 = Math.min(left.length, right.length);
8701
- const r = createResultArray(left, length2);
8702
- for (let i = 0; i < length2; i++) {
8703
- r[i] = scalarBinOp(left[i], right[i]);
8704
- }
8705
- return r;
8706
- };
8707
- var createBinopVecNum = (scalarBinOp) => (left, right) => {
8708
- const length2 = left.length;
8709
- const r = createResultArray(left, length2);
8710
- for (let i = 0; i < length2; i++) {
8711
- r[i] = scalarBinOp(left[i], right);
8712
- }
8713
- return r;
8714
- };
8715
- var createBinopNumVec = (scalarBinOp) => (left, right) => {
8716
- const length2 = right.length;
8717
- const r = createResultArray(right, length2);
8718
- for (let i = 0; i < length2; i++) {
8719
- r[i] = scalarBinOp(left, right[i]);
8720
- }
8721
- return r;
8722
- };
8723
- var createUnopVec = (scalarUnop) => (a) => {
8724
- const length2 = a.length;
8725
- const r = createResultArray(a, length2);
8726
- for (let i = 0; i < length2; i++) {
8727
- r[i] = scalarUnop(a[i]);
8728
- }
8729
- return r;
8730
- };
8731
- function mapDictValues(dict, fun) {
8732
- return Object.keys(dict).reduce(
8733
- (acc, key) => {
8734
- acc[key] = fun(dict[key]);
8735
- return acc;
8736
- },
8737
- {}
8738
- );
8739
- }
8740
- var binopsNum = {
8741
- "||": (a, b) => a || b,
8742
- "&&": (a, b) => a && b,
8743
- "|": (a, b) => a | b,
8744
- "^": (a, b) => a ^ b,
8745
- "&": (a, b) => a & b,
8746
- "==": (a, b) => Number(a == b),
8747
- "!=": (a, b) => Number(a != b),
8748
- "===": (a, b) => Number(a === b),
8749
- "!==": (a, b) => Number(a !== b),
8750
- "<": (a, b) => Number(a < b),
8751
- ">": (a, b) => Number(a > b),
8752
- "<=": (a, b) => Number(a <= b),
8753
- ">=": (a, b) => Number(a >= b),
8754
- "<<": (a, b) => a << b,
8755
- ">>": (a, b) => a >> b,
8756
- ">>>": (a, b) => a >>> b,
8757
- "+": (a, b) => a + b,
8758
- "-": (a, b) => a - b,
8759
- "*": (a, b) => a * b,
8760
- "/": (a, b) => a / b,
8761
- "%": (a, b) => a % b
8762
- };
8763
- var unopsNum = {
8764
- "-": (a) => -a,
8765
- "+": (a) => +a,
8766
- "~": (a) => ~a,
8767
- "!": (a) => Number(!a)
8768
- };
8769
- var binopsVector = mapDictValues(binopsNum, createBinopVec);
8770
- var binopsNumVec = mapDictValues(binopsNum, createBinopNumVec);
8771
- var binopsVecNum = mapDictValues(binopsNum, createBinopVecNum);
8772
- var unopsVector = mapDictValues(unopsNum, createUnopVec);
8773
- function getBinop(operator, left, right) {
8774
- const isLeftVec = isVecLike(left);
8775
- const isRightVec = isVecLike(right);
8776
- if (isLeftVec && isRightVec) {
8777
- return binopsVector[operator];
8778
- } else if (isLeftVec) {
8779
- return binopsVecNum[operator];
8780
- } else if (isRightVec) {
8781
- return binopsNumVec[operator];
8782
- } else {
8783
- return binopsNum[operator];
8784
- }
8785
- }
8786
- function evaluate(_node, context) {
8787
- const node = _node;
8788
- switch (node.type) {
8789
- case "BinaryExpression": {
8790
- const left = evaluate(node.left, context);
8791
- const right = evaluate(node.right, context);
8792
- const binopFun = getBinop(node.operator, left, right);
8793
- return binopFun(left, right);
8794
- }
8795
- case "ConditionalExpression": {
8796
- const val = evaluate(node.test, context);
8797
- if (isVecLike(val)) {
8798
- const length2 = val.length;
8799
- const consequentVal = evaluate(node.consequent, context);
8800
- const alternateVal = evaluate(node.alternate, context);
8801
- const r = createResultArray(val);
8802
- for (let i = 0; i < length2; i++) {
8803
- const entryVal = val[i] ? consequentVal : alternateVal;
8804
- r[i] = isVecLike(entryVal) ? entryVal[i] ?? NaN : entryVal;
8805
- }
8806
- return r;
8807
- } else {
8808
- return val ? evaluate(node.consequent, context) : evaluate(node.alternate, context);
8809
- }
8810
- }
8811
- case "Identifier":
8812
- return context[node.name];
8813
- case "Literal":
8814
- return node.value;
8815
- case "UnaryExpression": {
8816
- const val = evaluate(node.argument, context);
8817
- const unopFun = isVecLike(val) ? unopsVector[node.operator] : unopsNum[node.operator];
8818
- return unopFun(val);
8819
- }
8820
- default:
8821
- return void 0;
8822
- }
8823
- }
8824
- var validResult = { valid: true };
8825
- function visit(_node, visitor) {
8826
- const node = _node;
8827
- visitor(node);
8828
- switch (node.type) {
8829
- case "BinaryExpression": {
8830
- visit(node.left, visitor);
8831
- visit(node.right, visitor);
8832
- break;
8833
- }
8834
- case "ConditionalExpression": {
8835
- visit(node.test, visitor);
8836
- visit(node.consequent, visitor);
8837
- visit(node.alternate, visitor);
8838
- break;
8839
- }
8840
- case "UnaryExpression": {
8841
- visit(node.argument, visitor);
8842
- break;
8843
- }
8844
- }
8845
- }
8846
- var supportedExpressionTypes = [
8847
- "BinaryExpression",
8848
- "UnaryExpression",
8849
- "ConditionalExpression",
8850
- "LogicalExpression",
8851
- "Identifier",
8852
- "Literal"
8853
- ];
8854
- function validate(_node, context) {
8855
- const node = _node;
8856
- const errors = [];
8857
- visit(node, (node2) => {
8858
- if (!supportedExpressionTypes.includes(node2.type)) {
8859
- errors.push({
8860
- valid: false,
8861
- errorCode: 0 /* InvalidSyntax */,
8862
- errorMessage: `Not allowed`
8863
- });
8864
- return;
8865
- }
8866
- if (node2.type === "Identifier") {
8867
- if (!Object.prototype.hasOwnProperty.call(context, node2.name)) {
8868
- return errors.push({
8869
- valid: false,
8870
- errorCode: 1 /* UnknownIdentifier */,
8871
- errorMessage: `"${node2.name}" not found`
8872
- });
8873
- }
8874
- }
8875
- if (node2.type === "Literal") {
8876
- if (typeof node2.value !== "number") {
8877
- return errors.push({
8878
- valid: false,
8879
- errorCode: 0 /* InvalidSyntax */,
8880
- errorMessage: `Only number literals are supported`
8881
- });
8882
- }
8883
- }
8884
- });
8885
- return errors.length ? errors[0] : validResult;
8886
- }
8887
- function getSymbols(node) {
8888
- const symbols = /* @__PURE__ */ new Set();
8889
- visit(node, (node2) => {
8890
- if (node2.type === "Identifier") {
8891
- symbols.add(node2.name);
8892
- }
8893
- });
8894
- return Array.from(symbols);
8895
- }
8896
- function compile(expression) {
8897
- return (0, import_jsep.default)(expression);
8898
- }
8899
8747
 
8900
8748
  // src/fetch-map/layer-map.ts
8901
8749
  init_cjs_shims();
@@ -9494,37 +9342,6 @@ function formatDate(value) {
9494
9342
  function formatTimestamp(value) {
9495
9343
  return String(Math.floor(new Date(value).getTime() / 1e3));
9496
9344
  }
9497
- function roundedPow10(exp) {
9498
- const raw = Math.pow(10, exp);
9499
- if (exp < 0) {
9500
- const shift = Math.pow(10, -exp);
9501
- return Math.round(raw * shift) / shift;
9502
- }
9503
- return raw;
9504
- }
9505
- function getLog10ScaleSteps({
9506
- min: min2,
9507
- max: max2,
9508
- steps
9509
- }) {
9510
- if (min2 === 0) {
9511
- if (max2 === Infinity) {
9512
- return [...Array(steps - 1)].map((_v, i) => roundedPow10(i + 1));
9513
- }
9514
- const maxLog = Math.log10(max2);
9515
- const endExponent = Math.ceil(maxLog);
9516
- const startExponent = endExponent - steps + 1;
9517
- return [...Array(steps - 1)].map(
9518
- (_v, i) => roundedPow10(startExponent + i)
9519
- );
9520
- } else {
9521
- const minLog = Math.log10(min2);
9522
- const startExponent = Math.ceil(minLog) === minLog ? minLog + 1 : Math.ceil(minLog);
9523
- return [...Array(steps - 1)].map(
9524
- (_v, i) => roundedPow10(startExponent + i)
9525
- );
9526
- }
9527
- }
9528
9345
 
9529
9346
  // src/fetch-map/layer-map.ts
9530
9347
  var SCALE_FUNCS = {
@@ -9541,19 +9358,7 @@ var SCALE_FUNCS = {
9541
9358
  function identity2(v2) {
9542
9359
  return v2;
9543
9360
  }
9544
- var hexToRGB = (c) => {
9545
- const { r, g, b } = rgb(c);
9546
- return [r, g, b];
9547
- };
9548
- var rgbToHex = (c) => {
9549
- const [r, g, b] = c;
9550
- const rStr = r.toString(16).padStart(2, "0");
9551
- const gStr = g.toString(16).padStart(2, "0");
9552
- const bStr = b.toString(16).padStart(2, "0");
9553
- return `#${rStr}${gStr}${bStr}`.toUpperCase();
9554
- };
9555
9361
  var UNKNOWN_COLOR = "#868d91";
9556
- var UNKNOWN_COLOR_RGB = hexToRGB(UNKNOWN_COLOR);
9557
9362
  var OPACITY_MAP = {
9558
9363
  getFillColor: "opacity",
9559
9364
  getLineColor: "strokeOpacity",
@@ -9586,12 +9391,6 @@ var sharedPropMap = {
9586
9391
  wireframe: "wireframe"
9587
9392
  }
9588
9393
  };
9589
- var rasterPropsMap = {
9590
- isVisible: "visible",
9591
- visConfig: {
9592
- opacity: "opacity"
9593
- }
9594
- };
9595
9394
  var customMarkersPropsMap = {
9596
9395
  color: "getIconColor",
9597
9396
  visConfig: {
@@ -9635,12 +9434,6 @@ function getLayerProps(type, config2, dataset) {
9635
9434
  `Outdated layer type: ${type}. Please open map in CARTO Builder to automatically migrate.`
9636
9435
  );
9637
9436
  }
9638
- if (type === "raster") {
9639
- return {
9640
- propMap: rasterPropsMap,
9641
- defaultProps: {}
9642
- };
9643
- }
9644
9437
  let basePropMap = sharedPropMap;
9645
9438
  if (config2.visConfig?.customMarkers) {
9646
9439
  basePropMap = mergePropMaps(basePropMap, customMarkersPropsMap);
@@ -9661,19 +9454,16 @@ function getLayerProps(type, config2, dataset) {
9661
9454
  }
9662
9455
  function domainFromAttribute(attribute, scaleType, scaleLength) {
9663
9456
  if (scaleType === "ordinal" || scaleType === "point") {
9664
- if (!attribute.categories) {
9665
- return [0, 1];
9666
- }
9667
9457
  return attribute.categories.map((c) => c.category).filter((c) => c !== void 0 && c !== null);
9668
9458
  }
9669
9459
  if (scaleType === "quantile" && attribute.quantiles) {
9670
- return "global" in attribute.quantiles ? attribute.quantiles.global[scaleLength] : attribute.quantiles[scaleLength];
9460
+ return attribute.quantiles.global ? attribute.quantiles.global[scaleLength] : attribute.quantiles[scaleLength];
9671
9461
  }
9672
9462
  let { min: min2 } = attribute;
9673
9463
  if (scaleType === "log" && min2 === 0) {
9674
9464
  min2 = 1e-5;
9675
9465
  }
9676
- return [min2 ?? 0, attribute.max ?? 1];
9466
+ return [min2, attribute.max];
9677
9467
  }
9678
9468
  function domainFromValues(values, scaleType) {
9679
9469
  if (scaleType === "ordinal" || scaleType === "point") {
@@ -9694,14 +9484,12 @@ function calculateDomain(data, name, scaleType, scaleLength) {
9694
9484
  if (data.tilestats) {
9695
9485
  const { attributes } = data.tilestats.layers[0];
9696
9486
  const attribute = attributes.find((a) => a.attribute === name);
9697
- if (attribute) {
9698
- return domainFromAttribute(attribute, scaleType, scaleLength);
9699
- }
9487
+ return domainFromAttribute(attribute, scaleType, scaleLength);
9700
9488
  }
9701
9489
  return [0, 1];
9702
9490
  }
9703
9491
  function normalizeAccessor(accessor, data) {
9704
- if (data.features || data.tilestats || data.raster_metadata) {
9492
+ if (data.features || data.tilestats) {
9705
9493
  return (object, info) => {
9706
9494
  if (object) {
9707
9495
  return accessor(object.properties || object.__source.object.properties);
@@ -9734,75 +9522,46 @@ function findAccessorKey(keys, properties) {
9734
9522
  return keys;
9735
9523
  }
9736
9524
  function getColorAccessor({ name, colorColumn }, scaleType, { aggregation, range }, opacity, data) {
9737
- const { scale: scale2, domain } = calculateLayerScale(
9525
+ const scale2 = calculateLayerScale(
9738
9526
  colorColumn || name,
9739
- colorColumn ? "identity" : scaleType,
9527
+ scaleType,
9740
9528
  range,
9741
9529
  data
9742
9530
  );
9743
9531
  const alpha = opacityToAlpha(opacity);
9744
- let accessorKeys = getAccessorKeys(colorColumn || name, aggregation);
9532
+ let accessorKeys = getAccessorKeys(name, aggregation);
9745
9533
  const accessor = (properties) => {
9746
9534
  if (!(accessorKeys[0] in properties)) {
9747
9535
  accessorKeys = findAccessorKey(accessorKeys, properties);
9748
9536
  }
9749
9537
  const propertyValue = properties[accessorKeys[0]];
9750
- const scaled = scale2(propertyValue);
9751
- const rgb2 = typeof scaled === "string" ? hexToRGB(scaled) : scaled;
9752
- return [...rgb2, propertyValue === null ? 0 : alpha];
9753
- };
9754
- return {
9755
- accessor: normalizeAccessor(accessor, data),
9756
- scaleDomain: scale2.domain(),
9757
- domain,
9758
- range: (scale2.range() || []).map(rgbToHex)
9538
+ const { r, g, b } = rgb(scale2(propertyValue));
9539
+ return [r, g, b, propertyValue === null ? 0 : alpha];
9759
9540
  };
9541
+ return { accessor: normalizeAccessor(accessor, data), scale: scale2 };
9760
9542
  }
9761
9543
  function calculateLayerScale(name, scaleType, range, data) {
9544
+ const scale2 = SCALE_FUNCS[scaleType]();
9762
9545
  let domain = [];
9763
- let scaleDomain;
9764
9546
  let scaleColor = [];
9765
- const { colors } = range;
9766
- if (scaleType === "custom") {
9767
- domain = calculateDomain(data, name, scaleType, colors.length);
9768
- const [min2, max2] = domain;
9769
- if (range.uiCustomScaleType === "logarithmic") {
9770
- scaleDomain = getLog10ScaleSteps({
9771
- min: min2,
9772
- max: max2,
9773
- steps: colors.length
9774
- });
9775
- scaleColor = colors;
9776
- } else if (range.colorMap) {
9777
- const { colorMap } = range;
9778
- scaleDomain = [];
9547
+ if (scaleType !== "identity") {
9548
+ const { colorMap, colors } = range;
9549
+ if (Array.isArray(colorMap)) {
9779
9550
  colorMap.forEach(([value, color2]) => {
9780
- scaleDomain.push(Number(value));
9551
+ domain.push(value);
9781
9552
  scaleColor.push(color2);
9782
9553
  });
9554
+ } else {
9555
+ domain = calculateDomain(data, name, scaleType, colors.length);
9556
+ scaleColor = colors;
9783
9557
  }
9784
- } else if (scaleType !== "identity") {
9785
- domain = calculateDomain(data, name, scaleType, colors.length);
9786
- scaleColor = colors;
9787
9558
  if (scaleType === "ordinal") {
9788
9559
  domain = domain.slice(0, scaleColor.length);
9789
9560
  }
9790
9561
  }
9791
- return {
9792
- scale: createColorScale(
9793
- scaleType,
9794
- scaleDomain || domain,
9795
- scaleColor.map(hexToRGB),
9796
- UNKNOWN_COLOR_RGB
9797
- ),
9798
- domain
9799
- };
9800
- }
9801
- function createColorScale(scaleType, domain, range, unknown) {
9802
- const scale2 = SCALE_FUNCS[scaleType]();
9803
9562
  scale2.domain(domain);
9804
- scale2.range(range);
9805
- scale2.unknown(unknown);
9563
+ scale2.range(scaleColor);
9564
+ scale2.unknown(UNKNOWN_COLOR);
9806
9565
  return scale2;
9807
9566
  }
9808
9567
  var FALLBACK_ICON = "data:image/svg+xml;charset=utf-8;base64,PHN2ZyB2aWV3Qm94PSIwIDAgMTAwIDEwMCIgeG1sbnM9Imh0dHA6Ly93d3cudzMub3JnLzIwMDAvc3ZnIj4NCiAgPGNpcmNsZSBjeD0iNTAiIGN5PSI1MCIgcj0iNTAiLz4NCjwvc3ZnPg==";
@@ -9852,13 +9611,9 @@ function negateAccessor(accessor) {
9852
9611
  }
9853
9612
  function getSizeAccessor({ name }, scaleType, aggregation, range, data) {
9854
9613
  const scale2 = scaleType ? SCALE_FUNCS[scaleType]() : identity2;
9855
- let domain = [];
9856
- if (scaleType && range) {
9614
+ if (scaleType) {
9857
9615
  if (aggregation !== AggregationTypes.Count) {
9858
- domain = calculateDomain(data, name, scaleType);
9859
- scale2.domain(domain);
9860
- } else {
9861
- domain = scale2.domain();
9616
+ scale2.domain(calculateDomain(data, name, scaleType));
9862
9617
  }
9863
9618
  scale2.range(range);
9864
9619
  }
@@ -9870,12 +9625,7 @@ function getSizeAccessor({ name }, scaleType, aggregation, range, data) {
9870
9625
  const propertyValue = properties[accessorKeys[0]];
9871
9626
  return scale2(propertyValue);
9872
9627
  };
9873
- return {
9874
- accessor: normalizeAccessor(accessor, data),
9875
- domain,
9876
- scaleDomain: domain,
9877
- range
9878
- };
9628
+ return { accessor: normalizeAccessor(accessor, data), scale: scale2 };
9879
9629
  }
9880
9630
  var FORMATS = {
9881
9631
  date: formatDate,
@@ -9926,424 +9676,13 @@ function calculateClusterTextFontSize(radius) {
9926
9676
  return 11;
9927
9677
  }
9928
9678
 
9929
- // src/fetch-map/raster-layer.ts
9930
- var UNKNOWN_COLOR2 = [134, 141, 145];
9931
- var RASTER_COLOR_BANDS = ["red", "green", "blue"];
9932
- function getHasDataPredicate(noData) {
9933
- if (noData === "nan") {
9934
- return (v2) => !isNaN(v2);
9935
- }
9936
- if (typeof noData === "string") {
9937
- noData = parseFloat(noData);
9938
- }
9939
- if (typeof noData === "number") {
9940
- return (v2) => v2 !== noData && !isNaN(v2);
9941
- }
9942
- return () => true;
9943
- }
9944
- function createRasterColumnLayerDataTransform(transform) {
9945
- return (data) => {
9946
- if (!data || !("data" in data) || !data?.data?.cells?.numericProps) {
9947
- return data;
9948
- }
9949
- return transform(data);
9950
- };
9951
- }
9952
- function createEvaluationContext(numericProps, noData) {
9953
- const hasData = getHasDataPredicate(noData);
9954
- const bands = Object.entries(numericProps).map(([bandName, { value }]) => ({
9955
- bandName,
9956
- values: value,
9957
- copied: false
9958
- }));
9959
- const length2 = bands[0].values.length;
9960
- for (let i = 0; i < length2; i++) {
9961
- let hasSomeData = false;
9962
- for (let j = 0; j < bands.length; j++) {
9963
- hasSomeData = hasSomeData || hasData(bands[j].values[i]);
9964
- }
9965
- if (!hasSomeData) {
9966
- for (let j = 0; j < bands.length; j++) {
9967
- if (!bands[j].copied) {
9968
- bands[j].copied = true;
9969
- bands[j].values = Array.from(bands[j].values);
9970
- }
9971
- bands[j].values[i] = NaN;
9972
- }
9973
- }
9974
- }
9975
- const context = bands.reduce(
9976
- (agg, { bandName, values }) => {
9977
- agg[bandName] = values;
9978
- return agg;
9979
- },
9980
- {}
9981
- );
9982
- return context;
9983
- }
9984
- function createExprDataTransform({
9985
- colorBand,
9986
- rasterMetadata,
9987
- usedSymbols
9988
- }) {
9989
- if (!colorBand || !colorBand.type || colorBand.type === "none") {
9990
- return void 0;
9991
- }
9992
- const expr = colorBand?.type === "expression" ? colorBand.value : void 0;
9993
- const vecExprEvaluator = expr ? createVecExprEvaluator(expr) : void 0;
9994
- const dataTransform = createRasterColumnLayerDataTransform(
9995
- (dataWrapped) => {
9996
- const data = dataWrapped.data;
9997
- if (expr) {
9998
- const cachedResult = dataWrapped.customExpressionResults?.[expr];
9999
- if (cachedResult) {
10000
- return dataWrapped;
10001
- }
10002
- }
10003
- let context = dataWrapped.expressionEvalContext;
10004
- if (!context) {
10005
- const usedNumericProps = usedSymbols.reduce(
10006
- (acc, symbol) => {
10007
- acc[symbol] = data.cells.numericProps[symbol];
10008
- return acc;
10009
- },
10010
- {}
10011
- );
10012
- context = createEvaluationContext(
10013
- usedNumericProps,
10014
- rasterMetadata.nodata
10015
- );
10016
- dataWrapped = {
10017
- ...dataWrapped,
10018
- expressionEvalContext: context
10019
- };
10020
- }
10021
- if (!vecExprEvaluator || !expr) return dataWrapped;
10022
- const evalResult = vecExprEvaluator(context);
10023
- return {
10024
- ...dataWrapped,
10025
- customExpressionResults: {
10026
- ...dataWrapped.customExpressionResults,
10027
- [expr]: evalResult
10028
- }
10029
- };
10030
- }
10031
- );
10032
- return dataTransform;
10033
- }
10034
- function combineDataTransforms(dataTransforms) {
10035
- const actualTransforms = dataTransforms.filter((v2) => v2);
10036
- if (actualTransforms.length === 0) return void 0;
10037
- if (actualTransforms.length === 1) return actualTransforms[0];
10038
- return (data) => actualTransforms.reduce(
10039
- (aggData, transformFun) => transformFun(aggData),
10040
- data
10041
- );
10042
- }
10043
- function createRgbToColorBufferDataTransform({
10044
- bandDefs,
10045
- attribute
10046
- }) {
10047
- return createRasterColumnLayerDataTransform(
10048
- (dataWrapped) => {
10049
- const length2 = dataWrapped.length;
10050
- const getBandBufferOrValue = (colorBand) => {
10051
- if (colorBand?.type === "expression") {
10052
- return dataWrapped.customExpressionResults?.[colorBand.value];
10053
- }
10054
- if (colorBand?.type === "band") {
10055
- return dataWrapped.expressionEvalContext?.[colorBand.value];
10056
- }
10057
- return 0;
10058
- };
10059
- const red = getBandBufferOrValue(bandDefs.red);
10060
- const green = getBandBufferOrValue(bandDefs.green);
10061
- const blue = getBandBufferOrValue(bandDefs.blue);
10062
- const colorBuffer = new Uint8Array(length2 * 4);
10063
- for (let inputIndex = 0, outputIndex = 0; inputIndex < length2; inputIndex++, outputIndex += 4) {
10064
- const redRaw = typeof red === "number" ? red : red ? red[inputIndex] : NaN;
10065
- const greenRaw = typeof green === "number" ? green : green ? green[inputIndex] : NaN;
10066
- const blueRaw = typeof blue === "number" ? blue : blue ? blue[inputIndex] : NaN;
10067
- if (isNaN(redRaw) && isNaN(greenRaw) && isNaN(blueRaw)) {
10068
- bufferSetRgba(colorBuffer, outputIndex, 0, 0, 0, 0);
10069
- } else {
10070
- bufferSetRgba(
10071
- colorBuffer,
10072
- outputIndex,
10073
- redRaw,
10074
- greenRaw,
10075
- blueRaw,
10076
- 255
10077
- );
10078
- }
10079
- }
10080
- dataWrapped.customExpressionResults = void 0;
10081
- dataWrapped.expressionEvalContext = void 0;
10082
- return {
10083
- ...dataWrapped,
10084
- attributes: {
10085
- [attribute]: colorBuffer
10086
- }
10087
- };
10088
- }
10089
- );
10090
- }
10091
- function getUsedSymbols(colorBands) {
10092
- return Array.from(
10093
- colorBands.reduce((symbols, band) => {
10094
- if (band.type === "expression") {
10095
- const expressionSymbols = createVecExprEvaluator(band.value)?.symbols || [];
10096
- expressionSymbols.forEach((symbol) => symbols.add(symbol));
10097
- }
10098
- if (band.type === "band") {
10099
- symbols.add(band.value);
10100
- }
10101
- return symbols;
10102
- }, /* @__PURE__ */ new Set())
10103
- );
10104
- }
10105
- function getRasterTileLayerStylePropsRgb({
10106
- layerConfig,
10107
- rasterMetadata,
10108
- visualChannels
10109
- }) {
10110
- const { visConfig } = layerConfig;
10111
- const { colorBands } = visConfig;
10112
- const bandDefs = {
10113
- red: colorBands?.find((band) => band.band === "red"),
10114
- green: colorBands?.find((band) => band.band === "green"),
10115
- blue: colorBands?.find((band) => band.band === "blue")
10116
- };
10117
- const rgbToInstanceFillColorsDataTransform = createRgbToColorBufferDataTransform({
10118
- bandDefs,
10119
- attribute: "instanceFillColors"
10120
- });
10121
- const usedSymbols = colorBands ? getUsedSymbols(colorBands) : [];
10122
- const bandTransforms = RASTER_COLOR_BANDS.map(
10123
- (band) => createExprDataTransform({
10124
- colorBand: bandDefs[band],
10125
- rasterMetadata,
10126
- usedSymbols
10127
- })
10128
- );
10129
- const combinedDataTransform = combineDataTransforms([
10130
- ...bandTransforms,
10131
- rgbToInstanceFillColorsDataTransform
10132
- ]);
10133
- return {
10134
- dataTransform: combinedDataTransform,
10135
- updateTriggers: getRasterTileLayerUpdateTriggers({
10136
- layerConfig,
10137
- visualChannels
10138
- })
10139
- };
10140
- }
10141
- function createBandColorScaleDataTransform({
10142
- bandName,
10143
- scaleFun,
10144
- nodata,
10145
- attribute
10146
- }) {
10147
- const hasData = getHasDataPredicate(nodata);
10148
- return createRasterColumnLayerDataTransform(
10149
- (dataWrapped) => {
10150
- const length2 = dataWrapped.length;
10151
- const bandBuffer = dataWrapped.data.cells.numericProps[bandName].value;
10152
- const colorBuffer = new Uint8Array(length2 * 4);
10153
- for (let i = 0; i < length2; i++) {
10154
- const rawValue = bandBuffer[i];
10155
- if (!hasData(rawValue)) {
10156
- bufferSetRgba(colorBuffer, i * 4, 0, 0, 0, 0);
10157
- } else {
10158
- const colorRgb = scaleFun(rawValue);
10159
- bufferSetRgba(
10160
- colorBuffer,
10161
- i * 4,
10162
- colorRgb[0],
10163
- colorRgb[1],
10164
- colorRgb[2],
10165
- 255
10166
- );
10167
- }
10168
- }
10169
- return {
10170
- ...dataWrapped,
10171
- attributes: {
10172
- [attribute]: colorBuffer
10173
- }
10174
- };
10175
- }
10176
- );
10177
- }
10178
- function domainFromRasterMetadataBand(band, scaleType, colorRange) {
10179
- if (scaleType === "ordinal") {
10180
- return colorRange.colorMap?.map(([value]) => value) || [];
10181
- }
10182
- if (scaleType === "custom") {
10183
- if (colorRange.uiCustomScaleType === "logarithmic") {
10184
- return getLog10ScaleSteps({
10185
- min: band.stats.min,
10186
- max: band.stats.max,
10187
- steps: colorRange.colors.length
10188
- });
10189
- } else {
10190
- return colorRange.colorMap?.map(([value]) => value) || [];
10191
- }
10192
- }
10193
- const scaleLength = colorRange.colors.length;
10194
- if (scaleType === "quantile") {
10195
- const quantiles = band.stats.quantiles?.[scaleLength];
10196
- if (!quantiles) {
10197
- return [0, 1];
10198
- }
10199
- return [band.stats.min, ...quantiles, band.stats.max];
10200
- }
10201
- return [band.stats.min, band.stats.max];
10202
- }
10203
- function getRasterTileLayerStylePropsScaledBand({
10204
- layerConfig,
10205
- rasterMetadata,
10206
- visualChannels
10207
- }) {
10208
- const { visConfig } = layerConfig;
10209
- const { colorField } = visualChannels;
10210
- const { rasterStyleType } = visConfig;
10211
- const colorRange = rasterStyleType === "ColorRange" ? visConfig.colorRange : visConfig.uniqueValuesColorRange;
10212
- const scaleType = rasterStyleType === "ColorRange" ? visualChannels.colorScale : "ordinal";
10213
- const bandInfo = rasterMetadata.bands.find(
10214
- (band) => band.name === colorField?.name
10215
- );
10216
- if (!colorField?.name || !scaleType || !colorRange || !bandInfo) {
10217
- return {};
10218
- }
10219
- const domain = domainFromRasterMetadataBand(bandInfo, scaleType, colorRange);
10220
- const scaleFun = createColorScale(
10221
- scaleType,
10222
- domain,
10223
- colorRange.colors.map(hexToRGB2),
10224
- UNKNOWN_COLOR2
10225
- );
10226
- const bandColorScaleDataTransform = createBandColorScaleDataTransform({
10227
- bandName: bandInfo.name,
10228
- scaleFun,
10229
- nodata: bandInfo?.nodata ?? rasterMetadata.nodata,
10230
- attribute: "instanceFillColors"
10231
- });
10232
- return {
10233
- dataTransform: bandColorScaleDataTransform,
10234
- updateTriggers: getRasterTileLayerUpdateTriggers({
10235
- layerConfig,
10236
- visualChannels
10237
- })
10238
- };
10239
- }
10240
- function getRasterTileLayerStyleProps({
10241
- layerConfig,
10242
- visualChannels,
10243
- rasterMetadata
10244
- }) {
10245
- const { visConfig } = layerConfig;
10246
- const { rasterStyleType } = visConfig;
10247
- if (rasterStyleType === "Rgb") {
10248
- return getRasterTileLayerStylePropsRgb({
10249
- layerConfig,
10250
- rasterMetadata,
10251
- visualChannels
10252
- });
10253
- } else {
10254
- return getRasterTileLayerStylePropsScaledBand({
10255
- layerConfig,
10256
- rasterMetadata,
10257
- visualChannels
10258
- });
10259
- }
10260
- }
10261
- function getRasterTileLayerUpdateTriggers({
10262
- layerConfig,
10263
- visualChannels
10264
- }) {
10265
- const { visConfig } = layerConfig;
10266
- const { rasterStyleType } = visConfig;
10267
- const getFillColorUpdateTriggers = {
10268
- rasterStyleType
10269
- };
10270
- if (rasterStyleType === "ColorRange") {
10271
- getFillColorUpdateTriggers.colorRange = visConfig.colorRange?.colors;
10272
- getFillColorUpdateTriggers.colorMap = visConfig.colorRange?.colorMap;
10273
- getFillColorUpdateTriggers.colorScale = visualChannels.colorScale;
10274
- getFillColorUpdateTriggers.colorFieldId = visualChannels.colorField?.name;
10275
- } else if (rasterStyleType === "UniqueValues") {
10276
- getFillColorUpdateTriggers.colorMap = visConfig.uniqueValuesColorRange?.colorMap;
10277
- getFillColorUpdateTriggers.colorFieldId = visualChannels.colorField?.name;
10278
- } else if (rasterStyleType === "Rgb") {
10279
- getFillColorUpdateTriggers.colorBands = visConfig.colorBands;
10280
- }
10281
- return {
10282
- getFillColor: getFillColorUpdateTriggers
10283
- };
10284
- }
10285
- function bufferSetRgba(target, index, r, g, b, a) {
10286
- target[index + 0] = r;
10287
- target[index + 1] = g;
10288
- target[index + 2] = b;
10289
- target[index + 3] = a;
10290
- }
10291
- function hexToRGB2(hexColor) {
10292
- const r = parseInt(hexColor.slice(1, 3), 16);
10293
- const g = parseInt(hexColor.slice(3, 5), 16);
10294
- const b = parseInt(hexColor.slice(5, 7), 16);
10295
- return [r, g, b];
10296
- }
10297
-
10298
- // src/fetch-map/fetch-map.ts
10299
- init_cjs_shims();
10300
-
10301
9679
  // src/fetch-map/parse-map.ts
10302
- init_cjs_shims();
10303
- function getLayerDescriptor({
10304
- mapConfig,
10305
- layer,
10306
- dataset
10307
- }) {
10308
- const { filters, visState } = mapConfig;
10309
- const { layerBlending, interactionConfig } = visState;
10310
- const { id, type, config: config2, visualChannels } = layer;
10311
- const { data, id: datasetId } = dataset;
10312
- const { propMap, defaultProps: defaultProps2 } = getLayerProps(type, config2, dataset);
10313
- const styleProps = createStyleProps(config2, propMap);
10314
- const { channelProps, scales } = createChannelProps(
10315
- id,
10316
- type,
10317
- config2,
10318
- visualChannels,
10319
- data,
10320
- dataset
10321
- );
10322
- const layerDescriptor = {
10323
- type,
10324
- filters: isEmptyObject(filters) || isRemoteCalculationSupported(dataset) ? void 0 : filters[datasetId],
10325
- props: {
10326
- id,
10327
- data,
10328
- ...defaultProps2,
10329
- ...createInteractionProps(interactionConfig),
10330
- ...styleProps,
10331
- ...channelProps,
10332
- ...createParametersProp(layerBlending, styleProps.parameters || {}),
10333
- // Must come after style
10334
- ...createLoadOptions(data.accessToken)
10335
- },
10336
- scales
10337
- };
10338
- return layerDescriptor;
10339
- }
10340
9680
  function parseMap(json) {
10341
9681
  const { keplerMapConfig, datasets, token } = json;
10342
9682
  assert2(keplerMapConfig.version === "v1", "Only support Kepler v1");
10343
- const mapConfig = keplerMapConfig.config;
10344
- const { mapState, mapStyle, popupSettings, legendSettings, visState } = mapConfig;
10345
- const { layers } = visState;
10346
- const layersReverse = [...layers].reverse();
9683
+ const config2 = keplerMapConfig.config;
9684
+ const { filters, mapState, mapStyle, popupSettings, legendSettings } = config2;
9685
+ const { layers, layerBlending, interactionConfig } = config2.visState;
10347
9686
  return {
10348
9687
  id: json.id,
10349
9688
  title: json.title,
@@ -10356,19 +9695,45 @@ function parseMap(json) {
10356
9695
  popupSettings,
10357
9696
  legendSettings,
10358
9697
  token,
10359
- layers: layersReverse.map((layer) => {
9698
+ layers: layers.reverse().map(({ id, type, config: config3, visualChannels }) => {
10360
9699
  try {
10361
- const { dataId } = layer.config;
9700
+ const { dataId } = config3;
10362
9701
  const dataset = datasets.find(
10363
9702
  (d) => d.id === dataId
10364
9703
  );
10365
9704
  assert2(dataset, `No dataset matching dataId: ${dataId}`);
10366
- const layerDescriptor = getLayerDescriptor({
10367
- mapConfig,
10368
- layer,
9705
+ const { data } = dataset;
9706
+ assert2(data, `No data loaded for dataId: ${dataId}`);
9707
+ const { propMap, defaultProps: defaultProps2 } = getLayerProps(type, config3, dataset);
9708
+ const styleProps = createStyleProps(config3, propMap);
9709
+ const { channelProps, scales } = createChannelProps(
9710
+ id,
9711
+ type,
9712
+ config3,
9713
+ visualChannels,
9714
+ data,
10369
9715
  dataset
10370
- });
10371
- return layerDescriptor;
9716
+ );
9717
+ const layer = {
9718
+ type,
9719
+ filters: isEmptyObject(filters) || isRemoteCalculationSupported(dataset) ? void 0 : filters[dataId],
9720
+ props: {
9721
+ id,
9722
+ data,
9723
+ ...defaultProps2,
9724
+ ...createInteractionProps(interactionConfig),
9725
+ ...styleProps,
9726
+ ...channelProps,
9727
+ ...createParametersProp(
9728
+ layerBlending,
9729
+ styleProps.parameters || {}
9730
+ ),
9731
+ // Must come after style
9732
+ ...createLoadOptions(token)
9733
+ },
9734
+ scales
9735
+ };
9736
+ return layer;
10372
9737
  } catch (e) {
10373
9738
  console.error(e.message);
10374
9739
  return void 0;
@@ -10433,63 +9798,43 @@ function createStyleProps(config2, mapping) {
10433
9798
  result.highlightColor = config2.visConfig.enable3d ? [255, 255, 255, 60] : [252, 242, 26, 255];
10434
9799
  return result;
10435
9800
  }
9801
+ function domainAndRangeFromScale(scale2) {
9802
+ return {
9803
+ domain: scale2.domain(),
9804
+ range: scale2.range()
9805
+ };
9806
+ }
10436
9807
  function createChannelProps(id, layerType, config2, visualChannels, data, dataset) {
10437
- if (layerType === "raster") {
10438
- const rasterMetadata = data.raster_metadata;
10439
- if (!rasterMetadata) {
10440
- return {
10441
- channelProps: {},
10442
- scales: {}
10443
- };
10444
- }
10445
- const rasterStyleType = config2.visConfig.rasterStyleType;
10446
- if (rasterStyleType === "Rgb") {
10447
- return {
10448
- channelProps: getRasterTileLayerStylePropsRgb({
10449
- layerConfig: config2,
10450
- rasterMetadata,
10451
- visualChannels
10452
- }),
10453
- scales: {}
10454
- // TODO
10455
- };
10456
- } else {
10457
- return {
10458
- channelProps: getRasterTileLayerStylePropsScaledBand({
10459
- layerConfig: config2,
10460
- visualChannels,
10461
- rasterMetadata
10462
- }),
10463
- scales: {
10464
- // TODO
10465
- }
10466
- };
10467
- }
10468
- }
9808
+ const {
9809
+ colorField,
9810
+ colorScale,
9811
+ radiusField,
9812
+ radiusScale,
9813
+ strokeColorField,
9814
+ strokeColorScale,
9815
+ weightField
9816
+ } = visualChannels;
9817
+ const { heightField, heightScale } = visualChannels;
10469
9818
  const { textLabel, visConfig } = config2;
10470
9819
  const result = {};
10471
- const updateTriggers = {};
10472
9820
  const scales = {};
10473
- {
10474
- const { colorField, colorScale } = visualChannels;
10475
- const { colorRange, colorAggregation } = visConfig;
10476
- if (colorField && colorScale && colorRange) {
10477
- const { accessor, ...scaleProps } = getColorAccessor(
10478
- colorField,
10479
- colorScale,
10480
- { aggregation: colorAggregation, range: colorRange },
10481
- visConfig.opacity,
10482
- data
10483
- );
10484
- result.getFillColor = accessor;
10485
- scales.fillColor = updateTriggers.getFillColor = {
10486
- field: colorField,
10487
- type: colorScale,
10488
- ...scaleProps
10489
- };
10490
- } else {
10491
- scales.fillColor = {};
10492
- }
9821
+ if (colorField) {
9822
+ const { colorAggregation: aggregation, colorRange: range } = visConfig;
9823
+ const { accessor, scale: scale2 } = getColorAccessor(
9824
+ colorField,
9825
+ colorScale,
9826
+ { aggregation, range },
9827
+ visConfig.opacity,
9828
+ data
9829
+ );
9830
+ result.getFillColor = accessor;
9831
+ scales.fillColor = {
9832
+ field: colorField,
9833
+ type: colorScale,
9834
+ ...domainAndRangeFromScale(scale2)
9835
+ };
9836
+ } else if (visConfig.filled) {
9837
+ scales.fillColor = {};
10493
9838
  }
10494
9839
  if (layerType === "clusterTile") {
10495
9840
  const aggregationExpAlias = getDefaultAggregationExpColumnAliasForLayerType(
@@ -10502,7 +9847,6 @@ function createChannelProps(id, layerType, config2, visualChannels, data, datase
10502
9847
  result.getWeight = (d) => {
10503
9848
  return d.properties[aggregationExpAlias];
10504
9849
  };
10505
- updateTriggers.getWeight = aggregationExpAlias;
10506
9850
  result.getPointRadius = (d, info) => {
10507
9851
  return calculateClusterRadius(
10508
9852
  d.properties,
@@ -10511,16 +9855,11 @@ function createChannelProps(id, layerType, config2, visualChannels, data, datase
10511
9855
  aggregationExpAlias
10512
9856
  );
10513
9857
  };
10514
- updateTriggers.getPointRadius = {
10515
- aggregationExpAlias,
10516
- radiusRange: visConfig.radiusRange
10517
- };
10518
9858
  result.textCharacterSet = "auto";
10519
9859
  result.textFontFamily = "Inter, sans";
10520
9860
  result.textFontSettings = { sdf: true };
10521
9861
  result.textFontWeight = 600;
10522
9862
  result.getText = (d) => TEXT_NUMBER_FORMATTER.format(d.properties[aggregationExpAlias]);
10523
- updateTriggers.getText = aggregationExpAlias;
10524
9863
  result.getTextColor = config2.textLabel[TEXT_LABEL_INDEX].color;
10525
9864
  result.textOutlineColor = [
10526
9865
  ...config2.textLabel[TEXT_LABEL_INDEX].outlineColor,
@@ -10537,107 +9876,68 @@ function createChannelProps(id, layerType, config2, visualChannels, data, datase
10537
9876
  );
10538
9877
  return calculateClusterTextFontSize(radius);
10539
9878
  };
10540
- updateTriggers.getTextSize = {
10541
- aggregationExpAlias,
10542
- radiusRange: visConfig.radiusRange
10543
- };
10544
- }
10545
- {
10546
- const radiusRange = visConfig.radiusRange;
10547
- const { radiusField, radiusScale } = visualChannels;
10548
- if (radiusField && radiusRange && radiusScale) {
10549
- const { accessor, ...scaleProps } = getSizeAccessor(
10550
- radiusField,
10551
- radiusScale,
10552
- visConfig.sizeAggregation,
10553
- radiusRange,
10554
- data
10555
- );
10556
- result.getPointRadius = accessor;
10557
- scales.pointRadius = updateTriggers.getPointRadius = {
10558
- field: radiusField,
10559
- type: radiusScale,
10560
- ...scaleProps
10561
- };
10562
- }
10563
9879
  }
10564
- {
10565
- const strokeColorRange = visConfig.strokeColorRange;
10566
- const { strokeColorScale, strokeColorField } = visualChannels;
10567
- if (strokeColorField && strokeColorRange && strokeColorScale) {
10568
- const { strokeColorAggregation: aggregation } = visConfig;
10569
- const opacity = visConfig.strokeOpacity !== void 0 ? visConfig.strokeOpacity : 1;
10570
- const { accessor, ...scaleProps } = getColorAccessor(
10571
- strokeColorField,
10572
- strokeColorScale,
10573
- { aggregation, range: strokeColorRange },
10574
- opacity,
10575
- data
10576
- );
10577
- result.getLineColor = accessor;
10578
- scales.lineColor = updateTriggers.getLineColor = {
10579
- field: strokeColorField,
10580
- type: strokeColorScale,
10581
- ...scaleProps
10582
- };
10583
- }
9880
+ if (radiusField) {
9881
+ const { accessor, scale: scale2 } = getSizeAccessor(
9882
+ radiusField,
9883
+ radiusScale,
9884
+ visConfig.sizeAggregation,
9885
+ visConfig.radiusRange || visConfig.sizeRange,
9886
+ data
9887
+ );
9888
+ result.getPointRadius = accessor;
9889
+ scales.pointRadius = {
9890
+ field: radiusField,
9891
+ type: radiusScale || "identity",
9892
+ ...domainAndRangeFromScale(scale2)
9893
+ };
10584
9894
  }
10585
- {
10586
- const { sizeField: strokeWidthField, sizeScale: strokeWidthScale } = visualChannels;
10587
- const { sizeRange, sizeAggregation } = visConfig;
10588
- if (strokeWidthField && sizeRange) {
10589
- const { accessor, ...scaleProps } = getSizeAccessor(
10590
- strokeWidthField,
10591
- strokeWidthScale,
10592
- sizeAggregation,
10593
- sizeRange,
10594
- data
10595
- );
10596
- result.getLineWidth = accessor;
10597
- scales.lineWidth = updateTriggers.getLineWidth = {
10598
- field: strokeWidthField,
10599
- type: strokeWidthScale || "identity",
10600
- ...scaleProps
10601
- };
10602
- }
9895
+ if (strokeColorField) {
9896
+ const opacity = visConfig.strokeOpacity !== void 0 ? visConfig.strokeOpacity : 1;
9897
+ const { strokeColorAggregation: aggregation, strokeColorRange: range } = visConfig;
9898
+ const { accessor, scale: scale2 } = getColorAccessor(
9899
+ strokeColorField,
9900
+ strokeColorScale,
9901
+ { aggregation, range },
9902
+ opacity,
9903
+ data
9904
+ );
9905
+ result.getLineColor = accessor;
9906
+ scales.lineColor = {
9907
+ field: strokeColorField,
9908
+ type: strokeColorScale,
9909
+ ...domainAndRangeFromScale(scale2)
9910
+ };
10603
9911
  }
10604
- {
10605
- const { enable3d, heightRange } = visConfig;
10606
- const { heightField, heightScale } = visualChannels;
10607
- if (heightField && heightRange && enable3d) {
10608
- const { accessor, ...scaleProps } = getSizeAccessor(
10609
- heightField,
10610
- heightScale,
10611
- visConfig.heightAggregation,
10612
- heightRange,
10613
- data
10614
- );
10615
- result.getElevation = accessor;
10616
- scales.elevation = updateTriggers.getElevation = {
10617
- field: heightField,
10618
- type: heightScale || "identity",
10619
- ...scaleProps
10620
- };
10621
- }
9912
+ if (heightField && visConfig.enable3d) {
9913
+ const { accessor, scale: scale2 } = getSizeAccessor(
9914
+ heightField,
9915
+ heightScale,
9916
+ visConfig.heightAggregation,
9917
+ visConfig.heightRange || visConfig.sizeRange,
9918
+ data
9919
+ );
9920
+ result.getElevation = accessor;
9921
+ scales.elevation = {
9922
+ field: heightField,
9923
+ type: heightScale || "identity",
9924
+ ...domainAndRangeFromScale(scale2)
9925
+ };
10622
9926
  }
10623
- {
10624
- const { weightField } = visualChannels;
10625
- const { weightAggregation } = visConfig;
10626
- if (weightField && weightAggregation) {
10627
- const { accessor, ...scaleProps } = getSizeAccessor(
10628
- weightField,
10629
- void 0,
10630
- weightAggregation,
10631
- void 0,
10632
- data
10633
- );
10634
- result.getWeight = accessor;
10635
- scales.weight = updateTriggers.getWeight = {
10636
- field: weightField,
10637
- type: "identity",
10638
- ...scaleProps
10639
- };
10640
- }
9927
+ if (weightField) {
9928
+ const { accessor, scale: scale2 } = getSizeAccessor(
9929
+ weightField,
9930
+ void 0,
9931
+ visConfig.weightAggregation,
9932
+ void 0,
9933
+ data
9934
+ );
9935
+ result.getWeight = accessor;
9936
+ scales.weight = {
9937
+ field: weightField,
9938
+ type: "identity",
9939
+ ...domainAndRangeFromScale(scale2)
9940
+ };
10641
9941
  }
10642
9942
  if (visConfig.customMarkers) {
10643
9943
  const maxIconSize = getMaxMarkerSize(visConfig, visualChannels);
@@ -10654,12 +9954,6 @@ function createChannelProps(id, layerType, config2, visualChannels, data, datase
10654
9954
  { fallbackUrl: customMarkersUrl, maxIconSize, useMaskedIcons },
10655
9955
  data
10656
9956
  );
10657
- updateTriggers.getIcon = {
10658
- customMarkersUrl,
10659
- customMarkersRange,
10660
- maxIconSize,
10661
- useMaskedIcons
10662
- };
10663
9957
  result._subLayerProps = {
10664
9958
  "points-icon": {
10665
9959
  loadOptions: {
@@ -10676,11 +9970,9 @@ function createChannelProps(id, layerType, config2, visualChannels, data, datase
10676
9970
  };
10677
9971
  if (getFillColor && useMaskedIcons) {
10678
9972
  result.getIconColor = getFillColor;
10679
- updateTriggers.getIconColor = updateTriggers.getFillColor;
10680
9973
  }
10681
9974
  if (getPointRadius) {
10682
9975
  result.getIconSize = getPointRadius;
10683
- updateTriggers.getIconSize = updateTriggers.getPointRadius;
10684
9976
  }
10685
9977
  if (visualChannels.rotationField) {
10686
9978
  const { accessor } = getSizeAccessor(
@@ -10691,7 +9983,6 @@ function createChannelProps(id, layerType, config2, visualChannels, data, datase
10691
9983
  data
10692
9984
  );
10693
9985
  result.getIconAngle = negateAccessor(accessor);
10694
- updateTriggers.getIconAngle = updateTriggers.getRotationField;
10695
9986
  }
10696
9987
  } else if (layerType === "tileset") {
10697
9988
  result.pointType = "circle";
@@ -10736,13 +10027,7 @@ function createChannelProps(id, layerType, config2, visualChannels, data, datase
10736
10027
  }
10737
10028
  };
10738
10029
  }
10739
- return {
10740
- channelProps: {
10741
- ...result,
10742
- updateTriggers
10743
- },
10744
- scales
10745
- };
10030
+ return { channelProps: result, scales };
10746
10031
  }
10747
10032
  function createLoadOptions(accessToken) {
10748
10033
  return {
@@ -11398,16 +10683,9 @@ function hashBuckets(initialCount) {
11398
10683
  WidgetSource,
11399
10684
  WidgetTableSource,
11400
10685
  WidgetTilesetSource,
11401
- _ErrorCode,
11402
- _applyLayerGroupFilters,
11403
10686
  _buildFeatureFilter,
11404
- _createVecExprEvaluator,
11405
10687
  _domainFromValues,
11406
- _evaluateVecExpr,
11407
10688
  _getHexagonResolution,
11408
- _getLog10ScaleSteps,
11409
- _getRasterTileLayerStyleProps,
11410
- _validateVecExprSyntax,
11411
10689
  addFilter,
11412
10690
  aggregate,
11413
10691
  aggregationFunctions,
@@ -11420,11 +10698,9 @@ function hashBuckets(initialCount) {
11420
10698
  buildStatsUrl,
11421
10699
  calculateClusterRadius,
11422
10700
  calculateClusterTextFontSize,
11423
- calculateLayerScale,
11424
10701
  clearDefaultRequestCache,
11425
10702
  clearFilters,
11426
10703
  configureSource,
11427
- createColorScale,
11428
10704
  createPolygonSpatialFilter,
11429
10705
  createViewportSpatialFilter,
11430
10706
  fetchBasemapProps,
@@ -11439,7 +10715,6 @@ function hashBuckets(initialCount) {
11439
10715
  getDefaultAggregationExpColumnAliasForLayerType,
11440
10716
  getFilter,
11441
10717
  getIconUrlAccessor,
11442
- getLayerDescriptor,
11443
10718
  getLayerProps,
11444
10719
  getMaxMarkerSize,
11445
10720
  getSizeAccessor,
@@ -11470,6 +10745,8 @@ function hashBuckets(initialCount) {
11470
10745
  tileFeatures,
11471
10746
  tileFeaturesGeometries,
11472
10747
  tileFeaturesSpatialIndex,
10748
+ trajectoryQuerySource,
10749
+ trajectoryTableSource,
11473
10750
  transformToTileCoords,
11474
10751
  vectorQuerySource,
11475
10752
  vectorTableSource,