@dra2020/baseclient 1.0.26 → 1.0.27
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 +25 -13
- package/dist/baseclient.js.map +1 -1
- package/dist/poly/boundbox.d.ts +1 -0
- package/lib/geo/geo.ts +21 -9
- package/lib/poly/boundbox.ts +6 -1
- package/package.json +1 -1
package/dist/poly/boundbox.d.ts
CHANGED
|
@@ -12,6 +12,7 @@ export declare function clipLon(lon: number): number;
|
|
|
12
12
|
export declare function boundboxExtend(bbox: BoundBox, x: number, y: number): void;
|
|
13
13
|
export declare function boundbox(poly: any, bbox?: BoundBox): BoundBox;
|
|
14
14
|
export declare function boundboxPoly(bb: BoundBox): any;
|
|
15
|
+
export declare function boundboxEmpty(bb: BoundBox): boolean;
|
|
15
16
|
export declare function boundboxArea(poly: any): number;
|
|
16
17
|
export declare function boundboxIntersects(bb1: BoundBox, bb2: BoundBox): boolean;
|
|
17
18
|
export declare function boundboxContains(bb: BoundBox, x: number, y: number): boolean;
|
package/lib/geo/geo.ts
CHANGED
|
@@ -113,6 +113,7 @@ export class GeoMultiCollection
|
|
|
113
113
|
|
|
114
114
|
empty()
|
|
115
115
|
{
|
|
116
|
+
this.all = { tag: 'all' };
|
|
116
117
|
this.entries = {};
|
|
117
118
|
this.hidden = {};
|
|
118
119
|
this._onChange();
|
|
@@ -165,7 +166,8 @@ export class GeoMultiCollection
|
|
|
165
166
|
|
|
166
167
|
_onChange(): void
|
|
167
168
|
{
|
|
168
|
-
this.all
|
|
169
|
+
if (this.all.topo || this.all.col || this.all.map)
|
|
170
|
+
this.all = { tag: 'all' };
|
|
169
171
|
this.stamp++;
|
|
170
172
|
}
|
|
171
173
|
|
|
@@ -278,12 +280,17 @@ export class GeoMultiCollection
|
|
|
278
280
|
if (id)
|
|
279
281
|
{
|
|
280
282
|
if (typeof id === 'string')
|
|
281
|
-
|
|
283
|
+
{
|
|
284
|
+
if (! this.hidden[id])
|
|
285
|
+
{
|
|
286
|
+
this.hidden[id] = true;
|
|
287
|
+
this._onChange();
|
|
288
|
+
}
|
|
289
|
+
}
|
|
282
290
|
else if (Array.isArray(id))
|
|
283
|
-
id.forEach((i:
|
|
291
|
+
id.forEach((i: any) => this.hide(i));
|
|
284
292
|
else if (typeof id === 'object')
|
|
285
|
-
for (let p in id) if (id.hasOwnProperty(p)) this.
|
|
286
|
-
this._onChange();
|
|
293
|
+
for (let p in id) if (id.hasOwnProperty(p)) this.hide(p);
|
|
287
294
|
}
|
|
288
295
|
}
|
|
289
296
|
|
|
@@ -292,12 +299,17 @@ export class GeoMultiCollection
|
|
|
292
299
|
if (id)
|
|
293
300
|
{
|
|
294
301
|
if (typeof id === 'string')
|
|
295
|
-
|
|
302
|
+
{
|
|
303
|
+
if (this.hidden[id])
|
|
304
|
+
{
|
|
305
|
+
delete this.hidden[id];
|
|
306
|
+
this._onChange();
|
|
307
|
+
}
|
|
308
|
+
}
|
|
296
309
|
else if (Array.isArray(id))
|
|
297
|
-
id.forEach((i:
|
|
310
|
+
id.forEach((i: any) => this.show(i))
|
|
298
311
|
else if (typeof id === 'object')
|
|
299
|
-
for (let p in id) if (id.hasOwnProperty(p))
|
|
300
|
-
this._onChange();
|
|
312
|
+
for (let p in id) if (id.hasOwnProperty(p)) this.show(p);
|
|
301
313
|
}
|
|
302
314
|
}
|
|
303
315
|
|
package/lib/poly/boundbox.ts
CHANGED
|
@@ -79,7 +79,7 @@ export function boundbox(poly: any, bbox?: BoundBox): BoundBox
|
|
|
79
79
|
}
|
|
80
80
|
|
|
81
81
|
// single point
|
|
82
|
-
else
|
|
82
|
+
else if (Array.isArray(poly) && poly.length >= 2)
|
|
83
83
|
boundboxExtend(bbox, poly[0], poly[1]);
|
|
84
84
|
}
|
|
85
85
|
|
|
@@ -91,6 +91,11 @@ export function boundboxPoly(bb: BoundBox): any
|
|
|
91
91
|
return [ [ [bb.left, bb.top], [bb.left, bb.bottom], [bb.right, bb.bottom], [bb.right, bb.top], [bb.left, bb.top] ] ];
|
|
92
92
|
}
|
|
93
93
|
|
|
94
|
+
export function boundboxEmpty(bb: BoundBox): boolean
|
|
95
|
+
{
|
|
96
|
+
return !bb || bb.left === undefined || P.polyArea(boundboxPoly(bb)) == 0;
|
|
97
|
+
}
|
|
98
|
+
|
|
94
99
|
export function boundboxArea(poly: any): number
|
|
95
100
|
{
|
|
96
101
|
return P.polyArea(boundboxPoly(boundbox(poly)));
|