@dra2020/baseclient 1.0.11 → 1.0.14
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/README.md +16 -5
- package/dist/all/all.d.ts +18 -2
- package/dist/all/allclient.d.ts +18 -0
- package/dist/base.js +33010 -0
- package/dist/base.js.map +1 -0
- package/dist/baseclient.js +166 -1279
- package/dist/baseclient.js.map +1 -1
- package/dist/dbabstract/all.d.ts +1 -0
- package/dist/dbabstract/db.d.ts +83 -0
- package/dist/dbdynamo/all.d.ts +1 -0
- package/dist/dbdynamo/dbdynamo.d.ts +190 -0
- package/dist/filterexpr/filterexpr.d.ts +0 -3
- package/dist/fsm/fsm.d.ts +0 -1
- package/dist/fsmfile/all.d.ts +1 -0
- package/dist/fsmfile/fsmfile.d.ts +47 -0
- package/dist/jsonstream/all.d.ts +1 -0
- package/dist/jsonstream/jsonstream.d.ts +130 -0
- package/dist/lambda/all.d.ts +1 -0
- package/dist/lambda/env.d.ts +10 -0
- package/dist/lambda/lambda.d.ts +18 -0
- package/dist/logserver/all.d.ts +5 -0
- package/dist/logserver/log.d.ts +11 -0
- package/dist/logserver/logaccum.d.ts +154 -0
- package/dist/logserver/logblob.d.ts +24 -0
- package/dist/logserver/logconcat.d.ts +55 -0
- package/dist/logserver/logkey.d.ts +28 -0
- package/dist/memsqs/all.d.ts +4 -0
- package/dist/memsqs/client.d.ts +13 -0
- package/dist/memsqs/loopback.d.ts +11 -0
- package/dist/memsqs/orderedlist.d.ts +19 -0
- package/dist/memsqs/queue.d.ts +84 -0
- package/dist/memsqs/server.d.ts +37 -0
- package/dist/ot-js/otsession.d.ts +0 -3
- package/dist/poly/union.d.ts +0 -1
- package/dist/storage/all.d.ts +4 -0
- package/dist/storage/datablob.d.ts +9 -0
- package/dist/storage/env.d.ts +10 -0
- package/dist/storage/splitsblob.d.ts +13 -0
- package/dist/storage/storage.d.ts +166 -0
- package/dist/storages3/all.d.ts +1 -0
- package/dist/storages3/s3.d.ts +62 -0
- package/docs/dbabstract.md +2 -0
- package/docs/dbdynamo.md +2 -0
- package/docs/fsmfile.md +2 -0
- package/docs/jsonstream.md +44 -0
- package/docs/lambda.md +2 -0
- package/docs/logserver.md +2 -0
- package/docs/storage.md +2 -0
- package/docs/storages3.md +2 -0
- package/lib/all/all.ts +22 -2
- package/lib/all/allclient.ts +19 -0
- package/lib/dbabstract/all.ts +1 -0
- package/lib/dbabstract/db.ts +246 -0
- package/lib/dbdynamo/all.ts +1 -0
- package/lib/dbdynamo/dbdynamo.ts +1551 -0
- package/lib/filterexpr/filterexpr.ts +5 -79
- package/lib/fsm/fsm.ts +2 -12
- package/lib/fsmfile/all.ts +1 -0
- package/lib/fsmfile/fsmfile.ts +236 -0
- package/lib/jsonstream/all.ts +1 -0
- package/lib/jsonstream/jsonstream.ts +940 -0
- package/lib/lambda/all.ts +1 -0
- package/lib/lambda/env.ts +13 -0
- package/lib/lambda/lambda.ts +120 -0
- package/lib/logserver/all.ts +5 -0
- package/lib/logserver/log.ts +565 -0
- package/lib/logserver/logaccum.ts +1445 -0
- package/lib/logserver/logblob.ts +84 -0
- package/lib/logserver/logconcat.ts +313 -0
- package/lib/logserver/logkey.ts +125 -0
- package/lib/memsqs/all.ts +4 -0
- package/lib/memsqs/client.ts +268 -0
- package/lib/memsqs/loopback.ts +64 -0
- package/lib/memsqs/orderedlist.ts +74 -0
- package/lib/memsqs/queue.ts +395 -0
- package/lib/memsqs/server.ts +262 -0
- package/lib/ot-js/otsession.ts +1 -4
- package/lib/poly/hash.ts +1 -1
- package/lib/poly/topo.ts +41 -15
- package/lib/poly/union.ts +0 -17
- package/lib/storage/all.ts +4 -0
- package/lib/storage/datablob.ts +36 -0
- package/lib/storage/env.ts +14 -0
- package/lib/storage/splitsblob.ts +63 -0
- package/lib/storage/storage.ts +604 -0
- package/lib/storages3/all.ts +1 -0
- package/lib/storages3/s3.ts +576 -0
- package/package.json +10 -9
- package/dist/geo/all.d.ts +0 -2
- package/dist/geo/geo.d.ts +0 -67
- package/dist/geo/vfeature.d.ts +0 -4
- package/docs/filterexpr.md +0 -22
- package/lib/geo/all.ts +0 -2
- package/lib/geo/geo.ts +0 -452
- package/lib/geo/vfeature.ts +0 -34
package/lib/poly/topo.ts
CHANGED
|
@@ -59,6 +59,19 @@ function correctGeometry(f: any): any
|
|
|
59
59
|
{
|
|
60
60
|
let multiPoly = f.geometry.coordinates;
|
|
61
61
|
|
|
62
|
+
/* Comment this out right now - might have been do to not rewinding merge output
|
|
63
|
+
// topojson will under certain circumstances return a MultiPolygon with the first Polygon containing holes
|
|
64
|
+
// that are precisely filled by a subsequent polygon. We make a secondary union pass to try to correct for this.
|
|
65
|
+
// If we have a really degenerate multipolygon (test above some number of polygons) omit this expensive pass
|
|
66
|
+
// since cleanup is unlikely.
|
|
67
|
+
if (multiPoly.length > 1 && multiPoly.length < 50)
|
|
68
|
+
{
|
|
69
|
+
let result = Q.unionPolys(multiPoly);
|
|
70
|
+
if (Util.depthof(result) == 4) result = [ result ];
|
|
71
|
+
multiPoly = result;
|
|
72
|
+
}
|
|
73
|
+
*/
|
|
74
|
+
|
|
62
75
|
// Convert degenerate MultiPolygon to Polygon
|
|
63
76
|
if (multiPoly.length == 1)
|
|
64
77
|
{
|
|
@@ -67,9 +80,6 @@ function correctGeometry(f: any): any
|
|
|
67
80
|
}
|
|
68
81
|
}
|
|
69
82
|
|
|
70
|
-
// TopoJSON does not guarantee proper winding order which messes up later processing. Fix it.
|
|
71
|
-
P.featureRewind(f);
|
|
72
|
-
|
|
73
83
|
return f;
|
|
74
84
|
}
|
|
75
85
|
|
|
@@ -184,11 +194,6 @@ export interface SimplifyOptions
|
|
|
184
194
|
|
|
185
195
|
const DefaultSimplifyOptions: SimplifyOptions = { minArea: 500 };
|
|
186
196
|
|
|
187
|
-
function log(s: string): void
|
|
188
|
-
{
|
|
189
|
-
//console.log(s);
|
|
190
|
-
}
|
|
191
|
-
|
|
192
197
|
//
|
|
193
198
|
// topoSimplifyCollection:
|
|
194
199
|
// This implements our simplification strategy for block/precinct level shapes. The basic idea is to
|
|
@@ -213,10 +218,10 @@ export function topoSimplifyCollection(col: any, options?: SimplifyOptions): any
|
|
|
213
218
|
let elapsedTotal = new Util.Elapsed();
|
|
214
219
|
let elapsed = new Util.Elapsed();
|
|
215
220
|
let topo = topoFromCollection(col);
|
|
216
|
-
log(`topoSimplifyCollection: fromCollection: ${Math.round(elapsed.ms())}ms`);
|
|
221
|
+
console.log(`topoSimplifyCollection: fromCollection: ${Math.round(elapsed.ms())}ms`);
|
|
217
222
|
elapsed.start();
|
|
218
223
|
topo = TopoSimplify.presimplify(topo, TopoSimplify['sphericalTriangleArea']);
|
|
219
|
-
log(`topoSimplifyCollection: presimplify: ${Math.round(elapsed.ms())}ms`);
|
|
224
|
+
console.log(`topoSimplifyCollection: presimplify: ${Math.round(elapsed.ms())}ms`);
|
|
220
225
|
elapsed.start();
|
|
221
226
|
|
|
222
227
|
// Keep iterating on removing simplification from degenerate shapes
|
|
@@ -281,13 +286,13 @@ export function topoSimplifyCollection(col: any, options?: SimplifyOptions): any
|
|
|
281
286
|
}
|
|
282
287
|
}
|
|
283
288
|
});
|
|
284
|
-
log(`topoSimplifyCollection: pass ${nTries}: ${nBad} (${nTiny} tiny) of ${col.features.length} features are degenerate`);
|
|
289
|
+
console.log(`topoSimplifyCollection: pass ${nTries}: ${nBad} (${nTiny} tiny) of ${col.features.length} features are degenerate`);
|
|
285
290
|
|
|
286
291
|
// If not making progress, keep more points
|
|
287
292
|
if (nBad >= nBadLast)
|
|
288
293
|
{
|
|
289
294
|
keepweight /= 10;
|
|
290
|
-
log(`topoSimplifyCollection: pass ${nTries}: reducing weight limit to ${keepweight}`);
|
|
295
|
+
console.log(`topoSimplifyCollection: pass ${nTries}: reducing weight limit to ${keepweight}`);
|
|
291
296
|
}
|
|
292
297
|
nBadLast = nBad;
|
|
293
298
|
|
|
@@ -303,7 +308,7 @@ export function topoSimplifyCollection(col: any, options?: SimplifyOptions): any
|
|
|
303
308
|
nTries++;
|
|
304
309
|
}
|
|
305
310
|
|
|
306
|
-
log(`topoSimplifyCollection: total elapsed time: ${bigTimeString(elapsedTotal.ms())}`);
|
|
311
|
+
console.log(`topoSimplifyCollection: total elapsed time: ${bigTimeString(elapsedTotal.ms())}`);
|
|
307
312
|
|
|
308
313
|
return col;
|
|
309
314
|
}
|
|
@@ -313,7 +318,28 @@ export function topoMerge(topo: Topo, geoids: string[]): any
|
|
|
313
318
|
if (geoids == null || geoids.length == 0) return null;
|
|
314
319
|
let objects: any[] = [];
|
|
315
320
|
geoids.forEach((geoid) => objects.push(topo.objects[geoid]));
|
|
316
|
-
|
|
321
|
+
let f: any = correctGeometry({ type: 'Feature', properties: {}, geometry: TopoClient.merge(topo, objects) });
|
|
322
|
+
P.featureRewind(f);
|
|
323
|
+
|
|
324
|
+
/* Comment out for now - may be due to merge output needing to be rewound
|
|
325
|
+
// If I get a bad output from topoMerge, just do more expensive poly union. This can happen if input polygons
|
|
326
|
+
// are a little funky (in particular, if they double back along the same edge.
|
|
327
|
+
if (selfIntersectFast(f))
|
|
328
|
+
{
|
|
329
|
+
//console.log('topoMerge: patching selfIntersect');
|
|
330
|
+
let polys: any[] = [];
|
|
331
|
+
geoids.forEach((geoid) => polys.push(topoToFeature(topo, geoid).geometry.coordinates));
|
|
332
|
+
let result = Q.unionPolys(polys);
|
|
333
|
+
let depth = Util.depthof(result);
|
|
334
|
+
if (depth === 5 && result.length === 1)
|
|
335
|
+
{
|
|
336
|
+
depth = 4;
|
|
337
|
+
result = result[0];
|
|
338
|
+
}
|
|
339
|
+
f = { type: 'feature', properties: {}, geometry: { type: depth == 4 ? 'Polygon' : 'MultiPolygon', coordinates: result } };
|
|
340
|
+
}
|
|
341
|
+
*/
|
|
342
|
+
return f;
|
|
317
343
|
}
|
|
318
344
|
|
|
319
345
|
export function topoMergeFeatures(topo: Topo, features: any[]): any
|
|
@@ -366,7 +392,7 @@ class FsmIncrementalUnion extends FSM.Fsm
|
|
|
366
392
|
let values = Object.values(map);
|
|
367
393
|
this.work = { nUnion: values.length, nDifference: 0, ms: 0 };
|
|
368
394
|
let elapsed = new Util.Elapsed();
|
|
369
|
-
this.result = topoMergeFeatures(this.key.
|
|
395
|
+
this.result = topoMergeFeatures(this.key.topo, values);
|
|
370
396
|
this.work.ms = elapsed.ms();
|
|
371
397
|
this.map = map;
|
|
372
398
|
}
|
package/lib/poly/union.ts
CHANGED
|
@@ -59,23 +59,6 @@ export function polyIntersects(p1: any, p2: any): boolean
|
|
|
59
59
|
return bIntersects;
|
|
60
60
|
}
|
|
61
61
|
|
|
62
|
-
export function polyDifference(main: any, parts: any[]): any
|
|
63
|
-
{
|
|
64
|
-
main = PP.polyUnpack(coords(main));
|
|
65
|
-
|
|
66
|
-
// need to explode multipolygon so that "exploded" is a valid multipolygon input to underlying difference routine
|
|
67
|
-
let exploded: any[] = [];
|
|
68
|
-
parts.forEach((p: any) => {
|
|
69
|
-
p = PP.polyUnpack(coords(p));
|
|
70
|
-
if (Util.depthof(p) == 5)
|
|
71
|
-
p.forEach((poly: any) => { exploded.push(poly) });
|
|
72
|
-
else
|
|
73
|
-
exploded.push(p);
|
|
74
|
-
});
|
|
75
|
-
|
|
76
|
-
return PR.polyRound(_difference(main, exploded));
|
|
77
|
-
}
|
|
78
|
-
|
|
79
62
|
class FsmDifference extends FSM.Fsm
|
|
80
63
|
{
|
|
81
64
|
accum: any;
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
// Shared libraries
|
|
2
|
+
import * as Util from '../util/all';
|
|
3
|
+
import * as Context from '../context/all';
|
|
4
|
+
import * as LogAbstract from '../logabstract/all';
|
|
5
|
+
import * as FSM from '../fsm/all';
|
|
6
|
+
|
|
7
|
+
// App libraries
|
|
8
|
+
import { Environment } from './env';
|
|
9
|
+
import * as Storage from './storage';
|
|
10
|
+
|
|
11
|
+
export class DataBlob extends Storage.StorageBlob
|
|
12
|
+
{
|
|
13
|
+
constructor(env: Environment, params: Storage.BlobParams)
|
|
14
|
+
{
|
|
15
|
+
if (params.bucket == null) params.bucket = env.context.xflag('production') ? 'data' : 'data-dev';
|
|
16
|
+
super(env, params);
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
get env(): Environment { return this._env as Environment; }
|
|
20
|
+
|
|
21
|
+
get json(): any { return this.params.loadTo }
|
|
22
|
+
|
|
23
|
+
static createForJSON(env: Environment, id: string): DataBlob
|
|
24
|
+
{
|
|
25
|
+
let blob = new DataBlob(env, { id: id, loadToType: 'object' });
|
|
26
|
+
blob.startLoad(env.storageManager);
|
|
27
|
+
return blob;
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
static createForStream(env: Environment, id: string, bucket?: string): DataBlob
|
|
31
|
+
{
|
|
32
|
+
let blob = new DataBlob(env, { id: id, bucket: bucket, loadToType: 'stream' });
|
|
33
|
+
blob.startLoad(env.storageManager);
|
|
34
|
+
return blob;
|
|
35
|
+
}
|
|
36
|
+
}
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
// Shared libraries
|
|
2
|
+
import * as Context from '../context/all';
|
|
3
|
+
import * as FSM from '../fsm/all';
|
|
4
|
+
import * as LogAbstract from '../logabstract/all';
|
|
5
|
+
|
|
6
|
+
import * as Storage from './storage';
|
|
7
|
+
|
|
8
|
+
export interface Environment
|
|
9
|
+
{
|
|
10
|
+
context: Context.IContext;
|
|
11
|
+
log: LogAbstract.ILog;
|
|
12
|
+
fsmManager: FSM.FsmManager;
|
|
13
|
+
storageManager: Storage.StorageManager;
|
|
14
|
+
}
|
|
@@ -0,0 +1,63 @@
|
|
|
1
|
+
// Node
|
|
2
|
+
import * as zlib from 'zlib';
|
|
3
|
+
|
|
4
|
+
// Shared libraries
|
|
5
|
+
import * as Context from '../context/all';
|
|
6
|
+
import * as LogAbstract from '../logabstract/all';
|
|
7
|
+
import * as FSM from '../fsm/all';
|
|
8
|
+
|
|
9
|
+
// App libraries
|
|
10
|
+
import { Environment } from './env';
|
|
11
|
+
import * as Storage from './storage';
|
|
12
|
+
|
|
13
|
+
export class SplitsBlob extends Storage.StorageBlob
|
|
14
|
+
{
|
|
15
|
+
ls: { [key: string]: Storage.BlobProperties };
|
|
16
|
+
|
|
17
|
+
constructor(env: Environment, params: Storage.BlobParams)
|
|
18
|
+
{
|
|
19
|
+
if (params.bucket === undefined) params.bucket = env.context.xflag('production') ? 'splits' : 'splits-dev';
|
|
20
|
+
super(env, params);
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
get env(): Environment { return this._env as Environment; }
|
|
24
|
+
|
|
25
|
+
get collection(): any { return this.params.loadTo }
|
|
26
|
+
|
|
27
|
+
static createForLs(env: Environment): SplitsBlob
|
|
28
|
+
{
|
|
29
|
+
let blob = new SplitsBlob(env, { id: '' });
|
|
30
|
+
blob.startList(env.storageManager);
|
|
31
|
+
new FSM.FsmOnDone(env, blob.fsmList, (f: FSM.Fsm) => {
|
|
32
|
+
if (! f.iserror)
|
|
33
|
+
{
|
|
34
|
+
blob.ls = {};
|
|
35
|
+
blob.keys.forEach((k: string, i: number) => { blob.ls[k] = blob.props[i] });
|
|
36
|
+
}
|
|
37
|
+
});
|
|
38
|
+
return blob;
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
static createForUpload(env: Environment, id: string, collection: any): SplitsBlob
|
|
42
|
+
{
|
|
43
|
+
let params: Storage.BlobParams = {
|
|
44
|
+
id: id,
|
|
45
|
+
saveFromType: 'object',
|
|
46
|
+
saveFrom: collection,
|
|
47
|
+
ContentEncoding: 'gzip',
|
|
48
|
+
ContentType: 'application/json',
|
|
49
|
+
CacheControl: 'no-cache'
|
|
50
|
+
};
|
|
51
|
+
let blob = new SplitsBlob(env, params);
|
|
52
|
+
blob.setDirty();
|
|
53
|
+
blob.checkSave(env.storageManager);
|
|
54
|
+
return blob;
|
|
55
|
+
}
|
|
56
|
+
|
|
57
|
+
static createForDownload(env: Environment, id: string): SplitsBlob
|
|
58
|
+
{
|
|
59
|
+
let blob = new SplitsBlob(env, { id: id, loadToType: 'object' });
|
|
60
|
+
blob.startLoad(env.storageManager);
|
|
61
|
+
return blob;
|
|
62
|
+
}
|
|
63
|
+
}
|