@dra2020/district-analytics 8.1.1 → 8.2.1
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 +191997 -13940
- package/dist/cli.js.map +1 -1
- package/dist/district-analytics.js +28 -1
- package/dist/district-analytics.js.map +1 -1
- package/dist/src/_data.d.ts +1 -0
- package/dist/src/compact.d.ts +1 -0
- package/package.json +9 -8
|
@@ -380,6 +380,9 @@ class Districts {
|
|
|
380
380
|
this._shapes = ds;
|
|
381
381
|
this.statistics = this.initStatistics();
|
|
382
382
|
}
|
|
383
|
+
getDistrictShapes() {
|
|
384
|
+
return this._shapes;
|
|
385
|
+
}
|
|
383
386
|
getDistrictShapeByID(id) {
|
|
384
387
|
// NOTE - Find the district shape by ID (not index)
|
|
385
388
|
// return this._shapes.features[id];
|
|
@@ -1186,8 +1189,9 @@ var __importStar = (this && this.__importStar) || function (mod) {
|
|
|
1186
1189
|
return result;
|
|
1187
1190
|
};
|
|
1188
1191
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
1189
|
-
// NOTE - This file will NOT be empty, when legacy code is deleted.
|
|
1190
1192
|
const Poly = __importStar(__webpack_require__(/*! @dra2020/poly */ "@dra2020/poly"));
|
|
1193
|
+
const Compactness = __importStar(__webpack_require__(/*! @dra2020/compactness */ "@dra2020/compactness"));
|
|
1194
|
+
const U = __importStar(__webpack_require__(/*! ./utils */ "./src/utils.ts"));
|
|
1191
1195
|
// HELPER TO EXTRACT PROPERTIES OF DISTRICT SHAPES
|
|
1192
1196
|
// TODO - Create an array, as opposed to a dict
|
|
1193
1197
|
function extractDistrictProperties(s, bLog = false) {
|
|
@@ -1212,6 +1216,14 @@ function extractDistrictProperties(s, bLog = false) {
|
|
|
1212
1216
|
}
|
|
1213
1217
|
}
|
|
1214
1218
|
exports.extractDistrictProperties = extractDistrictProperties;
|
|
1219
|
+
// SCORE KIWYSI COMPACTNESS
|
|
1220
|
+
function scoreKIWYSICompactness(s, bLog = false) {
|
|
1221
|
+
const shapes = s.districts.getDistrictShapes();
|
|
1222
|
+
const scores = Compactness.scoreShapes(shapes);
|
|
1223
|
+
const avgKIWYSIScore = U.avgArray(scores);
|
|
1224
|
+
return avgKIWYSIScore;
|
|
1225
|
+
}
|
|
1226
|
+
exports.scoreKIWYSICompactness = scoreKIWYSICompactness;
|
|
1215
1227
|
// SAVE THESE NOTES, IN CASE WE NEED TO REWORK HOW WE PERFORM THESE CALCS.
|
|
1216
1228
|
// THEY REFLECT HOW I DID THEM IN PYTHON.
|
|
1217
1229
|
//
|
|
@@ -1820,6 +1832,7 @@ const Score = __importStar(__webpack_require__(/*! @dra2020/dra-score */ "@dra20
|
|
|
1820
1832
|
const U = __importStar(__webpack_require__(/*! ./utils */ "./src/utils.ts"));
|
|
1821
1833
|
const D = __importStar(__webpack_require__(/*! ./_data */ "./src/_data.ts"));
|
|
1822
1834
|
const M = __importStar(__webpack_require__(/*! ./minority */ "./src/minority.ts"));
|
|
1835
|
+
const C = __importStar(__webpack_require__(/*! ./compact */ "./src/compact.ts"));
|
|
1823
1836
|
// PROFILE A PLAN
|
|
1824
1837
|
function profilePlan(s, bLog = false) {
|
|
1825
1838
|
const state = s.state.xx;
|
|
@@ -1944,6 +1957,9 @@ function scorePlan(s, p, bLog = false, overridesJSON) {
|
|
|
1944
1957
|
// Add minority notes
|
|
1945
1958
|
scorecard.minority.details['majorityMinority'] = M.getMajorityMinority(s);
|
|
1946
1959
|
scorecard.minority.details['vraPreclearance'] = M.getVRASection5(s);
|
|
1960
|
+
// Add KIWYSI compactness score
|
|
1961
|
+
const kiwysiScore = C.scoreKIWYSICompactness(s, bLog);
|
|
1962
|
+
scorecard.compactness.details['kiwysi'] = kiwysiScore;
|
|
1947
1963
|
return scorecard;
|
|
1948
1964
|
}
|
|
1949
1965
|
exports.scorePlan = scorePlan;
|
|
@@ -2568,6 +2584,17 @@ module.exports = JSON.parse("{\"AL\":\"all\",\"AK\":\"all\",\"AZ\":\"all\",\"CA\
|
|
|
2568
2584
|
|
|
2569
2585
|
/***/ }),
|
|
2570
2586
|
|
|
2587
|
+
/***/ "@dra2020/compactness":
|
|
2588
|
+
/*!***************************************!*\
|
|
2589
|
+
!*** external "@dra2020/compactness" ***!
|
|
2590
|
+
\***************************************/
|
|
2591
|
+
/*! no static exports found */
|
|
2592
|
+
/***/ (function(module, exports) {
|
|
2593
|
+
|
|
2594
|
+
module.exports = require("@dra2020/compactness");
|
|
2595
|
+
|
|
2596
|
+
/***/ }),
|
|
2597
|
+
|
|
2571
2598
|
/***/ "@dra2020/dra-score":
|
|
2572
2599
|
/*!*************************************!*\
|
|
2573
2600
|
!*** external "@dra2020/dra-score" ***!
|