@artstesh/maps 1.0.10 → 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 (64) hide show
  1. package/dist/bundles/maps-components-src-map.umd.js +242 -96
  2. package/dist/bundles/maps-components-src-map.umd.js.map +1 -1
  3. package/dist/bundles/maps-components.umd.js +242 -96
  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 +4 -1
  7. package/dist/esm2015/map/messages/commands/cancel-feature-modification.command.js +8 -0
  8. package/dist/esm2015/map/messages/commands/modify-feature.command.js +15 -0
  9. package/dist/esm2015/map/messages/executors/filter-features-in-area.executor.js +13 -0
  10. package/dist/esm2015/map/messages/executors/generate-draw.executor.js +14 -0
  11. package/dist/esm2015/map/messages/index.js +3 -1
  12. package/dist/esm2015/map/models/drawing-type.enum.js +2 -1
  13. package/dist/esm2015/map/services/drawing/drawing-generation.service.js +16 -21
  14. package/dist/esm2015/map/services/drawing/drawing.service.js +9 -13
  15. package/dist/esm2015/map/services/drawing/feature-modification.service.js +104 -0
  16. package/dist/esm2015/map/services/feature.service.js +4 -17
  17. package/dist/esm2015/map/services/map-management.service.js +5 -13
  18. package/dist/esm2015/map/services/message-registrator.service.js +19 -11
  19. package/dist/esm2015/src/map/helpers/polygon-style.helper.js +19 -2
  20. package/dist/esm2015/src/map/map-plate/map-plate.component.js +4 -1
  21. package/dist/esm2015/src/map/messages/commands/cancel-feature-modification.command.js +8 -0
  22. package/dist/esm2015/src/map/messages/commands/modify-feature.command.js +15 -0
  23. package/dist/esm2015/src/map/messages/executors/filter-features-in-area.executor.js +13 -0
  24. package/dist/esm2015/src/map/messages/executors/generate-draw.executor.js +14 -0
  25. package/dist/esm2015/src/map/messages/index.js +3 -1
  26. package/dist/esm2015/src/map/models/drawing-type.enum.js +2 -1
  27. package/dist/esm2015/src/map/services/drawing/drawing-generation.service.js +16 -21
  28. package/dist/esm2015/src/map/services/drawing/drawing.service.js +9 -13
  29. package/dist/esm2015/src/map/services/drawing/feature-modification.service.js +104 -0
  30. package/dist/esm2015/src/map/services/feature.service.js +4 -17
  31. package/dist/esm2015/src/map/services/map-management.service.js +5 -13
  32. package/dist/esm2015/src/map/services/message-registrator.service.js +19 -11
  33. package/dist/fesm2015/maps-components-src-map.js +197 -81
  34. package/dist/fesm2015/maps-components-src-map.js.map +1 -1
  35. package/dist/fesm2015/maps-components.js +197 -81
  36. package/dist/fesm2015/maps-components.js.map +1 -1
  37. package/dist/map/helpers/polygon-style.helper.d.ts +1 -0
  38. package/dist/map/messages/commands/cancel-feature-modification.command.d.ts +5 -0
  39. package/dist/map/messages/commands/modify-feature.command.d.ts +11 -0
  40. package/dist/map/messages/{queries/filter-features-in-area.query.d.ts → executors/filter-features-in-area.executor.d.ts} +2 -2
  41. package/dist/map/messages/{queries/generate-draw.query.d.ts → executors/generate-draw.executor.d.ts} +2 -2
  42. package/dist/map/messages/index.d.ts +2 -0
  43. package/dist/map/models/drawing-type.enum.d.ts +2 -1
  44. package/dist/map/services/drawing/drawing-generation.service.d.ts +5 -9
  45. package/dist/map/services/drawing/feature-modification.service.d.ts +22 -0
  46. package/dist/map/services/feature.service.d.ts +6 -9
  47. package/dist/map/services/message-registrator.service.d.ts +3 -3
  48. package/dist/package.json +1 -1
  49. package/dist/src/map/helpers/polygon-style.helper.d.ts +1 -0
  50. package/dist/src/map/messages/commands/cancel-feature-modification.command.d.ts +5 -0
  51. package/dist/src/map/messages/commands/modify-feature.command.d.ts +11 -0
  52. package/dist/src/map/messages/{queries/filter-features-in-area.query.d.ts → executors/filter-features-in-area.executor.d.ts} +2 -2
  53. package/dist/src/map/messages/{queries/generate-draw.query.d.ts → executors/generate-draw.executor.d.ts} +2 -2
  54. package/dist/src/map/messages/index.d.ts +2 -0
  55. package/dist/src/map/models/drawing-type.enum.d.ts +2 -1
  56. package/dist/src/map/services/drawing/drawing-generation.service.d.ts +5 -9
  57. package/dist/src/map/services/drawing/feature-modification.service.d.ts +22 -0
  58. package/dist/src/map/services/feature.service.d.ts +6 -9
  59. package/dist/src/map/services/message-registrator.service.d.ts +3 -3
  60. package/package.json +2 -2
  61. package/dist/esm2015/map/messages/queries/filter-features-in-area.query.js +0 -13
  62. package/dist/esm2015/map/messages/queries/generate-draw.query.js +0 -14
  63. package/dist/esm2015/src/map/messages/queries/filter-features-in-area.query.js +0 -13
  64. 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'), 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/src/map', ['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["maps-components"] || {}, global["maps-components"].src = global["maps-components"].src || {}, global["maps-components"].src.map = {}), 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';
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/src/map', ['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["maps-components"] || {}, global["maps-components"].src = global["maps-components"].src || {}, global["maps-components"].src.map = {}), 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;
@@ -883,6 +884,43 @@
883
884
  }(postboy.PostboyCallbackMessage));
