@dra2020/baseclient 1.0.34 → 1.0.35
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 +35 -16
- package/dist/baseclient.js.map +1 -1
- package/dist/geo/geo.d.ts +3 -0
- package/lib/geo/geo.ts +25 -9
- package/lib/poly/topo.ts +11 -6
- package/package.json +1 -1
package/dist/geo/geo.d.ts
CHANGED
|
@@ -13,8 +13,11 @@ export declare type GeoCentroidMap = {
|
|
|
13
13
|
export declare function geoEnsureID(col: GeoFeatureCollection): void;
|
|
14
14
|
export declare function geoCollectionToMap(col: GeoFeatureCollection): GeoFeatureMap;
|
|
15
15
|
export declare function geoMapToCollection(map: GeoFeatureMap): GeoFeatureCollection;
|
|
16
|
+
export declare function geoMapToCollectionNonNull(map: GeoFeatureMap): GeoFeatureCollection;
|
|
16
17
|
export declare function geoCollectionToTopo(col: GeoFeatureCollection): Poly.Topo;
|
|
18
|
+
export declare function geoCollectionToTopoNonNull(col: GeoFeatureCollection): Poly.Topo;
|
|
17
19
|
export declare function geoTopoToCollection(topo: Poly.Topo): GeoFeatureCollection;
|
|
20
|
+
export declare function geoTopoToCollectionNonNull(topo: Poly.Topo): GeoFeatureCollection;
|
|
18
21
|
export interface GeoFeatureMap {
|
|
19
22
|
[id: string]: GeoFeature;
|
|
20
23
|
}
|
package/lib/geo/geo.ts
CHANGED
|
@@ -38,7 +38,13 @@ export function geoCollectionToMap(col: GeoFeatureCollection): GeoFeatureMap
|
|
|
38
38
|
|
|
39
39
|
export function geoMapToCollection(map: GeoFeatureMap): GeoFeatureCollection
|
|
40
40
|
{
|
|
41
|
-
if (
|
|
41
|
+
if (Util.countKeys(map) == 0) return null;
|
|
42
|
+
return geoMapToCollectionNonNull(map);
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
export function geoMapToCollectionNonNull(map: GeoFeatureMap): GeoFeatureCollection
|
|
46
|
+
{
|
|
47
|
+
if (map == null) return null;
|
|
42
48
|
let col: GeoFeatureCollection = { type: 'FeatureCollection', features: [] };
|
|
43
49
|
Object.keys(map).forEach((geoid: string) => { col.features.push(map[geoid]) });
|
|
44
50
|
return col;
|
|
@@ -51,6 +57,11 @@ export function geoCollectionToTopo(col: GeoFeatureCollection): Poly.Topo
|
|
|
51
57
|
return topo;
|
|
52
58
|
}
|
|
53
59
|
|
|
60
|
+
export function geoCollectionToTopoNonNull(col: GeoFeatureCollection): Poly.Topo
|
|
61
|
+
{
|
|
62
|
+
return geoCollectionToTopo(col);
|
|
63
|
+
}
|
|
64
|
+
|
|
54
65
|
export function geoTopoToCollection(topo: Poly.Topo): GeoFeatureCollection
|
|
55
66
|
{
|
|
56
67
|
let col = Poly.topoToCollection(topo);
|
|
@@ -58,6 +69,11 @@ export function geoTopoToCollection(topo: Poly.Topo): GeoFeatureCollection
|
|
|
58
69
|
return col;
|
|
59
70
|
}
|
|
60
71
|
|
|
72
|
+
export function geoTopoToCollectionNonNull(topo: Poly.Topo): GeoFeatureCollection
|
|
73
|
+
{
|
|
74
|
+
return geoTopoToCollection(topo);
|
|
75
|
+
}
|
|
76
|
+
|
|
61
77
|
export interface GeoFeatureMap
|
|
62
78
|
{
|
|
63
79
|
[id: string]: GeoFeature; // Maps id to GeoFeature
|
|
@@ -183,9 +199,9 @@ export class GeoMultiCollection
|
|
|
183
199
|
if (! e.col)
|
|
184
200
|
{
|
|
185
201
|
if (e.map)
|
|
186
|
-
e.col =
|
|
202
|
+
e.col = geoMapToCollectionNonNull(e.map);
|
|
187
203
|
else if (e.topo)
|
|
188
|
-
e.col =
|
|
204
|
+
e.col = geoTopoToCollectionNonNull(e.topo);
|
|
189
205
|
}
|
|
190
206
|
return e.col;
|
|
191
207
|
}
|
|
@@ -199,7 +215,7 @@ export class GeoMultiCollection
|
|
|
199
215
|
e.map = geoCollectionToMap(e.col);
|
|
200
216
|
else if (e.topo)
|
|
201
217
|
{
|
|
202
|
-
e.col =
|
|
218
|
+
e.col = geoTopoToCollectionNonNull(e.topo);
|
|
203
219
|
e.map = geoCollectionToMap(e.col);
|
|
204
220
|
}
|
|
205
221
|
}
|
|
@@ -212,11 +228,11 @@ export class GeoMultiCollection
|
|
|
212
228
|
if (! e.topo)
|
|
213
229
|
{
|
|
214
230
|
if (e.col)
|
|
215
|
-
e.topo =
|
|
231
|
+
e.topo = geoCollectionToTopoNonNull(e.col);
|
|
216
232
|
else if (e.map)
|
|
217
233
|
{
|
|
218
|
-
e.col =
|
|
219
|
-
e.topo =
|
|
234
|
+
e.col = geoMapToCollectionNonNull(e.map);
|
|
235
|
+
e.topo = geoCollectionToTopoNonNull(e.col);
|
|
220
236
|
}
|
|
221
237
|
}
|
|
222
238
|
return e.topo;
|
|
@@ -242,7 +258,7 @@ export class GeoMultiCollection
|
|
|
242
258
|
this.all.col = this._col(this.nthEntry(0));
|
|
243
259
|
else
|
|
244
260
|
// Going from map to collection guarantees that any duplicates are removed
|
|
245
|
-
this.all.col =
|
|
261
|
+
this.all.col = geoMapToCollectionNonNull(this.allMap());
|
|
246
262
|
}
|
|
247
263
|
return this.all.col;
|
|
248
264
|
}
|
|
@@ -276,7 +292,7 @@ export class GeoMultiCollection
|
|
|
276
292
|
if (n == 1)
|
|
277
293
|
this.all.topo = this._topo(this.nthEntry(0));
|
|
278
294
|
else
|
|
279
|
-
this.all.topo =
|
|
295
|
+
this.all.topo = geoCollectionToTopoNonNull(this.allCol());
|
|
280
296
|
}
|
|
281
297
|
return this.all.topo;
|
|
282
298
|
}
|
package/lib/poly/topo.ts
CHANGED
|
@@ -33,10 +33,14 @@ export function topoFromCollection(col: any): Topo
|
|
|
33
33
|
let prop = getGEOID(col);
|
|
34
34
|
let objects: any = {};
|
|
35
35
|
col.features.forEach((f: any) => objects[f.properties[prop]] = f);
|
|
36
|
-
let topo
|
|
36
|
+
let topo: any;
|
|
37
|
+
if (Util.isEmpty(objects))
|
|
38
|
+
topo = { objects: objects }
|
|
39
|
+
else
|
|
40
|
+
topo = TopoServer.topology(objects);
|
|
37
41
|
PP.featureRepack(col, save);
|
|
38
42
|
if (col.datasets)
|
|
39
|
-
|
|
43
|
+
topo.datasets = col.datasets;
|
|
40
44
|
return topo;
|
|
41
45
|
}
|
|
42
46
|
|
|
@@ -109,10 +113,11 @@ export function topoToFeature(topo: Topo, geoid: string): any
|
|
|
109
113
|
export function topoToCollection(topo: Topo): any
|
|
110
114
|
{
|
|
111
115
|
let col: any = { type: 'FeatureCollection', features: [] };
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
+
if (topo)
|
|
117
|
+
Object.keys(topo.objects).forEach((geoid: string) => {
|
|
118
|
+
col.features.push(topoToFeature(topo, geoid));
|
|
119
|
+
});
|
|
120
|
+
if (topo && topo.datasets) col.datasets = topo.datasets;
|
|
116
121
|
return col;
|
|
117
122
|
}
|
|
118
123
|
|