@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.
@@ -8177,6 +8177,102 @@ var vectorTilesetSource = async function(options) {
8177
8177
  );
8178
8178
  };
8179
8179
 
8180
+ // src/sources/trajectory-query-source.ts
8181
+ var trajectoryQuerySource = async function(options) {
8182
+ const {
8183
+ columns,
8184
+ spatialDataColumn = DEFAULT_GEO_COLUMN,
8185
+ sqlQuery,
8186
+ tileResolution = DEFAULT_TILE_RESOLUTION,
8187
+ queryParameters,
8188
+ aggregationExp,
8189
+ trajectoryIdColumn,
8190
+ timestampColumn
8191
+ } = options;
8192
+ const spatialDataType = "trajectory";
8193
+ const urlParameters = {
8194
+ spatialDataColumn,
8195
+ spatialDataType,
8196
+ tileResolution: tileResolution.toString(),
8197
+ q: sqlQuery,
8198
+ trajectoryIdColumn,
8199
+ timestampColumn
8200
+ };
8201
+ if (columns) {
8202
+ urlParameters.columns = columns.join(",");
8203
+ }
8204
+ if (queryParameters) {
8205
+ urlParameters.queryParameters = queryParameters;
8206
+ }
8207
+ if (aggregationExp) {
8208
+ urlParameters.aggregationExp = aggregationExp;
8209
+ }
8210
+ const result = await baseSource(
8211
+ "query",
8212
+ options,
8213
+ urlParameters
8214
+ );
8215
+ const widgetSource = new WidgetQuerySource({
8216
+ ...options,
8217
+ // NOTE: Parameters with default values above must be explicitly passed here.
8218
+ spatialDataColumn,
8219
+ spatialDataType,
8220
+ tileResolution
8221
+ });
8222
+ const timestampRange = await widgetSource.getRange({ column: timestampColumn });
8223
+ return {
8224
+ ...result,
8225
+ widgetSource,
8226
+ timestampRange
8227
+ };
8228
+ };
8229
+
8230
+ // src/sources/trajectory-table-source.ts
8231
+ var trajectoryTableSource = async function(options) {
8232
+ const {
8233
+ columns,
8234
+ spatialDataColumn = DEFAULT_GEO_COLUMN,
8235
+ tableName,
8236
+ tileResolution = DEFAULT_TILE_RESOLUTION,
8237
+ aggregationExp,
8238
+ trajectoryIdColumn,
8239
+ timestampColumn
8240
+ } = options;
8241
+ const spatialDataType = "trajectory";
8242
+ const urlParameters = {
8243
+ name: tableName,
8244
+ spatialDataColumn,
8245
+ spatialDataType,
8246
+ tileResolution: tileResolution.toString(),
8247
+ trajectoryIdColumn,
8248
+ timestampColumn
8249
+ };
8250
+ if (columns) {
8251
+ urlParameters.columns = columns.join(",");
8252
+ }
8253
+ if (aggregationExp) {
8254
+ urlParameters.aggregationExp = aggregationExp;
8255
+ }
8256
+ const result = await baseSource(
8257
+ "table",
8258
+ options,
8259
+ urlParameters
8260
+ );
8261
+ const widgetSource = new WidgetTableSource({
8262
+ ...options,
8263
+ // NOTE: Parameters with default values above must be explicitly passed here.
8264
+ spatialDataColumn,
8265
+ spatialDataType,
8266
+ tileResolution
8267
+ });
8268
+ const timestampRange = await widgetSource.getRange({ column: timestampColumn });
8269
+ return {
8270
+ ...result,
8271
+ widgetSource,
8272
+ timestampRange
8273
+ };
8274
+ };
8275
+
8180
8276
  // src/api/query.ts
