@artstesh/maps 1.0.9 → 1.0.11

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (82) hide show
  1. package/dist/bundles/maps-components-src-map.umd.js +402 -51
  2. package/dist/bundles/maps-components-src-map.umd.js.map +1 -1
  3. package/dist/bundles/maps-components.umd.js +402 -51
  4. package/dist/bundles/maps-components.umd.js.map +1 -1
  5. package/dist/esm2015/map/helpers/polygon-style.helper.js +19 -2
  6. package/dist/esm2015/map/map-plate/map-plate.component.js +7 -1
  7. package/dist/esm2015/map/messages/commands/cancel-feature-modification.command.js +8 -0
  8. package/dist/esm2015/map/messages/commands/draw-selection-area.command.js +14 -0
  9. package/dist/esm2015/map/messages/commands/modify-feature.command.js +15 -0
  10. package/dist/esm2015/map/messages/executors/filter-features-in-area.executor.js +13 -0
  11. package/dist/esm2015/map/messages/executors/generate-draw.executor.js +14 -0
  12. package/dist/esm2015/map/messages/index.js +4 -1
  13. package/dist/esm2015/map/messages/queries/get-features-in-area.query.js +13 -0
  14. package/dist/esm2015/map/models/dictionary.js +56 -0
  15. package/dist/esm2015/map/models/drawing-type.enum.js +2 -1
  16. package/dist/esm2015/map/models/index.js +2 -1
  17. package/dist/esm2015/map/services/drawing/drawing-generation.service.js +16 -21
  18. package/dist/esm2015/map/services/drawing/drawing.service.js +33 -15
  19. package/dist/esm2015/map/services/drawing/feature-modification.service.js +104 -0
  20. package/dist/esm2015/map/services/feature.service.js +16 -0
  21. package/dist/esm2015/map/services/map-management.service.js +31 -9
  22. package/dist/esm2015/map/services/message-registrator.service.js +23 -8
  23. package/dist/esm2015/src/map/helpers/polygon-style.helper.js +19 -2
  24. package/dist/esm2015/src/map/map-plate/map-plate.component.js +7 -1
  25. package/dist/esm2015/src/map/messages/commands/cancel-feature-modification.command.js +8 -0
  26. package/dist/esm2015/src/map/messages/commands/draw-selection-area.command.js +14 -0
  27. package/dist/esm2015/src/map/messages/commands/modify-feature.command.js +15 -0
  28. package/dist/esm2015/src/map/messages/executors/filter-features-in-area.executor.js +13 -0
  29. package/dist/esm2015/src/map/messages/executors/generate-draw.executor.js +14 -0
  30. package/dist/esm2015/src/map/messages/index.js +4 -1
  31. package/dist/esm2015/src/map/messages/queries/get-features-in-area.query.js +13 -0
  32. package/dist/esm2015/src/map/models/dictionary.js +56 -0
  33. package/dist/esm2015/src/map/models/drawing-type.enum.js +2 -1
  34. package/dist/esm2015/src/map/models/index.js +2 -1
  35. package/dist/esm2015/src/map/services/drawing/drawing-generation.service.js +16 -21
  36. package/dist/esm2015/src/map/services/drawing/drawing.service.js +33 -15
  37. package/dist/esm2015/src/map/services/drawing/feature-modification.service.js +104 -0
  38. package/dist/esm2015/src/map/services/feature.service.js +16 -0
  39. package/dist/esm2015/src/map/services/map-management.service.js +31 -9
  40. package/dist/esm2015/src/map/services/message-registrator.service.js +23 -8
  41. package/dist/fesm2015/maps-components-src-map.js +327 -44
  42. package/dist/fesm2015/maps-components-src-map.js.map +1 -1
  43. package/dist/fesm2015/maps-components.js +327 -44
  44. package/dist/fesm2015/maps-components.js.map +1 -1
  45. package/dist/map/helpers/polygon-style.helper.d.ts +1 -0
  46. package/dist/map/messages/commands/cancel-feature-modification.command.d.ts +5 -0
  47. package/dist/map/messages/commands/draw-selection-area.command.d.ts +12 -0
  48. package/dist/map/messages/commands/modify-feature.command.d.ts +11 -0
  49. package/dist/map/messages/executors/filter-features-in-area.executor.d.ts +10 -0
  50. package/dist/map/messages/{queries/generate-draw.query.d.ts → executors/generate-draw.executor.d.ts} +2 -2
  51. package/dist/map/messages/index.d.ts +3 -0
  52. package/dist/map/messages/queries/get-features-in-area.query.d.ts +11 -0
  53. package/dist/map/models/dictionary.d.ts +17 -0
  54. package/dist/map/models/drawing-type.enum.d.ts +2 -1
  55. package/dist/map/models/index.d.ts +1 -0
  56. package/dist/map/services/drawing/drawing-generation.service.d.ts +5 -9
  57. package/dist/map/services/drawing/drawing.service.d.ts +2 -0
  58. package/dist/map/services/drawing/feature-modification.service.d.ts +22 -0
  59. package/dist/map/services/feature.service.d.ts +8 -0
  60. package/dist/map/services/map-management.service.d.ts +1 -0
  61. package/dist/map/services/message-registrator.service.d.ts +3 -2
  62. package/dist/package.json +1 -1
  63. package/dist/src/map/helpers/polygon-style.helper.d.ts +1 -0
  64. package/dist/src/map/messages/commands/cancel-feature-modification.command.d.ts +5 -0
  65. package/dist/src/map/messages/commands/draw-selection-area.command.d.ts +12 -0
  66. package/dist/src/map/messages/commands/modify-feature.command.d.ts +11 -0
  67. package/dist/src/map/messages/executors/filter-features-in-area.executor.d.ts +10 -0
  68. package/dist/src/map/messages/{queries/generate-draw.query.d.ts → executors/generate-draw.executor.d.ts} +2 -2
  69. package/dist/src/map/messages/index.d.ts +3 -0
  70. package/dist/src/map/messages/queries/get-features-in-area.query.d.ts +11 -0
  71. package/dist/src/map/models/dictionary.d.ts +17 -0
  72. package/dist/src/map/models/drawing-type.enum.d.ts +2 -1
  73. package/dist/src/map/models/index.d.ts +1 -0
  74. package/dist/src/map/services/drawing/drawing-generation.service.d.ts +5 -9
  75. package/dist/src/map/services/drawing/drawing.service.d.ts +2 -0
  76. package/dist/src/map/services/drawing/feature-modification.service.d.ts +22 -0
  77. package/dist/src/map/services/feature.service.d.ts +8 -0
  78. package/dist/src/map/services/map-management.service.d.ts +1 -0
  79. package/dist/src/map/services/message-registrator.service.d.ts +3 -2
  80. package/package.json +2 -2
  81. package/dist/esm2015/map/messages/queries/generate-draw.query.js +0 -14
  82. package/dist/esm2015/src/map/messages/queries/generate-draw.query.js +0 -14
