@dra2020/baseclient 1.0.92 → 1.0.94
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 +30 -1
- package/dist/baseclient.js.map +1 -1
- package/dist/geo/geo.d.ts +1 -0
- package/dist/geo/multiblockmapping.d.ts +2 -0
- package/lib/geo/geo.ts +24 -0
- package/lib/geo/multiblockmapping.ts +13 -0
- package/package.json +1 -1
package/dist/geo/geo.d.ts
CHANGED
|
@@ -52,6 +52,7 @@ export declare class GeoMultiCollection {
|
|
|
52
52
|
nthEntry(n: number): GeoEntry;
|
|
53
53
|
add(tag: string, topo: Poly.Topo, col: GeoFeatureCollection, map: GeoFeatureMap): void;
|
|
54
54
|
addMulti(multi: GeoMultiCollection): void;
|
|
55
|
+
addAll(tag: string, multi: GeoMultiCollection): void;
|
|
55
56
|
remove(tag: string): void;
|
|
56
57
|
_onChange(): void;
|
|
57
58
|
_col(e: GeoEntry): GeoFeatureCollection;
|
|
@@ -12,10 +12,12 @@ interface Entry {
|
|
|
12
12
|
export declare function reverseBlockMapping(bm: BlockMapping): ReverseBlockMapping;
|
|
13
13
|
export declare class MultiBlockMapping {
|
|
14
14
|
entries: Entry[];
|
|
15
|
+
stamp: number;
|
|
15
16
|
constructor(tag?: string, bm?: BlockMapping);
|
|
16
17
|
add(tag: string, bm: BlockMapping): void;
|
|
17
18
|
remove(tag: string): void;
|
|
18
19
|
map(blockid: string): string;
|
|
20
|
+
multimap(blockid: string): string[];
|
|
19
21
|
bmOf(tag: string): BlockMapping;
|
|
20
22
|
mapmain(blockid: string): string;
|
|
21
23
|
rev(geoid: string): string[];
|
package/lib/geo/geo.ts
CHANGED
|
@@ -294,6 +294,30 @@ export class GeoMultiCollection
|
|
|
294
294
|
}
|
|
295
295
|
}
|
|
296
296
|
|
|
297
|
+
// Add the "all" collection from the passed in multi, but do not force compute of any things not computed yet.
|
|
298
|
+
addAll(tag: string, multi: GeoMultiCollection): void
|
|
299
|
+
{
|
|
300
|
+
let nEntries = Util.countKeys(multi.entries);
|
|
301
|
+
if (nEntries)
|
|
302
|
+
{
|
|
303
|
+
// Make sure all collection is created
|
|
304
|
+
if (!multi.all.topo && !multi.all.col && !multi.all.map)
|
|
305
|
+
{
|
|
306
|
+
// Create cheapest one (collection if I need to create, otherwise copy from single entry)
|
|
307
|
+
if (nEntries > 1)
|
|
308
|
+
multi.allCol();
|
|
309
|
+
else
|
|
310
|
+
{
|
|
311
|
+
let e = multi.nthEntry(0);
|
|
312
|
+
multi.all.topo = e.topo;
|
|
313
|
+
multi.all.col = e.col;
|
|
314
|
+
multi.all.map = e.map;
|
|
315
|
+
}
|
|
316
|
+
}
|
|
317
|
+
this.add(tag, multi.all.topo, multi.all.col, multi.all.map);
|
|
318
|
+
}
|
|
319
|
+
}
|
|
320
|
+
|
|
297
321
|
remove(tag: string): void
|
|
298
322
|
{
|
|
299
323
|
let entry = this.entries[tag];
|
|
@@ -24,10 +24,12 @@ export function reverseBlockMapping(bm: BlockMapping): ReverseBlockMapping
|
|
|
24
24
|
export class MultiBlockMapping
|
|
25
25
|
{
|
|
26
26
|
entries: Entry[];
|
|
27
|
+
stamp: number;
|
|
27
28
|
|
|
28
29
|
constructor(tag?: string, bm?: BlockMapping)
|
|
29
30
|
{
|
|
30
31
|
this.entries = [];
|
|
32
|
+
this.stamp = Math.trunc(Math.random() * Number.MAX_SAFE_INTEGER / 2);
|
|
31
33
|
if (tag && bm)
|
|
32
34
|
this.entries.push({ tag, bm });
|
|
33
35
|
}
|
|
@@ -37,13 +39,17 @@ export class MultiBlockMapping
|
|
|
37
39
|
this.entries.forEach(e => { if (e.tag === tag) { e.bm = bm; delete e.rbm; bm = null } });
|
|
38
40
|
if (bm)
|
|
39
41
|
this.entries.push({ tag, bm });
|
|
42
|
+
this.stamp++;
|
|
40
43
|
}
|
|
41
44
|
|
|
42
45
|
remove(tag: string): void
|
|
43
46
|
{
|
|
44
47
|
for (let i = this.entries.length-1; i >= 0; i--)
|
|
45
48
|
if (this.entries[i].tag === tag)
|
|
49
|
+
{
|
|
50
|
+
this.stamp++;
|
|
46
51
|
this.entries.splice(i, 1);
|
|
52
|
+
}
|
|
47
53
|
}
|
|
48
54
|
|
|
49
55
|
map(blockid: string): string
|
|
@@ -58,6 +64,13 @@ export class MultiBlockMapping
|
|
|
58
64
|
return undefined;
|
|
59
65
|
}
|
|
60
66
|
|
|
67
|
+
multimap(blockid: string): string[]
|
|
68
|
+
{
|
|
69
|
+
let a: string[] = [];
|
|
70
|
+
this.entries.forEach(e => { if (e.bm[blockid]) a.push(e.bm[blockid]) });
|
|
71
|
+
return a;
|
|
72
|
+
}
|
|
73
|
+
|
|
61
74
|
bmOf(tag: string): BlockMapping
|
|
62
75
|
{
|
|
63
76
|
let e = this.entries.find(e => e.tag === tag);
|