@artstesh/maps 5.0.8 → 5.0.10

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 (67) hide show
  1. package/dist/esm2022/map/helpers/index.mjs +2 -1
  2. package/dist/esm2022/map/helpers/stringify-feature.helper.mjs +58 -0
  3. package/dist/esm2022/map/map-plate/map-plate.component.mjs +7 -1
  4. package/dist/esm2022/map/messages/commands/draw-selection-area.command.mjs +17 -0
  5. package/dist/esm2022/map/messages/index.mjs +2 -1
  6. package/dist/esm2022/map/messages/queries/filter-features-in-area.query.mjs +15 -0
  7. package/dist/esm2022/map/messages/queries/generate-draw.query.mjs +17 -0
  8. package/dist/esm2022/map/messages/queries/get-features-in-area.query.mjs +15 -0
  9. package/dist/esm2022/map/models/dictionary.mjs +54 -0
  10. package/dist/esm2022/map/models/drawing-type.enum.mjs +2 -1
  11. package/dist/esm2022/map/models/index.mjs +2 -1
  12. package/dist/esm2022/map/services/drawing/drawing-generation.service.mjs +29 -0
  13. package/dist/esm2022/map/services/drawing/drawing.service.mjs +36 -14
  14. package/dist/esm2022/map/services/feature.service.mjs +30 -0
  15. package/dist/esm2022/map/services/map-management.service.mjs +36 -7
  16. package/dist/esm2022/map/services/message-registrator.service.mjs +15 -5
  17. package/dist/esm2022/src/map/helpers/index.mjs +2 -1
  18. package/dist/esm2022/src/map/helpers/stringify-feature.helper.mjs +58 -0
  19. package/dist/esm2022/src/map/map-plate/map-plate.component.mjs +7 -1
  20. package/dist/esm2022/src/map/messages/commands/draw-selection-area.command.mjs +17 -0
  21. package/dist/esm2022/src/map/messages/index.mjs +2 -1
  22. package/dist/esm2022/src/map/messages/queries/filter-features-in-area.query.mjs +15 -0
  23. package/dist/esm2022/src/map/messages/queries/generate-draw.query.mjs +17 -0
  24. package/dist/esm2022/src/map/messages/queries/get-features-in-area.query.mjs +15 -0
  25. package/dist/esm2022/src/map/models/dictionary.mjs +54 -0
  26. package/dist/esm2022/src/map/models/drawing-type.enum.mjs +2 -1
  27. package/dist/esm2022/src/map/models/index.mjs +2 -1
  28. package/dist/esm2022/src/map/services/drawing/drawing-generation.service.mjs +29 -0
  29. package/dist/esm2022/src/map/services/drawing/drawing.service.mjs +36 -14
  30. package/dist/esm2022/src/map/services/feature.service.mjs +30 -0
  31. package/dist/esm2022/src/map/services/map-management.service.mjs +36 -7
  32. package/dist/esm2022/src/map/services/message-registrator.service.mjs +15 -5
  33. package/dist/fesm2022/maps-components-src-map.mjs +294 -27
  34. package/dist/fesm2022/maps-components-src-map.mjs.map +1 -1
  35. package/dist/fesm2022/maps-components.mjs +294 -27
  36. package/dist/fesm2022/maps-components.mjs.map +1 -1
  37. package/dist/map/helpers/index.d.ts +1 -0
  38. package/dist/map/helpers/stringify-feature.helper.d.ts +8 -0
  39. package/dist/map/messages/commands/draw-selection-area.command.d.ts +12 -0
  40. package/dist/map/messages/index.d.ts +1 -0
  41. package/dist/map/messages/queries/filter-features-in-area.query.d.ts +10 -0
  42. package/dist/map/messages/queries/generate-draw.query.d.ts +14 -0
  43. package/dist/map/messages/queries/get-features-in-area.query.d.ts +11 -0
  44. package/dist/map/models/dictionary.d.ts +17 -0
  45. package/dist/map/models/drawing-type.enum.d.ts +2 -1
  46. package/dist/map/models/index.d.ts +1 -0
  47. package/dist/map/services/drawing/drawing-generation.service.d.ts +10 -0
  48. package/dist/map/services/drawing/drawing.service.d.ts +2 -0
  49. package/dist/map/services/feature.service.d.ts +11 -0
  50. package/dist/map/services/map-management.service.d.ts +1 -0
  51. package/dist/map/services/message-registrator.service.d.ts +3 -1
  52. package/dist/src/map/helpers/index.d.ts +1 -0
  53. package/dist/src/map/helpers/stringify-feature.helper.d.ts +8 -0
  54. package/dist/src/map/messages/commands/draw-selection-area.command.d.ts +12 -0
  55. package/dist/src/map/messages/index.d.ts +1 -0
  56. package/dist/src/map/messages/queries/filter-features-in-area.query.d.ts +10 -0
  57. package/dist/src/map/messages/queries/generate-draw.query.d.ts +14 -0
  58. package/dist/src/map/messages/queries/get-features-in-area.query.d.ts +11 -0
  59. package/dist/src/map/models/dictionary.d.ts +17 -0
  60. package/dist/src/map/models/drawing-type.enum.d.ts +2 -1
  61. package/dist/src/map/models/index.d.ts +1 -0
  62. package/dist/src/map/services/drawing/drawing-generation.service.d.ts +10 -0
  63. package/dist/src/map/services/drawing/drawing.service.d.ts +2 -0
  64. package/dist/src/map/services/feature.service.d.ts +11 -0
  65. package/dist/src/map/services/map-management.service.d.ts +1 -0
  66. package/dist/src/map/services/message-registrator.service.d.ts +3 -1
  67. package/package.json +2 -2
