@dra2020/district-analytics 17.0.1 → 17.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.
@@ -15,7 +15,7 @@ export type SessionRequest = {
15
15
  counties: GeoFeatureCollection;
16
16
  config: {};
17
17
  };
18
- export declare const enum Dataset {
18
+ export declare enum Dataset {
19
19
  SHAPES = "SHAPES",
20
20
  CENSUS = "CENSUS",
21
21
  VAP = "VAP",
@@ -27,6 +27,13 @@ export type DatasetKeys = {
27
27
  VAP: string;
28
28
  ELECTION: string;
29
29
  };
30
+ export declare const fieldMap: {
31
+ [key: string]: {
32
+ [key: string]: string;
33
+ };
34
+ };
35
+ export declare const multiFieldPairs: [string, string][];
36
+ export declare const multiFields: string[];
30
37
  export declare const enum FeatureField {
31
38
  TotalPop = 0,
32
39
  WhitePop = 1,
@@ -71,46 +78,24 @@ export type WeightedNeighbors = {
71
78
  [geoID: string]: number;
72
79
  };
73
80
  export type UnweightedNeighbors = string[];
74
- export type TestEntry = {
75
- score?: number | boolean;
76
- details: Dict;
77
- normalizedScore?: number;
78
- };
79
- export type DistrictWIP = {
80
- [districtID: number]: any;
81
- };
82
- export declare const enum Test {
83
- Complete = 0,
84
- Contiguous = 1,
85
- FreeOfHoles = 2,
86
- EqualPopulation = 3,// This is the legal/not legal assessment of the population
87
- PopulationDeviation = 4,// deviation % (when legal, less is still better).
88
- UnexpectedCountySplits = 5,
89
- VTDSplits = 6
90
- }
91
- export type TestEntries = {
92
- [test: number]: TestEntry;
93
- };
94
- export type DistrictProperties = {
95
- [districtID: number]: any;
96
- };
97
- export type DistrictShapeProperties = [number, number, number];
98
- export declare const enum DistrictShapeProperty {
99
- Area = 0,
100
- Diameter = 1,
101
- Perimeter = 2
102
- }
103
- export type GeoIDParts = {
104
- vfeature?: boolean;
105
- state: string;
106
- county: string;
107
- rest: string;
108
- };
109
- export type GeoIDTotal = {
110
- [geoID: string]: number;
111
- };
112
- export type Dict = {
113
- [key: string]: any;
81
+ export type RequirementsChecklist = {
82
+ score: boolean;
83
+ metrics: {
84
+ complete: boolean;
85
+ contiguous: boolean;
86
+ freeOfHoles: boolean;
87
+ equalPopulation: boolean;
88
+ };
89
+ details: {
90
+ unassignedFeatures: string[];
91
+ emptyDistricts: number[];
92
+ discontiguousDistricts: number[];
93
+ embeddedDistricts: number[];
94
+ populationDeviation: number;
95
+ deviationThreshold: number;
96
+ };
97
+ datasets: Datasets;
98
+ resources: {};
114
99
  };
115
100
  export type Datasets = {
116
101
  shapes?: string;
@@ -125,3 +110,63 @@ export type Ratings = {
125
110
  compactness: number;
126
111
  splitting: number;
127
112
  };
113
+ export declare enum StatisticsFields {
114
+ districtID = "districtID",
115
+ totalPop = "totalPop",
116
+ popDevPct = "popDevPct",
117
+ bEqualPop = "bEqualPop",
118
+ bNotEmpty = "bNotEmpty",
119
+ bContiguous = "bContiguous",
120
+ bNotEmbedded = "bNotEmbedded",
121
+ demPct = "demPct",
122
+ repPct = "repPct",
123
+ othPct = "othPct",
124
+ totalVAP = "totalVAP",
125
+ whitePct = "whitePct",
126
+ minorityPct = "minorityPct",
127
+ blackPct = "blackPct",
128
+ hispanicPct = "hispanicPct",
129
+ pacificPct = "pacificPct",
130
+ asianPct = "asianPct",
131
+ nativePct = "nativePct"
132
+ }
133
+ export type DistrictRow = {
134
+ districtID: number;
135
+ totalPop: number;
136
+ popDevPct: number;
137
+ bEqualPop: boolean;
138
+ bNotEmpty: boolean;
139
+ bContiguous: boolean;
140
+ bNotEmbedded: boolean;
141
+ demPct: number;
142
+ repPct: number;
143
+ othPct: number;
144
+ totalVAP: number;
145
+ whitePct: number;
146
+ minorityPct: number;
147
+ blackPct: number;
148
+ hispanicPct: number;
149
+ pacificPct: number;
150
+ asianPct: number;
151
+ nativePct: number;
152
+ };
153
+ export type DistrictStatistics = {
154
+ table: DistrictRow[];
155
+ details: {};
156
+ datasets: Datasets;
157
+ resources: {};
158
+ };
159
+ export type TestEntry = {
160
+ score?: number | boolean;
161
+ details: Dict;
162
+ normalizedScore?: number;
163
+ };
164
+ export type GeoIDParts = {
165
+ vfeature?: boolean;
166
+ state: string;
167
+ county: string;
168
+ rest: string;
169
+ };
170
+ export type Dict = {
171
+ [key: string]: any;
172
+ };
@@ -1,9 +1,8 @@
1
- import { AnalyticsSession } from './_api';
1
+ import * as D from './data';
2
2
  import * as T from './types';
3
- export declare function getDistrict(plan: T.PlanByGeoID, geoID: string): number | undefined;
4
3
  export declare function parseGeoID(geoID: string): T.GeoIDParts;
5
- export declare function isWaterOnly(geoID: string, s?: AnalyticsSession): boolean;
6
- export declare function isUninhabited(geoID: string, s: AnalyticsSession): boolean;
4
+ export declare function isWaterOnly(geoID: string, container?: D.SessionData): boolean;
5
+ export declare function isUninhabited(geoID: string, container: D.SessionData): boolean;
7
6
  export declare function trim(fullFraction: number, digits?: number | undefined): number;
8
7
  export declare function sumArray(arr: number[]): number;
9
8
  export declare function avgArray(arr: number[]): number;
@@ -11,6 +10,10 @@ export declare function minArray(arr: number[]): number;
11
10
  export declare function maxArray(arr: number[]): number;
12
11
  export declare function initArray(n: number, value: any): any[];
13
12
  export declare function andArray(arr: boolean[]): boolean;
13
+ export declare function addArrays(a: number[], b: number[]): number[];
14
+ export declare function subtractArrays(a: number[], b: number[]): number[];
15
+ export declare function divideArrays(numerator: number[], denominator: number[]): number[];
16
+ export declare function falseIndexes(booleans: boolean[]): number[];
14
17
  export declare function keyExists(k: string, o: object): boolean;
15
18
  export declare function isObjectEmpty(o: object): boolean;
16
19
  export declare function isSetEmpty(s: any): boolean;
@@ -20,7 +23,7 @@ export declare function getNumericObjectKeys(o: object): number[];
20
23
  export declare function getSelectObjectKeys(o: T.Dict, v: any[]): string[];
21
24
  export declare function arrayContains(a: any[], item: any): boolean;
22
25
  export declare function objectContains(o: object, key: any): boolean;
23
- export declare function countEnumValues(enumName: any): number;
24
26
  export declare function shallowCopy(src: any): any;
25
27
  export declare function deepCopy(src: any): any;
26
28
  export declare function depthof(a: any): number;
29
+ export declare function deepEqual(obj1: any, obj2: any, path?: string): boolean;
@@ -1,5 +0,0 @@
1
- import * as T from './types';
2
- import { AnalyticsSession } from './_api';
3
- export declare function doIsComplete(s: AnalyticsSession, bLog?: boolean): T.TestEntry;
4
- export declare function doIsContiguous(s: AnalyticsSession, bLog?: boolean): T.TestEntry;
5
- export declare function doIsFreeOfHoles(s: AnalyticsSession, bLog?: boolean): T.TestEntry;
package/dist/types.d.ts CHANGED
@@ -15,7 +15,7 @@ export type SessionRequest = {
15
15
  counties: GeoFeatureCollection;
16
16
  config: {};
17
17
  };
18
- export declare const enum Dataset {
18
+ export declare enum Dataset {
19
19
  SHAPES = "SHAPES",
20
20
  CENSUS = "CENSUS",
21
21
  VAP = "VAP",
@@ -27,6 +27,13 @@ export type DatasetKeys = {
27
27
  VAP: string;
28
28
  ELECTION: string;
29
29
  };
30
+ export declare const fieldMap: {
31
+ [key: string]: {
32
+ [key: string]: string;
33
+ };
34
+ };
35
+ export declare const multiFieldPairs: [string, string][];
36
+ export declare const multiFields: string[];
30
37
  export declare const enum FeatureField {
31
38
  TotalPop = 0,
32
39
  WhitePop = 1,
@@ -71,46 +78,24 @@ export type WeightedNeighbors = {
71
78
  [geoID: string]: number;
72
79
  };
73
80
  export type UnweightedNeighbors = string[];
74
- export type TestEntry = {
75
- score?: number | boolean;
76
- details: Dict;
77
- normalizedScore?: number;
78
- };
79
- export type DistrictWIP = {
80
- [districtID: number]: any;
81
- };
82
- export declare const enum Test {
83
- Complete = 0,
84
- Contiguous = 1,
85
- FreeOfHoles = 2,
86
- EqualPopulation = 3,// This is the legal/not legal assessment of the population
87
- PopulationDeviation = 4,// deviation % (when legal, less is still better).
88
- UnexpectedCountySplits = 5,
89
- VTDSplits = 6
90
- }
91
- export type TestEntries = {
92
- [test: number]: TestEntry;
93
- };
94
- export type DistrictProperties = {
95
- [districtID: number]: any;
96
- };
97
- export type DistrictShapeProperties = [number, number, number];
98
- export declare const enum DistrictShapeProperty {
99
- Area = 0,
100
- Diameter = 1,
101
- Perimeter = 2
102
- }
103
- export type GeoIDParts = {
104
- vfeature?: boolean;
105
- state: string;
106
- county: string;
107
- rest: string;
108
- };
109
- export type GeoIDTotal = {
110
- [geoID: string]: number;
111
- };
112
- export type Dict = {
113
- [key: string]: any;
81
+ export type RequirementsChecklist = {
82
+ score: boolean;
83
+ metrics: {
84
+ complete: boolean;
85
+ contiguous: boolean;
86
+ freeOfHoles: boolean;
87
+ equalPopulation: boolean;
88
+ };
89
+ details: {
90
+ unassignedFeatures: string[];
91
+ emptyDistricts: number[];
92
+ discontiguousDistricts: number[];
93
+ embeddedDistricts: number[];
94
+ populationDeviation: number;
95
+ deviationThreshold: number;
96
+ };
97
+ datasets: Datasets;
98
+ resources: {};
114
99
  };
115
100
  export type Datasets = {
116
101
  shapes?: string;
@@ -125,3 +110,63 @@ export type Ratings = {
125
110
  compactness: number;
126
111
  splitting: number;
127
112
  };
113
+ export declare enum StatisticsFields {
114
+ districtID = "districtID",
115
+ totalPop = "totalPop",
116
+ popDevPct = "popDevPct",
117
+ bEqualPop = "bEqualPop",
118
+ bNotEmpty = "bNotEmpty",
119
+ bContiguous = "bContiguous",
120
+ bNotEmbedded = "bNotEmbedded",
121
+ demPct = "demPct",
122
+ repPct = "repPct",
123
+ othPct = "othPct",
124
+ totalVAP = "totalVAP",
125
+ whitePct = "whitePct",
126
+ minorityPct = "minorityPct",
127
+ blackPct = "blackPct",
128
+ hispanicPct = "hispanicPct",
129
+ pacificPct = "pacificPct",
130
+ asianPct = "asianPct",
131
+ nativePct = "nativePct"
132
+ }
133
+ export type DistrictRow = {
134
+ districtID: number;
135
+ totalPop: number;
136
+ popDevPct: number;
137
+ bEqualPop: boolean;
138
+ bNotEmpty: boolean;
139
+ bContiguous: boolean;
140
+ bNotEmbedded: boolean;
141
+ demPct: number;
142
+ repPct: number;
143
+ othPct: number;
144
+ totalVAP: number;
145
+ whitePct: number;
146
+ minorityPct: number;
147
+ blackPct: number;
148
+ hispanicPct: number;
149
+ pacificPct: number;
150
+ asianPct: number;
151
+ nativePct: number;
152
+ };
153
+ export type DistrictStatistics = {
154
+ table: DistrictRow[];
155
+ details: {};
156
+ datasets: Datasets;
157
+ resources: {};
158
+ };
159
+ export type TestEntry = {
160
+ score?: number | boolean;
161
+ details: Dict;
162
+ normalizedScore?: number;
163
+ };
164
+ export type GeoIDParts = {
165
+ vfeature?: boolean;
166
+ state: string;
167
+ county: string;
168
+ rest: string;
169
+ };
170
+ export type Dict = {
171
+ [key: string]: any;
172
+ };
package/dist/utils.d.ts CHANGED
@@ -1,9 +1,8 @@
1
- import { AnalyticsSession } from './_api';
1
+ import * as D from './data';
2
2
  import * as T from './types';
3
- export declare function getDistrict(plan: T.PlanByGeoID, geoID: string): number | undefined;
4
3
  export declare function parseGeoID(geoID: string): T.GeoIDParts;
5
- export declare function isWaterOnly(geoID: string, s?: AnalyticsSession): boolean;
6
- export declare function isUninhabited(geoID: string, s: AnalyticsSession): boolean;
4
+ export declare function isWaterOnly(geoID: string, container?: D.SessionData): boolean;
5
+ export declare function isUninhabited(geoID: string, container: D.SessionData): boolean;
7
6
  export declare function trim(fullFraction: number, digits?: number | undefined): number;
8
7
  export declare function sumArray(arr: number[]): number;
9
8
  export declare function avgArray(arr: number[]): number;
@@ -11,6 +10,10 @@ export declare function minArray(arr: number[]): number;
11
10
  export declare function maxArray(arr: number[]): number;
12
11
  export declare function initArray(n: number, value: any): any[];
13
12
  export declare function andArray(arr: boolean[]): boolean;
13
+ export declare function addArrays(a: number[], b: number[]): number[];
14
+ export declare function subtractArrays(a: number[], b: number[]): number[];
15
+ export declare function divideArrays(numerator: number[], denominator: number[]): number[];
16
+ export declare function falseIndexes(booleans: boolean[]): number[];
14
17
  export declare function keyExists(k: string, o: object): boolean;
15
18
  export declare function isObjectEmpty(o: object): boolean;
16
19
  export declare function isSetEmpty(s: any): boolean;
@@ -20,7 +23,7 @@ export declare function getNumericObjectKeys(o: object): number[];
20
23
  export declare function getSelectObjectKeys(o: T.Dict, v: any[]): string[];
21
24
  export declare function arrayContains(a: any[], item: any): boolean;
22
25
  export declare function objectContains(o: object, key: any): boolean;
23
- export declare function countEnumValues(enumName: any): number;
24
26
  export declare function shallowCopy(src: any): any;
25
27
  export declare function deepCopy(src: any): any;
26
28
  export declare function depthof(a: any): number;
29
+ export declare function deepEqual(obj1: any, obj2: any, path?: string): boolean;
package/dist/valid.d.ts CHANGED
@@ -1,5 +0,0 @@
1
- import * as T from './types';
2
- import { AnalyticsSession } from './_api';
3
- export declare function doIsComplete(s: AnalyticsSession, bLog?: boolean): T.TestEntry;
4
- export declare function doIsContiguous(s: AnalyticsSession, bLog?: boolean): T.TestEntry;
5
- export declare function doIsFreeOfHoles(s: AnalyticsSession, bLog?: boolean): T.TestEntry;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@dra2020/district-analytics",
3
- "version": "17.0.1",
3
+ "version": "17.1.0",
4
4
  "description": "District analytics TypeScript package",
5
5
  "main": "dist/district-analytics.js",
6
6
  "files": [
@@ -48,8 +48,8 @@
48
48
  },
49
49
  "dependencies": {
50
50
  "@dra2020/baseclient": "^1.0.166",
51
- "@dra2020/dra-analytics": "^4.1.8",
51
+ "@dra2020/dra-analytics": "^5.0.0",
52
52
  "@dra2020/dra-types": "^1.8.149",
53
53
  "geojson": "^0.5.0"
54
54
  }
55
- }
55
+ }