@artstesh/maps 4.0.10 → 4.1.0

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 (92) hide show
  1. package/dist/esm2020/map/helpers/polygon-style.helper.mjs +19 -2
  2. package/dist/esm2020/map/map-plate/controls/index.mjs +3 -0
  3. package/dist/esm2020/map/map-plate/controls/map-control-zoom/map-control-zoom.component.mjs +49 -0
  4. package/dist/esm2020/map/map-plate/controls/map-control-zoom/zoom-control.factory.mjs +13 -0
  5. package/dist/esm2020/map/map-plate/controls/map-control-zoom/zoom-control.settings.mjs +47 -0
  6. package/dist/esm2020/map/map-plate/map-plate.component.mjs +4 -1
  7. package/dist/esm2020/map/map.module.mjs +8 -3
  8. package/dist/esm2020/map/messages/commands/cancel-feature-modification.command.mjs +8 -0
  9. package/dist/esm2020/map/messages/commands/modify-feature.command.mjs +15 -0
  10. package/dist/esm2020/map/messages/executors/filter-features-in-area.executor.mjs +13 -0
  11. package/dist/esm2020/map/messages/executors/generate-draw.executor.mjs +14 -0
  12. package/dist/esm2020/map/messages/executors/generate-zoom-control.executor.mjs +12 -0
  13. package/dist/esm2020/map/messages/index.mjs +3 -1
  14. package/dist/esm2020/map/models/drawing-type.enum.mjs +2 -1
  15. package/dist/esm2020/map/public-api.mjs +2 -1
  16. package/dist/esm2020/map/services/drawing/drawing-generation.service.mjs +16 -21
  17. package/dist/esm2020/map/services/drawing/drawing.service.mjs +8 -12
  18. package/dist/esm2020/map/services/drawing/feature-modification.service.mjs +99 -0
  19. package/dist/esm2020/map/services/feature.service.mjs +4 -17
  20. package/dist/esm2020/map/services/map-management.service.mjs +5 -13
  21. package/dist/esm2020/map/services/message-registrator.service.mjs +22 -11
  22. package/dist/esm2020/src/map/helpers/polygon-style.helper.mjs +19 -2
  23. package/dist/esm2020/src/map/map-plate/controls/index.mjs +3 -0
  24. package/dist/esm2020/src/map/map-plate/controls/map-control-zoom/map-control-zoom.component.mjs +49 -0
  25. package/dist/esm2020/src/map/map-plate/controls/map-control-zoom/zoom-control.factory.mjs +13 -0
  26. package/dist/esm2020/src/map/map-plate/controls/map-control-zoom/zoom-control.settings.mjs +47 -0
  27. package/dist/esm2020/src/map/map-plate/map-plate.component.mjs +4 -1
  28. package/dist/esm2020/src/map/map.module.mjs +8 -3
  29. package/dist/esm2020/src/map/messages/commands/cancel-feature-modification.command.mjs +8 -0
  30. package/dist/esm2020/src/map/messages/commands/modify-feature.command.mjs +15 -0
  31. package/dist/esm2020/src/map/messages/executors/filter-features-in-area.executor.mjs +13 -0
  32. package/dist/esm2020/src/map/messages/executors/generate-draw.executor.mjs +14 -0
  33. package/dist/esm2020/src/map/messages/executors/generate-zoom-control.executor.mjs +12 -0
  34. package/dist/esm2020/src/map/messages/index.mjs +3 -1
  35. package/dist/esm2020/src/map/models/drawing-type.enum.mjs +2 -1
  36. package/dist/esm2020/src/map/public-api.mjs +2 -1
  37. package/dist/esm2020/src/map/services/drawing/drawing-generation.service.mjs +16 -21
  38. package/dist/esm2020/src/map/services/drawing/drawing.service.mjs +8 -12
  39. package/dist/esm2020/src/map/services/drawing/feature-modification.service.mjs +99 -0
  40. package/dist/esm2020/src/map/services/feature.service.mjs +4 -17
  41. package/dist/esm2020/src/map/services/map-management.service.mjs +5 -13
  42. package/dist/esm2020/src/map/services/message-registrator.service.mjs +22 -11
  43. package/dist/fesm2015/maps-components-src-map.mjs +316 -83
  44. package/dist/fesm2015/maps-components-src-map.mjs.map +1 -1
  45. package/dist/fesm2015/maps-components.mjs +316 -83
  46. package/dist/fesm2015/maps-components.mjs.map +1 -1
  47. package/dist/fesm2020/maps-components-src-map.mjs +310 -82
  48. package/dist/fesm2020/maps-components-src-map.mjs.map +1 -1
  49. package/dist/fesm2020/maps-components.mjs +310 -82
  50. package/dist/fesm2020/maps-components.mjs.map +1 -1
  51. package/dist/map/helpers/polygon-style.helper.d.ts +1 -0
  52. package/dist/map/map-plate/controls/index.d.ts +2 -0
  53. package/dist/map/map-plate/controls/map-control-zoom/map-control-zoom.component.d.ts +19 -0
  54. package/dist/map/map-plate/controls/map-control-zoom/zoom-control.factory.d.ts +5 -0
  55. package/dist/map/map-plate/controls/map-control-zoom/zoom-control.settings.d.ts +14 -0
  56. package/dist/map/map.module.d.ts +3 -2
  57. package/dist/map/messages/commands/cancel-feature-modification.command.d.ts +5 -0
  58. package/dist/map/messages/commands/modify-feature.command.d.ts +11 -0
  59. package/dist/map/messages/{queries/filter-features-in-area.query.d.ts → executors/filter-features-in-area.executor.d.ts} +2 -2
  60. package/dist/map/messages/{queries/generate-draw.query.d.ts → executors/generate-draw.executor.d.ts} +2 -2
  61. package/dist/map/messages/executors/generate-zoom-control.executor.d.ts +9 -0
  62. package/dist/map/messages/index.d.ts +2 -0
  63. package/dist/map/models/drawing-type.enum.d.ts +2 -1
  64. package/dist/map/public-api.d.ts +1 -0
  65. package/dist/map/services/drawing/drawing-generation.service.d.ts +5 -9
  66. package/dist/map/services/drawing/feature-modification.service.d.ts +22 -0
  67. package/dist/map/services/feature.service.d.ts +6 -9
  68. package/dist/map/services/message-registrator.service.d.ts +3 -3
  69. package/dist/package.json +1 -1
  70. package/dist/src/map/helpers/polygon-style.helper.d.ts +1 -0
  71. package/dist/src/map/map-plate/controls/index.d.ts +2 -0
  72. package/dist/src/map/map-plate/controls/map-control-zoom/map-control-zoom.component.d.ts +19 -0
  73. package/dist/src/map/map-plate/controls/map-control-zoom/zoom-control.factory.d.ts +5 -0
  74. package/dist/src/map/map-plate/controls/map-control-zoom/zoom-control.settings.d.ts +14 -0
  75. package/dist/src/map/map.module.d.ts +3 -2
  76. package/dist/src/map/messages/commands/cancel-feature-modification.command.d.ts +5 -0
  77. package/dist/src/map/messages/commands/modify-feature.command.d.ts +11 -0
  78. package/dist/src/map/messages/{queries/filter-features-in-area.query.d.ts → executors/filter-features-in-area.executor.d.ts} +2 -2
  79. package/dist/src/map/messages/{queries/generate-draw.query.d.ts → executors/generate-draw.executor.d.ts} +2 -2
  80. package/dist/src/map/messages/executors/generate-zoom-control.executor.d.ts +9 -0
  81. package/dist/src/map/messages/index.d.ts +2 -0
  82. package/dist/src/map/models/drawing-type.enum.d.ts +2 -1
  83. package/dist/src/map/public-api.d.ts +1 -0
  84. package/dist/src/map/services/drawing/drawing-generation.service.d.ts +5 -9
  85. package/dist/src/map/services/drawing/feature-modification.service.d.ts +22 -0
  86. package/dist/src/map/services/feature.service.d.ts +6 -9
  87. package/dist/src/map/services/message-registrator.service.d.ts +3 -3
  88. package/package.json +2 -2
  89. package/dist/esm2020/map/messages/queries/filter-features-in-area.query.mjs +0 -13
  90. package/dist/esm2020/map/messages/queries/generate-draw.query.mjs +0 -14
  91. package/dist/esm2020/src/map/messages/queries/filter-features-in-area.query.mjs +0 -13
  92. package/dist/esm2020/src/map/messages/queries/generate-draw.query.mjs +0 -14
