@nextgis/ngw-map 1.17.0 → 1.18.0
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 +597 -22
- 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 +616 -22
- 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
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
/** Bundle of @nextgis/ngw-map; version: 1.
|
|
1
|
+
/** Bundle of @nextgis/ngw-map; version: 1.18.0; author: NextGIS */
|
|
2
2
|
import { EventEmitter } from 'events';
|
|
3
3
|
import CancelablePromise from '@nextgis/cancelable-promise';
|
|
4
4
|
import { deepmerge, deprecatedWarn, defined, isObject, getIdentifyRadius } from '@nextgis/utils';
|
package/lib/ngw-map.global.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
/** Bundle of @nextgis/ngw-map; version: 1.
|
|
1
|
+
/** Bundle of @nextgis/ngw-map; version: 1.18.0; author: NextGIS */
|
|
2
2
|
var NgwMap = (function (exports) {
|
|
3
3
|
'use strict';
|
|
4
4
|
|
|
@@ -1339,12 +1339,6 @@ var NgwMap = (function (exports) {
|
|
|
1339
1339
|
return url.replace(/([^:]\/)\/+/g, '$1');
|
|
1340
1340
|
}
|
|
1341
1341
|
|
|
1342
|
-
function isExpression(value) {
|
|
1343
|
-
if (Array.isArray(value)) {
|
|
1344
|
-
return true;
|
|
1345
|
-
}
|
|
1346
|
-
return false;
|
|
1347
|
-
}
|
|
1348
1342
|
function isPropertiesPaint(paint) {
|
|
1349
1343
|
if (Array.isArray(paint)) {
|
|
1350
1344
|
return true;
|
|
@@ -1364,41 +1358,641 @@ var NgwMap = (function (exports) {
|
|
|
1364
1358
|
return false;
|
|
1365
1359
|
}
|
|
1366
1360
|
|
|
1367
|
-
function
|
|
1368
|
-
|
|
1369
|
-
|
|
1361
|
+
var tryConvert = function (converter, arg, data) {
|
|
1362
|
+
try {
|
|
1363
|
+
var result = converter(arg, data);
|
|
1364
|
+
if (result !== undefined) {
|
|
1365
|
+
return result;
|
|
1366
|
+
}
|
|
1367
|
+
}
|
|
1368
|
+
catch (_a) {
|
|
1369
|
+
// ignore errors
|
|
1370
|
+
}
|
|
1371
|
+
return undefined;
|
|
1372
|
+
};
|
|
1373
|
+
|
|
1374
|
+
function fallback(cb) {
|
|
1375
|
+
return function (args, data) {
|
|
1376
|
+
for (var _i = 0, args_1 = args; _i < args_1.length; _i++) {
|
|
1377
|
+
var arg = args_1[_i];
|
|
1378
|
+
var result = tryConvert(cb, arg, data);
|
|
1379
|
+
if (result !== undefined) {
|
|
1380
|
+
return result;
|
|
1381
|
+
}
|
|
1382
|
+
}
|
|
1383
|
+
throw new Error("Received a mismatched type");
|
|
1384
|
+
};
|
|
1370
1385
|
}
|
|
1371
|
-
|
|
1372
|
-
|
|
1373
|
-
var
|
|
1374
|
-
|
|
1375
|
-
|
|
1386
|
+
|
|
1387
|
+
var array = function (args) {
|
|
1388
|
+
var firstArg = args[0], secondArg = args[1], thirdArg = args[2];
|
|
1389
|
+
var requiredType = undefined;
|
|
1390
|
+
var requiredLength = undefined;
|
|
1391
|
+
var value;
|
|
1392
|
+
if (typeof firstArg === 'string' &&
|
|
1393
|
+
['string', 'number', 'boolean'].includes(firstArg)) {
|
|
1394
|
+
requiredType = firstArg;
|
|
1395
|
+
if (typeof secondArg === 'number') {
|
|
1396
|
+
requiredLength = secondArg;
|
|
1397
|
+
value = thirdArg;
|
|
1398
|
+
}
|
|
1399
|
+
else {
|
|
1400
|
+
value = secondArg;
|
|
1401
|
+
}
|
|
1402
|
+
}
|
|
1403
|
+
else if (Array.isArray(firstArg)) {
|
|
1404
|
+
value = firstArg;
|
|
1405
|
+
}
|
|
1406
|
+
if (!Array.isArray(value)) {
|
|
1407
|
+
throw new Error('Expected an array');
|
|
1408
|
+
}
|
|
1409
|
+
if (requiredType && !value.every(function (item) { return typeof item === requiredType; })) {
|
|
1410
|
+
throw new Error("Expected all items in array to be of type ".concat(requiredType));
|
|
1411
|
+
}
|
|
1412
|
+
if (requiredLength && value.length !== requiredLength) {
|
|
1413
|
+
throw new Error("Expected array of length ".concat(requiredLength));
|
|
1414
|
+
}
|
|
1415
|
+
return value;
|
|
1416
|
+
};
|
|
1417
|
+
var typeExpressions = {
|
|
1418
|
+
array: array,
|
|
1419
|
+
boolean: fallback(function (arg) { return (typeof arg === 'boolean' ? arg : undefined); }),
|
|
1420
|
+
literal: function (_a) {
|
|
1421
|
+
var arg = _a[0];
|
|
1422
|
+
return arg;
|
|
1423
|
+
},
|
|
1424
|
+
number: fallback(function (arg) { return (typeof arg === 'number' ? arg : undefined); }),
|
|
1425
|
+
object: fallback(function (arg) {
|
|
1426
|
+
return arg !== null && typeof arg === 'object' && !Array.isArray(arg)
|
|
1427
|
+
? arg
|
|
1428
|
+
: undefined;
|
|
1429
|
+
}),
|
|
1430
|
+
string: fallback(function (arg) { return (typeof arg === 'string' ? arg : undefined); }),
|
|
1431
|
+
'to-boolean': fallback(Boolean),
|
|
1432
|
+
'to-number': fallback(Number),
|
|
1433
|
+
'to-string': fallback(String),
|
|
1434
|
+
typeof: function (_a) {
|
|
1435
|
+
var arg = _a[0];
|
|
1436
|
+
return typeof arg;
|
|
1437
|
+
},
|
|
1438
|
+
};
|
|
1439
|
+
|
|
1440
|
+
var mathExpressions = {
|
|
1441
|
+
'+': function (args) { return args.reduce(function (a, b) { return a + b; }, 0); },
|
|
1442
|
+
'-': function (args) { return args.reduce(function (a, b) { return a - b; }); },
|
|
1443
|
+
'*': function (args) { return args.reduce(function (a, b) { return a * b; }, 1); },
|
|
1444
|
+
'/': function (args) { return args.reduce(function (a, b) { return a / b; }); },
|
|
1445
|
+
'%': function (args) { return args[0] % args[1]; },
|
|
1446
|
+
'^': function (args) { return Math.pow(args[0], args[1]); },
|
|
1447
|
+
abs: function (args) { return Math.abs(args[0]); },
|
|
1448
|
+
acos: function (args) { return Math.acos(args[0]); },
|
|
1449
|
+
asin: function (args) { return Math.asin(args[0]); },
|
|
1450
|
+
atan: function (args) { return Math.atan(args[0]); },
|
|
1451
|
+
ceil: function (args) { return Math.ceil(args[0]); },
|
|
1452
|
+
cos: function (args) { return Math.cos(args[0]); },
|
|
1453
|
+
e: function () { return Math.E; },
|
|
1454
|
+
floor: function (args) { return Math.floor(args[0]); },
|
|
1455
|
+
ln: function (args) { return Math.log(args[0]); },
|
|
1456
|
+
ln2: function () { return Math.LN2; },
|
|
1457
|
+
log10: function (args) { return Math.log10(args[0]); },
|
|
1458
|
+
log2: function (args) { return Math.log2(args[0]); },
|
|
1459
|
+
max: function (args) { return Math.max.apply(Math, args); },
|
|
1460
|
+
min: function (args) { return Math.min.apply(Math, args); },
|
|
1461
|
+
pi: function () { return Math.PI; },
|
|
1462
|
+
round: function (args) { return Math.round(args[0]); },
|
|
1463
|
+
sin: function (args) { return Math.sin(args[0]); },
|
|
1464
|
+
sqrt: function (args) { return Math.sqrt(args[0]); },
|
|
1465
|
+
tan: function (args) { return Math.tan(args[0]); },
|
|
1466
|
+
};
|
|
1467
|
+
|
|
1468
|
+
function get(_a, data) {
|
|
1469
|
+
var key = _a[0], objExp = _a[1];
|
|
1470
|
+
var target = objExp || data;
|
|
1471
|
+
if (target && typeof target === 'object' && key in target) {
|
|
1472
|
+
return target[key];
|
|
1473
|
+
}
|
|
1474
|
+
return null;
|
|
1475
|
+
}
|
|
1476
|
+
function has(_a, data) {
|
|
1477
|
+
var key = _a[0], objExp = _a[1];
|
|
1478
|
+
var target = objExp || data;
|
|
1479
|
+
return !!(target && typeof target === 'object' && key in target);
|
|
1480
|
+
}
|
|
1481
|
+
function at(_a) {
|
|
1482
|
+
var index = _a[0], array = _a[1];
|
|
1483
|
+
return array[index];
|
|
1484
|
+
}
|
|
1485
|
+
function inFunc(_a) {
|
|
1486
|
+
var keyword = _a[0], input = _a[1];
|
|
1487
|
+
if (typeof input === 'string') {
|
|
1488
|
+
return input.includes(String(keyword));
|
|
1489
|
+
}
|
|
1490
|
+
else if (Array.isArray(input)) {
|
|
1491
|
+
return input.includes(keyword);
|
|
1492
|
+
}
|
|
1493
|
+
throw new Error("Invalid input type for 'in'. Expected string or array, got ".concat(typeof input, "."));
|
|
1494
|
+
}
|
|
1495
|
+
var length = function (_a) {
|
|
1496
|
+
var item = _a[0];
|
|
1497
|
+
if (typeof item === 'string' || Array.isArray(item)) {
|
|
1498
|
+
return item.length;
|
|
1499
|
+
}
|
|
1500
|
+
return undefined;
|
|
1501
|
+
};
|
|
1502
|
+
function indexOf(_a) {
|
|
1503
|
+
var keyword = _a[0], input = _a[1], startIndex = _a[2];
|
|
1504
|
+
if (typeof input === 'string') {
|
|
1505
|
+
return input.indexOf(String(keyword), startIndex);
|
|
1506
|
+
}
|
|
1507
|
+
else if (Array.isArray(input)) {
|
|
1508
|
+
return input.indexOf(keyword, startIndex);
|
|
1509
|
+
}
|
|
1510
|
+
throw new Error("Invalid input type for 'index-of'. Expected string or array, got ".concat(typeof input, "."));
|
|
1511
|
+
}
|
|
1512
|
+
function slice(args) {
|
|
1513
|
+
var input = args[0], startIndex = args[1], endIndex = args[2];
|
|
1514
|
+
if (typeof input === 'string') {
|
|
1515
|
+
return input.slice(startIndex, endIndex);
|
|
1516
|
+
}
|
|
1517
|
+
else if (Array.isArray(input)) {
|
|
1518
|
+
return input.slice(startIndex, endIndex);
|
|
1519
|
+
}
|
|
1520
|
+
throw new Error("Invalid input type for 'slice'. Expected string or array, got ".concat(typeof input, "."));
|
|
1521
|
+
}
|
|
1522
|
+
var lookupExpressions = {
|
|
1523
|
+
get: get,
|
|
1524
|
+
length: length,
|
|
1525
|
+
at: at,
|
|
1526
|
+
has: has,
|
|
1527
|
+
in: inFunc,
|
|
1528
|
+
'index-of': indexOf,
|
|
1529
|
+
slice: slice,
|
|
1530
|
+
};
|
|
1531
|
+
|
|
1532
|
+
var stringExpressions = {
|
|
1533
|
+
concat: function (args) { return args.reduce(function (a, b) { return String(a) + String(b); }, ''); },
|
|
1534
|
+
downcase: function (args) { return String(args[0]).toLowerCase(); },
|
|
1535
|
+
upcase: function (args) { return String(args[0]).toUpperCase(); },
|
|
1536
|
+
};
|
|
1537
|
+
|
|
1538
|
+
function not(_a) {
|
|
1539
|
+
var expr = _a[0];
|
|
1540
|
+
return !expr;
|
|
1541
|
+
}
|
|
1542
|
+
var checkCompareValues = function (_a) {
|
|
1543
|
+
var a = _a[0], b = _a[1];
|
|
1544
|
+
if (typeof a !== typeof b) {
|
|
1545
|
+
throw new Error('Values have different types.');
|
|
1376
1546
|
}
|
|
1547
|
+
};
|
|
1548
|
+
function notEqual(_a) {
|
|
1549
|
+
var a = _a[0], b = _a[1];
|
|
1550
|
+
checkCompareValues([a, b]);
|
|
1551
|
+
return a !== b;
|
|
1552
|
+
}
|
|
1553
|
+
function lessThan(_a) {
|
|
1554
|
+
var left = _a[0], right = _a[1];
|
|
1555
|
+
checkCompareValues([left, right]);
|
|
1556
|
+
return left < right;
|
|
1557
|
+
}
|
|
1558
|
+
function lessThanOrEqual(_a) {
|
|
1559
|
+
var left = _a[0], right = _a[1];
|
|
1560
|
+
checkCompareValues([left, right]);
|
|
1561
|
+
return left <= right;
|
|
1562
|
+
}
|
|
1563
|
+
function equal(_a) {
|
|
1564
|
+
var left = _a[0], right = _a[1];
|
|
1565
|
+
checkCompareValues([left, right]);
|
|
1566
|
+
return left === right;
|
|
1567
|
+
}
|
|
1568
|
+
function greaterThan(_a) {
|
|
1569
|
+
var left = _a[0], right = _a[1];
|
|
1570
|
+
checkCompareValues([left, right]);
|
|
1571
|
+
return left > right;
|
|
1572
|
+
}
|
|
1573
|
+
function greaterThanOrEqual(_a) {
|
|
1574
|
+
var left = _a[0], right = _a[1];
|
|
1575
|
+
checkCompareValues([left, right]);
|
|
1576
|
+
return left >= right;
|
|
1577
|
+
}
|
|
1578
|
+
function all(args) {
|
|
1579
|
+
for (var i = 0; i < args.length; i++) {
|
|
1580
|
+
var arg = args[i];
|
|
1581
|
+
if (!arg) {
|
|
1582
|
+
return false;
|
|
1583
|
+
}
|
|
1584
|
+
}
|
|
1585
|
+
return true;
|
|
1586
|
+
}
|
|
1587
|
+
function any(args) {
|
|
1588
|
+
for (var i = 0; i < args.length; i++) {
|
|
1589
|
+
var arg = args[i];
|
|
1590
|
+
if (arg) {
|
|
1591
|
+
return true;
|
|
1592
|
+
}
|
|
1593
|
+
}
|
|
1594
|
+
return false;
|
|
1595
|
+
}
|
|
1596
|
+
function match(args) {
|
|
1597
|
+
var lookup = args[0], cases = args.slice(1);
|
|
1377
1598
|
// remove last odd item from cases array
|
|
1378
1599
|
var defValue = cases.splice(-1, cases.length % 2)[0];
|
|
1379
1600
|
for (var fry = 0; fry < cases.length - 1; fry += 2) {
|
|
1380
1601
|
var key = cases[fry];
|
|
1381
|
-
if (key ===
|
|
1602
|
+
if (key === lookup) {
|
|
1382
1603
|
return cases[fry + 1];
|
|
1383
1604
|
}
|
|
1384
1605
|
}
|
|
1385
1606
|
return defValue;
|
|
1386
1607
|
}
|
|
1387
|
-
|
|
1388
|
-
|
|
1608
|
+
function caseFunc(args) {
|
|
1609
|
+
if (args.length < 2) {
|
|
1610
|
+
throw new Error('The "case" function requires at least a condition and a corresponding output.');
|
|
1611
|
+
}
|
|
1612
|
+
var fallback = args[args.length - 1];
|
|
1613
|
+
if (args.length % 2 === 0) {
|
|
1614
|
+
throw new Error('Missing a fallback value or unmatched condition-output pair.');
|
|
1615
|
+
}
|
|
1616
|
+
for (var i = 0; i < args.length - 1; i += 2) {
|
|
1617
|
+
var condition = args[i];
|
|
1618
|
+
var value = args[i + 1];
|
|
1619
|
+
if (condition) {
|
|
1620
|
+
return value;
|
|
1621
|
+
}
|
|
1622
|
+
}
|
|
1623
|
+
return fallback;
|
|
1624
|
+
}
|
|
1625
|
+
var decisionExpressions = {
|
|
1626
|
+
'!': not,
|
|
1627
|
+
'!=': notEqual,
|
|
1628
|
+
'<': lessThan,
|
|
1629
|
+
'<=': lessThanOrEqual,
|
|
1630
|
+
'==': equal,
|
|
1631
|
+
'>': greaterThan,
|
|
1632
|
+
'>=': greaterThanOrEqual,
|
|
1633
|
+
all: all,
|
|
1634
|
+
any: any,
|
|
1635
|
+
case: caseFunc,
|
|
1389
1636
|
match: match,
|
|
1390
1637
|
};
|
|
1391
|
-
|
|
1638
|
+
|
|
1639
|
+
function step(args) {
|
|
1640
|
+
var input = args[0], defaultValue = args[1], stops = args.slice(2);
|
|
1641
|
+
if (typeof input !== 'number') {
|
|
1642
|
+
return defaultValue;
|
|
1643
|
+
}
|
|
1644
|
+
for (var i = 0; i < stops.length - 2; i += 2) {
|
|
1645
|
+
var stopInput = stops[i];
|
|
1646
|
+
var stopOutput = stops[i + 1];
|
|
1647
|
+
var nextStopInput = stops[i + 2];
|
|
1648
|
+
if (input >= stopInput && input < nextStopInput) {
|
|
1649
|
+
return stopOutput;
|
|
1650
|
+
}
|
|
1651
|
+
}
|
|
1652
|
+
if (input >= stops[stops.length - 2]) {
|
|
1653
|
+
return stops[stops.length - 1];
|
|
1654
|
+
}
|
|
1655
|
+
return defaultValue;
|
|
1656
|
+
}
|
|
1657
|
+
|
|
1658
|
+
var COLORS = {
|
|
1659
|
+
aliceblue: '#f0f8ff',
|
|
1660
|
+
antiquewhite: '#faebd7',
|
|
1661
|
+
aqua: '#00ffff',
|
|
1662
|
+
aquamarine: '#7fffd4',
|
|
1663
|
+
azure: '#f0ffff',
|
|
1664
|
+
beige: '#f5f5dc',
|
|
1665
|
+
bisque: '#ffe4c4',
|
|
1666
|
+
black: '#000000',
|
|
1667
|
+
blanchedalmond: '#ffebcd',
|
|
1668
|
+
blue: '#0000ff',
|
|
1669
|
+
blueviolet: '#8a2be2',
|
|
1670
|
+
brown: '#a52a2a',
|
|
1671
|
+
burlywood: '#deb887',
|
|
1672
|
+
cadetblue: '#5f9ea0',
|
|
1673
|
+
chartreuse: '#7fff00',
|
|
1674
|
+
chocolate: '#d2691e',
|
|
1675
|
+
coral: '#ff7f50',
|
|
1676
|
+
cornflowerblue: '#6495ed',
|
|
1677
|
+
cornsilk: '#fff8dc',
|
|
1678
|
+
crimson: '#dc143c',
|
|
1679
|
+
cyan: '#00ffff',
|
|
1680
|
+
darkblue: '#00008b',
|
|
1681
|
+
darkcyan: '#008b8b',
|
|
1682
|
+
darkgoldenrod: '#b8860b',
|
|
1683
|
+
darkgray: '#a9a9a9',
|
|
1684
|
+
darkgreen: '#006400',
|
|
1685
|
+
darkkhaki: '#bdb76b',
|
|
1686
|
+
darkmagenta: '#8b008b',
|
|
1687
|
+
darkolivegreen: '#556b2f',
|
|
1688
|
+
darkorange: '#ff8c00',
|
|
1689
|
+
darkorchid: '#9932cc',
|
|
1690
|
+
darkred: '#8b0000',
|
|
1691
|
+
darksalmon: '#e9967a',
|
|
1692
|
+
darkseagreen: '#8fbc8f',
|
|
1693
|
+
darkslateblue: '#483d8b',
|
|
1694
|
+
darkslategray: '#2f4f4f',
|
|
1695
|
+
darkturquoise: '#00ced1',
|
|
1696
|
+
darkviolet: '#9400d3',
|
|
1697
|
+
deeppink: '#ff1493',
|
|
1698
|
+
deepskyblue: '#00bfff',
|
|
1699
|
+
dimgray: '#696969',
|
|
1700
|
+
dodgerblue: '#1e90ff',
|
|
1701
|
+
firebrick: '#b22222',
|
|
1702
|
+
floralwhite: '#fffaf0',
|
|
1703
|
+
forestgreen: '#228b22',
|
|
1704
|
+
fuchsia: '#ff00ff',
|
|
1705
|
+
gainsboro: '#dcdcdc',
|
|
1706
|
+
ghostwhite: '#f8f8ff',
|
|
1707
|
+
gold: '#ffd700',
|
|
1708
|
+
goldenrod: '#daa520',
|
|
1709
|
+
gray: '#808080',
|
|
1710
|
+
green: '#008000',
|
|
1711
|
+
greenyellow: '#adff2f',
|
|
1712
|
+
honeydew: '#f0fff0',
|
|
1713
|
+
hotpink: '#ff69b4',
|
|
1714
|
+
'indianred ': '#cd5c5c',
|
|
1715
|
+
indigo: '#4b0082',
|
|
1716
|
+
ivory: '#fffff0',
|
|
1717
|
+
khaki: '#f0e68c',
|
|
1718
|
+
lavender: '#e6e6fa',
|
|
1719
|
+
lavenderblush: '#fff0f5',
|
|
1720
|
+
lawngreen: '#7cfc00',
|
|
1721
|
+
lemonchiffon: '#fffacd',
|
|
1722
|
+
lightblue: '#add8e6',
|
|
1723
|
+
lightcoral: '#f08080',
|
|
1724
|
+
lightcyan: '#e0ffff',
|
|
1725
|
+
lightgoldenrodyellow: '#fafad2',
|
|
1726
|
+
lightgrey: '#d3d3d3',
|
|
1727
|
+
lightgreen: '#90ee90',
|
|
1728
|
+
lightpink: '#ffb6c1',
|
|
1729
|
+
lightsalmon: '#ffa07a',
|
|
1730
|
+
lightseagreen: '#20b2aa',
|
|
1731
|
+
lightskyblue: '#87cefa',
|
|
1732
|
+
lightslategray: '#778899',
|
|
1733
|
+
lightsteelblue: '#b0c4de',
|
|
1734
|
+
lightyellow: '#ffffe0',
|
|
1735
|
+
lime: '#00ff00',
|
|
1736
|
+
limegreen: '#32cd32',
|
|
1737
|
+
linen: '#faf0e6',
|
|
1738
|
+
magenta: '#ff00ff',
|
|
1739
|
+
maroon: '#800000',
|
|
1740
|
+
mediumaquamarine: '#66cdaa',
|
|
1741
|
+
mediumblue: '#0000cd',
|
|
1742
|
+
mediumorchid: '#ba55d3',
|
|
1743
|
+
mediumpurple: '#9370d8',
|
|
1744
|
+
mediumseagreen: '#3cb371',
|
|
1745
|
+
mediumslateblue: '#7b68ee',
|
|
1746
|
+
mediumspringgreen: '#00fa9a',
|
|
1747
|
+
mediumturquoise: '#48d1cc',
|
|
1748
|
+
mediumvioletred: '#c71585',
|
|
1749
|
+
midnightblue: '#191970',
|
|
1750
|
+
mintcream: '#f5fffa',
|
|
1751
|
+
mistyrose: '#ffe4e1',
|
|
1752
|
+
moccasin: '#ffe4b5',
|
|
1753
|
+
navajowhite: '#ffdead',
|
|
1754
|
+
navy: '#000080',
|
|
1755
|
+
oldlace: '#fdf5e6',
|
|
1756
|
+
olive: '#808000',
|
|
1757
|
+
olivedrab: '#6b8e23',
|
|
1758
|
+
orange: '#ffa500',
|
|
1759
|
+
orangered: '#ff4500',
|
|
1760
|
+
orchid: '#da70d6',
|
|
1761
|
+
palegoldenrod: '#eee8aa',
|
|
1762
|
+
palegreen: '#98fb98',
|
|
1763
|
+
paleturquoise: '#afeeee',
|
|
1764
|
+
palevioletred: '#d87093',
|
|
1765
|
+
papayawhip: '#ffefd5',
|
|
1766
|
+
peachpuff: '#ffdab9',
|
|
1767
|
+
peru: '#cd853f',
|
|
1768
|
+
pink: '#ffc0cb',
|
|
1769
|
+
plum: '#dda0dd',
|
|
1770
|
+
powderblue: '#b0e0e6',
|
|
1771
|
+
purple: '#800080',
|
|
1772
|
+
rebeccapurple: '#663399',
|
|
1773
|
+
red: '#ff0000',
|
|
1774
|
+
rosybrown: '#bc8f8f',
|
|
1775
|
+
royalblue: '#4169e1',
|
|
1776
|
+
saddlebrown: '#8b4513',
|
|
1777
|
+
salmon: '#fa8072',
|
|
1778
|
+
sandybrown: '#f4a460',
|
|
1779
|
+
seagreen: '#2e8b57',
|
|
1780
|
+
seashell: '#fff5ee',
|
|
1781
|
+
sienna: '#a0522d',
|
|
1782
|
+
silver: '#c0c0c0',
|
|
1783
|
+
skyblue: '#87ceeb',
|
|
1784
|
+
slateblue: '#6a5acd',
|
|
1785
|
+
slategray: '#708090',
|
|
1786
|
+
snow: '#fffafa',
|
|
1787
|
+
springgreen: '#00ff7f',
|
|
1788
|
+
steelblue: '#4682b4',
|
|
1789
|
+
tan: '#d2b48c',
|
|
1790
|
+
teal: '#008080',
|
|
1791
|
+
thistle: '#d8bfd8',
|
|
1792
|
+
tomato: '#ff6347',
|
|
1793
|
+
turquoise: '#40e0d0',
|
|
1794
|
+
violet: '#ee82ee',
|
|
1795
|
+
wheat: '#f5deb3',
|
|
1796
|
+
white: '#ffffff',
|
|
1797
|
+
whitesmoke: '#f5f5f5',
|
|
1798
|
+
yellow: '#ffff00',
|
|
1799
|
+
yellowgreen: '#9acd32',
|
|
1800
|
+
};
|
|
1801
|
+
|
|
1802
|
+
function isHex(hex) {
|
|
1803
|
+
return typeof hex === 'string' && /^#([A-Fa-f0-9]{3}){1,2}$/.test(hex);
|
|
1804
|
+
}
|
|
1805
|
+
function isRgb(hex) {
|
|
1806
|
+
var r =
|
|
1807
|
+
// eslint-disable-next-line max-len
|
|
1808
|
+
/^rgb(a?)\(\s*([0-9]+)\s*,\s*([0-9]+)\s*,\s*([0-9]+)(?:\s*,\s*([01](?:\.\d+)?))?\s*\)$/;
|
|
1809
|
+
return typeof hex === 'string' && r.test(hex);
|
|
1810
|
+
}
|
|
1811
|
+
function isColorObj(obj) {
|
|
1812
|
+
if (typeof obj === 'object' && obj !== null) {
|
|
1813
|
+
var hasRgb = 'r' in obj && 'g' in obj && 'b' in obj;
|
|
1814
|
+
var hasValidAlpha = !('a' in obj) || (typeof obj.a === 'number' && obj.a >= 0 && obj.a <= 1);
|
|
1815
|
+
return hasRgb && hasValidAlpha;
|
|
1816
|
+
}
|
|
1817
|
+
return false;
|
|
1818
|
+
}
|
|
1819
|
+
function isColorName(name) {
|
|
1820
|
+
if (typeof name === 'string' && name in COLORS) {
|
|
1821
|
+
return true;
|
|
1822
|
+
}
|
|
1823
|
+
return false;
|
|
1824
|
+
}
|
|
1825
|
+
function toColor(value) {
|
|
1826
|
+
if (isHex(value)) {
|
|
1827
|
+
return hexToColor(value);
|
|
1828
|
+
}
|
|
1829
|
+
else if (isColorName(value)) {
|
|
1830
|
+
return colorNameToColor(value);
|
|
1831
|
+
}
|
|
1832
|
+
else if (isRgb(value)) {
|
|
1833
|
+
return rgbToColor(value);
|
|
1834
|
+
}
|
|
1835
|
+
else if (isColorObj(value)) {
|
|
1836
|
+
return colorObjectToColor(value);
|
|
1837
|
+
}
|
|
1838
|
+
throw new Error("The '".concat(value, "' cannot be converted to color"));
|
|
1839
|
+
}
|
|
1840
|
+
function colorNameToColor(name) {
|
|
1841
|
+
return hexToColor(COLORS[name]);
|
|
1842
|
+
}
|
|
1843
|
+
function hexToColor(hex) {
|
|
1844
|
+
var shortRGB = /^#([0-9a-fA-F])([0-9a-fA-F])([0-9a-fA-F])$/;
|
|
1845
|
+
var shortRGBA = /^#([0-9a-fA-F])([0-9a-fA-F])([0-9a-fA-F])([0-9a-fA-F])$/;
|
|
1846
|
+
var longRGB = /^#([0-9a-fA-F]{2})([0-9a-fA-F]{2})([0-9a-fA-F]{2})$/;
|
|
1847
|
+
var longRGBA = /^#([0-9a-fA-F]{2})([0-9a-fA-F]{2})([0-9a-fA-F]{2})([0-9a-fA-F]{2})$/;
|
|
1848
|
+
var result;
|
|
1849
|
+
if ((result = shortRGB.exec(hex))) {
|
|
1850
|
+
return [
|
|
1851
|
+
parseInt(result[1] + result[1], 16),
|
|
1852
|
+
parseInt(result[2] + result[2], 16),
|
|
1853
|
+
parseInt(result[3] + result[3], 16),
|
|
1854
|
+
];
|
|
1855
|
+
}
|
|
1856
|
+
else if ((result = shortRGBA.exec(hex))) {
|
|
1857
|
+
return [
|
|
1858
|
+
parseInt(result[1] + result[1], 16),
|
|
1859
|
+
parseInt(result[2] + result[2], 16),
|
|
1860
|
+
parseInt(result[3] + result[3], 16),
|
|
1861
|
+
parseInt(result[4] + result[4], 16) / 255,
|
|
1862
|
+
];
|
|
1863
|
+
}
|
|
1864
|
+
else if ((result = longRGB.exec(hex))) {
|
|
1865
|
+
return [
|
|
1866
|
+
parseInt(result[1], 16),
|
|
1867
|
+
parseInt(result[2], 16),
|
|
1868
|
+
parseInt(result[3], 16),
|
|
1869
|
+
];
|
|
1870
|
+
}
|
|
1871
|
+
else if ((result = longRGBA.exec(hex))) {
|
|
1872
|
+
return [
|
|
1873
|
+
parseInt(result[1], 16),
|
|
1874
|
+
parseInt(result[2], 16),
|
|
1875
|
+
parseInt(result[3], 16),
|
|
1876
|
+
parseInt(result[4], 16) / 255,
|
|
1877
|
+
];
|
|
1878
|
+
}
|
|
1879
|
+
throw new Error("The '".concat(hex, "' Is not valid hex"));
|
|
1880
|
+
}
|
|
1881
|
+
function rgbToColor(rgb) {
|
|
1882
|
+
var rgbPattern = /^rgb\((\d+),\s*(\d+),\s*(\d+)\)$/;
|
|
1883
|
+
var rgbaPattern = /^rgba\((\d+),\s*(\d+),\s*(\d+),\s*([\d.]+)\)$/;
|
|
1884
|
+
var matches;
|
|
1885
|
+
if ((matches = rgb.match(rgbPattern))) {
|
|
1886
|
+
return [
|
|
1887
|
+
parseInt(matches[1], 10),
|
|
1888
|
+
parseInt(matches[2], 10),
|
|
1889
|
+
parseInt(matches[3], 10),
|
|
1890
|
+
];
|
|
1891
|
+
}
|
|
1892
|
+
else if ((matches = rgb.match(rgbaPattern))) {
|
|
1893
|
+
return [
|
|
1894
|
+
parseInt(matches[1], 10),
|
|
1895
|
+
parseInt(matches[2], 10),
|
|
1896
|
+
parseInt(matches[3], 10),
|
|
1897
|
+
parseFloat(matches[4]),
|
|
1898
|
+
];
|
|
1899
|
+
}
|
|
1900
|
+
throw new Error("The '".concat(rgb, "' Is not valid rgb"));
|
|
1901
|
+
}
|
|
1902
|
+
function colorObjectToColor(_a) {
|
|
1903
|
+
var r = _a.r, g = _a.g, b = _a.b, a = _a.a;
|
|
1904
|
+
return __spreadArray([r, g, b], (a !== undefined ? [a] : []), true);
|
|
1905
|
+
}
|
|
1906
|
+
function colorToRGB(array) {
|
|
1907
|
+
return "rgb(".concat(array.join(','), ")");
|
|
1908
|
+
}
|
|
1909
|
+
|
|
1910
|
+
function linearInterpolation(input, input1, output1, input2, output2) {
|
|
1911
|
+
if (typeof output1 === 'number' && typeof output2 === 'number') {
|
|
1912
|
+
return (output1 + ((input - input1) / (input2 - input1)) * (output2 - output1));
|
|
1913
|
+
}
|
|
1914
|
+
try {
|
|
1915
|
+
var outputColor1 = toColor(output1);
|
|
1916
|
+
var outputColor2_1 = toColor(output2);
|
|
1917
|
+
return colorToRGB(outputColor1.map(function (val, index) {
|
|
1918
|
+
return Math.ceil(linearInterpolation(input, input1, val, input2, outputColor2_1[index]));
|
|
1919
|
+
}));
|
|
1920
|
+
}
|
|
1921
|
+
catch (er) {
|
|
1922
|
+
console.log(er);
|
|
1923
|
+
}
|
|
1924
|
+
throw new Error('Unsupported output type for linear interpolation.');
|
|
1925
|
+
}
|
|
1926
|
+
function interpolate(_a) {
|
|
1927
|
+
var interpolation = _a[0], input = _a[1], stops = _a.slice(2);
|
|
1928
|
+
if (stops.length < 2) {
|
|
1929
|
+
throw new Error('At least two stops are required');
|
|
1930
|
+
}
|
|
1931
|
+
if (typeof input !== 'number') {
|
|
1932
|
+
throw new Error('Input must be a number.');
|
|
1933
|
+
}
|
|
1934
|
+
if (stops.length < 2 || stops.length % 2 !== 0) {
|
|
1935
|
+
throw new Error('Invalid stops provided.');
|
|
1936
|
+
}
|
|
1937
|
+
for (var i = 0; i < stops.length - 2; i += 2) {
|
|
1938
|
+
var stopInput1 = stops[i];
|
|
1939
|
+
var stopOutput1 = stops[i + 1];
|
|
1940
|
+
var stopInput2 = stops[i + 2];
|
|
1941
|
+
var stopOutput2 = stops[i + 3];
|
|
1942
|
+
if (input >= stopInput1 && input <= stopInput2) {
|
|
1943
|
+
if (interpolation[0] === 'linear') {
|
|
1944
|
+
return linearInterpolation(input, stopInput1, stopOutput1, stopInput2, stopOutput2);
|
|
1945
|
+
}
|
|
1946
|
+
// else if (interpolation[0] === 'exponential') {
|
|
1947
|
+
// const base = interpolation[1];
|
|
1948
|
+
// return exponentialInterpolation(
|
|
1949
|
+
// input,
|
|
1950
|
+
// base,
|
|
1951
|
+
// stopInput1,
|
|
1952
|
+
// stopOutput1,
|
|
1953
|
+
// stopInput2,
|
|
1954
|
+
// stopOutput2,
|
|
1955
|
+
// );
|
|
1956
|
+
// }
|
|
1957
|
+
}
|
|
1958
|
+
}
|
|
1959
|
+
throw new Error('Invalid interpolation type.');
|
|
1960
|
+
}
|
|
1961
|
+
|
|
1962
|
+
var interpolationExpressions = {
|
|
1963
|
+
step: step,
|
|
1964
|
+
interpolate: interpolate,
|
|
1965
|
+
};
|
|
1966
|
+
|
|
1967
|
+
function isExpression(value) {
|
|
1968
|
+
if (Array.isArray(value)) {
|
|
1969
|
+
var lookup = value[0], cases = value.slice(1);
|
|
1970
|
+
var l = lookup;
|
|
1971
|
+
return (typeof l === 'string' &&
|
|
1972
|
+
l !== 'literal' &&
|
|
1973
|
+
l in expressions &&
|
|
1974
|
+
cases.length > 0);
|
|
1975
|
+
}
|
|
1976
|
+
return false;
|
|
1977
|
+
}
|
|
1978
|
+
var expressions = __assign(__assign(__assign(__assign(__assign(__assign({}, mathExpressions), typeExpressions), stringExpressions), lookupExpressions), decisionExpressions), interpolationExpressions);
|
|
1979
|
+
function evaluate(expression, data) {
|
|
1980
|
+
if (data === void 0) { data = {}; }
|
|
1392
1981
|
var name = expression[0], args = expression.slice(1);
|
|
1393
1982
|
var expressionFun = expressions[name];
|
|
1394
1983
|
if (expressionFun) {
|
|
1395
|
-
return expressionFun(
|
|
1984
|
+
return expressionFun(args.map(function (arg) { return (isExpression(arg) ? evaluate(arg, data) : arg); }), data);
|
|
1396
1985
|
}
|
|
1397
|
-
|
|
1986
|
+
throw new Error("Expression \"".concat(name, "\" is not supported."));
|
|
1398
1987
|
}
|
|
1988
|
+
|
|
1399
1989
|
function createPropertyExpressionCb(expression) {
|
|
1400
1990
|
return function (feature) {
|
|
1401
|
-
|
|
1991
|
+
var properties = feature.properties;
|
|
1992
|
+
if (properties) {
|
|
1993
|
+
return evaluate(expression, properties);
|
|
1994
|
+
}
|
|
1995
|
+
return false;
|
|
1402
1996
|
};
|
|
1403
1997
|
}
|
|
1404
1998
|
var excludeExpressionList = ['iconSize', 'iconAnchor'];
|