@artstesh/maps 1.0.8 → 1.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/bundles/maps-components-src-map.umd.js +334 -27
  2. package/dist/bundles/maps-components-src-map.umd.js.map +1 -1
  3. package/dist/bundles/maps-components.umd.js +334 -27
  4. package/dist/bundles/maps-components.umd.js.map +1 -1
  5. package/dist/esm2015/map/helpers/index.js +2 -1
  6. package/dist/esm2015/map/helpers/stringify-feature.helper.js +58 -0
  7. package/dist/esm2015/map/map-plate/map-plate.component.js +7 -1
  8. package/dist/esm2015/map/messages/commands/draw-selection-area.command.js +14 -0
  9. package/dist/esm2015/map/messages/index.js +2 -1
  10. package/dist/esm2015/map/messages/queries/filter-features-in-area.query.js +13 -0
  11. package/dist/esm2015/map/messages/queries/generate-draw.query.js +14 -0
  12. package/dist/esm2015/map/messages/queries/get-features-in-area.query.js +13 -0
  13. package/dist/esm2015/map/models/dictionary.js +56 -0
  14. package/dist/esm2015/map/models/drawing-type.enum.js +2 -1
  15. package/dist/esm2015/map/models/index.js +2 -1
  16. package/dist/esm2015/map/services/drawing/drawing-generation.service.js +28 -0
  17. package/dist/esm2015/map/services/drawing/drawing.service.js +37 -14
  18. package/dist/esm2015/map/services/feature.service.js +29 -0
  19. package/dist/esm2015/map/services/map-management.service.js +39 -9
  20. package/dist/esm2015/map/services/message-registrator.service.js +15 -5
  21. package/dist/esm2015/src/map/helpers/index.js +2 -1
  22. package/dist/esm2015/src/map/helpers/stringify-feature.helper.js +58 -0
  23. package/dist/esm2015/src/map/map-plate/map-plate.component.js +7 -1
  24. package/dist/esm2015/src/map/messages/commands/draw-selection-area.command.js +14 -0
  25. package/dist/esm2015/src/map/messages/index.js +2 -1
  26. package/dist/esm2015/src/map/messages/queries/filter-features-in-area.query.js +13 -0
  27. package/dist/esm2015/src/map/messages/queries/generate-draw.query.js +14 -0
  28. package/dist/esm2015/src/map/messages/queries/get-features-in-area.query.js +13 -0
  29. package/dist/esm2015/src/map/models/dictionary.js +56 -0
  30. package/dist/esm2015/src/map/models/drawing-type.enum.js +2 -1
  31. package/dist/esm2015/src/map/models/index.js +2 -1
  32. package/dist/esm2015/src/map/services/drawing/drawing-generation.service.js +28 -0
  33. package/dist/esm2015/src/map/services/drawing/drawing.service.js +37 -14
  34. package/dist/esm2015/src/map/services/feature.service.js +29 -0
  35. package/dist/esm2015/src/map/services/map-management.service.js +39 -9
  36. package/dist/esm2015/src/map/services/message-registrator.service.js +15 -5
  37. package/dist/fesm2015/maps-components-src-map.js +288 -29
  38. package/dist/fesm2015/maps-components-src-map.js.map +1 -1
  39. package/dist/fesm2015/maps-components.js +288 -29
  40. package/dist/fesm2015/maps-components.js.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 i6 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: "12.2.17", 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,18 +503,18 @@ 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, _b;
403
- if (!this.layers[c.layer])
512
+ var _a;
513
+ if (!this.layers.has(c.layer))
404
514
  return;
405
- let source = (_a = this.layers[c.layer]) === null || _a === void 0 ? void 0 : _a.getSource();
515
+ let source = this.layers.take(c.layer).getSource();
406
516
  if (!!source['getSource'])
407
- source = (_b = source) === null || _b === void 0 ? void 0 : _b.getSource();
517
+ source = (_a = source) === null || _a === void 0 ? void 0 : _a.getSource();
408
518
  source === null || source === void 0 ? void 0 : source.clear();
409
519
  source === null || source === void 0 ? void 0 : source.addFeatures(c.features);
410
520
  });
@@ -413,10 +523,33 @@ class MapManagementService {
413
523
  this.postboy.subscribe(RemoveLayerCommand.ID).subscribe((c) => {
414
524
  if (!this.map)
415
525
  return;
416
- delete this.layers[c.layer.get('name')];
526
+ this.layers.rmv(c.layer.get('name'));
417
527
  this.map.removeLayer(c.layer);
418
528
  });
419
529
  }