884
885
  DrawSelectionAreaCommand.ID = '573d8a0d-f25b-42b7-9ad7-0ac6d86ac362';
885
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
+
886
924
  var AddLayerCommand = /** @class */ (function (_super) {
887
925
  __extends(AddLayerCommand, _super);
888
926
  function AddLayerCommand(layer) {
@@ -1028,64 +1066,105 @@
1028
1066
  }(postboy.PostboyGenericMessage));
1029
1067
  DrawingFinishedEvent.ID = 'c724b68e-b4eb-4783-90f1-a8e31973fd36';
1030
1068
 
1031
- var GenerateDrawQuery = /** @class */ (function (_super) {
1032
- __extends(GenerateDrawQuery, _super);
1033
- 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(); }
1034
1114
  var _this = _super.call(this) || this;
1035
- _this.layer = layer;
1036
- _this.style = style;
1037
- _this.type = type;
1115
+ _this.area = area;
1116
+ _this.ignore = ignore;
1038
1117
  return _this;
1039
1118
  }
1040
- Object.defineProperty(GenerateDrawQuery.prototype, "id", {
1119
+ Object.defineProperty(GetFeaturesInAreaQuery.prototype, "id", {
1041
1120
  get: function () {
1042
- return GenerateDrawQuery.ID;
1121
+ return GetFeaturesInAreaQuery.ID;
1043
1122
  },
1044
1123
  enumerable: false,
1045
1124
  configurable: true
1046
1125
  });
1047
- return GenerateDrawQuery;
1126
+ return GetFeaturesInAreaQuery;
1048
1127
  }(postboy.PostboyCallbackMessage));
1049
- GenerateDrawQuery.ID = 'f01c99ba-0953-4ab5-82f9-04e6fbb678c1';
1128
+ GetFeaturesInAreaQuery.ID = 'efcf4271-a07a-40e0-9f02-d4dade40b8ac';
1050
1129
 
1051
- var FilterFeaturesInAreaQuery = /** @class */ (function (_super) {
1052
- __extends(FilterFeaturesInAreaQuery, _super);
1053
- function FilterFeaturesInAreaQuery(area, features) {
1130
+ var FilterFeaturesInAreaExecutor = /** @class */ (function (_super) {
1131
+ __extends(FilterFeaturesInAreaExecutor, _super);
1132
+ function FilterFeaturesInAreaExecutor(area, features) {
1054
1133
  var _this = _super.call(this) || this;
1055
1134
  _this.area = area;
1056
1135
  _this.features = features;
1057
1136
  return _this;
1058
1137
  }
1059
- Object.defineProperty(FilterFeaturesInAreaQuery.prototype, "id", {
1138
+ Object.defineProperty(FilterFeaturesInAreaExecutor.prototype, "id", {
1060
1139
  get: function () {
1061
- return FilterFeaturesInAreaQuery.ID;
1140
+ return FilterFeaturesInAreaExecutor.ID;
1062
1141
  },
1063
1142
  enumerable: false,
1064
1143
  configurable: true
1065
1144
  });
1066
- return FilterFeaturesInAreaQuery;
1067
- }(postboy.PostboyCallbackMessage));
1068
- FilterFeaturesInAreaQuery.ID = '36bb2d94-8028-4512-90dd-2386af3fc67c';
1145
+ return FilterFeaturesInAreaExecutor;
1146
+ }(postboy.PostboyExecutor));
1147
+ FilterFeaturesInAreaExecutor.ID = '36bb2d94-8028-4512-90dd-2386af3fc67c';
1069
1148
 
1070
- var GetFeaturesInAreaQuery = /** @class */ (function (_super) {
1071
- __extends(GetFeaturesInAreaQuery, _super);
1072
- function GetFeaturesInAreaQuery(area, ignore) {
1073
- if (ignore === void 0) { ignore = new Set(); }
1149
+ var GenerateDrawExecutor = /** @class */ (function (_super) {
1150
+ __extends(GenerateDrawExecutor, _super);
1151
+ function GenerateDrawExecutor(layer, style, type) {
1074
1152
  var _this = _super.call(this) || this;
1075
- _this.area = area;
1076
- _this.ignore = ignore;
1153
+ _this.layer = layer;
1154
+ _this.style = style;
1155
+ _this.type = type;
1077
1156
  return _this;
1078
1157
  }
1079
- Object.defineProperty(GetFeaturesInAreaQuery.prototype, "id", {
1158
+ Object.defineProperty(GenerateDrawExecutor.prototype, "id", {
1080
1159
  get: function () {
1081
- return GetFeaturesInAreaQuery.ID;
1160
+ return GenerateDrawExecutor.ID;
1082
1161
  },
1083
1162
  enumerable: false,
1084
1163
  configurable: true
1085
1164
  });
1086
- return GetFeaturesInAreaQuery;
1087
- }(postboy.PostboyCallbackMessage));
1088
- GetFeaturesInAreaQuery.ID = 'efcf4271-a07a-40e0-9f02-d4dade40b8ac';
1165
+ return GenerateDrawExecutor;
1166
+ }(postboy.PostboyExecutor));
1167
+ GenerateDrawExecutor.ID = 'f01c99ba-0953-4ab5-82f9-04e6fbb678c1';
1089
1168
 
1090
1169
  var MapPostboyService = /** @class */ (function (_super) {
1091
1170
  __extends(MapPostboyService, _super);
@@ -1178,8 +1257,6 @@
1178
1257
  var _this = this;
1179
1258
  this.postboy.subscribe(GetFeaturesInAreaQuery.ID).subscribe(function (qr) {
1180
1259
  var result = new Dictionary();
1181
- var queue = [];
1182
- var queries = [];
1183
1260
  _this.layers.forEach(function (l) {
1184
1261
  var _a, _b;
1185
1262
  var layerName = l.get('name');
@@ -1188,14 +1265,10 @@
1188
1265
  var source = l.getSource();
1189
1266
  if (!!source['getSource'])
1190
1267
  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);
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))); }));
1196
1270
  });
1197
- rxjs.forkJoin(queue).subscribe(function () { return qr.finish(result); });
1198
- queries.forEach(function (q) { return _this.postboy.fire(q); });
1271
+ qr.finish(result);
1199
1272
  });
1200
1273
  };
1201
1274
  return MapManagementService;
@@ -1349,22 +1422,18 @@
1349
1422
  var _this = this;
1350
1423
  this.postboy.subscribe(StartDrawingCommand.ID).subscribe(function (ev) {
1351
1424
  _this.draw(function (l) {
1425
+ var _a;
1352
1426
  if (!l || !_this.map) {
1353
1427
  _this.clearInteraction(l);
1354
1428
  return;
1355
1429
  }
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
- });
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);
1366
1436
  });
