@artstesh/maps 4.0.8 → 4.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 (71) hide show
  1. package/dist/esm2020/map/helpers/index.mjs +2 -1
  2. package/dist/esm2020/map/helpers/stringify-feature.helper.mjs +58 -0
  3. package/dist/esm2020/map/map-plate/map-plate.component.mjs +7 -1
  4. package/dist/esm2020/map/messages/commands/draw-selection-area.command.mjs +14 -0
  5. package/dist/esm2020/map/messages/index.mjs +2 -1
  6. package/dist/esm2020/map/messages/queries/filter-features-in-area.query.mjs +13 -0
  7. package/dist/esm2020/map/messages/queries/generate-draw.query.mjs +14 -0
  8. package/dist/esm2020/map/messages/queries/get-features-in-area.query.mjs +13 -0
  9. package/dist/esm2020/map/models/dictionary.mjs +56 -0
  10. package/dist/esm2020/map/models/drawing-type.enum.mjs +2 -1
  11. package/dist/esm2020/map/models/index.mjs +2 -1
  12. package/dist/esm2020/map/services/drawing/drawing-generation.service.mjs +28 -0
  13. package/dist/esm2020/map/services/drawing/drawing.service.mjs +36 -14
  14. package/dist/esm2020/map/services/feature.service.mjs +29 -0
  15. package/dist/esm2020/map/services/map-management.service.mjs +36 -7
  16. package/dist/esm2020/map/services/message-registrator.service.mjs +15 -5
  17. package/dist/esm2020/src/map/helpers/index.mjs +2 -1
  18. package/dist/esm2020/src/map/helpers/stringify-feature.helper.mjs +58 -0
  19. package/dist/esm2020/src/map/map-plate/map-plate.component.mjs +7 -1
  20. package/dist/esm2020/src/map/messages/commands/draw-selection-area.command.mjs +14 -0
  21. package/dist/esm2020/src/map/messages/index.mjs +2 -1
  22. package/dist/esm2020/src/map/messages/queries/filter-features-in-area.query.mjs +13 -0
  23. package/dist/esm2020/src/map/messages/queries/generate-draw.query.mjs +14 -0
  24. package/dist/esm2020/src/map/messages/queries/get-features-in-area.query.mjs +13 -0
  25. package/dist/esm2020/src/map/models/dictionary.mjs +56 -0
  26. package/dist/esm2020/src/map/models/drawing-type.enum.mjs +2 -1
  27. package/dist/esm2020/src/map/models/index.mjs +2 -1
  28. package/dist/esm2020/src/map/services/drawing/drawing-generation.service.mjs +28 -0
  29. package/dist/esm2020/src/map/services/drawing/drawing.service.mjs +36 -14
  30. package/dist/esm2020/src/map/services/feature.service.mjs +29 -0
  31. package/dist/esm2020/src/map/services/map-management.service.mjs +36 -7
  32. package/dist/esm2020/src/map/services/message-registrator.service.mjs +15 -5
  33. package/dist/fesm2015/maps-components-src-map.mjs +286 -28
  34. package/dist/fesm2015/maps-components-src-map.mjs.map +1 -1
  35. package/dist/fesm2015/maps-components.mjs +286 -28
  36. package/dist/fesm2015/maps-components.mjs.map +1 -1
  37. package/dist/fesm2020/maps-components-src-map.mjs +284 -27
  38. package/dist/fesm2020/maps-components-src-map.mjs.map +1 -1
  39. package/dist/fesm2020/maps-components.mjs +284 -27
  40. package/dist/fesm2020/maps-components.mjs.map +1 -1
  41. package/dist/map/helpers/index.d.ts +1 -0
  42. package/dist/map/helpers/stringify-feature.helper.d.ts +8 -0
  43. package/dist/map/messages/commands/draw-selection-area.command.d.ts +12 -0
  44. package/dist/map/messages/index.d.ts +1 -0
  45. package/dist/map/messages/queries/filter-features-in-area.query.d.ts +10 -0
  46. package/dist/map/messages/queries/generate-draw.query.d.ts +14 -0
  47. package/dist/map/messages/queries/get-features-in-area.query.d.ts +11 -0
  48. package/dist/map/models/dictionary.d.ts +17 -0
  49. package/dist/map/models/drawing-type.enum.d.ts +2 -1
  50. package/dist/map/models/index.d.ts +1 -0
  51. package/dist/map/services/drawing/drawing-generation.service.d.ts +10 -0
  52. package/dist/map/services/drawing/drawing.service.d.ts +2 -0
  53. package/dist/map/services/feature.service.d.ts +11 -0
  54. package/dist/map/services/map-management.service.d.ts +1 -0
  55. package/dist/map/services/message-registrator.service.d.ts +3 -1
  56. package/dist/src/map/helpers/index.d.ts +1 -0
  57. package/dist/src/map/helpers/stringify-feature.helper.d.ts +8 -0
  58. package/dist/src/map/messages/commands/draw-selection-area.command.d.ts +12 -0
  59. package/dist/src/map/messages/index.d.ts +1 -0
  60. package/dist/src/map/messages/queries/filter-features-in-area.query.d.ts +10 -0
  61. package/dist/src/map/messages/queries/generate-draw.query.d.ts +14 -0
  62. package/dist/src/map/messages/queries/get-features-in-area.query.d.ts +11 -0
  63. package/dist/src/map/models/dictionary.d.ts +17 -0
  64. package/dist/src/map/models/drawing-type.enum.d.ts +2 -1
  65. package/dist/src/map/models/index.d.ts +1 -0
  66. package/dist/src/map/services/drawing/drawing-generation.service.d.ts +10 -0
  67. package/dist/src/map/services/drawing/drawing.service.d.ts +2 -0
  68. package/dist/src/map/services/feature.service.d.ts +11 -0
  69. package/dist/src/map/services/map-management.service.d.ts +1 -0
  70. package/dist/src/map/services/message-registrator.service.d.ts +3 -1
  71. 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
  constructor() {
@@ -177,6 +179,7 @@ class PolygonModel {
177
179
  var DrawingType;
178
180
  (function (DrawingType) {
179
181
  DrawingType[DrawingType["Polygon"] = 1] = "Polygon";
182
+ DrawingType[DrawingType["Circle"] = 2] = "Circle";
180
183
  })(DrawingType || (DrawingType = {}));
181
184
 
182
185
  var FeatureOutputFormat;
@@ -185,6 +188,62 @@ var FeatureOutputFormat;
185
188
  FeatureOutputFormat[FeatureOutputFormat["WKT"] = 2] = "WKT";
186
189
  })(FeatureOutputFormat || (FeatureOutputFormat = {}));
