@artstesh/maps 5.1.6 → 5.1.7

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 (40) hide show
  1. package/dist/esm2022/map/messages/commands/draw-selection-area.command.mjs +1 -1
  2. package/dist/esm2022/map/messages/commands/fit-to-polygons.command.mjs +15 -0
  3. package/dist/esm2022/map/messages/index.mjs +2 -1
  4. package/dist/esm2022/map/messages/queries/get-features-in-area.query.mjs +1 -1
  5. package/dist/esm2022/map/models/index.mjs +1 -2
  6. package/dist/esm2022/map/services/drawing/drawing.service.mjs +3 -2
  7. package/dist/esm2022/map/services/map-feature.service.mjs +18 -4
  8. package/dist/esm2022/map/services/map-management.service.mjs +2 -2
  9. package/dist/esm2022/map/services/message-registrator.service.mjs +3 -2
  10. package/dist/esm2022/src/map/messages/commands/draw-selection-area.command.mjs +1 -1
  11. package/dist/esm2022/src/map/messages/commands/fit-to-polygons.command.mjs +15 -0
  12. package/dist/esm2022/src/map/messages/index.mjs +2 -1
  13. package/dist/esm2022/src/map/messages/queries/get-features-in-area.query.mjs +1 -1
  14. package/dist/esm2022/src/map/models/index.mjs +1 -2
  15. package/dist/esm2022/src/map/services/drawing/drawing.service.mjs +3 -2
  16. package/dist/esm2022/src/map/services/map-feature.service.mjs +18 -4
  17. package/dist/esm2022/src/map/services/map-management.service.mjs +2 -2
  18. package/dist/esm2022/src/map/services/message-registrator.service.mjs +3 -2
  19. package/dist/fesm2022/maps-components-src-map.mjs +33 -57
  20. package/dist/fesm2022/maps-components-src-map.mjs.map +1 -1
  21. package/dist/fesm2022/maps-components.mjs +33 -57
  22. package/dist/fesm2022/maps-components.mjs.map +1 -1
  23. package/dist/map/messages/commands/draw-selection-area.command.d.ts +2 -1
  24. package/dist/map/messages/commands/fit-to-polygons.command.d.ts +9 -0
  25. package/dist/map/messages/index.d.ts +1 -0
  26. package/dist/map/messages/queries/get-features-in-area.query.d.ts +1 -1
  27. package/dist/map/models/index.d.ts +0 -1
  28. package/dist/map/services/map-feature.service.d.ts +2 -0
  29. package/dist/package.json +2 -1
  30. package/dist/src/map/messages/commands/draw-selection-area.command.d.ts +2 -1
  31. package/dist/src/map/messages/commands/fit-to-polygons.command.d.ts +9 -0
  32. package/dist/src/map/messages/index.d.ts +1 -0
  33. package/dist/src/map/messages/queries/get-features-in-area.query.d.ts +1 -1
  34. package/dist/src/map/models/index.d.ts +0 -1
  35. package/dist/src/map/services/map-feature.service.d.ts +2 -0
  36. package/package.json +3 -2
  37. package/dist/esm2022/map/models/dictionary.mjs +0 -54
  38. package/dist/esm2022/src/map/models/dictionary.mjs +0 -54
  39. package/dist/map/models/dictionary.d.ts +0 -17
  40. package/dist/src/map/models/dictionary.d.ts +0 -17
@@ -12,6 +12,7 @@ import { PostboyGenericMessage, PostboyCallbackMessage, PostboyExecutor, Postboy
12
12
  import { Draw, Modify, Translate } from 'ol/interaction';
13
13
  import { createRegularPolygon, createBox } from 'ol/interaction/Draw';
14
14
  import * as Sphere from 'ol/sphere';
15
+ import { Dictionary } from '@artstesh/collections';
15
16
  import { first, filter, auditTime } from 'rxjs/operators';
16
17
  import { Vector, XYZ } from 'ol/source';
17
18
  import TileLayer from 'ol/layer/Tile';
@@ -200,60 +201,6 @@ var FeatureOutputFormat;
200
201
  FeatureOutputFormat[FeatureOutputFormat["WKT"] = 2] = "WKT";
201
202
  })(FeatureOutputFormat || (FeatureOutputFormat = {}));