1367
- _this.postboy.fire(drawQuery);
1368
1437
  });
1369
1438
  });
1370
1439
  };
@@ -1412,59 +1481,108 @@
1412
1481
  type: i0.Injectable
1413
1482
  }], ctorParameters: function () { return [{ type: MapPostboyService }]; } });
1414
1483
 
1415
- var DrawingGenerationService = /** @class */ (function () {
1416
- function DrawingGenerationService(postboy) {
1484
+ var FeatureModificationService = /** @class */ (function () {
1485
+ function FeatureModificationService(postboy) {
1417
1486
  this.postboy = postboy;
1418
1487
  }
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
- }));
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
+ });
1427
1505
  });
1428
1506
  };
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()); }));
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,
1444
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);
1445
1524
  };
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;
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);
1454
1539
  };
1455
- return FeatureService;
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;
1456
1574
  }());
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: [{
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: [{
1460
1578
  type: i0.Injectable
1461
1579
  }], ctorParameters: function () { return [{ type: MapPostboyService }]; } });
1462
1580
 
1463
1581
  var MessageRegistratorService = /** @class */ (function (_super) {
1464
1582
  __extends(MessageRegistratorService, _super);
1465
- function MessageRegistratorService(service, management, state, mapFeature, interaction, drawing, drawGenerator, feature) {
1583
+ function MessageRegistratorService(service, management, state, mapFeature, interaction, drawing, featureModification) {
1466
1584
  var _this = _super.call(this, service) || this;
1467
- _this.registerServices([management, state, interaction, mapFeature, drawing, drawGenerator, feature]);
1585
+ _this.registerServices([management, state, interaction, mapFeature, drawing, featureModification]);
1468
1586
  return _this;
1469
1587
  }
1470
1588
  MessageRegistratorService.prototype._up = function () {
@@ -1482,18 +1600,23 @@
1482
1600
  this.registerSubject(StartDrawingCommand.ID);
1483
1601
  this.registerSubject(GetLayerQuery.ID);
1484
1602
  this.registerSubject(DrawingFinishedEvent.ID);
1485
- this.registerSubject(GenerateDrawQuery.ID);
1486
- this.registerSubject(FilterFeaturesInAreaQuery.ID);
1487
1603
  this.registerSubject(GetFeaturesInAreaQuery.ID);
1488
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); });
1489
1612
  };