530
+ observeFeaturesInArea() {
531
+ this.postboy.subscribe(GetFeaturesInAreaQuery.ID).subscribe((qr) => {
532
+ let result = new Dictionary();
533
+ const queue = [];
534
+ const queries = [];
535
+ this.layers.forEach((l) => {
536
+ var _a, _b;
537
+ let layerName = l.get('name');
538
+ if (qr.ignore.has(layerName) || layerName === MapConstants.DrawingLayerId)
539
+ return;
540
+ let source = l.getSource();
541
+ if (!!source['getSource'])
542
+ source = (_a = source) === null || _a === void 0 ? void 0 : _a.getSource();
543
+ const query = new FilterFeaturesInAreaQuery(qr.area, (_b = source === null || source === void 0 ? void 0 : source.getFeatures()) !== null && _b !== void 0 ? _b : []);
544
+ queue.push(query.result.pipe(tap((r) => {
545
+ result.put(l.get('name'), r.map((e) => (Object.assign({ id: e.getId() }, e.get(MapConstants.FeatureInfo)))));
546
+ })));
547
+ queries.push(query);
548
+ });
549
+ forkJoin(queue).subscribe(() => qr.finish(result));
550
+ queries.forEach((q) => this.postboy.fire(q));
551
+ });
552
+ }
420
553
  }
421
554
  MapManagementService.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "12.2.17", ngImport: i0, type: MapManagementService, deps: [{ token: MapPostboyService }], target: i0.ɵɵFactoryTarget.Injectable });
422
555
  MapManagementService.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "12.2.17", ngImport: i0, type: MapManagementService });
@@ -534,26 +667,47 @@ class DrawingService {
534
667
  this.postboy = postboy;
535
668
  }
536
669
  up() {
670
+ this.observeDrawing();
671
+ this.observeSelectArea();
672
+ this.observeMapRender();
673
+ }
674
+ observeSelectArea() {
675
+ this.postboy.subscribe(DrawSelectionAreaCommand.ID).subscribe((ev) => {
676
+ const drawingCommand = new StartDrawingCommand(ev.type, ev.style);
677
+ drawingCommand.result.subscribe((r) => {
678
+ if (!r) {
679
+ ev.finish(new Dictionary());
680
+ return;
681
+ }
682
+ const area = PolygonModel.fromGeoJson(1, r).feature.getGeometry();
683
+ const getFeaturesCommand = new GetFeaturesInAreaQuery(area, ev.ignore);
684
+ getFeaturesCommand.result.subscribe((result) => ev.finish(result));
685
+ this.postboy.fire(getFeaturesCommand);
686
+ });
687
+ this.postboy.fire(drawingCommand);
688
+ });
689
+ }
690
+ observeDrawing() {
537
691
  this.postboy.subscribe(StartDrawingCommand.ID).subscribe((ev) => {
538
692
  this.draw((l) => {
539
693
  if (!l || !this.map) {
540
694
  this.clearInteraction(l);
541
695
  return;
542
696
  }
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);
697
+ const drawQuery = new GenerateDrawQuery(l, ev.style, ev.type);
698
+ drawQuery.result.subscribe((draw) => {
699
+ var _a;
700
+ const cancelSub = this.observeCancelation(ev, l);
701
+ this.drawInteraction = draw;
702
+ (_a = this.map) === null || _a === void 0 ? void 0 : _a.addInteraction(this.drawInteraction);
703
+ this.drawInteraction.on('drawend', (evt) => {
704
+ cancelSub.unsubscribe();
705
+ this.onEnd(evt, ev, l);
706
+ });
553
707
  });
708
+ this.postboy.fire(drawQuery);
554
709
  });
555
710
  });
556
- this.observeMapRender();
557
711
  }
558
712
  onEnd(evt, command, layer) {
559
713
  command.finish(command.format === FeatureOutputFormat.GeoJson
@@ -595,10 +749,56 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "12.2.17", ngImpo
595
749
  type: Injectable
596
750
  }], ctorParameters: function () { return [{ type: MapPostboyService }]; } });
597
751
 