@@ -2,23 +2,24 @@ import * as i0 from '@angular/core';
2
2
  import { Component, Injectable, ChangeDetectionStrategy, Input, ViewChild, NgModule } from '@angular/core';
3
3
  import * as i4 from '@angular/common';
4
4
  import { CommonModule } from '@angular/common';
5
- import { Feature } from 'ol';
5
+ import { Feature, Collection } from 'ol';
6
6
  import { Point, LineString } from 'ol/geom';
7
7
  import { GeoJSON, WKT } from 'ol/format';
8
8
  import { getCenter, createEmpty, extend } from 'ol/extent';
9
9
  import { get, useGeographic, transform } from 'ol/proj';
10
- import { PostboyGenericMessage, PostboyCallbackMessage, PostboyService, PostboyAbstractRegistrator } from '@artstesh/postboy';
11
- import { forkJoin, combineLatest } from 'rxjs';
12
- import { tap, first, filter, auditTime } from 'rxjs/operators';
13
- import { Vector, XYZ } from 'ol/source';
14
- import { Draw } from 'ol/interaction';
10
+ import { PostboyGenericMessage, PostboyCallbackMessage, PostboyExecutor, PostboyService, PostboyAbstractRegistrator } from '@artstesh/postboy';
11
+ import { Draw, Modify, Translate } from 'ol/interaction';
15
12
  import { createRegularPolygon } from 'ol/interaction/Draw';
13
+ import { Zoom } from 'ol/control';
14
+ import { first, filter, auditTime } from 'rxjs/operators';
15
+ import { Vector, XYZ } from 'ol/source';
16
16
  import TileLayer from 'ol/layer/Tile';
17
17
  import OSM from 'ol/source/OSM';
18
18
  import { Vector as Vector$1 } from 'ol/layer';
19
19
  import { bbox } from 'ol/loadingstrategy';
20
20
  import Polygon, { fromExtent } from 'ol/geom/Polygon';
21
21
  import Cluster from 'ol/source/Cluster';
22
+ import { combineLatest } from 'rxjs';
22
23
  import Map from 'ol/Map';
