@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
@@ -1,8 +1,8 @@
1
1
  (function (global, factory) {
2
- typeof exports === 'object' && typeof module !== 'undefined' ? factory(exports, require('@angular/core'), require('@angular/common'), require('ol'), require('ol/geom'), require('ol/format'), require('ol/extent'), require('ol/proj'), require('@artstesh/postboy'), require('rxjs/operators'), require('ol/source'), require('ol/interaction'), require('ol/layer/Tile'), require('ol/source/OSM'), require('ol/layer'), require('ol/loadingstrategy'), require('ol/geom/Polygon'), require('ol/source/Cluster'), require('rxjs'), require('ol/Map'), require('ol/View'), require('ol/Overlay'), require('ol/style/Style'), require('ol/style')) :
3
- typeof define === 'function' && define.amd ? define('maps-components', ['exports', '@angular/core', '@angular/common', 'ol', 'ol/geom', 'ol/format', 'ol/extent', 'ol/proj', '@artstesh/postboy', 'rxjs/operators', 'ol/source', 'ol/interaction', 'ol/layer/Tile', 'ol/source/OSM', 'ol/layer', 'ol/loadingstrategy', 'ol/geom/Polygon', 'ol/source/Cluster', 'rxjs', 'ol/Map', 'ol/View', 'ol/Overlay', 'ol/style/Style', 'ol/style'], factory) :
4
- (global = typeof globalThis !== 'undefined' ? globalThis : global || self, factory(global["maps-components"] = {}, global.ng.core, global.ng.common, global.ol, global.geom, global.format, global.extent, global.proj, global.postboy, global.rxjs.operators, global.source, global.interaction, global.TileLayer, global.OSM, global.layer, global.loadingstrategy, global.Polygon, global.Cluster, global.rxjs, global.Map, global.View, global.Overlay, global.Style, global.style));
5
- })(this, (function (exports, i0, i6, ol, geom, format, extent, proj, postboy, operators, source, interaction, TileLayer, OSM, layer, loadingstrategy, Polygon, Cluster, rxjs, Map, View, Overlay, Style, style) { 'use strict';
2
+ typeof exports === 'object' && typeof module !== 'undefined' ? factory(exports, require('@angular/core'), require('@angular/common'), require('ol'), require('ol/geom'), require('ol/format'), require('ol/extent'), require('ol/proj'), require('@artstesh/postboy'), require('rxjs'), require('rxjs/operators'), require('ol/source'), require('ol/interaction'), require('ol/interaction/Draw'), require('ol/layer/Tile'), require('ol/source/OSM'), require('ol/layer'), require('ol/loadingstrategy'), require('ol/geom/Polygon'), require('ol/source/Cluster'), require('ol/Map'), require('ol/View'), require('ol/Overlay'), require('ol/style/Style'), require('ol/style'), require('ol/proj/epsg4326')) :
3
+ typeof define === 'function' && define.amd ? define('maps-components', ['exports', '@angular/core', '@angular/common', 'ol', 'ol/geom', 'ol/format', 'ol/extent', 'ol/proj', '@artstesh/postboy', 'rxjs', 'rxjs/operators', 'ol/source', 'ol/interaction', 'ol/interaction/Draw', 'ol/layer/Tile', 'ol/source/OSM', 'ol/layer', 'ol/loadingstrategy', 'ol/geom/Polygon', 'ol/source/Cluster', 'ol/Map', 'ol/View', 'ol/Overlay', 'ol/style/Style', 'ol/style', 'ol/proj/epsg4326'], factory) :
4
+ (global = typeof globalThis !== 'undefined' ? globalThis : global || self, factory(global["maps-components"] = {}, global.ng.core, global.ng.common, global.ol, global.geom, global.format, global.extent, global.proj, global.postboy, global.rxjs, global.rxjs.operators, global.source, global.interaction, global.Draw, global.TileLayer, global.OSM, global.layer, global.loadingstrategy, global.Polygon, global.Cluster, global.Map, global.View, global.Overlay, global.Style, global.style, global.epsg4326));
5
+ })(this, (function (exports, i0, i6, ol, geom, format, extent, proj, postboy, rxjs, operators, source, interaction, Draw, TileLayer, OSM, layer, loadingstrategy, Polygon, Cluster, Map, View, Overlay, Style, style, epsg4326) { 'use strict';
6
6
 
7
7
  function _interopDefaultLegacy (e) { return e && typeof e === 'object' && 'default' in e ? e : { 'default': e }; }
8
8
 
@@ -28,6 +28,7 @@
28
28
  var i6__namespace = /*#__PURE__*/_interopNamespace(i6);
29
29
  var TileLayer__default = /*#__PURE__*/_interopDefaultLegacy(TileLayer);
30
30
  var OSM__default = /*#__PURE__*/_interopDefaultLegacy(OSM);
31
+ var Polygon__default = /*#__PURE__*/_interopDefaultLegacy(Polygon);
31
32
  var Cluster__default = /*#__PURE__*/_interopDefaultLegacy(Cluster);
32
33
  var Map__default = /*#__PURE__*/_interopDefaultLegacy(Map);
33
34
  var View__default = /*#__PURE__*/_interopDefaultLegacy(View);
@@ -674,6 +675,7 @@
674
675
  exports.DrawingType = void 0;
675
676
  (function (DrawingType) {
676
677
  DrawingType[DrawingType["Polygon"] = 1] = "Polygon";
678
+ DrawingType[DrawingType["Circle"] = 2] = "Circle";
677
679
  })(exports.DrawingType || (exports.DrawingType = {}));
678
680
 
679
681
  exports.FeatureOutputFormat = void 0;
@@ -682,6 +684,72 @@
682
684
  FeatureOutputFormat[FeatureOutputFormat["WKT"] = 2] = "WKT";
683
685
  })(exports.FeatureOutputFormat || (exports.FeatureOutputFormat = {}));
684
686
 
687
+ var Dictionary = /** @class */ (function () {
688
+ function Dictionary() {
689
+ var _this = this;
690
+ this.collection = {};
691
+ this._keys = new Set();
692
+ this.has = function (key) { return _this._keys.has(key); };
693
+ }
694
+ Object.defineProperty(Dictionary.prototype, "keys", {
695
+ get: function () {
696
+ return Array.from(this._keys);
697
+ },
698
+ enumerable: false,
699
+ configurable: true
700
+ });
701
+ Object.defineProperty(Dictionary.prototype, "size", {
702
+ get: function () {
703
+ return this._keys.size;
704
+ },
705
+ enumerable: false,
706
+ configurable: true
707
+ });
708
+ Dictionary.clone = function (dic, action) {
709
+ return Dictionary.create(dic.collection, action);
710
+ };
711
+ Dictionary.create = function (dic, action) {
712
+ var keyList = Object.keys(dic);
713
+ var result = new Dictionary();
714
+ for (var i = 0; i < keyList.length; i++) {
715
+ var key = keyList[i];
716
+ result._keys.add(key);
717
+ result.collection[key] = action ? action(dic[key], key) : dic[key];
718
+ }
719
+ return result;
720
+ };
721
+ Dictionary.prototype.find = function (predicate) {
722
+ var result = null;
723
+ this.forEach(function (e) {
724
+ if (result === null && predicate(e))
725
+ result = e;
726
+ });
727
+ return result;
728
+ };
729
+ Dictionary.prototype.take = function (key) {
730
+ return this._keys.has(key) ? this.collection[key] : null;
731
+ };
732
+ Dictionary.prototype.put = function (key, value) {
733
+ if (value == null)
734
+ return;
735
+ this.collection[key] = value;
736
+ this._keys.add(key);
737
+ };
738
+ Dictionary.prototype.rmv = function (key) {
739
+ if (!this._keys.has(key))
740
+ return;
741
+ delete this.collection[key];
742
+ this._keys.delete(key);
743
+ };
744
+ Dictionary.prototype.forEach = function (callback) {
745
+ var keys = Object.keys(this.collection);
746
+ for (var i = 0; i < keys.length; i++) {
747
+ callback(this.collection[keys[i]], i);
748
+ }
749
+ };
750
+ return Dictionary;
751
+ }());
752
+
685
753
  var MapRenderedEvent = /** @class */ (function (_super) {
686
754
  __extends(MapRenderedEvent, _super);
687
755
  function MapRenderedEvent(map) {
@@ -794,6 +862,27 @@
794
862
  }(postboy.PostboyGenericMessage));
795
863
  CancelDrawingCommand.ID = '7d38d983-feba-4176-a66b-18175e5ecd6b';
796
864
 
865
+ var DrawSelectionAreaCommand = /** @class */ (function (_super) {
866
+ __extends(DrawSelectionAreaCommand, _super);
867
+ function DrawSelectionAreaCommand(type, style, ignore) {
868
+ if (ignore === void 0) { ignore = new Set(); }
869
+ var _this = _super.call(this) || this;
870
+ _this.type = type;
871
+ _this.style = style;
872
+ _this.ignore = ignore;
873
+ return _this;
874
+ }
875
+ Object.defineProperty(DrawSelectionAreaCommand.prototype, "id", {
876
+ get: function () {
877
+ return DrawSelectionAreaCommand.ID;
878
+ },
879
+ enumerable: false,
880
+ configurable: true
881
+ });
882
+ return DrawSelectionAreaCommand;
883
+ }(postboy.PostboyCallbackMessage));
884
+ DrawSelectionAreaCommand.ID = '573d8a0d-f25b-42b7-9ad7-0ac6d86ac362';
885
+
797
886
  var AddLayerCommand = /** @class */ (function (_super) {
798
887
  __extends(AddLayerCommand, _super);
799
888
  function AddLayerCommand(layer) {
@@ -939,6 +1028,65 @@
939
1028
  }(postboy.PostboyGenericMessage));
940
1029
  DrawingFinishedEvent.ID = 'c724b68e-b4eb-4783-90f1-a8e31973fd36';
941
1030
 
1031
+ var GenerateDrawQuery = /** @class */ (function (_super) {
1032
+ __extends(GenerateDrawQuery, _super);
1033
+ function GenerateDrawQuery(layer, style, type) {
1034
+ var _this = _super.call(this) || this;
1035
+ _this.layer = layer;
1036
+ _this.style = style;
1037
+ _this.type = type;
1038
+ return _this;
1039
+ }
1040
+ Object.defineProperty(GenerateDrawQuery.prototype, "id", {
1041
+ get: function () {
1042
+ return GenerateDrawQuery.ID;
1043
+ },
1044
+ enumerable: false,
1045
+ configurable: true
1046
+ });
1047
+ return GenerateDrawQuery;
1048
+ }(postboy.PostboyCallbackMessage));
1049
+ GenerateDrawQuery.ID = 'f01c99ba-0953-4ab5-82f9-04e6fbb678c1';
1050
+
1051
+ var FilterFeaturesInAreaQuery = /** @class */ (function (_super) {
1052
+ __extends(FilterFeaturesInAreaQuery, _super);
1053
+ function FilterFeaturesInAreaQuery(area, features) {
1054
+ var _this = _super.call(this) || this;
1055
+ _this.area = area;
1056
+ _this.features = features;
1057
+ return _this;
1058
+ }
1059
+ Object.defineProperty(FilterFeaturesInAreaQuery.prototype, "id", {
1060
+ get: function () {
1061
+ return FilterFeaturesInAreaQuery.ID;
1062
+ },
1063
+ enumerable: false,
1064
+ configurable: true
1065
+ });
1066
+ return FilterFeaturesInAreaQuery;
1067
+ }(postboy.PostboyCallbackMessage));
1068
+ FilterFeaturesInAreaQuery.ID = '36bb2d94-8028-4512-90dd-2386af3fc67c';
1069
+
1070
+ var GetFeaturesInAreaQuery = /** @class */ (function (_super) {
1071
+ __extends(GetFeaturesInAreaQuery, _super);
1072
+ function GetFeaturesInAreaQuery(area, ignore) {
1073
+ if (ignore === void 0) { ignore = new Set(); }
1074
+ var _this = _super.call(this) || this;
1075
+ _this.area = area;
1076
+ _this.ignore = ignore;
1077
+ return _this;
1078
+ }
1079
+ Object.defineProperty(GetFeaturesInAreaQuery.prototype, "id", {
1080
+ get: function () {
1081
+ return GetFeaturesInAreaQuery.ID;
1082
+ },
1083
+ enumerable: false,
1084
+ configurable: true
1085
+ });
1086
+ return GetFeaturesInAreaQuery;
1087
+ }(postboy.PostboyCallbackMessage));
1088
+ GetFeaturesInAreaQuery.ID = 'efcf4271-a07a-40e0-9f02-d4dade40b8ac';
1089
+
942
1090
  var MapPostboyService = /** @class */ (function (_super) {
943
1091
  __extends(MapPostboyService, _super);
944
1092
  function MapPostboyService() {
@@ -957,7 +1105,7 @@
957
1105
  var MapManagementService = /** @class */ (function () {
958
1106
  function MapManagementService(postboy) {
959
1107
  this.postboy = postboy;
960
- this.layers = {};
1108
+ this.layers = new Dictionary();
961
1109
  }
962
1110
  MapManagementService.prototype.up = function () {
963
1111
  this.observeMapRender();
@@ -967,6 +1115,7 @@
967
1115
  this.observeAddTile();
968
1116
  this.observeRemoveTile();
969
1117
  this.observeLayerQuery();
1118
+ this.observeFeaturesInArea();
970
1119
  };
971
1120
  MapManagementService.prototype.observeRemoveTile = function () {
972
1121
  var _this = this;
@@ -978,7 +1127,7 @@
978
1127
  };
979
1128
  MapManagementService.prototype.observeLayerQuery = function () {
980
1129
  var _this = this;
981
- this.postboy.subscribe(GetLayerQuery.ID).subscribe(function (ev) { var _a; return ev.finish((_a = _this.layers[ev.name]) !== null && _a !== void 0 ? _a : null); });
1130
+ this.postboy.subscribe(GetLayerQuery.ID).subscribe(function (ev) { return ev.finish(_this.layers.take(ev.name)); });
982
1131
  };
983
1132
  MapManagementService.prototype.observeAddTile = function () {
984
1133
  var _this = this;
@@ -999,19 +1148,19 @@
999
1148
  this.postboy.subscribe(AddLayerCommand.ID).subscribe(function (c) {
1000
1149
  if (!_this.map)
1001
1150
  return;
1002
- _this.layers[c.layer.get('name')] = c.layer;
1151
+ _this.layers.put(c.layer.get('name'), c.layer);
1003
1152
  _this.map.addLayer(c.layer);
1004
1153
  });
1005
1154
  };
1006
1155
  MapManagementService.prototype.observePlaceFeatures = function () {
1007
1156
  var _this = this;
1008
1157
  this.postboy.subscribe(PlaceLayerFeaturesCommand.ID).subscribe(function (c) {
1009
- var _a, _b;
1010
- if (!_this.layers[c.layer])
1158
+ var _a;
1159
+ if (!_this.layers.has(c.layer))
1011
1160
  return;
1012
- var source = (_a = _this.layers[c.layer]) === null || _a === void 0 ? void 0 : _a.getSource();
1161
+ var source = _this.layers.take(c.layer).getSource();
1013
1162
  if (!!source['getSource'])
1014
- source = (_b = source) === null || _b === void 0 ? void 0 : _b.getSource();
1163
+ source = (_a = source) === null || _a === void 0 ? void 0 : _a.getSource();
1015
1164
  source === null || source === void 0 ? void 0 : source.clear();
1016
1165
  source === null || source === void 0 ? void 0 : source.addFeatures(c.features);
1017
1166
  });
@@ -1021,10 +1170,34 @@
1021
1170
  this.postboy.subscribe(RemoveLayerCommand.ID).subscribe(function (c) {
1022
1171
  if (!_this.map)
1023
1172
  return;
1024
- delete _this.layers[c.layer.get('name')];
1173
+ _this.layers.rmv(c.layer.get('name'));
1025
1174
  _this.map.removeLayer(c.layer);
1026
1175
  });
1027
1176
  };
1177
+ MapManagementService.prototype.observeFeaturesInArea = function () {
1178
+ var _this = this;
1179
+ this.postboy.subscribe(GetFeaturesInAreaQuery.ID).subscribe(function (qr) {
1180
+ var result = new Dictionary();
1181
+ var queue = [];
1182
+ var queries = [];
1183
+ _this.layers.forEach(function (l) {
1184
+ var _a, _b;
1185
+ var layerName = l.get('name');
1186
+ if (qr.ignore.has(layerName) || layerName === MapConstants.DrawingLayerId)
1187
+ return;
1188
+ var source = l.getSource();
1189
+ if (!!source['getSource'])
1190
+ source = (_a = source) === null || _a === void 0 ? void 0 : _a.getSource();
1191
+ var query = new FilterFeaturesInAreaQuery(qr.area, (_b = source === null || source === void 0 ? void 0 : source.getFeatures()) !== null && _b !== void 0 ? _b : []);
1192
+ queue.push(query.result.pipe(operators.tap(function (r) {
1193
+ result.put(l.get('name'), r.map(function (e) { return (Object.assign({ id: e.getId() }, e.get(MapConstants.FeatureInfo))); }));
1194
+ })));
1195
+ queries.push(query);
1196
+ });
1197
+ rxjs.forkJoin(queue).subscribe(function () { return qr.finish(result); });
1198
+ queries.forEach(function (q) { return _this.postboy.fire(q); });
1199
+ });
1200
+ };
1028
1201
  return MapManagementService;
1029
1202
  }());
1030
1203
  MapManagementService.ɵfac = i0__namespace.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "12.2.17", ngImport: i0__namespace, type: MapManagementService, deps: [{ token: MapPostboyService }], target: i0__namespace.ɵɵFactoryTarget.Injectable });
@@ -1151,6 +1324,28 @@
1151
1324
  this.postboy = postboy;
1152
1325
  }
1153
1326
  DrawingService.prototype.up = function () {
1327
+ this.observeDrawing();
1328
+ this.observeSelectArea();
1329
+ this.observeMapRender();
1330
+ };
1331
+ DrawingService.prototype.observeSelectArea = function () {
1332
+ var _this = this;
1333
+ this.postboy.subscribe(DrawSelectionAreaCommand.ID).subscribe(function (ev) {
1334
+ var drawingCommand = new StartDrawingCommand(ev.type, ev.style);
1335
+ drawingCommand.result.subscribe(function (r) {
1336
+ if (!r) {
1337
+ ev.finish(new Dictionary());
1338
+ return;
1339
+ }
1340
+ var area = PolygonModel.fromGeoJson(1, r).feature.getGeometry();
1341
+ var getFeaturesCommand = new GetFeaturesInAreaQuery(area, ev.ignore);
1342
+ getFeaturesCommand.result.subscribe(function (result) { return ev.finish(result); });
1343
+ _this.postboy.fire(getFeaturesCommand);
1344
+ });
1345
+ _this.postboy.fire(drawingCommand);
1346
+ });
1347
+ };
1348
+ DrawingService.prototype.observeDrawing = function () {
1154
1349
  var _this = this;
1155
1350
  this.postboy.subscribe(StartDrawingCommand.ID).subscribe(function (ev) {
1156
1351
  _this.draw(function (l) {
@@ -1158,20 +1353,20 @@
1158
1353
  _this.clearInteraction(l);
1159
1354
  return;
1160
1355
  }
1161
- var cancelSub = _this.observeCancelation(ev, l);
1162
- _this.drawInteraction = new interaction.Draw({
1163
- source: l.getSource(),
1164
- type: exports.DrawingType[ev.type],
1165
- style: ev.style,
1166
- });
1167
- _this.map.addInteraction(_this.drawInteraction);
1168
- _this.drawInteraction.on('drawend', function (evt) {
1169
- cancelSub.unsubscribe();
1170
- _this.onEnd(evt, ev, l);
1356
+ var drawQuery = new GenerateDrawQuery(l, ev.style, ev.type);
1357
+ drawQuery.result.subscribe(function (draw) {
1358
+ var _a;
1359
+ var cancelSub = _this.observeCancelation(ev, l);
1360
+ _this.drawInteraction = draw;
1361
+ (_a = _this.map) === null || _a === void 0 ? void 0 : _a.addInteraction(_this.drawInteraction);
1362
+ _this.drawInteraction.on('drawend', function (evt) {
1363
+ cancelSub.unsubscribe();
1364
+ _this.onEnd(evt, ev, l);
1365
+ });
1171
1366
  });
1367
+ _this.postboy.fire(drawQuery);
1172
1368
  });
1173
1369
  });
1174
- this.observeMapRender();
1175
1370
  };
1176
1371
  DrawingService.prototype.onEnd = function (evt, command, layer) {
1177
1372
  command.finish(command.format === exports.FeatureOutputFormat.GeoJson
@@ -1217,11 +1412,59 @@
1217
1412
  type: i0.Injectable
1218
1413
  }], ctorParameters: function () { return [{ type: MapPostboyService }]; } });
1219
1414
 
1415
+ var DrawingGenerationService = /** @class */ (function () {
1416
+ function DrawingGenerationService(postboy) {
1417
+ this.postboy = postboy;
1418
+ }
1419
+ DrawingGenerationService.prototype.up = function () {
1420
+ this.postboy.subscribe(GenerateDrawQuery.ID).subscribe(function (ev) {
1421
+ ev.finish(new interaction.Draw({
1422
+ source: ev.layer.getSource(),
1423
+ type: exports.DrawingType[ev.type],
1424
+ style: ev.style,
1425
+ geometryFunction: ev.type !== exports.DrawingType.Circle ? undefined : Draw.createRegularPolygon(32),
1426
+ }));
1427
+ });
1428
+ };
1429
+ return DrawingGenerationService;
1430
+ }());
1431
+ DrawingGenerationService.ɵfac = i0__namespace.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "12.2.17", ngImport: i0__namespace, type: DrawingGenerationService, deps: [{ token: MapPostboyService }], target: i0__namespace.ɵɵFactoryTarget.Injectable });
1432
+ DrawingGenerationService.ɵprov = i0__namespace.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "12.2.17", ngImport: i0__namespace, type: DrawingGenerationService });
1433
+ i0__namespace.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "12.2.17", ngImport: i0__namespace, type: DrawingGenerationService, decorators: [{
1434
+ type: i0.Injectable
1435
+ }], ctorParameters: function () { return [{ type: MapPostboyService }]; } });
1436
+
1437
+ var FeatureService = /** @class */ (function () {
1438
+ function FeatureService(postboy) {
1439
+ this.postboy = postboy;
1440
+ }
1441
+ FeatureService.prototype.up = function () {
1442
+ this.postboy.subscribe(FilterFeaturesInAreaQuery.ID).subscribe(function (qr) {
1443
+ qr.finish(qr.features.filter(function (f) { return FeatureService.booleanIntersects(qr.area, f.getGeometry()); }));
1444
+ });
1445
+ };
1446
+ FeatureService.booleanIntersects = function (g1, g2) {
1447
+ if (g2.getType() === 'Point')
1448
+ return g1.intersectsCoordinate(g2.getCoordinates());
1449
+ if (g2.getType() === 'Circle')
1450
+ return g1.intersectsCoordinate(g2.getCenter());
1451
+ if (g2.getType() === 'Polygon')
1452
+ return g1.intersectsCoordinate(g2.getInteriorPoint().getCoordinates());
1453
+ return false;
1454
+ };
1455
+ return FeatureService;
1456
+ }());
1457
+ FeatureService.ɵfac = i0__namespace.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "12.2.17", ngImport: i0__namespace, type: FeatureService, deps: [{ token: MapPostboyService }], target: i0__namespace.ɵɵFactoryTarget.Injectable });
1458
+ FeatureService.ɵprov = i0__namespace.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "12.2.17", ngImport: i0__namespace, type: FeatureService });
1459
+ i0__namespace.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "12.2.17", ngImport: i0__namespace, type: FeatureService, decorators: [{
1460
+ type: i0.Injectable
1461
+ }], ctorParameters: function () { return [{ type: MapPostboyService }]; } });
1462
+
1220
1463
  var MessageRegistratorService = /** @class */ (function (_super) {
1221
1464
  __extends(MessageRegistratorService, _super);
1222
- function MessageRegistratorService(service, management, state, feature, interaction, drawing) {
1465
+ function MessageRegistratorService(service, management, state, mapFeature, interaction, drawing, drawGenerator, feature) {
1223
1466
  var _this = _super.call(this, service) || this;
1224
- _this.registerServices([management, state, interaction, feature, drawing]);
1467
+ _this.registerServices([management, state, interaction, mapFeature, drawing, drawGenerator, feature]);
1225
1468
  return _this;
1226
1469
  }
1227
1470
  MessageRegistratorService.prototype._up = function () {
@@ -1239,14 +1482,18 @@
1239
1482
  this.registerSubject(StartDrawingCommand.ID);
1240
1483
  this.registerSubject(GetLayerQuery.ID);
1241
1484
  this.registerSubject(DrawingFinishedEvent.ID);
1485
+ this.registerSubject(GenerateDrawQuery.ID);
1486
+ this.registerSubject(FilterFeaturesInAreaQuery.ID);
1487
+ this.registerSubject(GetFeaturesInAreaQuery.ID);
1488
+ this.registerSubject(DrawSelectionAreaCommand.ID);
1242
1489
  };
1243
1490
  return MessageRegistratorService;
1244
1491
  }(postboy.PostboyAbstractRegistrator));
1245
- MessageRegistratorService.ɵfac = i0__namespace.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "12.2.17", ngImport: i0__namespace, type: MessageRegistratorService, deps: [{ token: MapPostboyService }, { token: MapManagementService }, { token: MapStateService }, { token: MapFeatureService }, { token: MapClickService }, { token: DrawingService }], target: i0__namespace.ɵɵFactoryTarget.Injectable });
1492
+ MessageRegistratorService.ɵfac = i0__namespace.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "12.2.17", ngImport: i0__namespace, type: MessageRegistratorService, deps: [{ token: MapPostboyService }, { token: MapManagementService }, { token: MapStateService }, { token: MapFeatureService }, { token: MapClickService }, { token: DrawingService }, { token: DrawingGenerationService }, { token: FeatureService }], target: i0__namespace.ɵɵFactoryTarget.Injectable });
1246
1493
  MessageRegistratorService.ɵprov = i0__namespace.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "12.2.17", ngImport: i0__namespace, type: MessageRegistratorService });