752
+ class DrawingGenerationService {
753
+ constructor(postboy) {
754
+ this.postboy = postboy;
755
+ }
756
+ up() {
757
+ this.postboy.subscribe(GenerateDrawQuery.ID).subscribe((ev) => {
758
+ ev.finish(new Draw({
759
+ source: ev.layer.getSource(),
760
+ type: DrawingType[ev.type],
761
+ style: ev.style,
762
+ geometryFunction: ev.type !== DrawingType.Circle ? undefined : createRegularPolygon(32),
763
+ }));
764
+ });
765
+ }
766
+ }
767
+ DrawingGenerationService.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "12.2.17", ngImport: i0, type: DrawingGenerationService, deps: [{ token: MapPostboyService }], target: i0.ɵɵFactoryTarget.Injectable });
768
+ DrawingGenerationService.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "12.2.17", ngImport: i0, type: DrawingGenerationService });
769
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "12.2.17", ngImport: i0, type: DrawingGenerationService, decorators: [{
770
+ type: Injectable
771
+ }], ctorParameters: function () { return [{ type: MapPostboyService }]; } });
772
+
773
+ class FeatureService {
774
+ constructor(postboy) {
775
+ this.postboy = postboy;
776
+ }
777
+ up() {
778
+ this.postboy.subscribe(FilterFeaturesInAreaQuery.ID).subscribe((qr) => {
779
+ qr.finish(qr.features.filter((f) => FeatureService.booleanIntersects(qr.area, f.getGeometry())));
780
+ });
781
+ }
782
+ static booleanIntersects(g1, g2) {
783
+ if (g2.getType() === 'Point')
784
+ return g1.intersectsCoordinate(g2.getCoordinates());
785
+ if (g2.getType() === 'Circle')
786
+ return g1.intersectsCoordinate(g2.getCenter());
787
+ if (g2.getType() === 'Polygon')
788
+ return g1.intersectsCoordinate(g2.getInteriorPoint().getCoordinates());
789
+ return false;
790
+ }
791
+ }
792
+ FeatureService.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "12.2.17", ngImport: i0, type: FeatureService, deps: [{ token: MapPostboyService }], target: i0.ɵɵFactoryTarget.Injectable });
793
+ FeatureService.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "12.2.17", ngImport: i0, type: FeatureService });
794
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "12.2.17", ngImport: i0, type: FeatureService, decorators: [{
795
+ type: Injectable
796
+ }], ctorParameters: function () { return [{ type: MapPostboyService }]; } });
797
+
598
798
  class MessageRegistratorService extends PostboyAbstractRegistrator {
599
- constructor(service, management, state, feature, interaction, drawing) {
799
+ constructor(service, management, state, mapFeature, interaction, drawing, drawGenerator, feature) {
600
800
  super(service);
601
- this.registerServices([management, state, interaction, feature, drawing]);
801
+ this.registerServices([management, state, interaction, mapFeature, drawing, drawGenerator, feature]);
602
802
  }
603
803
  _up() {
604
804
  this.registerReplay(MapRenderedEvent.ID);
@@ -615,13 +815,17 @@ class MessageRegistratorService extends PostboyAbstractRegistrator {
615
815
  this.registerSubject(StartDrawingCommand.ID);
616
816
  this.registerSubject(GetLayerQuery.ID);
617
817
  this.registerSubject(DrawingFinishedEvent.ID);
818
+ this.registerSubject(GenerateDrawQuery.ID);
819
+ this.registerSubject(FilterFeaturesInAreaQuery.ID);
820
+ this.registerSubject(GetFeaturesInAreaQuery.ID);
821
+ this.registerSubject(DrawSelectionAreaCommand.ID);
618
822
  }
619
823
  }
620
- MessageRegistratorService.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "12.2.17", ngImport: i0, type: MessageRegistratorService, deps: [{ token: MapPostboyService }, { token: MapManagementService }, { token: MapStateService }, { token: MapFeatureService }, { token: MapClickService }, { token: DrawingService }], target: i0.ɵɵFactoryTarget.Injectable });
824
+ MessageRegistratorService.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "12.2.17", 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
825
  MessageRegistratorService.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "12.2.17", ngImport: i0, type: MessageRegistratorService });
622
826
  i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "12.2.17", ngImport: i0, type: MessageRegistratorService, decorators: [{
623
827
  type: Injectable
624
- }], ctorParameters: function () { return [{ type: MapPostboyService }, { type: MapManagementService }, { type: MapStateService }, { type: MapFeatureService }, { type: MapClickService }, { type: DrawingService }]; } });
828
+ }], ctorParameters: function () { return [{ type: MapPostboyService }, { type: MapManagementService }, { type: MapStateService }, { type: MapFeatureService }, { type: MapClickService }, { type: DrawingService }, { type: DrawingGenerationService }, { type: FeatureService }]; } });
625
829
 
626
830
  class TileLayerSettings {
627
831
  constructor() {
@@ -1198,6 +1402,8 @@ MapPlateComponent.ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "12.0.0", vers
1198
1402
  MapClickService,
1199
1403
  MapFeatureService,
1200
1404
  DrawingService,
1405
+ DrawingGenerationService,
1406
+ FeatureService,
1201
1407
  ], 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"], components: [{ type: OsmTileLayerComponent, selector: "lib-osm-tile-layer", inputs: ["url", "map"] }, { type: FeatureLayerComponent, selector: "lib-feature-layer", inputs: ["settings"] }], directives: [{ type: i6.NgIf, selector: "[ngIf]", inputs: ["ngIf", "ngIfThen", "ngIfElse"] }], changeDetection: i0.ChangeDetectionStrategy.OnPush });
1202
1408
  i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "12.2.17", ngImport: i0, type: MapPlateComponent, decorators: [{
1203
1409
  type: Component,
@@ -1213,6 +1419,8 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "12.2.17", ngImpo
1213
1419
  MapClickService,
1214
1420
  MapFeatureService,
1215
1421
  DrawingService,
1422
+ DrawingGenerationService,
1423
+ FeatureService,
1216
1424
  ],
1217
1425
  }]