23
24
  import View from 'ol/View';
24
25
  import Overlay from 'ol/Overlay';
@@ -180,6 +181,7 @@ var DrawingType;
180
181
  (function (DrawingType) {
181
182
  DrawingType[DrawingType["Polygon"] = 1] = "Polygon";
182
183
  DrawingType[DrawingType["Circle"] = 2] = "Circle";
184
+ DrawingType[DrawingType["Square"] = 3] = "Square";
183
185
  })(DrawingType || (DrawingType = {}));
184
186
 
185
187
  var FeatureOutputFormat;
@@ -324,6 +326,26 @@ class DrawSelectionAreaCommand extends PostboyCallbackMessage {
324
326
  }
325
327
  DrawSelectionAreaCommand.ID = '573d8a0d-f25b-42b7-9ad7-0ac6d86ac362';
326
328
 
329
+ class ModifyFeatureCommand extends PostboyCallbackMessage {
330
+ constructor(model, style, format = FeatureOutputFormat.GeoJson) {
331
+ super();
332
+ this.model = model;
333
+ this.style = style;
334
+ this.format = format;
335
+ }
336
+ get id() {
337
+ return ModifyFeatureCommand.ID;
338
+ }
339
+ }
340
+ ModifyFeatureCommand.ID = 'ead85caa-24c6-4844-a68c-2cea91774c8c';
341
+
342
+ class CancelFeatureModificationCommand extends PostboyGenericMessage {
343
+ get id() {
344
+ return CancelFeatureModificationCommand.ID;
345
+ }
346
+ }
347
+ CancelFeatureModificationCommand.ID = '9c9fb40f-ea95-4704-8177-0e9ecabf36fa';
348
+
327
349
  class AddLayerCommand extends PostboyGenericMessage {
328
350
  constructor(layer) {
329
351
  super();
@@ -413,42 +435,101 @@ class DrawingFinishedEvent extends PostboyGenericMessage {
413
435
  }
414
436
  DrawingFinishedEvent.ID = 'c724b68e-b4eb-4783-90f1-a8e31973fd36';
415
437
 
416
- class GenerateDrawQuery extends PostboyCallbackMessage {
417
- constructor(layer, style, type) {
438
+ class DrawingGenerationService {
439
+ static getDraw(ev) {
440
+ return new Draw({
441
+ source: ev.layer.getSource(),
442
+ type: ev.type === DrawingType.Polygon ? 'Polygon' : 'Circle',
443
+ style: ev.style,
444
+ geometryFunction: DrawingGenerationService.geometryFunc(ev.type),
445
+ });
446
+ }
447
+ static geometryFunc(type) {
448
+ switch (type) {
449
+ case DrawingType.Circle:
450
+ return createRegularPolygon(32);
451
+ case DrawingType.Square:
452
+ return createRegularPolygon(4);
453
+ }
454
+ return undefined;
455
+ }
456
+ }
457
+
458
+ class FeatureService {
459
+ constructor() { }
460
+ static filterFeaturesInArea(query) {
461
+ return query.features.filter((f) => FeatureService.booleanIntersects(query.area, f.getGeometry()));
462
+ }
463
+ static booleanIntersects(g1, g2) {
464
+ if (g2.getType() === 'Point')
465
+ return g1.intersectsCoordinate(g2.getCoordinates());
466
+ if (g2.getType() === 'Circle')
467
+ return g1.intersectsCoordinate(g2.getCenter());
468
+ if (g2.getType() === 'Polygon')
469
+ return g1.intersectsCoordinate(g2.getInteriorPoint().getCoordinates());
470
+ return false;
471
+ }
472
+ }
473
+
474
+ class GetFeaturesInAreaQuery extends PostboyCallbackMessage {
475
+ constructor(area, ignore = new Set()) {
418
476
  super();
419
- this.layer = layer;
420
- this.style = style;
421
- this.type = type;
477
+ this.area = area;
478
+ this.ignore = ignore;
422
479
  }
423
480
  get id() {
424
- return GenerateDrawQuery.ID;
481
+ return GetFeaturesInAreaQuery.ID;
425
482
  }
426
483
  }
427
- GenerateDrawQuery.ID = 'f01c99ba-0953-4ab5-82f9-04e6fbb678c1';
484
+ GetFeaturesInAreaQuery.ID = 'efcf4271-a07a-40e0-9f02-d4dade40b8ac';
428
485
 
429
- class FilterFeaturesInAreaQuery extends PostboyCallbackMessage {
486
+ class FilterFeaturesInAreaExecutor extends PostboyExecutor {
430
487
  constructor(area, features) {
431
488
  super();
432
489
  this.area = area;
433
490
  this.features = features;
434
491
  }
435
492
  get id() {
436
- return FilterFeaturesInAreaQuery.ID;
493
+ return FilterFeaturesInAreaExecutor.ID;
437
494
  }
438
495
  }
439
- FilterFeaturesInAreaQuery.ID = '36bb2d94-8028-4512-90dd-2386af3fc67c';
496
+ FilterFeaturesInAreaExecutor.ID = '36bb2d94-8028-4512-90dd-2386af3fc67c';
440
497
 
441
- class GetFeaturesInAreaQuery extends PostboyCallbackMessage {
442
- constructor(area, ignore = new Set()) {
498
+ class GenerateDrawExecutor extends PostboyExecutor {
499
+ constructor(layer, style, type) {
443
500
  super();
444
- this.area = area;
445
- this.ignore = ignore;
501
+ this.layer = layer;
502
+ this.style = style;
503
+ this.type = type;
446
504
  }
447
505
  get id() {
448
- return GetFeaturesInAreaQuery.ID;
506
+ return GenerateDrawExecutor.ID;
449
507
  }
450
508
  }
451
- GetFeaturesInAreaQuery.ID = 'efcf4271-a07a-40e0-9f02-d4dade40b8ac';
509
+ GenerateDrawExecutor.ID = 'f01c99ba-0953-4ab5-82f9-04e6fbb678c1';
510
+
511
+ class GenerateZoomControlExecutor extends PostboyExecutor {
512
+ constructor(settings) {
513
+ super();
514
+ this.settings = settings;
515
+ }
516
+ get id() {
517
+ return GenerateZoomControlExecutor.ID;
518
+ }
519
+ }
520
+ GenerateZoomControlExecutor.ID = 'ff16a833-c68e-4b1a-bc23-c0d16b002810';
521
+
522
+ class ZoomControlFactory {
523
+ static build(settings) {
524
+ return new Zoom({
525
+ zoomInTipLabel: settings.zoomInLabel,
526
+ zoomOutTipLabel: settings.zoomOutLabel,
527
+ zoomInClassName: settings.zoomInClass,
528
+ zoomOutClassName: settings.zoomOutClass,
529
+ className: settings.controlClass,
530
+ });
531
+ }
532
+ }
452
533
 
453
534
  class MapPostboyService extends PostboyService {
454
535
  constructor() {
@@ -529,8 +610,6 @@ class MapManagementService {
529
610
  observeFeaturesInArea() {
530
611
  this.postboy.subscribe(GetFeaturesInAreaQuery.ID).subscribe((qr) => {
531
612
  let result = new Dictionary();
532
- const queue = [];
533
- const queries = [];
534
613
  this.layers.forEach((l) => {
535
614
  var _a;
536
615
  let layerName = l.get('name');
@@ -539,14 +618,10 @@ class MapManagementService {
539
618
  let source = l.getSource();
540
619
  if (!!source['getSource'])
541
620
  source = source === null || source === void 0 ? void 0 : source.getSource();
542
- const query = new FilterFeaturesInAreaQuery(qr.area, (_a = source === null || source === void 0 ? void 0 : source.getFeatures()) !== null && _a !== void 0 ? _a : []);
543
- queue.push(query.result.pipe(tap((r) => {
544
- result.put(l.get('name'), r.map((e) => (Object.assign({ id: e.getId() }, e.get(MapConstants.FeatureInfo)))));
545
- })));
546
- queries.push(query);
621
+ let features = this.postboy.execute(new FilterFeaturesInAreaExecutor(qr.area, (_a = source === null || source === void 0 ? void 0 : source.getFeatures()) !== null && _a !== void 0 ? _a : []));
622
+ result.put(layerName, features.map((e) => (Object.assign({ id: e.getId() }, e.get(MapConstants.FeatureInfo)))));
547
623
  });
548
- forkJoin(queue).subscribe(() => qr.finish(result));
549
- queries.forEach((q) => this.postboy.fire(q));
624
+ qr.finish(result);
550
625
  });
551
626
  }
552
627
  }
@@ -689,22 +764,18 @@ class DrawingService {
689
764
  observeDrawing() {
690
765
  this.postboy.subscribe(StartDrawingCommand.ID).subscribe((ev) => {
691
766
  this.draw((l) => {
767
+ var _a;
692
768
  if (!l || !this.map) {
693
769
  this.clearInteraction(l);
694
770
  return;
695
771
  }
696
- const drawQuery = new GenerateDrawQuery(l, ev.style, ev.type);
697
- drawQuery.result.subscribe((draw) => {
698
- var _a;
699
- const cancelSub = this.observeCancelation(ev, l);
700
- this.drawInteraction = draw;
701
- (_a = this.map) === null || _a === void 0 ? void 0 : _a.addInteraction(this.drawInteraction);
702
- this.drawInteraction.on('drawend', (evt) => {
703
- cancelSub.unsubscribe();
704
- this.onEnd(evt, ev, l);
705
- });
772
+ const cancelSub = this.observeCancelation(ev, l);
773
+ this.drawInteraction = this.postboy.execute(new GenerateDrawExecutor(l, ev.style, ev.type));
774
+ (_a = this.map) === null || _a === void 0 ? void 0 : _a.addInteraction(this.drawInteraction);
775
+ this.drawInteraction.on('drawend', (evt) => {
776
+ cancelSub.unsubscribe();
777
+ this.onEnd(evt, ev, l);
706
778
  });
707
- this.postboy.fire(drawQuery);
708
779
  });
709
780
  });
710
781
  }
@@ -748,56 +819,101 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "15.2.10", ngImpo
748
819
  type: Injectable
749
820
  }], ctorParameters: function () { return [{ type: MapPostboyService }]; } });
750
821
 
751
- class DrawingGenerationService {
822
+ class FeatureModificationService {
752
823
  constructor(postboy) {
753
824
  this.postboy = postboy;
754
825
  }
755
826
  up() {
756
- this.postboy.subscribe(GenerateDrawQuery.ID).subscribe((ev) => {
757
- ev.finish(new Draw({
758
- source: ev.layer.getSource(),
759
- type: DrawingType[ev.type],
760
- style: ev.style,
761
- geometryFunction: ev.type !== DrawingType.Circle ? undefined : createRegularPolygon(32),
762
- }));
827
+ this.observeModification();
828
+ this.observeMapRender();
829
+ }
830
+ observeModification() {
831
+ this.postboy.subscribe(ModifyFeatureCommand.ID).subscribe((ev) => {
832
+ this.defineLayer((l) => {
833
+ if (!l || !this.map) {
834
+ this.clearInteraction(l);
835
+ return;
836
+ }
837
+ this.observeCancelation(ev, l);
838
+ this.initFeature(l, ev.model.feature);
839
+ this.addModify(ev);
840
+ this.addDragging(ev);
841
+ });
763
842
  });
764
843
  }
765
- }
766
- DrawingGenerationService.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "15.2.10", ngImport: i0, type: DrawingGenerationService, deps: [{ token: MapPostboyService }], target: i0.ɵɵFactoryTarget.Injectable });
767
- DrawingGenerationService.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "15.2.10", ngImport: i0, type: DrawingGenerationService });
768
- i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "15.2.10", ngImport: i0, type: DrawingGenerationService, decorators: [{
769
- type: Injectable
770
- }], ctorParameters: function () { return [{ type: MapPostboyService }]; } });
771
-
772
- class FeatureService {
773
- constructor(postboy) {
774
- this.postboy = postboy;
844
+ initFeature(layer, feature) {
845
+ var _a, _b;
846
+ (_a = layer.getSource()) === null || _a === void 0 ? void 0 : _a.clear();
847
+ (_b = layer.getSource()) === null || _b === void 0 ? void 0 : _b.addFeature(feature);
775
848
  }
776
- up() {
777
- this.postboy.subscribe(FilterFeaturesInAreaQuery.ID).subscribe((qr) => {
778
- qr.finish(qr.features.filter((f) => FeatureService.booleanIntersects(qr.area, f.getGeometry())));
849
+ addModify(command) {
850
+ var _a;
851
+ this.modify = new Modify({
852
+ features: new Collection([command.model.feature]),
853
+ style: command.style,
779
854
  });
855
+ this.modify.on('modifyend', () => {
856
+ this.onModified(command);
857
+ command.model.feature.changed();
858
+ });
859
+ (_a = this.map) === null || _a === void 0 ? void 0 : _a.addInteraction(this.modify);
780
860
  }
781
- static booleanIntersects(g1, g2) {
782
- if (g2.getType() === 'Point')
783
- return g1.intersectsCoordinate(g2.getCoordinates());
784
- if (g2.getType() === 'Circle')
785
- return g1.intersectsCoordinate(g2.getCenter());
786
- if (g2.getType() === 'Polygon')
787
- return g1.intersectsCoordinate(g2.getInteriorPoint().getCoordinates());
788
- return false;
861
+ addDragging(command) {
862
+ var _a;
863
+ this.translate = new Translate({
864
+ features: new Collection([command.model.feature]),
865
+ condition: (ev) => {
866
+ var _a;
867
+ const clone = command.model.feature.clone();
868
+ (_a = clone.getGeometry()) === null || _a === void 0 ? void 0 : _a.scale(0.999);
869
+ return clone.getGeometry().intersectsCoordinate(ev.coordinate);
870
+ },
871
+ });
872
+ this.translate.on('translateend', () => this.onModified(command));
873
+ (_a = this.map) === null || _a === void 0 ? void 0 : _a.addInteraction(this.translate);
874
+ }
875
+ onModified(command) {
876
+ command.next(command.format === FeatureOutputFormat.GeoJson
877
+ ? new GeoJSON().writeFeature(command.model.feature)
878
+ : new WKT().writeFeature(command.model.feature));
879
+ }
880
+ observeMapRender() {
881
+ this.postboy.subscribe(MapRenderedEvent.ID).subscribe((m) => {
882
+ this.map = m.map;
883
+ });
884
+ }
885
+ defineLayer(action) {
886
+ const query = new GetLayerQuery(MapConstants.DrawingLayerId);
887
+ query.result.subscribe((l) => action(l));
888
+ this.postboy.fire(query);
889
+ }
890
+ observeCancelation(ev, layer) {
891
+ return this.postboy
892
+ .subscribe(CancelFeatureModificationCommand.ID)
893
+ .pipe(first())
894
+ .subscribe(() => {
895
+ ev.finish(null);
896
+ this.clearInteraction(layer);
897
+ });
898
+ }
899
+ clearInteraction(layer) {
900
+ var _a, _b;
901
+ if (this.modify)
902
+ (_a = this.map) === null || _a === void 0 ? void 0 : _a.removeInteraction(this.modify);
903
+ if (this.translate)
904
+ (_b = this.map) === null || _b === void 0 ? void 0 : _b.removeInteraction(this.translate);
789
905
  }
790
906
  }
791
- FeatureService.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "15.2.10", ngImport: i0, type: FeatureService, deps: [{ token: MapPostboyService }], target: i0.ɵɵFactoryTarget.Injectable });
792
- FeatureService.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "15.2.10", ngImport: i0, type: FeatureService });
793
- i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "15.2.10", ngImport: i0, type: FeatureService, decorators: [{
907
+ FeatureModificationService.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "15.2.10", ngImport: i0, type: FeatureModificationService, deps: [{ token: MapPostboyService }], target: i0.ɵɵFactoryTarget.Injectable });
908
+ FeatureModificationService.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "15.2.10", ngImport: i0, type: FeatureModificationService });
909
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "15.2.10", ngImport: i0, type: FeatureModificationService, decorators: [{
794
910
  type: Injectable
795
911
  }], ctorParameters: function () { return [{ type: MapPostboyService }]; } });
796
912
 
797
913
  class MessageRegistratorService extends PostboyAbstractRegistrator {
798
- constructor(service, management, state, mapFeature, interaction, drawing, drawGenerator, feature) {
914
+ constructor(service, management, state, mapFeature, interaction, drawing, featureModification) {
799
915
  super(service);
800
- this.registerServices([management, state, interaction, mapFeature, drawing, drawGenerator, feature]);
916
+ this.registerServices([management, state, interaction, mapFeature, drawing, featureModification]);
801
917
  }
802
918
  _up() {
803
919
  this.registerReplay(MapRenderedEvent.ID);
@@ -814,17 +930,23 @@ class MessageRegistratorService extends PostboyAbstractRegistrator {
814
930
  this.registerSubject(StartDrawingCommand.ID);
815
931
  this.registerSubject(GetLayerQuery.ID);
816
932
  this.registerSubject(DrawingFinishedEvent.ID);
817
- this.registerSubject(GenerateDrawQuery.ID);
818
- this.registerSubject(FilterFeaturesInAreaQuery.ID);
819
933
  this.registerSubject(GetFeaturesInAreaQuery.ID);
820
934
  this.registerSubject(DrawSelectionAreaCommand.ID);
935
+ this.registerSubject(CancelFeatureModificationCommand.ID);
936
+ this.registerSubject(ModifyFeatureCommand.ID);
937
+ this.setExecutors();
938
+ }
939
+ setExecutors() {
940
+ this.registerExecutor(FilterFeaturesInAreaExecutor.ID, (e) => FeatureService.filterFeaturesInArea(e));
941
+ this.registerExecutor(GenerateDrawExecutor.ID, (e) => DrawingGenerationService.getDraw(e));
942
+ this.registerExecutor(GenerateZoomControlExecutor.ID, (e) => ZoomControlFactory.build(e.settings));
821
943
  }
822
944
  }
823
- MessageRegistratorService.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "15.2.10", ngImport: i0, type: MessageRegistratorService, deps: [{ token: MapPostboyService }, { token: MapManagementService }, { token: MapStateService }, { token: MapFeatureService }, { token: MapClickService }, { token: DrawingService }, { token: DrawingGenerationService }, { token: FeatureService }], target: i0.ɵɵFactoryTarget.Injectable });
945
+ MessageRegistratorService.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "15.2.10", ngImport: i0, type: MessageRegistratorService, deps: [{ token: MapPostboyService }, { token: MapManagementService }, { token: MapStateService }, { token: MapFeatureService }, { token: MapClickService }, { token: DrawingService }, { token: FeatureModificationService }], target: i0.ɵɵFactoryTarget.Injectable });
824
946
  MessageRegistratorService.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "15.2.10", ngImport: i0, type: MessageRegistratorService });
