@dra2020/dra-types 1.8.141 → 1.8.143
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/datasets.d.ts +7 -0
- package/dist/dra-types.js +44 -0
- package/dist/dra-types.js.map +1 -1
- package/lib/datasets.ts +47 -0
- package/package.json +2 -2
package/dist/datasets.d.ts
CHANGED
|
@@ -90,3 +90,10 @@ export declare function datasetRestrict(ds: Dataset): {
|
|
|
90
90
|
export type DatasetIndex = {
|
|
91
91
|
[id: string]: Dataset;
|
|
92
92
|
};
|
|
93
|
+
export interface PrimaryKeys {
|
|
94
|
+
CENSUS: string;
|
|
95
|
+
VAP: string;
|
|
96
|
+
ELECTION: string;
|
|
97
|
+
}
|
|
98
|
+
export declare function defaultBuiltinKeys(state: string, datasource: string, planType: string, builtins: Set<string>): PrimaryKeys;
|
|
99
|
+
export declare function usesPrisonerAdjust(state: string, datasource: string, planType: string): boolean;
|
package/dist/dra-types.js
CHANGED
|
@@ -1408,6 +1408,8 @@ exports.formColorBy = formColorBy;
|
|
|
1408
1408
|
exports.parseColorBy = parseColorBy;
|
|
1409
1409
|
exports.isColorBy = isColorBy;
|
|
1410
1410
|
exports.datasetRestrict = datasetRestrict;
|
|
1411
|
+
exports.defaultBuiltinKeys = defaultBuiltinKeys;
|
|
1412
|
+
exports.usesPrisonerAdjust = usesPrisonerAdjust;
|
|
1411
1413
|
function sortFields(f1, f2) {
|
|
1412
1414
|
return (f1.order || 0) - (f2.order || 0);
|
|
1413
1415
|
}
|
|
@@ -1433,6 +1435,48 @@ function datasetRestrict(ds) {
|
|
|
1433
1435
|
return ds.meta[ds.id].restrict;
|
|
1434
1436
|
return null;
|
|
1435
1437
|
}
|
|
1438
|
+
;
|
|
1439
|
+
function defaultBuiltinKeys(state, datasource, planType, builtins) {
|
|
1440
|
+
function bestOf(a) { return a.find(s => builtins.has(s)); }
|
|
1441
|
+
return (datasource === '2020_VD')
|
|
1442
|
+
? {
|
|
1443
|
+
CENSUS: bestOf((usesPrisonerAdjust(state, datasource, planType)
|
|
1444
|
+
? ['D20FA', 'D20F', 'D19F', 'D18F']
|
|
1445
|
+
: ['D20F', 'D19F', 'D18F'])),
|
|
1446
|
+
VAP: bestOf(['D20T', 'D19T', 'D18T']),
|
|
1447
|
+
ELECTION: bestOf(['C16GCO', 'E20GPR', 'E16GPR'])
|
|
1448
|
+
}
|
|
1449
|
+
:
|
|
1450
|
+
{
|
|
1451
|
+
CENSUS: bestOf(['D10F', 'D16F']),
|
|
1452
|
+
VAP: bestOf(['D10T', 'D16T']),
|
|
1453
|
+
ELECTION: bestOf(['C16GCO', 'E20GPR', 'E16GPR', 'E08GPR'])
|
|
1454
|
+
};
|
|
1455
|
+
}
|
|
1456
|
+
// Hard-coded based on both the existence of the dataset and the legal requirements of that particular state
|
|
1457
|
+
// (e.g. NY uses for state house maps but not congressional maps). So that is why we hard-code rather than
|
|
1458
|
+
// derive from dataset metadata.
|
|
1459
|
+
//
|
|
1460
|
+
function usesPrisonerAdjust(state, datasource, planType) {
|
|
1461
|
+
if (datasource !== '2020_VD')
|
|
1462
|
+
return false;
|
|
1463
|
+
switch (state) {
|
|
1464
|
+
case 'CA':
|
|
1465
|
+
case 'DE':
|
|
1466
|
+
case 'MD':
|
|
1467
|
+
case 'NJ':
|
|
1468
|
+
case 'NV':
|
|
1469
|
+
case 'PA':
|
|
1470
|
+
case 'VA':
|
|
1471
|
+
case 'WA':
|
|
1472
|
+
return (planType === 'congress' || planType === 'upper' || planType === 'lower' || planType === 'coi');
|
|
1473
|
+
case 'CO':
|
|
1474
|
+
case 'CT':
|
|
1475
|
+
case 'NY':
|
|
1476
|
+
return (planType === 'upper' || planType === 'lower' || planType === 'coi');
|
|
1477
|
+
}
|
|
1478
|
+
return false;
|
|
1479
|
+
}
|
|
1436
1480
|
|
|
1437
1481
|
|
|
1438
1482
|
/***/ }),
|