@vcmap/core 5.1.6 → 5.2.1

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 (63) hide show
  1. package/dist/src/interaction/abstractInteraction.d.ts +5 -0
  2. package/dist/src/interaction/abstractInteraction.js.map +1 -1
  3. package/dist/src/interaction/eventHandler.d.ts +5 -1
  4. package/dist/src/interaction/eventHandler.js +29 -12
  5. package/dist/src/interaction/eventHandler.js.map +1 -1
  6. package/dist/src/map/baseOLMap.d.ts +2 -1
  7. package/dist/src/map/baseOLMap.js +1 -1
  8. package/dist/src/map/baseOLMap.js.map +1 -1
  9. package/dist/src/map/cesiumMap.d.ts +2 -1
  10. package/dist/src/map/cesiumMap.js +7 -4
  11. package/dist/src/map/cesiumMap.js.map +1 -1
  12. package/dist/src/map/obliqueMap.js +3 -3
  13. package/dist/src/map/obliqueMap.js.map +1 -1
  14. package/dist/src/map/openlayersMap.js +1 -1
  15. package/dist/src/map/openlayersMap.js.map +1 -1
  16. package/dist/src/map/vcsMap.d.ts +17 -6
  17. package/dist/src/map/vcsMap.js +46 -8
  18. package/dist/src/map/vcsMap.js.map +1 -1
  19. package/dist/src/util/clipping/clippingObject.js +10 -1
  20. package/dist/src/util/clipping/clippingObject.js.map +1 -1
  21. package/dist/src/util/clipping/clippingObjectManager.js +6 -0
  22. package/dist/src/util/clipping/clippingObjectManager.js.map +1 -1
  23. package/dist/src/util/clipping/clippingPlaneHelper.d.ts +3 -2
  24. package/dist/src/util/clipping/clippingPlaneHelper.js +14 -7
  25. package/dist/src/util/clipping/clippingPlaneHelper.js.map +1 -1
  26. package/dist/src/util/editor/editFeaturesSession.js +56 -4
  27. package/dist/src/util/editor/editFeaturesSession.js.map +1 -1
  28. package/dist/src/util/editor/editGeometrySession.d.ts +6 -1
  29. package/dist/src/util/editor/editGeometrySession.js +51 -44
  30. package/dist/src/util/editor/editGeometrySession.js.map +1 -1
  31. package/dist/src/util/editor/interactions/editGeometryMouseOverInteraction.d.ts +1 -1
  32. package/dist/src/util/editor/interactions/editGeometryMouseOverInteraction.js +4 -2
  33. package/dist/src/util/editor/interactions/editGeometryMouseOverInteraction.js.map +1 -1
  34. package/dist/src/util/editor/interactions/rightClickInteraction.d.ts +9 -0
  35. package/dist/src/util/editor/interactions/rightClickInteraction.js +31 -0
  36. package/dist/src/util/editor/interactions/rightClickInteraction.js.map +1 -0
  37. package/dist/src/util/flight/flightInstance.d.ts +1 -1
  38. package/dist/src/util/flight/flightPlayer.js +16 -13
  39. package/dist/src/util/flight/flightPlayer.js.map +1 -1
  40. package/dist/src/util/mapCollection.d.ts +14 -0
  41. package/dist/src/util/mapCollection.js +33 -0
  42. package/dist/src/util/mapCollection.js.map +1 -1
  43. package/dist/src/vcsApp.d.ts +7 -1
  44. package/dist/src/vcsApp.js +71 -20
  45. package/dist/src/vcsApp.js.map +1 -1
  46. package/package.json +3 -2
  47. package/src/interaction/abstractInteraction.ts +5 -0
  48. package/src/interaction/eventHandler.ts +30 -13
  49. package/src/map/baseOLMap.ts +3 -2
  50. package/src/map/cesiumMap.ts +11 -4
  51. package/src/map/obliqueMap.ts +3 -3
  52. package/src/map/openlayersMap.ts +1 -1
  53. package/src/map/vcsMap.ts +63 -10
  54. package/src/util/clipping/clippingObject.ts +10 -1
  55. package/src/util/clipping/clippingObjectManager.ts +6 -0
  56. package/src/util/clipping/clippingPlaneHelper.ts +14 -6
  57. package/src/util/editor/editFeaturesSession.ts +72 -10
  58. package/src/util/editor/editGeometrySession.ts +61 -39
  59. package/src/util/editor/interactions/editGeometryMouseOverInteraction.ts +7 -2
  60. package/src/util/editor/interactions/rightClickInteraction.ts +42 -0
  61. package/src/util/flight/flightPlayer.ts +21 -15
  62. package/src/util/mapCollection.ts +47 -0
  63. package/src/vcsApp.ts +82 -23