825
947
  i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "15.2.10", ngImport: i0, type: MessageRegistratorService, decorators: [{
826
948
  type: Injectable
827
- }], ctorParameters: function () { return [{ type: MapPostboyService }, { type: MapManagementService }, { type: MapStateService }, { type: MapFeatureService }, { type: MapClickService }, { type: DrawingService }, { type: DrawingGenerationService }, { type: FeatureService }]; } });
949
+ }], ctorParameters: function () { return [{ type: MapPostboyService }, { type: MapManagementService }, { type: MapStateService }, { type: MapFeatureService }, { type: MapClickService }, { type: DrawingService }, { type: FeatureModificationService }]; } });
828
950
 
829
951
  class TileLayerSettings {
830
952
  constructor() {
@@ -1383,6 +1505,7 @@ MapPlateComponent.ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "14.0.0", vers
1383
1505
  DrawingService,
1384
1506
  DrawingGenerationService,
1385
1507
  FeatureService,
1508
+ FeatureModificationService,
1386
1509
  ], usesInheritance: true, ngImport: i0, template: "<ng-content></ng-content>\r\n<lib-osm-tile-layer *ngIf=\"osmUrl && map\" [map]=\"map\" [url]=\"osmUrl\"></lib-osm-tile-layer>\r\n<lib-feature-layer *ngIf=\"map\" [settings]=\"drawingLayerSettings\"></lib-feature-layer>\r\n", styles: ["lib-map-plate{position:relative;display:flex;flex-direction:column;height:100%}\n"], dependencies: [{ kind: "directive", type: i4.NgIf, selector: "[ngIf]", inputs: ["ngIf", "ngIfThen", "ngIfElse"] }, { kind: "component", type: OsmTileLayerComponent, selector: "lib-osm-tile-layer", inputs: ["url", "map"] }, { kind: "component", type: FeatureLayerComponent, selector: "lib-feature-layer", inputs: ["settings"] }], changeDetection: i0.ChangeDetectionStrategy.OnPush });