1218
1426
  }], ctorParameters: function () { return [{ type: i0.ElementRef }, { type: MapPostboyService }, { type: MapPlateFactory }, { type: MessageRegistratorService }, { type: i0.ChangeDetectorRef }]; }, propDecorators: { settings: [{
@@ -1502,6 +1710,57 @@ class TextStyleHelper {
1502
1710
  }
1503
1711
  }
1504
1712
 
1713
+ class StringifyFeatureHelper {
1714
+ static polygon(feature, format = FeatureOutputFormat.GeoJson) {
1715
+ return format === FeatureOutputFormat.GeoJson
1716
+ ? new GeoJSON().writeFeature(feature)
1717
+ : new WKT().writeFeature(feature);
1718
+ }
1719
+ static circle(feature, format = FeatureOutputFormat.GeoJson) {
1720
+ // const clone = feature.clone();
1721
+ // clone.setGeometry(fromCircle(feature.getGeometry()! as Circle));
1722
+ const tetemp = feature.getGeometryName();
1723
+ const circle = feature.getGeometry();
1724
+ // const temp = StringifyFeatureHelper.drawCircle(circle.getCenter(), circle.getRadius());
1725
+ const ttt = feature.getGeometry().getExtent();
1726
+ const eastPoint = [ttt[2], (ttt[1] + ttt[3]) / 2];
1727
+ const aaa = [
1728
+ ...transform([ttt[0], ttt[1]], 'EPSG:4326', 'EPSG:3857'),
1729
+ ...transform([ttt[2], ttt[3]], 'EPSG:4326', 'EPSG:3857'),
1730
+ ];
1731
+ const radius = (aaa[2] - aaa[0]) / 2;
1732
+ const radius2 = new LineString([circle.getCenter(), eastPoint]).getLength();
1733
+ const polygonGeom = new Polygon(StringifyFeatureHelper.drawCircle(circle.getCenter(), radius));
1734
+ // var edgeCoordinate = [circle.getCenter()[0] + radius, circle.getCenter()[1]];
1735
+ // var wgs84Sphere = new Sphere(6378137);
1736
+ return StringifyFeatureHelper.polygon(new Feature(polygonGeom), format);
1737
+ // const rad = circle.getRadius();
1738
+ // const degrees = 180 / Math.PI; // radians to degrees
1739
+ // const radians = Math.PI / 180; // degrees to radians
1740
+ // const rlat = rad * degrees * 1000;
1741
+ // const rlng = rad * radians;
1742
+ // return StringifyFeatureHelper.polygon(new Feature<Geometry>(circular(circle.getCenter(),circle.getRadius() * METERS_PER_UNIT)), format);
1743
+ }
1744
+ static drawCircle(point, radius) {
1745
+ const tetetemp = transform(point, 'EPSG:4326', 'EPSG:3857');
1746
+ // const tetetemp = point;
1747
+ const radians = Math.PI / 180; // degrees to radians
1748
+ const degrees = 180 / Math.PI; // radians to degrees
1749
+ const earthsradius = 6378137.0;
1750
+ const rlat = (radius / earthsradius) * degrees;
1751
+ const rlng = rlat / Math.cos(tetetemp[1] * radians);
1752
+ const extp = [];
1753
+ for (let i = 0; i <= 32; i++) {
1754
+ const theta = Math.PI * (i / 16);
1755
+ extp.push([
1756
+ tetetemp[0] + rlng * Math.cos(theta) * METERS_PER_UNIT,
1757
+ tetetemp[1] + rlat * Math.sin(theta) * METERS_PER_UNIT,
1758
+ ]);
1759
+ }
1760
+ return [extp.map((e) => transform(e, 'EPSG:3857', 'EPSG:4326'))];
1761
+ }
1762
+ }
1763
+
1505
1764
  /*
1506
1765
  * Public API Surface of maps
1507
1766
  */
@@ -1514,5 +1773,5 @@ class TextStyleHelper {
1514
1773
  * Generated bundle index. Do not edit.
1515
1774
  */
1516
1775
 
1517
- 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 };
1776
+ 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 };
1518
1777
  //# sourceMappingURL=maps-components.js.map