202
203
 
203
- class Dictionary {
204
- collection = {};
205
- _keys = new Set();
206
- get keys() {
207
- return Array.from(this._keys);
208
- }
209
- get size() {
210
- return this._keys.size;
211
- }
212
- static clone(dic, action) {
213
- return Dictionary.create(dic.collection, action);
214
- }
215
- static create(dic, action) {
216
- let keyList = Object.keys(dic);
217
- const result = new Dictionary();
218
- for (let i = 0; i < keyList.length; i++) {
219
- let key = keyList[i];
220
- result._keys.add(key);
221
- result.collection[key] = action ? action(dic[key], key) : dic[key];
222
- }
223
- return result;
224
- }
225
- find(predicate) {
226
- let result = null;
227
- this.forEach((e) => {
228
- if (result === null && predicate(e))
229
- result = e;
230
- });
231
- return result;
232
- }
233
- has = (key) => this._keys.has(key);
234
- take(key) {
235
- return this._keys.has(key) ? this.collection[key] : null;
236
- }
237
- put(key, value) {
238
- if (value == null)
239
- return;
240
- this.collection[key] = value;
241
- this._keys.add(key);
242
- }
243
- rmv(key) {
244
- if (!this._keys.has(key))
245
- return;
246
- delete this.collection[key];
247
- this._keys.delete(key);
248
- }
249
- forEach(callback) {
250
- let keys = Object.keys(this.collection);
251
- for (let i = 0; i < keys.length; i++) {
252
- callback(this.collection[keys[i]], i);
253
- }
254
- }
255
- }
256
-
257
204
  /**
258
205
  *
259
206
  * A control is a visible widget with a DOM element in a fixed position on the screen. They can involve user input (buttons), or be informational only; the position is determined using CSS. By default these are placed in the container with CSS class name ol-overlaycontainer-stopevent, but can use any outside DOM element.
@@ -445,6 +392,20 @@ class CalculateAreaExecutor extends PostboyExecutor {
445
392
  }
446
393
  }
447
394
 
395
+ class FitToPolygonsCommand extends PostboyGenericMessage {
396
+ features;
397
+ zoomAfter;
398
+ static ID = 'a9e42b23-ffaf-4c46-8370-e0432cd14d60';
399
+ constructor(features, zoomAfter = 0) {
400
+ super();
401
+ this.features = features;
402
+ this.zoomAfter = zoomAfter;
403
+ }
404
+ get id() {
405
+ return FitToPolygonsCommand.ID;
406
+ }
407
+ }
408
+
448
409
  class AddLayerCommand extends PostboyGenericMessage {
449
410
  layer;
450
411
  static ID = 'd93e250f-92bc-43ac-9c6a-46c521a1aaa5';
@@ -795,21 +756,35 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "16.2.12", ngImpo
795
756
  class MapFeatureService {
796
757
  postboy;
797
758
  map;
759
+ fitPolygonsWaiting;
798
760
  constructor(postboy) {
799
761
  this.postboy = postboy;
800
762
  }
801
763
  up() {
802
764
  this.observeMapRender();
803
765
  this.observeFitToFeatures();
766
+ this.observeFitToPolygons();
804
767
  }
805
768
  observeMapRender() {
806
769
  this.postboy.subscribe(MapRenderedEvent.ID).subscribe((m) => {
807
770
  this.map = m.map;
771
+ if (this.fitPolygonsWaiting)
772
+ this.postboy.fire(this.fitPolygonsWaiting);
808
773
  });
809
774
  }
810
775
  observeFitToFeatures() {
811
- this.postboy.subscribe(FitToFeaturesCommand.ID).subscribe((m) => {
812
- this.fitToGeometries(m.features.map((f) => f.getGeometry()), m.zoomAfter);
776
+ this.postboy.subscribe(FitToFeaturesCommand.ID).subscribe((cmd) => {
777
+ this.fitToGeometries(cmd.features.map((f) => f.getGeometry()), cmd.zoomAfter);
778
+ });
779
+ }
780
+ observeFitToPolygons() {
781
+ this.postboy.subscribe(FitToPolygonsCommand.ID).subscribe((cmd) => {
782
+ if (!this.map) {
783
+ this.fitPolygonsWaiting = cmd;
784
+ return;
785
+ }
786
+ this.fitPolygonsWaiting = undefined;
787
+ this.fitToGeometries(cmd.features.map((f) => f.feature.getGeometry()), cmd.zoomAfter);
813
788
  });
814
789
  }
815
790
  fitToGeometries(geometries, zoomAfter) {
@@ -1102,6 +1077,7 @@ class MessageRegistratorService extends PostboyAbstractRegistrator {
1102
1077
  this.registerSubject(MapClickEvent.ID);
1103
1078
  this.registerSubject(CloseTooltipCommand.ID);
1104
1079
  this.registerSubject(FitToFeaturesCommand.ID);
1080
+ this.registerSubject(FitToPolygonsCommand.ID);
1105
1081
  this.registerSubject(MapMoveEndEvent.ID);
1106
1082
  this.registerSubject(CancelDrawingCommand.ID);
1107
1083
  this.registerSubject(StartDrawingCommand.ID);
@@ -2204,5 +2180,5 @@ class StringifyFeatureHelper {
2204
2180
  * Generated bundle index. Do not edit.
2205
2181
  */
