@dra2020/district-analytics 8.2.2 → 8.2.5
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 +58 -19
- package/dist/cli.js.map +1 -1
- package/dist/district-analytics.js +46 -12
- package/dist/district-analytics.js.map +1 -1
- package/dist/src/results.d.ts +2 -1
- package/package.json +3 -3
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 */);
|
|
@@ -281987,7 +281999,7 @@ function extractDistrictProperties(s, bLog = false) {
|
|
|
281987
281999
|
exports.extractDistrictProperties = extractDistrictProperties;
|
|
281988
282000
|
function isAShape(poly) {
|
|
281989
282001
|
const bPolyUndefined = (poly === undefined) ? true : false;
|
|
281990
|
-
const bNull = (bPolyUndefined) ? true : Poly.polyNull(poly); // TODO
|
|
282002
|
+
const bNull = (bPolyUndefined) ? true : Poly.polyNull(poly); // TODO - poly
|
|
281991
282003
|
const bNoCoordinates = U.isArrayEmpty((poly.geometry.coordinates)) ? true : false;
|
|
281992
282004
|
return (!bPolyUndefined && !bNull && !bNoCoordinates);
|
|
281993
282005
|
}
|
|
@@ -282203,12 +282215,25 @@ function doPreprocessData(s, bLog = false) {
|
|
|
282203
282215
|
exports.doPreprocessData = doPreprocessData;
|
|
282204
282216
|
// CREATE A FIPS CODE TO COUNTY NAME LOOKUP
|
|
282205
282217
|
function doPreprocessCountyFeatures(s, bLog = false) {
|
|
282218
|
+
let fipsCodes = [];
|
|
282219
|
+
// CREATE A MAP OF FIPS CODES TO NAMES
|
|
282206
282220
|
for (let i = 0; i < s.counties.nCounties; i++) {
|
|
282207
282221
|
let county = s.counties.countyByIndex(i);
|
|
282208
282222
|
let fips = s.counties.propertyForCounty(county, 'COUNTYFP');
|
|
282223
|
+
fipsCodes.push(fips);
|
|
282209
282224
|
let name = s.counties.propertyForCounty(county, 'NAME');
|
|
282210
282225
|
s.counties.mapFIPSToName(fips, name);
|
|
282211
282226
|
}
|
|
282227
|
+
// CREATE A FIPS CODE-ORDINAL MAP
|
|
282228
|
+
// Sort the FIPS codes in the county shapes
|
|
282229
|
+
fipsCodes = fipsCodes.sort();
|
|
282230
|
+
// Add a dummy county, for county-district splitting analysis.
|
|
282231
|
+
fipsCodes.unshift('000');
|
|
282232
|
+
// NOTE - This was added for the legacy SPLITTING implementation.
|
|
282233
|
+
// Create the ID-ordinal map
|
|
282234
|
+
for (let i in fipsCodes) {
|
|
282235
|
+
s.counties.index[fipsCodes[i]] = Number(i);
|
|
282236
|
+
}
|
|
282212
282237
|
}
|
|
282213
282238
|
// ANALYZE THE CENSUS BY COUNTY
|
|
282214
282239
|
function doPreprocessCensus(s, bLog = false) {
|
|
@@ -282228,12 +282253,18 @@ function doPreprocessCensus(s, bLog = false) {
|
|
|
282228
282253
|
s.state.totalPop += value;
|
|
282229
282254
|
// Get the county FIPS code for the feature
|
|
282230
282255
|
let countyFIPS = U.parseGeoID(geoID)['county'];
|
|
282231
|
-
//
|
|
282232
|
-
if (
|
|
282233
|
-
|
|
282256
|
+
// Ignore features when the county is unrecognized
|
|
282257
|
+
if (U.keyExists(countyFIPS, s.counties.index)) {
|
|
282258
|
+
// If a subtotal for the county doesn't exist, initialize one
|
|
282259
|
+
if (!(U.keyExists(countyFIPS, totalByCounty))) {
|
|
282260
|
+
totalByCounty[countyFIPS] = 0;
|
|
282261
|
+
}
|
|
282262
|
+
// Sum total population by county
|
|
282263
|
+
totalByCounty[countyFIPS] += value;
|
|
282264
|
+
}
|
|
282265
|
+
else {
|
|
282266
|
+
console.log("County not recognized:", geoID);
|
|
282234
282267
|
}
|
|
282235
|
-
// Sum total population by county
|
|
282236
|
-
totalByCounty[countyFIPS] += value;
|
|
282237
282268
|
}
|
|
282238
282269
|
else {
|
|
282239
282270
|
if (bLog)
|
|
@@ -282241,18 +282272,24 @@ function doPreprocessCensus(s, bLog = false) {
|
|
|
282241
282272
|
}
|
|
282242
282273
|
}
|
|
282243
282274
|
// NOTE - The above could be replaced, if I got totals on county.geojson.
|
|
282275
|
+
/* Moved this to doPreprocessCountyFeatures() - 09-14-2020 to fix VA county mismatch bug
|
|
282244
282276
|
// CREATE A FIPS CODE-ORDINAL MAP
|
|
282277
|
+
|
|
282245
282278
|
// Get the county FIPS codes
|
|
282246
282279
|
let fipsCodes = U.getObjectKeys(totalByCounty);
|
|
282247
282280
|
// Sort the results
|
|
282248
282281
|
fipsCodes = fipsCodes.sort();
|
|
282282
|
+
|
|
282249
282283
|
// NOTE - This was added for the legacy SPLITTING implementation.
|
|
282250
282284
|
// Add a dummy county, for county-district splitting analysis.
|
|
282251
282285
|
fipsCodes.unshift('000');
|
|
282286
|
+
|
|
282252
282287
|
// Create the ID-ordinal map
|
|
282253
|
-
for (let i in fipsCodes)
|
|
282254
|
-
|
|
282288
|
+
for (let i in fipsCodes)
|
|
282289
|
+
{
|
|
282290
|
+
s.counties.index[fipsCodes[i]] = Number(i);
|
|
282255
282291
|
}
|
|
282292
|
+
*/
|
|
282256
282293
|
// MAKE AN ARRAY OF TOTAL POPULATIONS BY COUNTY INDEX
|
|
282257
282294
|
// Add an extra 0th virtual county bucket for county-district splitting analysis
|
|
282258
282295
|
let nCountyBuckets = s.counties.nCounties + 1;
|
|
@@ -282274,6 +282311,8 @@ function doPreprocessCensus(s, bLog = false) {
|
|
|
282274
282311
|
let tooBigName = [];
|
|
282275
282312
|
let expectedSplits = 0;
|
|
282276
282313
|
let expectedAffected = 0;
|
|
282314
|
+
// Get the county FIPS codes
|
|
282315
|
+
let fipsCodes = U.getObjectKeys(s.counties.index);
|
|
282277
282316
|
// Loop over the counties
|
|
282278
282317
|
for (let county in fipsCodes) {
|
|
282279
282318
|
let fipsCode = fipsCodes[county];
|