@@ -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/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('rxjs'), 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/operators', 'ol/source', 'ol/interaction', 'ol/interaction/Draw', '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', '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.operators, global.source, global.interaction, global.Draw, global.TileLayer, global.OSM, global.layer, global.loadingstrategy, global.Polygon, global.Cluster, global.rxjs, global.Map, global.View, global.Overlay, global.Style, global.style, global.epsg4326));
5
- })(this, (function (exports, i0, i6, ol, geom, format, extent, proj, postboy, operators, source, interaction, Draw, TileLayer, OSM, layer, loadingstrategy, Polygon, Cluster, rxjs, Map, View, Overlay, Style, style, epsg4326) { '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('ol/interaction'), require('ol/interaction/Draw'), require('rxjs/operators'), require('ol/source'), 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'), 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', 'ol/interaction', 'ol/interaction/Draw', 'rxjs/operators', 'ol/source', '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', '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.interaction, global.Draw, global.rxjs.operators, global.source, global.TileLayer, global.OSM, global.layer, global.loadingstrategy, global.Polygon, global.Cluster, global.rxjs, global.Map, global.View, global.Overlay, global.Style, global.style, global.epsg4326));
5
+ })(this, (function (exports, i0, i6, ol, geom, format, extent, proj, postboy, interaction, Draw, operators, source, TileLayer, OSM, layer, loadingstrategy, Polygon, Cluster, rxjs, 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
 
@@ -676,6 +676,7 @@
676
676
  (function (DrawingType) {
677
677
  DrawingType[DrawingType["Polygon"] = 1] = "Polygon";
678
678
  DrawingType[DrawingType["Circle"] = 2] = "Circle";
679
+ DrawingType[DrawingType["Square"] = 3] = "Square";
679
680
  })(exports.DrawingType || (exports.DrawingType = {}));
680
681
 
681
682
  exports.FeatureOutputFormat = void 0;
@@ -684,6 +685,72 @@
684
685
  FeatureOutputFormat[FeatureOutputFormat["WKT"] = 2] = "WKT";
685
686
  })(exports.FeatureOutputFormat || (exports.FeatureOutputFormat = {}));
686
687
 
688
+ var Dictionary = /** @class */ (function () {
689
+ function Dictionary() {
690
+ var _this = this;
691
+ this.collection = {};
692
+ this._keys = new Set();
693
+ this.has = function (key) { return _this._keys.has(key); };
694
+ }
695
+ Object.defineProperty(Dictionary.prototype, "keys", {
696
+ get: function () {
697
+ return Array.from(this._keys);
698
+ },
699
+ enumerable: false,
700
+ configurable: true
701
+ });
702
+ Object.defineProperty(Dictionary.prototype, "size", {
703
+ get: function () {
704
+ return this._keys.size;
705
+ },
706
+ enumerable: false,
707
+ configurable: true
708
+ });
709
+ Dictionary.clone = function (dic, action) {
710
+ return Dictionary.create(dic.collection, action);
711
+ };
712
+ Dictionary.create = function (dic, action) {
713
+ var keyList = Object.keys(dic);
714
+ var result = new Dictionary();
715
+ for (var i = 0; i < keyList.length; i++) {
716
+ var key = keyList[i];
717
+ result._keys.add(key);
718
+ result.collection[key] = action ? action(dic[key], key) : dic[key];
719
+ }
720
+ return result;
721
+ };
722
+ Dictionary.prototype.find = function (predicate) {
723
+ var result = null;
724
+ this.forEach(function (e) {
725
+ if (result === null && predicate(e))
726
+ result = e;
727
+ });
728
+ return result;
729
+ };
730
+ Dictionary.prototype.take = function (key) {
731
+ return this._keys.has(key) ? this.collection[key] : null;
732
+ };
733
+ Dictionary.prototype.put = function (key, value) {
734
+ if (value == null)
735
+ return;
736
+ this.collection[key] = value;
737
+ this._keys.add(key);
738
+ };
739
+ Dictionary.prototype.rmv = function (key) {
740
+ if (!this._keys.has(key))
741
+ return;
742
+ delete this.collection[key];
743
+ this._keys.delete(key);
744
+ };
745
+ Dictionary.prototype.forEach = function (callback) {
746
+ var keys = Object.keys(this.collection);
747
+ for (var i = 0; i < keys.length; i++) {
748
+ callback(this.collection[keys[i]], i);
749
+ }
750
+ };
751
+ return Dictionary;
752
+ }());
753
+
687
754
  var MapRenderedEvent = /** @class */ (function (_super) {
688
755
  __extends(MapRenderedEvent, _super);
689
756
  function MapRenderedEvent(map) {
@@ -796,6 +863,64 @@
796
863
  }(postboy.PostboyGenericMessage));
797
864
  CancelDrawingCommand.ID = '7d38d983-feba-4176-a66b-18175e5ecd6b';
798
865
 
866
+ var DrawSelectionAreaCommand = /** @class */ (function (_super) {
867
+ __extends(DrawSelectionAreaCommand, _super);
868
+ function DrawSelectionAreaCommand(type, style, ignore) {
869
+ if (ignore === void 0) { ignore = new Set(); }
870
+ var _this = _super.call(this) || this;
871
+ _this.type = type;
872
+ _this.style = style;
873
+ _this.ignore = ignore;
874
+ return _this;
875
+ }
876
+ Object.defineProperty(DrawSelectionAreaCommand.prototype, "id", {
877
+ get: function () {
878
+ return DrawSelectionAreaCommand.ID;
879
+ },
880
+ enumerable: false,
881
+ configurable: true
882
+ });
883
+ return DrawSelectionAreaCommand;
884
+ }(postboy.PostboyCallbackMessage));
885
+ DrawSelectionAreaCommand.ID = '573d8a0d-f25b-42b7-9ad7-0ac6d86ac362';
886
+
887
+ var ModifyFeatureCommand = /** @class */ (function (_super) {
888
+ __extends(ModifyFeatureCommand, _super);
889
+ function ModifyFeatureCommand(model, style, format) {
890
+ if (format === void 0) { format = exports.FeatureOutputFormat.GeoJson; }
891
+ var _this = _super.call(this) || this;
892
+ _this.model = model;
893
+ _this.style = style;
894
+ _this.format = format;
895
+ return _this;
896
+ }
897
+ Object.defineProperty(ModifyFeatureCommand.prototype, "id", {
898
+ get: function () {
899
+ return ModifyFeatureCommand.ID;
900
+ },
901
+ enumerable: false,
902
+ configurable: true
903
+ });
904
+ return ModifyFeatureCommand;
905
+ }(postboy.PostboyCallbackMessage));
906
+ ModifyFeatureCommand.ID = 'ead85caa-24c6-4844-a68c-2cea91774c8c';
907
+
908
+ var CancelFeatureModificationCommand = /** @class */ (function (_super) {
909
+ __extends(CancelFeatureModificationCommand, _super);
910
+ function CancelFeatureModificationCommand() {
911
+ return _super !== null && _super.apply(this, arguments) || this;
912
+ }
913
+ Object.defineProperty(CancelFeatureModificationCommand.prototype, "id", {
914
+ get: function () {
915
+ return CancelFeatureModificationCommand.ID;
916
+ },
917
+ enumerable: false,
918
+ configurable: true
919
+ });
920
+ return CancelFeatureModificationCommand;
921
+ }(postboy.PostboyGenericMessage));
922
+ CancelFeatureModificationCommand.ID = '9c9fb40f-ea95-4704-8177-0e9ecabf36fa';
923
+
799
924
  var AddLayerCommand = /** @class */ (function (_super) {
800
925
  __extends(AddLayerCommand, _super);
801
926
  function AddLayerCommand(layer) {
@@ -941,25 +1066,105 @@
941
1066
  }(postboy.PostboyGenericMessage));
942
1067
  DrawingFinishedEvent.ID = 'c724b68e-b4eb-4783-90f1-a8e31973fd36';
943
1068
 
944
- var GenerateDrawQuery = /** @class */ (function (_super) {
945
- __extends(GenerateDrawQuery, _super);
946
- function GenerateDrawQuery(layer, style, type) {
1069
+ var DrawingGenerationService = /** @class */ (function () {
1070
+ function DrawingGenerationService() {
1071
+ }
1072
+ DrawingGenerationService.getDraw = function (ev) {
1073
+ return new interaction.Draw({
1074
+ source: ev.layer.getSource(),
1075
+ type: ev.type === exports.DrawingType.Polygon ? 'Polygon' : 'Circle',
1076
+ style: ev.style,
1077
+ geometryFunction: DrawingGenerationService.geometryFunc(ev.type),
1078
+ });
1079
+ };
1080
+ DrawingGenerationService.geometryFunc = function (type) {
1081
+ switch (type) {
1082
+ case exports.DrawingType.Circle:
1083
+ return Draw.createRegularPolygon(32);
1084
+ case exports.DrawingType.Square:
1085
+ return Draw.createRegularPolygon(4);
1086
+ }
1087
+ return undefined;
1088
+ };
1089
+ return DrawingGenerationService;
1090
+ }());
1091
+
1092
+ var FeatureService = /** @class */ (function () {
1093
+ function FeatureService() {
1094
+ }
1095
+ FeatureService.filterFeaturesInArea = function (query) {
1096
+ return query.features.filter(function (f) { return FeatureService.booleanIntersects(query.area, f.getGeometry()); });
1097
+ };
1098
+ FeatureService.booleanIntersects = function (g1, g2) {
1099
+ if (g2.getType() === 'Point')
1100
+ return g1.intersectsCoordinate(g2.getCoordinates());
1101
+ if (g2.getType() === 'Circle')
1102
+ return g1.intersectsCoordinate(g2.getCenter());
1103
+ if (g2.getType() === 'Polygon')
1104
+ return g1.intersectsCoordinate(g2.getInteriorPoint().getCoordinates());
1105
+ return false;
1106
+ };
1107
+ return FeatureService;
1108
+ }());
1109
+
1110
+ var GetFeaturesInAreaQuery = /** @class */ (function (_super) {
1111
+ __extends(GetFeaturesInAreaQuery, _super);
1112
+ function GetFeaturesInAreaQuery(area, ignore) {
1113
+ if (ignore === void 0) { ignore = new Set(); }
1114
+ var _this = _super.call(this) || this;
1115
+ _this.area = area;
1116
+ _this.ignore = ignore;
1117
+ return _this;
1118
+ }
1119
+ Object.defineProperty(GetFeaturesInAreaQuery.prototype, "id", {
1120
+ get: function () {
1121
+ return GetFeaturesInAreaQuery.ID;
1122
+ },
1123
+ enumerable: false,
1124
+ configurable: true
1125
+ });
1126
+ return GetFeaturesInAreaQuery;
1127
+ }(postboy.PostboyCallbackMessage));
1128
+ GetFeaturesInAreaQuery.ID = 'efcf4271-a07a-40e0-9f02-d4dade40b8ac';
1129
+
1130
+ var FilterFeaturesInAreaExecutor = /** @class */ (function (_super) {
1131
+ __extends(FilterFeaturesInAreaExecutor, _super);
1132
+ function FilterFeaturesInAreaExecutor(area, features) {
1133
+ var _this = _super.call(this) || this;
1134
+ _this.area = area;
1135
+ _this.features = features;
1136
+ return _this;
1137
+ }
1138
+ Object.defineProperty(FilterFeaturesInAreaExecutor.prototype, "id", {
1139
+ get: function () {
1140
+ return FilterFeaturesInAreaExecutor.ID;
1141
+ },
1142
+ enumerable: false,
1143
+ configurable: true
1144
+ });
1145
+ return FilterFeaturesInAreaExecutor;
1146
+ }(postboy.PostboyExecutor));
1147
+ FilterFeaturesInAreaExecutor.ID = '36bb2d94-8028-4512-90dd-2386af3fc67c';
1148
+
1149
+ var GenerateDrawExecutor = /** @class */ (function (_super) {
1150
+ __extends(GenerateDrawExecutor, _super);
1151
+ function GenerateDrawExecutor(layer, style, type) {
947
1152
  var _this = _super.call(this) || this;
948
1153
  _this.layer = layer;
949
1154
  _this.style = style;
950
1155
  _this.type = type;
951
1156
  return _this;
952
1157
  }
953
- Object.defineProperty(GenerateDrawQuery.prototype, "id", {
1158
+ Object.defineProperty(GenerateDrawExecutor.prototype, "id", {
954
1159
  get: function () {
955
- return GenerateDrawQuery.ID;
1160
+ return GenerateDrawExecutor.ID;
956
1161
  },
957
1162
  enumerable: false,
958
1163
  configurable: true
959
1164
  });
960
- return GenerateDrawQuery;
961
- }(postboy.PostboyCallbackMessage));
962
- GenerateDrawQuery.ID = 'f01c99ba-0953-4ab5-82f9-04e6fbb678c1';
1165
+ return GenerateDrawExecutor;
1166
+ }(postboy.PostboyExecutor));
1167
+ GenerateDrawExecutor.ID = 'f01c99ba-0953-4ab5-82f9-04e6fbb678c1';
963
1168
 
964
1169
  var MapPostboyService = /** @class */ (function (_super) {
965
1170
  __extends(MapPostboyService, _super);
@@ -979,7 +1184,7 @@
979
1184
  var MapManagementService = /** @class */ (function () {
980
1185
  function MapManagementService(postboy) {
981
1186
  this.postboy = postboy;
982
- this.layers = {};
1187
+ this.layers = new Dictionary();
983
1188
  }
984
1189
  MapManagementService.prototype.up = function () {
985
1190
  this.observeMapRender();
@@ -989,6 +1194,7 @@
989
1194
  this.observeAddTile();
990
1195
  this.observeRemoveTile();
991
1196
  this.observeLayerQuery();
1197
+ this.observeFeaturesInArea();
992
1198
  };
993
1199
  MapManagementService.prototype.observeRemoveTile = function () {
994
1200
  var _this = this;
@@ -1000,7 +1206,7 @@
1000
1206
  };
1001
1207
  MapManagementService.prototype.observeLayerQuery = function () {
1002
1208
  var _this = this;
1003
- this.postboy.subscribe(GetLayerQuery.ID).subscribe(function (ev) { var _a; return ev.finish((_a = _this.layers[ev.name]) !== null && _a !== void 0 ? _a : null); });
1209
+ this.postboy.subscribe(GetLayerQuery.ID).subscribe(function (ev) { return ev.finish(_this.layers.take(ev.name)); });
1004
1210
  };
1005
1211
  MapManagementService.prototype.observeAddTile = function () {
1006
1212
  var _this = this;
@@ -1021,19 +1227,19 @@
1021
1227
  this.postboy.subscribe(AddLayerCommand.ID).subscribe(function (c) {
1022
1228
  if (!_this.map)
1023
1229
  return;
1024
- _this.layers[c.layer.get('name')] = c.layer;
1230
+ _this.layers.put(c.layer.get('name'), c.layer);
1025
1231
  _this.map.addLayer(c.layer);
1026
1232
  });
1027
1233
  };
1028
1234
  MapManagementService.prototype.observePlaceFeatures = function () {
1029
1235
  var _this = this;
1030
1236
  this.postboy.subscribe(PlaceLayerFeaturesCommand.ID).subscribe(function (c) {
1031
- var _a, _b;
1032
- if (!_this.layers[c.layer])
1237
+ var _a;
1238
+ if (!_this.layers.has(c.layer))
1033
1239
  return;
1034
- var source = (_a = _this.layers[c.layer]) === null || _a === void 0 ? void 0 : _a.getSource();
1240
+ var source = _this.layers.take(c.layer).getSource();
1035
1241
  if (!!source['getSource'])
1036
- source = (_b = source) === null || _b === void 0 ? void 0 : _b.getSource();
1242
+ source = (_a = source) === null || _a === void 0 ? void 0 : _a.getSource();
1037
1243
  source === null || source === void 0 ? void 0 : source.clear();
1038
1244
  source === null || source === void 0 ? void 0 : source.addFeatures(c.features);
1039
1245
  });
@@ -1043,10 +1249,28 @@
1043
1249
  this.postboy.subscribe(RemoveLayerCommand.ID).subscribe(function (c) {
1044
1250
  if (!_this.map)
1045
1251
  return;
1046
- delete _this.layers[c.layer.get('name')];
1252
+ _this.layers.rmv(c.layer.get('name'));
1047
1253
  _this.map.removeLayer(c.layer);
1048
1254
  });
1049
1255
  };
1256
+ MapManagementService.prototype.observeFeaturesInArea = function () {
1257
+ var _this = this;
1258
+ this.postboy.subscribe(GetFeaturesInAreaQuery.ID).subscribe(function (qr) {
1259
+ var result = new Dictionary();
1260
+ _this.layers.forEach(function (l) {
1261
+ var _a, _b;
1262
+ var layerName = l.get('name');
1263
+ if (qr.ignore.has(layerName) || layerName === MapConstants.DrawingLayerId)
1264
+ return;
1265
+ var source = l.getSource();
1266
+ if (!!source['getSource'])
1267
+ source = (_a = source) === null || _a === void 0 ? void 0 : _a.getSource();
1268
+ var features = _this.postboy.execute(new FilterFeaturesInAreaExecutor(qr.area, (_b = source === null || source === void 0 ? void 0 : source.getFeatures()) !== null && _b !== void 0 ? _b : []));
1269
+ result.put(layerName, features.map(function (e) { return (Object.assign({ id: e.getId() }, e.get(MapConstants.FeatureInfo))); }));
1270
+ });
1271
+ qr.finish(result);
1272
+ });
1273
+ };
1050
1274
  return MapManagementService;
1051
1275
  }());
1052
1276
  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 });
@@ -1173,28 +1397,45 @@
1173
1397
  this.postboy = postboy;
1174
1398
  }
1175
1399
  DrawingService.prototype.up = function () {
1400
+ this.observeDrawing();
1401
+ this.observeSelectArea();
1402
+ this.observeMapRender();
1403
+ };
1404
+ DrawingService.prototype.observeSelectArea = function () {
1405
+ var _this = this;
1406
+ this.postboy.subscribe(DrawSelectionAreaCommand.ID).subscribe(function (ev) {
1407
+ var drawingCommand = new StartDrawingCommand(ev.type, ev.style);
1408
+ drawingCommand.result.subscribe(function (r) {
1409
+ if (!r) {
1410
+ ev.finish(new Dictionary());
1411
+ return;
1412
+ }
1413
+ var area = PolygonModel.fromGeoJson(1, r).feature.getGeometry();
1414
+ var getFeaturesCommand = new GetFeaturesInAreaQuery(area, ev.ignore);
1415
+ getFeaturesCommand.result.subscribe(function (result) { return ev.finish(result); });
1416
+ _this.postboy.fire(getFeaturesCommand);
1417
+ });
1418
+ _this.postboy.fire(drawingCommand);
1419
+ });
1420
+ };
1421
+ DrawingService.prototype.observeDrawing = function () {
1176
1422
  var _this = this;
1177
1423
  this.postboy.subscribe(StartDrawingCommand.ID).subscribe(function (ev) {
1178
1424
  _this.draw(function (l) {
1425
+ var _a;
1179
1426
  if (!l || !_this.map) {
1180
1427
  _this.clearInteraction(l);
1181
1428
  return;
1182
1429
  }
1183
- var drawQuery = new GenerateDrawQuery(l, ev.style, ev.type);
1184
- drawQuery.result.subscribe(function (draw) {
1185
- var _a;
1186
- var cancelSub = _this.observeCancelation(ev, l);
1187
- _this.drawInteraction = draw;
1188
- (_a = _this.map) === null || _a === void 0 ? void 0 : _a.addInteraction(_this.drawInteraction);
1189
- _this.drawInteraction.on('drawend', function (evt) {
1190
- cancelSub.unsubscribe();
1191
- _this.onEnd(evt, ev, l);
1192
- });
1430
+ var cancelSub = _this.observeCancelation(ev, l);
1431
+ _this.drawInteraction = _this.postboy.execute(new GenerateDrawExecutor(l, ev.style, ev.type));
1432
+ (_a = _this.map) === null || _a === void 0 ? void 0 : _a.addInteraction(_this.drawInteraction);
1433
+ _this.drawInteraction.on('drawend', function (evt) {
1434
+ cancelSub.unsubscribe();
1435
+ _this.onEnd(evt, ev, l);
1193
1436
  });
1194
- _this.postboy.fire(drawQuery);
1195
1437
  });
1196
1438
  });
1197
- this.observeMapRender();
1198
1439
  };
1199
1440
  DrawingService.prototype.onEnd = function (evt, command, layer) {
1200
1441
  command.finish(command.format === exports.FeatureOutputFormat.GeoJson
@@ -1240,33 +1481,108 @@
1240
1481
  type: i0.Injectable
1241
1482
  }], ctorParameters: function () { return [{ type: MapPostboyService }]; } });
1242
1483
 
1243
- var DrawingGenerationService = /** @class */ (function () {
1244
- function DrawingGenerationService(postboy) {
1484
+ var FeatureModificationService = /** @class */ (function () {
1485
+ function FeatureModificationService(postboy) {
1245
1486
  this.postboy = postboy;
1246
1487
  }
1247
- DrawingGenerationService.prototype.up = function () {
1248
- this.postboy.subscribe(GenerateDrawQuery.ID).subscribe(function (ev) {
1249
- ev.finish(new interaction.Draw({
1250
- source: ev.layer.getSource(),
1251
- type: exports.DrawingType[ev.type],
1252
- style: ev.style,
1253
- geometryFunction: ev.type !== exports.DrawingType.Circle ? undefined : Draw.createRegularPolygon(32),
1254
- }));
1488
+ FeatureModificationService.prototype.up = function () {
1489
+ this.observeModification();
1490
+ this.observeMapRender();
1491
+ };
1492
+ FeatureModificationService.prototype.observeModification = function () {
1493
+ var _this = this;
1494
+ this.postboy.subscribe(ModifyFeatureCommand.ID).subscribe(function (ev) {
1495
+ _this.defineLayer(function (l) {
1496
+ if (!l || !_this.map) {
1497
+ _this.clearInteraction(l);
1498
+ return;
1499
+ }
1500
+ _this.observeCancelation(ev, l);
1501
+ _this.initFeature(l, ev.model.feature);
1502
+ _this.addModify(ev);
1503
+ _this.addDragging(ev);
1504
+ });
1255
1505
  });
1256
1506
  };
1257
- return DrawingGenerationService;
1507
+ FeatureModificationService.prototype.initFeature = function (layer, feature) {
1508
+ var _a, _b;
1509
+ (_a = layer.getSource()) === null || _a === void 0 ? void 0 : _a.clear();
1510
+ (_b = layer.getSource()) === null || _b === void 0 ? void 0 : _b.addFeature(feature);
1511
+ };
1512
+ FeatureModificationService.prototype.addModify = function (command) {
1513
+ var _this = this;
1514
+ var _a;
1515
+ this.modify = new interaction.Modify({
1516
+ features: new ol.Collection([command.model.feature]),
1517
+ style: command.style,
1518
+ });
1519
+ this.modify.on('modifyend', function () {
1520
+ _this.onModified(command);
1521
+ command.model.feature.changed();
1522
+ });
1523
+ (_a = this.map) === null || _a === void 0 ? void 0 : _a.addInteraction(this.modify);
1524
+ };
1525
+ FeatureModificationService.prototype.addDragging = function (command) {
1526
+ var _this = this;
1527
+ var _a;
1528
+ this.translate = new interaction.Translate({
1529
+ features: new ol.Collection([command.model.feature]),
1530
+ condition: function (ev) {
1531
+ var _a;
1532
+ var clone = command.model.feature.clone();
1533
+ (_a = clone.getGeometry()) === null || _a === void 0 ? void 0 : _a.scale(0.999);
1534
+ return clone.getGeometry().intersectsCoordinate(ev.coordinate);
1535
+ },
1536
+ });
1537
+ this.translate.on('translateend', function () { return _this.onModified(command); });
1538
+ (_a = this.map) === null || _a === void 0 ? void 0 : _a.addInteraction(this.translate);
1539
+ };
1540
+ FeatureModificationService.prototype.onModified = function (command) {
1541
+ command.next(command.format === exports.FeatureOutputFormat.GeoJson
1542
+ ? new format.GeoJSON().writeFeature(command.model.feature)
1543
+ : new format.WKT().writeFeature(command.model.feature));
1544
+ };
1545
+ FeatureModificationService.prototype.observeMapRender = function () {
1546
+ var _this = this;
1547
+ this.postboy.subscribe(MapRenderedEvent.ID).subscribe(function (m) {
1548
+ _this.map = m.map;
1549
+ });
1550
+ };
1551
+ FeatureModificationService.prototype.defineLayer = function (action) {
1552
+ var query = new GetLayerQuery(MapConstants.DrawingLayerId);
1553
+ query.result.subscribe(function (l) { return action(l); });
1554
+ this.postboy.fire(query);
1555
+ };
1556
+ FeatureModificationService.prototype.observeCancelation = function (ev, layer) {
1557
+ var _this = this;
1558
+ return this.postboy
1559
+ .subscribe(CancelFeatureModificationCommand.ID)
1560
+ .pipe(operators.first())
1561
+ .subscribe(function () {
1562
+ ev.finish(null);
1563
+ _this.clearInteraction(layer);
1564
+ });
1565
+ };
1566
+ FeatureModificationService.prototype.clearInteraction = function (layer) {
1567
+ var _a, _b;
1568
+ if (this.modify)
1569
+ (_a = this.map) === null || _a === void 0 ? void 0 : _a.removeInteraction(this.modify);
1570
+ if (this.translate)
1571
+ (_b = this.map) === null || _b === void 0 ? void 0 : _b.removeInteraction(this.translate);
1572
+ };
1573
+ return FeatureModificationService;
1258
1574
  }());
1259
- 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 });
1260
- DrawingGenerationService.ɵprov = i0__namespace.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "12.2.17", ngImport: i0__namespace, type: DrawingGenerationService });
1261
- i0__namespace.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "12.2.17", ngImport: i0__namespace, type: DrawingGenerationService, decorators: [{
1575
+ FeatureModificationService.ɵfac = i0__namespace.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "12.2.17", ngImport: i0__namespace, type: FeatureModificationService, deps: [{ token: MapPostboyService }], target: i0__namespace.ɵɵFactoryTarget.Injectable });
1576
+ FeatureModificationService.ɵprov = i0__namespace.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "12.2.17", ngImport: i0__namespace, type: FeatureModificationService });
1577
+ i0__namespace.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "12.2.17", ngImport: i0__namespace, type: FeatureModificationService, decorators: [{
1262
1578
  type: i0.Injectable
1263
1579
  }], ctorParameters: function () { return [{ type: MapPostboyService }]; } });
1264
1580
 
1265
1581
  var MessageRegistratorService = /** @class */ (function (_super) {
1266
1582
  __extends(MessageRegistratorService, _super);
1267
- function MessageRegistratorService(service, management, state, feature, interaction, drawing, drawGenerator) {
1583
+ function MessageRegistratorService(service, management, state, mapFeature, interaction, drawing, featureModification) {
1268
1584
  var _this = _super.call(this, service) || this;
1269
- _this.registerServices([management, state, interaction, feature, drawing, drawGenerator]);
1585
+ _this.registerServices([management, state, interaction, mapFeature, drawing, featureModification]);
1270
1586
  return _this;
1271
1587
  }
1272
1588
  MessageRegistratorService.prototype._up = function () {
@@ -1284,15 +1600,23 @@
1284
1600
  this.registerSubject(StartDrawingCommand.ID);
1285
1601
  this.registerSubject(GetLayerQuery.ID);
1286
1602
  this.registerSubject(DrawingFinishedEvent.ID);
1287
- this.registerSubject(GenerateDrawQuery.ID);
1603
+ this.registerSubject(GetFeaturesInAreaQuery.ID);
1604
+ this.registerSubject(DrawSelectionAreaCommand.ID);
1605
+ this.registerSubject(CancelFeatureModificationCommand.ID);
1606
+ this.registerSubject(ModifyFeatureCommand.ID);
1607
+ this.setExecutors();
1608
+ };
1609
+ MessageRegistratorService.prototype.setExecutors = function () {
1610
+ this.registerExecutor(FilterFeaturesInAreaExecutor.ID, function (e) { return FeatureService.filterFeaturesInArea(e); });
1611
+ this.registerExecutor(GenerateDrawExecutor.ID, function (e) { return DrawingGenerationService.getDraw(e); });
1288
1612
  };
1289
1613
  return MessageRegistratorService;
1290
1614
  }(postboy.PostboyAbstractRegistrator));
1291
- 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 }], target: i0__namespace.ɵɵFactoryTarget.Injectable });
1615
+ 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: FeatureModificationService }], target: i0__namespace.ɵɵFactoryTarget.Injectable });
1292
1616
  MessageRegistratorService.ɵprov = i0__namespace.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "12.2.17", ngImport: i0__namespace, type: MessageRegistratorService });
