@artstesh/maps 4.0.9 → 4.0.11

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 (82) hide show
  1. package/dist/esm2020/map/helpers/polygon-style.helper.mjs +19 -2
  2. package/dist/esm2020/map/map-plate/map-plate.component.mjs +7 -1
  3. package/dist/esm2020/map/messages/commands/cancel-feature-modification.command.mjs +8 -0
  4. package/dist/esm2020/map/messages/commands/draw-selection-area.command.mjs +14 -0
  5. package/dist/esm2020/map/messages/commands/modify-feature.command.mjs +15 -0
  6. package/dist/esm2020/map/messages/executors/filter-features-in-area.executor.mjs +13 -0
  7. package/dist/esm2020/map/messages/executors/generate-draw.executor.mjs +14 -0
  8. package/dist/esm2020/map/messages/index.mjs +4 -1
  9. package/dist/esm2020/map/messages/queries/get-features-in-area.query.mjs +13 -0
  10. package/dist/esm2020/map/models/dictionary.mjs +56 -0
  11. package/dist/esm2020/map/models/drawing-type.enum.mjs +2 -1
  12. package/dist/esm2020/map/models/index.mjs +2 -1
  13. package/dist/esm2020/map/services/drawing/drawing-generation.service.mjs +16 -21
  14. package/dist/esm2020/map/services/drawing/drawing.service.mjs +32 -14
  15. package/dist/esm2020/map/services/drawing/feature-modification.service.mjs +99 -0
  16. package/dist/esm2020/map/services/feature.service.mjs +16 -0
  17. package/dist/esm2020/map/services/map-management.service.mjs +28 -7
  18. package/dist/esm2020/map/services/message-registrator.service.mjs +23 -8
  19. package/dist/esm2020/src/map/helpers/polygon-style.helper.mjs +19 -2
  20. package/dist/esm2020/src/map/map-plate/map-plate.component.mjs +7 -1
  21. package/dist/esm2020/src/map/messages/commands/cancel-feature-modification.command.mjs +8 -0
  22. package/dist/esm2020/src/map/messages/commands/draw-selection-area.command.mjs +14 -0
  23. package/dist/esm2020/src/map/messages/commands/modify-feature.command.mjs +15 -0
  24. package/dist/esm2020/src/map/messages/executors/filter-features-in-area.executor.mjs +13 -0
  25. package/dist/esm2020/src/map/messages/executors/generate-draw.executor.mjs +14 -0
  26. package/dist/esm2020/src/map/messages/index.mjs +4 -1
  27. package/dist/esm2020/src/map/messages/queries/get-features-in-area.query.mjs +13 -0
  28. package/dist/esm2020/src/map/models/dictionary.mjs +56 -0
  29. package/dist/esm2020/src/map/models/drawing-type.enum.mjs +2 -1
  30. package/dist/esm2020/src/map/models/index.mjs +2 -1
  31. package/dist/esm2020/src/map/services/drawing/drawing-generation.service.mjs +16 -21
  32. package/dist/esm2020/src/map/services/drawing/drawing.service.mjs +32 -14
  33. package/dist/esm2020/src/map/services/drawing/feature-modification.service.mjs +99 -0
  34. package/dist/esm2020/src/map/services/feature.service.mjs +16 -0
  35. package/dist/esm2020/src/map/services/map-management.service.mjs +28 -7
  36. package/dist/esm2020/src/map/services/message-registrator.service.mjs +23 -8
  37. package/dist/fesm2015/maps-components-src-map.mjs +325 -43
  38. package/dist/fesm2015/maps-components-src-map.mjs.map +1 -1
  39. package/dist/fesm2015/maps-components.mjs +325 -43
  40. package/dist/fesm2015/maps-components.mjs.map +1 -1
  41. package/dist/fesm2020/maps-components-src-map.mjs +318 -41
  42. package/dist/fesm2020/maps-components-src-map.mjs.map +1 -1
  43. package/dist/fesm2020/maps-components.mjs +318 -41
  44. package/dist/fesm2020/maps-components.mjs.map +1 -1
  45. package/dist/map/helpers/polygon-style.helper.d.ts +1 -0
  46. package/dist/map/messages/commands/cancel-feature-modification.command.d.ts +5 -0
  47. package/dist/map/messages/commands/draw-selection-area.command.d.ts +12 -0
  48. package/dist/map/messages/commands/modify-feature.command.d.ts +11 -0
  49. package/dist/map/messages/executors/filter-features-in-area.executor.d.ts +10 -0
  50. package/dist/map/messages/{queries/generate-draw.query.d.ts → executors/generate-draw.executor.d.ts} +2 -2
  51. package/dist/map/messages/index.d.ts +3 -0
  52. package/dist/map/messages/queries/get-features-in-area.query.d.ts +11 -0
  53. package/dist/map/models/dictionary.d.ts +17 -0
  54. package/dist/map/models/drawing-type.enum.d.ts +2 -1
  55. package/dist/map/models/index.d.ts +1 -0
  56. package/dist/map/services/drawing/drawing-generation.service.d.ts +5 -9
  57. package/dist/map/services/drawing/drawing.service.d.ts +2 -0
  58. package/dist/map/services/drawing/feature-modification.service.d.ts +22 -0
  59. package/dist/map/services/feature.service.d.ts +8 -0
  60. package/dist/map/services/map-management.service.d.ts +1 -0
  61. package/dist/map/services/message-registrator.service.d.ts +3 -2
  62. package/dist/package.json +1 -1
  63. package/dist/src/map/helpers/polygon-style.helper.d.ts +1 -0
  64. package/dist/src/map/messages/commands/cancel-feature-modification.command.d.ts +5 -0
  65. package/dist/src/map/messages/commands/draw-selection-area.command.d.ts +12 -0
  66. package/dist/src/map/messages/commands/modify-feature.command.d.ts +11 -0
  67. package/dist/src/map/messages/executors/filter-features-in-area.executor.d.ts +10 -0
  68. package/dist/src/map/messages/{queries/generate-draw.query.d.ts → executors/generate-draw.executor.d.ts} +2 -2
  69. package/dist/src/map/messages/index.d.ts +3 -0
  70. package/dist/src/map/messages/queries/get-features-in-area.query.d.ts +11 -0
  71. package/dist/src/map/models/dictionary.d.ts +17 -0
  72. package/dist/src/map/models/drawing-type.enum.d.ts +2 -1
  73. package/dist/src/map/models/index.d.ts +1 -0
  74. package/dist/src/map/services/drawing/drawing-generation.service.d.ts +5 -9
  75. package/dist/src/map/services/drawing/drawing.service.d.ts +2 -0
  76. package/dist/src/map/services/drawing/feature-modification.service.d.ts +22 -0
  77. package/dist/src/map/services/feature.service.d.ts +8 -0
  78. package/dist/src/map/services/map-management.service.d.ts +1 -0
  79. package/dist/src/map/services/message-registrator.service.d.ts +3 -2
  80. package/package.json +2 -2
  81. package/dist/esm2020/map/messages/queries/generate-draw.query.mjs +0 -14
  82. package/dist/esm2020/src/map/messages/queries/generate-draw.query.mjs +0 -14
