@dra2020/district-analytics 11.5.0 → 12.0.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/README.md +1 -1
- package/dist/district-analytics.js +181 -95
- package/dist/district-analytics.js.map +1 -1
- package/dist/src/_data.d.ts +3 -3
- package/dist/src/index.d.ts +2 -1
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -15,7 +15,7 @@ let sr = {} as DA.SessionRequest;
|
|
|
15
15
|
sr['title'] = "NC 2016 Contingent Corrected Map";
|
|
16
16
|
sr['stateXX'] = "NC";
|
|
17
17
|
sr['nDistricts'] = 13;
|
|
18
|
-
sr['
|
|
18
|
+
sr['planType'] = PlanType.congress; // One or ...
|
|
19
19
|
sr['legislativeDistricts'] = false; // ... the other
|
|
20
20
|
sr['data'] = data as T.GeoFeatureCollection;
|
|
21
21
|
sr['counties'] = counties as T.GeoFeatureCollection;
|
|
@@ -65,7 +65,7 @@ class AnalyticsSession {
|
|
|
65
65
|
this.config = this.processConfig(SessionRequest['config']);
|
|
66
66
|
// 2020 - Set the CD / LD toggle:
|
|
67
67
|
// * If 2020, use the PlanType, if given.
|
|
68
|
-
// * If
|
|
68
|
+
// * If 2010, use the legacy LD toggle, if given.
|
|
69
69
|
// * Otherwise assume CD's.
|
|
70
70
|
// * Use the LD population deviation threshold for districts that are not CD's.
|
|
71
71
|
if ((this.config.cycle == 2020) && (SessionRequest['planType'] !== undefined))
|
|
@@ -86,9 +86,9 @@ class AnalyticsSession {
|
|
|
86
86
|
// DEBUG
|
|
87
87
|
console.log("Cycle was not set explicitly on the session request.");
|
|
88
88
|
}
|
|
89
|
-
// DEBUG
|
|
90
|
-
console.log("Cycle = ", config['cycle']);
|
|
91
|
-
console.log("Shapes = ", config['datasets'][
|
|
89
|
+
// DEBUG - Turned off 03/05/21
|
|
90
|
+
// console.log("Cycle = ", config['cycle']);
|
|
91
|
+
// console.log("Shapes = ", config['datasets'][T.Dataset.SHAPES], ": ", config['descriptions']['SHAPES']);
|
|
92
92
|
return config;
|
|
93
93
|
}
|
|
94
94
|
// Using the the data in the analytics session, calculate all the
|
|
@@ -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 {
|
|
@@ -497,8 +503,8 @@ class Districts {
|
|
|
497
503
|
const features = geoIDs;
|
|
498
504
|
const nakedGraph = graph._graph;
|
|
499
505
|
const nakedPlan = plan._planByGeoID;
|
|
500
|
-
bContiguous = G.isConnected(features, nakedGraph);
|
|
501
|
-
bNotEmbedded = (!G.isEmbedded(i, features, nakedPlan, nakedGraph));
|
|
506
|
+
bContiguous = G.isConnected(features, nakedGraph, bLog);
|
|
507
|
+
bNotEmbedded = (!G.isEmbedded(i, features, nakedPlan, nakedGraph, bLog));
|
|
502
508
|
}
|
|
503
509
|
{ // UPDATE THE DISTRICT STATISTICS
|
|
504
510
|
// NOTE - These are set below for both non-empty & empty districts:
|
|
@@ -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
|
|
@@ -965,7 +1035,9 @@ function invertPlan(plan, s, bLog = false) {
|
|
|
965
1035
|
if (!(s == undefined)) {
|
|
966
1036
|
for (let i = 0; i < s.features.nFeatures(); i++) {
|
|
967
1037
|
let f = s.features.featureByIndex(i);
|
|
968
|
-
|
|
1038
|
+
// 03-27-21
|
|
1039
|
+
let geoID = geoIDForFeature(f);
|
|
1040
|
+
// let geoID: string = s.features.geoIDForFeature(f);
|
|
969
1041
|
// If the feature is NOT explicitly assigned to a district, add the geoID
|
|
970
1042
|
// to the dummy unassigned district 0.
|
|
971
1043
|
if (!(U.keyExists(geoID, plan)))
|
|
@@ -1240,6 +1312,7 @@ function doFindCountiesSplitUnexpectedly(s, bLog = false) {
|
|
|
1240
1312
|
// 02-23-21 - Added single-county district details
|
|
1241
1313
|
test['details']['expectedSplits'] = s.state.expectedSplits;
|
|
1242
1314
|
test['details']['tooBigName'] = s.state.tooBigName;
|
|
1315
|
+
test['details']['singleCountyDistrictMax'] = s.state.singleCountyDistrictMax;
|
|
1243
1316
|
test['details']['nCountiesSplit'] = splitCountiesFIPS.length;
|
|
1244
1317
|
test['details']['nSingleCountyDistricts'] = singleCountyDistricts.length;
|
|
1245
1318
|
return test;
|
|
@@ -1444,12 +1517,15 @@ var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
|
1444
1517
|
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
|
|
1445
1518
|
};
|
|
1446
1519
|
Object.defineProperty(exports, "__esModule", ({ value: true }));
|
|
1447
|
-
exports.inferSelectedMinority = void 0;
|
|
1520
|
+
exports.inferSelectedMinority = exports.fieldForFeature = exports.geoIDForFeature = void 0;
|
|
1448
1521
|
__exportStar(__webpack_require__(/*! ./_api */ "./src/_api.ts"), exports);
|
|
1449
|
-
__exportStar(__webpack_require__(/*! ./results */ "./src/results.ts"), exports);
|
|
1450
|
-
__exportStar(__webpack_require__(/*! ./types */ "./src/types.ts"), exports);
|
|
1451
1522
|
var _data_1 = __webpack_require__(/*! ./_data */ "./src/_data.ts");
|
|
1523
|
+
Object.defineProperty(exports, "geoIDForFeature", ({ enumerable: true, get: function () { return _data_1.geoIDForFeature; } }));
|
|
1524
|
+
Object.defineProperty(exports, "fieldForFeature", ({ enumerable: true, get: function () { return _data_1.fieldForFeature; } }));
|
|
1452
1525
|
Object.defineProperty(exports, "inferSelectedMinority", ({ enumerable: true, get: function () { return _data_1.inferSelectedMinority; } }));
|
|
1526
|
+
__exportStar(__webpack_require__(/*! ./results */ "./src/results.ts"), exports);
|
|
1527
|
+
__exportStar(__webpack_require__(/*! ./types */ "./src/types.ts"), exports);
|
|
1528
|
+
__exportStar(__webpack_require__(/*! ./utils */ "./src/utils.ts"), exports);
|
|
1453
1529
|
|
|
1454
1530
|
|
|
1455
1531
|
/***/ }),
|
|
@@ -1585,6 +1661,7 @@ var __importStar = (this && this.__importStar) || function (mod) {
|
|
|
1585
1661
|
Object.defineProperty(exports, "__esModule", ({ value: true }));
|
|
1586
1662
|
exports.doPreprocessData = void 0;
|
|
1587
1663
|
const U = __importStar(__webpack_require__(/*! ./utils */ "./src/utils.ts"));
|
|
1664
|
+
const D = __importStar(__webpack_require__(/*! ./_data */ "./src/_data.ts"));
|
|
1588
1665
|
// NOTE - Do preprocessing separately, so the constructor returns quickly.
|
|
1589
1666
|
function doPreprocessData(s, bLog = false) {
|
|
1590
1667
|
// If necessary, do one-time preprocessing
|
|
@@ -1632,10 +1709,15 @@ function doPreprocessCensus(s, bLog = false) {
|
|
|
1632
1709
|
// NOTE - This works w/o GEOIDs, because you're looping over all features.
|
|
1633
1710
|
for (let i = 0; i < s.features.nFeatures(); i++) {
|
|
1634
1711
|
let f = s.features.featureByIndex(i);
|
|
1635
|
-
|
|
1712
|
+
// 03-27-21
|
|
1713
|
+
let geoID = D.geoIDForFeature(f);
|
|
1714
|
+
// let geoID: string = s.features.geoIDForFeature(f);
|
|
1636
1715
|
// Skip water-only features
|
|
1637
1716
|
if (!(U.isWaterOnly(geoID))) {
|
|
1638
|
-
|
|
1717
|
+
// 03-27-21
|
|
1718
|
+
const dk = s.features._keys["CENSUS" /* CENSUS */];
|
|
1719
|
+
let value = D.fieldForFeature(f, dk, "Tot" /* TotalPop */);
|
|
1720
|
+
// let value: number = s.features.fieldForFeature(f, T.Dataset.CENSUS, T.FeatureField.TotalPop);
|
|
1639
1721
|
// Sum total population across the state
|
|
1640
1722
|
s.state.totalPop += value;
|
|
1641
1723
|
// Get the county FIPS code for the feature
|
|
@@ -2209,6 +2291,7 @@ var __importStar = (this && this.__importStar) || function (mod) {
|
|
|
2209
2291
|
Object.defineProperty(exports, "__esModule", ({ value: true }));
|
|
2210
2292
|
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;
|
|
2211
2293
|
const DT = __importStar(__webpack_require__(/*! @dra2020/dra-types */ "@dra2020/dra-types"));
|
|
2294
|
+
const _data_1 = __webpack_require__(/*! ./_data */ "./src/_data.ts");
|
|
2212
2295
|
const S = __importStar(__webpack_require__(/*! ./settings */ "./src/settings.ts"));
|
|
2213
2296
|
// PLAN HELPERS
|
|
2214
2297
|
// Is a "neighbor" in state?
|
|
@@ -2273,7 +2356,10 @@ exports.isWaterOnly = isWaterOnly;
|
|
|
2273
2356
|
function isUninhabited(geoID, s) {
|
|
2274
2357
|
const featureID = s.features.featureID(geoID);
|
|
2275
2358
|
const f = s.features.featureByIndex(featureID);
|
|
2276
|
-
|
|
2359
|
+
// 03-27-21
|
|
2360
|
+
const dk = s.features._keys["CENSUS" /* CENSUS */];
|
|
2361
|
+
const totalPop = _data_1.fieldForFeature(f, dk, "Tot" /* TotalPop */);
|
|
2362
|
+
// const totalPop = s.features.fieldForFeature(f, T.Dataset.CENSUS, T.FeatureField.TotalPop);
|
|
2277
2363
|
let bUninhabited = (totalPop > 0) ? false : true;
|
|
2278
2364
|
// HACK for Kentucky's atypical data, so the official map shows as complete
|
|
2279
2365
|
const geoIDparts = parseGeoID(geoID);
|