8181
8277
  var query = async function(options) {
8182
8278
  const {
@@ -8335,250 +8431,6 @@ var basemap_styles_default = {
8335
8431
  DARK_MATTER_NOLABELS: getStyleUrl("dark-matter-nolabels")
8336
8432
  };
8337
8433
 
8338
- // src/fetch-map/vec-expr-evaluator.ts
8339
- import jsep from "jsep";
8340
- function createVecExprEvaluator(expression) {
8341
- try {
8342
- const parsed = compile(expression);
8343
- const evalFun = (context) => evaluate(parsed, context);
8344
- evalFun.symbols = getSymbols(parsed);
8345
- return evalFun;
8346
- } catch {
8347
- return null;
8348
- }
8349
- }
8350
- function evaluateVecExpr(expression, context) {
8351
- try {
8352
- return createVecExprEvaluator(expression)?.(context);
8353
- } catch {
8354
- return null;
8355
- }
8356
- }
8357
- var ErrorCode = /* @__PURE__ */ ((ErrorCode2) => {
8358
- ErrorCode2[ErrorCode2["InvalidSyntax"] = 0] = "InvalidSyntax";
8359
- ErrorCode2[ErrorCode2["UnknownIdentifier"] = 1] = "UnknownIdentifier";
8360
- return ErrorCode2;
8361
- })(ErrorCode || {});
8362
- function validateVecExprSyntax(expression, context) {
8363
- let parsed;
8364
- try {
8365
- parsed = compile(expression);
8366
- } catch (e) {
8367
- return {
8368
- valid: false,
8369
- errorCode: 0 /* InvalidSyntax */,
8370
- errorMessage: e && "message" in e ? String(e.message) : String(e)
8371
- };
8372
- }
8373
- return validate(parsed, context);
8374
- }
8375
- function createResultArray(typeTemplate, length2 = typeTemplate.length) {
8376
- return new Array(length2);
8377
- }
8378
- function isVecLike(a) {
8379
- return Array.isArray(a) || ArrayBuffer.isView(a);
8380
- }
8381
- var createBinopVec = (scalarBinOp) => (left, right) => {
8382
- const length2 = Math.min(left.length, right.length);
8383
- const r = createResultArray(left, length2);
8384
- for (let i = 0; i < length2; i++) {
8385
- r[i] = scalarBinOp(left[i], right[i]);
8386
- }
8387
- return r;
8388
- };
8389
- var createBinopVecNum = (scalarBinOp) => (left, right) => {
8390
- const length2 = left.length;
8391
- const r = createResultArray(left, length2);
8392
- for (let i = 0; i < length2; i++) {
8393
- r[i] = scalarBinOp(left[i], right);
8394
- }
8395
- return r;
8396
- };
8397
- var createBinopNumVec = (scalarBinOp) => (left, right) => {
8398
- const length2 = right.length;
8399
- const r = createResultArray(right, length2);
8400
- for (let i = 0; i < length2; i++) {
8401
- r[i] = scalarBinOp(left, right[i]);
8402
- }
8403
- return r;
8404
- };
8405
- var createUnopVec = (scalarUnop) => (a) => {
8406
- const length2 = a.length;
8407
- const r = createResultArray(a, length2);
8408
- for (let i = 0; i < length2; i++) {
8409
- r[i] = scalarUnop(a[i]);
8410
- }
8411
- return r;
8412
- };
8413
- function mapDictValues(dict, fun) {
8414
- return Object.keys(dict).reduce(
8415
- (acc, key) => {
8416
- acc[key] = fun(dict[key]);
8417
- return acc;
8418
- },
8419
- {}
8420
- );
8421
- }
8422
- var binopsNum = {
8423
- "||": (a, b) => a || b,
8424
- "&&": (a, b) => a && b,
8425
- "|": (a, b) => a | b,
8426
- "^": (a, b) => a ^ b,
8427
- "&": (a, b) => a & b,
8428
- "==": (a, b) => Number(a == b),
8429
- "!=": (a, b) => Number(a != b),
8430
- "===": (a, b) => Number(a === b),
8431
- "!==": (a, b) => Number(a !== b),
8432
- "<": (a, b) => Number(a < b),
8433
- ">": (a, b) => Number(a > b),
8434
- "<=": (a, b) => Number(a <= b),
8435
- ">=": (a, b) => Number(a >= b),
8436
- "<<": (a, b) => a << b,
8437
- ">>": (a, b) => a >> b,
8438
- ">>>": (a, b) => a >>> b,
8439
- "+": (a, b) => a + b,
8440
- "-": (a, b) => a - b,
8441
- "*": (a, b) => a * b,
8442
- "/": (a, b) => a / b,
8443
- "%": (a, b) => a % b
8444
- };
8445
- var unopsNum = {
8446
- "-": (a) => -a,
8447
- "+": (a) => +a,
8448
- "~": (a) => ~a,
8449
- "!": (a) => Number(!a)
8450
- };
8451
- var binopsVector = mapDictValues(binopsNum, createBinopVec);
8452
- var binopsNumVec = mapDictValues(binopsNum, createBinopNumVec);
8453
- var binopsVecNum = mapDictValues(binopsNum, createBinopVecNum);
8454
- var unopsVector = mapDictValues(unopsNum, createUnopVec);
8455
- function getBinop(operator, left, right) {
8456
- const isLeftVec = isVecLike(left);
8457
- const isRightVec = isVecLike(right);
8458
- if (isLeftVec && isRightVec) {
8459
- return binopsVector[operator];
8460
- } else if (isLeftVec) {
8461
- return binopsVecNum[operator];
8462
- } else if (isRightVec) {
8463
- return binopsNumVec[operator];
8464
- } else {
8465
- return binopsNum[operator];
8466
- }
8467
- }
8468
- function evaluate(_node, context) {
8469
- const node = _node;
8470
- switch (node.type) {
8471
- case "BinaryExpression": {
8472
- const left = evaluate(node.left, context);
8473
- const right = evaluate(node.right, context);
8474
- const binopFun = getBinop(node.operator, left, right);
8475
- return binopFun(left, right);
8476
- }
8477
- case "ConditionalExpression": {
8478
- const val = evaluate(node.test, context);
8479
- if (isVecLike(val)) {
8480
- const length2 = val.length;
8481
- const consequentVal = evaluate(node.consequent, context);
8482
- const alternateVal = evaluate(node.alternate, context);
8483
- const r = createResultArray(val);
8484
- for (let i = 0; i < length2; i++) {
8485
- const entryVal = val[i] ? consequentVal : alternateVal;
8486
- r[i] = isVecLike(entryVal) ? entryVal[i] ?? NaN : entryVal;
8487
- }
8488
- return r;
8489
- } else {
8490
- return val ? evaluate(node.consequent, context) : evaluate(node.alternate, context);
8491
- }
8492
- }
8493
- case "Identifier":
8494
- return context[node.name];
8495
- case "Literal":
8496
- return node.value;
8497
- case "UnaryExpression": {
8498
- const val = evaluate(node.argument, context);
8499
- const unopFun = isVecLike(val) ? unopsVector[node.operator] : unopsNum[node.operator];
8500
- return unopFun(val);
8501
- }
8502
- default:
8503
- return void 0;
8504
- }
8505
- }
8506
- var validResult = { valid: true };
8507
- function visit(_node, visitor) {
8508
- const node = _node;
8509
- visitor(node);
8510
- switch (node.type) {
8511
- case "BinaryExpression": {
8512
- visit(node.left, visitor);
8513
- visit(node.right, visitor);
8514
- break;
8515
- }
8516
- case "ConditionalExpression": {
8517
- visit(node.test, visitor);
8518
- visit(node.consequent, visitor);
8519
- visit(node.alternate, visitor);
8520
- break;
8521
- }
8522
- case "UnaryExpression": {
8523
- visit(node.argument, visitor);
8524
- break;
8525
- }
8526
- }
8527
- }
8528
- var supportedExpressionTypes = [
8529
- "BinaryExpression",
8530
- "UnaryExpression",
8531
- "ConditionalExpression",
8532
- "LogicalExpression",
8533
- "Identifier",
8534
- "Literal"
8535
- ];
8536
- function validate(_node, context) {
8537
- const node = _node;
8538
- const errors = [];
8539
- visit(node, (node2) => {
8540
- if (!supportedExpressionTypes.includes(node2.type)) {
8541
- errors.push({
8542
- valid: false,
8543
- errorCode: 0 /* InvalidSyntax */,
8544
- errorMessage: `Not allowed`
8545
- });
8546
- return;
8547
- }
8548
- if (node2.type === "Identifier") {
8549
- if (!Object.prototype.hasOwnProperty.call(context, node2.name)) {
8550
- return errors.push({
8551
- valid: false,
8552
- errorCode: 1 /* UnknownIdentifier */,
8553
- errorMessage: `"${node2.name}" not found`
8554
- });
8555
- }
8556
- }
8557
- if (node2.type === "Literal") {
8558
- if (typeof node2.value !== "number") {
8559
- return errors.push({
8560
- valid: false,
8561
- errorCode: 0 /* InvalidSyntax */,
8562
- errorMessage: `Only number literals are supported`
8563
- });
8564
- }
8565
- }
8566
- });
8567
- return errors.length ? errors[0] : validResult;
8568
- }
8569
- function getSymbols(node) {
8570
- const symbols = /* @__PURE__ */ new Set();
8571
- visit(node, (node2) => {
8572
- if (node2.type === "Identifier") {
8573
- symbols.add(node2.name);
8574
- }
8575
- });
8576
- return Array.from(symbols);
8577
- }
8578
- function compile(expression) {
8579
- return jsep(expression);
8580
- }
8581
-
8582
8434
  // node_modules/d3-array/src/ascending.js
8583
8435
  function ascending(a, b) {
8584
8436
  return a == null || b == null ? NaN : a < b ? -1 : a > b ? 1 : a >= b ? 0 : NaN;
@@ -9157,37 +9009,6 @@ function formatDate(value) {
9157
9009
  function formatTimestamp(value) {
9158
9010
  return String(Math.floor(new Date(value).getTime() / 1e3));
9159
9011
  }
9160
- function roundedPow10(exp) {
9161
- const raw = Math.pow(10, exp);
9162
- if (exp < 0) {
9163
- const shift = Math.pow(10, -exp);
9164
- return Math.round(raw * shift) / shift;
9165
- }
9166
- return raw;
9167
- }
9168
- function getLog10ScaleSteps({
9169
- min: min2,
9170
- max: max2,
9171
- steps
9172
- }) {
9173
- if (min2 === 0) {
9174
- if (max2 === Infinity) {
9175
- return [...Array(steps - 1)].map((_v, i) => roundedPow10(i + 1));
9176
- }
9177
- const maxLog = Math.log10(max2);
9178
- const endExponent = Math.ceil(maxLog);
9179
- const startExponent = endExponent - steps + 1;
9180
- return [...Array(steps - 1)].map(
9181
- (_v, i) => roundedPow10(startExponent + i)
9182
- );
9183
- } else {
9184
- const minLog = Math.log10(min2);
9185
- const startExponent = Math.ceil(minLog) === minLog ? minLog + 1 : Math.ceil(minLog);
9186
- return [...Array(steps - 1)].map(
9187
- (_v, i) => roundedPow10(startExponent + i)
9188
- );
9189
- }
9190
- }
9191
9012
 
9192
9013
  // src/fetch-map/layer-map.ts
9193
9014
  var SCALE_FUNCS = {
@@ -9204,19 +9025,7 @@ var SCALE_FUNCS = {
9204
9025
  function identity2(v2) {
9205
9026
  return v2;
9206
9027
  }
9207
- var hexToRGB = (c) => {
9208
- const { r, g, b } = rgb(c);
9209
- return [r, g, b];
9210
- };
9211
- var rgbToHex = (c) => {
9212
- const [r, g, b] = c;
9213
- const rStr = r.toString(16).padStart(2, "0");
9214
- const gStr = g.toString(16).padStart(2, "0");
9215
- const bStr = b.toString(16).padStart(2, "0");
9216
- return `#${rStr}${gStr}${bStr}`.toUpperCase();
9217
- };
9218
9028
  var UNKNOWN_COLOR = "#868d91";
9219
- var UNKNOWN_COLOR_RGB = hexToRGB(UNKNOWN_COLOR);
9220
9029
  var OPACITY_MAP = {
9221
9030
  getFillColor: "opacity",
9222
9031
  getLineColor: "strokeOpacity",
@@ -9249,12 +9058,6 @@ var sharedPropMap = {
9249
9058
  wireframe: "wireframe"
9250
9059
  }
9251
9060
  };
9252
- var rasterPropsMap = {
9253
- isVisible: "visible",
9254
- visConfig: {
9255
- opacity: "opacity"
9256
- }
9257
- };
9258
9061
  var customMarkersPropsMap = {
9259
9062
  color: "getIconColor",
9260
9063
  visConfig: {
@@ -9298,12 +9101,6 @@ function getLayerProps(type, config2, dataset) {
9298
9101
  `Outdated layer type: ${type}. Please open map in CARTO Builder to automatically migrate.`
9299
9102
  );
9300
9103
  }
9301
- if (type === "raster") {
9302
- return {
9303
- propMap: rasterPropsMap,
9304
- defaultProps: {}
9305
- };
9306
- }
9307
9104
  let basePropMap = sharedPropMap;
9308
9105
  if (config2.visConfig?.customMarkers) {
9309
9106
  basePropMap = mergePropMaps(basePropMap, customMarkersPropsMap);
@@ -9324,19 +9121,16 @@ function getLayerProps(type, config2, dataset) {
9324
9121
  }
9325
9122
  function domainFromAttribute(attribute, scaleType, scaleLength) {
9326
9123
  if (scaleType === "ordinal" || scaleType === "point") {
9327
- if (!attribute.categories) {
9328
- return [0, 1];
9329
- }
9330
9124
  return attribute.categories.map((c) => c.category).filter((c) => c !== void 0 && c !== null);
9331
9125
  }
9332
9126
  if (scaleType === "quantile" && attribute.quantiles) {
9333
- return "global" in attribute.quantiles ? attribute.quantiles.global[scaleLength] : attribute.quantiles[scaleLength];
9127
+ return attribute.quantiles.global ? attribute.quantiles.global[scaleLength] : attribute.quantiles[scaleLength];
9334
9128
  }
9335
9129
  let { min: min2 } = attribute;
9336
9130
  if (scaleType === "log" && min2 === 0) {
9337
9131
  min2 = 1e-5;
9338
9132
  }
9339
- return [min2 ?? 0, attribute.max ?? 1];
9133
+ return [min2, attribute.max];
9340
9134
  }
9341
9135
  function domainFromValues(values, scaleType) {
9342
9136
  if (scaleType === "ordinal" || scaleType === "point") {
@@ -9357,14 +9151,12 @@ function calculateDomain(data, name, scaleType, scaleLength) {
9357
9151
  if (data.tilestats) {
9358
9152
  const { attributes } = data.tilestats.layers[0];
9359
9153
  const attribute = attributes.find((a) => a.attribute === name);
9360
- if (attribute) {
9361
- return domainFromAttribute(attribute, scaleType, scaleLength);
9362
- }
9154
+ return domainFromAttribute(attribute, scaleType, scaleLength);
9363
9155
  }
9364
9156
  return [0, 1];
9365
9157
  }
9366
9158
  function normalizeAccessor(accessor, data) {
9367
- if (data.features || data.tilestats || data.raster_metadata) {
9159
+ if (data.features || data.tilestats) {
9368
9160
  return (object, info) => {
9369
9161
  if (object) {
9370
9162
  return accessor(object.properties || object.__source.object.properties);
@@ -9397,75 +9189,46 @@ function findAccessorKey(keys, properties) {
9397
9189
  return keys;
9398
9190
  }
9399
9191
  function getColorAccessor({ name, colorColumn }, scaleType, { aggregation, range }, opacity, data) {
9400
- const { scale: scale2, domain } = calculateLayerScale(
9192
+ const scale2 = calculateLayerScale(
9401
9193
  colorColumn || name,
9402
- colorColumn ? "identity" : scaleType,
9194
+ scaleType,
9403
9195
  range,
9404
9196
  data
9405
9197
  );
9406
9198
  const alpha = opacityToAlpha(opacity);
9407
- let accessorKeys = getAccessorKeys(colorColumn || name, aggregation);
9199
+ let accessorKeys = getAccessorKeys(name, aggregation);
9408
9200
  const accessor = (properties) => {
9409
9201
  if (!(accessorKeys[0] in properties)) {
9410
9202
  accessorKeys = findAccessorKey(accessorKeys, properties);
9411
9203
  }
9412
9204
  const propertyValue = properties[accessorKeys[0]];
9413
- const scaled = scale2(propertyValue);
9414
- const rgb2 = typeof scaled === "string" ? hexToRGB(scaled) : scaled;
9415
- return [...rgb2, propertyValue === null ? 0 : alpha];
9416
- };
9417
- return {
9418
- accessor: normalizeAccessor(accessor, data),
9419
- scaleDomain: scale2.domain(),
9420
- domain,
9421
- range: (scale2.range() || []).map(rgbToHex)
9205
+ const { r, g, b } = rgb(scale2(propertyValue));
9206
+ return [r, g, b, propertyValue === null ? 0 : alpha];
9422
9207
  };
9208
+ return { accessor: normalizeAccessor(accessor, data), scale: scale2 };
9423
9209
  }
9424
9210
  function calculateLayerScale(name, scaleType, range, data) {
9211
+ const scale2 = SCALE_FUNCS[scaleType]();
9425
9212
  let domain = [];
9426
- let scaleDomain;
9427
9213
  let scaleColor = [];
9428
- const { colors } = range;
9429
- if (scaleType === "custom") {
9430
- domain = calculateDomain(data, name, scaleType, colors.length);
9431
- const [min2, max2] = domain;
9432
- if (range.uiCustomScaleType === "logarithmic") {
9433
- scaleDomain = getLog10ScaleSteps({
9434
- min: min2,
9435
- max: max2,
9436
- steps: colors.length
9437
- });
9438
- scaleColor = colors;
9439
- } else if (range.colorMap) {
9440
- const { colorMap } = range;
9441
- scaleDomain = [];
9214
+ if (scaleType !== "identity") {
9215
+ const { colorMap, colors } = range;
9216
+ if (Array.isArray(colorMap)) {
9442
9217
  colorMap.forEach(([value, color2]) => {
9443
- scaleDomain.push(Number(value));
9218
+ domain.push(value);
9444
9219
  scaleColor.push(color2);
9445
9220
  });
9221
+ } else {
9222
+ domain = calculateDomain(data, name, scaleType, colors.length);
9223
+ scaleColor = colors;
9446
9224
  }
9447
- } else if (scaleType !== "identity") {
9448
- domain = calculateDomain(data, name, scaleType, colors.length);
9449
- scaleColor = colors;
9450
9225
  if (scaleType === "ordinal") {
9451
9226
  domain = domain.slice(0, scaleColor.length);
9452
9227
  }
9453
9228
  }
9454
- return {
9455
- scale: createColorScale(
9456
- scaleType,
9457
- scaleDomain || domain,
9458
- scaleColor.map(hexToRGB),
9459
- UNKNOWN_COLOR_RGB
9460
- ),
9461
- domain
9462
- };
9463
- }
9464
- function createColorScale(scaleType, domain, range, unknown) {
9465
- const scale2 = SCALE_FUNCS[scaleType]();
9466
9229
  scale2.domain(domain);
9467
- scale2.range(range);
9468
- scale2.unknown(unknown);
9230
+ scale2.range(scaleColor);
9231
+ scale2.unknown(UNKNOWN_COLOR);
9469
9232
  return scale2;
9470
9233
  }
9471
9234
  var FALLBACK_ICON = "data:image/svg+xml;charset=utf-8;base64,PHN2ZyB2aWV3Qm94PSIwIDAgMTAwIDEwMCIgeG1sbnM9Imh0dHA6Ly93d3cudzMub3JnLzIwMDAvc3ZnIj4NCiAgPGNpcmNsZSBjeD0iNTAiIGN5PSI1MCIgcj0iNTAiLz4NCjwvc3ZnPg==";
@@ -9515,13 +9278,9 @@ function negateAccessor(accessor) {
9515
9278
  }
9516
9279
  function getSizeAccessor({ name }, scaleType, aggregation, range, data) {
9517
9280
  const scale2 = scaleType ? SCALE_FUNCS[scaleType]() : identity2;
9518
- let domain = [];
9519
- if (scaleType && range) {
9281
+ if (scaleType) {
9520
9282
  if (aggregation !== AggregationTypes.Count) {
9521
- domain = calculateDomain(data, name, scaleType);
9522
- scale2.domain(domain);
9523
- } else {
9524
- domain = scale2.domain();
9283
+ scale2.domain(calculateDomain(data, name, scaleType));
9525
9284
  }
9526
9285
  scale2.range(range);
9527
9286
  }
@@ -9533,12 +9292,7 @@ function getSizeAccessor({ name }, scaleType, aggregation, range, data) {
9533
9292
  const propertyValue = properties[accessorKeys[0]];
9534
9293
  return scale2(propertyValue);
9535
9294
  };
9536
- return {
9537
- accessor: normalizeAccessor(accessor, data),
9538
- domain,
9539
- scaleDomain: domain,
9540
- range
9541
- };
9295
+ return { accessor: normalizeAccessor(accessor, data), scale: scale2 };
9542
9296
  }
9543
9297
  var FORMATS = {
9544
9298
  date: formatDate,
@@ -9589,420 +9343,13 @@ function calculateClusterTextFontSize(radius) {
9589
9343
  return 11;
9590
9344
  }
9591
9345
 
9592
- // src/fetch-map/raster-layer.ts
9593
- var UNKNOWN_COLOR2 = [134, 141, 145];
9594
- var RASTER_COLOR_BANDS = ["red", "green", "blue"];
9595
- function getHasDataPredicate(noData) {
9596
- if (noData === "nan") {
9597
- return (v2) => !isNaN(v2);
9598
- }
9599
- if (typeof noData === "string") {
9600
- noData = parseFloat(noData);
9601
- }
9602
- if (typeof noData === "number") {
9603
- return (v2) => v2 !== noData && !isNaN(v2);
9604
- }
9605
- return () => true;
9606
- }
9607
- function createRasterColumnLayerDataTransform(transform) {
9608
- return (data) => {
9609
- if (!data || !("data" in data) || !data?.data?.cells?.numericProps) {
9610
- return data;
9611
- }
9612
- return transform(data);
9613
- };
9614
- }
9615
- function createEvaluationContext(numericProps, noData) {
9616
- const hasData = getHasDataPredicate(noData);
9617
- const bands = Object.entries(numericProps).map(([bandName, { value }]) => ({
9618
- bandName,
9619
- values: value,
9620
- copied: false
9621
- }));
9622
- const length2 = bands[0].values.length;
9623
- for (let i = 0; i < length2; i++) {
9624
- let hasSomeData = false;
9625
- for (let j = 0; j < bands.length; j++) {
9626
- hasSomeData = hasSomeData || hasData(bands[j].values[i]);
9627
- }
9628
- if (!hasSomeData) {
9629
- for (let j = 0; j < bands.length; j++) {
9630
- if (!bands[j].copied) {
9631
- bands[j].copied = true;
9632
- bands[j].values = Array.from(bands[j].values);
9633
- }
9634
- bands[j].values[i] = NaN;
9635
- }
9636
- }
9637
- }
9638
- const context = bands.reduce(
9639
- (agg, { bandName, values }) => {
9640
- agg[bandName] = values;
9641
- return agg;
9642
- },
9643
- {}
9644
- );
9645
- return context;
9646
- }
9647
- function createExprDataTransform({
9648
- colorBand,
9649
- rasterMetadata,
9650
- usedSymbols
9651
- }) {
9652
- if (!colorBand || !colorBand.type || colorBand.type === "none") {
9653
- return void 0;
9654
- }
9655
- const expr = colorBand?.type === "expression" ? colorBand.value : void 0;
9656
- const vecExprEvaluator = expr ? createVecExprEvaluator(expr) : void 0;
9657
- const dataTransform = createRasterColumnLayerDataTransform(
9658
- (dataWrapped) => {
9659
- const data = dataWrapped.data;
9660
- if (expr) {
9661
- const cachedResult = dataWrapped.customExpressionResults?.[expr];
9662
- if (cachedResult) {
9663
- return dataWrapped;
9664
- }
9665
- }
9666
- let context = dataWrapped.expressionEvalContext;
9667
- if (!context) {
9668
- const usedNumericProps = usedSymbols.reduce(
9669
- (acc, symbol) => {
9670
- acc[symbol] = data.cells.numericProps[symbol];
9671
- return acc;
9672
- },
9673
- {}
9674
- );
9675
- context = createEvaluationContext(
9676
- usedNumericProps,
9677
- rasterMetadata.nodata
9678
- );
9679
- dataWrapped = {
9680
- ...dataWrapped,
9681
- expressionEvalContext: context
9682
- };
9683
- }
9684
- if (!vecExprEvaluator || !expr) return dataWrapped;
9685
- const evalResult = vecExprEvaluator(context);
9686
- return {
9687
- ...dataWrapped,
9688
- customExpressionResults: {
9689
- ...dataWrapped.customExpressionResults,
9690
- [expr]: evalResult
9691
- }
9692
- };
9693
- }
9694
- );
9695
- return dataTransform;
9696
- }
9697
- function combineDataTransforms(dataTransforms) {
9698
- const actualTransforms = dataTransforms.filter((v2) => v2);
9699
- if (actualTransforms.length === 0) return void 0;
9700
- if (actualTransforms.length === 1) return actualTransforms[0];
9701
- return (data) => actualTransforms.reduce(
9702
- (aggData, transformFun) => transformFun(aggData),
9703
- data
9704
- );
9705
- }
9706
- function createRgbToColorBufferDataTransform({
9707
- bandDefs,
9708
- attribute
9709
- }) {
9710
- return createRasterColumnLayerDataTransform(
9711
- (dataWrapped) => {
9712
- const length2 = dataWrapped.length;
9713
- const getBandBufferOrValue = (colorBand) => {
9714
- if (colorBand?.type === "expression") {
9715
- return dataWrapped.customExpressionResults?.[colorBand.value];
9716
- }
9717
- if (colorBand?.type === "band") {
9718
- return dataWrapped.expressionEvalContext?.[colorBand.value];
9719
- }
9720
- return 0;
9721
- };
9722
- const red = getBandBufferOrValue(bandDefs.red);
9723
- const green = getBandBufferOrValue(bandDefs.green);
9724
- const blue = getBandBufferOrValue(bandDefs.blue);
9725
- const colorBuffer = new Uint8Array(length2 * 4);
9726
- for (let inputIndex = 0, outputIndex = 0; inputIndex < length2; inputIndex++, outputIndex += 4) {
9727
- const redRaw = typeof red === "number" ? red : red ? red[inputIndex] : NaN;
9728
- const greenRaw = typeof green === "number" ? green : green ? green[inputIndex] : NaN;
9729
- const blueRaw = typeof blue === "number" ? blue : blue ? blue[inputIndex] : NaN;
9730
- if (isNaN(redRaw) && isNaN(greenRaw) && isNaN(blueRaw)) {
9731
- bufferSetRgba(colorBuffer, outputIndex, 0, 0, 0, 0);
9732
- } else {
9733
- bufferSetRgba(
9734
- colorBuffer,
9735
- outputIndex,
9736
- redRaw,
9737
- greenRaw,
9738
- blueRaw,
9739
- 255
9740
- );
9741
- }
9742
- }
9743
- dataWrapped.customExpressionResults = void 0;
9744
- dataWrapped.expressionEvalContext = void 0;
9745
- return {
9746
- ...dataWrapped,
9747
- attributes: {
9748
- [attribute]: colorBuffer
9749
- }
9750
- };
9751
- }
9752
- );
9753
- }
9754
- function getUsedSymbols(colorBands) {
9755
- return Array.from(
9756
- colorBands.reduce((symbols, band) => {
9757
- if (band.type === "expression") {
9758
- const expressionSymbols = createVecExprEvaluator(band.value)?.symbols || [];
9759
- expressionSymbols.forEach((symbol) => symbols.add(symbol));
9760
- }
9761
- if (band.type === "band") {
9762
- symbols.add(band.value);
9763
- }
9764
- return symbols;
9765
- }, /* @__PURE__ */ new Set())
9766
- );
9767
- }
9768
- function getRasterTileLayerStylePropsRgb({
9769
- layerConfig,
9770
- rasterMetadata,
9771
- visualChannels
9772
- }) {
9773
- const { visConfig } = layerConfig;
9774
- const { colorBands } = visConfig;
9775
- const bandDefs = {
9776
- red: colorBands?.find((band) => band.band === "red"),
9777
- green: colorBands?.find((band) => band.band === "green"),
9778
- blue: colorBands?.find((band) => band.band === "blue")
9779
- };
9780
- const rgbToInstanceFillColorsDataTransform = createRgbToColorBufferDataTransform({
9781
- bandDefs,
9782
- attribute: "instanceFillColors"
9783
- });
9784
- const usedSymbols = colorBands ? getUsedSymbols(colorBands) : [];
9785
- const bandTransforms = RASTER_COLOR_BANDS.map(
9786
- (band) => createExprDataTransform({
9787
- colorBand: bandDefs[band],
9788
- rasterMetadata,
9789
- usedSymbols
9790
- })
9791
- );
9792
- const combinedDataTransform = combineDataTransforms([
9793
- ...bandTransforms,
9794
- rgbToInstanceFillColorsDataTransform
9795
- ]);
9796
- return {
9797
- dataTransform: combinedDataTransform,
9798
- updateTriggers: getRasterTileLayerUpdateTriggers({
9799
- layerConfig,
9800
- visualChannels
9801
- })
9802
- };
9803
- }
9804
- function createBandColorScaleDataTransform({
9805
- bandName,
9806
- scaleFun,
9807
- nodata,
9808
- attribute
9809
- }) {
9810
- const hasData = getHasDataPredicate(nodata);
9811
- return createRasterColumnLayerDataTransform(
9812
- (dataWrapped) => {
9813
- const length2 = dataWrapped.length;
9814
- const bandBuffer = dataWrapped.data.cells.numericProps[bandName].value;
9815
- const colorBuffer = new Uint8Array(length2 * 4);
9816
- for (let i = 0; i < length2; i++) {
9817
- const rawValue = bandBuffer[i];
9818
- if (!hasData(rawValue)) {
9819
- bufferSetRgba(colorBuffer, i * 4, 0, 0, 0, 0);
9820
- } else {
9821
- const colorRgb = scaleFun(rawValue);
9822
- bufferSetRgba(
9823
- colorBuffer,
9824
- i * 4,
9825
- colorRgb[0],
9826
- colorRgb[1],
9827
- colorRgb[2],
9828
- 255
9829
- );
9830
- }
9831
- }
9832
- return {
9833
- ...dataWrapped,
9834
- attributes: {
9835
- [attribute]: colorBuffer
9836
- }
9837
- };
9838
- }
9839
- );
9840
- }
9841
- function domainFromRasterMetadataBand(band, scaleType, colorRange) {
9842
- if (scaleType === "ordinal") {
9843
- return colorRange.colorMap?.map(([value]) => value) || [];
9844
- }
9845
- if (scaleType === "custom") {
9846
- if (colorRange.uiCustomScaleType === "logarithmic") {
9847
- return getLog10ScaleSteps({
9848
- min: band.stats.min,
9849
- max: band.stats.max,
9850
- steps: colorRange.colors.length
9851
- });
9852
- } else {
9853
- return colorRange.colorMap?.map(([value]) => value) || [];
9854
- }
9855
- }
9856
- const scaleLength = colorRange.colors.length;
9857
- if (scaleType === "quantile") {
9858
- const quantiles = band.stats.quantiles?.[scaleLength];
9859
- if (!quantiles) {
9860
- return [0, 1];
9861
- }
9862
- return [band.stats.min, ...quantiles, band.stats.max];
9863
- }
9864
- return [band.stats.min, band.stats.max];
9865
- }
9866
- function getRasterTileLayerStylePropsScaledBand({
9867
- layerConfig,
9868
- rasterMetadata,
9869
- visualChannels
9870
- }) {
9871
- const { visConfig } = layerConfig;
9872
- const { colorField } = visualChannels;
9873
- const { rasterStyleType } = visConfig;
9874
- const colorRange = rasterStyleType === "ColorRange" ? visConfig.colorRange : visConfig.uniqueValuesColorRange;
9875
- const scaleType = rasterStyleType === "ColorRange" ? visualChannels.colorScale : "ordinal";
9876
- const bandInfo = rasterMetadata.bands.find(
9877
- (band) => band.name === colorField?.name
9878
- );
9879
- if (!colorField?.name || !scaleType || !colorRange || !bandInfo) {
9880
- return {};
9881
- }
9882
- const domain = domainFromRasterMetadataBand(bandInfo, scaleType, colorRange);
9883
- const scaleFun = createColorScale(
9884
- scaleType,
9885
- domain,
9886
- colorRange.colors.map(hexToRGB2),
9887
- UNKNOWN_COLOR2
9888
- );
9889
- const bandColorScaleDataTransform = createBandColorScaleDataTransform({
9890
- bandName: bandInfo.name,
9891
- scaleFun,
9892
- nodata: bandInfo?.nodata ?? rasterMetadata.nodata,
9893
- attribute: "instanceFillColors"
9894
- });
9895
- return {
9896
- dataTransform: bandColorScaleDataTransform,
9897
- updateTriggers: getRasterTileLayerUpdateTriggers({
9898
- layerConfig,
9899
- visualChannels
9900
- })
9901
- };
9902
- }
9903
- function getRasterTileLayerStyleProps({
9904
- layerConfig,
9905
- visualChannels,
9906
- rasterMetadata
9907
- }) {
9908
- const { visConfig } = layerConfig;
9909
- const { rasterStyleType } = visConfig;
9910
- if (rasterStyleType === "Rgb") {
9911
- return getRasterTileLayerStylePropsRgb({
9912
- layerConfig,
9913
- rasterMetadata,
9914
- visualChannels
9915
- });
9916
- } else {
9917
- return getRasterTileLayerStylePropsScaledBand({
9918
- layerConfig,
9919
- rasterMetadata,
9920
- visualChannels
9921
- });
9922
- }
9923
- }
9924
- function getRasterTileLayerUpdateTriggers({
9925
- layerConfig,
9926
- visualChannels
9927
- }) {
9928
- const { visConfig } = layerConfig;
9929
- const { rasterStyleType } = visConfig;
9930
- const getFillColorUpdateTriggers = {
9931
- rasterStyleType
9932
- };
9933
- if (rasterStyleType === "ColorRange") {
9934
- getFillColorUpdateTriggers.colorRange = visConfig.colorRange?.colors;
9935
- getFillColorUpdateTriggers.colorMap = visConfig.colorRange?.colorMap;
9936
- getFillColorUpdateTriggers.colorScale = visualChannels.colorScale;
9937
- getFillColorUpdateTriggers.colorFieldId = visualChannels.colorField?.name;
9938
- } else if (rasterStyleType === "UniqueValues") {
9939
- getFillColorUpdateTriggers.colorMap = visConfig.uniqueValuesColorRange?.colorMap;
9940
- getFillColorUpdateTriggers.colorFieldId = visualChannels.colorField?.name;
9941
- } else if (rasterStyleType === "Rgb") {
9942
- getFillColorUpdateTriggers.colorBands = visConfig.colorBands;
9943
- }
9944
- return {
9945
- getFillColor: getFillColorUpdateTriggers
9946
- };
9947
- }
9948
- function bufferSetRgba(target, index, r, g, b, a) {
9949
- target[index + 0] = r;
9950
- target[index + 1] = g;
9951
- target[index + 2] = b;
9952
- target[index + 3] = a;
9953
- }
9954
- function hexToRGB2(hexColor) {
9955
- const r = parseInt(hexColor.slice(1, 3), 16);
9956
- const g = parseInt(hexColor.slice(3, 5), 16);
9957
- const b = parseInt(hexColor.slice(5, 7), 16);
9958
- return [r, g, b];
9959
- }
9960
-
9961
9346
  // src/fetch-map/parse-map.ts
9962
- function getLayerDescriptor({
9963
- mapConfig,
9964
- layer,
9965
- dataset
9966
- }) {
9967
- const { filters, visState } = mapConfig;
9968
- const { layerBlending, interactionConfig } = visState;
9969
- const { id, type, config: config2, visualChannels } = layer;
9970
- const { data, id: datasetId } = dataset;
9971
- const { propMap, defaultProps: defaultProps2 } = getLayerProps(type, config2, dataset);
9972
- const styleProps = createStyleProps(config2, propMap);
9973
- const { channelProps, scales } = createChannelProps(
9974
- id,
9975
- type,
9976
- config2,
9977
- visualChannels,
9978
- data,
9979
- dataset
9980
- );
9981
- const layerDescriptor = {
9982
- type,
9983
- filters: isEmptyObject(filters) || isRemoteCalculationSupported(dataset) ? void 0 : filters[datasetId],
9984
- props: {
9985
- id,
9986
- data,
9987
- ...defaultProps2,
9988
- ...createInteractionProps(interactionConfig),
9989
- ...styleProps,
9990
- ...channelProps,
9991
- ...createParametersProp(layerBlending, styleProps.parameters || {}),
9992
- // Must come after style
9993
- ...createLoadOptions(data.accessToken)
9994
- },
9995
- scales
9996
- };
9997
- return layerDescriptor;
9998
- }
9999
9347
  function parseMap(json) {
10000
9348
  const { keplerMapConfig, datasets, token } = json;
10001
9349
  assert2(keplerMapConfig.version === "v1", "Only support Kepler v1");
10002
- const mapConfig = keplerMapConfig.config;
10003
- const { mapState, mapStyle, popupSettings, legendSettings, visState } = mapConfig;
10004
- const { layers } = visState;
10005
- const layersReverse = [...layers].reverse();
9350
+ const config2 = keplerMapConfig.config;
9351
+ const { filters, mapState, mapStyle, popupSettings, legendSettings } = config2;
9352
+ const { layers, layerBlending, interactionConfig } = config2.visState;
10006
9353
  return {
10007
9354
  id: json.id,
10008
9355
  title: json.title,
@@ -10015,19 +9362,45 @@ function parseMap(json) {
10015
9362
  popupSettings,
10016
9363
  legendSettings,
10017
9364
  token,
10018
- layers: layersReverse.map((layer) => {
9365
+ layers: layers.reverse().map(({ id, type, config: config3, visualChannels }) => {
10019
9366
  try {
10020
- const { dataId } = layer.config;
9367
+ const { dataId } = config3;
10021
9368
  const dataset = datasets.find(
10022
9369
  (d) => d.id === dataId
10023
9370
  );
10024
9371
  assert2(dataset, `No dataset matching dataId: ${dataId}`);
10025
- const layerDescriptor = getLayerDescriptor({
10026
- mapConfig,
10027
- layer,
9372
+ const { data } = dataset;
9373
+ assert2(data, `No data loaded for dataId: ${dataId}`);
9374
+ const { propMap, defaultProps: defaultProps2 } = getLayerProps(type, config3, dataset);
9375
+ const styleProps = createStyleProps(config3, propMap);
9376
+ const { channelProps, scales } = createChannelProps(
9377
+ id,
9378
+ type,
9379
+ config3,
9380
+ visualChannels,
9381
+ data,
10028
9382
  dataset
10029
- });
10030
- return layerDescriptor;
9383
+ );
9384
+ const layer = {
9385
+ type,
9386
+ filters: isEmptyObject(filters) || isRemoteCalculationSupported(dataset) ? void 0 : filters[dataId],
9387
+ props: {
9388
+ id,
9389
+ data,
9390
+ ...defaultProps2,
9391
+ ...createInteractionProps(interactionConfig),
9392
+ ...styleProps,
9393
+ ...channelProps,
9394
+ ...createParametersProp(
9395
+ layerBlending,
9396
+ styleProps.parameters || {}
9397
+ ),
9398
+ // Must come after style
9399
+ ...createLoadOptions(token)
9400
+ },
9401
+ scales
9402
+ };
9403
+ return layer;
10031
9404
  } catch (e) {
10032
9405
  console.error(e.message);
10033
9406
  return void 0;
@@ -10092,63 +9465,43 @@ function createStyleProps(config2, mapping) {
10092
9465
  result.highlightColor = config2.visConfig.enable3d ? [255, 255, 255, 60] : [252, 242, 26, 255];
10093
9466
  return result;
10094
9467
  }
9468
+ function domainAndRangeFromScale(scale2) {
9469
+ return {
9470
+ domain: scale2.domain(),
9471
+ range: scale2.range()
9472
+ };
9473
+ }
10095
9474
  function createChannelProps(id, layerType, config2, visualChannels, data, dataset) {
10096
- if (layerType === "raster") {
10097
- const rasterMetadata = data.raster_metadata;
10098
- if (!rasterMetadata) {
10099
- return {
10100
- channelProps: {},
10101
- scales: {}
10102
- };
10103
- }
10104
- const rasterStyleType = config2.visConfig.rasterStyleType;
10105
- if (rasterStyleType === "Rgb") {
10106
- return {
10107
- channelProps: getRasterTileLayerStylePropsRgb({
10108
- layerConfig: config2,
10109
- rasterMetadata,
10110
- visualChannels
10111
- }),
10112
- scales: {}
10113
- // TODO
10114
- };
10115
- } else {
10116
- return {
10117
- channelProps: getRasterTileLayerStylePropsScaledBand({
10118
- layerConfig: config2,
10119
- visualChannels,
10120
- rasterMetadata
10121
- }),
10122
- scales: {
10123
- // TODO
10124
- }
10125
- };
10126
- }
10127
- }
9475
+ const {
9476
+ colorField,
9477
+ colorScale,
9478
+ radiusField,
9479
+ radiusScale,
9480
+ strokeColorField,
9481
+ strokeColorScale,
9482
+ weightField
9483
+ } = visualChannels;
9484
+ const { heightField, heightScale } = visualChannels;
10128
9485
  const { textLabel, visConfig } = config2;
10129
9486
  const result = {};
10130
- const updateTriggers = {};
10131
9487
  const scales = {};
10132
- {
10133
- const { colorField, colorScale } = visualChannels;
10134
- const { colorRange, colorAggregation } = visConfig;
10135
- if (colorField && colorScale && colorRange) {
10136
- const { accessor, ...scaleProps } = getColorAccessor(
10137
- colorField,
10138
- colorScale,
10139
- { aggregation: colorAggregation, range: colorRange },
10140
- visConfig.opacity,
10141
- data
10142
- );
10143
- result.getFillColor = accessor;
10144
- scales.fillColor = updateTriggers.getFillColor = {
10145
- field: colorField,
10146
- type: colorScale,
10147
- ...scaleProps
10148
- };
10149
- } else {
10150
- scales.fillColor = {};
10151
- }
9488
+ if (colorField) {
9489
+ const { colorAggregation: aggregation, colorRange: range } = visConfig;
9490
+ const { accessor, scale: scale2 } = getColorAccessor(
9491
+ colorField,
9492
+ colorScale,
9493
+ { aggregation, range },
9494
+ visConfig.opacity,
9495
+ data
9496
+ );
9497
+ result.getFillColor = accessor;
9498
+ scales.fillColor = {
9499
+ field: colorField,
9500
+ type: colorScale,
9501
+ ...domainAndRangeFromScale(scale2)
9502
+ };
9503
+ } else if (visConfig.filled) {
9504
+ scales.fillColor = {};
10152
9505
  }
10153
9506
  if (layerType === "clusterTile") {
10154
9507
  const aggregationExpAlias = getDefaultAggregationExpColumnAliasForLayerType(
@@ -10161,7 +9514,6 @@ function createChannelProps(id, layerType, config2, visualChannels, data, datase
10161
9514
  result.getWeight = (d) => {
10162
9515
  return d.properties[aggregationExpAlias];
10163
9516
  };
10164
- updateTriggers.getWeight = aggregationExpAlias;
10165
9517
  result.getPointRadius = (d, info) => {
10166
9518
  return calculateClusterRadius(
10167
9519
  d.properties,
@@ -10170,16 +9522,11 @@ function createChannelProps(id, layerType, config2, visualChannels, data, datase
10170
9522
  aggregationExpAlias
10171
9523
  );
10172
9524
  };
10173
- updateTriggers.getPointRadius = {
10174
- aggregationExpAlias,
10175
- radiusRange: visConfig.radiusRange
10176
- };
10177
9525
  result.textCharacterSet = "auto";
10178
9526
  result.textFontFamily = "Inter, sans";
10179
9527
  result.textFontSettings = { sdf: true };
10180
9528
  result.textFontWeight = 600;
10181
9529
  result.getText = (d) => TEXT_NUMBER_FORMATTER.format(d.properties[aggregationExpAlias]);
10182
- updateTriggers.getText = aggregationExpAlias;
10183
9530
  result.getTextColor = config2.textLabel[TEXT_LABEL_INDEX].color;
10184
9531
  result.textOutlineColor = [
10185
9532
  ...config2.textLabel[TEXT_LABEL_INDEX].outlineColor,
@@ -10196,107 +9543,68 @@ function createChannelProps(id, layerType, config2, visualChannels, data, datase
10196
9543
  );
10197
9544
  return calculateClusterTextFontSize(radius);
10198
9545
  };
10199
- updateTriggers.getTextSize = {
10200
- aggregationExpAlias,
10201
- radiusRange: visConfig.radiusRange
10202
- };
10203
9546
  }
10204
- {
10205
- const radiusRange = visConfig.radiusRange;
10206
- const { radiusField, radiusScale } = visualChannels;
10207
- if (radiusField && radiusRange && radiusScale) {
10208
- const { accessor, ...scaleProps } = getSizeAccessor(
10209
- radiusField,
10210
- radiusScale,
10211
- visConfig.sizeAggregation,
10212
- radiusRange,
10213
- data
10214
- );
10215
- result.getPointRadius = accessor;
10216
- scales.pointRadius = updateTriggers.getPointRadius = {
10217
- field: radiusField,
10218
- type: radiusScale,
10219
- ...scaleProps
10220
- };
10221
- }
10222
- }
10223
- {
10224
- const strokeColorRange = visConfig.strokeColorRange;
10225
- const { strokeColorScale, strokeColorField } = visualChannels;
10226
- if (strokeColorField && strokeColorRange && strokeColorScale) {
10227
- const { strokeColorAggregation: aggregation } = visConfig;
10228
- const opacity = visConfig.strokeOpacity !== void 0 ? visConfig.strokeOpacity : 1;
10229
- const { accessor, ...scaleProps } = getColorAccessor(
10230
- strokeColorField,
10231
- strokeColorScale,
10232
- { aggregation, range: strokeColorRange },
10233
- opacity,
10234
- data
10235
- );
10236
- result.getLineColor = accessor;
10237
- scales.lineColor = updateTriggers.getLineColor = {
10238
- field: strokeColorField,
10239
- type: strokeColorScale,
10240
- ...scaleProps
10241
- };
10242
- }
9547
+ if (radiusField) {
9548
+ const { accessor, scale: scale2 } = getSizeAccessor(
9549
+ radiusField,
9550
+ radiusScale,
9551
+ visConfig.sizeAggregation,
9552
+ visConfig.radiusRange || visConfig.sizeRange,
9553
+ data
9554
+ );
9555
+ result.getPointRadius = accessor;
9556
+ scales.pointRadius = {
9557
+ field: radiusField,
9558
+ type: radiusScale || "identity",
9559
+ ...domainAndRangeFromScale(scale2)
9560
+ };
10243
9561
  }
10244
- {
10245
- const { sizeField: strokeWidthField, sizeScale: strokeWidthScale } = visualChannels;
10246
- const { sizeRange, sizeAggregation } = visConfig;
10247
- if (strokeWidthField && sizeRange) {
10248
- const { accessor, ...scaleProps } = getSizeAccessor(
10249
- strokeWidthField,
10250
- strokeWidthScale,
10251
- sizeAggregation,
10252
- sizeRange,
10253
- data
10254
- );
10255
- result.getLineWidth = accessor;
10256
- scales.lineWidth = updateTriggers.getLineWidth = {
10257
- field: strokeWidthField,
10258
- type: strokeWidthScale || "identity",
10259
- ...scaleProps
10260
- };
10261
- }
9562
+ if (strokeColorField) {
9563
+ const opacity = visConfig.strokeOpacity !== void 0 ? visConfig.strokeOpacity : 1;
9564
+ const { strokeColorAggregation: aggregation, strokeColorRange: range } = visConfig;
9565
+ const { accessor, scale: scale2 } = getColorAccessor(
9566
+ strokeColorField,
9567
+ strokeColorScale,
9568
+ { aggregation, range },
9569
+ opacity,
9570
+ data
9571
+ );
9572
+ result.getLineColor = accessor;
9573
+ scales.lineColor = {
9574
+ field: strokeColorField,
9575
+ type: strokeColorScale,
9576
+ ...domainAndRangeFromScale(scale2)
9577
+ };
10262
9578
  }
10263
- {
10264
- const { enable3d, heightRange } = visConfig;
10265
- const { heightField, heightScale } = visualChannels;
10266
- if (heightField && heightRange && enable3d) {
10267
- const { accessor, ...scaleProps } = getSizeAccessor(
10268
- heightField,
10269
- heightScale,
10270
- visConfig.heightAggregation,
10271
- heightRange,
10272
- data
10273
- );
10274
- result.getElevation = accessor;
10275
- scales.elevation = updateTriggers.getElevation = {
10276
- field: heightField,
10277
- type: heightScale || "identity",
10278
- ...scaleProps
10279
- };
10280
- }
9579
+ if (heightField && visConfig.enable3d) {
9580
+ const { accessor, scale: scale2 } = getSizeAccessor(
9581
+ heightField,
9582
+ heightScale,
9583
+ visConfig.heightAggregation,
9584
+ visConfig.heightRange || visConfig.sizeRange,
9585
+ data
9586
+ );
9587
+ result.getElevation = accessor;
9588
+ scales.elevation = {
9589
+ field: heightField,
9590
+ type: heightScale || "identity",
9591
+ ...domainAndRangeFromScale(scale2)
9592
+ };
10281
9593
  }
10282
- {
10283
- const { weightField } = visualChannels;
10284
- const { weightAggregation } = visConfig;
10285
- if (weightField && weightAggregation) {
10286
- const { accessor, ...scaleProps } = getSizeAccessor(
10287
- weightField,
10288
- void 0,
10289
- weightAggregation,
10290
- void 0,
10291
- data
10292
- );
10293
- result.getWeight = accessor;
10294
- scales.weight = updateTriggers.getWeight = {
10295
- field: weightField,
10296
- type: "identity",
10297
- ...scaleProps
10298
- };
10299
- }
9594
+ if (weightField) {
9595
+ const { accessor, scale: scale2 } = getSizeAccessor(
9596
+ weightField,
9597
+ void 0,
9598
+ visConfig.weightAggregation,
9599
+ void 0,
9600
+ data
9601
+ );
9602
+ result.getWeight = accessor;
9603
+ scales.weight = {
9604
+ field: weightField,
9605
+ type: "identity",
9606
+ ...domainAndRangeFromScale(scale2)
9607
+ };
10300
9608
  }
10301
9609
  if (visConfig.customMarkers) {
10302
9610
  const maxIconSize = getMaxMarkerSize(visConfig, visualChannels);
@@ -10313,12 +9621,6 @@ function createChannelProps(id, layerType, config2, visualChannels, data, datase
10313
9621
  { fallbackUrl: customMarkersUrl, maxIconSize, useMaskedIcons },
10314
9622
  data
10315
9623
  );
10316
- updateTriggers.getIcon = {
10317
- customMarkersUrl,
10318
- customMarkersRange,
10319
- maxIconSize,
10320
- useMaskedIcons
10321
- };
10322
9624
  result._subLayerProps = {
10323
9625
  "points-icon": {
10324
9626
  loadOptions: {
@@ -10335,11 +9637,9 @@ function createChannelProps(id, layerType, config2, visualChannels, data, datase
10335
9637
  };
10336
9638
  if (getFillColor && useMaskedIcons) {
10337
9639
  result.getIconColor = getFillColor;
10338
- updateTriggers.getIconColor = updateTriggers.getFillColor;
10339
9640
  }
10340
9641
  if (getPointRadius) {
10341
9642
  result.getIconSize = getPointRadius;
10342
- updateTriggers.getIconSize = updateTriggers.getPointRadius;
10343
9643
  }
10344
9644
  if (visualChannels.rotationField) {
10345
9645
  const { accessor } = getSizeAccessor(
@@ -10350,7 +9650,6 @@ function createChannelProps(id, layerType, config2, visualChannels, data, datase
10350
9650
  data
10351
9651
  );
10352
9652
  result.getIconAngle = negateAccessor(accessor);
10353
- updateTriggers.getIconAngle = updateTriggers.getRotationField;
10354
9653
  }
10355
9654
  } else if (layerType === "tileset") {
10356
9655
  result.pointType = "circle";
@@ -10395,13 +9694,7 @@ function createChannelProps(id, layerType, config2, visualChannels, data, datase
10395
9694
  }
10396
9695
  };
10397
9696
  }
10398
- return {
10399
- channelProps: {
10400
- ...result,
10401
- updateTriggers
10402
- },
10403
- scales
10404
- };
9697
+ return { channelProps: result, scales };
10405
9698
  }
10406
9699
  function createLoadOptions(accessToken) {
10407
9700
  return {
@@ -11048,16 +10341,9 @@ export {
11048
10341
  WidgetSource,
11049
10342
  WidgetTableSource,
11050
10343
  WidgetTilesetSource,
11051
- ErrorCode as _ErrorCode,
11052
- applyLayerGroupFilters as _applyLayerGroupFilters,
11053
10344
  _buildFeatureFilter,
11054
- createVecExprEvaluator as _createVecExprEvaluator,
11055
10345
  domainFromValues as _domainFromValues,
11056
- evaluateVecExpr as _evaluateVecExpr,
11057
10346
  _getHexagonResolution,
11058
- getLog10ScaleSteps as _getLog10ScaleSteps,
11059
- getRasterTileLayerStyleProps as _getRasterTileLayerStyleProps,
11060
- validateVecExprSyntax as _validateVecExprSyntax,
11061
10347
  addFilter,
11062
10348
  aggregate,
11063
10349
  aggregationFunctions,
@@ -11070,11 +10356,9 @@ export {
11070
10356
  buildStatsUrl,
11071
10357
  calculateClusterRadius,
11072
10358
  calculateClusterTextFontSize,
11073
- calculateLayerScale,
11074
10359
  clearDefaultRequestCache,
11075
10360
  clearFilters,
11076
10361
  configureSource,
11077
- createColorScale,
11078
10362
  createPolygonSpatialFilter,
11079
10363
  createViewportSpatialFilter,
11080
10364
  fetchBasemapProps,
@@ -11089,7 +10373,6 @@ export {
11089
10373
  getDefaultAggregationExpColumnAliasForLayerType,
11090
10374
  getFilter,
11091
10375
  getIconUrlAccessor,
11092
- getLayerDescriptor,
11093
10376
  getLayerProps,
11094
10377
  getMaxMarkerSize,
11095
10378
  getSizeAccessor,
@@ -11120,6 +10403,8 @@ export {
11120
10403
  tileFeatures,
11121
10404
  tileFeaturesGeometries,
11122
10405
  tileFeaturesSpatialIndex,
10406
+ trajectoryQuerySource,
10407
+ trajectoryTableSource,
11123
10408
  transformToTileCoords,
11124
10409
  vectorQuerySource,
11125
10410
  vectorTableSource,