@dra2020/baseclient 1.0.10 → 1.0.13

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.
Files changed (120) hide show
  1. package/package.json +16 -15
  2. package/LICENSE +0 -21
  3. package/README.md +0 -26
  4. package/dist/all/all.d.ts +0 -20
  5. package/dist/baseclient.js +0 -10103
  6. package/dist/baseclient.js.map +0 -1
  7. package/dist/context/all.d.ts +0 -1
  8. package/dist/context/context.d.ts +0 -13
  9. package/dist/filterexpr/all.d.ts +0 -1
  10. package/dist/filterexpr/filterexpr.d.ts +0 -67
  11. package/dist/fsm/all.d.ts +0 -1
  12. package/dist/fsm/fsm.d.ts +0 -119
  13. package/dist/geo/all.d.ts +0 -2
  14. package/dist/geo/geo.d.ts +0 -67
  15. package/dist/geo/vfeature.d.ts +0 -4
  16. package/dist/logabstract/all.d.ts +0 -1
  17. package/dist/logabstract/log.d.ts +0 -26
  18. package/dist/logclient/all.d.ts +0 -1
  19. package/dist/logclient/log.d.ts +0 -6
  20. package/dist/ot-editutil/all.d.ts +0 -2
  21. package/dist/ot-editutil/oteditutil.d.ts +0 -14
  22. package/dist/ot-editutil/otmaputil.d.ts +0 -21
  23. package/dist/ot-js/all.d.ts +0 -9
  24. package/dist/ot-js/otarray.d.ts +0 -111
  25. package/dist/ot-js/otclientengine.d.ts +0 -38
  26. package/dist/ot-js/otcomposite.d.ts +0 -37
  27. package/dist/ot-js/otcounter.d.ts +0 -17
  28. package/dist/ot-js/otengine.d.ts +0 -22
  29. package/dist/ot-js/otmap.d.ts +0 -19
  30. package/dist/ot-js/otserverengine.d.ts +0 -38
  31. package/dist/ot-js/otsession.d.ts +0 -113
  32. package/dist/ot-js/ottypes.d.ts +0 -29
  33. package/dist/poly/all.d.ts +0 -15
  34. package/dist/poly/blend.d.ts +0 -1
  35. package/dist/poly/boundbox.d.ts +0 -16
  36. package/dist/poly/cartesian.d.ts +0 -5
  37. package/dist/poly/graham-scan.d.ts +0 -8
  38. package/dist/poly/hash.d.ts +0 -1
  39. package/dist/poly/matrix.d.ts +0 -24
  40. package/dist/poly/minbound.d.ts +0 -1
  41. package/dist/poly/poly.d.ts +0 -52
  42. package/dist/poly/polybin.d.ts +0 -5
  43. package/dist/poly/polylabel.d.ts +0 -7
  44. package/dist/poly/polypack.d.ts +0 -30
  45. package/dist/poly/polyround.d.ts +0 -1
  46. package/dist/poly/polysimplify.d.ts +0 -1
  47. package/dist/poly/quad.d.ts +0 -48
  48. package/dist/poly/selfintersect.d.ts +0 -1
  49. package/dist/poly/shamos.d.ts +0 -1
  50. package/dist/poly/simplify.d.ts +0 -2
  51. package/dist/poly/topo.d.ts +0 -46
  52. package/dist/poly/union.d.ts +0 -49
  53. package/dist/util/all.d.ts +0 -5
  54. package/dist/util/bintrie.d.ts +0 -93
  55. package/dist/util/countedhash.d.ts +0 -19
  56. package/dist/util/gradient.d.ts +0 -15
  57. package/dist/util/indexedarray.d.ts +0 -15
  58. package/dist/util/util.d.ts +0 -68
  59. package/docs/context.md +0 -2
  60. package/docs/filterexpr.md +0 -22
  61. package/docs/fsm.md +0 -243
  62. package/docs/logabstract.md +0 -2
  63. package/docs/logclient.md +0 -2
  64. package/docs/ot-editutil.md +0 -2
  65. package/docs/ot-js.md +0 -95
  66. package/docs/poly.md +0 -103
  67. package/docs/util.md +0 -2
  68. package/lib/all/all.ts +0 -21
  69. package/lib/context/all.ts +0 -1
  70. package/lib/context/context.ts +0 -82
  71. package/lib/filterexpr/all.ts +0 -1
  72. package/lib/filterexpr/filterexpr.ts +0 -699
  73. package/lib/fsm/all.ts +0 -1
  74. package/lib/fsm/fsm.ts +0 -559
  75. package/lib/geo/all.ts +0 -2
  76. package/lib/geo/geo.ts +0 -452
  77. package/lib/geo/vfeature.ts +0 -34
  78. package/lib/logabstract/all.ts +0 -1
  79. package/lib/logabstract/log.ts +0 -55
  80. package/lib/logclient/all.ts +0 -1
  81. package/lib/logclient/log.ts +0 -105
  82. package/lib/ot-editutil/all.ts +0 -2
  83. package/lib/ot-editutil/oteditutil.ts +0 -180
  84. package/lib/ot-editutil/otmaputil.ts +0 -209
  85. package/lib/ot-js/all.ts +0 -9
  86. package/lib/ot-js/otarray.ts +0 -1168
  87. package/lib/ot-js/otclientengine.ts +0 -327
  88. package/lib/ot-js/otcomposite.ts +0 -247
  89. package/lib/ot-js/otcounter.ts +0 -145
  90. package/lib/ot-js/otengine.ts +0 -71
  91. package/lib/ot-js/otmap.ts +0 -144
  92. package/lib/ot-js/otserverengine.ts +0 -329
  93. package/lib/ot-js/otsession.ts +0 -201
  94. package/lib/ot-js/ottypes.ts +0 -98
  95. package/lib/poly/all.ts +0 -15
  96. package/lib/poly/blend.ts +0 -27
  97. package/lib/poly/boundbox.ts +0 -102
  98. package/lib/poly/cartesian.ts +0 -130
  99. package/lib/poly/graham-scan.ts +0 -401
  100. package/lib/poly/hash.ts +0 -15
  101. package/lib/poly/matrix.ts +0 -309
  102. package/lib/poly/minbound.ts +0 -211
  103. package/lib/poly/poly.ts +0 -767
  104. package/lib/poly/polybin.ts +0 -218
  105. package/lib/poly/polylabel.ts +0 -204
  106. package/lib/poly/polypack.ts +0 -458
  107. package/lib/poly/polyround.ts +0 -30
  108. package/lib/poly/polysimplify.ts +0 -24
  109. package/lib/poly/quad.ts +0 -272
  110. package/lib/poly/selfintersect.ts +0 -87
  111. package/lib/poly/shamos.ts +0 -297
  112. package/lib/poly/simplify.ts +0 -119
  113. package/lib/poly/topo.ts +0 -499
  114. package/lib/poly/union.ts +0 -388
  115. package/lib/util/all.ts +0 -5
  116. package/lib/util/bintrie.ts +0 -603
  117. package/lib/util/countedhash.ts +0 -83
  118. package/lib/util/gradient.ts +0 -108
  119. package/lib/util/indexedarray.ts +0 -80
  120. package/lib/util/util.ts +0 -695
package/lib/poly/union.ts DELETED
@@ -1,388 +0,0 @@
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
- }
package/lib/util/all.ts DELETED
@@ -1,5 +0,0 @@
1
- export * from './util';
2
- export * from './countedhash';
3
- export * from './indexedarray';
4
- export * from './gradient';
5
- export * from './bintrie';