@nextgis/ngw-map 1.18.9 → 1.18.10
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/lib/ngw-map.cjs.js +1 -1
- package/lib/ngw-map.esm-browser.js +102 -91
- package/lib/ngw-map.esm-browser.js.map +1 -1
- package/lib/ngw-map.esm-browser.prod.js +1 -1
- package/lib/ngw-map.esm-browser.prod.js.map +1 -1
- package/lib/ngw-map.esm-bundler.js +1 -1
- package/lib/ngw-map.global.js +103 -92
- package/lib/ngw-map.global.js.map +1 -1
- package/lib/ngw-map.global.prod.js +1 -1
- package/lib/ngw-map.global.prod.js.map +1 -1
- package/package.json +6 -6
package/lib/ngw-map.cjs.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
/** Bundle of @nextgis/ngw-map; version: 1.18.
|
|
1
|
+
/** Bundle of @nextgis/ngw-map; version: 1.18.10; author: NextGIS */
|
|
2
2
|
var events = {exports: {}};
|
|
3
3
|
|
|
4
4
|
var R = typeof Reflect === 'object' ? Reflect : null;
|
|
@@ -1210,6 +1210,13 @@ function fallback(cb) {
|
|
|
1210
1210
|
};
|
|
1211
1211
|
}
|
|
1212
1212
|
|
|
1213
|
+
function evaluateArgs(cb) {
|
|
1214
|
+
return (args, data) => {
|
|
1215
|
+
const unwrap = args.map((a) => a());
|
|
1216
|
+
return cb(unwrap, data);
|
|
1217
|
+
};
|
|
1218
|
+
}
|
|
1219
|
+
|
|
1213
1220
|
const array = (args) => {
|
|
1214
1221
|
const [firstArg, secondArg, thirdArg] = args;
|
|
1215
1222
|
let requiredType = undefined;
|
|
@@ -1241,46 +1248,46 @@ const array = (args) => {
|
|
|
1241
1248
|
return value;
|
|
1242
1249
|
};
|
|
1243
1250
|
const typeExpressions = {
|
|
1244
|
-
array,
|
|
1245
|
-
boolean: fallback((arg) => (typeof arg === 'boolean' ? arg : undefined)),
|
|
1246
|
-
literal: ([arg]) => arg,
|
|
1247
|
-
number: fallback((arg) => (typeof arg === 'number' ? arg : undefined)),
|
|
1248
|
-
object: fallback((arg) => arg !== null && typeof arg === 'object' && !Array.isArray(arg)
|
|
1251
|
+
array: evaluateArgs(array),
|
|
1252
|
+
boolean: evaluateArgs(fallback((arg) => (typeof arg === 'boolean' ? arg : undefined))),
|
|
1253
|
+
literal: evaluateArgs(([arg]) => arg),
|
|
1254
|
+
number: evaluateArgs(fallback((arg) => (typeof arg === 'number' ? arg : undefined))),
|
|
1255
|
+
object: evaluateArgs(fallback((arg) => arg !== null && typeof arg === 'object' && !Array.isArray(arg)
|
|
1249
1256
|
? arg
|
|
1250
|
-
: undefined),
|
|
1251
|
-
string: fallback((arg) => (typeof arg === 'string' ? arg : undefined)),
|
|
1252
|
-
'to-boolean': fallback(Boolean),
|
|
1253
|
-
'to-number': fallback(Number),
|
|
1254
|
-
'to-string': fallback(String),
|
|
1255
|
-
typeof: ([arg]) => typeof arg,
|
|
1257
|
+
: undefined)),
|
|
1258
|
+
string: evaluateArgs(fallback((arg) => (typeof arg === 'string' ? arg : undefined))),
|
|
1259
|
+
'to-boolean': evaluateArgs(fallback(Boolean)),
|
|
1260
|
+
'to-number': evaluateArgs(fallback(Number)),
|
|
1261
|
+
'to-string': evaluateArgs(fallback(String)),
|
|
1262
|
+
typeof: evaluateArgs(([arg]) => typeof arg),
|
|
1256
1263
|
};
|
|
1257
1264
|
|
|
1258
1265
|
const mathExpressions = {
|
|
1259
|
-
'+': (args) => args.reduce((a, b) => a + b, 0),
|
|
1260
|
-
'-': (args) => args.reduce((a, b) => a - b),
|
|
1261
|
-
'*': (args) => args.reduce((a, b) => a * b, 1),
|
|
1262
|
-
'/': (args) => args.reduce((a, b) => a / b),
|
|
1263
|
-
'%': (args) => args[0] % args[1],
|
|
1264
|
-
'^': (args) => Math.pow(args[0], args[1]),
|
|
1265
|
-
abs: (args) => Math.abs(args[0]),
|
|
1266
|
-
acos: (args) => Math.acos(args[0]),
|
|
1267
|
-
asin: (args) => Math.asin(args[0]),
|
|
1268
|
-
atan: (args) => Math.atan(args[0]),
|
|
1269
|
-
ceil: (args) => Math.ceil(args[0]),
|
|
1270
|
-
cos: (args) => Math.cos(args[0]),
|
|
1266
|
+
'+': evaluateArgs((args) => args.reduce((a, b) => a + b, 0)),
|
|
1267
|
+
'-': evaluateArgs((args) => args.reduce((a, b) => a - b)),
|
|
1268
|
+
'*': evaluateArgs((args) => args.reduce((a, b) => a * b, 1)),
|
|
1269
|
+
'/': evaluateArgs((args) => args.reduce((a, b) => a / b)),
|
|
1270
|
+
'%': evaluateArgs((args) => args[0] % args[1]),
|
|
1271
|
+
'^': evaluateArgs((args) => Math.pow(args[0], args[1])),
|
|
1272
|
+
abs: evaluateArgs((args) => Math.abs(args[0])),
|
|
1273
|
+
acos: evaluateArgs((args) => Math.acos(args[0])),
|
|
1274
|
+
asin: evaluateArgs((args) => Math.asin(args[0])),
|
|
1275
|
+
atan: evaluateArgs((args) => Math.atan(args[0])),
|
|
1276
|
+
ceil: evaluateArgs((args) => Math.ceil(args[0])),
|
|
1277
|
+
cos: evaluateArgs((args) => Math.cos(args[0])),
|
|
1271
1278
|
e: () => Math.E,
|
|
1272
|
-
floor: (args) => Math.floor(args[0]),
|
|
1273
|
-
ln: (args) => Math.log(args[0]),
|
|
1279
|
+
floor: evaluateArgs((args) => Math.floor(args[0])),
|
|
1280
|
+
ln: evaluateArgs((args) => Math.log(args[0])),
|
|
1274
1281
|
ln2: () => Math.LN2,
|
|
1275
|
-
log10: (args) => Math.log10(args[0]),
|
|
1276
|
-
log2: (args) => Math.log2(args[0]),
|
|
1277
|
-
max: (args) => Math.max(...args),
|
|
1278
|
-
min: (args) => Math.min(...args),
|
|
1282
|
+
log10: evaluateArgs((args) => Math.log10(args[0])),
|
|
1283
|
+
log2: evaluateArgs((args) => Math.log2(args[0])),
|
|
1284
|
+
max: evaluateArgs((args) => Math.max(...args)),
|
|
1285
|
+
min: evaluateArgs((args) => Math.min(...args)),
|
|
1279
1286
|
pi: () => Math.PI,
|
|
1280
|
-
round: (args) => Math.round(args[0]),
|
|
1281
|
-
sin: (args) => Math.sin(args[0]),
|
|
1282
|
-
sqrt: (args) => Math.sqrt(args[0]),
|
|
1283
|
-
tan: (args) => Math.tan(args[0]),
|
|
1287
|
+
round: evaluateArgs((args) => Math.round(args[0])),
|
|
1288
|
+
sin: evaluateArgs((args) => Math.sin(args[0])),
|
|
1289
|
+
sqrt: evaluateArgs((args) => Math.sqrt(args[0])),
|
|
1290
|
+
tan: evaluateArgs((args) => Math.tan(args[0])),
|
|
1284
1291
|
};
|
|
1285
1292
|
|
|
1286
1293
|
function get([key, objExp], data) {
|
|
@@ -1332,19 +1339,19 @@ function slice(args) {
|
|
|
1332
1339
|
throw new Error(`Invalid input type for 'slice'. Expected string or array, got ${typeof input}.`);
|
|
1333
1340
|
}
|
|
1334
1341
|
const lookupExpressions = {
|
|
1335
|
-
get,
|
|
1336
|
-
length,
|
|
1337
|
-
at,
|
|
1338
|
-
has,
|
|
1339
|
-
in: inFunc,
|
|
1340
|
-
'index-of': indexOf,
|
|
1341
|
-
slice,
|
|
1342
|
+
get: evaluateArgs(get),
|
|
1343
|
+
length: evaluateArgs(length),
|
|
1344
|
+
at: evaluateArgs(at),
|
|
1345
|
+
has: evaluateArgs(has),
|
|
1346
|
+
in: evaluateArgs(inFunc),
|
|
1347
|
+
'index-of': evaluateArgs(indexOf),
|
|
1348
|
+
slice: evaluateArgs(slice),
|
|
1342
1349
|
};
|
|
1343
1350
|
|
|
1344
1351
|
const stringExpressions = {
|
|
1345
|
-
concat: (args) => args.reduce((a, b) => String(a) + String(b), ''),
|
|
1346
|
-
downcase: (args) => String(args[0]).toLowerCase(),
|
|
1347
|
-
upcase: (args) => String(args[0]).toUpperCase(),
|
|
1352
|
+
concat: evaluateArgs((args) => args.reduce((a, b) => String(a) + String(b), '')),
|
|
1353
|
+
downcase: evaluateArgs((args) => String(args[0]).toLowerCase()),
|
|
1354
|
+
upcase: evaluateArgs((args) => String(args[0]).toUpperCase()),
|
|
1348
1355
|
};
|
|
1349
1356
|
|
|
1350
1357
|
function not([expr]) {
|
|
@@ -1379,85 +1386,87 @@ function greaterThanOrEqual([left, right]) {
|
|
|
1379
1386
|
checkCompareValues([left, right]);
|
|
1380
1387
|
return left >= right;
|
|
1381
1388
|
}
|
|
1382
|
-
|
|
1389
|
+
const all = (args) => {
|
|
1383
1390
|
for (let i = 0; i < args.length; i++) {
|
|
1384
|
-
const arg = args[i];
|
|
1391
|
+
const arg = args[i]();
|
|
1385
1392
|
if (!arg) {
|
|
1386
1393
|
return false;
|
|
1387
1394
|
}
|
|
1388
1395
|
}
|
|
1389
1396
|
return true;
|
|
1390
|
-
}
|
|
1391
|
-
|
|
1397
|
+
};
|
|
1398
|
+
const any = (args) => {
|
|
1392
1399
|
for (let i = 0; i < args.length; i++) {
|
|
1393
|
-
const arg = args[i];
|
|
1400
|
+
const arg = args[i]();
|
|
1394
1401
|
if (arg) {
|
|
1395
1402
|
return true;
|
|
1396
1403
|
}
|
|
1397
1404
|
}
|
|
1398
1405
|
return false;
|
|
1399
|
-
}
|
|
1400
|
-
|
|
1401
|
-
const [
|
|
1406
|
+
};
|
|
1407
|
+
const match = (args) => {
|
|
1408
|
+
const [lookupFn, ...cases] = args;
|
|
1409
|
+
const lookup = lookupFn();
|
|
1402
1410
|
// remove last odd item from cases array
|
|
1403
1411
|
const defValue = cases.splice(-1, cases.length % 2)[0];
|
|
1404
1412
|
for (let fry = 0; fry < cases.length - 1; fry += 2) {
|
|
1405
|
-
const key = cases[fry];
|
|
1413
|
+
const key = cases[fry]();
|
|
1406
1414
|
if (key === lookup) {
|
|
1407
|
-
return cases[fry + 1];
|
|
1415
|
+
return cases[fry + 1]();
|
|
1408
1416
|
}
|
|
1409
1417
|
}
|
|
1410
|
-
return defValue;
|
|
1411
|
-
}
|
|
1412
|
-
|
|
1418
|
+
return defValue();
|
|
1419
|
+
};
|
|
1420
|
+
const caseFunc = (args) => {
|
|
1413
1421
|
if (args.length < 2) {
|
|
1414
1422
|
throw new Error('The "case" function requires at least a condition and a corresponding output.');
|
|
1415
1423
|
}
|
|
1416
|
-
const fallback = args[args.length - 1];
|
|
1417
1424
|
if (args.length % 2 === 0) {
|
|
1418
1425
|
throw new Error('Missing a fallback value or unmatched condition-output pair.');
|
|
1419
1426
|
}
|
|
1420
1427
|
for (let i = 0; i < args.length - 1; i += 2) {
|
|
1421
|
-
const condition = args[i];
|
|
1422
|
-
const value = args[i + 1];
|
|
1428
|
+
const condition = args[i]();
|
|
1429
|
+
const value = args[i + 1]();
|
|
1423
1430
|
if (condition) {
|
|
1424
1431
|
return value;
|
|
1425
1432
|
}
|
|
1426
1433
|
}
|
|
1427
|
-
|
|
1428
|
-
|
|
1434
|
+
const fallback = args[args.length - 1];
|
|
1435
|
+
return fallback();
|
|
1436
|
+
};
|
|
1429
1437
|
const decisionExpressions = {
|
|
1430
|
-
'!': not,
|
|
1431
|
-
'!=': notEqual,
|
|
1432
|
-
'<': lessThan,
|
|
1433
|
-
'<=': lessThanOrEqual,
|
|
1434
|
-
'==': equal,
|
|
1435
|
-
'>': greaterThan,
|
|
1436
|
-
'>=': greaterThanOrEqual,
|
|
1437
|
-
all
|
|
1438
|
-
any
|
|
1438
|
+
'!': evaluateArgs(not),
|
|
1439
|
+
'!=': evaluateArgs(notEqual),
|
|
1440
|
+
'<': evaluateArgs(lessThan),
|
|
1441
|
+
'<=': evaluateArgs(lessThanOrEqual),
|
|
1442
|
+
'==': evaluateArgs(equal),
|
|
1443
|
+
'>': evaluateArgs(greaterThan),
|
|
1444
|
+
'>=': evaluateArgs(greaterThanOrEqual),
|
|
1445
|
+
all,
|
|
1446
|
+
any,
|
|
1439
1447
|
case: caseFunc,
|
|
1440
1448
|
match,
|
|
1441
1449
|
};
|
|
1442
1450
|
|
|
1443
|
-
|
|
1444
|
-
const [
|
|
1451
|
+
const step = (args) => {
|
|
1452
|
+
const [inputFn, defaultValue, ...stops] = args;
|
|
1453
|
+
const input = inputFn();
|
|
1445
1454
|
if (typeof input !== 'number') {
|
|
1446
|
-
return defaultValue;
|
|
1455
|
+
return defaultValue();
|
|
1447
1456
|
}
|
|
1448
1457
|
for (let i = 0; i < stops.length - 2; i += 2) {
|
|
1449
|
-
const stopInput = stops[i];
|
|
1450
|
-
const stopOutput = stops[i + 1];
|
|
1451
|
-
const nextStopInput = stops[i + 2];
|
|
1458
|
+
const stopInput = stops[i]();
|
|
1459
|
+
const stopOutput = stops[i + 1]();
|
|
1460
|
+
const nextStopInput = stops[i + 2]();
|
|
1452
1461
|
if (input >= stopInput && input < nextStopInput) {
|
|
1453
1462
|
return stopOutput;
|
|
1454
1463
|
}
|
|
1455
1464
|
}
|
|
1456
|
-
if (input >= stops[stops.length - 2]) {
|
|
1457
|
-
return stops[stops.length - 1];
|
|
1465
|
+
if (input >= stops[stops.length - 2]()) {
|
|
1466
|
+
return stops[stops.length - 1]();
|
|
1458
1467
|
}
|
|
1459
|
-
return defaultValue;
|
|
1460
|
-
}
|
|
1468
|
+
return defaultValue();
|
|
1469
|
+
};
|
|
1461
1470
|
|
|
1462
1471
|
const COLORS = {
|
|
1463
1472
|
aliceblue: '#f0f8ff',
|
|
@@ -1726,21 +1735,23 @@ function linearInterpolation(input, input1, output1, input2, output2) {
|
|
|
1726
1735
|
}
|
|
1727
1736
|
throw new Error('Unsupported output type for linear interpolation.');
|
|
1728
1737
|
}
|
|
1729
|
-
|
|
1738
|
+
const interpolate = ([interpolationFn, inputFn, ...stops]) => {
|
|
1730
1739
|
if (stops.length < 2) {
|
|
1731
1740
|
throw new Error('At least two stops are required');
|
|
1732
1741
|
}
|
|
1733
|
-
if (typeof input !== 'number') {
|
|
1734
|
-
throw new Error('Input must be a number.');
|
|
1735
|
-
}
|
|
1736
1742
|
if (stops.length < 2 || stops.length % 2 !== 0) {
|
|
1737
1743
|
throw new Error('Invalid stops provided.');
|
|
1738
1744
|
}
|
|
1745
|
+
const input = inputFn();
|
|
1746
|
+
if (typeof input !== 'number') {
|
|
1747
|
+
throw new Error('Input must be a number.');
|
|
1748
|
+
}
|
|
1749
|
+
const interpolation = interpolationFn();
|
|
1739
1750
|
for (let i = 0; i < stops.length - 2; i += 2) {
|
|
1740
|
-
const stopInput1 = stops[i];
|
|
1741
|
-
const stopOutput1 = stops[i + 1];
|
|
1742
|
-
const stopInput2 = stops[i + 2];
|
|
1743
|
-
const stopOutput2 = stops[i + 3];
|
|
1751
|
+
const stopInput1 = stops[i]();
|
|
1752
|
+
const stopOutput1 = stops[i + 1]();
|
|
1753
|
+
const stopInput2 = stops[i + 2]();
|
|
1754
|
+
const stopOutput2 = stops[i + 3]();
|
|
1744
1755
|
if (input >= stopInput1 && input <= stopInput2) {
|
|
1745
1756
|
if (interpolation[0] === 'linear') {
|
|
1746
1757
|
return linearInterpolation(input, stopInput1, stopOutput1, stopInput2, stopOutput2);
|
|
@@ -1759,7 +1770,7 @@ function interpolate([interpolation, input, ...stops]) {
|
|
|
1759
1770
|
}
|
|
1760
1771
|
}
|
|
1761
1772
|
throw new Error('Invalid interpolation type.');
|
|
1762
|
-
}
|
|
1773
|
+
};
|
|
1763
1774
|
|
|
1764
1775
|
const interpolationExpressions = {
|
|
1765
1776
|
step,
|
|
@@ -1789,7 +1800,7 @@ function evaluate(expression, data = {}) {
|
|
|
1789
1800
|
const [name, ...args] = expression;
|
|
1790
1801
|
const expressionFun = expressions[name];
|
|
1791
1802
|
if (expressionFun) {
|
|
1792
|
-
return expressionFun(args.map((arg) => (isExpression(arg) ? evaluate(arg, data) : arg)
|
|
1803
|
+
return expressionFun(args.map((arg) => () => isExpression(arg) ? evaluate(arg, data) : arg), data);
|
|
1793
1804
|
}
|
|
1794
1805
|
throw new Error(`Expression "${name}" is not supported.`);
|
|
1795
1806
|
}
|