@@ -2,16 +2,16 @@ 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';
10
+ import { PostboyGenericMessage, PostboyCallbackMessage, PostboyExecutor, PostboyService, PostboyAbstractRegistrator } from '@artstesh/postboy';
11
+ import { Draw, Modify, Translate } from 'ol/interaction';
12
+ import { createRegularPolygon } from 'ol/interaction/Draw';
11
13
  import { first, filter, auditTime } from 'rxjs/operators';
12
14
  import { Vector, XYZ } from 'ol/source';
13
- import { Draw } from 'ol/interaction';
14
- import { createRegularPolygon } from 'ol/interaction/Draw';
15
15
  import TileLayer from 'ol/layer/Tile';
16
16
  import OSM from 'ol/source/OSM';
17
17
  import { Vector as Vector$1 } from 'ol/layer';
@@ -180,6 +180,7 @@ var DrawingType;
180
180
  (function (DrawingType) {
181
181
  DrawingType[DrawingType["Polygon"] = 1] = "Polygon";
182
182
  DrawingType[DrawingType["Circle"] = 2] = "Circle";
183
+ DrawingType[DrawingType["Square"] = 3] = "Square";
183
184
  })(DrawingType || (DrawingType = {}));
184
185
 
185
186
  var FeatureOutputFormat;