package/src/vcsApp.ts CHANGED
@@ -122,7 +122,15 @@ class VcsApp {
122
122
 
123
123
  private _destroyed: VcsEvent<void>;
124
124
 
125
- private _moduleMutationPromise: Promise<void>;
125
+ private _moduleMutationChain: {
126
+ running: boolean;
127
+ items: Array<{
128
+ moduleId: string;
129
+ mutation: () => Promise<void>;
130
+ resolve: () => void;
131
+ reject: (reason?: any) => void;
132
+ }>;
133
+ };
126
134
 
127
135
  private _categoryItemClassRegistry: OverrideClassRegistry<Ctor<any>>;
128
136
 
@@ -216,7 +224,7 @@ class VcsApp {
216
224
  );
217
225
  this._categories = new CategoryCollection(this);
218
226
  this._destroyed = new VcsEvent();
219
- this._moduleMutationPromise = Promise.resolve();
227
+ this._moduleMutationChain = { running: false, items: [] };
220
228
  this._categoryItemClassRegistry = new OverrideClassRegistry(
221
229
  new ClassRegistry(),
222
230
  );
@@ -402,12 +410,13 @@ class VcsApp {
402
410
  config.startingObliqueCollectionName,
403
411
  );
404
412
  if (startingObliqueCollection) {
405
- [...this._maps]
406
- .filter((m) => m instanceof ObliqueMap)
407
- .forEach((m) => {
408
- // eslint-disable-next-line no-void
409
- void (m as ObliqueMap).setCollection(startingObliqueCollection);
410
- });
413
+ await Promise.all(
414
+ [...this._maps]
415
+ .filter((m) => m instanceof ObliqueMap)
416
+ .map((m) => {
417
+ return (m as ObliqueMap).setCollection(startingObliqueCollection);
418
+ }),
419
+ );
411
420
  }
412
421
  }
413
422
 
@@ -427,20 +436,61 @@ class VcsApp {
427
436
  }
428
437
  }
429
438
 
430
- addModule(module: VcsModule): Promise<void> {
439
+ /**
440
+ * When adding multiple modules, adding of previous modules are awaited.
441
+ * If an invalid module is added an error is thrown and already added items of invalid module are removed.
442
+ * @param module
443
+ */
444
+ async addModule(module: VcsModule): Promise<void> {
431
445
  check(module, VcsModule);
432
446
 
433
- this._moduleMutationPromise = this._moduleMutationPromise.then(async () => {
434
- if (this._modules.hasKey(module._id)) {
435
- getLogger().info(`module with id ${module._id} already loaded`);
436
- return;
437
- }
447
+ const mutation = async (): Promise<void> => {
448
+ try {
449
+ if (this._modules.hasKey(module._id)) {
450
+ getLogger().info(`module with id ${module._id} already loaded`);
451
+ return;
452
+ }
438
453
 
439
- await this._parseModule(module);
440
- await this._setModuleState(module);
441
- this._modules.add(module);
454
+ await this._parseModule(module);
455
+ await this._setModuleState(module);
456
+ this._modules.add(module);
457
+ } catch (err) {
458
+ await this._removeModule(module._id);
459
+ throw err;
460
+ }
461
+ };
462
+ return new Promise((resolve, reject) => {
463
+ this._moduleMutationChain.items.push({
464
+ moduleId: module._id,
465
+ mutation,
466
+ resolve,
467
+ reject,
468
+ });
469
+ this._startModuleMutationChain();
442
470
  });
443
- return this._moduleMutationPromise;
471
+ }
472
+
473
+ _startModuleMutationChain(): void {
474
+ if (!this._moduleMutationChain.running) {
475
+ const item = this._moduleMutationChain.items.shift();
476
+ if (item) {
477
+ try {
478
+ this._moduleMutationChain.running = true;
479
+ item
480
+ .mutation()
481
+ .then(() => item.resolve())
482
+ .catch((err) => item.reject(err))
483
+ .finally(() => {
484
+ this._moduleMutationChain.running = false;
485
+ this._startModuleMutationChain();
486
+ });
487
+ } catch (err) {
488
+ item.reject(err);
489
+ this._moduleMutationChain.running = false;
490
+ this._startModuleMutationChain();
491
+ }
492
+ }
493
+ }
444
494
  }
445
495
 
446
496
  serializeModule(moduleId: string): VcsModuleConfig {
@@ -503,8 +553,8 @@ class VcsApp {
503
553
  ]);
504
554
  }
505
555
 
506
- removeModule(moduleId: string): Promise<void> {
507
- this._moduleMutationPromise = this._moduleMutationPromise.then(async () => {
556
+ async removeModule(moduleId: string): Promise<void> {
557
+ const mutation = async (): Promise<void> => {
508
558
  const module = this._modules.getByKey(moduleId);
509
559
  if (!module) {
510
560
  getLogger().info(`module with id ${moduleId} has already been removed`);
@@ -512,16 +562,25 @@ class VcsApp {
512
562
  }
513
563
  await this._removeModule(moduleId);
514
564
  this._modules.remove(module);
565
+ };
566
+ return new Promise((resolve, reject) => {
567
+ this._moduleMutationChain.items.push({
568
+ moduleId,
569
+ mutation,
570
+ resolve,
571
+ reject,
572
+ });
573
+ this._startModuleMutationChain();
515
574
  });
516
-
517
- return this._moduleMutationPromise;
518
575
  }
519
576
 
520
577
  /**
521
578
  * Destroys the app and all its collections, their content and ui managers.
522
579
  */
523
580
  destroy(): void {
524
- Object.defineProperty(this, '_moduleMutationPromise', {
581
+ this._moduleMutationChain.running = false;
582
+ this._moduleMutationChain.items.splice(0);
583
+ Object.defineProperty(this, '_moduleMutationChain', {
525
584
  get() {
526
585
  throw new Error('VcsApp was destroyed');
527
586
  },