@@ -3,26 +3,28 @@ import { Component, Injectable, ChangeDetectionStrategy, Input, ViewChild, NgMod
3
3
  import * as i4 from '@angular/common';
4
4
  import { CommonModule } from '@angular/common';
5
5
  import { Feature } from 'ol';
6
- import { Point } from 'ol/geom';
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
- import { get, useGeographic } from 'ol/proj';
9
+ import { get, useGeographic, transform } from 'ol/proj';
10
10
  import { PostboyGenericMessage, PostboyCallbackMessage, PostboyService, PostboyAbstractRegistrator } from '@artstesh/postboy';
11
- import { first, filter, auditTime } from 'rxjs/operators';
11
+ import { forkJoin, combineLatest } from 'rxjs';
12
+ import { tap, first, filter, auditTime } from 'rxjs/operators';
12
13
  import { Vector, XYZ } from 'ol/source';
13
14
  import { Draw } from 'ol/interaction';
15
+ import { createRegularPolygon } from 'ol/interaction/Draw';
14
16
  import TileLayer from 'ol/layer/Tile';
15
17
  import OSM from 'ol/source/OSM';
16
18
  import { Vector as Vector$1 } from 'ol/layer';
17
19
  import { bbox } from 'ol/loadingstrategy';
18
- import { fromExtent } from 'ol/geom/Polygon';
20
+ import Polygon, { fromExtent } from 'ol/geom/Polygon';
19
21
  import Cluster from 'ol/source/Cluster';
20
- import { combineLatest } from 'rxjs';
21
22
  import Map from 'ol/Map';
22
23
  import View from 'ol/View';
23
24
  import Overlay from 'ol/Overlay';
24
25
  import Style from 'ol/style/Style';
25
26
  import { Icon, Circle, Fill, Stroke, Text } from 'ol/style';
27
+ import { METERS_PER_UNIT } from 'ol/proj/epsg4326';
26
28
 
27
29
  class DestructibleComponent {
28
30
  subs = [];
@@ -183,6 +185,7 @@ class PolygonModel {
183
185
  var DrawingType;
184
186
  (function (DrawingType) {
185
187
  DrawingType[DrawingType["Polygon"] = 1] = "Polygon";
188
+ DrawingType[DrawingType["Circle"] = 2] = "Circle";
186
189
  })(DrawingType || (DrawingType = {}));
187
190
 
188
191
  var FeatureOutputFormat;
@@ -191,6 +194,60 @@ var FeatureOutputFormat;
191
194
  FeatureOutputFormat[FeatureOutputFormat["WKT"] = 2] = "WKT";
192
195
  })(FeatureOutputFormat || (FeatureOutputFormat = {}));
193
196
 
197
+ class Dictionary {
198
+ collection = {};
199
+ _keys = new Set();
200
+ get keys() {
201
+ return Array.from(this._keys);
202
+ }
203
+ get size() {
204
+ return this._keys.size;
205
+ }
206
+ static clone(dic, action) {
207
+ return Dictionary.create(dic.collection, action);
208
+ }
209
+ static create(dic, action) {
210
+ let keyList = Object.keys(dic);
211
+ const result = new Dictionary();
212
+ for (let i = 0; i < keyList.length; i++) {
213
+ let key = keyList[i];
214
+ result._keys.add(key);
215
+ result.collection[key] = action ? action(dic[key], key) : dic[key];
216
+ }
217
+ return result;
218
+ }
219
+ find(predicate) {
220
+ let result = null;
221
+ this.forEach((e) => {
222
+ if (result === null && predicate(e))
223
+ result = e;
224
+ });
225
+ return result;
226
+ }
227
+ has = (key) => this._keys.has(key);
228
+ take(key) {
229
+ return this._keys.has(key) ? this.collection[key] : null;
230
+ }
231
+ put(key, value) {
232
+ if (value == null)
233
+ return;
234
+ this.collection[key] = value;
235
+ this._keys.add(key);
236
+ }
237
+ rmv(key) {
238
+ if (!this._keys.has(key))
239
+ return;
240
+ delete this.collection[key];
241
+ this._keys.delete(key);
242
+ }
243
+ forEach(callback) {
244
+ let keys = Object.keys(this.collection);
245
+ for (let i = 0; i < keys.length; i++) {
246
+ callback(this.collection[keys[i]], i);
247
+ }
248
+ }
249
+ }
250
+
194
251
  class MapRenderedEvent extends PostboyGenericMessage {
195
252
  map;
196
253
  static ID = 'b6121807-3b89-4cd3-82cf-089d2cefdc4f';
@@ -268,6 +325,22 @@ class CancelDrawingCommand extends PostboyGenericMessage {
268
325
  }
269
326
  }
270
327
 
328
+ class DrawSelectionAreaCommand extends PostboyCallbackMessage {
329
+ type;
330
+ style;
331
+ ignore;
332
+ static ID = '573d8a0d-f25b-42b7-9ad7-0ac6d86ac362';
333
+ constructor(type, style, ignore = new Set()) {
334
+ super();
335
+ this.type = type;
336
+ this.style = style;
337
+ this.ignore = ignore;
338
+ }
339
+ get id() {
340
+ return DrawSelectionAreaCommand.ID;
341
+ }
342
+ }
343
+
271
344
  class AddLayerCommand extends PostboyGenericMessage {
272
345
  layer;
273
346
  static ID = 'd93e250f-92bc-43ac-9c6a-46c521a1aaa5';
@@ -366,6 +439,50 @@ class DrawingFinishedEvent extends PostboyGenericMessage {
366
439
  }
367
440
  }
368
441
 
442
+ class GenerateDrawQuery extends PostboyCallbackMessage {
443
+ layer;
444
+ style;
445
+ type;
446
+ static ID = 'f01c99ba-0953-4ab5-82f9-04e6fbb678c1';
447
+ constructor(layer, style, type) {
448
+ super();
449
+ this.layer = layer;
450
+ this.style = style;
451
+ this.type = type;
452
+ }
453
+ get id() {
454
+ return GenerateDrawQuery.ID;
455
+ }
456
+ }
457
+
458
+ class FilterFeaturesInAreaQuery extends PostboyCallbackMessage {
459
+ area;
460
+ features;
461
+ static ID = '36bb2d94-8028-4512-90dd-2386af3fc67c';
462
+ constructor(area, features) {
463
+ super();
464
+ this.area = area;
465
+ this.features = features;
466
+ }
467
+ get id() {
468
+ return FilterFeaturesInAreaQuery.ID;
469
+ }
470
+ }
471
+
472
+ class GetFeaturesInAreaQuery extends PostboyCallbackMessage {
473
+ area;
474
+ ignore;
475
+ static ID = 'efcf4271-a07a-40e0-9f02-d4dade40b8ac';
476
+ constructor(area, ignore = new Set()) {
477
+ super();
478
+ this.area = area;
479
+ this.ignore = ignore;
480
+ }
481
+ get id() {
482
+ return GetFeaturesInAreaQuery.ID;
483
+ }
484
+ }
485
+
369
486
  class MapPostboyService extends PostboyService {
370
487
  constructor() {
371
488
  super();
@@ -381,7 +498,7 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "16.2.12", ngImpo
381
498
  class MapManagementService {
382
499
  postboy;
383
500
  map;
384
- layers = {};
501
+ layers = new Dictionary();
385
502
  constructor(postboy) {
386
503
  this.postboy = postboy;
387
504
  }
@@ -393,6 +510,7 @@ class MapManagementService {
393
510
  this.observeAddTile();
394
511
  this.observeRemoveTile();
395
512
  this.observeLayerQuery();
513
+ this.observeFeaturesInArea();
396
514
  }
397
515
  observeRemoveTile() {
398
516
  this.postboy.subscribe(RemoveTileCommand.ID).subscribe((c) => {
@@ -402,7 +520,7 @@ class MapManagementService {
402
520
  });
403
521
  }
404
522
  observeLayerQuery() {
405
- this.postboy.subscribe(GetLayerQuery.ID).subscribe((ev) => ev.finish(this.layers[ev.name] ?? null));
523
+ this.postboy.subscribe(GetLayerQuery.ID).subscribe((ev) => ev.finish(this.layers.take(ev.name)));
406
524
  }
407
525
  observeAddTile() {
408
526
  this.postboy.subscribe(AddTileCommand.ID).subscribe((c) => {
@@ -420,15 +538,15 @@ class MapManagementService {
420
538
  this.postboy.subscribe(AddLayerCommand.ID).subscribe((c) => {
421
539
  if (!this.map)
422
540
  return;
423
- this.layers[c.layer.get('name')] = c.layer;
541
+ this.layers.put(c.layer.get('name'), c.layer);
424
542
  this.map.addLayer(c.layer);
425
543
  });
426
544
  }
427
545
  observePlaceFeatures() {
428
546
  this.postboy.subscribe(PlaceLayerFeaturesCommand.ID).subscribe((c) => {
429
- if (!this.layers[c.layer])
547
+ if (!this.layers.has(c.layer))
430
548
  return;
431
- let source = this.layers[c.layer]?.getSource();
549
+ let source = this.layers.take(c.layer).getSource();
432
550
  if (!!source['getSource'])
433
551
  source = source?.getSource();
434
552
  source?.clear();
@@ -439,10 +557,32 @@ class MapManagementService {
439
557
  this.postboy.subscribe(RemoveLayerCommand.ID).subscribe((c) => {
440
558
  if (!this.map)
441
559
  return;
442
- delete this.layers[c.layer.get('name')];
560
+ this.layers.rmv(c.layer.get('name'));
443
561
  this.map.removeLayer(c.layer);
444
562
  });
445
563
  }
564
+ observeFeaturesInArea() {
565
+ this.postboy.subscribe(GetFeaturesInAreaQuery.ID).subscribe((qr) => {
566
+ let result = new Dictionary();
567
+ const queue = [];
568
+ const queries = [];
569
+ this.layers.forEach((l) => {
570
+ let layerName = l.get('name');
571
+ if (qr.ignore.has(layerName) || layerName === MapConstants.DrawingLayerId)
572
+ return;
573
+ let source = l.getSource();
574
+ if (!!source['getSource'])
575
+ source = source?.getSource();
576
+ const query = new FilterFeaturesInAreaQuery(qr.area, source?.getFeatures() ?? []);
577
+ queue.push(query.result.pipe(tap((r) => {
578
+ result.put(l.get('name'), r.map((e) => ({ id: e.getId(), ...e.get(MapConstants.FeatureInfo) })));
579
+ })));
580
+ queries.push(query);
581
+ });
582
+ forkJoin(queue).subscribe(() => qr.finish(result));
583
+ queries.forEach((q) => this.postboy.fire(q));
584
+ });
585
+ }
446
586
  static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "16.2.12", ngImport: i0, type: MapManagementService, deps: [{ token: MapPostboyService }], target: i0.ɵɵFactoryTarget.Injectable });
447
587
  static ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "16.2.12", ngImport: i0, type: MapManagementService });
448
588
  }
@@ -565,26 +705,46 @@ class DrawingService {
565
705
  this.postboy = postboy;
566
706
  }
567
707
  up() {
708
+ this.observeDrawing();
709
+ this.observeSelectArea();
710
+ this.observeMapRender();
711
+ }
712
+ observeSelectArea() {
713
+ this.postboy.subscribe(DrawSelectionAreaCommand.ID).subscribe((ev) => {
714
+ const drawingCommand = new StartDrawingCommand(ev.type, ev.style);
715
+ drawingCommand.result.subscribe((r) => {
716
+ if (!r) {
717
+ ev.finish(new Dictionary());
718
+ return;
719
+ }
720
+ const area = PolygonModel.fromGeoJson(1, r).feature.getGeometry();
721
+ const getFeaturesCommand = new GetFeaturesInAreaQuery(area, ev.ignore);
722
+ getFeaturesCommand.result.subscribe((result) => ev.finish(result));
723
+ this.postboy.fire(getFeaturesCommand);
724
+ });
725
+ this.postboy.fire(drawingCommand);
726
+ });
727
+ }
728
+ observeDrawing() {
568
729
  this.postboy.subscribe(StartDrawingCommand.ID).subscribe((ev) => {
569
730
  this.draw((l) => {
570
731
  if (!l || !this.map) {
571
732
  this.clearInteraction(l);
572
733
  return;
573
734
  }
574
- const cancelSub = this.observeCancelation(ev, l);
575
- this.drawInteraction = new Draw({
576
- source: l.getSource(),
577
- type: DrawingType[ev.type],
578
- style: ev.style,
579
- });
580
- this.map.addInteraction(this.drawInteraction);
581
- this.drawInteraction.on('drawend', (evt) => {
582
- cancelSub.unsubscribe();
583
- this.onEnd(evt, ev, l);
735
+ const drawQuery = new GenerateDrawQuery(l, ev.style, ev.type);
736
+ drawQuery.result.subscribe((draw) => {
737
+ const cancelSub = this.observeCancelation(ev, l);
738
+ this.drawInteraction = draw;
739
+ this.map?.addInteraction(this.drawInteraction);
740
+ this.drawInteraction.on('drawend', (evt) => {
741
+ cancelSub.unsubscribe();
742
+ this.onEnd(evt, ev, l);
743
+ });
584
744
  });
745
+ this.postboy.fire(drawQuery);
585
746
  });
586
747
  });
587
- this.observeMapRender();
588
748
  }
589
749
  onEnd(evt, command, layer) {
590
750
  command.finish(command.format === FeatureOutputFormat.GeoJson
@@ -625,10 +785,58 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "16.2.12", ngImpo
625
785
  type: Injectable
626
786
  }], ctorParameters: function () { return [{ type: MapPostboyService }]; } });
627
787
 
788
+ class DrawingGenerationService {
789
+ postboy;
790
+ constructor(postboy) {
791
+ this.postboy = postboy;
792
+ }
793
+ up() {
794
+ this.postboy.subscribe(GenerateDrawQuery.ID).subscribe((ev) => {
795
+ ev.finish(new Draw({
796
+ source: ev.layer.getSource(),
797
+ type: DrawingType[ev.type],
798
+ style: ev.style,
799
+ geometryFunction: ev.type !== DrawingType.Circle ? undefined : createRegularPolygon(32),
800
+ }));
801
+ });
802
+ }
803
+ static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "16.2.12", ngImport: i0, type: DrawingGenerationService, deps: [{ token: MapPostboyService }], target: i0.ɵɵFactoryTarget.Injectable });
804
+ static ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "16.2.12", ngImport: i0, type: DrawingGenerationService });
805
+ }
806
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "16.2.12", ngImport: i0, type: DrawingGenerationService, decorators: [{
807
+ type: Injectable
808
+ }], ctorParameters: function () { return [{ type: MapPostboyService }]; } });
809
+
810
+ class FeatureService {
811
+ postboy;
812
+ constructor(postboy) {
813
+ this.postboy = postboy;
814
+ }
815
+ up() {
816
+ this.postboy.subscribe(FilterFeaturesInAreaQuery.ID).subscribe((qr) => {
817
+ qr.finish(qr.features.filter((f) => FeatureService.booleanIntersects(qr.area, f.getGeometry())));
818
+ });
819
+ }
820
+ static booleanIntersects(g1, g2) {
821
+ if (g2.getType() === 'Point')
822
+ return g1.intersectsCoordinate(g2.getCoordinates());
823
+ if (g2.getType() === 'Circle')
824
+ return g1.intersectsCoordinate(g2.getCenter());
825
+ if (g2.getType() === 'Polygon')
826
+ return g1.intersectsCoordinate(g2.getInteriorPoint().getCoordinates());
827
+ return false;
828
+ }
829
+ static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "16.2.12", ngImport: i0, type: FeatureService, deps: [{ token: MapPostboyService }], target: i0.ɵɵFactoryTarget.Injectable });
830
+ static ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "16.2.12", ngImport: i0, type: FeatureService });
831
+ }
832
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "16.2.12", ngImport: i0, type: FeatureService, decorators: [{
833
+ type: Injectable
834
+ }], ctorParameters: function () { return [{ type: MapPostboyService }]; } });
835
+
628
836
  class MessageRegistratorService extends PostboyAbstractRegistrator {
629
- constructor(service, management, state, feature, interaction, drawing) {
837
+ constructor(service, management, state, mapFeature, interaction, drawing, drawGenerator, feature) {
630
838
  super(service);
631
- this.registerServices([management, state, interaction, feature, drawing]);
839
+ this.registerServices([management, state, interaction, mapFeature, drawing, drawGenerator, feature]);
632
840
  }
633
841
  _up() {
634
842
  this.registerReplay(MapRenderedEvent.ID);
@@ -645,13 +853,17 @@ class MessageRegistratorService extends PostboyAbstractRegistrator {
645
853
  this.registerSubject(StartDrawingCommand.ID);
646
854
  this.registerSubject(GetLayerQuery.ID);
647
855
  this.registerSubject(DrawingFinishedEvent.ID);
856
+ this.registerSubject(GenerateDrawQuery.ID);
857
+ this.registerSubject(FilterFeaturesInAreaQuery.ID);
858
+ this.registerSubject(GetFeaturesInAreaQuery.ID);
859
+ this.registerSubject(DrawSelectionAreaCommand.ID);
648
860
  }
649
- static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "16.2.12", ngImport: i0, type: MessageRegistratorService, deps: [{ token: MapPostboyService }, { token: MapManagementService }, { token: MapStateService }, { token: MapFeatureService }, { token: MapClickService }, { token: DrawingService }], target: i0.ɵɵFactoryTarget.Injectable });
861
+ static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "16.2.12", 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 });
650
862
  static ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "16.2.12", ngImport: i0, type: MessageRegistratorService });
