@dra2020/baseclient 1.0.14 → 1.0.17
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 +5 -16
- package/dist/all/all.d.ts +2 -18
- package/dist/baseclient.js +1309 -173
- package/dist/baseclient.js.map +1 -1
- package/dist/filterexpr/filterexpr.d.ts +3 -0
- package/dist/fsm/fsm.d.ts +1 -0
- package/dist/geo/all.d.ts +2 -0
- package/dist/geo/geo.d.ts +67 -0
- package/dist/geo/vfeature.d.ts +4 -0
- package/dist/ot-js/otsession.d.ts +3 -0
- package/dist/poly/union.d.ts +1 -0
- package/docs/filterexpr.md +22 -0
- package/lib/all/all.ts +2 -22
- package/lib/filterexpr/filterexpr.ts +79 -5
- package/lib/fsm/fsm.ts +12 -2
- package/lib/geo/all.ts +2 -0
- package/lib/geo/geo.ts +452 -0
- package/lib/geo/vfeature.ts +34 -0
- package/lib/ot-js/otsession.ts +4 -1
- package/lib/poly/hash.ts +1 -1
- package/lib/poly/polybin.ts +5 -4
- package/lib/poly/polypack.ts +16 -4
- package/lib/poly/topo.ts +26 -41
- package/lib/poly/union.ts +17 -0
- package/package.json +9 -10
- package/dist/all/allclient.d.ts +0 -18
- package/dist/base.js +0 -33010
- package/dist/base.js.map +0 -1
- package/dist/dbabstract/all.d.ts +0 -1
- package/dist/dbabstract/db.d.ts +0 -83
- package/dist/dbdynamo/all.d.ts +0 -1
- package/dist/dbdynamo/dbdynamo.d.ts +0 -190
- package/dist/fsmfile/all.d.ts +0 -1
- package/dist/fsmfile/fsmfile.d.ts +0 -47
- package/dist/jsonstream/all.d.ts +0 -1
- package/dist/jsonstream/jsonstream.d.ts +0 -130
- package/dist/lambda/all.d.ts +0 -1
- package/dist/lambda/env.d.ts +0 -10
- package/dist/lambda/lambda.d.ts +0 -18
- package/dist/logserver/all.d.ts +0 -5
- package/dist/logserver/log.d.ts +0 -11
- package/dist/logserver/logaccum.d.ts +0 -154
- package/dist/logserver/logblob.d.ts +0 -24
- package/dist/logserver/logconcat.d.ts +0 -55
- package/dist/logserver/logkey.d.ts +0 -28
- package/dist/memsqs/all.d.ts +0 -4
- package/dist/memsqs/client.d.ts +0 -13
- package/dist/memsqs/loopback.d.ts +0 -11
- package/dist/memsqs/orderedlist.d.ts +0 -19
- package/dist/memsqs/queue.d.ts +0 -84
- package/dist/memsqs/server.d.ts +0 -37
- package/dist/storage/all.d.ts +0 -4
- package/dist/storage/datablob.d.ts +0 -9
- package/dist/storage/env.d.ts +0 -10
- package/dist/storage/splitsblob.d.ts +0 -13
- package/dist/storage/storage.d.ts +0 -166
- package/dist/storages3/all.d.ts +0 -1
- package/dist/storages3/s3.d.ts +0 -62
- package/docs/dbabstract.md +0 -2
- package/docs/dbdynamo.md +0 -2
- package/docs/fsmfile.md +0 -2
- package/docs/jsonstream.md +0 -44
- package/docs/lambda.md +0 -2
- package/docs/logserver.md +0 -2
- package/docs/storage.md +0 -2
- package/docs/storages3.md +0 -2
- package/lib/all/allclient.ts +0 -19
- package/lib/dbabstract/all.ts +0 -1
- package/lib/dbabstract/db.ts +0 -246
- package/lib/dbdynamo/all.ts +0 -1
- package/lib/dbdynamo/dbdynamo.ts +0 -1551
- package/lib/fsmfile/all.ts +0 -1
- package/lib/fsmfile/fsmfile.ts +0 -236
- package/lib/jsonstream/all.ts +0 -1
- package/lib/jsonstream/jsonstream.ts +0 -940
- package/lib/lambda/all.ts +0 -1
- package/lib/lambda/env.ts +0 -13
- package/lib/lambda/lambda.ts +0 -120
- package/lib/logserver/all.ts +0 -5
- package/lib/logserver/log.ts +0 -565
- package/lib/logserver/logaccum.ts +0 -1445
- package/lib/logserver/logblob.ts +0 -84
- package/lib/logserver/logconcat.ts +0 -313
- package/lib/logserver/logkey.ts +0 -125
- package/lib/memsqs/all.ts +0 -4
- package/lib/memsqs/client.ts +0 -268
- package/lib/memsqs/loopback.ts +0 -64
- package/lib/memsqs/orderedlist.ts +0 -74
- package/lib/memsqs/queue.ts +0 -395
- package/lib/memsqs/server.ts +0 -262
- package/lib/storage/all.ts +0 -4
- package/lib/storage/datablob.ts +0 -36
- package/lib/storage/env.ts +0 -14
- package/lib/storage/splitsblob.ts +0 -63
- package/lib/storage/storage.ts +0 -604
- package/lib/storages3/all.ts +0 -1
- package/lib/storages3/s3.ts +0 -576
package/lib/poly/topo.ts
CHANGED
|
@@ -59,19 +59,6 @@ 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
|
-
|
|
75
62
|
// Convert degenerate MultiPolygon to Polygon
|
|
76
63
|
if (multiPoly.length == 1)
|
|
77
64
|
{
|
|
@@ -80,6 +67,15 @@ function correctGeometry(f: any): any
|
|
|
80
67
|
}
|
|
81
68
|
}
|
|
82
69
|
|
|
70
|
+
if (f && f.geometry && f.geometry.type === 'Point' && f.geometry.coordinates)
|
|
71
|
+
{
|
|
72
|
+
while (Array.isArray(f.geometry.coordinates[0]))
|
|
73
|
+
f.geometry.coordinates = f.geometry.coordinates[0];
|
|
74
|
+
}
|
|
75
|
+
else
|
|
76
|
+
// TopoJSON does not guarantee proper winding order which messes up later processing. Fix it.
|
|
77
|
+
P.featureRewind(f);
|
|
78
|
+
|
|
83
79
|
return f;
|
|
84
80
|
}
|
|
85
81
|
|
|
@@ -194,6 +190,11 @@ export interface SimplifyOptions
|
|
|
194
190
|
|
|
195
191
|
const DefaultSimplifyOptions: SimplifyOptions = { minArea: 500 };
|
|
196
192
|
|
|
193
|
+
function log(s: string): void
|
|
194
|
+
{
|
|
195
|
+
//console.log(s);
|
|
196
|
+
}
|
|
197
|
+
|
|
197
198
|
//
|
|
198
199
|
// topoSimplifyCollection:
|
|
199
200
|
// This implements our simplification strategy for block/precinct level shapes. The basic idea is to
|
|
@@ -218,10 +219,10 @@ export function topoSimplifyCollection(col: any, options?: SimplifyOptions): any
|
|
|
218
219
|
let elapsedTotal = new Util.Elapsed();
|
|
219
220
|
let elapsed = new Util.Elapsed();
|
|
220
221
|
let topo = topoFromCollection(col);
|
|
221
|
-
|
|
222
|
+
log(`topoSimplifyCollection: fromCollection: ${Math.round(elapsed.ms())}ms`);
|
|
222
223
|
elapsed.start();
|
|
223
224
|
topo = TopoSimplify.presimplify(topo, TopoSimplify['sphericalTriangleArea']);
|
|
224
|
-
|
|
225
|
+
log(`topoSimplifyCollection: presimplify: ${Math.round(elapsed.ms())}ms`);
|
|
225
226
|
elapsed.start();
|
|
226
227
|
|
|
227
228
|
// Keep iterating on removing simplification from degenerate shapes
|
|
@@ -240,6 +241,11 @@ export function topoSimplifyCollection(col: any, options?: SimplifyOptions): any
|
|
|
240
241
|
col.features.forEach((f: any) => {
|
|
241
242
|
let oOld: any = topo.objects[f.properties.id];
|
|
242
243
|
let oNew: any = testtopo.objects[f.properties.id];
|
|
244
|
+
|
|
245
|
+
// Ignore points
|
|
246
|
+
if (f.geometry && f.geometry.type === 'Point')
|
|
247
|
+
keepTiny.set(f, f);
|
|
248
|
+
|
|
243
249
|
if (! keepTiny.has(f))
|
|
244
250
|
{
|
|
245
251
|
// Walk through each polygon of a multipolygon separately since I may have a large non-degenerate
|
|
@@ -286,13 +292,13 @@ export function topoSimplifyCollection(col: any, options?: SimplifyOptions): any
|
|
|
286
292
|
}
|
|
287
293
|
}
|
|
288
294
|
});
|
|
289
|
-
|
|
295
|
+
log(`topoSimplifyCollection: pass ${nTries}: ${nBad} (${nTiny} tiny) of ${col.features.length} features are degenerate`);
|
|
290
296
|
|
|
291
297
|
// If not making progress, keep more points
|
|
292
298
|
if (nBad >= nBadLast)
|
|
293
299
|
{
|
|
294
300
|
keepweight /= 10;
|
|
295
|
-
|
|
301
|
+
log(`topoSimplifyCollection: pass ${nTries}: reducing weight limit to ${keepweight}`);
|
|
296
302
|
}
|
|
297
303
|
nBadLast = nBad;
|
|
298
304
|
|
|
@@ -308,7 +314,7 @@ export function topoSimplifyCollection(col: any, options?: SimplifyOptions): any
|
|
|
308
314
|
nTries++;
|
|
309
315
|
}
|
|
310
316
|
|
|
311
|
-
|
|
317
|
+
log(`topoSimplifyCollection: total elapsed time: ${bigTimeString(elapsedTotal.ms())}`);
|
|
312
318
|
|
|
313
319
|
return col;
|
|
314
320
|
}
|
|
@@ -318,28 +324,7 @@ export function topoMerge(topo: Topo, geoids: string[]): any
|
|
|
318
324
|
if (geoids == null || geoids.length == 0) return null;
|
|
319
325
|
let objects: any[] = [];
|
|
320
326
|
geoids.forEach((geoid) => objects.push(topo.objects[geoid]));
|
|
321
|
-
|
|
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;
|
|
327
|
+
return correctGeometry({ type: 'Feature', properties: {}, geometry: TopoClient.merge(topo, objects) });
|
|
343
328
|
}
|
|
344
329
|
|
|
345
330
|
export function topoMergeFeatures(topo: Topo, features: any[]): any
|
|
@@ -392,7 +377,7 @@ class FsmIncrementalUnion extends FSM.Fsm
|
|
|
392
377
|
let values = Object.values(map);
|
|
393
378
|
this.work = { nUnion: values.length, nDifference: 0, ms: 0 };
|
|
394
379
|
let elapsed = new Util.Elapsed();
|
|
395
|
-
this.result = topoMergeFeatures(this.key.
|
|
380
|
+
this.result = topoMergeFeatures(this.key.multi.allTopo(), values);
|
|
396
381
|
this.work.ms = elapsed.ms();
|
|
397
382
|
this.map = map;
|
|
398
383
|
}
|
package/lib/poly/union.ts
CHANGED
|
@@ -59,6 +59,23 @@ 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
|
+
|
|
62
79
|
class FsmDifference extends FSM.Fsm
|
|
63
80
|
{
|
|
64
81
|
accum: any;
|
package/package.json
CHANGED
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@dra2020/baseclient",
|
|
3
|
-
"version": "1.0.
|
|
3
|
+
"version": "1.0.17",
|
|
4
4
|
"description": "Utility functions for Javascript projects.",
|
|
5
5
|
"main": "dist/baseclient.js",
|
|
6
|
-
"types": "dist/all/
|
|
6
|
+
"types": "./dist/all/all.d.ts",
|
|
7
7
|
"scripts": {
|
|
8
8
|
"test": "echo \"No test defined.\"",
|
|
9
9
|
"build": "webpack",
|
|
@@ -16,7 +16,7 @@
|
|
|
16
16
|
],
|
|
17
17
|
"repository": {
|
|
18
18
|
"type": "git",
|
|
19
|
-
"url": "git+https://github.com/dra2020/
|
|
19
|
+
"url": "git+https://github.com/dra2020/baseclient.git"
|
|
20
20
|
},
|
|
21
21
|
"keywords": [
|
|
22
22
|
"Typescript"
|
|
@@ -24,26 +24,25 @@
|
|
|
24
24
|
"author": "Terry Crowley",
|
|
25
25
|
"license": "MIT",
|
|
26
26
|
"bugs": {
|
|
27
|
-
"url": "https://github.com/dra2020/
|
|
27
|
+
"url": "https://github.com/dra2020/baseclient/issues"
|
|
28
28
|
},
|
|
29
|
-
"homepage": "https://github.com/dra2020/
|
|
29
|
+
"homepage": "https://github.com/dra2020/baseclient#readme",
|
|
30
30
|
"devDependencies": {
|
|
31
31
|
"@types/diff-match-patch": "^1.0.32",
|
|
32
32
|
"@types/geojson": "^7946.0.7",
|
|
33
33
|
"@types/node": "12.7.2",
|
|
34
34
|
"@types/object-hash": "^1.3.4",
|
|
35
|
-
"source-map-loader": "^
|
|
36
|
-
"ts-loader": "^8.0.
|
|
35
|
+
"source-map-loader": "^2.0.0",
|
|
36
|
+
"ts-loader": "^8.0.14",
|
|
37
37
|
"tsify": "^5.0.2",
|
|
38
38
|
"typescript": "^4.1.3",
|
|
39
|
-
"webpack": "^5.
|
|
40
|
-
"webpack-cli": "^4.
|
|
39
|
+
"webpack": "^5.15.0",
|
|
40
|
+
"webpack-cli": "^4.4.0"
|
|
41
41
|
},
|
|
42
42
|
"dependencies": {
|
|
43
43
|
"@dra2020/topojson-client": "^3.2.7",
|
|
44
44
|
"@dra2020/topojson-server": "^3.0.103",
|
|
45
45
|
"@dra2020/topojson-simplify": "^3.0.102",
|
|
46
|
-
"aws-sdk": "^2.825.0",
|
|
47
46
|
"diff-match-patch": "^1.0.5",
|
|
48
47
|
"geojson": "^0.5.0",
|
|
49
48
|
"object-hash": "^2.1.1",
|
package/dist/all/allclient.d.ts
DELETED
|
@@ -1,18 +0,0 @@
|
|
|
1
|
-
import * as Util from '../util/all';
|
|
2
|
-
export { Util };
|
|
3
|
-
import * as Context from '../context/all';
|
|
4
|
-
export { Context };
|
|
5
|
-
import * as FSM from '../fsm/all';
|
|
6
|
-
export { FSM };
|
|
7
|
-
import * as Poly from '../poly/all';
|
|
8
|
-
export { Poly };
|
|
9
|
-
import * as LogAbstract from '../logabstract/all';
|
|
10
|
-
export { LogAbstract };
|
|
11
|
-
import * as LogClient from '../logclient/all';
|
|
12
|
-
export { LogClient };
|
|
13
|
-
import * as OT from '../ot-js/all';
|
|
14
|
-
export { OT };
|
|
15
|
-
import * as OTE from '../ot-editutil/all';
|
|
16
|
-
export { OTE };
|
|
17
|
-
import { FilterExpr } from '../filterexpr/all';
|
|
18
|
-
export { FilterExpr };
|