187
190
 
191
+ class Dictionary {
192
+ constructor() {
193
+ this.collection = {};
194
+ this._keys = new Set();
195
+ this.has = (key) => this._keys.has(key);
196
+ }
197
+ get keys() {
198
+ return Array.from(this._keys);
199
+ }
200
+ get size() {
201
+ return this._keys.size;
202
+ }
203
+ static clone(dic, action) {
204
+ return Dictionary.create(dic.collection, action);
205
+ }
206
+ static create(dic, action) {
207
+ let keyList = Object.keys(dic);
208
+ const result = new Dictionary();
209
+ for (let i = 0; i < keyList.length; i++) {
210
+ let key = keyList[i];
211
+ result._keys.add(key);
212
+ result.collection[key] = action ? action(dic[key], key) : dic[key];
213
+ }
214
+ return result;
215
+ }
216
+ find(predicate) {
217
+ let result = null;
218
+ this.forEach((e) => {
219
+ if (result === null && predicate(e))
220
+ result = e;
221
+ });
222
+ return result;
223
+ }
224
+ take(key) {
225
+ return this._keys.has(key) ? this.collection[key] : null;
226
+ }
227
+ put(key, value) {
228
+ if (value == null)
229
+ return;
230
+ this.collection[key] = value;
231
+ this._keys.add(key);
232
+ }
233
+ rmv(key) {
234
+ if (!this._keys.has(key))
235
+ return;
236
+ delete this.collection[key];
237
+ this._keys.delete(key);
238
+ }
239
+ forEach(callback) {
240
+ let keys = Object.keys(this.collection);
241
+ for (let i = 0; i < keys.length; i++) {
242
+ callback(this.collection[keys[i]], i);
243
+ }
244
+ }
245
+ }
246
+
188
247
  class MapRenderedEvent extends PostboyGenericMessage {
189
248
  constructor(map) {
190
249
  super();
@@ -252,6 +311,19 @@ class CancelDrawingCommand extends PostboyGenericMessage {
252
311
  }
253
312
  CancelDrawingCommand.ID = '7d38d983-feba-4176-a66b-18175e5ecd6b';
254
313
 
314
+ class DrawSelectionAreaCommand extends PostboyCallbackMessage {
315
+ constructor(type, style, ignore = new Set()) {
316
+ super();
317
+ this.type = type;
318
+ this.style = style;
319
+ this.ignore = ignore;
320
+ }
321
+ get id() {
322
+ return DrawSelectionAreaCommand.ID;
323
+ }
324
+ }
325
+ DrawSelectionAreaCommand.ID = '573d8a0d-f25b-42b7-9ad7-0ac6d86ac362';
326
+
255
327
  class AddLayerCommand extends PostboyGenericMessage {
256
328
  constructor(layer) {
257
329
  super();
@@ -341,6 +413,43 @@ class DrawingFinishedEvent extends PostboyGenericMessage {
341
413
  }
342
414
  DrawingFinishedEvent.ID = 'c724b68e-b4eb-4783-90f1-a8e31973fd36';
343
415
 
416
+ class GenerateDrawQuery extends PostboyCallbackMessage {
417
+ constructor(layer, style, type) {
418
+ super();
419
+ this.layer = layer;
420
+ this.style = style;
421
+ this.type = type;
422
+ }
423
+ get id() {
424
+ return GenerateDrawQuery.ID;
425
+ }
426
+ }
427
+ GenerateDrawQuery.ID = 'f01c99ba-0953-4ab5-82f9-04e6fbb678c1';
428
+
429
+ class FilterFeaturesInAreaQuery extends PostboyCallbackMessage {
430
+ constructor(area, features) {
431
+ super();
432
+ this.area = area;
433
+ this.features = features;
434
+ }
435
+ get id() {
436
+ return FilterFeaturesInAreaQuery.ID;
437
+ }
438
+ }
439
+ FilterFeaturesInAreaQuery.ID = '36bb2d94-8028-4512-90dd-2386af3fc67c';
440
+
441
+ class GetFeaturesInAreaQuery extends PostboyCallbackMessage {
442
+ constructor(area, ignore = new Set()) {
443
+ super();
444
+ this.area = area;
445
+ this.ignore = ignore;
446
+ }
447
+ get id() {
448
+ return GetFeaturesInAreaQuery.ID;
449
+ }
450
+ }
451
+ GetFeaturesInAreaQuery.ID = 'efcf4271-a07a-40e0-9f02-d4dade40b8ac';
452
+
344
453
  class MapPostboyService extends PostboyService {
345
454
  constructor() {
346
455
  super();
@@ -356,7 +465,7 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "15.2.10", ngImpo
356
465
  class MapManagementService {
357
466
  constructor(postboy) {
358
467
  this.postboy = postboy;
359
- this.layers = {};
468
+ this.layers = new Dictionary();
360
469
  }
361
470
  up() {
362
471
  this.observeMapRender();
@@ -366,6 +475,7 @@ class MapManagementService {
366
475
  this.observeAddTile();
367
476
  this.observeRemoveTile();
368
477
  this.observeLayerQuery();
478
+ this.observeFeaturesInArea();
369
479
  }
370
480
  observeRemoveTile() {
371
481
  this.postboy.subscribe(RemoveTileCommand.ID).subscribe((c) => {
@@ -375,7 +485,7 @@ class MapManagementService {
375
485
  });
376
486
  }
377
487
  observeLayerQuery() {
378
- this.postboy.subscribe(GetLayerQuery.ID).subscribe((ev) => { var _a; return ev.finish((_a = this.layers[ev.name]) !== null && _a !== void 0 ? _a : null); });
488
+ this.postboy.subscribe(GetLayerQuery.ID).subscribe((ev) => ev.finish(this.layers.take(ev.name)));
379
489
  }
380
490
  observeAddTile() {
381
491
  this.postboy.subscribe(AddTileCommand.ID).subscribe((c) => {
@@ -393,16 +503,15 @@ class MapManagementService {
393
503
  this.postboy.subscribe(AddLayerCommand.ID).subscribe((c) => {
394
504
  if (!this.map)
395
505
  return;
396
- this.layers[c.layer.get('name')] = c.layer;
506
+ this.layers.put(c.layer.get('name'), c.layer);
397
507
  this.map.addLayer(c.layer);
398
508
  });
399
509
  }
400
510
  observePlaceFeatures() {
401
511
  this.postboy.subscribe(PlaceLayerFeaturesCommand.ID).subscribe((c) => {
402
- var _a;
403
- if (!this.layers[c.layer])
512
+ if (!this.layers.has(c.layer))
404
513
  return;
405
- let source = (_a = this.layers[c.layer]) === null || _a === void 0 ? void 0 : _a.getSource();
514
+ let source = this.layers.take(c.layer).getSource();
406
515
  if (!!source['getSource'])
407
516
  source = source === null || source === void 0 ? void 0 : source.getSource();
408
517
  source === null || source === void 0 ? void 0 : source.clear();
@@ -413,10 +522,33 @@ class MapManagementService {
413
522
  this.postboy.subscribe(RemoveLayerCommand.ID).subscribe((c) => {
414
523
  if (!this.map)
415
524
  return;
416
- delete this.layers[c.layer.get('name')];
525
+ this.layers.rmv(c.layer.get('name'));
417
526
  this.map.removeLayer(c.layer);
418
527
  });
419
528
  }
529
+ observeFeaturesInArea() {
530
+ this.postboy.subscribe(GetFeaturesInAreaQuery.ID).subscribe((qr) => {
531
+ let result = new Dictionary();
532
+ const queue = [];
533
+ const queries = [];
534
+ this.layers.forEach((l) => {
535
+ var _a;
536
+ let layerName = l.get('name');
537
+ if (qr.ignore.has(layerName) || layerName === MapConstants.DrawingLayerId)
538
+ return;
539
+ let source = l.getSource();
540
+ if (!!source['getSource'])
541
+ 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);
547
+ });
548
+ forkJoin(queue).subscribe(() => qr.finish(result));
549
+ queries.forEach((q) => this.postboy.fire(q));
550
+ });
551
+ }
420
552
  }
421
553
  MapManagementService.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "15.2.10", ngImport: i0, type: MapManagementService, deps: [{ token: MapPostboyService }], target: i0.ɵɵFactoryTarget.Injectable });
422
554
  MapManagementService.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "15.2.10", ngImport: i0, type: MapManagementService });
@@ -534,26 +666,47 @@ class DrawingService {
534
666
  this.postboy = postboy;
535
667
  }
536
668
  up() {
669
+ this.observeDrawing();
670
+ this.observeSelectArea();
671
+ this.observeMapRender();
672
+ }
673
+ observeSelectArea() {
674
+ this.postboy.subscribe(DrawSelectionAreaCommand.ID).subscribe((ev) => {
675
+ const drawingCommand = new StartDrawingCommand(ev.type, ev.style);
676
+ drawingCommand.result.subscribe((r) => {
677
+ if (!r) {
678
+ ev.finish(new Dictionary());
679
+ return;
680
+ }
681
+ const area = PolygonModel.fromGeoJson(1, r).feature.getGeometry();
682
+ const getFeaturesCommand = new GetFeaturesInAreaQuery(area, ev.ignore);
683
+ getFeaturesCommand.result.subscribe((result) => ev.finish(result));
684
+ this.postboy.fire(getFeaturesCommand);
685
+ });
686
+ this.postboy.fire(drawingCommand);
687
+ });
688
+ }
689
+ observeDrawing() {
537
690
  this.postboy.subscribe(StartDrawingCommand.ID).subscribe((ev) => {
538
691
  this.draw((l) => {
539
692
  if (!l || !this.map) {
540
693
  this.clearInteraction(l);
541
694
  return;
542
695
  }
543
- const cancelSub = this.observeCancelation(ev, l);
544
- this.drawInteraction = new Draw({
545
- source: l.getSource(),
546
- type: DrawingType[ev.type],
547
- style: ev.style,
548
- });
549
- this.map.addInteraction(this.drawInteraction);
550
- this.drawInteraction.on('drawend', (evt) => {
551
- cancelSub.unsubscribe();
552
- this.onEnd(evt, ev, l);
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
+ });
553
706
  });
707
+ this.postboy.fire(drawQuery);
554
708
  });
555
709
  });
556
- this.observeMapRender();
557
710
  }
558
711
  onEnd(evt, command, layer) {
559
712
  command.finish(command.format === FeatureOutputFormat.GeoJson
@@ -595,10 +748,56 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "15.2.10", ngImpo
595
748
  type: Injectable
596
749
  }], ctorParameters: function () { return [{ type: MapPostboyService }]; } });
597
750
 
751
+ class DrawingGenerationService {
752
+ constructor(postboy) {
753
+ this.postboy = postboy;
754
+ }
755
+ 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
+ }));
763
+ });
764
+ }
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;
775
+ }
776
+ up() {
777
+ this.postboy.subscribe(FilterFeaturesInAreaQuery.ID).subscribe((qr) => {
778
+ qr.finish(qr.features.filter((f) => FeatureService.booleanIntersects(qr.area, f.getGeometry())));
779
+ });
780
+ }
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;
789
+ }
790
+ }
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: [{
794
+ type: Injectable
795
+ }], ctorParameters: function () { return [{ type: MapPostboyService }]; } });
796
+
598
797
  class MessageRegistratorService extends PostboyAbstractRegistrator {
599
- constructor(service, management, state, feature, interaction, drawing) {
798
+ constructor(service, management, state, mapFeature, interaction, drawing, drawGenerator, feature) {
600
799
  super(service);
601
- this.registerServices([management, state, interaction, feature, drawing]);
800
+ this.registerServices([management, state, interaction, mapFeature, drawing, drawGenerator, feature]);
602
801
  }
603
802
  _up() {
604
803
  this.registerReplay(MapRenderedEvent.ID);
@@ -615,13 +814,17 @@ class MessageRegistratorService extends PostboyAbstractRegistrator {
615
814
  this.registerSubject(StartDrawingCommand.ID);
616
815
  this.registerSubject(GetLayerQuery.ID);
617
816
  this.registerSubject(DrawingFinishedEvent.ID);
817
+ this.registerSubject(GenerateDrawQuery.ID);
818
+ this.registerSubject(FilterFeaturesInAreaQuery.ID);
819
+ this.registerSubject(GetFeaturesInAreaQuery.ID);
820
+ this.registerSubject(DrawSelectionAreaCommand.ID);
618
821
  }
619
822
  }
620
- 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 }], target: i0.ɵɵFactoryTarget.Injectable });
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 });
621
824
  MessageRegistratorService.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "15.2.10", ngImport: i0, type: MessageRegistratorService });