1387
1510
  i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "15.2.10", ngImport: i0, type: MapPlateComponent, decorators: [{
1388
1511
  type: Component,
@@ -1395,6 +1518,7 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "15.2.10", ngImpo
1395
1518
  DrawingService,
1396
1519
  DrawingGenerationService,
1397
1520
  FeatureService,
1521
+ FeatureModificationService,
1398
1522
  ], template: "<ng-content></ng-content>\r\n<lib-osm-tile-layer *ngIf=\"osmUrl && map\" [map]=\"map\" [url]=\"osmUrl\"></lib-osm-tile-layer>\r\n<lib-feature-layer *ngIf=\"map\" [settings]=\"drawingLayerSettings\"></lib-feature-layer>\r\n", styles: ["lib-map-plate{position:relative;display:flex;flex-direction:column;height:100%}\n"] }]
1399
1523
  }], ctorParameters: function () { return [{ type: i0.ElementRef }, { type: MapPostboyService }, { type: MapPlateFactory }, { type: MessageRegistratorService }, { type: i0.ChangeDetectorRef }]; }, propDecorators: { settings: [{
1400
1524
  type: Input
@@ -1568,6 +1692,94 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "15.2.10", ngImpo
1568
1692
  type: Input
1569
1693
  }] } });
1570
1694
 