1490
1613
  return MessageRegistratorService;
1491
1614
  }(postboy.PostboyAbstractRegistrator));
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 });
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 });
1493
1616
  MessageRegistratorService.ɵprov = i0__namespace.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "12.2.17", ngImport: i0__namespace, type: MessageRegistratorService });
1494
1617
  i0__namespace.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "12.2.17", ngImport: i0__namespace, type: MessageRegistratorService, decorators: [{
1495
1618
  type: i0.Injectable
1496
- }], ctorParameters: function () { return [{ type: MapPostboyService }, { type: MapManagementService }, { type: MapStateService }, { type: MapFeatureService }, { type: MapClickService }, { type: DrawingService }, { type: DrawingGenerationService }, { type: FeatureService }]; } });
1619
+ }], ctorParameters: function () { return [{ type: MapPostboyService }, { type: MapManagementService }, { type: MapStateService }, { type: MapFeatureService }, { type: MapClickService }, { type: DrawingService }, { type: FeatureModificationService }]; } });
1497
1620
 
1498
1621
  var TileLayerSettings = /** @class */ (function () {
1499
1622
  function TileLayerSettings() {
@@ -2135,6 +2258,7 @@
2135
2258
  DrawingService,
2136
2259
  DrawingGenerationService,
2137
2260
  FeatureService,
2261
+ FeatureModificationService,
2138
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 });
2139
2263
  i0__namespace.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "12.2.17", ngImport: i0__namespace, type: MapPlateComponent, decorators: [{
2140
2264
  type: i0.Component,
@@ -2152,6 +2276,7 @@
2152
2276
  DrawingService,
2153
2277
  DrawingGenerationService,
2154
2278
  FeatureService,
2279
+ FeatureModificationService,
2155
2280
  ],
2156
2281
  }]
2157
2282
  }], ctorParameters: function () { return [{ type: i0__namespace.ElementRef }, { type: MapPostboyService }, { type: MapPlateFactory }, { type: MessageRegistratorService }, { type: i0__namespace.ChangeDetectorRef }]; }, propDecorators: { settings: [{
@@ -2465,6 +2590,25 @@
2465
2590
  }),
2466
2591
  });
2467
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
+ };
2468
2612
  return PolygonStyleHelper;
2469
2613
  }());
2470
2614
 
@@ -2546,6 +2690,7 @@
2546
2690
  */
2547
2691
 
2548
2692
  exports.CancelDrawingCommand = CancelDrawingCommand;
2693
+ exports.CancelFeatureModificationCommand = CancelFeatureModificationCommand;
2549
2694
  exports.CloseTooltipCommand = CloseTooltipCommand;
2550
2695
  exports.ClusterLayerComponent = ClusterLayerComponent;
2551
2696
  exports.ClusterLayerSettings = ClusterLayerSettings;
@@ -2565,6 +2710,7 @@
2565
2710
  exports.MarkerStyleHelper = MarkerStyleHelper;
2566
2711
  exports.MarkersComponent = MarkersComponent;
2567
2712
  exports.MessageRegistratorService = MessageRegistratorService;
2713
+ exports.ModifyFeatureCommand = ModifyFeatureCommand;
2568
2714
  exports.OsmTileLayerComponent = OsmTileLayerComponent;
2569
2715
  exports.PolygonModel = PolygonModel;
2570
2716
  exports.PolygonStyleHelper = PolygonStyleHelper;