@dra2020/district-analytics 11.5.2 → 12.1.0
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 +203 -89
- package/dist/district-analytics.js.map +1 -1
- package/dist/src/_data.d.ts +4 -3
- package/dist/src/index.d.ts +2 -1
- package/dist/src/pg.d.ts +2 -0
- package/dist/src/types.d.ts +3 -0
- package/package.json +4 -4
|
@@ -231,7 +231,7 @@ var __importStar = (this && this.__importStar) || function (mod) {
|
|
|
231
231
|
return result;
|
|
232
232
|
};
|
|
233
233
|
Object.defineProperty(exports, "__esModule", ({ value: true }));
|
|
234
|
-
exports.Graph = exports.invertPlan = exports.Plan = exports.State = exports.Counties = exports.
|
|
234
|
+
exports.Graph = exports.invertPlan = exports.Plan = exports.State = exports.Counties = exports.fieldForFeature = exports.geoIDForFeature = exports.Features = exports.inferSelectedMinority = exports.Districts = void 0;
|
|
235
235
|
const G = __importStar(__webpack_require__(/*! @dra2020/dra-graph */ "@dra2020/dra-graph"));
|
|
236
236
|
const U = __importStar(__webpack_require__(/*! ./utils */ "./src/utils.ts"));
|
|
237
237
|
const S = __importStar(__webpack_require__(/*! ./settings */ "./src/settings.ts"));
|
|
@@ -388,7 +388,10 @@ class Districts {
|
|
|
388
388
|
// ACCUMULATE VALUES
|
|
389
389
|
// Total population of each feature
|
|
390
390
|
// NOTE - This result is used more than once
|
|
391
|
-
|
|
391
|
+
// 03-27-21
|
|
392
|
+
const dkCENSUS = outerThis._session.features._keys["CENSUS" /* CENSUS */];
|
|
393
|
+
featurePop = fieldForFeature(f, dkCENSUS, "Tot" /* TotalPop */);
|
|
394
|
+
// featurePop = outerThis._session.features.fieldForFeature(f, T.Dataset.CENSUS, T.FeatureField.TotalPop);
|
|
392
395
|
// Total district population
|
|
393
396
|
totalPop += featurePop;
|
|
394
397
|
// Ignore features when the county is unrecognized
|
|
@@ -406,15 +409,15 @@ class Districts {
|
|
|
406
409
|
// Democratic and Republican vote totals
|
|
407
410
|
// 10-22-2020 - Added Other votes
|
|
408
411
|
// 10-24-2020 - Added guard against inconsistent election data
|
|
409
|
-
|
|
410
|
-
const
|
|
411
|
-
const
|
|
412
|
+
// 03-27-2021
|
|
413
|
+
const dkELECTION = outerThis._session.features._keys["ELECTION" /* ELECTION */];
|
|
414
|
+
const featureDem = fieldForFeature(f, dkELECTION, "D" /* DemVotes */);
|
|
415
|
+
// const featureDem = outerThis._session.features.fieldForFeature(f, T.Dataset.ELECTION, T.FeatureField.DemVotes);
|
|
416
|
+
const featureRep = fieldForFeature(f, dkELECTION, "R" /* RepVotes */);
|
|
417
|
+
const featureTot = fieldForFeature(f, dkELECTION, "Tot" /* TotalVotes */);
|
|
412
418
|
demVotes += featureDem;
|
|
413
419
|
repVotes += featureRep;
|
|
414
420
|
totVotes += featureTot;
|
|
415
|
-
// demVotes += outerThis._session.features.fieldForFeature(f, T.Dataset.ELECTION, T.FeatureField.DemVotes);
|
|
416
|
-
// repVotes += outerThis._session.features.fieldForFeature(f, T.Dataset.ELECTION, T.FeatureField.RepVotes);
|
|
417
|
-
// totVotes += outerThis._session.features.fieldForFeature(f, T.Dataset.ELECTION, T.FeatureField.TotalVotes);
|
|
418
421
|
// NOTE: Unless you grab the values above before accumulating them,
|
|
419
422
|
// you can't accumulate othVotes for districts. You must calculate
|
|
420
423
|
// them by implication later.
|
|
@@ -424,13 +427,16 @@ class Districts {
|
|
|
424
427
|
console.log("Statistics: Inconsistent election data for precinct:", geoID, featureDem, featureRep, featureTot);
|
|
425
428
|
}
|
|
426
429
|
// Voting-age demographic breakdowns (or citizen voting-age)
|
|
427
|
-
|
|
428
|
-
|
|
429
|
-
|
|
430
|
-
|
|
431
|
-
|
|
432
|
-
|
|
433
|
-
|
|
430
|
+
// 03-27-21
|
|
431
|
+
const dkVAP = outerThis._session.features._keys["VAP" /* VAP */];
|
|
432
|
+
totalVAP += fieldForFeature(f, dkVAP, "Tot" /* TotalPop */);
|
|
433
|
+
// totalVAP += outerThis._session.features.fieldForFeature(f, T.Dataset.VAP, T.FeatureField.TotalPop);
|
|
434
|
+
whitePop += fieldForFeature(f, dkVAP, "Wh" /* WhitePop */);
|
|
435
|
+
blackPop += fieldForFeature(f, dkVAP, "BlC" /* BlackPop */);
|
|
436
|
+
hispanicPop += fieldForFeature(f, dkVAP, "His" /* HispanicPop */);
|
|
437
|
+
pacificPop += fieldForFeature(f, dkVAP, "PacC" /* PacificPop */);
|
|
438
|
+
asianPop += fieldForFeature(f, dkVAP, "AsnC" /* AsianPop */);
|
|
439
|
+
nativePop += fieldForFeature(f, dkVAP, "NatC" /* NativePop */);
|
|
434
440
|
}
|
|
435
441
|
}
|
|
436
442
|
else {
|
|
@@ -651,26 +657,31 @@ class Districts {
|
|
|
651
657
|
let f = outerThis._session.features.featureByIndex(featureID);
|
|
652
658
|
if (!(f == undefined)) {
|
|
653
659
|
// Calculate the Dem two-party vote
|
|
654
|
-
|
|
655
|
-
const
|
|
656
|
-
|
|
660
|
+
// 03-27-21
|
|
661
|
+
const dkELECTION = outerThis._session.features._keys["ELECTION" /* ELECTION */];
|
|
662
|
+
const featureDem = fieldForFeature(f, dkELECTION, "D" /* DemVotes */);
|
|
663
|
+
const featureRep = fieldForFeature(f, dkELECTION, "R" /* RepVotes */);
|
|
664
|
+
// const featureRep = outerThis._session.features.fieldForFeature(f, T.Dataset.ELECTION, T.FeatureField.RepVotes);
|
|
657
665
|
if ((featureDem + featureRep) > 0) {
|
|
658
666
|
const pctDem = featureDem / (featureDem + featureRep);
|
|
659
667
|
// Calculate the VAP/CVAP percentages by demographic
|
|
660
|
-
|
|
668
|
+
// 03-27-21
|
|
669
|
+
const dkVAP = outerThis._session.features._keys["VAP" /* VAP */];
|
|
670
|
+
const totalVAP = fieldForFeature(f, dkVAP, "Tot" /* TotalPop */);
|
|
671
|
+
// const totalVAP = outerThis._session.features.fieldForFeature(f, T.Dataset.VAP, T.FeatureField.TotalPop);
|
|
661
672
|
if (totalVAP > 0) {
|
|
662
673
|
// Gather all points, for debugging purposes ...
|
|
663
|
-
const hispanicVAP =
|
|
664
|
-
const blackVAP =
|
|
665
|
-
const pacificVAP =
|
|
666
|
-
const asianVAP =
|
|
667
|
-
const nativeVAP =
|
|
674
|
+
const hispanicVAP = fieldForFeature(f, dkVAP, "His" /* HispanicPop */);
|
|
675
|
+
const blackVAP = fieldForFeature(f, dkVAP, "BlC" /* BlackPop */);
|
|
676
|
+
const pacificVAP = fieldForFeature(f, dkVAP, "PacC" /* PacificPop */);
|
|
677
|
+
const asianVAP = fieldForFeature(f, dkVAP, "AsnC" /* AsianPop */);
|
|
678
|
+
const nativeVAP = fieldForFeature(f, dkVAP, "NatC" /* NativePop */);
|
|
668
679
|
const pctHispanic = hispanicVAP / totalVAP;
|
|
669
680
|
const pctBlack = blackVAP / totalVAP;
|
|
670
681
|
const pctPacific = pacificVAP / totalVAP;
|
|
671
682
|
const pctAsian = asianVAP / totalVAP;
|
|
672
683
|
const pctNative = nativeVAP / totalVAP;
|
|
673
|
-
const whiteVAP =
|
|
684
|
+
const whiteVAP = fieldForFeature(f, dkVAP, "Wh" /* WhitePop */);
|
|
674
685
|
const minorityVAP = totalVAP - whiteVAP;
|
|
675
686
|
const pctMinority = minorityVAP / totalVAP;
|
|
676
687
|
let pctComparison = whiteVAP / totalVAP;
|
|
@@ -754,6 +765,22 @@ class Districts {
|
|
|
754
765
|
}
|
|
755
766
|
}
|
|
756
767
|
exports.Districts = Districts;
|
|
768
|
+
function inferSelectedMinority(groups) {
|
|
769
|
+
if (groups.hispanic)
|
|
770
|
+
return 'Hispanic';
|
|
771
|
+
if (groups.black)
|
|
772
|
+
return 'Black';
|
|
773
|
+
if (groups.pacific)
|
|
774
|
+
return 'Pacific';
|
|
775
|
+
if (groups.asian)
|
|
776
|
+
return 'Asian';
|
|
777
|
+
if (groups.native)
|
|
778
|
+
return 'Native';
|
|
779
|
+
if (groups.minority)
|
|
780
|
+
return 'Minority';
|
|
781
|
+
return 'No minority selected!';
|
|
782
|
+
}
|
|
783
|
+
exports.inferSelectedMinority = inferSelectedMinority;
|
|
757
784
|
// CLASSES, ETC. FOR FEATURE & COUNTY DATA
|
|
758
785
|
// Wrap data by feature, to abstract the specifics of the internal structure
|
|
759
786
|
class Features {
|
|
@@ -765,49 +792,61 @@ class Features {
|
|
|
765
792
|
}
|
|
766
793
|
nFeatures() { return this._data.features.length; }
|
|
767
794
|
featureByIndex(i) { return this._data.features[i]; }
|
|
768
|
-
|
|
769
|
-
|
|
770
|
-
|
|
771
|
-
|
|
772
|
-
|
|
773
|
-
|
|
774
|
-
|
|
775
|
-
|
|
776
|
-
|
|
777
|
-
|
|
778
|
-
|
|
779
|
-
|
|
780
|
-
|
|
781
|
-
|
|
782
|
-
|
|
783
|
-
|
|
784
|
-
|
|
785
|
-
|
|
786
|
-
|
|
787
|
-
|
|
788
|
-
|
|
789
|
-
|
|
790
|
-
|
|
791
|
-
|
|
792
|
-
|
|
793
|
-
|
|
794
|
-
|
|
795
|
-
|
|
796
|
-
|
|
797
|
-
|
|
798
|
-
|
|
799
|
-
|
|
800
|
-
|
|
801
|
-
|
|
802
|
-
|
|
803
|
-
|
|
804
|
-
|
|
805
|
-
|
|
795
|
+
/* 03/27/21 - Moved to top-level & exported:
|
|
796
|
+
geoIDForFeature(f: any): string
|
|
797
|
+
{
|
|
798
|
+
// 12-02-2020 - Switched to using ids vs. geoids per Terry
|
|
799
|
+
if (f.properties && f.properties['id'])
|
|
800
|
+
{
|
|
801
|
+
return f.properties['id'];
|
|
802
|
+
// GEOIDs will be one of these properties
|
|
803
|
+
// const value = f.properties['GEOID10'] || f.properties['GEOID20'] || f.properties['GEOID'];
|
|
804
|
+
|
|
805
|
+
// return value;
|
|
806
|
+
}
|
|
807
|
+
else
|
|
808
|
+
{
|
|
809
|
+
console.log("This feature does not have an id property:", f);
|
|
810
|
+
throw "Feature with no id property.";
|
|
811
|
+
}
|
|
812
|
+
}
|
|
813
|
+
fieldForFeature(f: any, dt: T.Dataset, fk: string): any
|
|
814
|
+
{
|
|
815
|
+
const dk: string = this._keys[dt];
|
|
816
|
+
|
|
817
|
+
let result = undefined;
|
|
818
|
+
|
|
819
|
+
// 07-31-2020 - Fix to post-process PVI into the expected election composite format.
|
|
820
|
+
if (dk === 'P16GPR')
|
|
821
|
+
{
|
|
822
|
+
// 10-27-2020 - Enabling a 'Tot' result for PVI, now that we're reporting 'Other'
|
|
823
|
+
switch (fk)
|
|
824
|
+
{
|
|
825
|
+
case 'D': {
|
|
826
|
+
result = (_getFeatures(f, dk, 'D12') + _getFeatures(f, dk, 'D16')) / 2;
|
|
827
|
+
break;
|
|
828
|
+
}
|
|
829
|
+
case 'R': {
|
|
830
|
+
result = (_getFeatures(f, dk, 'R12') + _getFeatures(f, dk, 'R16')) / 2;
|
|
831
|
+
break;
|
|
832
|
+
}
|
|
833
|
+
case 'Tot': {
|
|
834
|
+
result = (_getFeatures(f, dk, 'D12') + _getFeatures(f, dk, 'D16') + _getFeatures(f, dk, 'R12') + _getFeatures(f, dk, 'R16')) / 2;
|
|
835
|
+
break;
|
|
836
|
+
}
|
|
837
|
+
default: {
|
|
838
|
+
console.log("Field not recognized.");
|
|
839
|
+
break;
|
|
840
|
+
}
|
|
806
841
|
}
|
|
807
|
-
|
|
808
|
-
|
|
809
|
-
|
|
842
|
+
// result = (_getFeatures(f, dk, (fk === 'D' ? 'D12' : 'R12')) + _getFeatures(f, dk, (fk === 'D' ? 'D16' : 'R16'))) / 2;
|
|
843
|
+
}
|
|
844
|
+
else
|
|
845
|
+
result = _getFeatures(f, dk, fk);
|
|
846
|
+
|
|
847
|
+
return result;
|
|
810
848
|
}
|
|
849
|
+
*/
|
|
811
850
|
resetDataset(d, k) {
|
|
812
851
|
this._keys[d] = k;
|
|
813
852
|
// NOTE - RECALC: Does anything need to be recalc'd now when a dataset is changed?
|
|
@@ -815,29 +854,60 @@ class Features {
|
|
|
815
854
|
mapGeoIDsToFeatureIDs() {
|
|
816
855
|
for (let i = 0; i < this._session.features.nFeatures(); i++) {
|
|
817
856
|
let f = this._session.features.featureByIndex(i);
|
|
818
|
-
|
|
857
|
+
// 03-27-21
|
|
858
|
+
let geoID = geoIDForFeature(f);
|
|
859
|
+
// let geoID: string = this._session.features.geoIDForFeature(f);
|
|
819
860
|
this._featureIDs[geoID] = i;
|
|
820
861
|
}
|
|
821
862
|
}
|
|
822
863
|
featureID(i) { return this._featureIDs[i]; }
|
|
823
864
|
}
|
|
824
865
|
exports.Features = Features;
|
|
825
|
-
function
|
|
826
|
-
|
|
827
|
-
|
|
828
|
-
|
|
829
|
-
|
|
830
|
-
|
|
831
|
-
return
|
|
832
|
-
|
|
833
|
-
|
|
834
|
-
|
|
835
|
-
|
|
836
|
-
|
|
837
|
-
|
|
838
|
-
|
|
866
|
+
function geoIDForFeature(f) {
|
|
867
|
+
// 12-02-2020 - Switched to using ids vs. geoids per Terry
|
|
868
|
+
if (f.properties && f.properties['id']) {
|
|
869
|
+
return f.properties['id'];
|
|
870
|
+
// GEOIDs will be one of these properties
|
|
871
|
+
// const value = f.properties['GEOID10'] || f.properties['GEOID20'] || f.properties['GEOID'];
|
|
872
|
+
// return value;
|
|
873
|
+
}
|
|
874
|
+
else {
|
|
875
|
+
console.log("This feature does not have an id property:", f);
|
|
876
|
+
throw "Feature with no id property.";
|
|
877
|
+
}
|
|
878
|
+
}
|
|
879
|
+
exports.geoIDForFeature = geoIDForFeature;
|
|
880
|
+
function fieldForFeature(f, dk /* dt: T.Dataset */, fk) {
|
|
881
|
+
// const dk: string = this._keys[dt];
|
|
882
|
+
let result = undefined;
|
|
883
|
+
// 07-31-2020 - Fix to post-process PVI into the expected election composite format.
|
|
884
|
+
if (dk === 'P16GPR') {
|
|
885
|
+
// 10-27-2020 - Enabling a 'Tot' result for PVI, now that we're reporting 'Other'
|
|
886
|
+
switch (fk) {
|
|
887
|
+
case 'D': {
|
|
888
|
+
result = (_getFeatures(f, dk, 'D12') + _getFeatures(f, dk, 'D16')) / 2;
|
|
889
|
+
break;
|
|
890
|
+
}
|
|
891
|
+
case 'R': {
|
|
892
|
+
result = (_getFeatures(f, dk, 'R12') + _getFeatures(f, dk, 'R16')) / 2;
|
|
893
|
+
break;
|
|
894
|
+
}
|
|
895
|
+
case 'Tot': {
|
|
896
|
+
result = (_getFeatures(f, dk, 'D12') + _getFeatures(f, dk, 'D16') + _getFeatures(f, dk, 'R12') + _getFeatures(f, dk, 'R16')) / 2;
|
|
897
|
+
break;
|
|
898
|
+
}
|
|
899
|
+
default: {
|
|
900
|
+
console.log("Field not recognized.");
|
|
901
|
+
break;
|
|
902
|
+
}
|
|
903
|
+
}
|
|
904
|
+
// result = (_getFeatures(f, dk, (fk === 'D' ? 'D12' : 'R12')) + _getFeatures(f, dk, (fk === 'D' ? 'D16' : 'R16'))) / 2;
|
|
905
|
+
}
|
|
906
|
+
else
|
|
907
|
+
result = _getFeatures(f, dk, fk);
|
|
908
|
+
return result;
|
|
839
909
|
}
|
|
840
|
-
exports.
|
|
910
|
+
exports.fieldForFeature = fieldForFeature;
|
|
841
911
|
// NOTE - This accessor is cloned from fGetW() in dra-client/restrict.ts
|
|
842
912
|
// f is a direct GeoJSON feature
|
|
843
913
|
// p is a geoID
|
|
@@ -891,6 +961,7 @@ class Counties {
|
|
|
891
961
|
constructor(s, data) {
|
|
892
962
|
this._countyNameLookup = {};
|
|
893
963
|
this.index = {};
|
|
964
|
+
this.fips = {};
|
|
894
965
|
this.totalPopulation = [];
|
|
895
966
|
this._session = s;
|
|
896
967
|
this._data = data;
|
|
@@ -965,7 +1036,9 @@ function invertPlan(plan, s, bLog = false) {
|
|
|
965
1036
|
if (!(s == undefined)) {
|
|
966
1037
|
for (let i = 0; i < s.features.nFeatures(); i++) {
|
|
967
1038
|
let f = s.features.featureByIndex(i);
|
|
968
|
-
|
|
1039
|
+
// 03-27-21
|
|
1040
|
+
let geoID = geoIDForFeature(f);
|
|
1041
|
+
// let geoID: string = s.features.geoIDForFeature(f);
|
|
969
1042
|
// If the feature is NOT explicitly assigned to a district, add the geoID
|
|
970
1043
|
// to the dummy unassigned district 0.
|
|
971
1044
|
if (!(U.keyExists(geoID, plan)))
|
|
@@ -1175,6 +1248,8 @@ function doFindCountiesSplitUnexpectedly(s, bLog = false) {
|
|
|
1175
1248
|
let nPartitionsOverall = 0;
|
|
1176
1249
|
let splitCounties = new Set(); // The counties that are split across districts
|
|
1177
1250
|
let totalAffected = 0; // The total population affected by those splits
|
|
1251
|
+
// 07-17-21 - For enumerating # of times each split county is split
|
|
1252
|
+
let countyIndexesWithSplits = [];
|
|
1178
1253
|
// Ignore the dummy unassigned 0 "county."
|
|
1179
1254
|
for (let c = 1; c <= s.counties.nCounties; c++) {
|
|
1180
1255
|
let nCountyParts = 0;
|
|
@@ -1195,8 +1270,30 @@ function doFindCountiesSplitUnexpectedly(s, bLog = false) {
|
|
|
1195
1270
|
if (nCountyParts > 1) {
|
|
1196
1271
|
splitCounties.add(c);
|
|
1197
1272
|
totalAffected += subtotal;
|
|
1273
|
+
// 07-17-21 - Enumerate # of times each split county is split
|
|
1274
|
+
countyIndexesWithSplits.push([c, nCountyParts - 1]);
|
|
1198
1275
|
}
|
|
1199
1276
|
}
|
|
1277
|
+
// 07-17-21 - Enumerate # of times each split county is split
|
|
1278
|
+
let splitCountiesWithSplits = [];
|
|
1279
|
+
countyIndexesWithSplits.forEach(pair => {
|
|
1280
|
+
const index = pair[0];
|
|
1281
|
+
const splits = pair[1];
|
|
1282
|
+
// Convert 1–N indices to FIPS codes
|
|
1283
|
+
const fips = s.counties.fips[index];
|
|
1284
|
+
if (fips) {
|
|
1285
|
+
// Convert FIPS codes to names
|
|
1286
|
+
const name = s.counties.nameFromFIPS(fips);
|
|
1287
|
+
// Combine # of splits with names
|
|
1288
|
+
if (name) {
|
|
1289
|
+
const text = `${name} (${splits})`;
|
|
1290
|
+
splitCountiesWithSplits.push(text);
|
|
1291
|
+
}
|
|
1292
|
+
}
|
|
1293
|
+
});
|
|
1294
|
+
// Sort by name
|
|
1295
|
+
splitCountiesWithSplits.sort();
|
|
1296
|
+
// End
|
|
1200
1297
|
// Convert county ordinals to FIPS codes
|
|
1201
1298
|
let splitCountiesFIPS = U.getSelectObjectKeys(s.counties.index, [...splitCounties]);
|
|
1202
1299
|
// THEN TAKE ACCOUNT OF THE COUNTY SPLITTING THAT IS EXPECTED (REQUIRED)
|
|
@@ -1243,6 +1340,8 @@ function doFindCountiesSplitUnexpectedly(s, bLog = false) {
|
|
|
1243
1340
|
test['details']['singleCountyDistrictMax'] = s.state.singleCountyDistrictMax;
|
|
1244
1341
|
test['details']['nCountiesSplit'] = splitCountiesFIPS.length;
|
|
1245
1342
|
test['details']['nSingleCountyDistricts'] = singleCountyDistricts.length;
|
|
1343
|
+
// 07-17-21 - Enumerate # of times each split county is split
|
|
1344
|
+
test['details']['countiesWithSplits'] = splitCountiesWithSplits;
|
|
1246
1345
|
return test;
|
|
1247
1346
|
}
|
|
1248
1347
|
exports.doFindCountiesSplitUnexpectedly = doFindCountiesSplitUnexpectedly;
|
|
@@ -1445,12 +1544,15 @@ var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
|
1445
1544
|
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
|
|
1446
1545
|
};
|
|
1447
1546
|
Object.defineProperty(exports, "__esModule", ({ value: true }));
|
|
1448
|
-
exports.inferSelectedMinority = void 0;
|
|
1547
|
+
exports.inferSelectedMinority = exports.fieldForFeature = exports.geoIDForFeature = void 0;
|
|
1449
1548
|
__exportStar(__webpack_require__(/*! ./_api */ "./src/_api.ts"), exports);
|
|
1450
|
-
__exportStar(__webpack_require__(/*! ./results */ "./src/results.ts"), exports);
|
|
1451
|
-
__exportStar(__webpack_require__(/*! ./types */ "./src/types.ts"), exports);
|
|
1452
1549
|
var _data_1 = __webpack_require__(/*! ./_data */ "./src/_data.ts");
|
|
1550
|
+
Object.defineProperty(exports, "geoIDForFeature", ({ enumerable: true, get: function () { return _data_1.geoIDForFeature; } }));
|
|
1551
|
+
Object.defineProperty(exports, "fieldForFeature", ({ enumerable: true, get: function () { return _data_1.fieldForFeature; } }));
|
|
1453
1552
|
Object.defineProperty(exports, "inferSelectedMinority", ({ enumerable: true, get: function () { return _data_1.inferSelectedMinority; } }));
|
|
1553
|
+
__exportStar(__webpack_require__(/*! ./results */ "./src/results.ts"), exports);
|
|
1554
|
+
__exportStar(__webpack_require__(/*! ./types */ "./src/types.ts"), exports);
|
|
1555
|
+
__exportStar(__webpack_require__(/*! ./utils */ "./src/utils.ts"), exports);
|
|
1454
1556
|
|
|
1455
1557
|
|
|
1456
1558
|
/***/ }),
|
|
@@ -1586,6 +1688,7 @@ var __importStar = (this && this.__importStar) || function (mod) {
|
|
|
1586
1688
|
Object.defineProperty(exports, "__esModule", ({ value: true }));
|
|
1587
1689
|
exports.doPreprocessData = void 0;
|
|
1588
1690
|
const U = __importStar(__webpack_require__(/*! ./utils */ "./src/utils.ts"));
|
|
1691
|
+
const D = __importStar(__webpack_require__(/*! ./_data */ "./src/_data.ts"));
|
|
1589
1692
|
// NOTE - Do preprocessing separately, so the constructor returns quickly.
|
|
1590
1693
|
function doPreprocessData(s, bLog = false) {
|
|
1591
1694
|
// If necessary, do one-time preprocessing
|
|
@@ -1621,6 +1724,8 @@ function doPreprocessCountyFeatures(s, bLog = false) {
|
|
|
1621
1724
|
// Create the ID-ordinal map
|
|
1622
1725
|
for (let i in fipsCodes) {
|
|
1623
1726
|
s.counties.index[fipsCodes[i]] = Number(i);
|
|
1727
|
+
// 07-17-21 - For enumerating # of times each split county is split
|
|
1728
|
+
s.counties.fips[Number(i)] = fipsCodes[i];
|
|
1624
1729
|
}
|
|
1625
1730
|
}
|
|
1626
1731
|
// ANALYZE THE CENSUS BY COUNTY
|
|
@@ -1633,10 +1738,15 @@ function doPreprocessCensus(s, bLog = false) {
|
|
|
1633
1738
|
// NOTE - This works w/o GEOIDs, because you're looping over all features.
|
|
1634
1739
|
for (let i = 0; i < s.features.nFeatures(); i++) {
|
|
1635
1740
|
let f = s.features.featureByIndex(i);
|
|
1636
|
-
|
|
1741
|
+
// 03-27-21
|
|
1742
|
+
let geoID = D.geoIDForFeature(f);
|
|
1743
|
+
// let geoID: string = s.features.geoIDForFeature(f);
|
|
1637
1744
|
// Skip water-only features
|
|
1638
1745
|
if (!(U.isWaterOnly(geoID))) {
|
|
1639
|
-
|
|
1746
|
+
// 03-27-21
|
|
1747
|
+
const dk = s.features._keys["CENSUS" /* CENSUS */];
|
|
1748
|
+
let value = D.fieldForFeature(f, dk, "Tot" /* TotalPop */);
|
|
1749
|
+
// let value: number = s.features.fieldForFeature(f, T.Dataset.CENSUS, T.FeatureField.TotalPop);
|
|
1640
1750
|
// Sum total population across the state
|
|
1641
1751
|
s.state.totalPop += value;
|
|
1642
1752
|
// Get the county FIPS code for the feature
|
|
@@ -2210,6 +2320,7 @@ var __importStar = (this && this.__importStar) || function (mod) {
|
|
|
2210
2320
|
Object.defineProperty(exports, "__esModule", ({ value: true }));
|
|
2211
2321
|
exports.depthof = exports.deepCopy = exports.shallowCopy = exports.countEnumValues = exports.objectContains = exports.arrayContains = exports.getSelectObjectKeys = exports.getNumericObjectKeys = exports.getObjectKeys = exports.isArrayEmpty = exports.isSetEmpty = exports.isObjectEmpty = exports.keyExists = exports.andArray = exports.initArray = exports.maxArray = exports.minArray = exports.avgArray = exports.sumArray = exports.trim = exports.isUninhabited = exports.isWaterOnly = exports.parseGeoID = exports.getDistrict = exports.isOutOfState = exports.isInState = void 0;
|
|
2212
2322
|
const DT = __importStar(__webpack_require__(/*! @dra2020/dra-types */ "@dra2020/dra-types"));
|
|
2323
|
+
const _data_1 = __webpack_require__(/*! ./_data */ "./src/_data.ts");
|
|
2213
2324
|
const S = __importStar(__webpack_require__(/*! ./settings */ "./src/settings.ts"));
|
|
2214
2325
|
// PLAN HELPERS
|
|
2215
2326
|
// Is a "neighbor" in state?
|
|
@@ -2274,7 +2385,10 @@ exports.isWaterOnly = isWaterOnly;
|
|
|
2274
2385
|
function isUninhabited(geoID, s) {
|
|
2275
2386
|
const featureID = s.features.featureID(geoID);
|
|
2276
2387
|
const f = s.features.featureByIndex(featureID);
|
|
2277
|
-
|
|
2388
|
+
// 03-27-21
|
|
2389
|
+
const dk = s.features._keys["CENSUS" /* CENSUS */];
|
|
2390
|
+
const totalPop = _data_1.fieldForFeature(f, dk, "Tot" /* TotalPop */);
|
|
2391
|
+
// const totalPop = s.features.fieldForFeature(f, T.Dataset.CENSUS, T.FeatureField.TotalPop);
|
|
2278
2392
|
let bUninhabited = (totalPop > 0) ? false : true;
|
|
2279
2393
|
// HACK for Kentucky's atypical data, so the official map shows as complete
|
|
2280
2394
|
const geoIDparts = parseGeoID(geoID);
|