1695
+ class ZoomControlSettings {
1696
+ constructor() {
1697
+ this.controlClass = 'ol-zoom';
1698
+ this.zoomInClass = 'ol-zoom-in';
1699
+ this.zoomOutClass = 'ol-zoom-out';
1700
+ this.zoomInLabel = 'Zoom In';
1701
+ this.zoomOutLabel = 'Zoom Out';
1702
+ }
1703
+ static copy(model) {
1704
+ const result = new ZoomControlSettings();
1705
+ result.controlClass = model.controlClass;
1706
+ result.zoomInClass = model.zoomInClass;
1707
+ result.zoomOutClass = model.zoomOutClass;
1708
+ result.zoomInLabel = model.zoomInLabel;
1709
+ result.zoomOutLabel = model.zoomOutLabel;
1710
+ return result;
1711
+ }
1712
+ isSame(model) {
1713
+ if (this.zoomInClass !== model.zoomInClass)
1714
+ return false;
1715
+ if (this.zoomOutClass !== model.zoomOutClass)
1716
+ return false;
1717
+ if (this.zoomInLabel !== model.zoomInLabel)
1718
+ return false;
1719
+ if (this.controlClass !== model.controlClass)
1720
+ return false;
1721
+ if (this.zoomOutLabel !== model.zoomOutLabel)
1722
+ return false;
1723
+ return true;
1724
+ }
1725
+ setZoomInLabel(zoomInLabel) {
1726
+ return ZoomControlSettings.copy(Object.assign(Object.assign({}, this), { zoomInLabel }));
1727
+ }
1728
+ setZoomOutClass(zoomOutClass) {
1729
+ return ZoomControlSettings.copy(Object.assign(Object.assign({}, this), { zoomOutClass }));
1730
+ }
1731
+ setZoomInClass(zoomInClass) {
1732
+ return ZoomControlSettings.copy(Object.assign(Object.assign({}, this), { zoomInClass }));
1733
+ }
1734
+ setZoomOutLabel(zoomOutLabel) {
1735
+ return ZoomControlSettings.copy(Object.assign(Object.assign({}, this), { zoomOutLabel }));
1736
+ }
1737
+ setControlClass(controlClass) {
1738
+ return ZoomControlSettings.copy(Object.assign(Object.assign({}, this), { controlClass }));
1739
+ }
1740
+ }
1741
+
1742
+ class MapControlZoomComponent extends DestructibleComponent {
1743
+ set settings(value) {
1744
+ if (!value || this._settings.isSame(value))
1745
+ return;
1746
+ this._settings = value;
1747
+ this.setControl();
1748
+ }
1749
+ constructor(postboy) {
1750
+ super();
1751
+ this.postboy = postboy;
1752
+ this._settings = new ZoomControlSettings();
1753
+ this.onDestroy = () => {
1754
+ this.eliminate();
1755
+ };
1756
+ this.eliminate = () => !!this.map && !!this.control && this.map.removeControl(this.control);
1757
+ }
1758
+ ngOnInit() {
1759
+ this.postboy
1760
+ .subscribe(MapRenderedEvent.ID)
1761
+ .pipe(filter((m) => !!m), first())
1762
+ .subscribe((m) => {
1763
+ this.map = m.map;
1764
+ this.setControl();
1765
+ });
1766
+ }
1767
+ setControl() {
1768
+ if (!this.map)
1769
+ return;
1770
+ this.control = this.postboy.execute(new GenerateZoomControlExecutor(this._settings));
1771
+ this.map.addControl(this.control);
1772
+ }
1773
+ }
1774
+ MapControlZoomComponent.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "15.2.10", ngImport: i0, type: MapControlZoomComponent, deps: [{ token: MapPostboyService }], target: i0.ɵɵFactoryTarget.Component });
1775
+ MapControlZoomComponent.ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "14.0.0", version: "15.2.10", type: MapControlZoomComponent, selector: "lib-map-control-zoom", inputs: { settings: "settings" }, usesInheritance: true, ngImport: i0, template: '', isInline: true, changeDetection: i0.ChangeDetectionStrategy.OnPush });
1776
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "15.2.10", ngImport: i0, type: MapControlZoomComponent, decorators: [{
1777
+ type: Component,
1778
+ args: [{ selector: 'lib-map-control-zoom', template: '', changeDetection: ChangeDetectionStrategy.OnPush }]
1779
+ }], ctorParameters: function () { return [{ type: MapPostboyService }]; }, propDecorators: { settings: [{
1780
+ type: Input
1781
+ }] } });
1782
+
1571
1783
  class MapModule {
1572
1784
  }