@@ -188,6 +189,62 @@ var FeatureOutputFormat;
188
189
  FeatureOutputFormat[FeatureOutputFormat["WKT"] = 2] = "WKT";
189
190
  })(FeatureOutputFormat || (FeatureOutputFormat = {}));
190
191
 
192
+ class Dictionary {
193
+ constructor() {
194
+ this.collection = {};
195
+ this._keys = new Set();
196
+ this.has = (key) => this._keys.has(key);
197
+ }
198
+ get keys() {
199
+ return Array.from(this._keys);
200
+ }
201
+ get size() {
202
+ return this._keys.size;
203
+ }
204
+ static clone(dic, action) {
205
+ return Dictionary.create(dic.collection, action);
206
+ }
207
+ static create(dic, action) {
208
+ let keyList = Object.keys(dic);
209
+ const result = new Dictionary();
210
+ for (let i = 0; i < keyList.length; i++) {
211
+ let key = keyList[i];
212
+ result._keys.add(key);
213
+ result.collection[key] = action ? action(dic[key], key) : dic[key];
214
+ }
215
+ return result;
216
+ }
217
+ find(predicate) {
218
+ let result = null;
219
+ this.forEach((e) => {
220
+ if (result === null && predicate(e))
221
+ result = e;
222
+ });
223
+ return result;
224
+ }
225
+ take(key) {
226
+ return this._keys.has(key) ? this.collection[key] : null;
227
+ }
228
+ put(key, value) {
229
+ if (value == null)
230
+ return;
231
+ this.collection[key] = value;
232
+ this._keys.add(key);
233
+ }
234
+ rmv(key) {
235
+ if (!this._keys.has(key))
236
+ return;
237
+ delete this.collection[key];
238
+ this._keys.delete(key);
239
+ }
240
+ forEach(callback) {
241
+ let keys = Object.keys(this.collection);
242
+ for (let i = 0; i < keys.length; i++) {
243
+ callback(this.collection[keys[i]], i);
244
+ }
245
+ }
246
+ }
247
+
191
248
  class MapRenderedEvent extends PostboyGenericMessage {
192
249
  constructor(map) {
193
250
  super();
@@ -255,6 +312,39 @@ class CancelDrawingCommand extends PostboyGenericMessage {
255
312
  }
256
313
  CancelDrawingCommand.ID = '7d38d983-feba-4176-a66b-18175e5ecd6b';
257
314
 
315
+ class DrawSelectionAreaCommand extends PostboyCallbackMessage {
316
+ constructor(type, style, ignore = new Set()) {
317
+ super();
318
+ this.type = type;
319
+ this.style = style;
320
+ this.ignore = ignore;
321
+ }
322
+ get id() {
323
+ return DrawSelectionAreaCommand.ID;
324
+ }
325
+ }
326
+ DrawSelectionAreaCommand.ID = '573d8a0d-f25b-42b7-9ad7-0ac6d86ac362';
327
+
328
+ class ModifyFeatureCommand extends PostboyCallbackMessage {
329
+ constructor(model, style, format = FeatureOutputFormat.GeoJson) {
330
+ super();
331
+ this.model = model;
332
+ this.style = style;
333
+ this.format = format;
334
+ }
335
+ get id() {
336
+ return ModifyFeatureCommand.ID;
337
+ }
338
+ }
339
+ ModifyFeatureCommand.ID = 'ead85caa-24c6-4844-a68c-2cea91774c8c';
340
+
341
+ class CancelFeatureModificationCommand extends PostboyGenericMessage {
342
+ get id() {
343
+ return CancelFeatureModificationCommand.ID;
344
+ }
345
+ }
346
+ CancelFeatureModificationCommand.ID = '9c9fb40f-ea95-4704-8177-0e9ecabf36fa';
347
+
258
348
  class AddLayerCommand extends PostboyGenericMessage {
259
349
  constructor(layer) {
260
350
  super();
@@ -344,7 +434,67 @@ class DrawingFinishedEvent extends PostboyGenericMessage {
344
434
  }
345
435
  DrawingFinishedEvent.ID = 'c724b68e-b4eb-4783-90f1-a8e31973fd36';
346
436
 
347
- class GenerateDrawQuery extends PostboyCallbackMessage {
437
+ class DrawingGenerationService {
438
+ static getDraw(ev) {
439
+ return new Draw({
440
+ source: ev.layer.getSource(),
441
+ type: ev.type === DrawingType.Polygon ? 'Polygon' : 'Circle',
442
+ style: ev.style,
443
+ geometryFunction: DrawingGenerationService.geometryFunc(ev.type),
444
+ });
445
+ }
446
+ static geometryFunc(type) {
447
+ switch (type) {
448
+ case DrawingType.Circle:
449
+ return createRegularPolygon(32);
450
+ case DrawingType.Square:
451
+ return createRegularPolygon(4);
452
+ }
453
+ return undefined;
454
+ }
455
+ }
456
+
457
+ class FeatureService {
458
+ constructor() { }
459
+ static filterFeaturesInArea(query) {
460
+ return query.features.filter((f) => FeatureService.booleanIntersects(query.area, f.getGeometry()));
461
+ }
462
+ static booleanIntersects(g1, g2) {
463
+ if (g2.getType() === 'Point')
464
+ return g1.intersectsCoordinate(g2.getCoordinates());
465
+ if (g2.getType() === 'Circle')
466
+ return g1.intersectsCoordinate(g2.getCenter());
467
+ if (g2.getType() === 'Polygon')
468
+ return g1.intersectsCoordinate(g2.getInteriorPoint().getCoordinates());
469
+ return false;
470
+ }
471
+ }
472
+
473
+ class GetFeaturesInAreaQuery extends PostboyCallbackMessage {
474
+ constructor(area, ignore = new Set()) {
475
+ super();
476
+ this.area = area;
477
+ this.ignore = ignore;
478
+ }
479
+ get id() {
480
+ return GetFeaturesInAreaQuery.ID;
481
+ }
482
+ }
483
+ GetFeaturesInAreaQuery.ID = 'efcf4271-a07a-40e0-9f02-d4dade40b8ac';
484
+
485
+ class FilterFeaturesInAreaExecutor extends PostboyExecutor {
486
+ constructor(area, features) {
487
+ super();
488
+ this.area = area;
489
+ this.features = features;
490
+ }
491
+ get id() {
492
+ return FilterFeaturesInAreaExecutor.ID;
493
+ }
494
+ }
495
+ FilterFeaturesInAreaExecutor.ID = '36bb2d94-8028-4512-90dd-2386af3fc67c';
496
+
497
+ class GenerateDrawExecutor extends PostboyExecutor {
348
498
  constructor(layer, style, type) {
349
499
  super();
350
500
  this.layer = layer;
@@ -352,10 +502,10 @@ class GenerateDrawQuery extends PostboyCallbackMessage {
352
502
  this.type = type;
353
503
  }
354
504
  get id() {
355
- return GenerateDrawQuery.ID;
505
+ return GenerateDrawExecutor.ID;
356
506
  }
357
507
  }
358
- GenerateDrawQuery.ID = 'f01c99ba-0953-4ab5-82f9-04e6fbb678c1';
508
+ GenerateDrawExecutor.ID = 'f01c99ba-0953-4ab5-82f9-04e6fbb678c1';
359
509
 
360
510
  class MapPostboyService extends PostboyService {
361
511
  constructor() {
@@ -372,7 +522,7 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "15.2.10", ngImpo
372
522
  class MapManagementService {
373
523
  constructor(postboy) {
374
524
  this.postboy = postboy;
375
- this.layers = {};
525
+ this.layers = new Dictionary();
376
526
  }
377
527
  up() {
378
528
  this.observeMapRender();
@@ -382,6 +532,7 @@ class MapManagementService {
382
532
  this.observeAddTile();
383
533
  this.observeRemoveTile();
384
534
  this.observeLayerQuery();
535
+ this.observeFeaturesInArea();
385
536
  }
386
537
  observeRemoveTile() {
387
538
  this.postboy.subscribe(RemoveTileCommand.ID).subscribe((c) => {
@@ -391,7 +542,7 @@ class MapManagementService {
391
542
  });
392
543
  }
393
544
  observeLayerQuery() {
394
- this.postboy.subscribe(GetLayerQuery.ID).subscribe((ev) => { var _a; return ev.finish((_a = this.layers[ev.name]) !== null && _a !== void 0 ? _a : null); });
545
+ this.postboy.subscribe(GetLayerQuery.ID).subscribe((ev) => ev.finish(this.layers.take(ev.name)));
395
546
  }
396
547
  observeAddTile() {
397
548
  this.postboy.subscribe(AddTileCommand.ID).subscribe((c) => {
@@ -409,16 +560,15 @@ class MapManagementService {
409
560
  this.postboy.subscribe(AddLayerCommand.ID).subscribe((c) => {
410
561
  if (!this.map)
411
562
  return;
412
- this.layers[c.layer.get('name')] = c.layer;
563
+ this.layers.put(c.layer.get('name'), c.layer);
413
564
  this.map.addLayer(c.layer);
414
565
  });
415
566
  }
416
567
  observePlaceFeatures() {
417
568
  this.postboy.subscribe(PlaceLayerFeaturesCommand.ID).subscribe((c) => {
418
- var _a;
419
- if (!this.layers[c.layer])
569
+ if (!this.layers.has(c.layer))
420
570
  return;
421
- let source = (_a = this.layers[c.layer]) === null || _a === void 0 ? void 0 : _a.getSource();
571
+ let source = this.layers.take(c.layer).getSource();
422
572
  if (!!source['getSource'])
423
573
  source = source === null || source === void 0 ? void 0 : source.getSource();
424
574
  source === null || source === void 0 ? void 0 : source.clear();
@@ -429,10 +579,27 @@ class MapManagementService {
429
579
  this.postboy.subscribe(RemoveLayerCommand.ID).subscribe((c) => {
430
580
  if (!this.map)
431
581
  return;
432
- delete this.layers[c.layer.get('name')];
582
+ this.layers.rmv(c.layer.get('name'));
433
583
  this.map.removeLayer(c.layer);
434
584
  });
435
585
  }
586
+ observeFeaturesInArea() {
587
+ this.postboy.subscribe(GetFeaturesInAreaQuery.ID).subscribe((qr) => {
588
+ let result = new Dictionary();
589
+ this.layers.forEach((l) => {
590
+ var _a;
591
+ let layerName = l.get('name');
592
+ if (qr.ignore.has(layerName) || layerName === MapConstants.DrawingLayerId)
593
+ return;
594
+ let source = l.getSource();
595
+ if (!!source['getSource'])
596
+ source = source === null || source === void 0 ? void 0 : source.getSource();
597
+ let features = this.postboy.execute(new FilterFeaturesInAreaExecutor(qr.area, (_a = source === null || source === void 0 ? void 0 : source.getFeatures()) !== null && _a !== void 0 ? _a : []));
598
+ result.put(layerName, features.map((e) => (Object.assign({ id: e.getId() }, e.get(MapConstants.FeatureInfo)))));
599
+ });
600
+ qr.finish(result);
601
+ });
602
+ }
436
603
  }
437
604
  MapManagementService.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "15.2.10", ngImport: i0, type: MapManagementService, deps: [{ token: MapPostboyService }], target: i0.ɵɵFactoryTarget.Injectable });
438
605
  MapManagementService.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "15.2.10", ngImport: i0, type: MapManagementService });
@@ -550,27 +717,43 @@ class DrawingService {
550
717
  this.postboy = postboy;
551
718
  }
552
719
  up() {
720
+ this.observeDrawing();
721
+ this.observeSelectArea();
722
+ this.observeMapRender();
723
+ }
724
+ observeSelectArea() {
725
+ this.postboy.subscribe(DrawSelectionAreaCommand.ID).subscribe((ev) => {
726
+ const drawingCommand = new StartDrawingCommand(ev.type, ev.style);
727
+ drawingCommand.result.subscribe((r) => {
728
+ if (!r) {
729
+ ev.finish(new Dictionary());
730
+ return;
731
+ }
732
+ const area = PolygonModel.fromGeoJson(1, r).feature.getGeometry();
733
+ const getFeaturesCommand = new GetFeaturesInAreaQuery(area, ev.ignore);
734
+ getFeaturesCommand.result.subscribe((result) => ev.finish(result));
735
+ this.postboy.fire(getFeaturesCommand);
736
+ });
737
+ this.postboy.fire(drawingCommand);
738
+ });
739
+ }
740
+ observeDrawing() {
553
741
  this.postboy.subscribe(StartDrawingCommand.ID).subscribe((ev) => {
554
742
  this.draw((l) => {
743
+ var _a;
555
744
  if (!l || !this.map) {
556
745
  this.clearInteraction(l);
557
746
  return;
558
747
  }
559
- const drawQuery = new GenerateDrawQuery(l, ev.style, ev.type);
560
- drawQuery.result.subscribe((draw) => {
561
- var _a;
562
- const cancelSub = this.observeCancelation(ev, l);
563
- this.drawInteraction = draw;
564
- (_a = this.map) === null || _a === void 0 ? void 0 : _a.addInteraction(this.drawInteraction);
565
- this.drawInteraction.on('drawend', (evt) => {
566
- cancelSub.unsubscribe();
567
- this.onEnd(evt, ev, l);
568
- });
748
+ const cancelSub = this.observeCancelation(ev, l);
749
+ this.drawInteraction = this.postboy.execute(new GenerateDrawExecutor(l, ev.style, ev.type));
750
+ (_a = this.map) === null || _a === void 0 ? void 0 : _a.addInteraction(this.drawInteraction);
751
+ this.drawInteraction.on('drawend', (evt) => {
752
+ cancelSub.unsubscribe();
753
+ this.onEnd(evt, ev, l);
569
754
  });
570
- this.postboy.fire(drawQuery);
571
755
  });
572
756
  });
573
- this.observeMapRender();
574
757
  }
575
758
  onEnd(evt, command, layer) {
576
759
  command.finish(command.format === FeatureOutputFormat.GeoJson
@@ -612,31 +795,101 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "15.2.10", ngImpo
612
795
  type: Injectable
613
796
  }], ctorParameters: function () { return [{ type: MapPostboyService }]; } });
614
797
 
615
- class DrawingGenerationService {
798
+ class FeatureModificationService {
616
799
  constructor(postboy) {
617
800
  this.postboy = postboy;
618
801
  }
619
802
  up() {
620
- this.postboy.subscribe(GenerateDrawQuery.ID).subscribe((ev) => {
621
- ev.finish(new Draw({
622
- source: ev.layer.getSource(),
623
- type: DrawingType[ev.type],
624
- style: ev.style,
625
- geometryFunction: ev.type !== DrawingType.Circle ? undefined : createRegularPolygon(32),
626
- }));
803
+ this.observeModification();
804
+ this.observeMapRender();
805
+ }
806
+ observeModification() {
807
+ this.postboy.subscribe(ModifyFeatureCommand.ID).subscribe((ev) => {
808
+ this.defineLayer((l) => {
809
+ if (!l || !this.map) {
810
+ this.clearInteraction(l);
811
+ return;
812
+ }
813
+ this.observeCancelation(ev, l);
814
+ this.initFeature(l, ev.model.feature);
815
+ this.addModify(ev);
816
+ this.addDragging(ev);
817
+ });
818
+ });
819
+ }
820
+ initFeature(layer, feature) {
821
+ var _a, _b;
822
+ (_a = layer.getSource()) === null || _a === void 0 ? void 0 : _a.clear();
823
+ (_b = layer.getSource()) === null || _b === void 0 ? void 0 : _b.addFeature(feature);
824
+ }
825
+ addModify(command) {
826
+ var _a;
827
+ this.modify = new Modify({
828
+ features: new Collection([command.model.feature]),
829
+ style: command.style,
627
830
  });
831
+ this.modify.on('modifyend', () => {
832
+ this.onModified(command);
833
+ command.model.feature.changed();
834
+ });
835
+ (_a = this.map) === null || _a === void 0 ? void 0 : _a.addInteraction(this.modify);
836
+ }
837
+ addDragging(command) {
838
+ var _a;
839
+ this.translate = new Translate({
840
+ features: new Collection([command.model.feature]),
841
+ condition: (ev) => {
842
+ var _a;
843
+ const clone = command.model.feature.clone();
844
+ (_a = clone.getGeometry()) === null || _a === void 0 ? void 0 : _a.scale(0.999);
845
+ return clone.getGeometry().intersectsCoordinate(ev.coordinate);
846
+ },
847
+ });
848
+ this.translate.on('translateend', () => this.onModified(command));
849
+ (_a = this.map) === null || _a === void 0 ? void 0 : _a.addInteraction(this.translate);
850
+ }
851
+ onModified(command) {
852
+ command.next(command.format === FeatureOutputFormat.GeoJson
853
+ ? new GeoJSON().writeFeature(command.model.feature)
854
+ : new WKT().writeFeature(command.model.feature));
855
+ }
856
+ observeMapRender() {
857
+ this.postboy.subscribe(MapRenderedEvent.ID).subscribe((m) => {
858
+ this.map = m.map;
859
+ });
860
+ }
861
+ defineLayer(action) {
862
+ const query = new GetLayerQuery(MapConstants.DrawingLayerId);
863
+ query.result.subscribe((l) => action(l));
864
+ this.postboy.fire(query);
865
+ }
866
+ observeCancelation(ev, layer) {
867
+ return this.postboy
868
+ .subscribe(CancelFeatureModificationCommand.ID)
869
+ .pipe(first())
870
+ .subscribe(() => {
871
+ ev.finish(null);
872
+ this.clearInteraction(layer);
873
+ });
874
+ }
875
+ clearInteraction(layer) {
876
+ var _a, _b;
877
+ if (this.modify)
878
+ (_a = this.map) === null || _a === void 0 ? void 0 : _a.removeInteraction(this.modify);
879
+ if (this.translate)
880
+ (_b = this.map) === null || _b === void 0 ? void 0 : _b.removeInteraction(this.translate);
628
881
  }
629
882
  }
630
- DrawingGenerationService.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "15.2.10", ngImport: i0, type: DrawingGenerationService, deps: [{ token: MapPostboyService }], target: i0.ɵɵFactoryTarget.Injectable });
631
- DrawingGenerationService.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "15.2.10", ngImport: i0, type: DrawingGenerationService });
632
- i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "15.2.10", ngImport: i0, type: DrawingGenerationService, decorators: [{
883
+ FeatureModificationService.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "15.2.10", ngImport: i0, type: FeatureModificationService, deps: [{ token: MapPostboyService }], target: i0.ɵɵFactoryTarget.Injectable });
884
+ FeatureModificationService.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "15.2.10", ngImport: i0, type: FeatureModificationService });
885
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "15.2.10", ngImport: i0, type: FeatureModificationService, decorators: [{
633
886
  type: Injectable
634
887
  }], ctorParameters: function () { return [{ type: MapPostboyService }]; } });
635
888
 
636
889
  class MessageRegistratorService extends PostboyAbstractRegistrator {
637
- constructor(service, management, state, feature, interaction, drawing, drawGenerator) {
890
+ constructor(service, management, state, mapFeature, interaction, drawing, featureModification) {
638
891
  super(service);
639
- this.registerServices([management, state, interaction, feature, drawing, drawGenerator]);
892
+ this.registerServices([management, state, interaction, mapFeature, drawing, featureModification]);
640
893
  }
641
894
  _up() {
642
895
  this.registerReplay(MapRenderedEvent.ID);
@@ -653,14 +906,22 @@ class MessageRegistratorService extends PostboyAbstractRegistrator {
653
906
  this.registerSubject(StartDrawingCommand.ID);
654
907
  this.registerSubject(GetLayerQuery.ID);
655
908
  this.registerSubject(DrawingFinishedEvent.ID);
656
- this.registerSubject(GenerateDrawQuery.ID);
909
+ this.registerSubject(GetFeaturesInAreaQuery.ID);
910
+ this.registerSubject(DrawSelectionAreaCommand.ID);
911
+ this.registerSubject(CancelFeatureModificationCommand.ID);
912
+ this.registerSubject(ModifyFeatureCommand.ID);
913
+ this.setExecutors();
914
+ }
915
+ setExecutors() {
916
+ this.registerExecutor(FilterFeaturesInAreaExecutor.ID, (e) => FeatureService.filterFeaturesInArea(e));
917
+ this.registerExecutor(GenerateDrawExecutor.ID, (e) => DrawingGenerationService.getDraw(e));
657
918
  }
658
919
  }
659
- 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 }], target: i0.ɵɵFactoryTarget.Injectable });
920
+ 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 });
660
921
  MessageRegistratorService.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "15.2.10", ngImport: i0, type: MessageRegistratorService });
661
922
  i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "15.2.10", ngImport: i0, type: MessageRegistratorService, decorators: [{
662
923
  type: Injectable
663
- }], ctorParameters: function () { return [{ type: MapPostboyService }, { type: MapManagementService }, { type: MapStateService }, { type: MapFeatureService }, { type: MapClickService }, { type: DrawingService }, { type: DrawingGenerationService }]; } });
924
+ }], ctorParameters: function () { return [{ type: MapPostboyService }, { type: MapManagementService }, { type: MapStateService }, { type: MapFeatureService }, { type: MapClickService }, { type: DrawingService }, { type: FeatureModificationService }]; } });
664
925
 