622
825
  i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "15.2.10", ngImport: i0, type: MessageRegistratorService, decorators: [{
623
826
  type: Injectable
624
- }], ctorParameters: function () { return [{ type: MapPostboyService }, { type: MapManagementService }, { type: MapStateService }, { type: MapFeatureService }, { type: MapClickService }, { type: DrawingService }]; } });
827
+ }], ctorParameters: function () { return [{ type: MapPostboyService }, { type: MapManagementService }, { type: MapStateService }, { type: MapFeatureService }, { type: MapClickService }, { type: DrawingService }, { type: DrawingGenerationService }, { type: FeatureService }]; } });
625
828
 
626
829
  class TileLayerSettings {
627
830
  constructor() {
@@ -1178,6 +1381,8 @@ MapPlateComponent.ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "14.0.0", vers
1178
1381
  MapClickService,
1179
1382
  MapFeatureService,
1180
1383
  DrawingService,
1384
+ DrawingGenerationService,
1385
+ FeatureService,
1181
1386
  ], 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 });
1182
1387
  i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "15.2.10", ngImport: i0, type: MapPlateComponent, decorators: [{
1183
1388
  type: Component,
@@ -1188,6 +1393,8 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "15.2.10", ngImpo
1188
1393
  MapClickService,
1189
1394
  MapFeatureService,
1190
1395
  DrawingService,
1396
+ DrawingGenerationService,
1397
+ FeatureService,
1191
1398
  ], 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"] }]
1192
1399
  }], ctorParameters: function () { return [{ type: i0.ElementRef }, { type: MapPostboyService }, { type: MapPlateFactory }, { type: MessageRegistratorService }, { type: i0.ChangeDetectorRef }]; }, propDecorators: { settings: [{
1193
1400
  type: Input
@@ -1461,6 +1668,57 @@ class TextStyleHelper {
1461
1668
  }
1462
1669
  }
1463
1670
 
1671
+ class StringifyFeatureHelper {
1672
+ static polygon(feature, format = FeatureOutputFormat.GeoJson) {
1673
+ return format === FeatureOutputFormat.GeoJson
1674
+ ? new GeoJSON().writeFeature(feature)
1675
+ : new WKT().writeFeature(feature);
1676
+ }
1677
+ static circle(feature, format = FeatureOutputFormat.GeoJson) {
1678
+ // const clone = feature.clone();
1679
+ // clone.setGeometry(fromCircle(feature.getGeometry()! as Circle));
1680
+ const tetemp = feature.getGeometryName();
1681
+ const circle = feature.getGeometry();
1682
+ // const temp = StringifyFeatureHelper.drawCircle(circle.getCenter(), circle.getRadius());
1683
+ const ttt = feature.getGeometry().getExtent();
1684
+ const eastPoint = [ttt[2], (ttt[1] + ttt[3]) / 2];
1685
+ const aaa = [
1686
+ ...transform([ttt[0], ttt[1]], 'EPSG:4326', 'EPSG:3857'),
1687
+ ...transform([ttt[2], ttt[3]], 'EPSG:4326', 'EPSG:3857'),
1688
+ ];
1689
+ const radius = (aaa[2] - aaa[0]) / 2;
1690
+ const radius2 = new LineString([circle.getCenter(), eastPoint]).getLength();
1691
+ const polygonGeom = new Polygon(StringifyFeatureHelper.drawCircle(circle.getCenter(), radius));
1692
+ // var edgeCoordinate = [circle.getCenter()[0] + radius, circle.getCenter()[1]];
1693
+ // var wgs84Sphere = new Sphere(6378137);
1694
+ return StringifyFeatureHelper.polygon(new Feature(polygonGeom), format);
1695
+ // const rad = circle.getRadius();
1696
+ // const degrees = 180 / Math.PI; // radians to degrees
1697
+ // const radians = Math.PI / 180; // degrees to radians
1698
+ // const rlat = rad * degrees * 1000;
1699
+ // const rlng = rad * radians;
1700
+ // return StringifyFeatureHelper.polygon(new Feature<Geometry>(circular(circle.getCenter(),circle.getRadius() * METERS_PER_UNIT)), format);
1701
+ }
1702
+ static drawCircle(point, radius) {
1703
+ const tetetemp = transform(point, 'EPSG:4326', 'EPSG:3857');
1704
+ // const tetetemp = point;
1705
+ const radians = Math.PI / 180; // degrees to radians
1706
+ const degrees = 180 / Math.PI; // radians to degrees
1707
+ const earthsradius = 6378137.0;
1708
+ const rlat = (radius / earthsradius) * degrees;
1709
+ const rlng = rlat / Math.cos(tetetemp[1] * radians);
1710
+ const extp = [];
1711
+ for (let i = 0; i <= 32; i++) {
1712
+ const theta = Math.PI * (i / 16);
1713
+ extp.push([
1714
+ tetetemp[0] + rlng * Math.cos(theta) * METERS_PER_UNIT,
1715
+ tetetemp[1] + rlat * Math.sin(theta) * METERS_PER_UNIT,
1716
+ ]);
1717
+ }
1718
+ return [extp.map((e) => transform(e, 'EPSG:3857', 'EPSG:4326'))];
1719
+ }
1720
+ }
1721
+
1464
1722
  /*
1465
1723
  * Public API Surface of maps
1466
1724
  */
@@ -1469,5 +1727,5 @@ class TextStyleHelper {
1469
1727
  * Generated bundle index. Do not edit.
1470
1728
  */
1471
1729
 
1472
- 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 };
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 };
1473
1731
  //# sourceMappingURL=maps-components-src-map.mjs.map