@dra2020/district-analytics 16.1.6 → 16.1.8
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/district-analytics.js +208 -131
- package/dist/district-analytics.js.map +1 -1
- package/package.json +5 -5
|
@@ -38,13 +38,23 @@ var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (
|
|
|
38
38
|
}) : function(o, v) {
|
|
39
39
|
o["default"] = v;
|
|
40
40
|
});
|
|
41
|
-
var __importStar = (this && this.__importStar) || function (
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
};
|
|
41
|
+
var __importStar = (this && this.__importStar) || (function () {
|
|
42
|
+
var ownKeys = function(o) {
|
|
43
|
+
ownKeys = Object.getOwnPropertyNames || function (o) {
|
|
44
|
+
var ar = [];
|
|
45
|
+
for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
|
|
46
|
+
return ar;
|
|
47
|
+
};
|
|
48
|
+
return ownKeys(o);
|
|
49
|
+
};
|
|
50
|
+
return function (mod) {
|
|
51
|
+
if (mod && mod.__esModule) return mod;
|
|
52
|
+
var result = {};
|
|
53
|
+
if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
|
|
54
|
+
__setModuleDefault(result, mod);
|
|
55
|
+
return result;
|
|
56
|
+
};
|
|
57
|
+
})();
|
|
48
58
|
Object.defineProperty(exports, "__esModule", ({ value: true }));
|
|
49
59
|
exports.AnalyticsSession = void 0;
|
|
50
60
|
const baseclient_1 = __webpack_require__(/*! @dra2020/baseclient */ "@dra2020/baseclient");
|
|
@@ -307,15 +317,29 @@ var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (
|
|
|
307
317
|
}) : function(o, v) {
|
|
308
318
|
o["default"] = v;
|
|
309
319
|
});
|
|
310
|
-
var __importStar = (this && this.__importStar) || function (
|
|
311
|
-
|
|
312
|
-
|
|
313
|
-
|
|
314
|
-
|
|
315
|
-
|
|
316
|
-
};
|
|
320
|
+
var __importStar = (this && this.__importStar) || (function () {
|
|
321
|
+
var ownKeys = function(o) {
|
|
322
|
+
ownKeys = Object.getOwnPropertyNames || function (o) {
|
|
323
|
+
var ar = [];
|
|
324
|
+
for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
|
|
325
|
+
return ar;
|
|
326
|
+
};
|
|
327
|
+
return ownKeys(o);
|
|
328
|
+
};
|
|
329
|
+
return function (mod) {
|
|
330
|
+
if (mod && mod.__esModule) return mod;
|
|
331
|
+
var result = {};
|
|
332
|
+
if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
|
|
333
|
+
__setModuleDefault(result, mod);
|
|
334
|
+
return result;
|
|
335
|
+
};
|
|
336
|
+
})();
|
|
317
337
|
Object.defineProperty(exports, "__esModule", ({ value: true }));
|
|
318
|
-
exports.GraphClass = exports.
|
|
338
|
+
exports.GraphClass = exports.Plan = exports.State = exports.Counties = exports.Features = exports.Districts = void 0;
|
|
339
|
+
exports.inferSelectedMinority = inferSelectedMinority;
|
|
340
|
+
exports.geoIDForFeature = geoIDForFeature;
|
|
341
|
+
exports.fieldForFeature = fieldForFeature;
|
|
342
|
+
exports.invertPlan = invertPlan;
|
|
319
343
|
const dra_analytics_1 = __webpack_require__(/*! @dra2020/dra-analytics */ "@dra2020/dra-analytics");
|
|
320
344
|
const T = __importStar(__webpack_require__(/*! ./types */ "./src/types.ts"));
|
|
321
345
|
const U = __importStar(__webpack_require__(/*! ./utils */ "./src/utils.ts"));
|
|
@@ -538,6 +562,7 @@ class Districts {
|
|
|
538
562
|
// if (bLog) console.log("Statistics: Skipping water-only feature in district statistics:", geoID);
|
|
539
563
|
// }
|
|
540
564
|
});
|
|
565
|
+
//console.log(`totalVAP: ${totalVAP}, blackPop: ${blackPop}`);
|
|
541
566
|
// COMPUTE DERIVED VALUES
|
|
542
567
|
// MMD - Generalized the per-district population deviations's for MMD's with variable #'s of reps per district.
|
|
543
568
|
// - The real districts are indexed 1–N.
|
|
@@ -879,7 +904,6 @@ function inferSelectedMinority(groups) {
|
|
|
879
904
|
return 'Minority';
|
|
880
905
|
return 'No minority selected!';
|
|
881
906
|
}
|
|
882
|
-
exports.inferSelectedMinority = inferSelectedMinority;
|
|
883
907
|
// CLASSES, ETC. FOR FEATURE & COUNTY DATA
|
|
884
908
|
// Wrap data by feature, to abstract the specifics of the internal structure
|
|
885
909
|
class Features {
|
|
@@ -975,16 +999,11 @@ function geoIDForFeature(f) {
|
|
|
975
999
|
throw "Feature with no id property.";
|
|
976
1000
|
}
|
|
977
1001
|
}
|
|
978
|
-
exports.geoIDForFeature = geoIDForFeature;
|
|
979
1002
|
function fieldForFeature(f, dk /* dt: T.Dataset */, ff) {
|
|
980
1003
|
// Multiple keys to transparently handle NH and non-NH (e.g. Bl vs BlC) keyed fields
|
|
981
|
-
//
|
|
982
|
-
|
|
983
|
-
let result = 0;
|
|
984
|
-
keys.forEach(key => { result += _getFeatures(f, dk, key); });
|
|
985
|
-
return result;
|
|
1004
|
+
// Take the max (typically one field will be zero, but some datasets contain Bl subset of BlC)
|
|
1005
|
+
return Math.max(...T.fieldsFromFeatureField(dk, ff).map(key => _getFeatures(f, dk, key)));
|
|
986
1006
|
}
|
|
987
|
-
exports.fieldForFeature = fieldForFeature;
|
|
988
1007
|
// NOTE - This accessor is cloned from fGetW() in dra-client/restrict.ts
|
|
989
1008
|
// f is a direct GeoJSON feature
|
|
990
1009
|
// p is a geoID
|
|
@@ -1114,7 +1133,6 @@ function invertPlan(plan, s, bLog = false) {
|
|
|
1114
1133
|
}
|
|
1115
1134
|
return invertedPlan;
|
|
1116
1135
|
}
|
|
1117
|
-
exports.invertPlan = invertPlan;
|
|
1118
1136
|
class GraphClass {
|
|
1119
1137
|
constructor(s, graph) {
|
|
1120
1138
|
this._session = s;
|
|
@@ -1152,7 +1170,9 @@ exports.GraphClass = GraphClass;
|
|
|
1152
1170
|
// ANALYZE A PLAN
|
|
1153
1171
|
//
|
|
1154
1172
|
Object.defineProperty(exports, "__esModule", ({ value: true }));
|
|
1155
|
-
exports.
|
|
1173
|
+
exports.doAnalyzeDistricts = doAnalyzeDistricts;
|
|
1174
|
+
exports.doAnalyzePlan = doAnalyzePlan;
|
|
1175
|
+
exports.doDeriveSecondaryTests = doDeriveSecondaryTests;
|
|
1156
1176
|
const valid_1 = __webpack_require__(/*! ./valid */ "./src/valid.ts");
|
|
1157
1177
|
const equal_1 = __webpack_require__(/*! ./equal */ "./src/equal.ts");
|
|
1158
1178
|
const cohesive_1 = __webpack_require__(/*! ./cohesive */ "./src/cohesive.ts");
|
|
@@ -1161,7 +1181,6 @@ function doAnalyzeDistricts(s, bLog = false) {
|
|
|
1161
1181
|
s.districts.recalcStatistics(bLog);
|
|
1162
1182
|
s.districts.extractDistrictShapeProperties(bLog);
|
|
1163
1183
|
}
|
|
1164
|
-
exports.doAnalyzeDistricts = doAnalyzeDistricts;
|
|
1165
1184
|
// Calculate the analytics & validations and cache the results
|
|
1166
1185
|
// NOTE - doAnalyzePlan() depends on doAnalyzeDistricts() having run first.
|
|
1167
1186
|
// NOTE - I could make this table-driven, but I'm thinking that the explicit
|
|
@@ -1182,7 +1201,6 @@ function doAnalyzePlan(s, bLog = false) {
|
|
|
1182
1201
|
s.bPlanAnalyzed = true;
|
|
1183
1202
|
s.bPostProcessingDone = false;
|
|
1184
1203
|
}
|
|
1185
|
-
exports.doAnalyzePlan = doAnalyzePlan;
|
|
1186
1204
|
//
|
|
1187
1205
|
// Derive secondary analytics that are based on primary tests.
|
|
1188
1206
|
// This concept allows Population Deviation to be a primary numeric test and
|
|
@@ -1191,7 +1209,6 @@ exports.doAnalyzePlan = doAnalyzePlan;
|
|
|
1191
1209
|
function doDeriveSecondaryTests(s, bLog = false) {
|
|
1192
1210
|
s.tests[3 /* T.Test.EqualPopulation */] = (0, equal_1.doHasEqualPopulations)(s, bLog);
|
|
1193
1211
|
}
|
|
1194
|
-
exports.doDeriveSecondaryTests = doDeriveSecondaryTests;
|
|
1195
1212
|
|
|
1196
1213
|
|
|
1197
1214
|
/***/ }),
|
|
@@ -1222,15 +1239,26 @@ var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (
|
|
|
1222
1239
|
}) : function(o, v) {
|
|
1223
1240
|
o["default"] = v;
|
|
1224
1241
|
});
|
|
1225
|
-
var __importStar = (this && this.__importStar) || function (
|
|
1226
|
-
|
|
1227
|
-
|
|
1228
|
-
|
|
1229
|
-
|
|
1230
|
-
|
|
1231
|
-
};
|
|
1242
|
+
var __importStar = (this && this.__importStar) || (function () {
|
|
1243
|
+
var ownKeys = function(o) {
|
|
1244
|
+
ownKeys = Object.getOwnPropertyNames || function (o) {
|
|
1245
|
+
var ar = [];
|
|
1246
|
+
for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
|
|
1247
|
+
return ar;
|
|
1248
|
+
};
|
|
1249
|
+
return ownKeys(o);
|
|
1250
|
+
};
|
|
1251
|
+
return function (mod) {
|
|
1252
|
+
if (mod && mod.__esModule) return mod;
|
|
1253
|
+
var result = {};
|
|
1254
|
+
if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
|
|
1255
|
+
__setModuleDefault(result, mod);
|
|
1256
|
+
return result;
|
|
1257
|
+
};
|
|
1258
|
+
})();
|
|
1232
1259
|
Object.defineProperty(exports, "__esModule", ({ value: true }));
|
|
1233
|
-
exports.
|
|
1260
|
+
exports.doFindCountiesSplitUnexpectedly = doFindCountiesSplitUnexpectedly;
|
|
1261
|
+
exports.doFindSplitVTDs = doFindSplitVTDs;
|
|
1234
1262
|
const U = __importStar(__webpack_require__(/*! ./utils */ "./src/utils.ts"));
|
|
1235
1263
|
// The main county-district splitting code is in the dra-analytics package.
|
|
1236
1264
|
// ANALYZE SIMPLE COUNTY & VTD SPLITTING
|
|
@@ -1404,7 +1432,6 @@ function doFindCountiesSplitUnexpectedly(s, bLog = false) {
|
|
|
1404
1432
|
test['details']['countiesWithSplits'] = splitCountiesWithSplits;
|
|
1405
1433
|
return test;
|
|
1406
1434
|
}
|
|
1407
|
-
exports.doFindCountiesSplitUnexpectedly = doFindCountiesSplitUnexpectedly;
|
|
1408
1435
|
// NOTE - This function just creates an empty container that dra-client fills in when generating the UI
|
|
1409
1436
|
function doFindSplitVTDs(s, bLog = false) {
|
|
1410
1437
|
let test = s.getTest(6 /* T.Test.VTDSplits */);
|
|
@@ -1413,7 +1440,6 @@ function doFindSplitVTDs(s, bLog = false) {
|
|
|
1413
1440
|
test['details']['splitVTDs'] = splitVTDs;
|
|
1414
1441
|
return test;
|
|
1415
1442
|
}
|
|
1416
|
-
exports.doFindSplitVTDs = doFindSplitVTDs;
|
|
1417
1443
|
|
|
1418
1444
|
|
|
1419
1445
|
/***/ }),
|
|
@@ -1444,15 +1470,25 @@ var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (
|
|
|
1444
1470
|
}) : function(o, v) {
|
|
1445
1471
|
o["default"] = v;
|
|
1446
1472
|
});
|
|
1447
|
-
var __importStar = (this && this.__importStar) || function (
|
|
1448
|
-
|
|
1449
|
-
|
|
1450
|
-
|
|
1451
|
-
|
|
1452
|
-
|
|
1453
|
-
};
|
|
1473
|
+
var __importStar = (this && this.__importStar) || (function () {
|
|
1474
|
+
var ownKeys = function(o) {
|
|
1475
|
+
ownKeys = Object.getOwnPropertyNames || function (o) {
|
|
1476
|
+
var ar = [];
|
|
1477
|
+
for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
|
|
1478
|
+
return ar;
|
|
1479
|
+
};
|
|
1480
|
+
return ownKeys(o);
|
|
1481
|
+
};
|
|
1482
|
+
return function (mod) {
|
|
1483
|
+
if (mod && mod.__esModule) return mod;
|
|
1484
|
+
var result = {};
|
|
1485
|
+
if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
|
|
1486
|
+
__setModuleDefault(result, mod);
|
|
1487
|
+
return result;
|
|
1488
|
+
};
|
|
1489
|
+
})();
|
|
1454
1490
|
Object.defineProperty(exports, "__esModule", ({ value: true }));
|
|
1455
|
-
exports.extractDistrictProperties =
|
|
1491
|
+
exports.extractDistrictProperties = extractDistrictProperties;
|
|
1456
1492
|
const baseclient_1 = __webpack_require__(/*! @dra2020/baseclient */ "@dra2020/baseclient");
|
|
1457
1493
|
const U = __importStar(__webpack_require__(/*! ./utils */ "./src/utils.ts"));
|
|
1458
1494
|
// The main compactness code is in the dra-analytics package.
|
|
@@ -1475,7 +1511,6 @@ function extractDistrictProperties(s, bLog = false) {
|
|
|
1475
1511
|
}
|
|
1476
1512
|
}
|
|
1477
1513
|
}
|
|
1478
|
-
exports.extractDistrictProperties = extractDistrictProperties;
|
|
1479
1514
|
function isAShape(poly) {
|
|
1480
1515
|
if (poly == null)
|
|
1481
1516
|
return false;
|
|
@@ -1526,7 +1561,7 @@ function isAShape(poly) {
|
|
|
1526
1561
|
// EQUAL POPULATION
|
|
1527
1562
|
//
|
|
1528
1563
|
Object.defineProperty(exports, "__esModule", ({ value: true }));
|
|
1529
|
-
exports.doHasEqualPopulations =
|
|
1564
|
+
exports.doHasEqualPopulations = doHasEqualPopulations;
|
|
1530
1565
|
// MMD - This generalizes for variable #'s of reps per district.
|
|
1531
1566
|
// NOTE - This validity check is *derived* and depends on population deviation %
|
|
1532
1567
|
// being computed (above) and normalized in test log & scorecard generation.
|
|
@@ -1544,7 +1579,6 @@ function doHasEqualPopulations(s, bLog = false) {
|
|
|
1544
1579
|
bEqualPop[summaryRow] = test['score'];
|
|
1545
1580
|
return test;
|
|
1546
1581
|
}
|
|
1547
|
-
exports.doHasEqualPopulations = doHasEqualPopulations;
|
|
1548
1582
|
|
|
1549
1583
|
|
|
1550
1584
|
/***/ }),
|
|
@@ -1610,7 +1644,9 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
1610
1644
|
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
1611
1645
|
};
|
|
1612
1646
|
Object.defineProperty(exports, "__esModule", ({ value: true }));
|
|
1613
|
-
exports.
|
|
1647
|
+
exports.getMajorityMinority = getMajorityMinority;
|
|
1648
|
+
exports.getVRASection5 = getVRASection5;
|
|
1649
|
+
exports.doAnalyzeRacialPolarization = doAnalyzeRacialPolarization;
|
|
1614
1650
|
const dra_analytics_1 = __webpack_require__(/*! @dra2020/dra-analytics */ "@dra2020/dra-analytics");
|
|
1615
1651
|
const majority_minority_json_1 = __importDefault(__webpack_require__(/*! ../static/majority-minority.json */ "./static/majority-minority.json"));
|
|
1616
1652
|
const vra5_preclearance_json_1 = __importDefault(__webpack_require__(/*! ../static/vra5-preclearance.json */ "./static/vra5-preclearance.json"));
|
|
@@ -1625,14 +1661,12 @@ function getMajorityMinority(s) {
|
|
|
1625
1661
|
const stateMM = mMDict[xx];
|
|
1626
1662
|
return stateMM;
|
|
1627
1663
|
}
|
|
1628
|
-
exports.getMajorityMinority = getMajorityMinority;
|
|
1629
1664
|
function getVRASection5(s) {
|
|
1630
1665
|
const xx = s.state.xx;
|
|
1631
1666
|
const vraPreDict = vra5_preclearance_json_1.default;
|
|
1632
1667
|
const stateVRAPre = vraPreDict[xx];
|
|
1633
1668
|
return stateVRAPre;
|
|
1634
1669
|
}
|
|
1635
|
-
exports.getVRASection5 = getVRASection5;
|
|
1636
1670
|
// RPV - pulled into a separate component 11-17-2020
|
|
1637
1671
|
function doAnalyzeRacialPolarization(s, districtID, groups, bLog = false) {
|
|
1638
1672
|
// Make sure that a minority is specified
|
|
@@ -1648,7 +1682,6 @@ function doAnalyzeRacialPolarization(s, districtID, groups, bLog = false) {
|
|
|
1648
1682
|
return undefined;
|
|
1649
1683
|
return dra_analytics_1.Minority.analyzeRacialVoting(points, districtID, groups);
|
|
1650
1684
|
}
|
|
1651
|
-
exports.doAnalyzeRacialPolarization = doAnalyzeRacialPolarization;
|
|
1652
1685
|
// RPV is in the dra-analytics package.
|
|
1653
1686
|
|
|
1654
1687
|
|
|
@@ -1680,15 +1713,25 @@ var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (
|
|
|
1680
1713
|
}) : function(o, v) {
|
|
1681
1714
|
o["default"] = v;
|
|
1682
1715
|
});
|
|
1683
|
-
var __importStar = (this && this.__importStar) || function (
|
|
1684
|
-
|
|
1685
|
-
|
|
1686
|
-
|
|
1687
|
-
|
|
1688
|
-
|
|
1689
|
-
};
|
|
1716
|
+
var __importStar = (this && this.__importStar) || (function () {
|
|
1717
|
+
var ownKeys = function(o) {
|
|
1718
|
+
ownKeys = Object.getOwnPropertyNames || function (o) {
|
|
1719
|
+
var ar = [];
|
|
1720
|
+
for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
|
|
1721
|
+
return ar;
|
|
1722
|
+
};
|
|
1723
|
+
return ownKeys(o);
|
|
1724
|
+
};
|
|
1725
|
+
return function (mod) {
|
|
1726
|
+
if (mod && mod.__esModule) return mod;
|
|
1727
|
+
var result = {};
|
|
1728
|
+
if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
|
|
1729
|
+
__setModuleDefault(result, mod);
|
|
1730
|
+
return result;
|
|
1731
|
+
};
|
|
1732
|
+
})();
|
|
1690
1733
|
Object.defineProperty(exports, "__esModule", ({ value: true }));
|
|
1691
|
-
exports.doPreprocessData =
|
|
1734
|
+
exports.doPreprocessData = doPreprocessData;
|
|
1692
1735
|
const U = __importStar(__webpack_require__(/*! ./utils */ "./src/utils.ts"));
|
|
1693
1736
|
const D = __importStar(__webpack_require__(/*! ./_data */ "./src/_data.ts"));
|
|
1694
1737
|
// NOTE - Do preprocessing separately, so the constructor returns quickly.
|
|
@@ -1705,7 +1748,6 @@ function doPreprocessData(s, bLog = false) {
|
|
|
1705
1748
|
// Create a map of geoIDs to feature IDs
|
|
1706
1749
|
s.features.mapGeoIDsToFeatureIDs();
|
|
1707
1750
|
}
|
|
1708
|
-
exports.doPreprocessData = doPreprocessData;
|
|
1709
1751
|
// CREATE A FIPS CODE TO COUNTY NAME LOOKUP
|
|
1710
1752
|
function doPreprocessCountyFeatures(s, bLog = false) {
|
|
1711
1753
|
let fipsCodes = [];
|
|
@@ -1881,15 +1923,27 @@ var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (
|
|
|
1881
1923
|
}) : function(o, v) {
|
|
1882
1924
|
o["default"] = v;
|
|
1883
1925
|
});
|
|
1884
|
-
var __importStar = (this && this.__importStar) || function (
|
|
1885
|
-
|
|
1886
|
-
|
|
1887
|
-
|
|
1888
|
-
|
|
1889
|
-
|
|
1890
|
-
};
|
|
1926
|
+
var __importStar = (this && this.__importStar) || (function () {
|
|
1927
|
+
var ownKeys = function(o) {
|
|
1928
|
+
ownKeys = Object.getOwnPropertyNames || function (o) {
|
|
1929
|
+
var ar = [];
|
|
1930
|
+
for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
|
|
1931
|
+
return ar;
|
|
1932
|
+
};
|
|
1933
|
+
return ownKeys(o);
|
|
1934
|
+
};
|
|
1935
|
+
return function (mod) {
|
|
1936
|
+
if (mod && mod.__esModule) return mod;
|
|
1937
|
+
var result = {};
|
|
1938
|
+
if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
|
|
1939
|
+
__setModuleDefault(result, mod);
|
|
1940
|
+
return result;
|
|
1941
|
+
};
|
|
1942
|
+
})();
|
|
1891
1943
|
Object.defineProperty(exports, "__esModule", ({ value: true }));
|
|
1892
|
-
exports.
|
|
1944
|
+
exports.prepareRequirementsChecklist = prepareRequirementsChecklist;
|
|
1945
|
+
exports.prepareDistrictStatistics = prepareDistrictStatistics;
|
|
1946
|
+
exports.doAnalyzePostProcessing = doAnalyzePostProcessing;
|
|
1893
1947
|
const U = __importStar(__webpack_require__(/*! ./utils */ "./src/utils.ts"));
|
|
1894
1948
|
const analyze_1 = __webpack_require__(/*! ./analyze */ "./src/analyze.ts");
|
|
1895
1949
|
function prepareRequirementsChecklist(s, bLog = false) {
|
|
@@ -1959,7 +2013,6 @@ function prepareRequirementsChecklist(s, bLog = false) {
|
|
|
1959
2013
|
}
|
|
1960
2014
|
return paRequirements;
|
|
1961
2015
|
}
|
|
1962
|
-
exports.prepareRequirementsChecklist = prepareRequirementsChecklist;
|
|
1963
2016
|
// Create a DistrictStatistics instance, deep copying the underlying values.
|
|
1964
2017
|
function prepareDistrictStatistics(s, bLog = false) {
|
|
1965
2018
|
if (!(s.bPostProcessingDone)) {
|
|
@@ -2011,7 +2064,6 @@ function prepareDistrictStatistics(s, bLog = false) {
|
|
|
2011
2064
|
};
|
|
2012
2065
|
return ds;
|
|
2013
2066
|
}
|
|
2014
|
-
exports.prepareDistrictStatistics = prepareDistrictStatistics;
|
|
2015
2067
|
// Postprocess analytics - Normalize numeric results and derive secondary tests.
|
|
2016
2068
|
// Do this after analytics have been run and before preparing a test log or scorecard.
|
|
2017
2069
|
function doAnalyzePostProcessing(s, bLog = false) {
|
|
@@ -2048,7 +2100,6 @@ function doAnalyzePostProcessing(s, bLog = false) {
|
|
|
2048
2100
|
// Toggle the semaphore, so postprocessing isn't for both the testlog & scorecard
|
|
2049
2101
|
s.bPostProcessingDone = true;
|
|
2050
2102
|
}
|
|
2051
|
-
exports.doAnalyzePostProcessing = doAnalyzePostProcessing;
|
|
2052
2103
|
|
|
2053
2104
|
|
|
2054
2105
|
/***/ }),
|
|
@@ -2079,15 +2130,29 @@ var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (
|
|
|
2079
2130
|
}) : function(o, v) {
|
|
2080
2131
|
o["default"] = v;
|
|
2081
2132
|
});
|
|
2082
|
-
var __importStar = (this && this.__importStar) || function (
|
|
2083
|
-
|
|
2084
|
-
|
|
2085
|
-
|
|
2086
|
-
|
|
2087
|
-
|
|
2088
|
-
};
|
|
2133
|
+
var __importStar = (this && this.__importStar) || (function () {
|
|
2134
|
+
var ownKeys = function(o) {
|
|
2135
|
+
ownKeys = Object.getOwnPropertyNames || function (o) {
|
|
2136
|
+
var ar = [];
|
|
2137
|
+
for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
|
|
2138
|
+
return ar;
|
|
2139
|
+
};
|
|
2140
|
+
return ownKeys(o);
|
|
2141
|
+
};
|
|
2142
|
+
return function (mod) {
|
|
2143
|
+
if (mod && mod.__esModule) return mod;
|
|
2144
|
+
var result = {};
|
|
2145
|
+
if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
|
|
2146
|
+
__setModuleDefault(result, mod);
|
|
2147
|
+
return result;
|
|
2148
|
+
};
|
|
2149
|
+
})();
|
|
2089
2150
|
Object.defineProperty(exports, "__esModule", ({ value: true }));
|
|
2090
|
-
exports.
|
|
2151
|
+
exports.profilePlan = profilePlan;
|
|
2152
|
+
exports.getStatewideDemographics = getStatewideDemographics;
|
|
2153
|
+
exports.computeMetrics = computeMetrics;
|
|
2154
|
+
exports.rateKeyDimensions = rateKeyDimensions;
|
|
2155
|
+
exports.thunkScorecard = thunkScorecard;
|
|
2091
2156
|
const U = __importStar(__webpack_require__(/*! ./utils */ "./src/utils.ts"));
|
|
2092
2157
|
const dra_analytics_1 = __webpack_require__(/*! @dra2020/dra-analytics */ "@dra2020/dra-analytics");
|
|
2093
2158
|
// PROFILE A PLAN
|
|
@@ -2146,7 +2211,6 @@ function profilePlan(s, bLog = false) {
|
|
|
2146
2211
|
};
|
|
2147
2212
|
return profile;
|
|
2148
2213
|
}
|
|
2149
|
-
exports.profilePlan = profilePlan;
|
|
2150
2214
|
// NOTE - The CxD splits structure from _data.ts includes dummy districts for
|
|
2151
2215
|
// unassigned precincts & state summary and an extra 0 county. But dra-score takes
|
|
2152
2216
|
// a simple 1–D x 1–C splits array (zero-based, of course).
|
|
@@ -2205,7 +2269,6 @@ function getStatewideDemographics(s, bLog = false) {
|
|
|
2205
2269
|
};
|
|
2206
2270
|
return demographics;
|
|
2207
2271
|
}
|
|
2208
|
-
exports.getStatewideDemographics = getStatewideDemographics;
|
|
2209
2272
|
// SCORE A PLAN using dra-analytics
|
|
2210
2273
|
function computeMetrics(p, districtShapes, bLog = false) {
|
|
2211
2274
|
if (bLog)
|
|
@@ -2243,7 +2306,6 @@ function computeMetrics(p, districtShapes, bLog = false) {
|
|
|
2243
2306
|
};
|
|
2244
2307
|
return scorecard;
|
|
2245
2308
|
}
|
|
2246
|
-
exports.computeMetrics = computeMetrics;
|
|
2247
2309
|
function rateKeyDimensions(scorecard, p, bLog = false) {
|
|
2248
2310
|
if (bLog)
|
|
2249
2311
|
console.log("Rating key dimensions ...");
|
|
@@ -2287,7 +2349,6 @@ function rateKeyDimensions(scorecard, p, bLog = false) {
|
|
|
2287
2349
|
scorecard.scratchpad = keep;
|
|
2288
2350
|
return scorecard;
|
|
2289
2351
|
}
|
|
2290
|
-
exports.rateKeyDimensions = rateKeyDimensions;
|
|
2291
2352
|
function thunkScorecard(newScorecard, bLog = false) {
|
|
2292
2353
|
if (bLog)
|
|
2293
2354
|
console.log("Thunking new scorecard into legacy structure ...");
|
|
@@ -2358,7 +2419,6 @@ function thunkScorecard(newScorecard, bLog = false) {
|
|
|
2358
2419
|
};
|
|
2359
2420
|
return scorecard;
|
|
2360
2421
|
}
|
|
2361
|
-
exports.thunkScorecard = thunkScorecard;
|
|
2362
2422
|
|
|
2363
2423
|
|
|
2364
2424
|
/***/ }),
|
|
@@ -2399,7 +2459,7 @@ exports.OUT_OF_STATE = "OUT_OF_STATE";
|
|
|
2399
2459
|
// TYPE DEFINITIONS
|
|
2400
2460
|
//
|
|
2401
2461
|
Object.defineProperty(exports, "__esModule", ({ value: true }));
|
|
2402
|
-
exports.fieldsFromFeatureField =
|
|
2462
|
+
exports.fieldsFromFeatureField = fieldsFromFeatureField;
|
|
2403
2463
|
const FieldsByFeatureField = [
|
|
2404
2464
|
["Tot"],
|
|
2405
2465
|
["Wh"],
|
|
@@ -2415,7 +2475,6 @@ const FieldsByFeatureField = [
|
|
|
2415
2475
|
function fieldsFromFeatureField(ds, ff) {
|
|
2416
2476
|
return FieldsByFeatureField[ff];
|
|
2417
2477
|
}
|
|
2418
|
-
exports.fieldsFromFeatureField = fieldsFromFeatureField;
|
|
2419
2478
|
|
|
2420
2479
|
|
|
2421
2480
|
/***/ }),
|
|
@@ -2446,15 +2505,48 @@ var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (
|
|
|
2446
2505
|
}) : function(o, v) {
|
|
2447
2506
|
o["default"] = v;
|
|
2448
2507
|
});
|
|
2449
|
-
var __importStar = (this && this.__importStar) || function (
|
|
2450
|
-
|
|
2451
|
-
|
|
2452
|
-
|
|
2453
|
-
|
|
2454
|
-
|
|
2455
|
-
};
|
|
2508
|
+
var __importStar = (this && this.__importStar) || (function () {
|
|
2509
|
+
var ownKeys = function(o) {
|
|
2510
|
+
ownKeys = Object.getOwnPropertyNames || function (o) {
|
|
2511
|
+
var ar = [];
|
|
2512
|
+
for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
|
|
2513
|
+
return ar;
|
|
2514
|
+
};
|
|
2515
|
+
return ownKeys(o);
|
|
2516
|
+
};
|
|
2517
|
+
return function (mod) {
|
|
2518
|
+
if (mod && mod.__esModule) return mod;
|
|
2519
|
+
var result = {};
|
|
2520
|
+
if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
|
|
2521
|
+
__setModuleDefault(result, mod);
|
|
2522
|
+
return result;
|
|
2523
|
+
};
|
|
2524
|
+
})();
|
|
2456
2525
|
Object.defineProperty(exports, "__esModule", ({ value: true }));
|
|
2457
|
-
exports.
|
|
2526
|
+
exports.getDistrict = getDistrict;
|
|
2527
|
+
exports.parseGeoID = parseGeoID;
|
|
2528
|
+
exports.isWaterOnly = isWaterOnly;
|
|
2529
|
+
exports.isUninhabited = isUninhabited;
|
|
2530
|
+
exports.trim = trim;
|
|
2531
|
+
exports.sumArray = sumArray;
|
|
2532
|
+
exports.avgArray = avgArray;
|
|
2533
|
+
exports.minArray = minArray;
|
|
2534
|
+
exports.maxArray = maxArray;
|
|
2535
|
+
exports.initArray = initArray;
|
|
2536
|
+
exports.andArray = andArray;
|
|
2537
|
+
exports.keyExists = keyExists;
|
|
2538
|
+
exports.isObjectEmpty = isObjectEmpty;
|
|
2539
|
+
exports.isSetEmpty = isSetEmpty;
|
|
2540
|
+
exports.isArrayEmpty = isArrayEmpty;
|
|
2541
|
+
exports.getObjectKeys = getObjectKeys;
|
|
2542
|
+
exports.getNumericObjectKeys = getNumericObjectKeys;
|
|
2543
|
+
exports.getSelectObjectKeys = getSelectObjectKeys;
|
|
2544
|
+
exports.arrayContains = arrayContains;
|
|
2545
|
+
exports.objectContains = objectContains;
|
|
2546
|
+
exports.countEnumValues = countEnumValues;
|
|
2547
|
+
exports.shallowCopy = shallowCopy;
|
|
2548
|
+
exports.deepCopy = deepCopy;
|
|
2549
|
+
exports.depthof = depthof;
|
|
2458
2550
|
const dra_types_1 = __webpack_require__(/*! @dra2020/dra-types */ "@dra2020/dra-types");
|
|
2459
2551
|
const _data_1 = __webpack_require__(/*! ./_data */ "./src/_data.ts");
|
|
2460
2552
|
const S = __importStar(__webpack_require__(/*! ./settings */ "./src/settings.ts"));
|
|
@@ -2471,7 +2563,6 @@ function getDistrict(plan, geoID) {
|
|
|
2471
2563
|
return undefined;
|
|
2472
2564
|
}
|
|
2473
2565
|
}
|
|
2474
|
-
exports.getDistrict = getDistrict;
|
|
2475
2566
|
// WORKING WITH GEOIDS
|
|
2476
2567
|
function parseGeoID(geoID) {
|
|
2477
2568
|
let bVfeature = false;
|
|
@@ -2489,7 +2580,6 @@ function parseGeoID(geoID) {
|
|
|
2489
2580
|
};
|
|
2490
2581
|
return parts;
|
|
2491
2582
|
}
|
|
2492
|
-
exports.parseGeoID = parseGeoID;
|
|
2493
2583
|
// 08-13-2020 - Enhanced completeness checking.
|
|
2494
2584
|
function isWaterOnly(geoID, s) {
|
|
2495
2585
|
const waterOnlySignature = 'ZZZZZZ';
|
|
@@ -2506,7 +2596,6 @@ function isWaterOnly(geoID, s) {
|
|
|
2506
2596
|
else
|
|
2507
2597
|
return false;
|
|
2508
2598
|
}
|
|
2509
|
-
exports.isWaterOnly = isWaterOnly;
|
|
2510
2599
|
function isUninhabited(geoID, s) {
|
|
2511
2600
|
const featureID = s.features.featureID(geoID);
|
|
2512
2601
|
const f /* T.GeoFeature */ = s.features.featureByIndex(featureID);
|
|
@@ -2524,7 +2613,6 @@ function isUninhabited(geoID, s) {
|
|
|
2524
2613
|
}
|
|
2525
2614
|
return bUninhabited;
|
|
2526
2615
|
}
|
|
2527
|
-
exports.isUninhabited = isUninhabited;
|
|
2528
2616
|
// Round a fractional number [0-1] to the desired level of PRECISION.
|
|
2529
2617
|
function trim(fullFraction, digits = undefined) {
|
|
2530
2618
|
if (digits == 0) {
|
|
@@ -2535,48 +2623,38 @@ function trim(fullFraction, digits = undefined) {
|
|
|
2535
2623
|
return Math.round(fullFraction * shiftPlaces) / shiftPlaces;
|
|
2536
2624
|
}
|
|
2537
2625
|
}
|
|
2538
|
-
exports.trim = trim;
|
|
2539
2626
|
// ARRAY HELPERS
|
|
2540
2627
|
function sumArray(arr) {
|
|
2541
2628
|
return arr.reduce((a, b) => a + b, 0);
|
|
2542
2629
|
}
|
|
2543
|
-
exports.sumArray = sumArray;
|
|
2544
2630
|
function avgArray(arr) {
|
|
2545
2631
|
return (arr.reduce((a, b) => a + b, 0)) / arr.length;
|
|
2546
2632
|
}
|
|
2547
|
-
exports.avgArray = avgArray;
|
|
2548
2633
|
function minArray(arr) {
|
|
2549
2634
|
return Math.min(...arr);
|
|
2550
2635
|
}
|
|
2551
|
-
exports.minArray = minArray;
|
|
2552
2636
|
function maxArray(arr) {
|
|
2553
2637
|
return Math.max(...arr);
|
|
2554
2638
|
}
|
|
2555
|
-
exports.maxArray = maxArray;
|
|
2556
2639
|
function initArray(n, value) {
|
|
2557
2640
|
return Array.from(Array(n), () => value);
|
|
2558
2641
|
}
|
|
2559
|
-
exports.initArray = initArray;
|
|
2560
2642
|
function andArray(arr) {
|
|
2561
2643
|
return arr.reduce(function (a, b) { return a && b; }, true);
|
|
2562
2644
|
}
|
|
2563
|
-
exports.andArray = andArray;
|
|
2564
2645
|
// WORKING WITH OBJECT KEYS/PROPERTIES
|
|
2565
2646
|
// Does an object have a key/property?
|
|
2566
2647
|
function keyExists(k, o) {
|
|
2567
2648
|
return k in o;
|
|
2568
2649
|
}
|
|
2569
|
-
exports.keyExists = keyExists;
|
|
2570
2650
|
// Does an object (dict) have any keys/properties?
|
|
2571
2651
|
function isObjectEmpty(o) {
|
|
2572
2652
|
return Object.keys(o).length === 0;
|
|
2573
2653
|
}
|
|
2574
|
-
exports.isObjectEmpty = isObjectEmpty;
|
|
2575
2654
|
// Does a Set have any members?
|
|
2576
2655
|
function isSetEmpty(s) {
|
|
2577
2656
|
return s.size === 0;
|
|
2578
2657
|
}
|
|
2579
|
-
exports.isSetEmpty = isSetEmpty;
|
|
2580
2658
|
// Does an array hold any items?
|
|
2581
2659
|
function isArrayEmpty(a) {
|
|
2582
2660
|
if (a === undefined || a.length == 0) {
|
|
@@ -2587,16 +2665,13 @@ function isArrayEmpty(a) {
|
|
|
2587
2665
|
return false;
|
|
2588
2666
|
}
|
|
2589
2667
|
}
|
|
2590
|
-
exports.isArrayEmpty = isArrayEmpty;
|
|
2591
2668
|
// Get the keys for an object
|
|
2592
2669
|
function getObjectKeys(o) {
|
|
2593
2670
|
return Object.keys(o);
|
|
2594
2671
|
}
|
|
2595
|
-
exports.getObjectKeys = getObjectKeys;
|
|
2596
2672
|
function getNumericObjectKeys(o) {
|
|
2597
2673
|
return Object.keys(o).map(Number);
|
|
2598
2674
|
}
|
|
2599
|
-
exports.getNumericObjectKeys = getNumericObjectKeys;
|
|
2600
2675
|
function getSelectObjectKeys(o, v) {
|
|
2601
2676
|
let selectKeys = [];
|
|
2602
2677
|
Object.keys(o).forEach(key => {
|
|
@@ -2606,15 +2681,12 @@ function getSelectObjectKeys(o, v) {
|
|
|
2606
2681
|
});
|
|
2607
2682
|
return selectKeys;
|
|
2608
2683
|
}
|
|
2609
|
-
exports.getSelectObjectKeys = getSelectObjectKeys;
|
|
2610
2684
|
function arrayContains(a, item) {
|
|
2611
2685
|
return a.some(x => x === item);
|
|
2612
2686
|
}
|
|
2613
|
-
exports.arrayContains = arrayContains;
|
|
2614
2687
|
function objectContains(o, key) {
|
|
2615
2688
|
return (key in o);
|
|
2616
2689
|
}
|
|
2617
|
-
exports.objectContains = objectContains;
|
|
2618
2690
|
// ENUM HELPERS
|
|
2619
2691
|
// Source: https://stackoverflow.com/questions/38034673/determine-the-number-of-enum-elements-typescript
|
|
2620
2692
|
function countEnumValues(enumName) {
|
|
@@ -2625,7 +2697,6 @@ function countEnumValues(enumName) {
|
|
|
2625
2697
|
}
|
|
2626
2698
|
return count;
|
|
2627
2699
|
}
|
|
2628
|
-
exports.countEnumValues = countEnumValues;
|
|
2629
2700
|
// COPYING - Copied from dra-client/util.ts
|
|
2630
2701
|
function shallowCopy(src) {
|
|
2631
2702
|
if (Array.isArray(src))
|
|
@@ -2640,7 +2711,6 @@ function shallowCopy(src) {
|
|
|
2640
2711
|
else
|
|
2641
2712
|
return src;
|
|
2642
2713
|
}
|
|
2643
|
-
exports.shallowCopy = shallowCopy;
|
|
2644
2714
|
function deepCopy(src) {
|
|
2645
2715
|
if (Array.isArray(src)) {
|
|
2646
2716
|
let dst = [];
|
|
@@ -2658,7 +2728,6 @@ function deepCopy(src) {
|
|
|
2658
2728
|
else
|
|
2659
2729
|
return src;
|
|
2660
2730
|
}
|
|
2661
|
-
exports.deepCopy = deepCopy;
|
|
2662
2731
|
function depthof(a) {
|
|
2663
2732
|
if (a === null || a === undefined)
|
|
2664
2733
|
return 1;
|
|
@@ -2685,7 +2754,6 @@ function depthof(a) {
|
|
|
2685
2754
|
}
|
|
2686
2755
|
}
|
|
2687
2756
|
}
|
|
2688
|
-
exports.depthof = depthof;
|
|
2689
2757
|
|
|
2690
2758
|
|
|
2691
2759
|
/***/ }),
|
|
@@ -2716,15 +2784,27 @@ var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (
|
|
|
2716
2784
|
}) : function(o, v) {
|
|
2717
2785
|
o["default"] = v;
|
|
2718
2786
|
});
|
|
2719
|
-
var __importStar = (this && this.__importStar) || function (
|
|
2720
|
-
|
|
2721
|
-
|
|
2722
|
-
|
|
2723
|
-
|
|
2724
|
-
|
|
2725
|
-
};
|
|
2787
|
+
var __importStar = (this && this.__importStar) || (function () {
|
|
2788
|
+
var ownKeys = function(o) {
|
|
2789
|
+
ownKeys = Object.getOwnPropertyNames || function (o) {
|
|
2790
|
+
var ar = [];
|
|
2791
|
+
for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
|
|
2792
|
+
return ar;
|
|
2793
|
+
};
|
|
2794
|
+
return ownKeys(o);
|
|
2795
|
+
};
|
|
2796
|
+
return function (mod) {
|
|
2797
|
+
if (mod && mod.__esModule) return mod;
|
|
2798
|
+
var result = {};
|
|
2799
|
+
if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
|
|
2800
|
+
__setModuleDefault(result, mod);
|
|
2801
|
+
return result;
|
|
2802
|
+
};
|
|
2803
|
+
})();
|
|
2726
2804
|
Object.defineProperty(exports, "__esModule", ({ value: true }));
|
|
2727
|
-
exports.
|
|
2805
|
+
exports.doIsComplete = doIsComplete;
|
|
2806
|
+
exports.doIsContiguous = doIsContiguous;
|
|
2807
|
+
exports.doIsFreeOfHoles = doIsFreeOfHoles;
|
|
2728
2808
|
const U = __importStar(__webpack_require__(/*! ./utils */ "./src/utils.ts"));
|
|
2729
2809
|
const S = __importStar(__webpack_require__(/*! ./settings */ "./src/settings.ts"));
|
|
2730
2810
|
//
|
|
@@ -2806,7 +2886,6 @@ function doIsComplete(s, bLog = false) {
|
|
|
2806
2886
|
bNotEmpty[summaryRow] = test['score'];
|
|
2807
2887
|
return test;
|
|
2808
2888
|
}
|
|
2809
|
-
exports.doIsComplete = doIsComplete;
|
|
2810
2889
|
//
|
|
2811
2890
|
// CONTIGUOUS - Is each district in a plan fully connected?
|
|
2812
2891
|
//
|
|
@@ -2842,7 +2921,6 @@ function doIsContiguous(s, bLog = false) {
|
|
|
2842
2921
|
bContiguous[summaryRow] = test['score'];
|
|
2843
2922
|
return test;
|
|
2844
2923
|
}
|
|
2845
|
-
exports.doIsContiguous = doIsContiguous;
|
|
2846
2924
|
//
|
|
2847
2925
|
// FREE OF HOLES - Are any districts fully embedded w/in another district?
|
|
2848
2926
|
//
|
|
@@ -2881,7 +2959,6 @@ function doIsFreeOfHoles(s, bLog = false) {
|
|
|
2881
2959
|
bNotEmbedded[summaryRow] = test['score'];
|
|
2882
2960
|
return test;
|
|
2883
2961
|
}
|
|
2884
|
-
exports.doIsFreeOfHoles = doIsFreeOfHoles;
|
|
2885
2962
|
|
|
2886
2963
|
|
|
2887
2964
|
/***/ }),
|