2206
2182
 
2207
- export { AddControlCommand, CalculateAreaExecutor, CancelDrawingCommand, CancelFeatureModificationCommand, CloseTooltipCommand, ClusterLayerComponent, ClusterLayerSettings, Dictionary, DrawSelectionAreaCommand, DrawingType, FeatureLayerComponent, FeatureLayerSettings, FeatureOutputFormat, MapClickEvent, MapControl, MapControlZoomComponent, MapLyrs, MapLyrsLabel, MapModule, MapMoveEndEvent, MapPlateComponent, MapPostboyService, MapRenderedEvent, MapSettings, MarkerModel, MarkerStyleHelper, MarkersComponent, MessageRegistratorService, ModifyFeatureCommand, OsmTileLayerComponent, PolygonModel, PolygonStyleHelper, PolygonsComponent, RemoveControlCommand, SetMapCenterCommand, StartDrawingCommand, StringifyFeatureHelper, TextStyleHelper, TileLayerComponent, TileLayerSettings, TooltipComponent, TooltipSettings, ZoomControlSettings };
2183
+ export { AddControlCommand, CalculateAreaExecutor, CancelDrawingCommand, CancelFeatureModificationCommand, CloseTooltipCommand, ClusterLayerComponent, ClusterLayerSettings, DrawSelectionAreaCommand, DrawingType, FeatureLayerComponent, FeatureLayerSettings, FeatureOutputFormat, FitToPolygonsCommand, MapClickEvent, MapControl, MapControlZoomComponent, MapLyrs, MapLyrsLabel, MapModule, MapMoveEndEvent, MapPlateComponent, MapPostboyService, MapRenderedEvent, MapSettings, MarkerModel, MarkerStyleHelper, MarkersComponent, MessageRegistratorService, ModifyFeatureCommand, OsmTileLayerComponent, PolygonModel, PolygonStyleHelper, PolygonsComponent, RemoveControlCommand, SetMapCenterCommand, StartDrawingCommand, StringifyFeatureHelper, TextStyleHelper, TileLayerComponent, TileLayerSettings, TooltipComponent, TooltipSettings, ZoomControlSettings };
2208
2184
  //# sourceMappingURL=maps-components.mjs.map