@nextgis/ngw-map 1.18.9 → 1.18.11
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 +143 -102
- 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 +145 -105
- 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.11; 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;
|
|
@@ -1240,47 +1247,78 @@ const array = (args) => {
|
|
|
1240
1247
|
}
|
|
1241
1248
|
return value;
|
|
1242
1249
|
};
|
|
1250
|
+
function typeOfValue(value) {
|
|
1251
|
+
if (value === null)
|
|
1252
|
+
return 'null';
|
|
1253
|
+
switch (typeof value) {
|
|
1254
|
+
case 'string':
|
|
1255
|
+
return 'string';
|
|
1256
|
+
case 'number':
|
|
1257
|
+
return 'number';
|
|
1258
|
+
case 'boolean':
|
|
1259
|
+
return 'boolean';
|
|
1260
|
+
case 'object':
|
|
1261
|
+
if (Array.isArray(value)) {
|
|
1262
|
+
let arrayType = 'value';
|
|
1263
|
+
if (value.every((item) => typeof item === 'number')) {
|
|
1264
|
+
arrayType = 'number';
|
|
1265
|
+
}
|
|
1266
|
+
else if (value.every((item) => typeof item === 'string')) {
|
|
1267
|
+
arrayType = 'string';
|
|
1268
|
+
}
|
|
1269
|
+
else if (value.every((item) => typeof item === 'boolean')) {
|
|
1270
|
+
arrayType = 'boolean';
|
|
1271
|
+
}
|
|
1272
|
+
return `array<${arrayType}, ${value.length}>`;
|
|
1273
|
+
}
|
|
1274
|
+
else {
|
|
1275
|
+
return 'object';
|
|
1276
|
+
}
|
|
1277
|
+
default:
|
|
1278
|
+
return 'undefined';
|
|
1279
|
+
}
|
|
1280
|
+
}
|
|
1243
1281
|
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)
|
|
1282
|
+
array: evaluateArgs(array),
|
|
1283
|
+
boolean: evaluateArgs(fallback((arg) => (typeof arg === 'boolean' ? arg : undefined))),
|
|
1284
|
+
literal: evaluateArgs(([arg]) => arg),
|
|
1285
|
+
number: evaluateArgs(fallback((arg) => (typeof arg === 'number' ? arg : undefined))),
|
|
1286
|
+
object: evaluateArgs(fallback((arg) => arg !== null && typeof arg === 'object' && !Array.isArray(arg)
|
|
1249
1287
|
? 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]) =>
|
|
1288
|
+
: undefined)),
|
|
1289
|
+
string: evaluateArgs(fallback((arg) => (typeof arg === 'string' ? arg : undefined))),
|
|
1290
|
+
'to-boolean': evaluateArgs(fallback(Boolean)),
|
|
1291
|
+
'to-number': evaluateArgs(fallback(Number)),
|
|
1292
|
+
'to-string': evaluateArgs(fallback(String)),
|
|
1293
|
+
typeof: evaluateArgs(([arg]) => typeOfValue(arg)),
|
|
1256
1294
|
};
|
|
1257
1295
|
|
|
1258
1296
|
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]),
|
|
1297
|
+
'+': evaluateArgs((args) => args.reduce((a, b) => a + b, 0)),
|
|
1298
|
+
'-': evaluateArgs((args) => args.reduce((a, b) => a - b)),
|
|
1299
|
+
'*': evaluateArgs((args) => args.reduce((a, b) => a * b, 1)),
|
|
1300
|
+
'/': evaluateArgs((args) => args.reduce((a, b) => a / b)),
|
|
1301
|
+
'%': evaluateArgs((args) => args[0] % args[1]),
|
|
1302
|
+
'^': evaluateArgs((args) => Math.pow(args[0], args[1])),
|
|
1303
|
+
abs: evaluateArgs((args) => Math.abs(args[0])),
|
|
1304
|
+
acos: evaluateArgs((args) => Math.acos(args[0])),
|
|
1305
|
+
asin: evaluateArgs((args) => Math.asin(args[0])),
|
|
1306
|
+
atan: evaluateArgs((args) => Math.atan(args[0])),
|
|
1307
|
+
ceil: evaluateArgs((args) => Math.ceil(args[0])),
|
|
1308
|
+
cos: evaluateArgs((args) => Math.cos(args[0])),
|
|
1271
1309
|
e: () => Math.E,
|
|
1272
|
-
floor: (args) => Math.floor(args[0]),
|
|
1273
|
-
ln: (args) => Math.log(args[0]),
|
|
1310
|
+
floor: evaluateArgs((args) => Math.floor(args[0])),
|
|
1311
|
+
ln: evaluateArgs((args) => Math.log(args[0])),
|
|
1274
1312
|
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),
|
|
1313
|
+
log10: evaluateArgs((args) => Math.log10(args[0])),
|
|
1314
|
+
log2: evaluateArgs((args) => Math.log2(args[0])),
|
|
1315
|
+
max: evaluateArgs((args) => Math.max(...args)),
|
|
1316
|
+
min: evaluateArgs((args) => Math.min(...args)),
|
|
1279
1317
|
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]),
|
|
1318
|
+
round: evaluateArgs((args) => Math.round(args[0])),
|
|
1319
|
+
sin: evaluateArgs((args) => Math.sin(args[0])),
|
|
1320
|
+
sqrt: evaluateArgs((args) => Math.sqrt(args[0])),
|
|
1321
|
+
tan: evaluateArgs((args) => Math.tan(args[0])),
|
|
1284
1322
|
};
|
|
1285
1323
|
|
|
1286
1324
|
function get([key, objExp], data) {
|
|
@@ -1332,132 +1370,133 @@ function slice(args) {
|
|
|
1332
1370
|
throw new Error(`Invalid input type for 'slice'. Expected string or array, got ${typeof input}.`);
|
|
1333
1371
|
}
|
|
1334
1372
|
const lookupExpressions = {
|
|
1335
|
-
get,
|
|
1336
|
-
length,
|
|
1337
|
-
at,
|
|
1338
|
-
has,
|
|
1339
|
-
in: inFunc,
|
|
1340
|
-
'index-of': indexOf,
|
|
1341
|
-
slice,
|
|
1373
|
+
get: evaluateArgs(get),
|
|
1374
|
+
length: evaluateArgs(length),
|
|
1375
|
+
at: evaluateArgs(at),
|
|
1376
|
+
has: evaluateArgs(has),
|
|
1377
|
+
in: evaluateArgs(inFunc),
|
|
1378
|
+
'index-of': evaluateArgs(indexOf),
|
|
1379
|
+
slice: evaluateArgs(slice),
|
|
1342
1380
|
};
|
|
1343
1381
|
|
|
1344
1382
|
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(),
|
|
1383
|
+
concat: evaluateArgs((args) => args.reduce((a, b) => String(a) + String(b), '')),
|
|
1384
|
+
downcase: evaluateArgs((args) => String(args[0]).toLowerCase()),
|
|
1385
|
+
upcase: evaluateArgs((args) => String(args[0]).toUpperCase()),
|
|
1348
1386
|
};
|
|
1349
1387
|
|
|
1350
1388
|
function not([expr]) {
|
|
1351
1389
|
return !expr;
|
|
1352
1390
|
}
|
|
1353
|
-
const checkCompareValues = ([a, b]) => {
|
|
1354
|
-
if (typeof a !== typeof b) {
|
|
1355
|
-
throw new Error('Values have different types.');
|
|
1356
|
-
}
|
|
1357
|
-
};
|
|
1358
1391
|
function notEqual([a, b]) {
|
|
1359
|
-
checkCompareValues([a, b]);
|
|
1360
1392
|
return a !== b;
|
|
1361
1393
|
}
|
|
1362
1394
|
function lessThan([left, right]) {
|
|
1363
|
-
checkCompareValues([left, right]);
|
|
1364
1395
|
return left < right;
|
|
1365
1396
|
}
|
|
1366
1397
|
function lessThanOrEqual([left, right]) {
|
|
1367
|
-
checkCompareValues([left, right]);
|
|
1368
1398
|
return left <= right;
|
|
1369
1399
|
}
|
|
1370
1400
|
function equal([left, right]) {
|
|
1371
|
-
checkCompareValues([left, right]);
|
|
1372
1401
|
return left === right;
|
|
1373
1402
|
}
|
|
1374
1403
|
function greaterThan([left, right]) {
|
|
1375
|
-
checkCompareValues([left, right]);
|
|
1376
1404
|
return left > right;
|
|
1377
1405
|
}
|
|
1378
1406
|
function greaterThanOrEqual([left, right]) {
|
|
1379
|
-
checkCompareValues([left, right]);
|
|
1380
1407
|
return left >= right;
|
|
1381
1408
|
}
|
|
1382
|
-
|
|
1409
|
+
const coalesce = (args) => {
|
|
1383
1410
|
for (let i = 0; i < args.length; i++) {
|
|
1384
|
-
const arg = args[i];
|
|
1411
|
+
const arg = args[i]();
|
|
1412
|
+
if (arg !== null && arg !== undefined) {
|
|
1413
|
+
return arg;
|
|
1414
|
+
}
|
|
1415
|
+
}
|
|
1416
|
+
return null;
|
|
1417
|
+
};
|
|
1418
|
+
const all = (args) => {
|
|
1419
|
+
for (let i = 0; i < args.length; i++) {
|
|
1420
|
+
const arg = args[i]();
|
|
1385
1421
|
if (!arg) {
|
|
1386
1422
|
return false;
|
|
1387
1423
|
}
|
|
1388
1424
|
}
|
|
1389
1425
|
return true;
|
|
1390
|
-
}
|
|
1391
|
-
|
|
1426
|
+
};
|
|
1427
|
+
const any = (args) => {
|
|
1392
1428
|
for (let i = 0; i < args.length; i++) {
|
|
1393
|
-
const arg = args[i];
|
|
1429
|
+
const arg = args[i]();
|
|
1394
1430
|
if (arg) {
|
|
1395
1431
|
return true;
|
|
1396
1432
|
}
|
|
1397
1433
|
}
|
|
1398
1434
|
return false;
|
|
1399
|
-
}
|
|
1400
|
-
|
|
1401
|
-
const [
|
|
1435
|
+
};
|
|
1436
|
+
const match = (args) => {
|
|
1437
|
+
const [lookupFn, ...cases] = args;
|
|
1438
|
+
const lookup = lookupFn();
|
|
1402
1439
|
// remove last odd item from cases array
|
|
1403
1440
|
const defValue = cases.splice(-1, cases.length % 2)[0];
|
|
1404
1441
|
for (let fry = 0; fry < cases.length - 1; fry += 2) {
|
|
1405
|
-
const key = cases[fry];
|
|
1442
|
+
const key = cases[fry]();
|
|
1406
1443
|
if (key === lookup) {
|
|
1407
|
-
return cases[fry + 1];
|
|
1444
|
+
return cases[fry + 1]();
|
|
1408
1445
|
}
|
|
1409
1446
|
}
|
|
1410
|
-
return defValue;
|
|
1411
|
-
}
|
|
1412
|
-
|
|
1447
|
+
return defValue();
|
|
1448
|
+
};
|
|
1449
|
+
const caseFunc = (args) => {
|
|
1413
1450
|
if (args.length < 2) {
|
|
1414
1451
|
throw new Error('The "case" function requires at least a condition and a corresponding output.');
|
|
1415
1452
|
}
|
|
1416
|
-
const fallback = args[args.length - 1];
|
|
1417
1453
|
if (args.length % 2 === 0) {
|
|
1418
1454
|
throw new Error('Missing a fallback value or unmatched condition-output pair.');
|
|
1419
1455
|
}
|
|
1420
1456
|
for (let i = 0; i < args.length - 1; i += 2) {
|
|
1421
|
-
const condition = args[i];
|
|
1422
|
-
const value = args[i + 1];
|
|
1457
|
+
const condition = args[i]();
|
|
1458
|
+
const value = args[i + 1]();
|
|
1423
1459
|
if (condition) {
|
|
1424
1460
|
return value;
|
|
1425
1461
|
}
|
|
1426
1462
|
}
|
|
1427
|
-
|
|
1428
|
-
|
|
1463
|
+
const fallback = args[args.length - 1];
|
|
1464
|
+
return fallback();
|
|
1465
|
+
};
|
|
1429
1466
|
const decisionExpressions = {
|
|
1430
|
-
'!': not,
|
|
1431
|
-
'!=': notEqual,
|
|
1432
|
-
'<': lessThan,
|
|
1433
|
-
'<=': lessThanOrEqual,
|
|
1434
|
-
'==': equal,
|
|
1435
|
-
'>': greaterThan,
|
|
1436
|
-
'>=': greaterThanOrEqual,
|
|
1437
|
-
|
|
1438
|
-
|
|
1467
|
+
'!': evaluateArgs(not),
|
|
1468
|
+
'!=': evaluateArgs(notEqual),
|
|
1469
|
+
'<': evaluateArgs(lessThan),
|
|
1470
|
+
'<=': evaluateArgs(lessThanOrEqual),
|
|
1471
|
+
'==': evaluateArgs(equal),
|
|
1472
|
+
'>': evaluateArgs(greaterThan),
|
|
1473
|
+
'>=': evaluateArgs(greaterThanOrEqual),
|
|
1474
|
+
coalesce,
|
|
1475
|
+
all,
|
|
1476
|
+
any,
|
|
1439
1477
|
case: caseFunc,
|
|
1440
1478
|
match,
|
|
1441
1479
|
};
|
|
1442
1480
|
|
|
1443
|
-
|
|
1444
|
-
const [
|
|
1481
|
+
const step = (args) => {
|
|
1482
|
+
const [inputFn, defaultValue, ...stops] = args;
|
|
1483
|
+
const input = inputFn();
|
|
1445
1484
|
if (typeof input !== 'number') {
|
|
1446
|
-
return defaultValue;
|
|
1485
|
+
return defaultValue();
|
|
1447
1486
|
}
|
|
1448
1487
|
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];
|
|
1488
|
+
const stopInput = stops[i]();
|
|
1489
|
+
const stopOutput = stops[i + 1]();
|
|
1490
|
+
const nextStopInput = stops[i + 2]();
|
|
1452
1491
|
if (input >= stopInput && input < nextStopInput) {
|
|
1453
1492
|
return stopOutput;
|
|
1454
1493
|
}
|
|
1455
1494
|
}
|
|
1456
|
-
if (input >= stops[stops.length - 2]) {
|
|
1457
|
-
return stops[stops.length - 1];
|
|
1495
|
+
if (input >= stops[stops.length - 2]()) {
|
|
1496
|
+
return stops[stops.length - 1]();
|
|
1458
1497
|
}
|
|
1459
|
-
return defaultValue;
|
|
1460
|
-
}
|
|
1498
|
+
return defaultValue();
|
|
1499
|
+
};
|
|
1461
1500
|
|
|
1462
1501
|
const COLORS = {
|
|
1463
1502
|
aliceblue: '#f0f8ff',
|
|
@@ -1726,21 +1765,23 @@ function linearInterpolation(input, input1, output1, input2, output2) {
|
|
|
1726
1765
|
}
|
|
1727
1766
|
throw new Error('Unsupported output type for linear interpolation.');
|
|
1728
1767
|
}
|
|
1729
|
-
|
|
1768
|
+
const interpolate = ([interpolationFn, inputFn, ...stops]) => {
|
|
1730
1769
|
if (stops.length < 2) {
|
|
1731
1770
|
throw new Error('At least two stops are required');
|
|
1732
1771
|
}
|
|
1733
|
-
if (typeof input !== 'number') {
|
|
1734
|
-
throw new Error('Input must be a number.');
|
|
1735
|
-
}
|
|
1736
1772
|
if (stops.length < 2 || stops.length % 2 !== 0) {
|
|
1737
1773
|
throw new Error('Invalid stops provided.');
|
|
1738
1774
|
}
|
|
1775
|
+
const input = inputFn();
|
|
1776
|
+
if (typeof input !== 'number') {
|
|
1777
|
+
throw new Error('Input must be a number.');
|
|
1778
|
+
}
|
|
1779
|
+
const interpolation = interpolationFn();
|
|
1739
1780
|
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];
|
|
1781
|
+
const stopInput1 = stops[i]();
|
|
1782
|
+
const stopOutput1 = stops[i + 1]();
|
|
1783
|
+
const stopInput2 = stops[i + 2]();
|
|
1784
|
+
const stopOutput2 = stops[i + 3]();
|
|
1744
1785
|
if (input >= stopInput1 && input <= stopInput2) {
|
|
1745
1786
|
if (interpolation[0] === 'linear') {
|
|
1746
1787
|
return linearInterpolation(input, stopInput1, stopOutput1, stopInput2, stopOutput2);
|
|
@@ -1759,7 +1800,7 @@ function interpolate([interpolation, input, ...stops]) {
|
|
|
1759
1800
|
}
|
|
1760
1801
|
}
|
|
1761
1802
|
throw new Error('Invalid interpolation type.');
|
|
1762
|
-
}
|
|
1803
|
+
};
|
|
1763
1804
|
|
|
1764
1805
|
const interpolationExpressions = {
|
|
1765
1806
|
step,
|
|
@@ -1789,7 +1830,7 @@ function evaluate(expression, data = {}) {
|
|
|
1789
1830
|
const [name, ...args] = expression;
|
|
1790
1831
|
const expressionFun = expressions[name];
|
|
1791
1832
|
if (expressionFun) {
|
|
1792
|
-
return expressionFun(args.map((arg) => (isExpression(arg) ? evaluate(arg, data) : arg)
|
|
1833
|
+
return expressionFun(args.map((arg) => () => isExpression(arg) ? evaluate(arg, data) : arg), data);
|
|
1793
1834
|
}
|
|
1794
1835
|
throw new Error(`Expression "${name}" is not supported.`);
|
|
1795
1836
|
}
|