@dra2020/baseclient 1.0.99 → 1.0.101
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 +20 -1
- package/dist/baseclient.js.map +1 -1
- package/dist/geo/geo.d.ts +6 -1
- package/lib/geo/geo.ts +21 -1
- package/lib/poly/polypack.ts +3 -0
- package/package.json +1 -1
package/dist/geo/geo.d.ts
CHANGED
|
@@ -10,7 +10,11 @@ export declare type GeoCentroidMap = {
|
|
|
10
10
|
y: number;
|
|
11
11
|
};
|
|
12
12
|
};
|
|
13
|
+
export declare type HideMap = {
|
|
14
|
+
[id: string]: boolean;
|
|
15
|
+
};
|
|
13
16
|
export declare function dumpMetrics(): void;
|
|
17
|
+
export declare function hidemapConcat(...args: HideMap[]): HideMap;
|
|
14
18
|
export interface NormalizeOptions {
|
|
15
19
|
joinPolygons?: boolean;
|
|
16
20
|
checkRewind?: boolean;
|
|
@@ -44,7 +48,7 @@ export declare function geoMapEqual(m1: GeoFeatureMap, m2: GeoFeatureMap): boole
|
|
|
44
48
|
export declare class GeoMultiCollection {
|
|
45
49
|
entries: GeoEntryMap;
|
|
46
50
|
all: GeoEntry;
|
|
47
|
-
hidden:
|
|
51
|
+
hidden: HideMap;
|
|
48
52
|
stamp: number;
|
|
49
53
|
constructor(tag?: string, topo?: Poly.Topo, col?: GeoFeatureCollection, map?: GeoFeatureMap);
|
|
50
54
|
empty(): void;
|
|
@@ -65,6 +69,7 @@ export declare class GeoMultiCollection {
|
|
|
65
69
|
allCol(): GeoFeatureCollection;
|
|
66
70
|
allMap(): GeoFeatureMap;
|
|
67
71
|
allTopo(): Poly.Topo;
|
|
72
|
+
hideSetAll(hm: HideMap): void;
|
|
68
73
|
hide(id: any): void;
|
|
69
74
|
show(id: any): void;
|
|
70
75
|
showAll(): void;
|
package/lib/geo/geo.ts
CHANGED
|
@@ -7,6 +7,7 @@ export type GeoFeature = geojson.Feature;
|
|
|
7
7
|
export type GeoFeatureArray = GeoFeature[];
|
|
8
8
|
export type GeoFeatureCollection = geojson.FeatureCollection;
|
|
9
9
|
export type GeoCentroidMap = { [geoid: string]: { x: number, y: number } };
|
|
10
|
+
export type HideMap = { [id: string]: boolean };
|
|
10
11
|
|
|
11
12
|
// Tracing/debugging aid
|
|
12
13
|
let metrics: { [action: string]: { count: number, total: number } } = {};
|
|
@@ -26,6 +27,15 @@ export function dumpMetrics(): void
|
|
|
26
27
|
});
|
|
27
28
|
}
|
|
28
29
|
|
|
30
|
+
export function hidemapConcat(...args: HideMap[]): HideMap
|
|
31
|
+
{
|
|
32
|
+
let hm: HideMap = {};
|
|
33
|
+
|
|
34
|
+
for (let i = 0; i < args.length; i++)
|
|
35
|
+
if (args[i]) Object.keys(args[i]).forEach(id => hm[id] = true);
|
|
36
|
+
return hm;
|
|
37
|
+
}
|
|
38
|
+
|
|
29
39
|
export interface NormalizeOptions
|
|
30
40
|
{
|
|
31
41
|
joinPolygons?: boolean,
|
|
@@ -241,7 +251,7 @@ export class GeoMultiCollection
|
|
|
241
251
|
{
|
|
242
252
|
entries: GeoEntryMap;
|
|
243
253
|
all: GeoEntry;
|
|
244
|
-
hidden:
|
|
254
|
+
hidden: HideMap;
|
|
245
255
|
stamp: number;
|
|
246
256
|
|
|
247
257
|
constructor(tag?: string, topo?: Poly.Topo, col?: GeoFeatureCollection, map?: GeoFeatureMap)
|
|
@@ -475,6 +485,16 @@ export class GeoMultiCollection
|
|
|
475
485
|
return this.all.topo;
|
|
476
486
|
}
|
|
477
487
|
|
|
488
|
+
hideSetAll(hm: HideMap): void
|
|
489
|
+
{
|
|
490
|
+
// Prevents onChange when resetting to same value
|
|
491
|
+
if (! Util.shallowEqual(this.hidden, hm))
|
|
492
|
+
{
|
|
493
|
+
this.showAll();
|
|
494
|
+
this.hide(hm);
|
|
495
|
+
}
|
|
496
|
+
}
|
|
497
|
+
|
|
478
498
|
hide(id: any): void
|
|
479
499
|
{
|
|
480
500
|
if (id)
|
package/lib/poly/polypack.ts
CHANGED
|
@@ -21,6 +21,7 @@ export function polyPackSize(coords: any): number
|
|
|
21
21
|
// Null feature?
|
|
22
22
|
if (coords == null || (coords.length !== undefined && coords.length == 0)) return 0;
|
|
23
23
|
|
|
24
|
+
if (! Array.isArray(coords)) return 0;
|
|
24
25
|
let depth = Util.depthof(coords);
|
|
25
26
|
if (depth == 3) coords = [[ coords ]];
|
|
26
27
|
else if (depth == 4) coords = [ coords ]; // normalize to multipolygon
|
|
@@ -223,6 +224,8 @@ export function polyPack(coords: any, prepack?: PolyPack): PolyPack
|
|
|
223
224
|
coords = coords.geometry.coordinates;
|
|
224
225
|
|
|
225
226
|
// Transparently handle polygon or multi-polygon
|
|
227
|
+
if (! Array.isArray(coords)) return null;
|
|
228
|
+
|
|
226
229
|
let depth = Util.depthof(coords);
|
|
227
230
|
if (depth == 2) coords = [ [ [ coords ] ] ];
|
|
228
231
|
else if (depth == 3) coords = [ [ coords ] ];
|