@dra2020/baseclient 1.0.91 → 1.0.93
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/baseclient.js +23 -4
- package/dist/baseclient.js.map +1 -1
- package/dist/geo/multiblockmapping.d.ts +2 -0
- package/lib/geo/geo.ts +10 -2
- package/lib/geo/multiblockmapping.ts +13 -0
- package/package.json +1 -1
package/dist/baseclient.js
CHANGED
|
@@ -2457,7 +2457,6 @@ exports.geoNormalizeCollection = geoNormalizeCollection;
|
|
|
2457
2457
|
function geoCollectionToMap(col) {
|
|
2458
2458
|
if (col == null)
|
|
2459
2459
|
return null;
|
|
2460
|
-
record('coltomap', col.features.length);
|
|
2461
2460
|
let map = {};
|
|
2462
2461
|
col.features.forEach((f) => { map[String(f.properties.id)] = f; });
|
|
2463
2462
|
return map;
|
|
@@ -2474,7 +2473,6 @@ function geoMapToCollectionNonNull(map) {
|
|
|
2474
2473
|
return null;
|
|
2475
2474
|
let col = { type: 'FeatureCollection', features: [] };
|
|
2476
2475
|
Object.keys(map).forEach((geoid) => { col.features.push(map[geoid]); });
|
|
2477
|
-
record('maptocol', col.features.length);
|
|
2478
2476
|
return col;
|
|
2479
2477
|
}
|
|
2480
2478
|
exports.geoMapToCollectionNonNull = geoMapToCollectionNonNull;
|
|
@@ -2482,6 +2480,8 @@ function geoCollectionToTopo(col) {
|
|
|
2482
2480
|
let topo = Poly.topoFromCollection(col);
|
|
2483
2481
|
Poly.topoPack(topo);
|
|
2484
2482
|
record('coltotopo', col.features.length);
|
|
2483
|
+
if (col.datasets)
|
|
2484
|
+
topo.datasets = col.datasets;
|
|
2485
2485
|
return topo;
|
|
2486
2486
|
}
|
|
2487
2487
|
exports.geoCollectionToTopo = geoCollectionToTopo;
|
|
@@ -2493,6 +2493,8 @@ function geoTopoToCollection(topo) {
|
|
|
2493
2493
|
let col = Poly.topoToCollection(topo);
|
|
2494
2494
|
Poly.featurePack(col);
|
|
2495
2495
|
record('topotocol', col.features.length);
|
|
2496
|
+
if (topo.datasets)
|
|
2497
|
+
col.datasets = topo.datasets;
|
|
2496
2498
|
return col;
|
|
2497
2499
|
}
|
|
2498
2500
|
exports.geoTopoToCollection = geoTopoToCollection;
|
|
@@ -2635,9 +2637,16 @@ class GeoMultiCollection {
|
|
|
2635
2637
|
let n = this.nEntries;
|
|
2636
2638
|
if (n == 1)
|
|
2637
2639
|
this.all.col = this._col(this.nthEntry(0));
|
|
2638
|
-
else
|
|
2640
|
+
else {
|
|
2639
2641
|
// Going from map to collection guarantees that any duplicates are removed
|
|
2640
2642
|
this.all.col = geoMapToCollectionNonNull(this.allMap());
|
|
2643
|
+
this.forEachEntry(e => {
|
|
2644
|
+
if (e.col && e.col.datasets)
|
|
2645
|
+
this.all.col.datasets = e.col.datasets;
|
|
2646
|
+
if (e.topo && e.topo.datasets)
|
|
2647
|
+
this.all.col.datasets = e.topo.datasets;
|
|
2648
|
+
});
|
|
2649
|
+
}
|
|
2641
2650
|
}
|
|
2642
2651
|
return this.all.col;
|
|
2643
2652
|
}
|
|
@@ -2873,6 +2882,7 @@ exports.reverseBlockMapping = reverseBlockMapping;
|
|
|
2873
2882
|
class MultiBlockMapping {
|
|
2874
2883
|
constructor(tag, bm) {
|
|
2875
2884
|
this.entries = [];
|
|
2885
|
+
this.stamp = Math.trunc(Math.random() * Number.MAX_SAFE_INTEGER / 2);
|
|
2876
2886
|
if (tag && bm)
|
|
2877
2887
|
this.entries.push({ tag, bm });
|
|
2878
2888
|
}
|
|
@@ -2884,11 +2894,14 @@ class MultiBlockMapping {
|
|
|
2884
2894
|
} });
|
|
2885
2895
|
if (bm)
|
|
2886
2896
|
this.entries.push({ tag, bm });
|
|
2897
|
+
this.stamp++;
|
|
2887
2898
|
}
|
|
2888
2899
|
remove(tag) {
|
|
2889
2900
|
for (let i = this.entries.length - 1; i >= 0; i--)
|
|
2890
|
-
if (this.entries[i].tag === tag)
|
|
2901
|
+
if (this.entries[i].tag === tag) {
|
|
2902
|
+
this.stamp++;
|
|
2891
2903
|
this.entries.splice(i, 1);
|
|
2904
|
+
}
|
|
2892
2905
|
}
|
|
2893
2906
|
map(blockid) {
|
|
2894
2907
|
// Walk backwards to pick up overrides first
|
|
@@ -2899,6 +2912,12 @@ class MultiBlockMapping {
|
|
|
2899
2912
|
}
|
|
2900
2913
|
return undefined;
|
|
2901
2914
|
}
|
|
2915
|
+
multimap(blockid) {
|
|
2916
|
+
let a = [];
|
|
2917
|
+
this.entries.forEach(e => { if (e.bm[blockid])
|
|
2918
|
+
a.push(e.bm[blockid]); });
|
|
2919
|
+
return a;
|
|
2920
|
+
}
|
|
2902
2921
|
bmOf(tag) {
|
|
2903
2922
|
let e = this.entries.find(e => e.tag === tag);
|
|
2904
2923
|
return e ? e.bm : null;
|