@dra2020/district-analytics 8.2.3 → 8.2.6
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 +64 -28
- package/dist/cli.js.map +1 -1
- package/dist/district-analytics.js +52 -21
- package/dist/district-analytics.js.map +1 -1
- package/dist/src/results.d.ts +2 -1
- package/package.json +3 -3
- package/dist/src/geofeature.d.ts +0 -0
package/dist/cli.js
CHANGED
|
@@ -90407,7 +90407,7 @@ function combineTwoPolys(poly1, poly2) {
|
|
|
90407
90407
|
throw 'Unable to load union function from polygon-clipping';
|
|
90408
90408
|
return _union(poly1, poly2);
|
|
90409
90409
|
}
|
|
90410
|
-
// FEATURE 3: REOCK
|
|
90410
|
+
// FEATURE 3: REOCK - Reock is the primary measure of the dispersion of district
|
|
90411
90411
|
// shapes, calculated as “the area of the distric to the area of the minimum spanning
|
|
90412
90412
|
// circle that can enclose the district.”
|
|
90413
90413
|
//
|
|
@@ -90531,12 +90531,17 @@ exports.featureizePoly = featureizePoly;
|
|
|
90531
90531
|
//
|
|
90532
90532
|
// COMPACTNESS PACKAGE API
|
|
90533
90533
|
//
|
|
90534
|
-
function __export(m) {
|
|
90535
|
-
for (var p in m) if (!exports.hasOwnProperty(p)) exports[p] = m[p];
|
|
90536
|
-
}
|
|
90537
90534
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
90538
|
-
|
|
90539
|
-
|
|
90535
|
+
var features_1 = __webpack_require__(/*! ./features */ "./src/features.ts");
|
|
90536
|
+
exports.calcXSymmetry = features_1.calcXSymmetry;
|
|
90537
|
+
exports.calcYSymmetry = features_1.calcYSymmetry;
|
|
90538
|
+
exports.calcReock = features_1.calcReock;
|
|
90539
|
+
exports.calcBoundingBox = features_1.calcBoundingBox;
|
|
90540
|
+
exports.calcPolsbyPopper = features_1.calcPolsbyPopper;
|
|
90541
|
+
exports.calcConvexHullFeature = features_1.calcConvexHullFeature;
|
|
90542
|
+
exports.calcSchwartzberg = features_1.calcSchwartzberg;
|
|
90543
|
+
var kiwysi_1 = __webpack_require__(/*! ./kiwysi */ "./src/kiwysi.ts");
|
|
90544
|
+
exports.scoreShapes = kiwysi_1.scoreShapes;
|
|
90540
90545
|
|
|
90541
90546
|
|
|
90542
90547
|
/***/ }),
|
|
@@ -90566,7 +90571,7 @@ exports.scoreShape = scoreShape;
|
|
|
90566
90571
|
function scoreShapes(shapes, options) {
|
|
90567
90572
|
let scores = [];
|
|
90568
90573
|
for (let i = 0; i < shapes.features.length; i++) {
|
|
90569
|
-
scores.push(scoreShape(shapes.features[i]));
|
|
90574
|
+
scores.push(scoreShape(shapes.features[i], options));
|
|
90570
90575
|
}
|
|
90571
90576
|
return scores;
|
|
90572
90577
|
}
|
|
@@ -281273,10 +281278,17 @@ class Districts {
|
|
|
281273
281278
|
featurePop = outerThis._session.features.fieldForFeature(f, "CENSUS" /* CENSUS */, "Tot" /* TotalPop */);
|
|
281274
281279
|
// Total district population
|
|
281275
281280
|
totalPop += featurePop;
|
|
281276
|
-
//
|
|
281277
|
-
|
|
281278
|
-
if (
|
|
281279
|
-
|
|
281281
|
+
// Ignore features when the county is unrecognized
|
|
281282
|
+
const countyFIPS = U.parseGeoID(geoID)['county'];
|
|
281283
|
+
if (U.keyExists(countyFIPS, outerThis._session.counties.index)) {
|
|
281284
|
+
// Total population by counties w/in a district,
|
|
281285
|
+
// except the dummy unassigned district 0
|
|
281286
|
+
if (i > 0)
|
|
281287
|
+
countySplits[outerThis.getCountyIndex(geoID)] += featurePop;
|
|
281288
|
+
}
|
|
281289
|
+
else {
|
|
281290
|
+
console.log("County not recognized:", geoID);
|
|
281291
|
+
}
|
|
281280
281292
|
// Democratic and Republican vote totals
|
|
281281
281293
|
demVotes += outerThis._session.features.fieldForFeature(f, "ELECTION" /* ELECTION */, "D" /* DemVotes */);
|
|
281282
281294
|
repVotes += outerThis._session.features.fieldForFeature(f, "ELECTION" /* ELECTION */, "R" /* RepVotes */);
|
|
@@ -281986,10 +281998,11 @@ function extractDistrictProperties(s, bLog = false) {
|
|
|
281986
281998
|
}
|
|
281987
281999
|
exports.extractDistrictProperties = extractDistrictProperties;
|
|
281988
282000
|
function isAShape(poly) {
|
|
281989
|
-
|
|
281990
|
-
|
|
281991
|
-
|
|
281992
|
-
|
|
282001
|
+
if (poly == null)
|
|
282002
|
+
return false;
|
|
282003
|
+
if (Poly.polyNull(poly))
|
|
282004
|
+
return false;
|
|
282005
|
+
return poly.geometry && poly.geometry.coordinates && !U.isArrayEmpty(poly.geometry.coordinates);
|
|
281993
282006
|
}
|
|
281994
282007
|
// SCORE KIWYSI COMPACTNESS
|
|
281995
282008
|
function scoreKIWYSICompactness(s, bLog = false) {
|
|
@@ -282203,12 +282216,25 @@ function doPreprocessData(s, bLog = false) {
|
|
|
282203
282216
|
exports.doPreprocessData = doPreprocessData;
|
|
282204
282217
|
// CREATE A FIPS CODE TO COUNTY NAME LOOKUP
|
|
282205
282218
|
function doPreprocessCountyFeatures(s, bLog = false) {
|
|
282219
|
+
let fipsCodes = [];
|
|
282220
|
+
// CREATE A MAP OF FIPS CODES TO NAMES
|
|
282206
282221
|
for (let i = 0; i < s.counties.nCounties; i++) {
|
|
282207
282222
|
let county = s.counties.countyByIndex(i);
|
|
282208
282223
|
let fips = s.counties.propertyForCounty(county, 'COUNTYFP');
|
|
282224
|
+
fipsCodes.push(fips);
|
|
282209
282225
|
let name = s.counties.propertyForCounty(county, 'NAME');
|
|
282210
282226
|
s.counties.mapFIPSToName(fips, name);
|
|
282211
282227
|
}
|
|
282228
|
+
// CREATE A FIPS CODE-ORDINAL MAP
|
|
282229
|
+
// Sort the FIPS codes in the county shapes
|
|
282230
|
+
fipsCodes = fipsCodes.sort();
|
|
282231
|
+
// Add a dummy county, for county-district splitting analysis.
|
|
282232
|
+
fipsCodes.unshift('000');
|
|
282233
|
+
// NOTE - This was added for the legacy SPLITTING implementation.
|
|
282234
|
+
// Create the ID-ordinal map
|
|
282235
|
+
for (let i in fipsCodes) {
|
|
282236
|
+
s.counties.index[fipsCodes[i]] = Number(i);
|
|
282237
|
+
}
|
|
282212
282238
|
}
|
|
282213
282239
|
// ANALYZE THE CENSUS BY COUNTY
|
|
282214
282240
|
function doPreprocessCensus(s, bLog = false) {
|
|
@@ -282228,12 +282254,18 @@ function doPreprocessCensus(s, bLog = false) {
|
|
|
282228
282254
|
s.state.totalPop += value;
|
|
282229
282255
|
// Get the county FIPS code for the feature
|
|
282230
282256
|
let countyFIPS = U.parseGeoID(geoID)['county'];
|
|
282231
|
-
//
|
|
282232
|
-
if (
|
|
282233
|
-
|
|
282257
|
+
// Ignore features when the county is unrecognized
|
|
282258
|
+
if (U.keyExists(countyFIPS, s.counties.index)) {
|
|
282259
|
+
// If a subtotal for the county doesn't exist, initialize one
|
|
282260
|
+
if (!(U.keyExists(countyFIPS, totalByCounty))) {
|
|
282261
|
+
totalByCounty[countyFIPS] = 0;
|
|
282262
|
+
}
|
|
282263
|
+
// Sum total population by county
|
|
282264
|
+
totalByCounty[countyFIPS] += value;
|
|
282265
|
+
}
|
|
282266
|
+
else {
|
|
282267
|
+
console.log("County not recognized:", geoID);
|
|
282234
282268
|
}
|
|
282235
|
-
// Sum total population by county
|
|
282236
|
-
totalByCounty[countyFIPS] += value;
|
|
282237
282269
|
}
|
|
282238
282270
|
else {
|
|
282239
282271
|
if (bLog)
|
|
@@ -282241,18 +282273,24 @@ function doPreprocessCensus(s, bLog = false) {
|
|
|
282241
282273
|
}
|
|
282242
282274
|
}
|
|
282243
282275
|
// NOTE - The above could be replaced, if I got totals on county.geojson.
|
|
282276
|
+
/* Moved this to doPreprocessCountyFeatures() - 09-14-2020 to fix VA county mismatch bug
|
|
282244
282277
|
// CREATE A FIPS CODE-ORDINAL MAP
|
|
282278
|
+
|
|
282245
282279
|
// Get the county FIPS codes
|
|
282246
282280
|
let fipsCodes = U.getObjectKeys(totalByCounty);
|
|
282247
282281
|
// Sort the results
|
|
282248
282282
|
fipsCodes = fipsCodes.sort();
|
|
282283
|
+
|
|
282249
282284
|
// NOTE - This was added for the legacy SPLITTING implementation.
|
|
282250
282285
|
// Add a dummy county, for county-district splitting analysis.
|
|
282251
282286
|
fipsCodes.unshift('000');
|
|
282287
|
+
|
|
282252
282288
|
// Create the ID-ordinal map
|
|
282253
|
-
for (let i in fipsCodes)
|
|
282254
|
-
|
|
282289
|
+
for (let i in fipsCodes)
|
|
282290
|
+
{
|
|
282291
|
+
s.counties.index[fipsCodes[i]] = Number(i);
|
|
282255
282292
|
}
|
|
282293
|
+
*/
|
|
282256
282294
|
// MAKE AN ARRAY OF TOTAL POPULATIONS BY COUNTY INDEX
|
|
282257
282295
|
// Add an extra 0th virtual county bucket for county-district splitting analysis
|
|
282258
282296
|
let nCountyBuckets = s.counties.nCounties + 1;
|
|
@@ -282274,6 +282312,8 @@ function doPreprocessCensus(s, bLog = false) {
|
|
|
282274
282312
|
let tooBigName = [];
|
|
282275
282313
|
let expectedSplits = 0;
|
|
282276
282314
|
let expectedAffected = 0;
|
|
282315
|
+
// Get the county FIPS codes
|
|
282316
|
+
let fipsCodes = U.getObjectKeys(s.counties.index);
|
|
282277
282317
|
// Loop over the counties
|
|
282278
282318
|
for (let county in fipsCodes) {
|
|
282279
282319
|
let fipsCode = fipsCodes[county];
|
|
@@ -282727,13 +282767,9 @@ function scorePlan(s, p, bLog = false, overridesJSON) {
|
|
|
282727
282767
|
// Add minority notes
|
|
282728
282768
|
scorecard.minority.details['majorityMinority'] = M.getMajorityMinority(s);
|
|
282729
282769
|
scorecard.minority.details['vraPreclearance'] = M.getVRASection5(s);
|
|
282730
|
-
// TODO - KIWYSI
|
|
282731
282770
|
// Add KIWYSI compactness score
|
|
282732
|
-
|
|
282733
|
-
|
|
282734
|
-
const kiwysiScore = C.scoreKIWYSICompactness(s, bLog);
|
|
282735
|
-
scorecard.compactness.details['kiwysi'] = kiwysiScore;
|
|
282736
|
-
}
|
|
282771
|
+
const kiwysiScore = C.scoreKIWYSICompactness(s, bLog);
|
|
282772
|
+
scorecard.compactness.details['kiwysi'] = kiwysiScore;
|
|
282737
282773
|
return scorecard;
|
|
282738
282774
|
}
|
|
282739
282775
|
exports.scorePlan = scorePlan;
|