665
926
  class TileLayerSettings {
666
927
  constructor() {
@@ -1218,6 +1479,8 @@ MapPlateComponent.ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "14.0.0", vers
1218
1479
  MapFeatureService,
1219
1480
  DrawingService,
1220
1481
  DrawingGenerationService,
1482
+ FeatureService,
1483
+ FeatureModificationService,
1221
1484
  ], 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 });
1222
1485
  i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "15.2.10", ngImport: i0, type: MapPlateComponent, decorators: [{
1223
1486
  type: Component,
@@ -1229,6 +1492,8 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "15.2.10", ngImpo
1229
1492
  MapFeatureService,
1230
1493
  DrawingService,
1231
1494
  DrawingGenerationService,
1495
+ FeatureService,
1496
+ FeatureModificationService,
1232
1497
  ], 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"] }]
1233
1498
  }], ctorParameters: function () { return [{ type: i0.ElementRef }, { type: MapPostboyService }, { type: MapPlateFactory }, { type: MessageRegistratorService }, { type: i0.ChangeDetectorRef }]; }, propDecorators: { settings: [{
1234
1499
  type: Input
@@ -1487,6 +1752,23 @@ class PolygonStyleHelper {
1487
1752
  }),
1488
1753
  });
1489
1754
  }
1755
+ static edit(fill, stroke, strokeWidth = 1, pinRadius = 5) {
1756
+ return new Style({
1757
+ image: new Circle({
1758
+ fill: new Fill({
1759
+ color: stroke,
1760
+ }),
1761
+ radius: pinRadius,
1762
+ }),
1763
+ fill: new Fill({
1764
+ color: fill,
1765
+ }),
1766
+ stroke: new Stroke({
1767
+ color: stroke,
1768
+ width: strokeWidth,
1769
+ }),
1770
+ });
1771
+ }
1490
1772
  }
