@dra2020/baseclient 1.0.85 → 1.0.87

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/LICENSE CHANGED
@@ -1,6 +1,6 @@
1
1
  MIT License
2
2
 
3
- Copyright (c) 2021 Terry Crowley
3
+ Copyright (c) 2021-2022 Dave's Redistricting, LLC.
4
4
 
5
5
  Permission is hereby granted, free of charge, to any person obtaining a copy
6
6
  of this software and associated documentation files (the "Software"), to deal
@@ -2278,6 +2278,7 @@ Object.defineProperty(exports, "__esModule", ({ value: true }));
2278
2278
  __exportStar(__webpack_require__(/*! ./geo */ "./lib/geo/geo.ts"), exports);
2279
2279
  __exportStar(__webpack_require__(/*! ./vfeature */ "./lib/geo/vfeature.ts"), exports);
2280
2280
  __exportStar(__webpack_require__(/*! ./flexname */ "./lib/geo/flexname.ts"), exports);
2281
+ __exportStar(__webpack_require__(/*! ./multiblockmapping */ "./lib/geo/multiblockmapping.ts"), exports);
2281
2282
 
2282
2283
 
2283
2284
  /***/ }),
@@ -2824,6 +2825,76 @@ function geoIntersect(multi, bbox, opt) {
2824
2825
  exports.geoIntersect = geoIntersect;
2825
2826
 
2826
2827
 
2828
+ /***/ }),
2829
+
2830
+ /***/ "./lib/geo/multiblockmapping.ts":
2831
+ /*!**************************************!*\
2832
+ !*** ./lib/geo/multiblockmapping.ts ***!
2833
+ \**************************************/
2834
+ /***/ ((__unused_webpack_module, exports) => {
2835
+
2836
+
2837
+ Object.defineProperty(exports, "__esModule", ({ value: true }));
2838
+ exports.MultiBlockMapping = exports.reverseBlockMapping = void 0;
2839
+ function reverseBlockMapping(bm) {
2840
+ let rev = {};
2841
+ if (bm)
2842
+ Object.keys(bm).forEach(blockid => {
2843
+ let geoid = bm[blockid];
2844
+ if (!rev[geoid])
2845
+ rev[geoid] = [];
2846
+ rev[geoid].push(blockid);
2847
+ });
2848
+ Object.values(rev).forEach((a) => a.sort());
2849
+ return rev;
2850
+ }
2851
+ exports.reverseBlockMapping = reverseBlockMapping;
2852
+ class MultiBlockMapping {
2853
+ constructor(tag, bm) {
2854
+ this.entries = [];
2855
+ if (tag && bm)
2856
+ this.entries.push({ tag, bm });
2857
+ }
2858
+ add(tag, bm) {
2859
+ this.entries.forEach(e => { if (e.tag === tag) {
2860
+ e.bm = bm;
2861
+ delete e.rbm;
2862
+ bm = null;
2863
+ } });
2864
+ if (bm)
2865
+ this.entries.push({ tag, bm });
2866
+ }
2867
+ remove(tag) {
2868
+ for (let i = this.entries.length - 1; i >= 0; i--)
2869
+ if (this.entries[i].tag === tag)
2870
+ this.entries.splice(i, 1);
2871
+ }
2872
+ map(blockid) {
2873
+ // Walk backwards to pick up overrides first
2874
+ for (let i = this.entries.length - 1; i >= 0; i--) {
2875
+ let e = this.entries[i];
2876
+ if (e.bm[blockid])
2877
+ return e.bm[blockid];
2878
+ }
2879
+ return undefined;
2880
+ }
2881
+ mapmain(blockid) {
2882
+ return this.entries.length ? this.entries[0].bm[blockid] : undefined;
2883
+ }
2884
+ rev(geoid) {
2885
+ for (let i = 0; i < this.entries.length; i++) {
2886
+ let e = this.entries[i];
2887
+ if (!e.rbm)
2888
+ e.rbm = reverseBlockMapping(e.bm);
2889
+ if (e.rbm[geoid])
2890
+ return e.rbm[geoid];
2891
+ }
2892
+ return undefined;
2893
+ }
2894
+ }
2895
+ exports.MultiBlockMapping = MultiBlockMapping;
2896
+
2897
+
2827
2898
  /***/ }),
2828
2899
 
2829
2900
  /***/ "./lib/geo/vfeature.ts":