@carto/api-client 0.5.15-alpha.raster-4 → 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,7 +9189,7 @@ 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
9194
  scaleType,
9403
9195
  range,
@@ -9410,61 +9202,33 @@ function getColorAccessor({ name, colorColumn }, scaleType, { aggregation, range
9410
9202
  accessorKeys = findAccessorKey(accessorKeys, properties);
9411
9203
  }
9412
9204
  const propertyValue = properties[accessorKeys[0]];
9413
- const [r, g, b] = scale2(propertyValue);
9205
+ const { r, g, b } = rgb(scale2(propertyValue));
9414
9206
  return [r, g, b, propertyValue === null ? 0 : alpha];
9415
9207
  };
9416
- return {
9417
- accessor: normalizeAccessor(accessor, data),
9418
- scaleDomain: scale2.domain(),
9419
- domain,
9420
- range: scale2.range().map(rgbToHex)
9421
- };
9208
+ return { accessor: normalizeAccessor(accessor, data), scale: scale2 };
9422
9209
  }
9423
9210
  function calculateLayerScale(name, scaleType, range, data) {
9211
+ const scale2 = SCALE_FUNCS[scaleType]();
9424
9212
  let domain = [];
9425
- let scaleDomain;
9426
9213
  let scaleColor = [];
9427
- const { colors } = range;
9428
- if (scaleType === "custom") {
9429
- domain = calculateDomain(data, name, scaleType, colors.length);
9430
- const [min2, max2] = domain;
9431
- if (range.uiCustomScaleType === "logarithmic") {
9432
- scaleDomain = getLog10ScaleSteps({
9433
- min: min2,
9434
- max: max2,
9435
- steps: colors.length
9436
- });
9437
- scaleColor = colors;
9438
- } else if (range.colorMap) {
9439
- const { colorMap } = range;
9440
- scaleDomain = [];
9214
+ if (scaleType !== "identity") {
9215
+ const { colorMap, colors } = range;
9216
+ if (Array.isArray(colorMap)) {
9441
9217
  colorMap.forEach(([value, color2]) => {
9442
- scaleDomain.push(Number(value));
9218
+ domain.push(value);
9443
9219
  scaleColor.push(color2);
9444
9220
  });
9221
+ } else {
9222
+ domain = calculateDomain(data, name, scaleType, colors.length);
9223
+ scaleColor = colors;
9445
9224
  }
9446
- } else if (scaleType !== "identity") {
9447
- domain = calculateDomain(data, name, scaleType, colors.length);
9448
- scaleColor = colors;
9449
9225
  if (scaleType === "ordinal") {
9450
9226
  domain = domain.slice(0, scaleColor.length);
9451
9227
  }
9452
9228
  }
9453
- return {
9454
- scale: createColorScale(
9455
- scaleType,
9456
- scaleDomain || domain,
9457
- scaleColor.map(hexToRGB),
9458
- UNKNOWN_COLOR_RGB
9459
- ),
9460
- domain
9461
- };
9462
- }
9463
- function createColorScale(scaleType, domain, range, unknown) {
9464
- const scale2 = SCALE_FUNCS[scaleType]();
9465
9229
  scale2.domain(domain);
9466
- scale2.range(range);
9467
- scale2.unknown(unknown);
9230
+ scale2.range(scaleColor);
9231
+ scale2.unknown(UNKNOWN_COLOR);
9468
9232
  return scale2;
9469
9233
  }
9470
9234
  var FALLBACK_ICON = "data:image/svg+xml;charset=utf-8;base64,PHN2ZyB2aWV3Qm94PSIwIDAgMTAwIDEwMCIgeG1sbnM9Imh0dHA6Ly93d3cudzMub3JnLzIwMDAvc3ZnIj4NCiAgPGNpcmNsZSBjeD0iNTAiIGN5PSI1MCIgcj0iNTAiLz4NCjwvc3ZnPg==";
@@ -9514,13 +9278,9 @@ function negateAccessor(accessor) {
9514
9278
  }
9515
9279
  function getSizeAccessor({ name }, scaleType, aggregation, range, data) {
9516
9280
  const scale2 = scaleType ? SCALE_FUNCS[scaleType]() : identity2;
9517
- let domain = [];
9518
- if (scaleType && range) {
9281
+ if (scaleType) {
9519
9282
  if (aggregation !== AggregationTypes.Count) {
9520
- domain = calculateDomain(data, name, scaleType);
9521
- scale2.domain(domain);
9522
- } else {
9523
- domain = scale2.domain();
9283
+ scale2.domain(calculateDomain(data, name, scaleType));
9524
9284
  }
9525
9285
  scale2.range(range);
9526
9286
  }
@@ -9532,12 +9292,7 @@ function getSizeAccessor({ name }, scaleType, aggregation, range, data) {
9532
9292
  const propertyValue = properties[accessorKeys[0]];
9533
9293
  return scale2(propertyValue);
9534
9294
  };
9535
- return {
9536
- accessor: normalizeAccessor(accessor, data),
9537
- domain,
9538
- scaleDomain: domain,
9539
- range
9540
- };
9295
+ return { accessor: normalizeAccessor(accessor, data), scale: scale2 };
9541
9296
  }
9542
9297
  var FORMATS = {
9543
9298
  date: formatDate,
@@ -9588,420 +9343,13 @@ function calculateClusterTextFontSize(radius) {
9588
9343
  return 11;
9589
9344
  }
9590
9345
 
9591
- // src/fetch-map/raster-layer.ts
9592
- var UNKNOWN_COLOR2 = [134, 141, 145];
9593
- var RASTER_COLOR_BANDS = ["red", "green", "blue"];
9594
- function getHasDataPredicate(noData) {
9595
- if (noData === "nan") {
9596
- return (v2) => !isNaN(v2);
9597
- }
9598
- if (typeof noData === "string") {
9599
- noData = parseFloat(noData);
9600
- }
9601
- if (typeof noData === "number") {
9602
- return (v2) => v2 !== noData && !isNaN(v2);
9603
- }
9604
- return () => true;
9605
- }
9606
- function createRasterColumnLayerDataTransform(transform) {
9607
- return (data) => {
9608
- if (!data || !("data" in data) || !data?.data?.cells?.numericProps) {
9609
- return data;
9610
- }
9611
- return transform(data);
9612
- };
9613
- }
9614
- function createEvaluationContext(numericProps, noData) {
9615
- const hasData = getHasDataPredicate(noData);
9616
- const bands = Object.entries(numericProps).map(([bandName, { value }]) => ({
9617
- bandName,
9618
- values: value,
9619
- copied: false
9620
- }));
9621
- const length2 = bands[0].values.length;
9622
- for (let i = 0; i < length2; i++) {
9623
- let hasSomeData = false;
9624
- for (let j = 0; j < bands.length; j++) {
9625
- hasSomeData = hasSomeData || hasData(bands[j].values[i]);
9626
- }
9627
- if (!hasSomeData) {
9628
- for (let j = 0; j < bands.length; j++) {
9629
- if (!bands[j].copied) {
9630
- bands[j].copied = true;
9631
- bands[j].values = Array.from(bands[j].values);
9632
- }
9633
- bands[j].values[i] = NaN;
9634
- }
9635
- }
9636
- }
9637
- const context = bands.reduce(
9638
- (agg, { bandName, values }) => {
9639
- agg[bandName] = values;
9640
- return agg;
9641
- },
9642
- {}
9643
- );
9644
- return context;
9645
- }
9646
- function createExprDataTransform({
9647
- colorBand,
9648
- rasterMetadata,
9649
- usedSymbols
9650
- }) {
9651
- if (!colorBand || !colorBand.type || colorBand.type === "none") {
9652
- return void 0;
9653
- }
9654
- const expr = colorBand?.type === "expression" ? colorBand.value : void 0;
9655
- const vecExprEvaluator = expr ? createVecExprEvaluator(expr) : void 0;
9656
- const dataTransform = createRasterColumnLayerDataTransform(
9657
- (dataWrapped) => {
9658
- const data = dataWrapped.data;
9659
- if (expr) {
9660
- const cachedResult = dataWrapped.customExpressionResults?.[expr];
9661
- if (cachedResult) {
9662
- return dataWrapped;
9663
- }
9664
- }
9665
- let context = dataWrapped.expressionEvalContext;
9666
- if (!context) {
9667
- const usedNumericProps = usedSymbols.reduce(
9668
- (acc, symbol) => {
9669
- acc[symbol] = data.cells.numericProps[symbol];
9670
- return acc;
9671
- },
9672
- {}
9673
- );
9674
- context = createEvaluationContext(
9675
- usedNumericProps,
9676
- rasterMetadata.nodata
9677
- );
9678
- dataWrapped = {
9679
- ...dataWrapped,
9680
- expressionEvalContext: context
9681
- };
9682
- }
9683
- if (!vecExprEvaluator || !expr) return dataWrapped;
9684
- const evalResult = vecExprEvaluator(context);
9685
- return {
9686
- ...dataWrapped,
9687
- customExpressionResults: {
9688
- ...dataWrapped.customExpressionResults,
9689
- [expr]: evalResult
9690
- }
9691
- };
9692
- }
9693
- );
9694
- return dataTransform;
9695
- }
9696
- function combineDataTransforms(dataTransforms) {
9697
- const actualTransforms = dataTransforms.filter((v2) => v2);
9698
- if (actualTransforms.length === 0) return void 0;
9699
- if (actualTransforms.length === 1) return actualTransforms[0];
9700
- return (data) => actualTransforms.reduce(
9701
- (aggData, transformFun) => transformFun(aggData),
9702
- data
9703
- );
9704
- }
9705
- function createRgbToColorBufferDataTransform({
9706
- bandDefs,
9707
- attribute
9708
- }) {
9709
- return createRasterColumnLayerDataTransform(
9710
- (dataWrapped) => {
9711
- const length2 = dataWrapped.length;
9712
- const getBandBufferOrValue = (colorBand) => {
9713
- if (colorBand?.type === "expression") {
9714
- return dataWrapped.customExpressionResults?.[colorBand.value];
9715
- }
9716
- if (colorBand?.type === "band") {
9717
- return dataWrapped.expressionEvalContext?.[colorBand.value];
9718
- }
9719
- return 0;
9720
- };
9721
- const red = getBandBufferOrValue(bandDefs.red);
9722
- const green = getBandBufferOrValue(bandDefs.green);
9723
- const blue = getBandBufferOrValue(bandDefs.blue);
9724
- const colorBuffer = new Uint8Array(length2 * 4);
9725
- for (let inputIndex = 0, outputIndex = 0; inputIndex < length2; inputIndex++, outputIndex += 4) {
9726
- const redRaw = typeof red === "number" ? red : red ? red[inputIndex] : NaN;
9727
- const greenRaw = typeof green === "number" ? green : green ? green[inputIndex] : NaN;
9728
- const blueRaw = typeof blue === "number" ? blue : blue ? blue[inputIndex] : NaN;
9729
- if (isNaN(redRaw) && isNaN(greenRaw) && isNaN(blueRaw)) {
9730
- bufferSetRgba(colorBuffer, outputIndex, 0, 0, 0, 0);
9731
- } else {
9732
- bufferSetRgba(
9733
- colorBuffer,
9734
- outputIndex,
9735
- redRaw,
9736
- greenRaw,
9737
- blueRaw,
9738
- 255
9739
- );
9740
- }
9741
- }
9742
- dataWrapped.customExpressionResults = void 0;
9743
- dataWrapped.expressionEvalContext = void 0;
9744
- return {
9745
- ...dataWrapped,
9746
- attributes: {
9747
- [attribute]: colorBuffer
9748
- }
9749
- };
9750
- }
9751
- );
9752
- }
9753
- function getUsedSymbols(colorBands) {
9754
- return Array.from(
9755
- colorBands.reduce((symbols, band) => {
9756
- if (band.type === "expression") {
9757
- const expressionSymbols = createVecExprEvaluator(band.value)?.symbols || [];
9758
- expressionSymbols.forEach((symbol) => symbols.add(symbol));
9759
- }
9760
- if (band.type === "band") {
9761
- symbols.add(band.value);
9762
- }
9763
- return symbols;
9764
- }, /* @__PURE__ */ new Set())
9765
- );
9766
- }
9767
- function getRasterTileLayerStylePropsRgb({
9768
- layerConfig,
9769
- rasterMetadata,
9770
- visualChannels
9771
- }) {
9772
- const { visConfig } = layerConfig;
9773
- const { colorBands } = visConfig;
9774
- const bandDefs = {
9775
- red: colorBands?.find((band) => band.band === "red"),
9776
- green: colorBands?.find((band) => band.band === "green"),
9777
- blue: colorBands?.find((band) => band.band === "blue")
9778
- };
9779
- const rgbToInstanceFillColorsDataTransform = createRgbToColorBufferDataTransform({
9780
- bandDefs,
9781
- attribute: "instanceFillColors"
9782
- });
9783
- const usedSymbols = colorBands ? getUsedSymbols(colorBands) : [];
9784
- const bandTransforms = RASTER_COLOR_BANDS.map(
9785
- (band) => createExprDataTransform({
9786
- colorBand: bandDefs[band],
9787
- rasterMetadata,
9788
- usedSymbols
9789
- })
9790
- );
9791
- const combinedDataTransform = combineDataTransforms([
9792
- ...bandTransforms,
9793
- rgbToInstanceFillColorsDataTransform
9794
- ]);
9795
- return {
9796
- dataTransform: combinedDataTransform,
9797
- updateTriggers: getRasterTileLayerUpdateTriggers({
9798
- layerConfig,
9799
- visualChannels
9800
- })
9801
- };
9802
- }
9803
- function createBandColorScaleDataTransform({
9804
- bandName,
9805
- scaleFun,
9806
- nodata,
9807
- attribute
9808
- }) {
9809
- const hasData = getHasDataPredicate(nodata);
9810
- return createRasterColumnLayerDataTransform(
9811
- (dataWrapped) => {
9812
- const length2 = dataWrapped.length;
9813
- const bandBuffer = dataWrapped.data.cells.numericProps[bandName].value;
9814
- const colorBuffer = new Uint8Array(length2 * 4);
9815
- for (let i = 0; i < length2; i++) {
9816
- const rawValue = bandBuffer[i];
9817
- if (!hasData(rawValue)) {
9818
- bufferSetRgba(colorBuffer, i * 4, 0, 0, 0, 0);
9819
- } else {
9820
- const colorRgb = scaleFun(rawValue);
9821
- bufferSetRgba(
9822
- colorBuffer,
9823
- i * 4,
9824
- colorRgb[0],
9825
- colorRgb[1],
9826
- colorRgb[2],
9827
- 255
9828
- );
9829
- }
9830
- }
9831
- return {
9832
- ...dataWrapped,
9833
- attributes: {
9834
- [attribute]: colorBuffer
9835
- }
9836
- };
9837
- }
9838
- );
9839
- }
9840
- function domainFromRasterMetadataBand(band, scaleType, colorRange) {
9841
- if (scaleType === "ordinal") {
9842
- return colorRange.colorMap?.map(([value]) => value) || [];
9843
- }
9844
- if (scaleType === "custom") {
9845
- if (colorRange.uiCustomScaleType === "logarithmic") {
9846
- return getLog10ScaleSteps({
9847
- min: band.stats.min,
9848
- max: band.stats.max,
9849
- steps: colorRange.colors.length
9850
- });
9851
- } else {
9852
- return colorRange.colorMap?.map(([value]) => value) || [];
9853
- }
9854
- }
9855
- const scaleLength = colorRange.colors.length;
9856
- if (scaleType === "quantile") {
9857
- const quantiles = band.stats.quantiles?.[scaleLength];
9858
- if (!quantiles) {
9859
- return [0, 1];
9860
- }
9861
- return [band.stats.min, ...quantiles, band.stats.max];
9862
- }
9863
- return [band.stats.min, band.stats.max];
9864
- }
9865
- function getRasterTileLayerStylePropsScaledBand({
9866
- layerConfig,
9867
- rasterMetadata,
9868
- visualChannels
9869
- }) {
9870
- const { visConfig } = layerConfig;
9871
- const { colorField } = visualChannels;
9872
- const { rasterStyleType } = visConfig;
9873
- const colorRange = rasterStyleType === "ColorRange" ? visConfig.colorRange : visConfig.uniqueValuesColorRange;
9874
- const scaleType = rasterStyleType === "ColorRange" ? visualChannels.colorScale : "ordinal";
9875
- const bandInfo = rasterMetadata.bands.find(
9876
- (band) => band.name === colorField?.name
9877
- );
9878
- if (!colorField?.name || !scaleType || !colorRange || !bandInfo) {
9879
- return {};
9880
- }
9881
- const domain = domainFromRasterMetadataBand(bandInfo, scaleType, colorRange);
9882
- const scaleFun = createColorScale(
9883
- scaleType,
9884
- domain,
9885
- colorRange.colors.map(hexToRGB2),
9886
- UNKNOWN_COLOR2
9887
- );
9888
- const bandColorScaleDataTransform = createBandColorScaleDataTransform({
9889
- bandName: bandInfo.name,
9890
- scaleFun,
9891
- nodata: bandInfo?.nodata ?? rasterMetadata.nodata,
9892
- attribute: "instanceFillColors"
9893
- });
9894
- return {
9895
- dataTransform: bandColorScaleDataTransform,
9896
- updateTriggers: getRasterTileLayerUpdateTriggers({
9897
- layerConfig,
9898
- visualChannels
9899
- })
9900
- };
9901
- }
9902
- function getRasterTileLayerStyleProps({
9903
- layerConfig,
9904
- visualChannels,
9905
- rasterMetadata
9906
- }) {
9907
- const { visConfig } = layerConfig;
9908
- const { rasterStyleType } = visConfig;
9909
- if (rasterStyleType === "Rgb") {
9910
- return getRasterTileLayerStylePropsRgb({
9911
- layerConfig,
9912
- rasterMetadata,
9913
- visualChannels
9914
- });
9915
- } else {
9916
- return getRasterTileLayerStylePropsScaledBand({
9917
- layerConfig,
9918
- rasterMetadata,
9919
- visualChannels
9920
- });
9921
- }
9922
- }
9923
- function getRasterTileLayerUpdateTriggers({
9924
- layerConfig,
9925
- visualChannels
9926
- }) {
9927
- const { visConfig } = layerConfig;
9928
- const { rasterStyleType } = visConfig;
9929
- const getFillColorUpdateTriggers = {
9930
- rasterStyleType
9931
- };
9932
- if (rasterStyleType === "ColorRange") {
9933
- getFillColorUpdateTriggers.colorRange = visConfig.colorRange?.colors;
9934
- getFillColorUpdateTriggers.colorMap = visConfig.colorRange?.colorMap;
9935
- getFillColorUpdateTriggers.colorScale = visualChannels.colorScale;
9936
- getFillColorUpdateTriggers.colorFieldId = visualChannels.colorField?.name;
9937
- } else if (rasterStyleType === "UniqueValues") {
9938
- getFillColorUpdateTriggers.colorMap = visConfig.uniqueValuesColorRange?.colorMap;
9939
- getFillColorUpdateTriggers.colorFieldId = visualChannels.colorField?.name;
9940
- } else if (rasterStyleType === "Rgb") {
9941
- getFillColorUpdateTriggers.colorBands = visConfig.colorBands;
9942
- }
9943
- return {
9944
- getFillColor: getFillColorUpdateTriggers
9945
- };
9946
- }
9947
- function bufferSetRgba(target, index, r, g, b, a) {
9948
- target[index + 0] = r;
9949
- target[index + 1] = g;
9950
- target[index + 2] = b;
9951
- target[index + 3] = a;
9952
- }
9953
- function hexToRGB2(hexColor) {
9954
- const r = parseInt(hexColor.slice(1, 3), 16);
9955
- const g = parseInt(hexColor.slice(3, 5), 16);
9956
- const b = parseInt(hexColor.slice(5, 7), 16);
9957
- return [r, g, b];
9958
- }
9959
-
9960
9346
  // src/fetch-map/parse-map.ts
9961
- function getLayerDescriptor({
9962
- mapConfig,
9963
- layer,
9964
- dataset
9965
- }) {
9966
- const { filters, visState } = mapConfig;
9967
- const { layerBlending, interactionConfig } = visState;
9968
- const { id, type, config: config2, visualChannels } = layer;
9969
- const { data, id: datasetId } = dataset;
9970
- const { propMap, defaultProps: defaultProps2 } = getLayerProps(type, config2, dataset);
9971
- const styleProps = createStyleProps(config2, propMap);
9972
- const { channelProps, scales } = createChannelProps(
9973
- id,
9974
- type,
9975
- config2,
9976
- visualChannels,
9977
- data,
9978
- dataset
9979
- );
9980
- const layerDescriptor = {
9981
- type,
9982
- filters: isEmptyObject(filters) || isRemoteCalculationSupported(dataset) ? void 0 : filters[datasetId],
9983
- props: {
9984
- id,
9985
- data,
9986
- ...defaultProps2,
9987
- ...createInteractionProps(interactionConfig),
9988
- ...styleProps,
9989
- ...channelProps,
9990
- ...createParametersProp(layerBlending, styleProps.parameters || {}),
9991
- // Must come after style
9992
- ...createLoadOptions(data.accessToken)
9993
- },
9994
- scales
9995
- };
9996
- return layerDescriptor;
9997
- }
9998
9347
  function parseMap(json) {
9999
9348
  const { keplerMapConfig, datasets, token } = json;
10000
9349
  assert2(keplerMapConfig.version === "v1", "Only support Kepler v1");
10001
- const mapConfig = keplerMapConfig.config;
10002
- const { mapState, mapStyle, popupSettings, legendSettings, visState } = mapConfig;
10003
- const { layers } = visState;
10004
- const layersReverse = [...layers].reverse();
9350
+ const config2 = keplerMapConfig.config;
9351
+ const { filters, mapState, mapStyle, popupSettings, legendSettings } = config2;
9352
+ const { layers, layerBlending, interactionConfig } = config2.visState;
10005
9353
  return {
10006
9354
  id: json.id,
10007
9355
  title: json.title,
@@ -10014,19 +9362,45 @@ function parseMap(json) {
10014
9362
  popupSettings,
10015
9363
  legendSettings,
10016
9364
  token,
10017
- layers: layersReverse.map((layer) => {
9365
+ layers: layers.reverse().map(({ id, type, config: config3, visualChannels }) => {
10018
9366
  try {
10019
- const { dataId } = layer.config;
9367
+ const { dataId } = config3;
10020
9368
  const dataset = datasets.find(
10021
9369
  (d) => d.id === dataId
10022
9370
  );
10023
9371
  assert2(dataset, `No dataset matching dataId: ${dataId}`);
10024
- const layerDescriptor = getLayerDescriptor({
10025
- mapConfig,
10026
- 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,
10027
9382
  dataset
10028
- });
10029
- 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;
10030
9404
  } catch (e) {
10031
9405
  console.error(e.message);
10032
9406
  return void 0;
@@ -10091,63 +9465,43 @@ function createStyleProps(config2, mapping) {
10091
9465
  result.highlightColor = config2.visConfig.enable3d ? [255, 255, 255, 60] : [252, 242, 26, 255];
10092
9466
  return result;
10093
9467
  }
9468
+ function domainAndRangeFromScale(scale2) {
9469
+ return {
9470
+ domain: scale2.domain(),
9471
+ range: scale2.range()
9472
+ };
9473
+ }
10094
9474
  function createChannelProps(id, layerType, config2, visualChannels, data, dataset) {
10095
- if (layerType === "raster") {
10096
- const rasterMetadata = data.raster_metadata;
10097
- if (!rasterMetadata) {
10098
- return {
10099
- channelProps: {},
10100
- scales: {}
10101
- };
10102
- }
10103
- const rasterStyleType = config2.visConfig.rasterStyleType;
10104
- if (rasterStyleType === "Rgb") {
10105
- return {
10106
- channelProps: getRasterTileLayerStylePropsRgb({
10107
- layerConfig: config2,
10108
- rasterMetadata,
10109
- visualChannels
10110
- }),
10111
- scales: {}
10112
- // TODO
10113
- };
10114
- } else {
10115
- return {
10116
- channelProps: getRasterTileLayerStylePropsScaledBand({
10117
- layerConfig: config2,
10118
- visualChannels,
10119
- rasterMetadata
10120
- }),
10121
- scales: {
10122
- // TODO
10123
- }
10124
- };
10125
- }
10126
- }
9475
+ const {
9476
+ colorField,
9477
+ colorScale,
9478
+ radiusField,
9479
+ radiusScale,
9480
+ strokeColorField,
9481
+ strokeColorScale,
9482
+ weightField
9483
+ } = visualChannels;
9484
+ const { heightField, heightScale } = visualChannels;
10127
9485
  const { textLabel, visConfig } = config2;
10128
9486
  const result = {};
10129
- const updateTriggers = {};
10130
9487
  const scales = {};
10131
- {
10132
- const { colorField, colorScale } = visualChannels;
10133
- const { colorRange, colorAggregation } = visConfig;
10134
- if (colorField && colorScale && colorRange) {
10135
- const { accessor, ...scaleProps } = getColorAccessor(
10136
- colorField,
10137
- colorScale,
10138
- { aggregation: colorAggregation, range: colorRange },
10139
- visConfig.opacity,
10140
- data
10141
- );
10142
- result.getFillColor = accessor;
10143
- scales.fillColor = updateTriggers.getFillColor = {
10144
- field: colorField,
10145
- type: colorScale,
10146
- ...scaleProps
10147
- };
10148
- } else {
10149
- scales.fillColor = {};
10150
- }
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 = {};
10151
9505
  }
10152
9506
  if (layerType === "clusterTile") {
10153
9507
  const aggregationExpAlias = getDefaultAggregationExpColumnAliasForLayerType(
@@ -10160,7 +9514,6 @@ function createChannelProps(id, layerType, config2, visualChannels, data, datase
10160
9514
  result.getWeight = (d) => {
10161
9515
  return d.properties[aggregationExpAlias];
10162
9516
  };
10163
- updateTriggers.getWeight = aggregationExpAlias;
10164
9517
  result.getPointRadius = (d, info) => {
10165
9518
  return calculateClusterRadius(
10166
9519
  d.properties,
@@ -10169,16 +9522,11 @@ function createChannelProps(id, layerType, config2, visualChannels, data, datase
10169
9522
  aggregationExpAlias
10170
9523
  );
10171
9524
  };
10172
- updateTriggers.getPointRadius = {
10173
- aggregationExpAlias,
10174
- radiusRange: visConfig.radiusRange
10175
- };
10176
9525
  result.textCharacterSet = "auto";
10177
9526
  result.textFontFamily = "Inter, sans";
10178
9527
  result.textFontSettings = { sdf: true };
10179
9528
  result.textFontWeight = 600;
10180
9529
  result.getText = (d) => TEXT_NUMBER_FORMATTER.format(d.properties[aggregationExpAlias]);
10181
- updateTriggers.getText = aggregationExpAlias;
10182
9530
  result.getTextColor = config2.textLabel[TEXT_LABEL_INDEX].color;
10183
9531
  result.textOutlineColor = [
10184
9532
  ...config2.textLabel[TEXT_LABEL_INDEX].outlineColor,
@@ -10195,107 +9543,68 @@ function createChannelProps(id, layerType, config2, visualChannels, data, datase
10195
9543
  );
10196
9544
  return calculateClusterTextFontSize(radius);
10197
9545
  };
10198
- updateTriggers.getTextSize = {
10199
- aggregationExpAlias,
10200
- radiusRange: visConfig.radiusRange
10201
- };
10202
- }
10203
- {
10204
- const radiusRange = visConfig.radiusRange;
10205
- const { radiusField, radiusScale } = visualChannels;
10206
- if (radiusField && radiusRange && radiusScale) {
10207
- const { accessor, ...scaleProps } = getSizeAccessor(
10208
- radiusField,
10209
- radiusScale,
10210
- visConfig.sizeAggregation,
10211
- radiusRange,
10212
- data
10213
- );
10214
- result.getPointRadius = accessor;
10215
- scales.pointRadius = updateTriggers.getPointRadius = {
10216
- field: radiusField,
10217
- type: radiusScale,
10218
- ...scaleProps
10219
- };
10220
- }
10221
9546
  }
10222
- {
10223
- const strokeColorRange = visConfig.strokeColorRange;
10224
- const { strokeColorScale, strokeColorField } = visualChannels;
10225
- if (strokeColorField && strokeColorRange && strokeColorScale) {
10226
- const { strokeColorAggregation: aggregation } = visConfig;
10227
- const opacity = visConfig.strokeOpacity !== void 0 ? visConfig.strokeOpacity : 1;
10228
- const { accessor, ...scaleProps } = getColorAccessor(
10229
- strokeColorField,
10230
- strokeColorScale,
10231
- { aggregation, range: strokeColorRange },
10232
- opacity,
10233
- data
10234
- );
10235
- result.getLineColor = accessor;
10236
- scales.lineColor = updateTriggers.getLineColor = {
10237
- field: strokeColorField,
10238
- type: strokeColorScale,
10239
- ...scaleProps
10240
- };
10241
- }
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
+ };
10242
9561
  }
10243
- {
10244
- const { sizeField: strokeWidthField, sizeScale: strokeWidthScale } = visualChannels;
10245
- const { sizeRange, sizeAggregation } = visConfig;
10246
- if (strokeWidthField && sizeRange) {
10247
- const { accessor, ...scaleProps } = getSizeAccessor(
10248
- strokeWidthField,
10249
- strokeWidthScale,
10250
- sizeAggregation,
10251
- sizeRange,
10252
- data
10253
- );
10254
- result.getLineWidth = accessor;
10255
- scales.lineWidth = updateTriggers.getLineWidth = {
10256
- field: strokeWidthField,
10257
- type: strokeWidthScale || "identity",
10258
- ...scaleProps
10259
- };
10260
- }
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
+ };
10261
9578
  }
10262
- {
10263
- const { enable3d, heightRange } = visConfig;
10264
- const { heightField, heightScale } = visualChannels;
10265
- if (heightField && heightRange && enable3d) {
10266
- const { accessor, ...scaleProps } = getSizeAccessor(
10267
- heightField,
10268
- heightScale,
10269
- visConfig.heightAggregation,
10270
- heightRange,
10271
- data
10272
- );
10273
- result.getElevation = accessor;
10274
- scales.elevation = updateTriggers.getElevation = {
10275
- field: heightField,
10276
- type: heightScale || "identity",
10277
- ...scaleProps
10278
- };
10279
- }
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
+ };
10280
9593
  }
10281
- {
10282
- const { weightField } = visualChannels;
10283
- const { weightAggregation } = visConfig;
10284
- if (weightField && weightAggregation) {
10285
- const { accessor, ...scaleProps } = getSizeAccessor(
10286
- weightField,
10287
- void 0,
10288
- weightAggregation,
10289
- void 0,
10290
- data
10291
- );
10292
- result.getWeight = accessor;
10293
- scales.weight = updateTriggers.getWeight = {
10294
- field: weightField,
10295
- type: "identity",
10296
- ...scaleProps
10297
- };
10298
- }
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
+ };
10299
9608
  }
10300
9609
  if (visConfig.customMarkers) {
10301
9610
  const maxIconSize = getMaxMarkerSize(visConfig, visualChannels);
@@ -10312,12 +9621,6 @@ function createChannelProps(id, layerType, config2, visualChannels, data, datase
10312
9621
  { fallbackUrl: customMarkersUrl, maxIconSize, useMaskedIcons },
10313
9622
  data
10314
9623
  );
10315
- updateTriggers.getIcon = {
10316
- customMarkersUrl,
10317
- customMarkersRange,
10318
- maxIconSize,
10319
- useMaskedIcons
10320
- };
10321
9624
  result._subLayerProps = {
10322
9625
  "points-icon": {
10323
9626
  loadOptions: {
@@ -10334,11 +9637,9 @@ function createChannelProps(id, layerType, config2, visualChannels, data, datase
10334
9637
  };
10335
9638
  if (getFillColor && useMaskedIcons) {
10336
9639
  result.getIconColor = getFillColor;
10337
- updateTriggers.getIconColor = updateTriggers.getFillColor;
10338
9640
  }
10339
9641
  if (getPointRadius) {
10340
9642
  result.getIconSize = getPointRadius;
10341
- updateTriggers.getIconSize = updateTriggers.getPointRadius;
10342
9643
  }
10343
9644
  if (visualChannels.rotationField) {
10344
9645
  const { accessor } = getSizeAccessor(
@@ -10349,7 +9650,6 @@ function createChannelProps(id, layerType, config2, visualChannels, data, datase
10349
9650
  data
10350
9651
  );
10351
9652
  result.getIconAngle = negateAccessor(accessor);
10352
- updateTriggers.getIconAngle = updateTriggers.getRotationField;
10353
9653
  }
10354
9654
  } else if (layerType === "tileset") {
10355
9655
  result.pointType = "circle";
@@ -10394,13 +9694,7 @@ function createChannelProps(id, layerType, config2, visualChannels, data, datase
10394
9694
  }
10395
9695
  };
10396
9696
  }
10397
- return {
10398
- channelProps: {
10399
- ...result,
10400
- updateTriggers
10401
- },
10402
- scales
10403
- };
9697
+ return { channelProps: result, scales };
10404
9698
  }
10405
9699
  function createLoadOptions(accessToken) {
10406
9700
  return {
@@ -11047,16 +10341,9 @@ export {
11047
10341
  WidgetSource,
11048
10342
  WidgetTableSource,
11049
10343
  WidgetTilesetSource,
11050
- ErrorCode as _ErrorCode,
11051
- applyLayerGroupFilters as _applyLayerGroupFilters,
11052
10344
  _buildFeatureFilter,
11053
- createVecExprEvaluator as _createVecExprEvaluator,
11054
10345
  domainFromValues as _domainFromValues,
11055
- evaluateVecExpr as _evaluateVecExpr,
11056
10346
  _getHexagonResolution,
11057
- getLog10ScaleSteps as _getLog10ScaleSteps,
11058
- getRasterTileLayerStyleProps as _getRasterTileLayerStyleProps,
11059
- validateVecExprSyntax as _validateVecExprSyntax,
11060
10347
  addFilter,
11061
10348
  aggregate,
11062
10349
  aggregationFunctions,
@@ -11069,11 +10356,9 @@ export {
11069
10356
  buildStatsUrl,
11070
10357
  calculateClusterRadius,
11071
10358
  calculateClusterTextFontSize,
11072
- calculateLayerScale,
11073
10359
  clearDefaultRequestCache,
11074
10360
  clearFilters,
11075
10361
  configureSource,
11076
- createColorScale,
11077
10362
  createPolygonSpatialFilter,
11078
10363
  createViewportSpatialFilter,
11079
10364
  fetchBasemapProps,
@@ -11088,7 +10373,6 @@ export {
11088
10373
  getDefaultAggregationExpColumnAliasForLayerType,
11089
10374
  getFilter,
11090
10375
  getIconUrlAccessor,
11091
- getLayerDescriptor,
11092
10376
  getLayerProps,
11093
10377
  getMaxMarkerSize,
11094
10378
  getSizeAccessor,
@@ -11119,6 +10403,8 @@ export {
11119
10403
  tileFeatures,
11120
10404
  tileFeaturesGeometries,
11121
10405
  tileFeaturesSpatialIndex,
10406
+ trajectoryQuerySource,
10407
+ trajectoryTableSource,
11122
10408
  transformToTileCoords,
11123
10409
  vectorQuerySource,
11124
10410
  vectorTableSource,