1491
1773
 
1492
1774
  class TextStyleHelper {
@@ -1565,5 +1847,5 @@ class StringifyFeatureHelper {
1565
1847
  * Generated bundle index. Do not edit.
1566
1848
  */
1567
1849
 
1568
- export { CancelDrawingCommand, CloseTooltipCommand, ClusterLayerComponent, ClusterLayerSettings, 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 };
1850
+ export { CancelDrawingCommand, CancelFeatureModificationCommand, CloseTooltipCommand, ClusterLayerComponent, ClusterLayerSettings, Dictionary, DrawSelectionAreaCommand, DrawingType, FeatureLayerComponent, FeatureLayerSettings, FeatureOutputFormat, MapClickEvent, MapLyrs, MapLyrsLabel, MapModule, MapMoveEndEvent, MapPlateComponent, MapPostboyService, MapRenderedEvent, MapSettings, MarkerModel, MarkerStyleHelper, MarkersComponent, MessageRegistratorService, ModifyFeatureCommand, OsmTileLayerComponent, PolygonModel, PolygonStyleHelper, PolygonsComponent, StartDrawingCommand, StringifyFeatureHelper, TextStyleHelper, TileLayerComponent, TileLayerSettings, TooltipComponent, TooltipSettings };
1569
1851
  //# sourceMappingURL=maps-components.mjs.map