@dra2020/district-analytics 11.1.3 → 11.2.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.
@@ -43,7 +43,7 @@ var __importStar = (this && this.__importStar) || function (mod) {
43
43
  };
44
44
  Object.defineProperty(exports, "__esModule", ({ value: true }));
45
45
  exports.AnalyticsSession = void 0;
46
- const Poly = __importStar(__webpack_require__(/*! @dra2020/poly */ "@dra2020/poly"));
46
+ const baseclient_1 = __webpack_require__(/*! @dra2020/baseclient */ "@dra2020/baseclient");
47
47
  const Score = __importStar(__webpack_require__(/*! @dra2020/dra-score */ "@dra2020/dra-score"));
48
48
  const preprocess_1 = __webpack_require__(/*! ./preprocess */ "./src/preprocess.ts");
49
49
  const analyze_1 = __webpack_require__(/*! ./analyze */ "./src/analyze.ts");
@@ -160,7 +160,7 @@ class AnalyticsSession {
160
160
  // If a district has a shape & it is not contiguous, by definition,
161
161
  // it will be a Multipolygon, i.e., it will have multiple pieces, some
162
162
  // possibly embedded w/in other districts. Get & add all the pieces.
163
- const districtParts = Poly.polyParts(poly);
163
+ const districtParts = baseclient_1.Poly.polyParts(poly);
164
164
  discontiguousDistrictFeatures.features.push(...districtParts.features);
165
165
  // discontiguousDistrictFeatures.features.push(poly);
166
166
  }
@@ -1282,7 +1282,7 @@ var __importStar = (this && this.__importStar) || function (mod) {
1282
1282
  };
1283
1283
  Object.defineProperty(exports, "__esModule", ({ value: true }));
1284
1284
  exports.scoreKIWYSICompactness = exports.extractDistrictProperties = void 0;
1285
- const Poly = __importStar(__webpack_require__(/*! @dra2020/poly */ "@dra2020/poly"));
1285
+ const baseclient_1 = __webpack_require__(/*! @dra2020/baseclient */ "@dra2020/baseclient");
1286
1286
  const Compactness = __importStar(__webpack_require__(/*! @dra2020/compactness */ "@dra2020/compactness"));
1287
1287
  const U = __importStar(__webpack_require__(/*! ./utils */ "./src/utils.ts"));
1288
1288
  // HELPER TO EXTRACT PROPERTIES OF DISTRICT SHAPES
