@dra2020/baseclient 1.0.13 → 1.0.16
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/LICENSE +21 -0
- package/README.md +26 -0
- package/dist/all/all.d.ts +20 -0
- package/dist/baseclient.js +10121 -0
- package/dist/baseclient.js.map +1 -0
- package/dist/context/all.d.ts +1 -0
- package/dist/context/context.d.ts +13 -0
- package/dist/filterexpr/all.d.ts +1 -0
- package/dist/filterexpr/filterexpr.d.ts +67 -0
- package/dist/fsm/all.d.ts +1 -0
- package/dist/fsm/fsm.d.ts +119 -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/logabstract/all.d.ts +1 -0
- package/dist/logabstract/log.d.ts +26 -0
- package/dist/logclient/all.d.ts +1 -0
- package/dist/logclient/log.d.ts +6 -0
- package/dist/ot-editutil/all.d.ts +2 -0
- package/dist/ot-editutil/oteditutil.d.ts +14 -0
- package/dist/ot-editutil/otmaputil.d.ts +21 -0
- package/dist/ot-js/all.d.ts +9 -0
- package/dist/ot-js/otarray.d.ts +111 -0
- package/dist/ot-js/otclientengine.d.ts +38 -0
- package/dist/ot-js/otcomposite.d.ts +37 -0
- package/dist/ot-js/otcounter.d.ts +17 -0
- package/dist/ot-js/otengine.d.ts +22 -0
- package/dist/ot-js/otmap.d.ts +19 -0
- package/dist/ot-js/otserverengine.d.ts +38 -0
- package/dist/ot-js/otsession.d.ts +114 -0
- package/dist/ot-js/ottypes.d.ts +29 -0
- package/dist/poly/all.d.ts +15 -0
- package/dist/poly/blend.d.ts +1 -0
- package/dist/poly/boundbox.d.ts +16 -0
- package/dist/poly/cartesian.d.ts +5 -0
- package/dist/poly/graham-scan.d.ts +8 -0
- package/dist/poly/hash.d.ts +1 -0
- package/dist/poly/matrix.d.ts +24 -0
- package/dist/poly/minbound.d.ts +1 -0
- package/dist/poly/poly.d.ts +52 -0
- package/dist/poly/polybin.d.ts +5 -0
- package/dist/poly/polylabel.d.ts +7 -0
- package/dist/poly/polypack.d.ts +30 -0
- package/dist/poly/polyround.d.ts +1 -0
- package/dist/poly/polysimplify.d.ts +1 -0
- package/dist/poly/quad.d.ts +48 -0
- package/dist/poly/selfintersect.d.ts +1 -0
- package/dist/poly/shamos.d.ts +1 -0
- package/dist/poly/simplify.d.ts +2 -0
- package/dist/poly/topo.d.ts +46 -0
- package/dist/poly/union.d.ts +49 -0
- package/dist/util/all.d.ts +5 -0
- package/dist/util/bintrie.d.ts +93 -0
- package/dist/util/countedhash.d.ts +19 -0
- package/dist/util/gradient.d.ts +15 -0
- package/dist/util/indexedarray.d.ts +15 -0
- package/dist/util/util.d.ts +68 -0
- package/docs/context.md +2 -0
- package/docs/filterexpr.md +22 -0
- package/docs/fsm.md +243 -0
- package/docs/logabstract.md +2 -0
- package/docs/logclient.md +2 -0
- package/docs/ot-editutil.md +2 -0
- package/docs/ot-js.md +95 -0
- package/docs/poly.md +103 -0
- package/docs/util.md +2 -0
- package/lib/all/all.ts +21 -0
- package/lib/context/all.ts +1 -0
- package/lib/context/context.ts +82 -0
- package/lib/filterexpr/all.ts +1 -0
- package/lib/filterexpr/filterexpr.ts +699 -0
- package/lib/fsm/all.ts +1 -0
- package/lib/fsm/fsm.ts +559 -0
- package/lib/geo/all.ts +2 -0
- package/lib/geo/geo.ts +452 -0
- package/lib/geo/vfeature.ts +34 -0
- package/lib/logabstract/all.ts +1 -0
- package/lib/logabstract/log.ts +55 -0
- package/lib/logclient/all.ts +1 -0
- package/lib/logclient/log.ts +105 -0
- package/lib/ot-editutil/all.ts +2 -0
- package/lib/ot-editutil/oteditutil.ts +180 -0
- package/lib/ot-editutil/otmaputil.ts +209 -0
- package/lib/ot-js/all.ts +9 -0
- package/lib/ot-js/otarray.ts +1168 -0
- package/lib/ot-js/otclientengine.ts +327 -0
- package/lib/ot-js/otcomposite.ts +247 -0
- package/lib/ot-js/otcounter.ts +145 -0
- package/lib/ot-js/otengine.ts +71 -0
- package/lib/ot-js/otmap.ts +144 -0
- package/lib/ot-js/otserverengine.ts +329 -0
- package/lib/ot-js/otsession.ts +202 -0
- package/lib/ot-js/ottypes.ts +98 -0
- package/lib/poly/all.ts +15 -0
- package/lib/poly/blend.ts +27 -0
- package/lib/poly/boundbox.ts +102 -0
- package/lib/poly/cartesian.ts +130 -0
- package/lib/poly/graham-scan.ts +401 -0
- package/lib/poly/hash.ts +15 -0
- package/lib/poly/matrix.ts +309 -0
- package/lib/poly/minbound.ts +211 -0
- package/lib/poly/poly.ts +767 -0
- package/lib/poly/polybin.ts +218 -0
- package/lib/poly/polylabel.ts +204 -0
- package/lib/poly/polypack.ts +468 -0
- package/lib/poly/polyround.ts +30 -0
- package/lib/poly/polysimplify.ts +24 -0
- package/lib/poly/quad.ts +272 -0
- package/lib/poly/selfintersect.ts +87 -0
- package/lib/poly/shamos.ts +297 -0
- package/lib/poly/simplify.ts +119 -0
- package/lib/poly/topo.ts +510 -0
- package/lib/poly/union.ts +388 -0
- package/lib/util/all.ts +5 -0
- package/lib/util/bintrie.ts +603 -0
- package/lib/util/countedhash.ts +83 -0
- package/lib/util/gradient.ts +108 -0
- package/lib/util/indexedarray.ts +80 -0
- package/lib/util/util.ts +695 -0
- package/package.json +15 -16
|
@@ -0,0 +1,388 @@
|
|
|
1
|
+
import * as PC from 'polygon-clipping';
|
|
2
|
+
|
|
3
|
+
import * as Util from '../util/all';
|
|
4
|
+
import * as FSM from '../fsm/all';
|
|
5
|
+
|
|
6
|
+
import * as Poly from './poly';
|
|
7
|
+
import * as Q from './quad';
|
|
8
|
+
import * as PP from './polypack';
|
|
9
|
+
import * as PR from './polyround';
|
|
10
|
+
|
|
11
|
+
// Confusion on how polygon-clipping exposes its interface - be flexible
|
|
12
|
+
let _union: any = undefined;
|
|
13
|
+
let _difference: any = undefined;
|
|
14
|
+
let _intersection: any = undefined;
|
|
15
|
+
let anyPC: any = PC;
|
|
16
|
+
if (anyPC.union) _union = anyPC.union;
|
|
17
|
+
else if (anyPC.default && anyPC.default.union) _union = anyPC.default.union;
|
|
18
|
+
if (_union === undefined) throw 'Unable to load union function from polygon-clipping';
|
|
19
|
+
if (anyPC.difference) _difference = anyPC.difference;
|
|
20
|
+
else if (anyPC.default && anyPC.default.difference) _difference = anyPC.default.difference;
|
|
21
|
+
if (_difference === undefined) throw 'Unable to load difference function from polygon-clipping';
|
|
22
|
+
if (anyPC.intersection) _intersection = anyPC.intersection;
|
|
23
|
+
else if (anyPC.default && anyPC.default.intersection) _intersection = anyPC.default.intersection;
|
|
24
|
+
if (_intersection === undefined) throw 'Unable to load intersection function from polygon-clipping';
|
|
25
|
+
|
|
26
|
+
const FSM_COMPUTING = FSM.FSM_CUSTOM1;
|
|
27
|
+
|
|
28
|
+
function unpackCoords(buffer: Float64Array, offset: number, nPoints: number): any
|
|
29
|
+
{
|
|
30
|
+
let c: any[] = [];
|
|
31
|
+
|
|
32
|
+
let end = offset + nPoints*2;
|
|
33
|
+
for (; offset < end; offset += 2)
|
|
34
|
+
c.push([buffer[offset], buffer[offset+1]]);
|
|
35
|
+
return [ c ];
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
export function polyIntersects(p1: any, p2: any): boolean
|
|
39
|
+
{
|
|
40
|
+
let pp1 = Poly.polyNormalize(p1);
|
|
41
|
+
let pp2 = Poly.polyNormalize(p2);
|
|
42
|
+
let bIntersects: boolean = false;
|
|
43
|
+
|
|
44
|
+
PP.polyPackEachRing(pp1, (buffer1: Float64Array, iPoly1: number, iRing1: number, iOffset1: number, nPoints1: number) => {
|
|
45
|
+
if (iRing1 == 0)
|
|
46
|
+
{
|
|
47
|
+
let c1 = unpackCoords(buffer1, iOffset1, nPoints1);
|
|
48
|
+
PP.polyPackEachRing(pp2, (buffer2: Float64Array, iPoly2: number, iRing2: number, iOffset2: number, nPoints2: number) => {
|
|
49
|
+
if (iRing2 == 0)
|
|
50
|
+
{
|
|
51
|
+
let c2 = unpackCoords(buffer2, iOffset2, nPoints2);
|
|
52
|
+
let result = _intersection(c1, c2);
|
|
53
|
+
if (result && result.length > 0)
|
|
54
|
+
bIntersects = true;
|
|
55
|
+
}
|
|
56
|
+
});
|
|
57
|
+
}
|
|
58
|
+
});
|
|
59
|
+
return bIntersects;
|
|
60
|
+
}
|
|
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
|
+
class FsmDifference extends FSM.Fsm
|
|
80
|
+
{
|
|
81
|
+
accum: any;
|
|
82
|
+
polys: any[];
|
|
83
|
+
work: Q.WorkDone;
|
|
84
|
+
|
|
85
|
+
constructor(env: FSM.FsmEnvironment, accum?: any, polys?: any[])
|
|
86
|
+
{
|
|
87
|
+
super(env);
|
|
88
|
+
this.work = { nUnion: 0, nDifference: 0, ms: 0 };
|
|
89
|
+
this.initialize(accum, polys);
|
|
90
|
+
}
|
|
91
|
+
|
|
92
|
+
initialize(accum: any, polys: any[])
|
|
93
|
+
{
|
|
94
|
+
this.accum = accum;
|
|
95
|
+
this.polys = polys;
|
|
96
|
+
if (polys == null || polys.length == 0)
|
|
97
|
+
this.setState(FSM.FSM_DONE);
|
|
98
|
+
else
|
|
99
|
+
{
|
|
100
|
+
this.work.nDifference = polys.length;
|
|
101
|
+
this.setState(FSM.FSM_STARTING);
|
|
102
|
+
}
|
|
103
|
+
}
|
|
104
|
+
|
|
105
|
+
cancel(): void
|
|
106
|
+
{
|
|
107
|
+
this.accum = null;
|
|
108
|
+
this.polys = null;
|
|
109
|
+
this.setState(FSM.FSM_DONE);
|
|
110
|
+
}
|
|
111
|
+
|
|
112
|
+
get result(): any
|
|
113
|
+
{
|
|
114
|
+
return this.accum;
|
|
115
|
+
}
|
|
116
|
+
|
|
117
|
+
tick(): void
|
|
118
|
+
{
|
|
119
|
+
if (this.ready)
|
|
120
|
+
{
|
|
121
|
+
switch (this.state)
|
|
122
|
+
{
|
|
123
|
+
case FSM.FSM_STARTING:
|
|
124
|
+
if (this.polys == null)
|
|
125
|
+
this.setState(FSM.FSM_DONE);
|
|
126
|
+
else
|
|
127
|
+
this.setState(FSM_COMPUTING);
|
|
128
|
+
break;
|
|
129
|
+
|
|
130
|
+
case FSM_COMPUTING:
|
|
131
|
+
let elapsed = new Util.Elapsed();
|
|
132
|
+
this.accum = PR.polyRound(_difference(this.accum, this.polys));
|
|
133
|
+
this.work.ms = elapsed.ms();
|
|
134
|
+
this.polys = null;
|
|
135
|
+
this.setState(FSM.FSM_DONE);
|
|
136
|
+
break;
|
|
137
|
+
}
|
|
138
|
+
}
|
|
139
|
+
}
|
|
140
|
+
}
|
|
141
|
+
|
|
142
|
+
const FSM_UNION = FSM.FSM_CUSTOM1;
|
|
143
|
+
const FSM_DIFFERENCE = FSM.FSM_CUSTOM2;
|
|
144
|
+
|
|
145
|
+
function coords(f: any): any
|
|
146
|
+
{
|
|
147
|
+
return (f.geometry !== undefined) ? (f.geometry.packed !== undefined ? f.geometry.packed : f.geometry.coordinates) : f;
|
|
148
|
+
}
|
|
149
|
+
|
|
150
|
+
class FsmIncrementalUnion extends FSM.Fsm
|
|
151
|
+
{
|
|
152
|
+
options: Poly.TickOptions;
|
|
153
|
+
key: any;
|
|
154
|
+
map: any; // { [geoid: string]: Feature }
|
|
155
|
+
result: any;
|
|
156
|
+
lastCompleteMap: any;
|
|
157
|
+
lastCompleteResult: any;
|
|
158
|
+
toSub: any[];
|
|
159
|
+
fsmUnion: Q.FsmQuadTree;
|
|
160
|
+
fsmDifference: FsmDifference;
|
|
161
|
+
work: Q.WorkDone;
|
|
162
|
+
|
|
163
|
+
constructor(env: FSM.FsmEnvironment, options: Poly.TickOptions, key: any, map?: any)
|
|
164
|
+
{
|
|
165
|
+
super(env);
|
|
166
|
+
this.options = options;
|
|
167
|
+
this.key = key;
|
|
168
|
+
this.result = null;
|
|
169
|
+
this.map = null;
|
|
170
|
+
this.lastCompleteResult = null;
|
|
171
|
+
this.lastCompleteMap = null;
|
|
172
|
+
this.toSub = null;
|
|
173
|
+
this.fsmUnion = null;
|
|
174
|
+
this.fsmDifference = null;
|
|
175
|
+
if (map) this.recompute(map);
|
|
176
|
+
}
|
|
177
|
+
|
|
178
|
+
matches(key: any): boolean
|
|
179
|
+
{
|
|
180
|
+
return Util.shallowEqual(this.key, key);
|
|
181
|
+
}
|
|
182
|
+
|
|
183
|
+
recompute(map: any): void
|
|
184
|
+
{
|
|
185
|
+
// If a computation is in progress, just cancel and restart
|
|
186
|
+
if (this.fsmUnion)
|
|
187
|
+
{
|
|
188
|
+
this.fsmUnion.cancel();
|
|
189
|
+
this.fsmUnion = null;
|
|
190
|
+
this.result = this.lastCompleteResult;
|
|
191
|
+
this.map = this.lastCompleteMap;
|
|
192
|
+
}
|
|
193
|
+
if (this.fsmDifference)
|
|
194
|
+
{
|
|
195
|
+
this.fsmDifference.cancel();
|
|
196
|
+
this.fsmDifference = null;
|
|
197
|
+
this.result = this.lastCompleteResult;
|
|
198
|
+
this.map = this.lastCompleteMap;
|
|
199
|
+
}
|
|
200
|
+
|
|
201
|
+
let polys: any[] = [];
|
|
202
|
+
if (this.result == null || Util.isEmpty(map))
|
|
203
|
+
{
|
|
204
|
+
// Starting from scratch
|
|
205
|
+
this.toSub = null;
|
|
206
|
+
for (let id in map) if (map.hasOwnProperty(id))
|
|
207
|
+
polys.push(coords(map[id]));
|
|
208
|
+
}
|
|
209
|
+
else
|
|
210
|
+
{
|
|
211
|
+
// We have the result of a previous computation - compute a difference since we assume
|
|
212
|
+
// that is cheaper (often only one or two polygons added or removed).
|
|
213
|
+
let id: string;
|
|
214
|
+
|
|
215
|
+
// To add (polygons in new map did not occur in old map)
|
|
216
|
+
polys.push(this.result);
|
|
217
|
+
this.result = null;
|
|
218
|
+
for (id in map) if (map.hasOwnProperty(id) && this.map[id] === undefined)
|
|
219
|
+
polys.push(coords(map[id]));
|
|
220
|
+
|
|
221
|
+
// To sub
|
|
222
|
+
this.toSub = [];
|
|
223
|
+
for (id in this.map) if (this.map.hasOwnProperty(id) && map[id] === undefined)
|
|
224
|
+
{
|
|
225
|
+
let c = PP.polyUnpack(coords(this.map[id]));
|
|
226
|
+
if (Util.depthof(c) === 5)
|
|
227
|
+
for (let i: number = 0; i < c.length; i++)
|
|
228
|
+
this.toSub.push(c[i]);
|
|
229
|
+
else
|
|
230
|
+
this.toSub.push(c);
|
|
231
|
+
}
|
|
232
|
+
if (this.toSub.length == 0)
|
|
233
|
+
this.toSub = null;
|
|
234
|
+
}
|
|
235
|
+
|
|
236
|
+
// Short-circuit when no work to be done
|
|
237
|
+
if (polys.length == 1 && this.toSub == null && this.lastCompleteResult)
|
|
238
|
+
{
|
|
239
|
+
this.work = { nUnion: 0, nDifference: 0, ms: 0 };
|
|
240
|
+
this.result = this.lastCompleteResult;
|
|
241
|
+
this.map = this.lastCompleteMap;
|
|
242
|
+
this.setState(FSM.FSM_DONE);
|
|
243
|
+
}
|
|
244
|
+
else
|
|
245
|
+
{
|
|
246
|
+
this.work = { nUnion: polys.length - 1, nDifference: this.toSub ? this.toSub.length : 0, ms: 0 };
|
|
247
|
+
this.fsmUnion = new Q.FsmQuadTree(this.env, this.options, polys);
|
|
248
|
+
this.waitOn(this.fsmUnion);
|
|
249
|
+
this.setState(FSM_UNION);
|
|
250
|
+
this.map = map;
|
|
251
|
+
}
|
|
252
|
+
}
|
|
253
|
+
|
|
254
|
+
cancel(): void
|
|
255
|
+
{
|
|
256
|
+
if (this.fsmUnion)
|
|
257
|
+
{
|
|
258
|
+
this.fsmUnion.cancel();
|
|
259
|
+
this.fsmUnion = null;
|
|
260
|
+
}
|
|
261
|
+
if (this.fsmDifference)
|
|
262
|
+
{
|
|
263
|
+
this.fsmDifference.cancel();
|
|
264
|
+
this.fsmDifference = null;
|
|
265
|
+
}
|
|
266
|
+
this.result = null;
|
|
267
|
+
this.map = null;
|
|
268
|
+
this.lastCompleteResult = null;
|
|
269
|
+
this.lastCompleteMap = null;
|
|
270
|
+
this.setState(FSM.FSM_DONE);
|
|
271
|
+
}
|
|
272
|
+
|
|
273
|
+
tick(): void
|
|
274
|
+
{
|
|
275
|
+
if (this.ready)
|
|
276
|
+
{
|
|
277
|
+
switch (this.state)
|
|
278
|
+
{
|
|
279
|
+
case FSM.FSM_STARTING:
|
|
280
|
+
// never initialized to do work (see recompute())
|
|
281
|
+
this.setState(FSM.FSM_DONE);
|
|
282
|
+
break;
|
|
283
|
+
|
|
284
|
+
case FSM_UNION:
|
|
285
|
+
if (this.fsmUnion)
|
|
286
|
+
this.work.ms += this.fsmUnion.work.ms;
|
|
287
|
+
this.fsmDifference = new FsmDifference(this.env, this.fsmUnion.result, this.toSub);
|
|
288
|
+
this.waitOn(this.fsmDifference);
|
|
289
|
+
this.toSub = null;
|
|
290
|
+
this.fsmUnion = null;
|
|
291
|
+
this.setState(FSM_DIFFERENCE);
|
|
292
|
+
break;
|
|
293
|
+
|
|
294
|
+
case FSM_DIFFERENCE:
|
|
295
|
+
this.result = this.fsmDifference.result;
|
|
296
|
+
this.work.ms += this.fsmDifference.work.ms;
|
|
297
|
+
this.lastCompleteResult = this.result;
|
|
298
|
+
this.lastCompleteMap = this.map;
|
|
299
|
+
this.fsmDifference = null;
|
|
300
|
+
this.setState(FSM.FSM_DONE);
|
|
301
|
+
break;
|
|
302
|
+
}
|
|
303
|
+
}
|
|
304
|
+
}
|
|
305
|
+
}
|
|
306
|
+
|
|
307
|
+
export interface UnionResult
|
|
308
|
+
{
|
|
309
|
+
key: any;
|
|
310
|
+
poly: any;
|
|
311
|
+
work: Q.WorkDone;
|
|
312
|
+
}
|
|
313
|
+
|
|
314
|
+
export class FsmUnion extends FSM.Fsm
|
|
315
|
+
{
|
|
316
|
+
options: Poly.TickOptions;
|
|
317
|
+
unions: FsmIncrementalUnion[];
|
|
318
|
+
work: Q.WorkDone;
|
|
319
|
+
|
|
320
|
+
constructor(env: FSM.FsmEnvironment, options?: Poly.TickOptions)
|
|
321
|
+
{
|
|
322
|
+
super(env);
|
|
323
|
+
this.options = Util.shallowAssignImmutable(Poly.DefaultTickOptions, options);
|
|
324
|
+
this.unions = [];
|
|
325
|
+
this.work = { nUnion: 0, nDifference: 0, ms: 0 };
|
|
326
|
+
}
|
|
327
|
+
|
|
328
|
+
get result(): UnionResult[]
|
|
329
|
+
{
|
|
330
|
+
if (this.unions.length > 0 && this.state === FSM.FSM_DONE)
|
|
331
|
+
return this.unions.map((i: FsmIncrementalUnion) => ({ key: i.key, poly: i.result, work: i.work }) );
|
|
332
|
+
else
|
|
333
|
+
return null;
|
|
334
|
+
}
|
|
335
|
+
|
|
336
|
+
cancel(): void
|
|
337
|
+
{
|
|
338
|
+
this.unions.forEach((i: FsmIncrementalUnion) => {
|
|
339
|
+
i.cancel();
|
|
340
|
+
});
|
|
341
|
+
this.unions = [];
|
|
342
|
+
this.setState(FSM.FSM_DONE);
|
|
343
|
+
}
|
|
344
|
+
|
|
345
|
+
cancelOne(key: any): void
|
|
346
|
+
{
|
|
347
|
+
for (let i = 0; i < this.unions.length; i++)
|
|
348
|
+
{
|
|
349
|
+
let u = this.unions[i];
|
|
350
|
+
if (u.matches(key))
|
|
351
|
+
{
|
|
352
|
+
u.cancel();
|
|
353
|
+
return;
|
|
354
|
+
}
|
|
355
|
+
}
|
|
356
|
+
}
|
|
357
|
+
|
|
358
|
+
recompute(key: any, map: any): void
|
|
359
|
+
{
|
|
360
|
+
let fsm: FsmIncrementalUnion = this.unions.find((i: FsmIncrementalUnion) => i.matches(key));
|
|
361
|
+
if (fsm == null)
|
|
362
|
+
{
|
|
363
|
+
fsm = new FsmIncrementalUnion(this.env, this.options, key, map);
|
|
364
|
+
this.unions.push(fsm);
|
|
365
|
+
}
|
|
366
|
+
else
|
|
367
|
+
fsm.recompute(map);
|
|
368
|
+
this.work = { nUnion: 0, nDifference: 0, ms: 0 };
|
|
369
|
+
this.unions.forEach((u) => { this.work.nUnion += u.work.nUnion; this.work.nDifference += u.work.nDifference });
|
|
370
|
+
this.waitOn(fsm);
|
|
371
|
+
this.setState(FSM_COMPUTING);
|
|
372
|
+
}
|
|
373
|
+
|
|
374
|
+
tick(): void
|
|
375
|
+
{
|
|
376
|
+
if (this.ready)
|
|
377
|
+
{
|
|
378
|
+
switch (this.state)
|
|
379
|
+
{
|
|
380
|
+
case FSM.FSM_STARTING:
|
|
381
|
+
case FSM_COMPUTING:
|
|
382
|
+
if (this.unions) this.unions.forEach((u) => { this.work.ms += u.work.ms });
|
|
383
|
+
this.setState(FSM.FSM_DONE);
|
|
384
|
+
break;
|
|
385
|
+
}
|
|
386
|
+
}
|
|
387
|
+
}
|
|
388
|
+
}
|