@dra2020/district-analytics 8.0.0 → 8.1.1
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/cli.js +85 -5
- package/dist/cli.js.map +1 -1
- package/dist/district-analytics.js +85 -5
- package/dist/district-analytics.js.map +1 -1
- package/dist/src/_data.d.ts +4 -28
- package/dist/src/types.d.ts +24 -0
- package/dist/src/utils.d.ts +3 -1
- package/package.json +1 -1
package/dist/cli.js
CHANGED
|
@@ -103415,6 +103415,41 @@ class Districts {
|
|
|
103415
103415
|
}
|
|
103416
103416
|
}
|
|
103417
103417
|
exports.Districts = Districts;
|
|
103418
|
+
// CLASSES, ETC. FOR FEATURE & COUNTY DATA
|
|
103419
|
+
// Types of datasets by feature
|
|
103420
|
+
/* 08-13-2020 - Moved to types.ts
|
|
103421
|
+
export const enum Dataset
|
|
103422
|
+
{
|
|
103423
|
+
SHAPES = "SHAPES",
|
|
103424
|
+
CENSUS = "CENSUS",
|
|
103425
|
+
VAP = "VAP",
|
|
103426
|
+
ELECTION = "ELECTION"
|
|
103427
|
+
}
|
|
103428
|
+
*/
|
|
103429
|
+
/* 08-13-2020 - Moved to types.ts
|
|
103430
|
+
export type DatasetKeys = {
|
|
103431
|
+
SHAPES: string; // A shapefile
|
|
103432
|
+
CENSUS: string; // A total population Census dataset
|
|
103433
|
+
VAP: string; // A voting age (or citizen voting age) dataset
|
|
103434
|
+
ELECTION: string; // An election dataset
|
|
103435
|
+
}
|
|
103436
|
+
*/
|
|
103437
|
+
// Identifiers of fields for each feature in the datasets
|
|
103438
|
+
/* 08-13-2020 - Moved to types.ts
|
|
103439
|
+
export const enum FeatureField
|
|
103440
|
+
{
|
|
103441
|
+
TotalPop = "Tot",
|
|
103442
|
+
WhitePop = "Wh",
|
|
103443
|
+
BlackPop = "BlC",
|
|
103444
|
+
HispanicPop = "His",
|
|
103445
|
+
AsianPop = "AsnC",
|
|
103446
|
+
PacificPop = "PacC",
|
|
103447
|
+
NativePop = "NatC",
|
|
103448
|
+
DemVotes = "D",
|
|
103449
|
+
RepVotes = "R",
|
|
103450
|
+
TotalVotes = "Tot"
|
|
103451
|
+
}
|
|
103452
|
+
*/
|
|
103418
103453
|
// Wrap data by feature, to abstract the specifics of the internal structure
|
|
103419
103454
|
class Features {
|
|
103420
103455
|
constructor(s, data, keys) {
|
|
@@ -104005,8 +104040,6 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
104005
104040
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
104006
104041
|
const majority_minority_json_1 = __importDefault(__webpack_require__(/*! ../static/majority-minority.json */ "./static/majority-minority.json"));
|
|
104007
104042
|
const vra5_preclearance_json_1 = __importDefault(__webpack_require__(/*! ../static/vra5-preclearance.json */ "./static/vra5-preclearance.json"));
|
|
104008
|
-
// import stateContacts from '../static/state-contacts.json';
|
|
104009
|
-
// import demographicDefs from '../static/demographic-defns.json';
|
|
104010
104043
|
// TODO - 2020: Update/revise this, when the update comes out in September:
|
|
104011
104044
|
// Sources for majority-minority info:
|
|
104012
104045
|
// - https://en.wikipedia.org/wiki/List_of_majority-minority_United_States_congressional_districts
|
|
@@ -104725,14 +104758,38 @@ function parseGeoID(geoID) {
|
|
|
104725
104758
|
return parts;
|
|
104726
104759
|
}
|
|
104727
104760
|
exports.parseGeoID = parseGeoID;
|
|
104728
|
-
|
|
104729
|
-
|
|
104761
|
+
// 08-13-2020 - Enhanced completeness checking.
|
|
104762
|
+
function isWaterOnly(geoID, s) {
|
|
104763
|
+
const waterOnlySignature = 'ZZZZZZ';
|
|
104730
104764
|
if (geoID.indexOf(waterOnlySignature) >= 0)
|
|
104731
104765
|
return true;
|
|
104766
|
+
if (s) {
|
|
104767
|
+
// If called with a session, get the feature ...
|
|
104768
|
+
const featureID = s.features.featureID(geoID);
|
|
104769
|
+
const f = s.features.featureByIndex(featureID);
|
|
104770
|
+
// ... and also check the 'ALAND' property
|
|
104771
|
+
const bNoLand = ((f.properties['ALAND10'] !== undefined) && (f.properties['ALAND10'] == 0)) ? true : false;
|
|
104772
|
+
return bNoLand;
|
|
104773
|
+
}
|
|
104732
104774
|
else
|
|
104733
104775
|
return false;
|
|
104734
104776
|
}
|
|
104735
104777
|
exports.isWaterOnly = isWaterOnly;
|
|
104778
|
+
function isUninhabited(geoID, s) {
|
|
104779
|
+
const featureID = s.features.featureID(geoID);
|
|
104780
|
+
const f = s.features.featureByIndex(featureID);
|
|
104781
|
+
const totalPop = s.features.fieldForFeature(f, "CENSUS" /* CENSUS */, "Tot" /* TotalPop */);
|
|
104782
|
+
let bUninhabited = (totalPop > 0) ? false : true;
|
|
104783
|
+
// HACK for Kentucky's atypical data, so the official map shows as complete
|
|
104784
|
+
const geoIDparts = parseGeoID(geoID);
|
|
104785
|
+
if (geoIDparts.state == '21') // KY
|
|
104786
|
+
{
|
|
104787
|
+
if ((f.properties['POPULATION'] !== undefined) && (f.properties['POPULATION'] == 0))
|
|
104788
|
+
bUninhabited = true;
|
|
104789
|
+
}
|
|
104790
|
+
return bUninhabited;
|
|
104791
|
+
}
|
|
104792
|
+
exports.isUninhabited = isUninhabited;
|
|
104736
104793
|
// NORMALIZING RESULTS
|
|
104737
104794
|
function normalize(rawScore, testScale) {
|
|
104738
104795
|
let rangeMin = testScale.scale[0];
|
|
@@ -104942,10 +104999,26 @@ function doIsComplete(s, bLog = false) {
|
|
|
104942
104999
|
// Check the dummy district that holds any unassigned features.
|
|
104943
105000
|
let unassignedFeatures = [];
|
|
104944
105001
|
let bAllAssigned = (!bNotEmptyByDistrict[S.NOT_ASSIGNED]);
|
|
105002
|
+
let bAllNonWaterOnlyAssigned = bAllAssigned ? true : false;
|
|
104945
105003
|
if (!bAllAssigned) {
|
|
104946
105004
|
let unassignedDistrict = s.plan.geoIDsForDistrictID(S.NOT_ASSIGNED);
|
|
104947
105005
|
unassignedFeatures = Array.from(unassignedDistrict);
|
|
104948
105006
|
// unassignedFeatures = unassignedFeatures.slice(0, S.NUMBER_OF_ITEMS_TO_REPORT);
|
|
105007
|
+
// 08-13-2020 - Enhanced completeness checking.
|
|
105008
|
+
// Are any of the unassigned features not water-only -or- inhabited?
|
|
105009
|
+
// Check the official congressional maps for CT, KY, IL, and MI.
|
|
105010
|
+
bAllNonWaterOnlyAssigned = !unassignedFeatures.some(function (geoID) {
|
|
105011
|
+
if (U.isWaterOnly(geoID, s)) {
|
|
105012
|
+
console.log("Unassigned water-only feature ignored in completeness check: ", geoID);
|
|
105013
|
+
return false;
|
|
105014
|
+
}
|
|
105015
|
+
if (U.isUninhabited(geoID, s)) {
|
|
105016
|
+
console.log("Uninhabited feature ignored in completeness check: ", geoID);
|
|
105017
|
+
return false;
|
|
105018
|
+
}
|
|
105019
|
+
// Not water-only and inhabited
|
|
105020
|
+
return true;
|
|
105021
|
+
});
|
|
104949
105022
|
}
|
|
104950
105023
|
// Do all real districts have at least one feature assigned to them?
|
|
104951
105024
|
let emptyDistricts = [];
|
|
@@ -104969,7 +105042,14 @@ function doIsComplete(s, bLog = false) {
|
|
|
104969
105042
|
// Note, this can happen if a district is created, and then all features
|
|
104970
105043
|
// are removed from it (in DRA).
|
|
104971
105044
|
// Populate the test entry
|
|
104972
|
-
|
|
105045
|
+
// 08-13-2020 - Revised completeness check:
|
|
105046
|
+
// A plan is complete if:
|
|
105047
|
+
// * All inhabited, not water-only districts are assigned to districts.
|
|
105048
|
+
// * No districts are empty, i.e., each has one or more geos assigned to them.
|
|
105049
|
+
// Note: We're not checking (in _data.ts) whether those geos are water-only
|
|
105050
|
+
// or have any population, but that's a real edge case.
|
|
105051
|
+
test['score'] = bAllNonWaterOnlyAssigned && bNoneEmpty;
|
|
105052
|
+
// test['score'] = bAllAssigned && bNoneEmpty;
|
|
104973
105053
|
if (!bAllAssigned) {
|
|
104974
105054
|
test['details']['unassignedFeatures'] = unassignedFeatures;
|
|
104975
105055
|
}
|