1573
1785
  MapModule.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "15.2.10", ngImport: i0, type: MapModule, deps: [], target: i0.ɵɵFactoryTarget.NgModule });
@@ -1579,13 +1791,15 @@ MapModule.ɵmod = i0.ɵɵngDeclareNgModule({ minVersion: "14.0.0", version: "15.
1579
1791
  MarkersComponent,
1580
1792
  TooltipComponent,
1581
1793
  PolygonsComponent,
1582
- ClusterLayerComponent], imports: [CommonModule], exports: [MapPlateComponent,
1794
+ ClusterLayerComponent,
1795
+ MapControlZoomComponent], imports: [CommonModule], exports: [MapPlateComponent,
1583
1796
  FeatureLayerComponent,
1584
1797
  MarkersComponent,
1585
1798
  TileLayerComponent,
1586
1799
  TooltipComponent,
1587
1800
  PolygonsComponent,
1588
- ClusterLayerComponent] });
1801
+ ClusterLayerComponent,
1802
+ MapControlZoomComponent] });
1589
1803
  MapModule.ɵinj = i0.ɵɵngDeclareInjector({ minVersion: "12.0.0", version: "15.2.10", ngImport: i0, type: MapModule, imports: [CommonModule] });
1590
1804
  i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "15.2.10", ngImport: i0, type: MapModule, decorators: [{
1591
1805
  type: NgModule,
@@ -1601,6 +1815,7 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "15.2.10", ngImpo
1601
1815
  TooltipComponent,
1602
1816
  PolygonsComponent,
1603
1817
  ClusterLayerComponent,
1818
+ MapControlZoomComponent,
1604
1819
  ],
1605
1820
  exports: [
1606
1821
  MapPlateComponent,
@@ -1610,6 +1825,7 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "15.2.10", ngImpo
1610
1825
  TooltipComponent,
1611
1826
  PolygonsComponent,
1612
1827
  ClusterLayerComponent,
1828
+ MapControlZoomComponent,
1613
1829
  ],
1614
1830
  }]