@@ -1292,9 +1292,9 @@ function extractDistrictProperties(s, bLog = false) {
1292
1292
  const poly = s.districts.getDistrictShapeByID(i);
1293
1293
  // Guard against no shape for empty districts AND null shapes
1294
1294
  if (isAShape(poly)) {
1295
- const area = Poly.polyAreaFlat(poly);
1296
- const perimeter = Poly.polyPerimeterFlat(poly);
1297
- const diameter = Poly.polyDiameterFlat(poly);
1295
+ const area = baseclient_1.Poly.polyAreaFlat(poly);
1296
+ const perimeter = baseclient_1.Poly.polyPerimeterFlat(poly);
1297
+ const diameter = baseclient_1.Poly.polyDiameterFlat(poly);
1298
1298
  let props = [0, 0, 0];
1299
1299
  props[0 /* Area */] = area;
1300
1300
  props[1 /* Diameter */] = diameter;
@@ -1308,7 +1308,7 @@ exports.extractDistrictProperties = extractDistrictProperties;
1308
1308
  function isAShape(poly) {
1309
1309
  if (poly == null)
1310
1310
  return false;
1311
- if (Poly.polyNull(poly))
1311
+ if (baseclient_1.Poly.polyNull(poly))
1312
1312
  return false;
1313
1313
  return poly.geometry && poly.geometry.coordinates && !U.isArrayEmpty(poly.geometry.coordinates);
1314
1314
  }
@@ -1322,7 +1322,7 @@ function scoreKIWYSICompactness(s, bLog = false) {
1322
1322
  for (let i = 0; i < rawShapes.features.length; i++) {
1323
1323
  const shape = rawShapes.features[i];
1324
1324
  if (isAShape(shape)) {
1325
- const d = Poly.polyDescribe(shape);
1325
+ const d = baseclient_1.Poly.polyDescribe(shape);
1326
1326
  let f = {
1327
1327
  type: 'Feature',
1328
1328
  properties: { districtID: `${i + 1}` },
@@ -2405,14 +2405,39 @@ function deepCopy(src) {
2405
2405
  return src;
2406
2406
  }
2407
2407
  exports.deepCopy = deepCopy;
2408
+ function depthof(a) {
2409
+ if (a === null || a === undefined)
2410
+ return 1;
2411
+ switch (typeof a) {
2412
+ default: return 1;
2413
+ case 'number': return 1;
2414
+ case 'boolean': return 1;
2415
+ case 'string': return 1;
2416
+ case 'object':
2417
+ {
2418
+ let d = 0;
2419
+ if (Array.isArray(a))
2420
+ return a.length > 0 ? (1 + depthof(a[0])) : 2; // still return 2 for empty array
2421
+ else if (Buffer && Buffer.isBuffer(a))
2422
+ return 2;
2423
+ else if (a.hasOwnProperty === undefined)
2424
+ return 1;
2425
+ else {
2426
+ for (var key in a)
2427
+ if (a.hasOwnProperty(key))
2428
+ return 1 + depthof(a[key]);
2429
+ return 2; // or 2 for empty object
2430
+ }
2431
+ }
2432
+ }
2433
+ }
2434
+ exports.depthof = depthof;
2408
2435
  /* TriState
2409
2436
  export function mapBooleanToTriState(bool: boolean): T.TriState
2410
2437
  {
2411
2438
  return (bool) ? T.TriState.Green : T.TriState.Red;
2412
2439
  }
2413
2440
  */
2414
- var util_1 = __webpack_require__(/*! @dra2020/util */ "@dra2020/util");
2415
- Object.defineProperty(exports, "depthof", ({ enumerable: true, get: function () { return util_1.depthof; } }));
2416
2441
 
2417
2442
 
2418
2443
  /***/ }),
@@ -2629,6 +2654,16 @@ module.exports = JSON.parse("{\"AL\":\"all\",\"AK\":\"all\",\"AZ\":\"all\",\"CA\
2629
2654
 
2630
2655
  /***/ }),
2631
2656
 
2657
+ /***/ "@dra2020/baseclient":
2658
+ /*!**************************************!*\
2659
+ !*** external "@dra2020/baseclient" ***!
2660
+ \**************************************/
2661
+ /***/ ((module) => {
2662
+
2663
+ module.exports = require("@dra2020/baseclient");;
2664
+
2665
+ /***/ }),
2666
+
2632
2667
  /***/ "@dra2020/compactness":
2633
2668
  /*!***************************************!*\
2634
2669
  !*** external "@dra2020/compactness" ***!
@@ -2669,16 +2704,6 @@ module.exports = require("@dra2020/dra-types");;
2669
2704
 
2670
2705
  /***/ }),
2671
2706
 
2672
- /***/ "@dra2020/poly":
2673
- /*!********************************!*\
2674
- !*** external "@dra2020/poly" ***!
2675
- \********************************/
2676
- /***/ ((module) => {
2677
-
2678
- module.exports = require("@dra2020/poly");;
2679
-
2680
- /***/ }),
2681
-
2682
2707
  /***/ "@dra2020/racial-voting":
2683
2708
  /*!*****************************************!*\
2684
2709
  !*** external "@dra2020/racial-voting" ***!
@@ -2687,16 +2712,6 @@ module.exports = require("@dra2020/poly");;
2687
2712
 
2688
2713
  module.exports = require("@dra2020/racial-voting");;
2689
2714
 
2690
- /***/ }),
2691
-
2692
- /***/ "@dra2020/util":
2693
- /*!********************************!*\
2694
- !*** external "@dra2020/util" ***!
2695
- \********************************/
2696
- /***/ ((module) => {
2697
-
2698
- module.exports = require("@dra2020/util");;
2699
-
2700
2715
  /***/ })
2701
2716
 
2702
2717
  /******/ });