1247
1494
  i0__namespace.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "12.2.17", ngImport: i0__namespace, type: MessageRegistratorService, decorators: [{
1248
1495
  type: i0.Injectable
1249
- }], ctorParameters: function () { return [{ type: MapPostboyService }, { type: MapManagementService }, { type: MapStateService }, { type: MapFeatureService }, { type: MapClickService }, { type: DrawingService }]; } });
1496
+ }], ctorParameters: function () { return [{ type: MapPostboyService }, { type: MapManagementService }, { type: MapStateService }, { type: MapFeatureService }, { type: MapClickService }, { type: DrawingService }, { type: DrawingGenerationService }, { type: FeatureService }]; } });
1250
1497
 
1251
1498
  var TileLayerSettings = /** @class */ (function () {
1252
1499
  function TileLayerSettings() {
@@ -1886,6 +2133,8 @@
1886
2133
  MapClickService,
1887
2134
  MapFeatureService,
1888
2135
  DrawingService,
2136
+ DrawingGenerationService,
2137
+ FeatureService,
1889
2138
  ], usesInheritance: true, ngImport: i0__namespace, 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__namespace.NgIf, selector: "[ngIf]", inputs: ["ngIf", "ngIfThen", "ngIfElse"] }], changeDetection: i0__namespace.ChangeDetectionStrategy.OnPush });
