@nextgis/ngw-leaflet 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-leaflet.esm-browser.js +597 -22
- package/lib/ngw-leaflet.esm-browser.js.map +1 -1
- package/lib/ngw-leaflet.esm-browser.prod.js +2 -2
- package/lib/ngw-leaflet.esm-browser.prod.js.map +1 -1
- package/lib/ngw-leaflet.esm-bundler.js +1 -1
- package/lib/ngw-leaflet.global.js +616 -22
- package/lib/ngw-leaflet.global.js.map +1 -1
- package/lib/ngw-leaflet.global.prod.js +2 -2
- package/lib/ngw-leaflet.global.prod.js.map +1 -1
- package/package.json +4 -4
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
/** Bundle of @nextgis/ngw-leaflet; version: 1.
|
|
1
|
+
/** Bundle of @nextgis/ngw-leaflet; version: 1.18.0; author: NextGIS */
|
|
2
2
|
function styleInject(css, ref) {
|
|
3
3
|
if ( ref === void 0 ) ref = {};
|
|
4
4
|
var insertAt = ref.insertAt;
|
|
@@ -15257,12 +15257,6 @@ function fixUrlStr(url) {
|
|
|
15257
15257
|
return url.replace(/([^:]\/)\/+/g, '$1');
|
|
15258
15258
|
}
|
|
15259
15259
|
|
|
15260
|
-
function isExpression(value) {
|
|
15261
|
-
if (Array.isArray(value)) {
|
|
15262
|
-
return true;
|
|
15263
|
-
}
|
|
15264
|
-
return false;
|
|
15265
|
-
}
|
|
15266
15260
|
function isPropertiesPaint(paint) {
|
|
15267
15261
|
if (Array.isArray(paint)) {
|
|
15268
15262
|
return true;
|
|
@@ -15282,41 +15276,622 @@ function isPaintCallback(paint) {
|
|
|
15282
15276
|
return false;
|
|
15283
15277
|
}
|
|
15284
15278
|
|
|
15285
|
-
|
|
15286
|
-
|
|
15287
|
-
|
|
15279
|
+
const tryConvert = (converter, arg, data) => {
|
|
15280
|
+
try {
|
|
15281
|
+
const result = converter(arg, data);
|
|
15282
|
+
if (result !== undefined) {
|
|
15283
|
+
return result;
|
|
15284
|
+
}
|
|
15285
|
+
}
|
|
15286
|
+
catch {
|
|
15287
|
+
// ignore errors
|
|
15288
|
+
}
|
|
15289
|
+
return undefined;
|
|
15290
|
+
};
|
|
15291
|
+
|
|
15292
|
+
function fallback(cb) {
|
|
15293
|
+
return (args, data) => {
|
|
15294
|
+
for (const arg of args) {
|
|
15295
|
+
const result = tryConvert(cb, arg, data);
|
|
15296
|
+
if (result !== undefined) {
|
|
15297
|
+
return result;
|
|
15298
|
+
}
|
|
15299
|
+
}
|
|
15300
|
+
throw new Error(`Received a mismatched type`);
|
|
15301
|
+
};
|
|
15288
15302
|
}
|
|
15289
|
-
|
|
15290
|
-
|
|
15291
|
-
|
|
15292
|
-
|
|
15293
|
-
|
|
15303
|
+
|
|
15304
|
+
const array = (args) => {
|
|
15305
|
+
const [firstArg, secondArg, thirdArg] = args;
|
|
15306
|
+
let requiredType = undefined;
|
|
15307
|
+
let requiredLength = undefined;
|
|
15308
|
+
let value;
|
|
15309
|
+
if (typeof firstArg === 'string' &&
|
|
15310
|
+
['string', 'number', 'boolean'].includes(firstArg)) {
|
|
15311
|
+
requiredType = firstArg;
|
|
15312
|
+
if (typeof secondArg === 'number') {
|
|
15313
|
+
requiredLength = secondArg;
|
|
15314
|
+
value = thirdArg;
|
|
15315
|
+
}
|
|
15316
|
+
else {
|
|
15317
|
+
value = secondArg;
|
|
15318
|
+
}
|
|
15319
|
+
}
|
|
15320
|
+
else if (Array.isArray(firstArg)) {
|
|
15321
|
+
value = firstArg;
|
|
15322
|
+
}
|
|
15323
|
+
if (!Array.isArray(value)) {
|
|
15324
|
+
throw new Error('Expected an array');
|
|
15325
|
+
}
|
|
15326
|
+
if (requiredType && !value.every((item) => typeof item === requiredType)) {
|
|
15327
|
+
throw new Error(`Expected all items in array to be of type ${requiredType}`);
|
|
15328
|
+
}
|
|
15329
|
+
if (requiredLength && value.length !== requiredLength) {
|
|
15330
|
+
throw new Error(`Expected array of length ${requiredLength}`);
|
|
15331
|
+
}
|
|
15332
|
+
return value;
|
|
15333
|
+
};
|
|
15334
|
+
const typeExpressions = {
|
|
15335
|
+
array,
|
|
15336
|
+
boolean: fallback((arg) => (typeof arg === 'boolean' ? arg : undefined)),
|
|
15337
|
+
literal: ([arg]) => arg,
|
|
15338
|
+
number: fallback((arg) => (typeof arg === 'number' ? arg : undefined)),
|
|
15339
|
+
object: fallback((arg) => arg !== null && typeof arg === 'object' && !Array.isArray(arg)
|
|
15340
|
+
? arg
|
|
15341
|
+
: undefined),
|
|
15342
|
+
string: fallback((arg) => (typeof arg === 'string' ? arg : undefined)),
|
|
15343
|
+
'to-boolean': fallback(Boolean),
|
|
15344
|
+
'to-number': fallback(Number),
|
|
15345
|
+
'to-string': fallback(String),
|
|
15346
|
+
typeof: ([arg]) => typeof arg,
|
|
15347
|
+
};
|
|
15348
|
+
|
|
15349
|
+
const mathExpressions = {
|
|
15350
|
+
'+': (args) => args.reduce((a, b) => a + b, 0),
|
|
15351
|
+
'-': (args) => args.reduce((a, b) => a - b),
|
|
15352
|
+
'*': (args) => args.reduce((a, b) => a * b, 1),
|
|
15353
|
+
'/': (args) => args.reduce((a, b) => a / b),
|
|
15354
|
+
'%': (args) => args[0] % args[1],
|
|
15355
|
+
'^': (args) => Math.pow(args[0], args[1]),
|
|
15356
|
+
abs: (args) => Math.abs(args[0]),
|
|
15357
|
+
acos: (args) => Math.acos(args[0]),
|
|
15358
|
+
asin: (args) => Math.asin(args[0]),
|
|
15359
|
+
atan: (args) => Math.atan(args[0]),
|
|
15360
|
+
ceil: (args) => Math.ceil(args[0]),
|
|
15361
|
+
cos: (args) => Math.cos(args[0]),
|
|
15362
|
+
e: () => Math.E,
|
|
15363
|
+
floor: (args) => Math.floor(args[0]),
|
|
15364
|
+
ln: (args) => Math.log(args[0]),
|
|
15365
|
+
ln2: () => Math.LN2,
|
|
15366
|
+
log10: (args) => Math.log10(args[0]),
|
|
15367
|
+
log2: (args) => Math.log2(args[0]),
|
|
15368
|
+
max: (args) => Math.max(...args),
|
|
15369
|
+
min: (args) => Math.min(...args),
|
|
15370
|
+
pi: () => Math.PI,
|
|
15371
|
+
round: (args) => Math.round(args[0]),
|
|
15372
|
+
sin: (args) => Math.sin(args[0]),
|
|
15373
|
+
sqrt: (args) => Math.sqrt(args[0]),
|
|
15374
|
+
tan: (args) => Math.tan(args[0]),
|
|
15375
|
+
};
|
|
15376
|
+
|
|
15377
|
+
function get([key, objExp], data) {
|
|
15378
|
+
const target = objExp || data;
|
|
15379
|
+
if (target && typeof target === 'object' && key in target) {
|
|
15380
|
+
return target[key];
|
|
15381
|
+
}
|
|
15382
|
+
return null;
|
|
15383
|
+
}
|
|
15384
|
+
function has([key, objExp], data) {
|
|
15385
|
+
const target = objExp || data;
|
|
15386
|
+
return !!(target && typeof target === 'object' && key in target);
|
|
15387
|
+
}
|
|
15388
|
+
function at([index, array]) {
|
|
15389
|
+
return array[index];
|
|
15390
|
+
}
|
|
15391
|
+
function inFunc([keyword, input]) {
|
|
15392
|
+
if (typeof input === 'string') {
|
|
15393
|
+
return input.includes(String(keyword));
|
|
15294
15394
|
}
|
|
15395
|
+
else if (Array.isArray(input)) {
|
|
15396
|
+
return input.includes(keyword);
|
|
15397
|
+
}
|
|
15398
|
+
throw new Error(`Invalid input type for 'in'. Expected string or array, got ${typeof input}.`);
|
|
15399
|
+
}
|
|
15400
|
+
const length = ([item]) => {
|
|
15401
|
+
if (typeof item === 'string' || Array.isArray(item)) {
|
|
15402
|
+
return item.length;
|
|
15403
|
+
}
|
|
15404
|
+
return undefined;
|
|
15405
|
+
};
|
|
15406
|
+
function indexOf([keyword, input, startIndex]) {
|
|
15407
|
+
if (typeof input === 'string') {
|
|
15408
|
+
return input.indexOf(String(keyword), startIndex);
|
|
15409
|
+
}
|
|
15410
|
+
else if (Array.isArray(input)) {
|
|
15411
|
+
return input.indexOf(keyword, startIndex);
|
|
15412
|
+
}
|
|
15413
|
+
throw new Error(`Invalid input type for 'index-of'. Expected string or array, got ${typeof input}.`);
|
|
15414
|
+
}
|
|
15415
|
+
function slice(args) {
|
|
15416
|
+
const [input, startIndex, endIndex] = args;
|
|
15417
|
+
if (typeof input === 'string') {
|
|
15418
|
+
return input.slice(startIndex, endIndex);
|
|
15419
|
+
}
|
|
15420
|
+
else if (Array.isArray(input)) {
|
|
15421
|
+
return input.slice(startIndex, endIndex);
|
|
15422
|
+
}
|
|
15423
|
+
throw new Error(`Invalid input type for 'slice'. Expected string or array, got ${typeof input}.`);
|
|
15424
|
+
}
|
|
15425
|
+
const lookupExpressions = {
|
|
15426
|
+
get,
|
|
15427
|
+
length,
|
|
15428
|
+
at,
|
|
15429
|
+
has,
|
|
15430
|
+
in: inFunc,
|
|
15431
|
+
'index-of': indexOf,
|
|
15432
|
+
slice,
|
|
15433
|
+
};
|
|
15434
|
+
|
|
15435
|
+
const stringExpressions = {
|
|
15436
|
+
concat: (args) => args.reduce((a, b) => String(a) + String(b), ''),
|
|
15437
|
+
downcase: (args) => String(args[0]).toLowerCase(),
|
|
15438
|
+
upcase: (args) => String(args[0]).toUpperCase(),
|
|
15439
|
+
};
|
|
15440
|
+
|
|
15441
|
+
function not([expr]) {
|
|
15442
|
+
return !expr;
|
|
15443
|
+
}
|
|
15444
|
+
const checkCompareValues = ([a, b]) => {
|
|
15445
|
+
if (typeof a !== typeof b) {
|
|
15446
|
+
throw new Error('Values have different types.');
|
|
15447
|
+
}
|
|
15448
|
+
};
|
|
15449
|
+
function notEqual([a, b]) {
|
|
15450
|
+
checkCompareValues([a, b]);
|
|
15451
|
+
return a !== b;
|
|
15452
|
+
}
|
|
15453
|
+
function lessThan([left, right]) {
|
|
15454
|
+
checkCompareValues([left, right]);
|
|
15455
|
+
return left < right;
|
|
15456
|
+
}
|
|
15457
|
+
function lessThanOrEqual([left, right]) {
|
|
15458
|
+
checkCompareValues([left, right]);
|
|
15459
|
+
return left <= right;
|
|
15460
|
+
}
|
|
15461
|
+
function equal([left, right]) {
|
|
15462
|
+
checkCompareValues([left, right]);
|
|
15463
|
+
return left === right;
|
|
15464
|
+
}
|
|
15465
|
+
function greaterThan([left, right]) {
|
|
15466
|
+
checkCompareValues([left, right]);
|
|
15467
|
+
return left > right;
|
|
15468
|
+
}
|
|
15469
|
+
function greaterThanOrEqual([left, right]) {
|
|
15470
|
+
checkCompareValues([left, right]);
|
|
15471
|
+
return left >= right;
|
|
15472
|
+
}
|
|
15473
|
+
function all(args) {
|
|
15474
|
+
for (let i = 0; i < args.length; i++) {
|
|
15475
|
+
const arg = args[i];
|
|
15476
|
+
if (!arg) {
|
|
15477
|
+
return false;
|
|
15478
|
+
}
|
|
15479
|
+
}
|
|
15480
|
+
return true;
|
|
15481
|
+
}
|
|
15482
|
+
function any(args) {
|
|
15483
|
+
for (let i = 0; i < args.length; i++) {
|
|
15484
|
+
const arg = args[i];
|
|
15485
|
+
if (arg) {
|
|
15486
|
+
return true;
|
|
15487
|
+
}
|
|
15488
|
+
}
|
|
15489
|
+
return false;
|
|
15490
|
+
}
|
|
15491
|
+
function match(args) {
|
|
15492
|
+
const [lookup, ...cases] = args;
|
|
15295
15493
|
// remove last odd item from cases array
|
|
15296
15494
|
const defValue = cases.splice(-1, cases.length % 2)[0];
|
|
15297
15495
|
for (let fry = 0; fry < cases.length - 1; fry += 2) {
|
|
15298
15496
|
const key = cases[fry];
|
|
15299
|
-
if (key ===
|
|
15497
|
+
if (key === lookup) {
|
|
15300
15498
|
return cases[fry + 1];
|
|
15301
15499
|
}
|
|
15302
15500
|
}
|
|
15303
15501
|
return defValue;
|
|
15304
15502
|
}
|
|
15305
|
-
|
|
15306
|
-
|
|
15503
|
+
function caseFunc(args) {
|
|
15504
|
+
if (args.length < 2) {
|
|
15505
|
+
throw new Error('The "case" function requires at least a condition and a corresponding output.');
|
|
15506
|
+
}
|
|
15507
|
+
const fallback = args[args.length - 1];
|
|
15508
|
+
if (args.length % 2 === 0) {
|
|
15509
|
+
throw new Error('Missing a fallback value or unmatched condition-output pair.');
|
|
15510
|
+
}
|
|
15511
|
+
for (let i = 0; i < args.length - 1; i += 2) {
|
|
15512
|
+
const condition = args[i];
|
|
15513
|
+
const value = args[i + 1];
|
|
15514
|
+
if (condition) {
|
|
15515
|
+
return value;
|
|
15516
|
+
}
|
|
15517
|
+
}
|
|
15518
|
+
return fallback;
|
|
15519
|
+
}
|
|
15520
|
+
const decisionExpressions = {
|
|
15521
|
+
'!': not,
|
|
15522
|
+
'!=': notEqual,
|
|
15523
|
+
'<': lessThan,
|
|
15524
|
+
'<=': lessThanOrEqual,
|
|
15525
|
+
'==': equal,
|
|
15526
|
+
'>': greaterThan,
|
|
15527
|
+
'>=': greaterThanOrEqual,
|
|
15528
|
+
all: all,
|
|
15529
|
+
any: any,
|
|
15530
|
+
case: caseFunc,
|
|
15307
15531
|
match,
|
|
15308
15532
|
};
|
|
15309
|
-
|
|
15533
|
+
|
|
15534
|
+
function step(args) {
|
|
15535
|
+
const [input, defaultValue, ...stops] = args;
|
|
15536
|
+
if (typeof input !== 'number') {
|
|
15537
|
+
return defaultValue;
|
|
15538
|
+
}
|
|
15539
|
+
for (let i = 0; i < stops.length - 2; i += 2) {
|
|
15540
|
+
const stopInput = stops[i];
|
|
15541
|
+
const stopOutput = stops[i + 1];
|
|
15542
|
+
const nextStopInput = stops[i + 2];
|
|
15543
|
+
if (input >= stopInput && input < nextStopInput) {
|
|
15544
|
+
return stopOutput;
|
|
15545
|
+
}
|
|
15546
|
+
}
|
|
15547
|
+
if (input >= stops[stops.length - 2]) {
|
|
15548
|
+
return stops[stops.length - 1];
|
|
15549
|
+
}
|
|
15550
|
+
return defaultValue;
|
|
15551
|
+
}
|
|
15552
|
+
|
|
15553
|
+
const COLORS = {
|
|
15554
|
+
aliceblue: '#f0f8ff',
|
|
15555
|
+
antiquewhite: '#faebd7',
|
|
15556
|
+
aqua: '#00ffff',
|
|
15557
|
+
aquamarine: '#7fffd4',
|
|
15558
|
+
azure: '#f0ffff',
|
|
15559
|
+
beige: '#f5f5dc',
|
|
15560
|
+
bisque: '#ffe4c4',
|
|
15561
|
+
black: '#000000',
|
|
15562
|
+
blanchedalmond: '#ffebcd',
|
|
15563
|
+
blue: '#0000ff',
|
|
15564
|
+
blueviolet: '#8a2be2',
|
|
15565
|
+
brown: '#a52a2a',
|
|
15566
|
+
burlywood: '#deb887',
|
|
15567
|
+
cadetblue: '#5f9ea0',
|
|
15568
|
+
chartreuse: '#7fff00',
|
|
15569
|
+
chocolate: '#d2691e',
|
|
15570
|
+
coral: '#ff7f50',
|
|
15571
|
+
cornflowerblue: '#6495ed',
|
|
15572
|
+
cornsilk: '#fff8dc',
|
|
15573
|
+
crimson: '#dc143c',
|
|
15574
|
+
cyan: '#00ffff',
|
|
15575
|
+
darkblue: '#00008b',
|
|
15576
|
+
darkcyan: '#008b8b',
|
|
15577
|
+
darkgoldenrod: '#b8860b',
|
|
15578
|
+
darkgray: '#a9a9a9',
|
|
15579
|
+
darkgreen: '#006400',
|
|
15580
|
+
darkkhaki: '#bdb76b',
|
|
15581
|
+
darkmagenta: '#8b008b',
|
|
15582
|
+
darkolivegreen: '#556b2f',
|
|
15583
|
+
darkorange: '#ff8c00',
|
|
15584
|
+
darkorchid: '#9932cc',
|
|
15585
|
+
darkred: '#8b0000',
|
|
15586
|
+
darksalmon: '#e9967a',
|
|
15587
|
+
darkseagreen: '#8fbc8f',
|
|
15588
|
+
darkslateblue: '#483d8b',
|
|
15589
|
+
darkslategray: '#2f4f4f',
|
|
15590
|
+
darkturquoise: '#00ced1',
|
|
15591
|
+
darkviolet: '#9400d3',
|
|
15592
|
+
deeppink: '#ff1493',
|
|
15593
|
+
deepskyblue: '#00bfff',
|
|
15594
|
+
dimgray: '#696969',
|
|
15595
|
+
dodgerblue: '#1e90ff',
|
|
15596
|
+
firebrick: '#b22222',
|
|
15597
|
+
floralwhite: '#fffaf0',
|
|
15598
|
+
forestgreen: '#228b22',
|
|
15599
|
+
fuchsia: '#ff00ff',
|
|
15600
|
+
gainsboro: '#dcdcdc',
|
|
15601
|
+
ghostwhite: '#f8f8ff',
|
|
15602
|
+
gold: '#ffd700',
|
|
15603
|
+
goldenrod: '#daa520',
|
|
15604
|
+
gray: '#808080',
|
|
15605
|
+
green: '#008000',
|
|
15606
|
+
greenyellow: '#adff2f',
|
|
15607
|
+
honeydew: '#f0fff0',
|
|
15608
|
+
hotpink: '#ff69b4',
|
|
15609
|
+
'indianred ': '#cd5c5c',
|
|
15610
|
+
indigo: '#4b0082',
|
|
15611
|
+
ivory: '#fffff0',
|
|
15612
|
+
khaki: '#f0e68c',
|
|
15613
|
+
lavender: '#e6e6fa',
|
|
15614
|
+
lavenderblush: '#fff0f5',
|
|
15615
|
+
lawngreen: '#7cfc00',
|
|
15616
|
+
lemonchiffon: '#fffacd',
|
|
15617
|
+
lightblue: '#add8e6',
|
|
15618
|
+
lightcoral: '#f08080',
|
|
15619
|
+
lightcyan: '#e0ffff',
|
|
15620
|
+
lightgoldenrodyellow: '#fafad2',
|
|
15621
|
+
lightgrey: '#d3d3d3',
|
|
15622
|
+
lightgreen: '#90ee90',
|
|
15623
|
+
lightpink: '#ffb6c1',
|
|
15624
|
+
lightsalmon: '#ffa07a',
|
|
15625
|
+
lightseagreen: '#20b2aa',
|
|
15626
|
+
lightskyblue: '#87cefa',
|
|
15627
|
+
lightslategray: '#778899',
|
|
15628
|
+
lightsteelblue: '#b0c4de',
|
|
15629
|
+
lightyellow: '#ffffe0',
|
|
15630
|
+
lime: '#00ff00',
|
|
15631
|
+
limegreen: '#32cd32',
|
|
15632
|
+
linen: '#faf0e6',
|
|
15633
|
+
magenta: '#ff00ff',
|
|
15634
|
+
maroon: '#800000',
|
|
15635
|
+
mediumaquamarine: '#66cdaa',
|
|
15636
|
+
mediumblue: '#0000cd',
|
|
15637
|
+
mediumorchid: '#ba55d3',
|
|
15638
|
+
mediumpurple: '#9370d8',
|
|
15639
|
+
mediumseagreen: '#3cb371',
|
|
15640
|
+
mediumslateblue: '#7b68ee',
|
|
15641
|
+
mediumspringgreen: '#00fa9a',
|
|
15642
|
+
mediumturquoise: '#48d1cc',
|
|
15643
|
+
mediumvioletred: '#c71585',
|
|
15644
|
+
midnightblue: '#191970',
|
|
15645
|
+
mintcream: '#f5fffa',
|
|
15646
|
+
mistyrose: '#ffe4e1',
|
|
15647
|
+
moccasin: '#ffe4b5',
|
|
15648
|
+
navajowhite: '#ffdead',
|
|
15649
|
+
navy: '#000080',
|
|
15650
|
+
oldlace: '#fdf5e6',
|
|
15651
|
+
olive: '#808000',
|
|
15652
|
+
olivedrab: '#6b8e23',
|
|
15653
|
+
orange: '#ffa500',
|
|
15654
|
+
orangered: '#ff4500',
|
|
15655
|
+
orchid: '#da70d6',
|
|
15656
|
+
palegoldenrod: '#eee8aa',
|
|
15657
|
+
palegreen: '#98fb98',
|
|
15658
|
+
paleturquoise: '#afeeee',
|
|
15659
|
+
palevioletred: '#d87093',
|
|
15660
|
+
papayawhip: '#ffefd5',
|
|
15661
|
+
peachpuff: '#ffdab9',
|
|
15662
|
+
peru: '#cd853f',
|
|
15663
|
+
pink: '#ffc0cb',
|
|
15664
|
+
plum: '#dda0dd',
|
|
15665
|
+
powderblue: '#b0e0e6',
|
|
15666
|
+
purple: '#800080',
|
|
15667
|
+
rebeccapurple: '#663399',
|
|
15668
|
+
red: '#ff0000',
|
|
15669
|
+
rosybrown: '#bc8f8f',
|
|
15670
|
+
royalblue: '#4169e1',
|
|
15671
|
+
saddlebrown: '#8b4513',
|
|
15672
|
+
salmon: '#fa8072',
|
|
15673
|
+
sandybrown: '#f4a460',
|
|
15674
|
+
seagreen: '#2e8b57',
|
|
15675
|
+
seashell: '#fff5ee',
|
|
15676
|
+
sienna: '#a0522d',
|
|
15677
|
+
silver: '#c0c0c0',
|
|
15678
|
+
skyblue: '#87ceeb',
|
|
15679
|
+
slateblue: '#6a5acd',
|
|
15680
|
+
slategray: '#708090',
|
|
15681
|
+
snow: '#fffafa',
|
|
15682
|
+
springgreen: '#00ff7f',
|
|
15683
|
+
steelblue: '#4682b4',
|
|
15684
|
+
tan: '#d2b48c',
|
|
15685
|
+
teal: '#008080',
|
|
15686
|
+
thistle: '#d8bfd8',
|
|
15687
|
+
tomato: '#ff6347',
|
|
15688
|
+
turquoise: '#40e0d0',
|
|
15689
|
+
violet: '#ee82ee',
|
|
15690
|
+
wheat: '#f5deb3',
|
|
15691
|
+
white: '#ffffff',
|
|
15692
|
+
whitesmoke: '#f5f5f5',
|
|
15693
|
+
yellow: '#ffff00',
|
|
15694
|
+
yellowgreen: '#9acd32',
|
|
15695
|
+
};
|
|
15696
|
+
|
|
15697
|
+
function isHex(hex) {
|
|
15698
|
+
return typeof hex === 'string' && /^#([A-Fa-f0-9]{3}){1,2}$/.test(hex);
|
|
15699
|
+
}
|
|
15700
|
+
function isRgb(hex) {
|
|
15701
|
+
const r =
|
|
15702
|
+
// eslint-disable-next-line max-len
|
|
15703
|
+
/^rgb(a?)\(\s*([0-9]+)\s*,\s*([0-9]+)\s*,\s*([0-9]+)(?:\s*,\s*([01](?:\.\d+)?))?\s*\)$/;
|
|
15704
|
+
return typeof hex === 'string' && r.test(hex);
|
|
15705
|
+
}
|
|
15706
|
+
function isColorObj(obj) {
|
|
15707
|
+
if (typeof obj === 'object' && obj !== null) {
|
|
15708
|
+
const hasRgb = 'r' in obj && 'g' in obj && 'b' in obj;
|
|
15709
|
+
const hasValidAlpha = !('a' in obj) || (typeof obj.a === 'number' && obj.a >= 0 && obj.a <= 1);
|
|
15710
|
+
return hasRgb && hasValidAlpha;
|
|
15711
|
+
}
|
|
15712
|
+
return false;
|
|
15713
|
+
}
|
|
15714
|
+
function isColorName(name) {
|
|
15715
|
+
if (typeof name === 'string' && name in COLORS) {
|
|
15716
|
+
return true;
|
|
15717
|
+
}
|
|
15718
|
+
return false;
|
|
15719
|
+
}
|
|
15720
|
+
function toColor(value) {
|
|
15721
|
+
if (isHex(value)) {
|
|
15722
|
+
return hexToColor(value);
|
|
15723
|
+
}
|
|
15724
|
+
else if (isColorName(value)) {
|
|
15725
|
+
return colorNameToColor(value);
|
|
15726
|
+
}
|
|
15727
|
+
else if (isRgb(value)) {
|
|
15728
|
+
return rgbToColor(value);
|
|
15729
|
+
}
|
|
15730
|
+
else if (isColorObj(value)) {
|
|
15731
|
+
return colorObjectToColor(value);
|
|
15732
|
+
}
|
|
15733
|
+
throw new Error(`The '${value}' cannot be converted to color`);
|
|
15734
|
+
}
|
|
15735
|
+
function colorNameToColor(name) {
|
|
15736
|
+
return hexToColor(COLORS[name]);
|
|
15737
|
+
}
|
|
15738
|
+
function hexToColor(hex) {
|
|
15739
|
+
const shortRGB = /^#([0-9a-fA-F])([0-9a-fA-F])([0-9a-fA-F])$/;
|
|
15740
|
+
const shortRGBA = /^#([0-9a-fA-F])([0-9a-fA-F])([0-9a-fA-F])([0-9a-fA-F])$/;
|
|
15741
|
+
const longRGB = /^#([0-9a-fA-F]{2})([0-9a-fA-F]{2})([0-9a-fA-F]{2})$/;
|
|
15742
|
+
const longRGBA = /^#([0-9a-fA-F]{2})([0-9a-fA-F]{2})([0-9a-fA-F]{2})([0-9a-fA-F]{2})$/;
|
|
15743
|
+
let result;
|
|
15744
|
+
if ((result = shortRGB.exec(hex))) {
|
|
15745
|
+
return [
|
|
15746
|
+
parseInt(result[1] + result[1], 16),
|
|
15747
|
+
parseInt(result[2] + result[2], 16),
|
|
15748
|
+
parseInt(result[3] + result[3], 16),
|
|
15749
|
+
];
|
|
15750
|
+
}
|
|
15751
|
+
else if ((result = shortRGBA.exec(hex))) {
|
|
15752
|
+
return [
|
|
15753
|
+
parseInt(result[1] + result[1], 16),
|
|
15754
|
+
parseInt(result[2] + result[2], 16),
|
|
15755
|
+
parseInt(result[3] + result[3], 16),
|
|
15756
|
+
parseInt(result[4] + result[4], 16) / 255,
|
|
15757
|
+
];
|
|
15758
|
+
}
|
|
15759
|
+
else if ((result = longRGB.exec(hex))) {
|
|
15760
|
+
return [
|
|
15761
|
+
parseInt(result[1], 16),
|
|
15762
|
+
parseInt(result[2], 16),
|
|
15763
|
+
parseInt(result[3], 16),
|
|
15764
|
+
];
|
|
15765
|
+
}
|
|
15766
|
+
else if ((result = longRGBA.exec(hex))) {
|
|
15767
|
+
return [
|
|
15768
|
+
parseInt(result[1], 16),
|
|
15769
|
+
parseInt(result[2], 16),
|
|
15770
|
+
parseInt(result[3], 16),
|
|
15771
|
+
parseInt(result[4], 16) / 255,
|
|
15772
|
+
];
|
|
15773
|
+
}
|
|
15774
|
+
throw new Error(`The '${hex}' Is not valid hex`);
|
|
15775
|
+
}
|
|
15776
|
+
function rgbToColor(rgb) {
|
|
15777
|
+
const rgbPattern = /^rgb\((\d+),\s*(\d+),\s*(\d+)\)$/;
|
|
15778
|
+
const rgbaPattern = /^rgba\((\d+),\s*(\d+),\s*(\d+),\s*([\d.]+)\)$/;
|
|
15779
|
+
let matches;
|
|
15780
|
+
if ((matches = rgb.match(rgbPattern))) {
|
|
15781
|
+
return [
|
|
15782
|
+
parseInt(matches[1], 10),
|
|
15783
|
+
parseInt(matches[2], 10),
|
|
15784
|
+
parseInt(matches[3], 10),
|
|
15785
|
+
];
|
|
15786
|
+
}
|
|
15787
|
+
else if ((matches = rgb.match(rgbaPattern))) {
|
|
15788
|
+
return [
|
|
15789
|
+
parseInt(matches[1], 10),
|
|
15790
|
+
parseInt(matches[2], 10),
|
|
15791
|
+
parseInt(matches[3], 10),
|
|
15792
|
+
parseFloat(matches[4]),
|
|
15793
|
+
];
|
|
15794
|
+
}
|
|
15795
|
+
throw new Error(`The '${rgb}' Is not valid rgb`);
|
|
15796
|
+
}
|
|
15797
|
+
function colorObjectToColor({ r, g, b, a }) {
|
|
15798
|
+
return [r, g, b, ...(a !== undefined ? [a] : [])];
|
|
15799
|
+
}
|
|
15800
|
+
function colorToRGB(array) {
|
|
15801
|
+
return `rgb(${array.join(',')})`;
|
|
15802
|
+
}
|
|
15803
|
+
|
|
15804
|
+
function linearInterpolation(input, input1, output1, input2, output2) {
|
|
15805
|
+
if (typeof output1 === 'number' && typeof output2 === 'number') {
|
|
15806
|
+
return (output1 + ((input - input1) / (input2 - input1)) * (output2 - output1));
|
|
15807
|
+
}
|
|
15808
|
+
try {
|
|
15809
|
+
const outputColor1 = toColor(output1);
|
|
15810
|
+
const outputColor2 = toColor(output2);
|
|
15811
|
+
return colorToRGB(outputColor1.map((val, index) => {
|
|
15812
|
+
return Math.ceil(linearInterpolation(input, input1, val, input2, outputColor2[index]));
|
|
15813
|
+
}));
|
|
15814
|
+
}
|
|
15815
|
+
catch (er) {
|
|
15816
|
+
console.log(er);
|
|
15817
|
+
}
|
|
15818
|
+
throw new Error('Unsupported output type for linear interpolation.');
|
|
15819
|
+
}
|
|
15820
|
+
function interpolate([interpolation, input, ...stops]) {
|
|
15821
|
+
if (stops.length < 2) {
|
|
15822
|
+
throw new Error('At least two stops are required');
|
|
15823
|
+
}
|
|
15824
|
+
if (typeof input !== 'number') {
|
|
15825
|
+
throw new Error('Input must be a number.');
|
|
15826
|
+
}
|
|
15827
|
+
if (stops.length < 2 || stops.length % 2 !== 0) {
|
|
15828
|
+
throw new Error('Invalid stops provided.');
|
|
15829
|
+
}
|
|
15830
|
+
for (let i = 0; i < stops.length - 2; i += 2) {
|
|
15831
|
+
const stopInput1 = stops[i];
|
|
15832
|
+
const stopOutput1 = stops[i + 1];
|
|
15833
|
+
const stopInput2 = stops[i + 2];
|
|
15834
|
+
const stopOutput2 = stops[i + 3];
|
|
15835
|
+
if (input >= stopInput1 && input <= stopInput2) {
|
|
15836
|
+
if (interpolation[0] === 'linear') {
|
|
15837
|
+
return linearInterpolation(input, stopInput1, stopOutput1, stopInput2, stopOutput2);
|
|
15838
|
+
}
|
|
15839
|
+
// else if (interpolation[0] === 'exponential') {
|
|
15840
|
+
// const base = interpolation[1];
|
|
15841
|
+
// return exponentialInterpolation(
|
|
15842
|
+
// input,
|
|
15843
|
+
// base,
|
|
15844
|
+
// stopInput1,
|
|
15845
|
+
// stopOutput1,
|
|
15846
|
+
// stopInput2,
|
|
15847
|
+
// stopOutput2,
|
|
15848
|
+
// );
|
|
15849
|
+
// }
|
|
15850
|
+
}
|
|
15851
|
+
}
|
|
15852
|
+
throw new Error('Invalid interpolation type.');
|
|
15853
|
+
}
|
|
15854
|
+
|
|
15855
|
+
const interpolationExpressions = {
|
|
15856
|
+
step,
|
|
15857
|
+
interpolate,
|
|
15858
|
+
};
|
|
15859
|
+
|
|
15860
|
+
function isExpression(value) {
|
|
15861
|
+
if (Array.isArray(value)) {
|
|
15862
|
+
const [lookup, ...cases] = value;
|
|
15863
|
+
const l = lookup;
|
|
15864
|
+
return (typeof l === 'string' &&
|
|
15865
|
+
l !== 'literal' &&
|
|
15866
|
+
l in expressions &&
|
|
15867
|
+
cases.length > 0);
|
|
15868
|
+
}
|
|
15869
|
+
return false;
|
|
15870
|
+
}
|
|
15871
|
+
const expressions = {
|
|
15872
|
+
...mathExpressions,
|
|
15873
|
+
...typeExpressions,
|
|
15874
|
+
...stringExpressions,
|
|
15875
|
+
...lookupExpressions,
|
|
15876
|
+
...decisionExpressions,
|
|
15877
|
+
...interpolationExpressions,
|
|
15878
|
+
};
|
|
15879
|
+
function evaluate(expression, data = {}) {
|
|
15310
15880
|
const [name, ...args] = expression;
|
|
15311
15881
|
const expressionFun = expressions[name];
|
|
15312
15882
|
if (expressionFun) {
|
|
15313
|
-
return expressionFun(
|
|
15883
|
+
return expressionFun(args.map((arg) => (isExpression(arg) ? evaluate(arg, data) : arg)), data);
|
|
15314
15884
|
}
|
|
15315
|
-
|
|
15885
|
+
throw new Error(`Expression "${name}" is not supported.`);
|
|
15316
15886
|
}
|
|
15887
|
+
|
|
15317
15888
|
function createPropertyExpressionCb(expression) {
|
|
15318
15889
|
return (feature) => {
|
|
15319
|
-
|
|
15890
|
+
const properties = feature.properties;
|
|
15891
|
+
if (properties) {
|
|
15892
|
+
return evaluate(expression, properties);
|
|
15893
|
+
}
|
|
15894
|
+
return false;
|
|
15320
15895
|
};
|
|
15321
15896
|
}
|
|
15322
15897
|
const excludeExpressionList = ['iconSize', 'iconAnchor'];
|