1293
1617
  i0__namespace.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "12.2.17", ngImport: i0__namespace, type: MessageRegistratorService, decorators: [{
1294
1618
  type: i0.Injectable
1295
- }], ctorParameters: function () { return [{ type: MapPostboyService }, { type: MapManagementService }, { type: MapStateService }, { type: MapFeatureService }, { type: MapClickService }, { type: DrawingService }, { type: DrawingGenerationService }]; } });
1619
+ }], ctorParameters: function () { return [{ type: MapPostboyService }, { type: MapManagementService }, { type: MapStateService }, { type: MapFeatureService }, { type: MapClickService }, { type: DrawingService }, { type: FeatureModificationService }]; } });
1296
1620
 
1297
1621
  var TileLayerSettings = /** @class */ (function () {
1298
1622
  function TileLayerSettings() {
@@ -1933,6 +2257,8 @@
1933
2257
  MapFeatureService,
1934
2258
  DrawingService,
1935
2259
  DrawingGenerationService,
2260
+ FeatureService,
2261
+ FeatureModificationService,
1936
2262
  ], 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 });
1937
2263
  i0__namespace.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "12.2.17", ngImport: i0__namespace, type: MapPlateComponent, decorators: [{
1938
2264
  type: i0.Component,
@@ -1949,6 +2275,8 @@
1949
2275
  MapFeatureService,
1950
2276
  DrawingService,
1951
2277
  DrawingGenerationService,
2278
+ FeatureService,
2279
+ FeatureModificationService,
1952
2280
  ],
1953
2281
  }]