1890
2139
  i0__namespace.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "12.2.17", ngImport: i0__namespace, type: MapPlateComponent, decorators: [{
1891
2140
  type: i0.Component,
@@ -1901,6 +2150,8 @@
1901
2150
  MapClickService,
1902
2151
  MapFeatureService,
1903
2152
  DrawingService,
2153
+ DrawingGenerationService,
2154
+ FeatureService,
1904
2155
  ],
1905
2156
  }]
1906
2157
  }], ctorParameters: function () { return [{ type: i0__namespace.ElementRef }, { type: MapPostboyService }, { type: MapPlateFactory }, { type: MessageRegistratorService }, { type: i0__namespace.ChangeDetectorRef }]; }, propDecorators: { settings: [{
@@ -2233,6 +2484,59 @@
2233
2484
  return TextStyleHelper;
2234
2485
  }());
2235
2486
 
2487
+ var StringifyFeatureHelper = /** @class */ (function () {
2488
+ function StringifyFeatureHelper() {
2489
+ }
2490
+ StringifyFeatureHelper.polygon = function (feature, format$1) {
2491
+ if (format$1 === void 0) { format$1 = exports.FeatureOutputFormat.GeoJson; }
2492
+ return format$1 === exports.FeatureOutputFormat.GeoJson
2493
+ ? new format.GeoJSON().writeFeature(feature)
2494
+ : new format.WKT().writeFeature(feature);
2495
+ };
2496
+ StringifyFeatureHelper.circle = function (feature, format) {
2497
+ if (format === void 0) { format = exports.FeatureOutputFormat.GeoJson; }
2498
+ // const clone = feature.clone();
2499
+ // clone.setGeometry(fromCircle(feature.getGeometry()! as Circle));
2500
+ var tetemp = feature.getGeometryName();
2501
+ var circle = feature.getGeometry();
2502
+ // const temp = StringifyFeatureHelper.drawCircle(circle.getCenter(), circle.getRadius());
2503
+ var ttt = feature.getGeometry().getExtent();
2504
+ var eastPoint = [ttt[2], (ttt[1] + ttt[3]) / 2];
2505
+ var aaa = __spreadArray(__spreadArray([], __read(proj.transform([ttt[0], ttt[1]], 'EPSG:4326', 'EPSG:3857'))), __read(proj.transform([ttt[2], ttt[3]], 'EPSG:4326', 'EPSG:3857')));
2506
+ var radius = (aaa[2] - aaa[0]) / 2;
2507
+ var radius2 = new geom.LineString([circle.getCenter(), eastPoint]).getLength();
2508
+ var polygonGeom = new Polygon__default["default"](StringifyFeatureHelper.drawCircle(circle.getCenter(), radius));
2509
+ // var edgeCoordinate = [circle.getCenter()[0] + radius, circle.getCenter()[1]];
2510
+ // var wgs84Sphere = new Sphere(6378137);
2511
+ return StringifyFeatureHelper.polygon(new ol.Feature(polygonGeom), format);
2512
+ // const rad = circle.getRadius();
2513
+ // const degrees = 180 / Math.PI; // radians to degrees
2514
+ // const radians = Math.PI / 180; // degrees to radians
2515
+ // const rlat = rad * degrees * 1000;
2516
+ // const rlng = rad * radians;
2517
+ // return StringifyFeatureHelper.polygon(new Feature<Geometry>(circular(circle.getCenter(),circle.getRadius() * METERS_PER_UNIT)), format);
2518
+ };
2519
+ StringifyFeatureHelper.drawCircle = function (point, radius) {
2520
+ var tetetemp = proj.transform(point, 'EPSG:4326', 'EPSG:3857');
2521
+ // const tetetemp = point;
2522
+ var radians = Math.PI / 180; // degrees to radians
2523
+ var degrees = 180 / Math.PI; // radians to degrees
2524
+ var earthsradius = 6378137.0;
2525
+ var rlat = (radius / earthsradius) * degrees;
2526
+ var rlng = rlat / Math.cos(tetetemp[1] * radians);
2527
+ var extp = [];
2528
+ for (var i = 0; i <= 32; i++) {
2529
+ var theta = Math.PI * (i / 16);
2530
+ extp.push([
2531
+ tetetemp[0] + rlng * Math.cos(theta) * epsg4326.METERS_PER_UNIT,
2532
+ tetetemp[1] + rlat * Math.sin(theta) * epsg4326.METERS_PER_UNIT,
2533
+ ]);
2534
+ }
2535
+ return [extp.map(function (e) { return proj.transform(e, 'EPSG:3857', 'EPSG:4326'); })];
2536
+ };
2537
+ return StringifyFeatureHelper;
2538
+ }());
2539
+
2236
2540
  /*
2237
2541
  * Public API Surface of maps
2238
2542
  */
@@ -2249,6 +2553,8 @@
2249
2553
  exports.CloseTooltipCommand = CloseTooltipCommand;
2250
2554
  exports.ClusterLayerComponent = ClusterLayerComponent;
2251
2555
  exports.ClusterLayerSettings = ClusterLayerSettings;
2556
+ exports.Dictionary = Dictionary;
2557
+ exports.DrawSelectionAreaCommand = DrawSelectionAreaCommand;
2252
2558
  exports.FeatureLayerComponent = FeatureLayerComponent;
2253
2559
  exports.FeatureLayerSettings = FeatureLayerSettings;
2254
2560
  exports.MapClickEvent = MapClickEvent;
@@ -2268,6 +2574,7 @@
2268
2574
  exports.PolygonStyleHelper = PolygonStyleHelper;
2269
2575
  exports.PolygonsComponent = PolygonsComponent;
2270
2576
  exports.StartDrawingCommand = StartDrawingCommand;
2577
+ exports.StringifyFeatureHelper = StringifyFeatureHelper;
2271
2578
  exports.TextStyleHelper = TextStyleHelper;
2272
2579
  exports.TileLayerComponent = TileLayerComponent;
2273
2580
  exports.TileLayerSettings = TileLayerSettings;