@carto/api-client 0.5.15-alpha.raster-5 → 0.5.16
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.
- package/CHANGELOG.md +9 -0
- package/build/api-client.cjs +325 -979
- package/build/api-client.cjs.map +1 -1
- package/build/api-client.d.cts +87 -154
- package/build/api-client.d.ts +87 -154
- package/build/api-client.js +319 -965
- package/build/api-client.js.map +1 -1
- package/build/worker-compat.js +1395 -1276
- package/build/worker-compat.js.map +1 -1
- package/build/worker.js +34 -0
- package/build/worker.js.map +1 -1
- package/package.json +3 -5
- package/src/fetch-map/basemap-styles.ts +1 -1
- package/src/fetch-map/index.ts +1 -6
- package/src/fetch-map/layer-map.ts +40 -130
- package/src/fetch-map/parse-map.ts +165 -284
- package/src/fetch-map/types.ts +7 -21
- package/src/fetch-map/utils.ts +0 -56
- package/src/index.ts +1 -7
- package/src/models/model.ts +1 -0
- package/src/sources/index.ts +12 -0
- package/src/sources/trajectory-query-source.ts +101 -0
- package/src/sources/trajectory-table-source.ts +96 -0
- package/src/sources/types.ts +12 -53
- package/src/widget-sources/types.ts +29 -1
- package/src/widget-sources/widget-remote-source.ts +30 -0
- package/src/widget-sources/widget-source.ts +11 -0
- package/src/widget-sources/widget-tileset-source-impl.ts +49 -0
- package/src/widget-sources/widget-tileset-source.ts +13 -0
- package/src/workers/constants.ts +1 -0
- package/src/fetch-map/raster-layer.ts +0 -536
- package/src/fetch-map/vec-expr-evaluator.ts +0 -374
package/build/api-client.js
CHANGED
|
@@ -6152,7 +6152,8 @@ var AVAILABLE_MODELS = [
|
|
|
6152
6152
|
"timeseries",
|
|
6153
6153
|
"range",
|
|
6154
6154
|
"scatterplot",
|
|
6155
|
-
"table"
|
|
6155
|
+
"table",
|
|
6156
|
+
"aggregations"
|
|
6156
6157
|
];
|
|
6157
6158
|
var { V3 } = ApiVersion;
|
|
6158
6159
|
var REQUEST_GET_MAX_URL_LENGTH = 2048;
|
|
@@ -6593,6 +6594,30 @@ var WidgetRemoteSource = class extends WidgetSource {
|
|
|
6593
6594
|
categories: res.metadata?.categories
|
|
6594
6595
|
}));
|
|
6595
6596
|
}
|
|
6597
|
+
async getAggregations(options) {
|
|
6598
|
+
const {
|
|
6599
|
+
signal,
|
|
6600
|
+
filters = this.props.filters,
|
|
6601
|
+
filterOwner,
|
|
6602
|
+
spatialFilter,
|
|
6603
|
+
spatialFiltersMode,
|
|
6604
|
+
aggregations
|
|
6605
|
+
} = options;
|
|
6606
|
+
return executeModel({
|
|
6607
|
+
model: "aggregations",
|
|
6608
|
+
source: {
|
|
6609
|
+
...this.getModelSource(filters, filterOwner),
|
|
6610
|
+
spatialFiltersMode,
|
|
6611
|
+
spatialFilter
|
|
6612
|
+
},
|
|
6613
|
+
params: {
|
|
6614
|
+
aggregations
|
|
6615
|
+
},
|
|
6616
|
+
opts: { signal, headers: this.props.headers }
|
|
6617
|
+
}).then((res) => ({
|
|
6618
|
+
rows: res.rows.map((row) => normalizeObjectKeys(row))
|
|
6619
|
+
}));
|
|
6620
|
+
}
|
|
6596
6621
|
/** @experimental */
|
|
6597
6622
|
async getExtent(options = {}) {
|
|
6598
6623
|
const { signal, filters = this.props.filters, filterOwner } = options;
|
|
@@ -7392,6 +7417,7 @@ var WidgetTilesetSourceImpl = class extends WidgetSource {
|
|
|
7392
7417
|
assertColumn(this._features, column);
|
|
7393
7418
|
}
|
|
7394
7419
|
const targetOperation = aggregationFunctions[operation2];
|
|
7420
|
+
assert2(targetOperation, `Unsupported aggregation operation: ${operation2}`);
|
|
7395
7421
|
return {
|
|
7396
7422
|
value: targetOperation(filteredFeatures, column, joinOperation)
|
|
7397
7423
|
};
|
|
@@ -7590,6 +7616,39 @@ var WidgetTilesetSourceImpl = class extends WidgetSource {
|
|
|
7590
7616
|
max: aggregationFunctions.max(filteredFeatures, column)
|
|
7591
7617
|
};
|
|
7592
7618
|
}
|
|
7619
|
+
async getAggregations({
|
|
7620
|
+
aggregations,
|
|
7621
|
+
filters,
|
|
7622
|
+
filterOwner,
|
|
7623
|
+
spatialFilter
|
|
7624
|
+
}) {
|
|
7625
|
+
const filteredFeatures = this._getFilteredFeatures(
|
|
7626
|
+
spatialFilter,
|
|
7627
|
+
filters,
|
|
7628
|
+
filterOwner
|
|
7629
|
+
);
|
|
7630
|
+
if (!this._features.length) {
|
|
7631
|
+
return { rows: [] };
|
|
7632
|
+
}
|
|
7633
|
+
assert2(
|
|
7634
|
+
typeof aggregations !== "string",
|
|
7635
|
+
"Unsupported tileset SQL aggregation"
|
|
7636
|
+
);
|
|
7637
|
+
const result = {};
|
|
7638
|
+
const usedAliases = /* @__PURE__ */ new Set();
|
|
7639
|
+
for (const { column, operation: operation2, alias } of aggregations) {
|
|
7640
|
+
if (column && column !== "*" || operation2 !== AggregationTypes.Count) {
|
|
7641
|
+
assertColumn(this._features, column);
|
|
7642
|
+
}
|
|
7643
|
+
const aliasKey = alias.toLowerCase();
|
|
7644
|
+
assert2(!usedAliases.has(aliasKey), `Duplicate alias: ${aliasKey}`);
|
|
7645
|
+
usedAliases.add(aliasKey);
|
|
7646
|
+
const targetOperation = aggregationFunctions[operation2];
|
|
7647
|
+
assert2(targetOperation, `Unsupported operation: ${operation2}`);
|
|
7648
|
+
result[alias] = targetOperation(filteredFeatures, column);
|
|
7649
|
+
}
|
|
7650
|
+
return { rows: [result] };
|
|
7651
|
+
}
|
|
7593
7652
|
/** @experimental */
|
|
7594
7653
|
async getExtent() {
|
|
7595
7654
|
return Promise.reject(new Error("not implemented"));
|
|
@@ -7824,6 +7883,16 @@ var WidgetTilesetSource = class extends WidgetSource {
|
|
|
7824
7883
|
}) {
|
|
7825
7884
|
return this._executeWorkerMethod("getRange" /* GET_RANGE */, [options], signal);
|
|
7826
7885
|
}
|
|
7886
|
+
async getAggregations({
|
|
7887
|
+
signal,
|
|
7888
|
+
...options
|
|
7889
|
+
}) {
|
|
7890
|
+
return this._executeWorkerMethod(
|
|
7891
|
+
"getAggregations" /* GET_AGGREGATIONS */,
|
|
7892
|
+
[options],
|
|
7893
|
+
signal
|
|
7894
|
+
);
|
|
7895
|
+
}
|
|
7827
7896
|
/** @experimental */
|
|
7828
7897
|
async getExtent() {
|
|
7829
7898
|
return Promise.resolve({
|
|
@@ -8177,6 +8246,102 @@ var vectorTilesetSource = async function(options) {
|
|
|
8177
8246
|
);
|
|
8178
8247
|
};
|
|
8179
8248
|
|
|
8249
|
+
// src/sources/trajectory-query-source.ts
|
|
8250
|
+
var trajectoryQuerySource = async function(options) {
|
|
8251
|
+
const {
|
|
8252
|
+
columns,
|
|
8253
|
+
spatialDataColumn = DEFAULT_GEO_COLUMN,
|
|
8254
|
+
sqlQuery,
|
|
8255
|
+
tileResolution = DEFAULT_TILE_RESOLUTION,
|
|
8256
|
+
queryParameters,
|
|
8257
|
+
aggregationExp,
|
|
8258
|
+
trajectoryIdColumn,
|
|
8259
|
+
timestampColumn
|
|
8260
|
+
} = options;
|
|
8261
|
+
const spatialDataType = "trajectory";
|
|
8262
|
+
const urlParameters = {
|
|
8263
|
+
spatialDataColumn,
|
|
8264
|
+
spatialDataType,
|
|
8265
|
+
tileResolution: tileResolution.toString(),
|
|
8266
|
+
q: sqlQuery,
|
|
8267
|
+
trajectoryIdColumn,
|
|
8268
|
+
timestampColumn
|
|
8269
|
+
};
|
|
8270
|
+
if (columns) {
|
|
8271
|
+
urlParameters.columns = columns.join(",");
|
|
8272
|
+
}
|
|
8273
|
+
if (queryParameters) {
|
|
8274
|
+
urlParameters.queryParameters = queryParameters;
|
|
8275
|
+
}
|
|
8276
|
+
if (aggregationExp) {
|
|
8277
|
+
urlParameters.aggregationExp = aggregationExp;
|
|
8278
|
+
}
|
|
8279
|
+
const result = await baseSource(
|
|
8280
|
+
"query",
|
|
8281
|
+
options,
|
|
8282
|
+
urlParameters
|
|
8283
|
+
);
|
|
8284
|
+
const widgetSource = new WidgetQuerySource({
|
|
8285
|
+
...options,
|
|
8286
|
+
// NOTE: Parameters with default values above must be explicitly passed here.
|
|
8287
|
+
spatialDataColumn,
|
|
8288
|
+
spatialDataType,
|
|
8289
|
+
tileResolution
|
|
8290
|
+
});
|
|
8291
|
+
const timestampRange = await widgetSource.getRange({ column: timestampColumn });
|
|
8292
|
+
return {
|
|
8293
|
+
...result,
|
|
8294
|
+
widgetSource,
|
|
8295
|
+
timestampRange
|
|
8296
|
+
};
|
|
8297
|
+
};
|
|
8298
|
+
|
|
8299
|
+
// src/sources/trajectory-table-source.ts
|
|
8300
|
+
var trajectoryTableSource = async function(options) {
|
|
8301
|
+
const {
|
|
8302
|
+
columns,
|
|
8303
|
+
spatialDataColumn = DEFAULT_GEO_COLUMN,
|
|
8304
|
+
tableName,
|
|
8305
|
+
tileResolution = DEFAULT_TILE_RESOLUTION,
|
|
8306
|
+
aggregationExp,
|
|
8307
|
+
trajectoryIdColumn,
|
|
8308
|
+
timestampColumn
|
|
8309
|
+
} = options;
|
|
8310
|
+
const spatialDataType = "trajectory";
|
|
8311
|
+
const urlParameters = {
|
|
8312
|
+
name: tableName,
|
|
8313
|
+
spatialDataColumn,
|
|
8314
|
+
spatialDataType,
|
|
8315
|
+
tileResolution: tileResolution.toString(),
|
|
8316
|
+
trajectoryIdColumn,
|
|
8317
|
+
timestampColumn
|
|
8318
|
+
};
|
|
8319
|
+
if (columns) {
|
|
8320
|
+
urlParameters.columns = columns.join(",");
|
|
8321
|
+
}
|
|
8322
|
+
if (aggregationExp) {
|
|
8323
|
+
urlParameters.aggregationExp = aggregationExp;
|
|
8324
|
+
}
|
|
8325
|
+
const result = await baseSource(
|
|
8326
|
+
"table",
|
|
8327
|
+
options,
|
|
8328
|
+
urlParameters
|
|
8329
|
+
);
|
|
8330
|
+
const widgetSource = new WidgetTableSource({
|
|
8331
|
+
...options,
|
|
8332
|
+
// NOTE: Parameters with default values above must be explicitly passed here.
|
|
8333
|
+
spatialDataColumn,
|
|
8334
|
+
spatialDataType,
|
|
8335
|
+
tileResolution
|
|
8336
|
+
});
|
|
8337
|
+
const timestampRange = await widgetSource.getRange({ column: timestampColumn });
|
|
8338
|
+
return {
|
|
8339
|
+
...result,
|
|
8340
|
+
widgetSource,
|
|
8341
|
+
timestampRange
|
|
8342
|
+
};
|
|
8343
|
+
};
|
|
8344
|
+
|
|
8180
8345
|
// src/api/query.ts
|
|
8181
8346
|
var query = async function(options) {
|
|
8182
8347
|
const {
|
|
@@ -8335,250 +8500,6 @@ var basemap_styles_default = {
|
|
|
8335
8500
|
DARK_MATTER_NOLABELS: getStyleUrl("dark-matter-nolabels")
|
|
8336
8501
|
};
|
|
8337
8502
|
|
|
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
8503
|
// node_modules/d3-array/src/ascending.js
|
|
8583
8504
|
function ascending(a, b) {
|
|
8584
8505
|
return a == null || b == null ? NaN : a < b ? -1 : a > b ? 1 : a >= b ? 0 : NaN;
|
|
@@ -9157,37 +9078,6 @@ function formatDate(value) {
|
|
|
9157
9078
|
function formatTimestamp(value) {
|
|
9158
9079
|
return String(Math.floor(new Date(value).getTime() / 1e3));
|
|
9159
9080
|
}
|
|
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
9081
|
|
|
9192
9082
|
// src/fetch-map/layer-map.ts
|
|
9193
9083
|
var SCALE_FUNCS = {
|
|
@@ -9204,19 +9094,7 @@ var SCALE_FUNCS = {
|
|
|
9204
9094
|
function identity2(v2) {
|
|
9205
9095
|
return v2;
|
|
9206
9096
|
}
|
|
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
9097
|
var UNKNOWN_COLOR = "#868d91";
|
|
9219
|
-
var UNKNOWN_COLOR_RGB = hexToRGB(UNKNOWN_COLOR);
|
|
9220
9098
|
var OPACITY_MAP = {
|
|
9221
9099
|
getFillColor: "opacity",
|
|
9222
9100
|
getLineColor: "strokeOpacity",
|
|
@@ -9249,12 +9127,6 @@ var sharedPropMap = {
|
|
|
9249
9127
|
wireframe: "wireframe"
|
|
9250
9128
|
}
|
|
9251
9129
|
};
|
|
9252
|
-
var rasterPropsMap = {
|
|
9253
|
-
isVisible: "visible",
|
|
9254
|
-
visConfig: {
|
|
9255
|
-
opacity: "opacity"
|
|
9256
|
-
}
|
|
9257
|
-
};
|
|
9258
9130
|
var customMarkersPropsMap = {
|
|
9259
9131
|
color: "getIconColor",
|
|
9260
9132
|
visConfig: {
|
|
@@ -9298,12 +9170,6 @@ function getLayerProps(type, config2, dataset) {
|
|
|
9298
9170
|
`Outdated layer type: ${type}. Please open map in CARTO Builder to automatically migrate.`
|
|
9299
9171
|
);
|
|
9300
9172
|
}
|
|
9301
|
-
if (type === "raster") {
|
|
9302
|
-
return {
|
|
9303
|
-
propMap: rasterPropsMap,
|
|
9304
|
-
defaultProps: {}
|
|
9305
|
-
};
|
|
9306
|
-
}
|
|
9307
9173
|
let basePropMap = sharedPropMap;
|
|
9308
9174
|
if (config2.visConfig?.customMarkers) {
|
|
9309
9175
|
basePropMap = mergePropMaps(basePropMap, customMarkersPropsMap);
|
|
@@ -9324,19 +9190,16 @@ function getLayerProps(type, config2, dataset) {
|
|
|
9324
9190
|
}
|
|
9325
9191
|
function domainFromAttribute(attribute, scaleType, scaleLength) {
|
|
9326
9192
|
if (scaleType === "ordinal" || scaleType === "point") {
|
|
9327
|
-
if (!attribute.categories) {
|
|
9328
|
-
return [0, 1];
|
|
9329
|
-
}
|
|
9330
9193
|
return attribute.categories.map((c) => c.category).filter((c) => c !== void 0 && c !== null);
|
|
9331
9194
|
}
|
|
9332
9195
|
if (scaleType === "quantile" && attribute.quantiles) {
|
|
9333
|
-
return
|
|
9196
|
+
return attribute.quantiles.global ? attribute.quantiles.global[scaleLength] : attribute.quantiles[scaleLength];
|
|
9334
9197
|
}
|
|
9335
9198
|
let { min: min2 } = attribute;
|
|
9336
9199
|
if (scaleType === "log" && min2 === 0) {
|
|
9337
9200
|
min2 = 1e-5;
|
|
9338
9201
|
}
|
|
9339
|
-
return [min2
|
|
9202
|
+
return [min2, attribute.max];
|
|
9340
9203
|
}
|
|
9341
9204
|
function domainFromValues(values, scaleType) {
|
|
9342
9205
|
if (scaleType === "ordinal" || scaleType === "point") {
|
|
@@ -9357,14 +9220,12 @@ function calculateDomain(data, name, scaleType, scaleLength) {
|
|
|
9357
9220
|
if (data.tilestats) {
|
|
9358
9221
|
const { attributes } = data.tilestats.layers[0];
|
|
9359
9222
|
const attribute = attributes.find((a) => a.attribute === name);
|
|
9360
|
-
|
|
9361
|
-
return domainFromAttribute(attribute, scaleType, scaleLength);
|
|
9362
|
-
}
|
|
9223
|
+
return domainFromAttribute(attribute, scaleType, scaleLength);
|
|
9363
9224
|
}
|
|
9364
9225
|
return [0, 1];
|
|
9365
9226
|
}
|
|
9366
9227
|
function normalizeAccessor(accessor, data) {
|
|
9367
|
-
if (data.features || data.tilestats
|
|
9228
|
+
if (data.features || data.tilestats) {
|
|
9368
9229
|
return (object, info) => {
|
|
9369
9230
|
if (object) {
|
|
9370
9231
|
return accessor(object.properties || object.__source.object.properties);
|
|
@@ -9397,75 +9258,46 @@ function findAccessorKey(keys, properties) {
|
|
|
9397
9258
|
return keys;
|
|
9398
9259
|
}
|
|
9399
9260
|
function getColorAccessor({ name, colorColumn }, scaleType, { aggregation, range }, opacity, data) {
|
|
9400
|
-
const
|
|
9261
|
+
const scale2 = calculateLayerScale(
|
|
9401
9262
|
colorColumn || name,
|
|
9402
|
-
|
|
9263
|
+
scaleType,
|
|
9403
9264
|
range,
|
|
9404
9265
|
data
|
|
9405
9266
|
);
|
|
9406
9267
|
const alpha = opacityToAlpha(opacity);
|
|
9407
|
-
let accessorKeys = getAccessorKeys(
|
|
9268
|
+
let accessorKeys = getAccessorKeys(name, aggregation);
|
|
9408
9269
|
const accessor = (properties) => {
|
|
9409
9270
|
if (!(accessorKeys[0] in properties)) {
|
|
9410
9271
|
accessorKeys = findAccessorKey(accessorKeys, properties);
|
|
9411
9272
|
}
|
|
9412
9273
|
const propertyValue = properties[accessorKeys[0]];
|
|
9413
|
-
const
|
|
9414
|
-
|
|
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)
|
|
9274
|
+
const { r, g, b } = rgb(scale2(propertyValue));
|
|
9275
|
+
return [r, g, b, propertyValue === null ? 0 : alpha];
|
|
9422
9276
|
};
|
|
9277
|
+
return { accessor: normalizeAccessor(accessor, data), scale: scale2 };
|
|
9423
9278
|
}
|
|
9424
9279
|
function calculateLayerScale(name, scaleType, range, data) {
|
|
9280
|
+
const scale2 = SCALE_FUNCS[scaleType]();
|
|
9425
9281
|
let domain = [];
|
|
9426
|
-
let scaleDomain;
|
|
9427
9282
|
let scaleColor = [];
|
|
9428
|
-
|
|
9429
|
-
|
|
9430
|
-
|
|
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 = [];
|
|
9283
|
+
if (scaleType !== "identity") {
|
|
9284
|
+
const { colorMap, colors } = range;
|
|
9285
|
+
if (Array.isArray(colorMap)) {
|
|
9442
9286
|
colorMap.forEach(([value, color2]) => {
|
|
9443
|
-
|
|
9287
|
+
domain.push(value);
|
|
9444
9288
|
scaleColor.push(color2);
|
|
9445
9289
|
});
|
|
9290
|
+
} else {
|
|
9291
|
+
domain = calculateDomain(data, name, scaleType, colors.length);
|
|
9292
|
+
scaleColor = colors;
|
|
9446
9293
|
}
|
|
9447
|
-
} else if (scaleType !== "identity") {
|
|
9448
|
-
domain = calculateDomain(data, name, scaleType, colors.length);
|
|
9449
|
-
scaleColor = colors;
|
|
9450
9294
|
if (scaleType === "ordinal") {
|
|
9451
9295
|
domain = domain.slice(0, scaleColor.length);
|
|
9452
9296
|
}
|
|
9453
9297
|
}
|
|
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
9298
|
scale2.domain(domain);
|
|
9467
|
-
scale2.range(
|
|
9468
|
-
scale2.unknown(
|
|
9299
|
+
scale2.range(scaleColor);
|
|
9300
|
+
scale2.unknown(UNKNOWN_COLOR);
|
|
9469
9301
|
return scale2;
|
|
9470
9302
|
}
|
|
9471
9303
|
var FALLBACK_ICON = "data:image/svg+xml;charset=utf-8;base64,PHN2ZyB2aWV3Qm94PSIwIDAgMTAwIDEwMCIgeG1sbnM9Imh0dHA6Ly93d3cudzMub3JnLzIwMDAvc3ZnIj4NCiAgPGNpcmNsZSBjeD0iNTAiIGN5PSI1MCIgcj0iNTAiLz4NCjwvc3ZnPg==";
|
|
@@ -9515,13 +9347,9 @@ function negateAccessor(accessor) {
|
|
|
9515
9347
|
}
|
|
9516
9348
|
function getSizeAccessor({ name }, scaleType, aggregation, range, data) {
|
|
9517
9349
|
const scale2 = scaleType ? SCALE_FUNCS[scaleType]() : identity2;
|
|
9518
|
-
|
|
9519
|
-
if (scaleType && range) {
|
|
9350
|
+
if (scaleType) {
|
|
9520
9351
|
if (aggregation !== AggregationTypes.Count) {
|
|
9521
|
-
domain
|
|
9522
|
-
scale2.domain(domain);
|
|
9523
|
-
} else {
|
|
9524
|
-
domain = scale2.domain();
|
|
9352
|
+
scale2.domain(calculateDomain(data, name, scaleType));
|
|
9525
9353
|
}
|
|
9526
9354
|
scale2.range(range);
|
|
9527
9355
|
}
|
|
@@ -9533,12 +9361,7 @@ function getSizeAccessor({ name }, scaleType, aggregation, range, data) {
|
|
|
9533
9361
|
const propertyValue = properties[accessorKeys[0]];
|
|
9534
9362
|
return scale2(propertyValue);
|
|
9535
9363
|
};
|
|
9536
|
-
return {
|
|
9537
|
-
accessor: normalizeAccessor(accessor, data),
|
|
9538
|
-
domain,
|
|
9539
|
-
scaleDomain: domain,
|
|
9540
|
-
range
|
|
9541
|
-
};
|
|
9364
|
+
return { accessor: normalizeAccessor(accessor, data), scale: scale2 };
|
|
9542
9365
|
}
|
|
9543
9366
|
var FORMATS = {
|
|
9544
9367
|
date: formatDate,
|
|
@@ -9589,420 +9412,13 @@ function calculateClusterTextFontSize(radius) {
|
|
|
9589
9412
|
return 11;
|
|
9590
9413
|
}
|
|
9591
9414
|
|
|
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
9415
|
// 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
9416
|
function parseMap(json) {
|
|
10000
9417
|
const { keplerMapConfig, datasets, token } = json;
|
|
10001
9418
|
assert2(keplerMapConfig.version === "v1", "Only support Kepler v1");
|
|
10002
|
-
const
|
|
10003
|
-
const { mapState, mapStyle, popupSettings, legendSettings
|
|
10004
|
-
const { layers } = visState;
|
|
10005
|
-
const layersReverse = [...layers].reverse();
|
|
9419
|
+
const config2 = keplerMapConfig.config;
|
|
9420
|
+
const { filters, mapState, mapStyle, popupSettings, legendSettings } = config2;
|
|
9421
|
+
const { layers, layerBlending, interactionConfig } = config2.visState;
|
|
10006
9422
|
return {
|
|
10007
9423
|
id: json.id,
|
|
10008
9424
|
title: json.title,
|
|
@@ -10015,19 +9431,45 @@ function parseMap(json) {
|
|
|
10015
9431
|
popupSettings,
|
|
10016
9432
|
legendSettings,
|
|
10017
9433
|
token,
|
|
10018
|
-
layers:
|
|
9434
|
+
layers: layers.reverse().map(({ id, type, config: config3, visualChannels }) => {
|
|
10019
9435
|
try {
|
|
10020
|
-
const { dataId } =
|
|
9436
|
+
const { dataId } = config3;
|
|
10021
9437
|
const dataset = datasets.find(
|
|
10022
9438
|
(d) => d.id === dataId
|
|
10023
9439
|
);
|
|
10024
9440
|
assert2(dataset, `No dataset matching dataId: ${dataId}`);
|
|
10025
|
-
const
|
|
10026
|
-
|
|
10027
|
-
|
|
9441
|
+
const { data } = dataset;
|
|
9442
|
+
assert2(data, `No data loaded for dataId: ${dataId}`);
|
|
9443
|
+
const { propMap, defaultProps: defaultProps2 } = getLayerProps(type, config3, dataset);
|
|
9444
|
+
const styleProps = createStyleProps(config3, propMap);
|
|
9445
|
+
const { channelProps, scales } = createChannelProps(
|
|
9446
|
+
id,
|
|
9447
|
+
type,
|
|
9448
|
+
config3,
|
|
9449
|
+
visualChannels,
|
|
9450
|
+
data,
|
|
10028
9451
|
dataset
|
|
10029
|
-
|
|
10030
|
-
|
|
9452
|
+
);
|
|
9453
|
+
const layer = {
|
|
9454
|
+
type,
|
|
9455
|
+
filters: isEmptyObject(filters) || isRemoteCalculationSupported(dataset) ? void 0 : filters[dataId],
|
|
9456
|
+
props: {
|
|
9457
|
+
id,
|
|
9458
|
+
data,
|
|
9459
|
+
...defaultProps2,
|
|
9460
|
+
...createInteractionProps(interactionConfig),
|
|
9461
|
+
...styleProps,
|
|
9462
|
+
...channelProps,
|
|
9463
|
+
...createParametersProp(
|
|
9464
|
+
layerBlending,
|
|
9465
|
+
styleProps.parameters || {}
|
|
9466
|
+
),
|
|
9467
|
+
// Must come after style
|
|
9468
|
+
...createLoadOptions(token)
|
|
9469
|
+
},
|
|
9470
|
+
scales
|
|
9471
|
+
};
|
|
9472
|
+
return layer;
|
|
10031
9473
|
} catch (e) {
|
|
10032
9474
|
console.error(e.message);
|
|
10033
9475
|
return void 0;
|
|
@@ -10092,63 +9534,43 @@ function createStyleProps(config2, mapping) {
|
|
|
10092
9534
|
result.highlightColor = config2.visConfig.enable3d ? [255, 255, 255, 60] : [252, 242, 26, 255];
|
|
10093
9535
|
return result;
|
|
10094
9536
|
}
|
|
9537
|
+
function domainAndRangeFromScale(scale2) {
|
|
9538
|
+
return {
|
|
9539
|
+
domain: scale2.domain(),
|
|
9540
|
+
range: scale2.range()
|
|
9541
|
+
};
|
|
9542
|
+
}
|
|
10095
9543
|
function createChannelProps(id, layerType, config2, visualChannels, data, dataset) {
|
|
10096
|
-
|
|
10097
|
-
|
|
10098
|
-
|
|
10099
|
-
|
|
10100
|
-
|
|
10101
|
-
|
|
10102
|
-
|
|
10103
|
-
|
|
10104
|
-
|
|
10105
|
-
|
|
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
|
-
}
|
|
9544
|
+
const {
|
|
9545
|
+
colorField,
|
|
9546
|
+
colorScale,
|
|
9547
|
+
radiusField,
|
|
9548
|
+
radiusScale,
|
|
9549
|
+
strokeColorField,
|
|
9550
|
+
strokeColorScale,
|
|
9551
|
+
weightField
|
|
9552
|
+
} = visualChannels;
|
|
9553
|
+
const { heightField, heightScale } = visualChannels;
|
|
10128
9554
|
const { textLabel, visConfig } = config2;
|
|
10129
9555
|
const result = {};
|
|
10130
|
-
const updateTriggers = {};
|
|
10131
9556
|
const scales = {};
|
|
10132
|
-
{
|
|
10133
|
-
const {
|
|
10134
|
-
const {
|
|
10135
|
-
|
|
10136
|
-
|
|
10137
|
-
|
|
10138
|
-
|
|
10139
|
-
|
|
10140
|
-
|
|
10141
|
-
|
|
10142
|
-
|
|
10143
|
-
|
|
10144
|
-
|
|
10145
|
-
|
|
10146
|
-
|
|
10147
|
-
|
|
10148
|
-
|
|
10149
|
-
} else {
|
|
10150
|
-
scales.fillColor = {};
|
|
10151
|
-
}
|
|
9557
|
+
if (colorField) {
|
|
9558
|
+
const { colorAggregation: aggregation, colorRange: range } = visConfig;
|
|
9559
|
+
const { accessor, scale: scale2 } = getColorAccessor(
|
|
9560
|
+
colorField,
|
|
9561
|
+
colorScale,
|
|
9562
|
+
{ aggregation, range },
|
|
9563
|
+
visConfig.opacity,
|
|
9564
|
+
data
|
|
9565
|
+
);
|
|
9566
|
+
result.getFillColor = accessor;
|
|
9567
|
+
scales.fillColor = {
|
|
9568
|
+
field: colorField,
|
|
9569
|
+
type: colorScale,
|
|
9570
|
+
...domainAndRangeFromScale(scale2)
|
|
9571
|
+
};
|
|
9572
|
+
} else if (visConfig.filled) {
|
|
9573
|
+
scales.fillColor = {};
|
|
10152
9574
|
}
|
|
10153
9575
|
if (layerType === "clusterTile") {
|
|
10154
9576
|
const aggregationExpAlias = getDefaultAggregationExpColumnAliasForLayerType(
|
|
@@ -10161,7 +9583,6 @@ function createChannelProps(id, layerType, config2, visualChannels, data, datase
|
|
|
10161
9583
|
result.getWeight = (d) => {
|
|
10162
9584
|
return d.properties[aggregationExpAlias];
|
|
10163
9585
|
};
|
|
10164
|
-
updateTriggers.getWeight = aggregationExpAlias;
|
|
10165
9586
|
result.getPointRadius = (d, info) => {
|
|
10166
9587
|
return calculateClusterRadius(
|
|
10167
9588
|
d.properties,
|
|
@@ -10170,16 +9591,11 @@ function createChannelProps(id, layerType, config2, visualChannels, data, datase
|
|
|
10170
9591
|
aggregationExpAlias
|
|
10171
9592
|
);
|
|
10172
9593
|
};
|
|
10173
|
-
updateTriggers.getPointRadius = {
|
|
10174
|
-
aggregationExpAlias,
|
|
10175
|
-
radiusRange: visConfig.radiusRange
|
|
10176
|
-
};
|
|
10177
9594
|
result.textCharacterSet = "auto";
|
|
10178
9595
|
result.textFontFamily = "Inter, sans";
|
|
10179
9596
|
result.textFontSettings = { sdf: true };
|
|
10180
9597
|
result.textFontWeight = 600;
|
|
10181
9598
|
result.getText = (d) => TEXT_NUMBER_FORMATTER.format(d.properties[aggregationExpAlias]);
|
|
10182
|
-
updateTriggers.getText = aggregationExpAlias;
|
|
10183
9599
|
result.getTextColor = config2.textLabel[TEXT_LABEL_INDEX].color;
|
|
10184
9600
|
result.textOutlineColor = [
|
|
10185
9601
|
...config2.textLabel[TEXT_LABEL_INDEX].outlineColor,
|
|
@@ -10196,107 +9612,68 @@ function createChannelProps(id, layerType, config2, visualChannels, data, datase
|
|
|
10196
9612
|
);
|
|
10197
9613
|
return calculateClusterTextFontSize(radius);
|
|
10198
9614
|
};
|
|
10199
|
-
updateTriggers.getTextSize = {
|
|
10200
|
-
aggregationExpAlias,
|
|
10201
|
-
radiusRange: visConfig.radiusRange
|
|
10202
|
-
};
|
|
10203
9615
|
}
|
|
10204
|
-
{
|
|
10205
|
-
const
|
|
10206
|
-
|
|
10207
|
-
|
|
10208
|
-
|
|
10209
|
-
|
|
10210
|
-
|
|
10211
|
-
|
|
10212
|
-
|
|
10213
|
-
|
|
10214
|
-
|
|
10215
|
-
|
|
10216
|
-
|
|
10217
|
-
|
|
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
|
-
}
|
|
9616
|
+
if (radiusField) {
|
|
9617
|
+
const { accessor, scale: scale2 } = getSizeAccessor(
|
|
9618
|
+
radiusField,
|
|
9619
|
+
radiusScale,
|
|
9620
|
+
visConfig.sizeAggregation,
|
|
9621
|
+
visConfig.radiusRange || visConfig.sizeRange,
|
|
9622
|
+
data
|
|
9623
|
+
);
|
|
9624
|
+
result.getPointRadius = accessor;
|
|
9625
|
+
scales.pointRadius = {
|
|
9626
|
+
field: radiusField,
|
|
9627
|
+
type: radiusScale || "identity",
|
|
9628
|
+
...domainAndRangeFromScale(scale2)
|
|
9629
|
+
};
|
|
10243
9630
|
}
|
|
10244
|
-
{
|
|
10245
|
-
const
|
|
10246
|
-
const {
|
|
10247
|
-
|
|
10248
|
-
|
|
10249
|
-
|
|
10250
|
-
|
|
10251
|
-
|
|
10252
|
-
|
|
10253
|
-
|
|
10254
|
-
|
|
10255
|
-
|
|
10256
|
-
|
|
10257
|
-
|
|
10258
|
-
|
|
10259
|
-
|
|
10260
|
-
};
|
|
10261
|
-
}
|
|
9631
|
+
if (strokeColorField) {
|
|
9632
|
+
const opacity = visConfig.strokeOpacity !== void 0 ? visConfig.strokeOpacity : 1;
|
|
9633
|
+
const { strokeColorAggregation: aggregation, strokeColorRange: range } = visConfig;
|
|
9634
|
+
const { accessor, scale: scale2 } = getColorAccessor(
|
|
9635
|
+
strokeColorField,
|
|
9636
|
+
strokeColorScale,
|
|
9637
|
+
{ aggregation, range },
|
|
9638
|
+
opacity,
|
|
9639
|
+
data
|
|
9640
|
+
);
|
|
9641
|
+
result.getLineColor = accessor;
|
|
9642
|
+
scales.lineColor = {
|
|
9643
|
+
field: strokeColorField,
|
|
9644
|
+
type: strokeColorScale,
|
|
9645
|
+
...domainAndRangeFromScale(scale2)
|
|
9646
|
+
};
|
|
10262
9647
|
}
|
|
10263
|
-
{
|
|
10264
|
-
const {
|
|
10265
|
-
|
|
10266
|
-
|
|
10267
|
-
|
|
10268
|
-
|
|
10269
|
-
|
|
10270
|
-
|
|
10271
|
-
|
|
10272
|
-
|
|
10273
|
-
|
|
10274
|
-
|
|
10275
|
-
|
|
10276
|
-
|
|
10277
|
-
type: heightScale || "identity",
|
|
10278
|
-
...scaleProps
|
|
10279
|
-
};
|
|
10280
|
-
}
|
|
9648
|
+
if (heightField && visConfig.enable3d) {
|
|
9649
|
+
const { accessor, scale: scale2 } = getSizeAccessor(
|
|
9650
|
+
heightField,
|
|
9651
|
+
heightScale,
|
|
9652
|
+
visConfig.heightAggregation,
|
|
9653
|
+
visConfig.heightRange || visConfig.sizeRange,
|
|
9654
|
+
data
|
|
9655
|
+
);
|
|
9656
|
+
result.getElevation = accessor;
|
|
9657
|
+
scales.elevation = {
|
|
9658
|
+
field: heightField,
|
|
9659
|
+
type: heightScale || "identity",
|
|
9660
|
+
...domainAndRangeFromScale(scale2)
|
|
9661
|
+
};
|
|
10281
9662
|
}
|
|
10282
|
-
{
|
|
10283
|
-
const {
|
|
10284
|
-
|
|
10285
|
-
|
|
10286
|
-
|
|
10287
|
-
|
|
10288
|
-
|
|
10289
|
-
|
|
10290
|
-
|
|
10291
|
-
|
|
10292
|
-
|
|
10293
|
-
|
|
10294
|
-
|
|
10295
|
-
|
|
10296
|
-
type: "identity",
|
|
10297
|
-
...scaleProps
|
|
10298
|
-
};
|
|
10299
|
-
}
|
|
9663
|
+
if (weightField) {
|
|
9664
|
+
const { accessor, scale: scale2 } = getSizeAccessor(
|
|
9665
|
+
weightField,
|
|
9666
|
+
void 0,
|
|
9667
|
+
visConfig.weightAggregation,
|
|
9668
|
+
void 0,
|
|
9669
|
+
data
|
|
9670
|
+
);
|
|
9671
|
+
result.getWeight = accessor;
|
|
9672
|
+
scales.weight = {
|
|
9673
|
+
field: weightField,
|
|
9674
|
+
type: "identity",
|
|
9675
|
+
...domainAndRangeFromScale(scale2)
|
|
9676
|
+
};
|
|
10300
9677
|
}
|
|
10301
9678
|
if (visConfig.customMarkers) {
|
|
10302
9679
|
const maxIconSize = getMaxMarkerSize(visConfig, visualChannels);
|
|
@@ -10313,12 +9690,6 @@ function createChannelProps(id, layerType, config2, visualChannels, data, datase
|
|
|
10313
9690
|
{ fallbackUrl: customMarkersUrl, maxIconSize, useMaskedIcons },
|
|
10314
9691
|
data
|
|
10315
9692
|
);
|
|
10316
|
-
updateTriggers.getIcon = {
|
|
10317
|
-
customMarkersUrl,
|
|
10318
|
-
customMarkersRange,
|
|
10319
|
-
maxIconSize,
|
|
10320
|
-
useMaskedIcons
|
|
10321
|
-
};
|
|
10322
9693
|
result._subLayerProps = {
|
|
10323
9694
|
"points-icon": {
|
|
10324
9695
|
loadOptions: {
|
|
@@ -10335,11 +9706,9 @@ function createChannelProps(id, layerType, config2, visualChannels, data, datase
|
|
|
10335
9706
|
};
|
|
10336
9707
|
if (getFillColor && useMaskedIcons) {
|
|
10337
9708
|
result.getIconColor = getFillColor;
|
|
10338
|
-
updateTriggers.getIconColor = updateTriggers.getFillColor;
|
|
10339
9709
|
}
|
|
10340
9710
|
if (getPointRadius) {
|
|
10341
9711
|
result.getIconSize = getPointRadius;
|
|
10342
|
-
updateTriggers.getIconSize = updateTriggers.getPointRadius;
|
|
10343
9712
|
}
|
|
10344
9713
|
if (visualChannels.rotationField) {
|
|
10345
9714
|
const { accessor } = getSizeAccessor(
|
|
@@ -10350,7 +9719,6 @@ function createChannelProps(id, layerType, config2, visualChannels, data, datase
|
|
|
10350
9719
|
data
|
|
10351
9720
|
);
|
|
10352
9721
|
result.getIconAngle = negateAccessor(accessor);
|
|
10353
|
-
updateTriggers.getIconAngle = updateTriggers.getRotationField;
|
|
10354
9722
|
}
|
|
10355
9723
|
} else if (layerType === "tileset") {
|
|
10356
9724
|
result.pointType = "circle";
|
|
@@ -10395,13 +9763,7 @@ function createChannelProps(id, layerType, config2, visualChannels, data, datase
|
|
|
10395
9763
|
}
|
|
10396
9764
|
};
|
|
10397
9765
|
}
|
|
10398
|
-
return {
|
|
10399
|
-
channelProps: {
|
|
10400
|
-
...result,
|
|
10401
|
-
updateTriggers
|
|
10402
|
-
},
|
|
10403
|
-
scales
|
|
10404
|
-
};
|
|
9766
|
+
return { channelProps: result, scales };
|
|
10405
9767
|
}
|
|
10406
9768
|
function createLoadOptions(accessToken) {
|
|
10407
9769
|
return {
|
|
@@ -11048,16 +10410,9 @@ export {
|
|
|
11048
10410
|
WidgetSource,
|
|
11049
10411
|
WidgetTableSource,
|
|
11050
10412
|
WidgetTilesetSource,
|
|
11051
|
-
ErrorCode as _ErrorCode,
|
|
11052
|
-
applyLayerGroupFilters as _applyLayerGroupFilters,
|
|
11053
10413
|
_buildFeatureFilter,
|
|
11054
|
-
createVecExprEvaluator as _createVecExprEvaluator,
|
|
11055
10414
|
domainFromValues as _domainFromValues,
|
|
11056
|
-
evaluateVecExpr as _evaluateVecExpr,
|
|
11057
10415
|
_getHexagonResolution,
|
|
11058
|
-
getLog10ScaleSteps as _getLog10ScaleSteps,
|
|
11059
|
-
getRasterTileLayerStyleProps as _getRasterTileLayerStyleProps,
|
|
11060
|
-
validateVecExprSyntax as _validateVecExprSyntax,
|
|
11061
10416
|
addFilter,
|
|
11062
10417
|
aggregate,
|
|
11063
10418
|
aggregationFunctions,
|
|
@@ -11070,11 +10425,9 @@ export {
|
|
|
11070
10425
|
buildStatsUrl,
|
|
11071
10426
|
calculateClusterRadius,
|
|
11072
10427
|
calculateClusterTextFontSize,
|
|
11073
|
-
calculateLayerScale,
|
|
11074
10428
|
clearDefaultRequestCache,
|
|
11075
10429
|
clearFilters,
|
|
11076
10430
|
configureSource,
|
|
11077
|
-
createColorScale,
|
|
11078
10431
|
createPolygonSpatialFilter,
|
|
11079
10432
|
createViewportSpatialFilter,
|
|
11080
10433
|
fetchBasemapProps,
|
|
@@ -11089,7 +10442,6 @@ export {
|
|
|
11089
10442
|
getDefaultAggregationExpColumnAliasForLayerType,
|
|
11090
10443
|
getFilter,
|
|
11091
10444
|
getIconUrlAccessor,
|
|
11092
|
-
getLayerDescriptor,
|
|
11093
10445
|
getLayerProps,
|
|
11094
10446
|
getMaxMarkerSize,
|
|
11095
10447
|
getSizeAccessor,
|
|
@@ -11120,6 +10472,8 @@ export {
|
|
|
11120
10472
|
tileFeatures,
|
|
11121
10473
|
tileFeaturesGeometries,
|
|
11122
10474
|
tileFeaturesSpatialIndex,
|
|
10475
|
+
trajectoryQuerySource,
|
|
10476
|
+
trajectoryTableSource,
|
|
11123
10477
|
transformToTileCoords,
|
|
11124
10478
|
vectorQuerySource,
|
|
11125
10479
|
vectorTableSource,
|