1615
1831
  }] });
@@ -1653,6 +1869,23 @@ class PolygonStyleHelper {
1653
1869
  }),
1654
1870
  });
1655
1871
  }
1872
+ static edit(fill, stroke, strokeWidth = 1, pinRadius = 5) {
1873
+ return new Style({
1874
+ image: new Circle({
1875
+ fill: new Fill({
1876
+ color: stroke,
1877
+ }),
1878
+ radius: pinRadius,
1879
+ }),
1880
+ fill: new Fill({
1881
+ color: fill,
1882
+ }),
1883
+ stroke: new Stroke({
1884
+ color: stroke,
1885
+ width: strokeWidth,
1886
+ }),
1887
+ });
1888
+ }
1656
1889
  }
1657
1890
 
1658
1891
  class TextStyleHelper {
@@ -1727,5 +1960,5 @@ class StringifyFeatureHelper {
1727
1960
  * Generated bundle index. Do not edit.
1728
1961
  */
1729
1962
 
1730
- export { CancelDrawingCommand, CloseTooltipCommand, ClusterLayerComponent, ClusterLayerSettings, Dictionary, DrawSelectionAreaCommand, DrawingType, FeatureLayerComponent, FeatureLayerSettings, FeatureOutputFormat, MapClickEvent, MapLyrs, MapLyrsLabel, MapModule, MapMoveEndEvent, MapPlateComponent, MapPostboyService, MapRenderedEvent, MapSettings, MarkerModel, MarkerStyleHelper, MarkersComponent, MessageRegistratorService, OsmTileLayerComponent, PolygonModel, PolygonStyleHelper, PolygonsComponent, StartDrawingCommand, StringifyFeatureHelper, TextStyleHelper, TileLayerComponent, TileLayerSettings, TooltipComponent, TooltipSettings };
1963
+ export { CancelDrawingCommand, CancelFeatureModificationCommand, CloseTooltipCommand, ClusterLayerComponent, ClusterLayerSettings, Dictionary, DrawSelectionAreaCommand, DrawingType, FeatureLayerComponent, FeatureLayerSettings, FeatureOutputFormat, MapClickEvent, MapControlZoomComponent, MapLyrs, MapLyrsLabel, MapModule, MapMoveEndEvent, MapPlateComponent, MapPostboyService, MapRenderedEvent, MapSettings, MarkerModel, MarkerStyleHelper, MarkersComponent, MessageRegistratorService, ModifyFeatureCommand, OsmTileLayerComponent, PolygonModel, PolygonStyleHelper, PolygonsComponent, StartDrawingCommand, StringifyFeatureHelper, TextStyleHelper, TileLayerComponent, TileLayerSettings, TooltipComponent, TooltipSettings, ZoomControlSettings };
1731
1964
  //# sourceMappingURL=maps-components-src-map.mjs.map