@dra2020/district-analytics 16.1.7 → 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 +205 -126
- 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"));
|
|
@@ -880,7 +904,6 @@ function inferSelectedMinority(groups) {
|
|
|
880
904
|
return 'Minority';
|
|
881
905
|
return 'No minority selected!';
|
|
882
906
|
}
|
|
883
|
-
exports.inferSelectedMinority = inferSelectedMinority;
|
|
884
907
|
// CLASSES, ETC. FOR FEATURE & COUNTY DATA
|
|
885
908
|
// Wrap data by feature, to abstract the specifics of the internal structure
|
|
886
909
|
class Features {
|
|
@@ -976,13 +999,11 @@ function geoIDForFeature(f) {
|
|
|
976
999
|
throw "Feature with no id property.";
|
|
977
1000
|
}
|
|
978
1001
|
}
|
|
979
|
-
exports.geoIDForFeature = geoIDForFeature;
|
|
980
1002
|
function fieldForFeature(f, dk /* dt: T.Dataset */, ff) {
|
|
981
1003
|
// Multiple keys to transparently handle NH and non-NH (e.g. Bl vs BlC) keyed fields
|
|
982
1004
|
// Take the max (typically one field will be zero, but some datasets contain Bl subset of BlC)
|
|
983
1005
|
return Math.max(...T.fieldsFromFeatureField(dk, ff).map(key => _getFeatures(f, dk, key)));
|
|
984
1006
|
}
|
|
985
|
-
exports.fieldForFeature = fieldForFeature;
|
|
986
1007
|
// NOTE - This accessor is cloned from fGetW() in dra-client/restrict.ts
|
|
987
1008
|
// f is a direct GeoJSON feature
|
|
988
1009
|
// p is a geoID
|
|
@@ -1112,7 +1133,6 @@ function invertPlan(plan, s, bLog = false) {
|
|
|
1112
1133
|
}
|
|
1113
1134
|
return invertedPlan;
|
|
1114
1135
|
}
|
|
1115
|
-
exports.invertPlan = invertPlan;
|
|
1116
1136
|
class GraphClass {
|
|
1117
1137
|
constructor(s, graph) {
|
|
1118
1138
|
this._session = s;
|
|
@@ -1150,7 +1170,9 @@ exports.GraphClass = GraphClass;
|
|
|
1150
1170
|
// ANALYZE A PLAN
|
|
1151
1171
|
//
|
|
1152
1172
|
Object.defineProperty(exports, "__esModule", ({ value: true }));
|
|
1153
|
-
exports.
|
|
1173
|
+
exports.doAnalyzeDistricts = doAnalyzeDistricts;
|
|
1174
|
+
exports.doAnalyzePlan = doAnalyzePlan;
|
|
1175
|
+
exports.doDeriveSecondaryTests = doDeriveSecondaryTests;
|
|
1154
1176
|
const valid_1 = __webpack_require__(/*! ./valid */ "./src/valid.ts");
|
|
1155
1177
|
const equal_1 = __webpack_require__(/*! ./equal */ "./src/equal.ts");
|
|
1156
1178
|
const cohesive_1 = __webpack_require__(/*! ./cohesive */ "./src/cohesive.ts");
|
|
@@ -1159,7 +1181,6 @@ function doAnalyzeDistricts(s, bLog = false) {
|
|
|
1159
1181
|
s.districts.recalcStatistics(bLog);
|
|
1160
1182
|
s.districts.extractDistrictShapeProperties(bLog);
|
|
1161
1183
|
}
|
|
1162
|
-
exports.doAnalyzeDistricts = doAnalyzeDistricts;
|
|
1163
1184
|
// Calculate the analytics & validations and cache the results
|
|
1164
1185
|
// NOTE - doAnalyzePlan() depends on doAnalyzeDistricts() having run first.
|
|
1165
1186
|
// NOTE - I could make this table-driven, but I'm thinking that the explicit
|
|
@@ -1180,7 +1201,6 @@ function doAnalyzePlan(s, bLog = false) {
|
|
|
1180
1201
|
s.bPlanAnalyzed = true;
|
|
1181
1202
|
s.bPostProcessingDone = false;
|
|
1182
1203
|
}
|
|
1183
|
-
exports.doAnalyzePlan = doAnalyzePlan;
|
|
1184
1204
|
//
|
|
1185
1205
|
// Derive secondary analytics that are based on primary tests.
|
|
1186
1206
|
// This concept allows Population Deviation to be a primary numeric test and
|
|
@@ -1189,7 +1209,6 @@ exports.doAnalyzePlan = doAnalyzePlan;
|
|
|
1189
1209
|
function doDeriveSecondaryTests(s, bLog = false) {
|
|
1190
1210
|
s.tests[3 /* T.Test.EqualPopulation */] = (0, equal_1.doHasEqualPopulations)(s, bLog);
|
|
1191
1211
|
}
|
|
1192
|
-
exports.doDeriveSecondaryTests = doDeriveSecondaryTests;
|
|
1193
1212
|
|
|
1194
1213
|
|
|
1195
1214
|
/***/ }),
|
|
@@ -1220,15 +1239,26 @@ var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (
|
|
|
1220
1239
|
}) : function(o, v) {
|
|
1221
1240
|
o["default"] = v;
|
|
1222
1241
|
});
|
|
1223
|
-
var __importStar = (this && this.__importStar) || function (
|
|
1224
|
-
|
|
1225
|
-
|
|
1226
|
-
|
|
1227
|
-
|
|
1228
|
-
|
|
1229
|
-
};
|
|
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
|
+
})();
|
|
1230
1259
|
Object.defineProperty(exports, "__esModule", ({ value: true }));
|
|
1231
|
-
exports.
|
|
1260
|
+
exports.doFindCountiesSplitUnexpectedly = doFindCountiesSplitUnexpectedly;
|
|
1261
|
+
exports.doFindSplitVTDs = doFindSplitVTDs;
|
|
1232
1262
|
const U = __importStar(__webpack_require__(/*! ./utils */ "./src/utils.ts"));
|
|
1233
1263
|
// The main county-district splitting code is in the dra-analytics package.
|
|
1234
1264
|
// ANALYZE SIMPLE COUNTY & VTD SPLITTING
|
|
@@ -1402,7 +1432,6 @@ function doFindCountiesSplitUnexpectedly(s, bLog = false) {
|
|
|
1402
1432
|
test['details']['countiesWithSplits'] = splitCountiesWithSplits;
|
|
1403
1433
|
return test;
|
|
1404
1434
|
}
|
|
1405
|
-
exports.doFindCountiesSplitUnexpectedly = doFindCountiesSplitUnexpectedly;
|
|
1406
1435
|
// NOTE - This function just creates an empty container that dra-client fills in when generating the UI
|
|
1407
1436
|
function doFindSplitVTDs(s, bLog = false) {
|
|
1408
1437
|
let test = s.getTest(6 /* T.Test.VTDSplits */);
|
|
@@ -1411,7 +1440,6 @@ function doFindSplitVTDs(s, bLog = false) {
|
|
|
1411
1440
|
test['details']['splitVTDs'] = splitVTDs;
|
|
1412
1441
|
return test;
|
|
1413
1442
|
}
|
|
1414
|
-
exports.doFindSplitVTDs = doFindSplitVTDs;
|
|
1415
1443
|
|
|
1416
1444
|
|
|
1417
1445
|
/***/ }),
|
|
@@ -1442,15 +1470,25 @@ var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (
|
|
|
1442
1470
|
}) : function(o, v) {
|
|
1443
1471
|
o["default"] = v;
|
|
1444
1472
|
});
|
|
1445
|
-
var __importStar = (this && this.__importStar) || function (
|
|
1446
|
-
|
|
1447
|
-
|
|
1448
|
-
|
|
1449
|
-
|
|
1450
|
-
|
|
1451
|
-
};
|
|
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
|
+
})();
|
|
1452
1490
|
Object.defineProperty(exports, "__esModule", ({ value: true }));
|
|
1453
|
-
exports.extractDistrictProperties =
|
|
1491
|
+
exports.extractDistrictProperties = extractDistrictProperties;
|
|
1454
1492
|
const baseclient_1 = __webpack_require__(/*! @dra2020/baseclient */ "@dra2020/baseclient");
|
|
1455
1493
|
const U = __importStar(__webpack_require__(/*! ./utils */ "./src/utils.ts"));
|
|
1456
1494
|
// The main compactness code is in the dra-analytics package.
|
|
@@ -1473,7 +1511,6 @@ function extractDistrictProperties(s, bLog = false) {
|
|
|
1473
1511
|
}
|
|
1474
1512
|
}
|
|
1475
1513
|
}
|
|
1476
|
-
exports.extractDistrictProperties = extractDistrictProperties;
|
|
1477
1514
|
function isAShape(poly) {
|
|
1478
1515
|
if (poly == null)
|
|
1479
1516
|
return false;
|
|
@@ -1524,7 +1561,7 @@ function isAShape(poly) {
|
|
|
1524
1561
|
// EQUAL POPULATION
|
|
1525
1562
|
//
|
|
1526
1563
|
Object.defineProperty(exports, "__esModule", ({ value: true }));
|
|
1527
|
-
exports.doHasEqualPopulations =
|
|
1564
|
+
exports.doHasEqualPopulations = doHasEqualPopulations;
|
|
1528
1565
|
// MMD - This generalizes for variable #'s of reps per district.
|
|
1529
1566
|
// NOTE - This validity check is *derived* and depends on population deviation %
|
|
1530
1567
|
// being computed (above) and normalized in test log & scorecard generation.
|
|
@@ -1542,7 +1579,6 @@ function doHasEqualPopulations(s, bLog = false) {
|
|
|
1542
1579
|
bEqualPop[summaryRow] = test['score'];
|
|
1543
1580
|
return test;
|
|
1544
1581
|
}
|
|
1545
|
-
exports.doHasEqualPopulations = doHasEqualPopulations;
|
|
1546
1582
|
|
|
1547
1583
|
|
|
1548
1584
|
/***/ }),
|
|
@@ -1608,7 +1644,9 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
1608
1644
|
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
1609
1645
|
};
|
|
1610
1646
|
Object.defineProperty(exports, "__esModule", ({ value: true }));
|
|
1611
|
-
exports.
|
|
1647
|
+
exports.getMajorityMinority = getMajorityMinority;
|
|
1648
|
+
exports.getVRASection5 = getVRASection5;
|
|
1649
|
+
exports.doAnalyzeRacialPolarization = doAnalyzeRacialPolarization;
|
|
1612
1650
|
const dra_analytics_1 = __webpack_require__(/*! @dra2020/dra-analytics */ "@dra2020/dra-analytics");
|
|
1613
1651
|
const majority_minority_json_1 = __importDefault(__webpack_require__(/*! ../static/majority-minority.json */ "./static/majority-minority.json"));
|
|
1614
1652
|
const vra5_preclearance_json_1 = __importDefault(__webpack_require__(/*! ../static/vra5-preclearance.json */ "./static/vra5-preclearance.json"));
|
|
@@ -1623,14 +1661,12 @@ function getMajorityMinority(s) {
|
|
|
1623
1661
|
const stateMM = mMDict[xx];
|
|
1624
1662
|
return stateMM;
|
|
1625
1663
|
}
|
|
1626
|
-
exports.getMajorityMinority = getMajorityMinority;
|
|
1627
1664
|
function getVRASection5(s) {
|
|
1628
1665
|
const xx = s.state.xx;
|
|
1629
1666
|
const vraPreDict = vra5_preclearance_json_1.default;
|
|
1630
1667
|
const stateVRAPre = vraPreDict[xx];
|
|
1631
1668
|
return stateVRAPre;
|
|
1632
1669
|
}
|
|
1633
|
-
exports.getVRASection5 = getVRASection5;
|
|
1634
1670
|
// RPV - pulled into a separate component 11-17-2020
|
|
1635
1671
|
function doAnalyzeRacialPolarization(s, districtID, groups, bLog = false) {
|
|
1636
1672
|
// Make sure that a minority is specified
|
|
@@ -1646,7 +1682,6 @@ function doAnalyzeRacialPolarization(s, districtID, groups, bLog = false) {
|
|
|
1646
1682
|
return undefined;
|
|
1647
1683
|
return dra_analytics_1.Minority.analyzeRacialVoting(points, districtID, groups);
|
|
1648
1684
|
}
|
|
1649
|
-
exports.doAnalyzeRacialPolarization = doAnalyzeRacialPolarization;
|
|
1650
1685
|
// RPV is in the dra-analytics package.
|
|
1651
1686
|
|
|
1652
1687
|
|
|
@@ -1678,15 +1713,25 @@ var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (
|
|
|
1678
1713
|
}) : function(o, v) {
|
|
1679
1714
|
o["default"] = v;
|
|
1680
1715
|
});
|
|
1681
|
-
var __importStar = (this && this.__importStar) || function (
|
|
1682
|
-
|
|
1683
|
-
|
|
1684
|
-
|
|
1685
|
-
|
|
1686
|
-
|
|
1687
|
-
};
|
|
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
|
+
})();
|
|
1688
1733
|
Object.defineProperty(exports, "__esModule", ({ value: true }));
|
|
1689
|
-
exports.doPreprocessData =
|
|
1734
|
+
exports.doPreprocessData = doPreprocessData;
|
|
1690
1735
|
const U = __importStar(__webpack_require__(/*! ./utils */ "./src/utils.ts"));
|
|
1691
1736
|
const D = __importStar(__webpack_require__(/*! ./_data */ "./src/_data.ts"));
|
|
1692
1737
|
// NOTE - Do preprocessing separately, so the constructor returns quickly.
|
|
@@ -1703,7 +1748,6 @@ function doPreprocessData(s, bLog = false) {
|
|
|
1703
1748
|
// Create a map of geoIDs to feature IDs
|
|
1704
1749
|
s.features.mapGeoIDsToFeatureIDs();
|
|
1705
1750
|
}
|
|
1706
|
-
exports.doPreprocessData = doPreprocessData;
|
|
1707
1751
|
// CREATE A FIPS CODE TO COUNTY NAME LOOKUP
|
|
1708
1752
|
function doPreprocessCountyFeatures(s, bLog = false) {
|
|
1709
1753
|
let fipsCodes = [];
|
|
@@ -1879,15 +1923,27 @@ var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (
|
|
|
1879
1923
|
}) : function(o, v) {
|
|
1880
1924
|
o["default"] = v;
|
|
1881
1925
|
});
|
|
1882
|
-
var __importStar = (this && this.__importStar) || function (
|
|
1883
|
-
|
|
1884
|
-
|
|
1885
|
-
|
|
1886
|
-
|
|
1887
|
-
|
|
1888
|
-
};
|
|
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
|
+
})();
|
|
1889
1943
|
Object.defineProperty(exports, "__esModule", ({ value: true }));
|
|
1890
|
-
exports.
|
|
1944
|
+
exports.prepareRequirementsChecklist = prepareRequirementsChecklist;
|
|
1945
|
+
exports.prepareDistrictStatistics = prepareDistrictStatistics;
|
|
1946
|
+
exports.doAnalyzePostProcessing = doAnalyzePostProcessing;
|
|
1891
1947
|
const U = __importStar(__webpack_require__(/*! ./utils */ "./src/utils.ts"));
|
|
1892
1948
|
const analyze_1 = __webpack_require__(/*! ./analyze */ "./src/analyze.ts");
|
|
1893
1949
|
function prepareRequirementsChecklist(s, bLog = false) {
|
|
@@ -1957,7 +2013,6 @@ function prepareRequirementsChecklist(s, bLog = false) {
|
|
|
1957
2013
|
}
|
|
1958
2014
|
return paRequirements;
|
|
1959
2015
|
}
|
|
1960
|
-
exports.prepareRequirementsChecklist = prepareRequirementsChecklist;
|
|
1961
2016
|
// Create a DistrictStatistics instance, deep copying the underlying values.
|
|
1962
2017
|
function prepareDistrictStatistics(s, bLog = false) {
|
|
1963
2018
|
if (!(s.bPostProcessingDone)) {
|
|
@@ -2009,7 +2064,6 @@ function prepareDistrictStatistics(s, bLog = false) {
|
|
|
2009
2064
|
};
|
|
2010
2065
|
return ds;
|
|
2011
2066
|
}
|
|
2012
|
-
exports.prepareDistrictStatistics = prepareDistrictStatistics;
|
|
2013
2067
|
// Postprocess analytics - Normalize numeric results and derive secondary tests.
|
|
2014
2068
|
// Do this after analytics have been run and before preparing a test log or scorecard.
|
|
2015
2069
|
function doAnalyzePostProcessing(s, bLog = false) {
|
|
@@ -2046,7 +2100,6 @@ function doAnalyzePostProcessing(s, bLog = false) {
|
|
|
2046
2100
|
// Toggle the semaphore, so postprocessing isn't for both the testlog & scorecard
|
|
2047
2101
|
s.bPostProcessingDone = true;
|
|
2048
2102
|
}
|
|
2049
|
-
exports.doAnalyzePostProcessing = doAnalyzePostProcessing;
|
|
2050
2103
|
|
|
2051
2104
|
|
|
2052
2105
|
/***/ }),
|
|
@@ -2077,15 +2130,29 @@ var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (
|
|
|
2077
2130
|
}) : function(o, v) {
|
|
2078
2131
|
o["default"] = v;
|
|
2079
2132
|
});
|
|
2080
|
-
var __importStar = (this && this.__importStar) || function (
|
|
2081
|
-
|
|
2082
|
-
|
|
2083
|
-
|
|
2084
|
-
|
|
2085
|
-
|
|
2086
|
-
};
|
|
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
|
+
})();
|
|
2087
2150
|
Object.defineProperty(exports, "__esModule", ({ value: true }));
|
|
2088
|
-
exports.
|
|
2151
|
+
exports.profilePlan = profilePlan;
|
|
2152
|
+
exports.getStatewideDemographics = getStatewideDemographics;
|
|
2153
|
+
exports.computeMetrics = computeMetrics;
|
|
2154
|
+
exports.rateKeyDimensions = rateKeyDimensions;
|
|
2155
|
+
exports.thunkScorecard = thunkScorecard;
|
|
2089
2156
|
const U = __importStar(__webpack_require__(/*! ./utils */ "./src/utils.ts"));
|
|
2090
2157
|
const dra_analytics_1 = __webpack_require__(/*! @dra2020/dra-analytics */ "@dra2020/dra-analytics");
|
|
2091
2158
|
// PROFILE A PLAN
|
|
@@ -2144,7 +2211,6 @@ function profilePlan(s, bLog = false) {
|
|
|
2144
2211
|
};
|
|
2145
2212
|
return profile;
|
|
2146
2213
|
}
|
|
2147
|
-
exports.profilePlan = profilePlan;
|
|
2148
2214
|
// NOTE - The CxD splits structure from _data.ts includes dummy districts for
|
|
2149
2215
|
// unassigned precincts & state summary and an extra 0 county. But dra-score takes
|
|
2150
2216
|
// a simple 1–D x 1–C splits array (zero-based, of course).
|
|
@@ -2203,7 +2269,6 @@ function getStatewideDemographics(s, bLog = false) {
|
|
|
2203
2269
|
};
|
|
2204
2270
|
return demographics;
|
|
2205
2271
|
}
|
|
2206
|
-
exports.getStatewideDemographics = getStatewideDemographics;
|
|
2207
2272
|
// SCORE A PLAN using dra-analytics
|
|
2208
2273
|
function computeMetrics(p, districtShapes, bLog = false) {
|
|
2209
2274
|
if (bLog)
|
|
@@ -2241,7 +2306,6 @@ function computeMetrics(p, districtShapes, bLog = false) {
|
|
|
2241
2306
|
};
|
|
2242
2307
|
return scorecard;
|
|
2243
2308
|
}
|
|
2244
|
-
exports.computeMetrics = computeMetrics;
|
|
2245
2309
|
function rateKeyDimensions(scorecard, p, bLog = false) {
|
|
2246
2310
|
if (bLog)
|
|
2247
2311
|
console.log("Rating key dimensions ...");
|
|
@@ -2285,7 +2349,6 @@ function rateKeyDimensions(scorecard, p, bLog = false) {
|
|
|
2285
2349
|
scorecard.scratchpad = keep;
|
|
2286
2350
|
return scorecard;
|
|
2287
2351
|
}
|
|
2288
|
-
exports.rateKeyDimensions = rateKeyDimensions;
|
|
2289
2352
|
function thunkScorecard(newScorecard, bLog = false) {
|
|
2290
2353
|
if (bLog)
|
|
2291
2354
|
console.log("Thunking new scorecard into legacy structure ...");
|
|
@@ -2356,7 +2419,6 @@ function thunkScorecard(newScorecard, bLog = false) {
|
|
|
2356
2419
|
};
|
|
2357
2420
|
return scorecard;
|
|
2358
2421
|
}
|
|
2359
|
-
exports.thunkScorecard = thunkScorecard;
|
|
2360
2422
|
|
|
2361
2423
|
|
|
2362
2424
|
/***/ }),
|
|
@@ -2397,7 +2459,7 @@ exports.OUT_OF_STATE = "OUT_OF_STATE";
|
|
|
2397
2459
|
// TYPE DEFINITIONS
|
|
2398
2460
|
//
|
|
2399
2461
|
Object.defineProperty(exports, "__esModule", ({ value: true }));
|
|
2400
|
-
exports.fieldsFromFeatureField =
|
|
2462
|
+
exports.fieldsFromFeatureField = fieldsFromFeatureField;
|
|
2401
2463
|
const FieldsByFeatureField = [
|
|
2402
2464
|
["Tot"],
|
|
2403
2465
|
["Wh"],
|
|
@@ -2413,7 +2475,6 @@ const FieldsByFeatureField = [
|
|
|
2413
2475
|
function fieldsFromFeatureField(ds, ff) {
|
|
2414
2476
|
return FieldsByFeatureField[ff];
|
|
2415
2477
|
}
|
|
2416
|
-
exports.fieldsFromFeatureField = fieldsFromFeatureField;
|
|
2417
2478
|
|
|
2418
2479
|
|
|
2419
2480
|
/***/ }),
|
|
@@ -2444,15 +2505,48 @@ var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (
|
|
|
2444
2505
|
}) : function(o, v) {
|
|
2445
2506
|
o["default"] = v;
|
|
2446
2507
|
});
|
|
2447
|
-
var __importStar = (this && this.__importStar) || function (
|
|
2448
|
-
|
|
2449
|
-
|
|
2450
|
-
|
|
2451
|
-
|
|
2452
|
-
|
|
2453
|
-
};
|
|
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
|
+
})();
|
|
2454
2525
|
Object.defineProperty(exports, "__esModule", ({ value: true }));
|
|
2455
|
-
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;
|
|
2456
2550
|
const dra_types_1 = __webpack_require__(/*! @dra2020/dra-types */ "@dra2020/dra-types");
|
|
2457
2551
|
const _data_1 = __webpack_require__(/*! ./_data */ "./src/_data.ts");
|
|
2458
2552
|
const S = __importStar(__webpack_require__(/*! ./settings */ "./src/settings.ts"));
|
|
@@ -2469,7 +2563,6 @@ function getDistrict(plan, geoID) {
|
|
|
2469
2563
|
return undefined;
|
|
2470
2564
|
}
|
|
2471
2565
|
}
|
|
2472
|
-
exports.getDistrict = getDistrict;
|
|
2473
2566
|
// WORKING WITH GEOIDS
|
|
2474
2567
|
function parseGeoID(geoID) {
|
|
2475
2568
|
let bVfeature = false;
|
|
@@ -2487,7 +2580,6 @@ function parseGeoID(geoID) {
|
|
|
2487
2580
|
};
|
|
2488
2581
|
return parts;
|
|
2489
2582
|
}
|
|
2490
|
-
exports.parseGeoID = parseGeoID;
|
|
2491
2583
|
// 08-13-2020 - Enhanced completeness checking.
|
|
2492
2584
|
function isWaterOnly(geoID, s) {
|
|
2493
2585
|
const waterOnlySignature = 'ZZZZZZ';
|
|
@@ -2504,7 +2596,6 @@ function isWaterOnly(geoID, s) {
|
|
|
2504
2596
|
else
|
|
2505
2597
|
return false;
|
|
2506
2598
|
}
|
|
2507
|
-
exports.isWaterOnly = isWaterOnly;
|
|
2508
2599
|
function isUninhabited(geoID, s) {
|
|
2509
2600
|
const featureID = s.features.featureID(geoID);
|
|
2510
2601
|
const f /* T.GeoFeature */ = s.features.featureByIndex(featureID);
|
|
@@ -2522,7 +2613,6 @@ function isUninhabited(geoID, s) {
|
|
|
2522
2613
|
}
|
|
2523
2614
|
return bUninhabited;
|
|
2524
2615
|
}
|
|
2525
|
-
exports.isUninhabited = isUninhabited;
|
|
2526
2616
|
// Round a fractional number [0-1] to the desired level of PRECISION.
|
|
2527
2617
|
function trim(fullFraction, digits = undefined) {
|
|
2528
2618
|
if (digits == 0) {
|
|
@@ -2533,48 +2623,38 @@ function trim(fullFraction, digits = undefined) {
|
|
|
2533
2623
|
return Math.round(fullFraction * shiftPlaces) / shiftPlaces;
|
|
2534
2624
|
}
|
|
2535
2625
|
}
|
|
2536
|
-
exports.trim = trim;
|
|
2537
2626
|
// ARRAY HELPERS
|
|
2538
2627
|
function sumArray(arr) {
|
|
2539
2628
|
return arr.reduce((a, b) => a + b, 0);
|
|
2540
2629
|
}
|
|
2541
|
-
exports.sumArray = sumArray;
|
|
2542
2630
|
function avgArray(arr) {
|
|
2543
2631
|
return (arr.reduce((a, b) => a + b, 0)) / arr.length;
|
|
2544
2632
|
}
|
|
2545
|
-
exports.avgArray = avgArray;
|
|
2546
2633
|
function minArray(arr) {
|
|
2547
2634
|
return Math.min(...arr);
|
|
2548
2635
|
}
|
|
2549
|
-
exports.minArray = minArray;
|
|
2550
2636
|
function maxArray(arr) {
|
|
2551
2637
|
return Math.max(...arr);
|
|
2552
2638
|
}
|
|
2553
|
-
exports.maxArray = maxArray;
|
|
2554
2639
|
function initArray(n, value) {
|
|
2555
2640
|
return Array.from(Array(n), () => value);
|
|
2556
2641
|
}
|
|
2557
|
-
exports.initArray = initArray;
|
|
2558
2642
|
function andArray(arr) {
|
|
2559
2643
|
return arr.reduce(function (a, b) { return a && b; }, true);
|
|
2560
2644
|
}
|
|
2561
|
-
exports.andArray = andArray;
|
|
2562
2645
|
// WORKING WITH OBJECT KEYS/PROPERTIES
|
|
2563
2646
|
// Does an object have a key/property?
|
|
2564
2647
|
function keyExists(k, o) {
|
|
2565
2648
|
return k in o;
|
|
2566
2649
|
}
|
|
2567
|
-
exports.keyExists = keyExists;
|
|
2568
2650
|
// Does an object (dict) have any keys/properties?
|
|
2569
2651
|
function isObjectEmpty(o) {
|
|
2570
2652
|
return Object.keys(o).length === 0;
|
|
2571
2653
|
}
|
|
2572
|
-
exports.isObjectEmpty = isObjectEmpty;
|
|
2573
2654
|
// Does a Set have any members?
|
|
2574
2655
|
function isSetEmpty(s) {
|
|
2575
2656
|
return s.size === 0;
|
|
2576
2657
|
}
|
|
2577
|
-
exports.isSetEmpty = isSetEmpty;
|
|
2578
2658
|
// Does an array hold any items?
|
|
2579
2659
|
function isArrayEmpty(a) {
|
|
2580
2660
|
if (a === undefined || a.length == 0) {
|
|
@@ -2585,16 +2665,13 @@ function isArrayEmpty(a) {
|
|
|
2585
2665
|
return false;
|
|
2586
2666
|
}
|
|
2587
2667
|
}
|
|
2588
|
-
exports.isArrayEmpty = isArrayEmpty;
|
|
2589
2668
|
// Get the keys for an object
|
|
2590
2669
|
function getObjectKeys(o) {
|
|
2591
2670
|
return Object.keys(o);
|
|
2592
2671
|
}
|
|
2593
|
-
exports.getObjectKeys = getObjectKeys;
|
|
2594
2672
|
function getNumericObjectKeys(o) {
|
|
2595
2673
|
return Object.keys(o).map(Number);
|
|
2596
2674
|
}
|
|
2597
|
-
exports.getNumericObjectKeys = getNumericObjectKeys;
|
|
2598
2675
|
function getSelectObjectKeys(o, v) {
|
|
2599
2676
|
let selectKeys = [];
|
|
2600
2677
|
Object.keys(o).forEach(key => {
|
|
@@ -2604,15 +2681,12 @@ function getSelectObjectKeys(o, v) {
|
|
|
2604
2681
|
});
|
|
2605
2682
|
return selectKeys;
|
|
2606
2683
|
}
|
|
2607
|
-
exports.getSelectObjectKeys = getSelectObjectKeys;
|
|
2608
2684
|
function arrayContains(a, item) {
|
|
2609
2685
|
return a.some(x => x === item);
|
|
2610
2686
|
}
|
|
2611
|
-
exports.arrayContains = arrayContains;
|
|
2612
2687
|
function objectContains(o, key) {
|
|
2613
2688
|
return (key in o);
|
|
2614
2689
|
}
|
|
2615
|
-
exports.objectContains = objectContains;
|
|
2616
2690
|
// ENUM HELPERS
|
|
2617
2691
|
// Source: https://stackoverflow.com/questions/38034673/determine-the-number-of-enum-elements-typescript
|
|
2618
2692
|
function countEnumValues(enumName) {
|
|
@@ -2623,7 +2697,6 @@ function countEnumValues(enumName) {
|
|
|
2623
2697
|
}
|
|
2624
2698
|
return count;
|
|
2625
2699
|
}
|
|
2626
|
-
exports.countEnumValues = countEnumValues;
|
|
2627
2700
|
// COPYING - Copied from dra-client/util.ts
|
|
2628
2701
|
function shallowCopy(src) {
|
|
2629
2702
|
if (Array.isArray(src))
|
|
@@ -2638,7 +2711,6 @@ function shallowCopy(src) {
|
|
|
2638
2711
|
else
|
|
2639
2712
|
return src;
|
|
2640
2713
|
}
|
|
2641
|
-
exports.shallowCopy = shallowCopy;
|
|
2642
2714
|
function deepCopy(src) {
|
|
2643
2715
|
if (Array.isArray(src)) {
|
|
2644
2716
|
let dst = [];
|
|
@@ -2656,7 +2728,6 @@ function deepCopy(src) {
|
|
|
2656
2728
|
else
|
|
2657
2729
|
return src;
|
|
2658
2730
|
}
|
|
2659
|
-
exports.deepCopy = deepCopy;
|
|
2660
2731
|
function depthof(a) {
|
|
2661
2732
|
if (a === null || a === undefined)
|
|
2662
2733
|
return 1;
|
|
@@ -2683,7 +2754,6 @@ function depthof(a) {
|
|
|
2683
2754
|
}
|
|
2684
2755
|
}
|
|
2685
2756
|
}
|
|
2686
|
-
exports.depthof = depthof;
|
|
2687
2757
|
|
|
2688
2758
|
|
|
2689
2759
|
/***/ }),
|
|
@@ -2714,15 +2784,27 @@ var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (
|
|
|
2714
2784
|
}) : function(o, v) {
|
|
2715
2785
|
o["default"] = v;
|
|
2716
2786
|
});
|
|
2717
|
-
var __importStar = (this && this.__importStar) || function (
|
|
2718
|
-
|
|
2719
|
-
|
|
2720
|
-
|
|
2721
|
-
|
|
2722
|
-
|
|
2723
|
-
};
|
|
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
|
+
})();
|
|
2724
2804
|
Object.defineProperty(exports, "__esModule", ({ value: true }));
|
|
2725
|
-
exports.
|
|
2805
|
+
exports.doIsComplete = doIsComplete;
|
|
2806
|
+
exports.doIsContiguous = doIsContiguous;
|
|
2807
|
+
exports.doIsFreeOfHoles = doIsFreeOfHoles;
|
|
2726
2808
|
const U = __importStar(__webpack_require__(/*! ./utils */ "./src/utils.ts"));
|
|
2727
2809
|
const S = __importStar(__webpack_require__(/*! ./settings */ "./src/settings.ts"));
|
|
2728
2810
|
//
|
|
@@ -2804,7 +2886,6 @@ function doIsComplete(s, bLog = false) {
|
|
|
2804
2886
|
bNotEmpty[summaryRow] = test['score'];
|
|
2805
2887
|
return test;
|
|
2806
2888
|
}
|
|
2807
|
-
exports.doIsComplete = doIsComplete;
|
|
2808
2889
|
//
|
|
2809
2890
|
// CONTIGUOUS - Is each district in a plan fully connected?
|
|
2810
2891
|
//
|
|
@@ -2840,7 +2921,6 @@ function doIsContiguous(s, bLog = false) {
|
|
|
2840
2921
|
bContiguous[summaryRow] = test['score'];
|
|
2841
2922
|
return test;
|
|
2842
2923
|
}
|
|
2843
|
-
exports.doIsContiguous = doIsContiguous;
|
|
2844
2924
|
//
|
|
2845
2925
|
// FREE OF HOLES - Are any districts fully embedded w/in another district?
|
|
2846
2926
|
//
|
|
@@ -2879,7 +2959,6 @@ function doIsFreeOfHoles(s, bLog = false) {
|
|
|
2879
2959
|
bNotEmbedded[summaryRow] = test['score'];
|
|
2880
2960
|
return test;
|
|
2881
2961
|
}
|
|
2882
|
-
exports.doIsFreeOfHoles = doIsFreeOfHoles;
|
|
2883
2962
|
|
|
2884
2963
|
|
|
2885
2964
|
/***/ }),
|