1954
2282
  }], ctorParameters: function () { return [{ type: i0__namespace.ElementRef }, { type: MapPostboyService }, { type: MapPlateFactory }, { type: MessageRegistratorService }, { type: i0__namespace.ChangeDetectorRef }]; }, propDecorators: { settings: [{
@@ -2262,6 +2590,25 @@
2262
2590
  }),
2263
2591
  });
2264
2592
  };
2593
+ PolygonStyleHelper.edit = function (fill, stroke, strokeWidth, pinRadius) {
2594
+ if (strokeWidth === void 0) { strokeWidth = 1; }
2595
+ if (pinRadius === void 0) { pinRadius = 5; }
2596
+ return new Style__default["default"]({
2597
+ image: new style.Circle({
2598
+ fill: new style.Fill({
2599
+ color: stroke,
2600
+ }),
2601
+ radius: pinRadius,
2602
+ }),
2603
+ fill: new style.Fill({
2604
+ color: fill,
2605
+ }),
2606
+ stroke: new style.Stroke({
2607
+ color: stroke,
2608
+ width: strokeWidth,
2609
+ }),
2610
+ });
2611
+ };
2265
2612
  return PolygonStyleHelper;
2266
2613
  }());
2267
2614
 
@@ -2347,9 +2694,12 @@
2347
2694
  */