651
863
  }
652
864
  i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "16.2.12", ngImport: i0, type: MessageRegistratorService, decorators: [{
653
865
  type: Injectable
654
- }], ctorParameters: function () { return [{ type: MapPostboyService }, { type: MapManagementService }, { type: MapStateService }, { type: MapFeatureService }, { type: MapClickService }, { type: DrawingService }]; } });
866
+ }], ctorParameters: function () { return [{ type: MapPostboyService }, { type: MapManagementService }, { type: MapStateService }, { type: MapFeatureService }, { type: MapClickService }, { type: DrawingService }, { type: DrawingGenerationService }, { type: FeatureService }]; } });
655
867
 
656
868
  class TileLayerSettings {
657
869
  maxZoom = 19;
@@ -1216,6 +1428,8 @@ class MapPlateComponent extends DestructibleComponent {
1216
1428
  MapClickService,
1217
1429
  MapFeatureService,
1218
1430
  DrawingService,
1431
+ DrawingGenerationService,
1432
+ FeatureService,
1219
1433
  ], 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 });
1220
1434
  }
1221
1435
  i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "16.2.12", ngImport: i0, type: MapPlateComponent, decorators: [{
@@ -1227,6 +1441,8 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "16.2.12", ngImpo
1227
1441
  MapClickService,
1228
1442
  MapFeatureService,
1229
1443
  DrawingService,
1444
+ DrawingGenerationService,
1445
+ FeatureService,
1230
1446
  ], 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"] }]
1231
1447
  }], ctorParameters: function () { return [{ type: i0.ElementRef }, { type: MapPostboyService }, { type: MapPlateFactory }, { type: MessageRegistratorService }, { type: i0.ChangeDetectorRef }]; }, propDecorators: { settings: [{
1232
1448
  type: Input
@@ -1504,6 +1720,57 @@ class TextStyleHelper {
1504
1720
  }
1505
1721
  }
1506
1722
 
1723
+ class StringifyFeatureHelper {
1724
+ static polygon(feature, format = FeatureOutputFormat.GeoJson) {
1725
+ return format === FeatureOutputFormat.GeoJson
1726
+ ? new GeoJSON().writeFeature(feature)
1727
+ : new WKT().writeFeature(feature);
1728
+ }
1729
+ static circle(feature, format = FeatureOutputFormat.GeoJson) {
1730
+ // const clone = feature.clone();
1731
+ // clone.setGeometry(fromCircle(feature.getGeometry()! as Circle));
1732
+ const tetemp = feature.getGeometryName();
1733
+ const circle = feature.getGeometry();
1734
+ // const temp = StringifyFeatureHelper.drawCircle(circle.getCenter(), circle.getRadius());
1735
+ const ttt = feature.getGeometry().getExtent();
1736
+ const eastPoint = [ttt[2], (ttt[1] + ttt[3]) / 2];
1737
+ const aaa = [
1738
+ ...transform([ttt[0], ttt[1]], 'EPSG:4326', 'EPSG:3857'),
1739
+ ...transform([ttt[2], ttt[3]], 'EPSG:4326', 'EPSG:3857'),
1740
+ ];
1741
+ const radius = (aaa[2] - aaa[0]) / 2;
1742
+ const radius2 = new LineString([circle.getCenter(), eastPoint]).getLength();
1743
+ const polygonGeom = new Polygon(StringifyFeatureHelper.drawCircle(circle.getCenter(), radius));
1744
+ // var edgeCoordinate = [circle.getCenter()[0] + radius, circle.getCenter()[1]];
1745
+ // var wgs84Sphere = new Sphere(6378137);
1746
+ return StringifyFeatureHelper.polygon(new Feature(polygonGeom), format);
1747
+ // const rad = circle.getRadius();
1748
+ // const degrees = 180 / Math.PI; // radians to degrees
1749
+ // const radians = Math.PI / 180; // degrees to radians
1750
+ // const rlat = rad * degrees * 1000;
1751
+ // const rlng = rad * radians;
1752
+ // return StringifyFeatureHelper.polygon(new Feature<Geometry>(circular(circle.getCenter(),circle.getRadius() * METERS_PER_UNIT)), format);
1753
+ }
1754
+ static drawCircle(point, radius) {
1755
+ const tetetemp = transform(point, 'EPSG:4326', 'EPSG:3857');
1756
+ // const tetetemp = point;
1757
+ const radians = Math.PI / 180; // degrees to radians
1758
+ const degrees = 180 / Math.PI; // radians to degrees
1759
+ const earthsradius = 6378137.0;
1760
+ const rlat = (radius / earthsradius) * degrees;
1761
+ const rlng = rlat / Math.cos(tetetemp[1] * radians);
1762
+ const extp = [];
1763
+ for (let i = 0; i <= 32; i++) {
1764
+ const theta = Math.PI * (i / 16);
1765
+ extp.push([
1766
+ tetetemp[0] + rlng * Math.cos(theta) * METERS_PER_UNIT,
1767
+ tetetemp[1] + rlat * Math.sin(theta) * METERS_PER_UNIT,
1768
+ ]);
1769
+ }
1770
+ return [extp.map((e) => transform(e, 'EPSG:3857', 'EPSG:4326'))];
1771
+ }
1772
+ }
1773
+
1507
1774
  /*
1508
1775
  * Public API Surface of maps
1509
1776
  */
@@ -1516,5 +1783,5 @@ class TextStyleHelper {
1516
1783
  * Generated bundle index. Do not edit.
1517
1784
  */
1518
1785
 
1519
- 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, TextStyleHelper, TileLayerComponent, TileLayerSettings, TooltipComponent, TooltipSettings };
1786
+ 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 };
1520
1787
  //# sourceMappingURL=maps-components.mjs.map