@dra2020/baseclient 1.0.69 → 1.0.70
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/dist/baseclient.js +102 -54
- package/dist/baseclient.js.map +1 -1
- package/dist/colors/colors.d.ts +13 -4
- package/lib/colors/colors.ts +165 -115
- package/lib/poly/poly.ts +2 -2
- package/package.json +1 -1
package/dist/baseclient.js
CHANGED
|
@@ -98,13 +98,13 @@ var __importStar = (this && this.__importStar) || function (mod) {
|
|
|
98
98
|
return result;
|
|
99
99
|
};
|
|
100
100
|
Object.defineProperty(exports, "__esModule", ({ value: true }));
|
|
101
|
-
exports.
|
|
101
|
+
exports.getPalette = exports.orderedColors = exports.genColor = exports.defaultDistrictsPalette = exports.EthnicBackgroundColor = exports.CountEthnicBackgroundColor = exports.PartisanDistrictClassicColors = exports.CountPartisanDistrictClassicColors = exports.PartisanPrecinctClassicColors = exports.CountPartisanPrecinctClassicColors = exports.EthnicFewClassicColors = exports.CountEthnicFewClassicColors = exports.ColorValues = exports.DefaultColorNames = exports.MaxClassicColors = exports.MaxColors = exports.MaxOrderedColors = void 0;
|
|
102
102
|
const JsColorMapsData = __importStar(__webpack_require__(/*! ./jscolormapsdata */ "./lib/colors/jscolormapsdata.ts"));
|
|
103
103
|
const all_1 = __webpack_require__(/*! ../all/all */ "./lib/all/all.ts");
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
104
|
+
exports.MaxOrderedColors = 50;
|
|
105
|
+
exports.MaxColors = exports.MaxOrderedColors * 3; // Tied to orderedColors()
|
|
106
|
+
exports.MaxClassicColors = 55;
|
|
107
|
+
exports.DefaultColorNames = [
|
|
108
108
|
'GhostWhite',
|
|
109
109
|
'Blue',
|
|
110
110
|
'Green',
|
|
@@ -304,12 +304,16 @@ exports.ColorValues = {
|
|
|
304
304
|
'Yellow': '#FFFF00',
|
|
305
305
|
'YellowGreen': '#9ACD32',
|
|
306
306
|
};
|
|
307
|
+
// For Demographics scale (4 colors)
|
|
308
|
+
exports.CountEthnicFewClassicColors = 4;
|
|
307
309
|
exports.EthnicFewClassicColors = [
|
|
308
310
|
'#fafafa',
|
|
309
311
|
'#aaaaaa',
|
|
310
312
|
'#666666',
|
|
311
313
|
'#111111', //
|
|
312
314
|
];
|
|
315
|
+
// For Partisan Precinct Scale (12 colors)
|
|
316
|
+
exports.CountPartisanPrecinctClassicColors = 12;
|
|
313
317
|
exports.PartisanPrecinctClassicColors = [
|
|
314
318
|
'#960018',
|
|
315
319
|
'#FF2020',
|
|
@@ -324,78 +328,106 @@ exports.PartisanPrecinctClassicColors = [
|
|
|
324
328
|
'#2020FF',
|
|
325
329
|
'#00008B', // Dark blue
|
|
326
330
|
];
|
|
331
|
+
// For Partisan District Scale (12 stops)
|
|
332
|
+
exports.CountPartisanDistrictClassicColors = 12;
|
|
333
|
+
exports.PartisanDistrictClassicColors = [
|
|
334
|
+
'#960018',
|
|
335
|
+
'#960018',
|
|
336
|
+
'#FF2020',
|
|
337
|
+
'#FF2020',
|
|
338
|
+
'#FF6060',
|
|
339
|
+
'#FFDEDE',
|
|
340
|
+
'#DEDEFF',
|
|
341
|
+
'#6060FF',
|
|
342
|
+
'#2020FF',
|
|
343
|
+
'#2020FF',
|
|
344
|
+
'#00008B',
|
|
345
|
+
'#00008B', // .60 <= 1.0
|
|
346
|
+
];
|
|
347
|
+
// All Groups Mosaic 16 colors
|
|
348
|
+
exports.CountEthnicBackgroundColor = 16;
|
|
349
|
+
exports.EthnicBackgroundColor = [
|
|
350
|
+
'#c0392b',
|
|
351
|
+
'#3498db',
|
|
352
|
+
'#2ecc71',
|
|
353
|
+
'#9b59b6',
|
|
354
|
+
'#d98880',
|
|
355
|
+
'#aed6f1',
|
|
356
|
+
'#abebc6',
|
|
357
|
+
'#bb8fce',
|
|
358
|
+
'#f1c40f',
|
|
359
|
+
'#aab7b8',
|
|
360
|
+
'#d5f5e3',
|
|
361
|
+
'#d6eaf8',
|
|
362
|
+
'#186a3b',
|
|
363
|
+
'#e8daef',
|
|
364
|
+
'#45b39d',
|
|
365
|
+
'#4a235a', // black / asian
|
|
366
|
+
];
|
|
367
|
+
exports.defaultDistrictsPalette = 'jet_r';
|
|
368
|
+
// Static color tables; lazily populated
|
|
327
369
|
let ColorTable = {};
|
|
328
370
|
let OrderedColorTable = {};
|
|
329
371
|
function genColor(i, useFirstColor, palette) {
|
|
330
372
|
// i is district number, 0 => District[0] (unassigned), so subtract 1 to access ColorTable
|
|
331
|
-
if (!useFirstColor || !palette)
|
|
332
|
-
return genDRAColor(i, useFirstColor);
|
|
333
373
|
if (i == 0)
|
|
334
|
-
return exports.ColorValues[DefaultColorNames[0]];
|
|
335
|
-
|
|
336
|
-
|
|
337
|
-
|
|
338
|
-
|
|
339
|
-
|
|
340
|
-
|
|
341
|
-
|
|
342
|
-
case 'inferno':
|
|
343
|
-
case 'turbo':
|
|
344
|
-
default:
|
|
345
|
-
return orderedColors(palette)[(i - 1) % MaxOrderedColors];
|
|
346
|
-
case 'draclassic':
|
|
347
|
-
return genDRAColor(i, useFirstColor);
|
|
348
|
-
}
|
|
374
|
+
return exports.ColorValues[exports.DefaultColorNames[0]];
|
|
375
|
+
if (!useFirstColor || !palette || palette === 'draclassic')
|
|
376
|
+
return genDRAColor(i, useFirstColor);
|
|
377
|
+
const colors = orderedColors(palette);
|
|
378
|
+
if (colors.length >= exports.MaxOrderedColors)
|
|
379
|
+
return colors[(i - 1) % exports.MaxOrderedColors];
|
|
380
|
+
// Unexpected to get here, but something in case of an error
|
|
381
|
+
return genDRAColor(i, useFirstColor);
|
|
349
382
|
}
|
|
350
383
|
exports.genColor = genColor;
|
|
351
|
-
|
|
352
|
-
|
|
353
|
-
|
|
354
|
-
|
|
355
|
-
|
|
356
|
-
|
|
357
|
-
|
|
384
|
+
// DRA classic color palette
|
|
385
|
+
function genDRAColor(i, useFirstColor) {
|
|
386
|
+
// i is district number, 0 => District[0] (unassigned), so subtract 1 to access ColorTable
|
|
387
|
+
function gen_table() {
|
|
388
|
+
ColorTable['draclassic'] = [];
|
|
389
|
+
for (let i = 0; i < exports.MaxClassicColors; i++) {
|
|
390
|
+
// A little funky math below to skip the first (white) color
|
|
391
|
+
let j = (i % (exports.DefaultColorNames.length - 1)) + 1;
|
|
392
|
+
ColorTable['draclassic'].push(exports.ColorValues[exports.DefaultColorNames[j]]);
|
|
393
|
+
}
|
|
358
394
|
}
|
|
359
|
-
|
|
395
|
+
if (!ColorTable['draclassic'])
|
|
396
|
+
gen_table();
|
|
397
|
+
if (i == 0)
|
|
398
|
+
return exports.ColorValues[exports.DefaultColorNames[0]];
|
|
399
|
+
return ColorTable['draclassic'][((i - 1) + (useFirstColor ? 0 : 1)) % exports.MaxClassicColors];
|
|
360
400
|
}
|
|
361
|
-
exports.getPalette = getPalette;
|
|
362
401
|
const DistrictsColorOrder = [0, 49, 24, 36, 12, 42, 6, 30, 18, 45, 3, 27, 9, 33, 15, 46, 21, 39, 4, 28, 10, 34, 16, 48, 22, 40, 5, 29, 11, 35, 17, 1, 23, 41,
|
|
363
402
|
7, 31, 13, 37, 19, 47, 25, 43, 8, 32, 14, 38, 2, 20, 26, 44];
|
|
364
403
|
function orderedColors(palette) {
|
|
365
404
|
const colors = getPalette(palette);
|
|
366
405
|
if (!OrderedColorTable[palette]) {
|
|
367
406
|
OrderedColorTable[palette] = [];
|
|
368
|
-
for (let i = 0; i < MaxColors; i++) {
|
|
407
|
+
for (let i = 0; i < exports.MaxColors; i++) {
|
|
369
408
|
OrderedColorTable[palette].push(colors[DistrictsColorOrder[i] * 3]);
|
|
370
409
|
}
|
|
371
410
|
}
|
|
372
411
|
return OrderedColorTable[palette];
|
|
373
412
|
}
|
|
374
|
-
exports.
|
|
375
|
-
|
|
376
|
-
|
|
377
|
-
|
|
378
|
-
|
|
379
|
-
|
|
380
|
-
|
|
381
|
-
|
|
382
|
-
let j = (i % (DefaultColorNames.length - 1)) + 1;
|
|
383
|
-
ColorTable['draclassic'].push(exports.ColorValues[DefaultColorNames[j]]);
|
|
384
|
-
}
|
|
413
|
+
exports.orderedColors = orderedColors;
|
|
414
|
+
function getPalette(palette) {
|
|
415
|
+
if (palette === 'draclassic') {
|
|
416
|
+
// return draclassic palette with only 50 colors
|
|
417
|
+
let colors = [];
|
|
418
|
+
for (let i = 1; i < exports.MaxOrderedColors; i++)
|
|
419
|
+
colors.push(genDRAColor(i, true));
|
|
420
|
+
return colors;
|
|
385
421
|
}
|
|
386
|
-
|
|
387
|
-
gen_table();
|
|
388
|
-
if (i == 0)
|
|
389
|
-
return exports.ColorValues[DefaultColorNames[0]];
|
|
390
|
-
return ColorTable['draclassic'][((i - 1) + (useFirstColor ? 0 : 1)) % MaxClassicColors];
|
|
422
|
+
return getColorTable(palette);
|
|
391
423
|
}
|
|
392
|
-
exports.
|
|
424
|
+
exports.getPalette = getPalette;
|
|
393
425
|
// Generate table for palette
|
|
394
426
|
function getColorTable(palette) {
|
|
395
427
|
if (palette === 'demographicsclassic') {
|
|
396
428
|
if (!ColorTable[palette]) {
|
|
397
429
|
ColorTable[palette] = [];
|
|
398
|
-
for (let i = 0; i <
|
|
430
|
+
for (let i = 0; i < exports.CountEthnicFewClassicColors; i++)
|
|
399
431
|
ColorTable[palette].push(exports.EthnicFewClassicColors[i]);
|
|
400
432
|
}
|
|
401
433
|
return ColorTable[palette];
|
|
@@ -403,14 +435,30 @@ function getColorTable(palette) {
|
|
|
403
435
|
else if (palette === 'partisanclassic') {
|
|
404
436
|
if (!ColorTable[palette]) {
|
|
405
437
|
ColorTable[palette] = [];
|
|
406
|
-
for (let i = 0; i <
|
|
438
|
+
for (let i = 0; i < exports.CountPartisanPrecinctClassicColors; i++)
|
|
407
439
|
ColorTable[palette].push(exports.PartisanPrecinctClassicColors[i]);
|
|
408
440
|
}
|
|
409
441
|
return ColorTable[palette];
|
|
410
442
|
}
|
|
443
|
+
else if (palette === 'partisandistrictsclassic') {
|
|
444
|
+
if (!ColorTable[palette]) {
|
|
445
|
+
ColorTable[palette] = [];
|
|
446
|
+
for (let i = 0; i < exports.CountPartisanDistrictClassicColors; i++)
|
|
447
|
+
ColorTable[palette].push(exports.PartisanDistrictClassicColors[i]);
|
|
448
|
+
}
|
|
449
|
+
return ColorTable[palette];
|
|
450
|
+
}
|
|
451
|
+
else if (palette === 'allgroupsclassic') {
|
|
452
|
+
if (!ColorTable[palette]) {
|
|
453
|
+
ColorTable[palette] = [];
|
|
454
|
+
for (let i = 0; i < exports.CountEthnicBackgroundColor; i++)
|
|
455
|
+
ColorTable[palette].push(exports.EthnicBackgroundColor[i]);
|
|
456
|
+
return ColorTable[palette];
|
|
457
|
+
}
|
|
458
|
+
}
|
|
411
459
|
if (allPaletteNames.includes(palette)) {
|
|
412
460
|
if (!ColorTable[palette])
|
|
413
|
-
ColorTable[palette] = jscolormap(palette, MaxColors);
|
|
461
|
+
ColorTable[palette] = jscolormap(palette, exports.MaxColors);
|
|
414
462
|
return ColorTable[palette];
|
|
415
463
|
}
|
|
416
464
|
else
|
|
@@ -7413,9 +7461,9 @@ function featureRewind(f, options) {
|
|
|
7413
7461
|
return null;
|
|
7414
7462
|
// Has to be an unpacked feature
|
|
7415
7463
|
if (f.type !== 'Feature')
|
|
7416
|
-
|
|
7464
|
+
return f;
|
|
7417
7465
|
if (!f.geometry || f.geometry.packed)
|
|
7418
|
-
|
|
7466
|
+
return f;
|
|
7419
7467
|
// Non polygons are simpler
|
|
7420
7468
|
if (f.geometry.type !== 'Polygon' && f.geometry.type !== 'MultiPolygon')
|
|
7421
7469
|
return canonicalPoint(f, options);
|