2348
2695
 
2349
2696
  exports.CancelDrawingCommand = CancelDrawingCommand;
2697
+ exports.CancelFeatureModificationCommand = CancelFeatureModificationCommand;
2350
2698
  exports.CloseTooltipCommand = CloseTooltipCommand;
2351
2699
  exports.ClusterLayerComponent = ClusterLayerComponent;
2352
2700
  exports.ClusterLayerSettings = ClusterLayerSettings;
2701
+ exports.Dictionary = Dictionary;
2702
+ exports.DrawSelectionAreaCommand = DrawSelectionAreaCommand;
2353
2703
  exports.FeatureLayerComponent = FeatureLayerComponent;
2354
2704
  exports.FeatureLayerSettings = FeatureLayerSettings;
2355
2705
  exports.MapClickEvent = MapClickEvent;
@@ -2364,6 +2714,7 @@
2364
2714
  exports.MarkerStyleHelper = MarkerStyleHelper;
2365
2715
  exports.MarkersComponent = MarkersComponent;
2366
2716
  exports.MessageRegistratorService = MessageRegistratorService;
2717
+ exports.ModifyFeatureCommand = ModifyFeatureCommand;
2367
2718
  exports.OsmTileLayerComponent = OsmTileLayerComponent;
2368
2719
  exports.PolygonModel = PolygonModel;
2369
2720
  exports.PolygonStyleHelper = PolygonStyleHelper;