@artstesh/maps 4.1.7 → 4.1.8

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 (44) hide show
  1. package/dist/esm2020/map/messages/commands/draw-selection-area.command.mjs +1 -1
  2. package/dist/esm2020/map/messages/commands/fit-to-polygons.command.mjs +13 -0
  3. package/dist/esm2020/map/messages/index.mjs +2 -1
  4. package/dist/esm2020/map/messages/queries/get-features-in-area.query.mjs +1 -1
  5. package/dist/esm2020/map/models/index.mjs +1 -2
  6. package/dist/esm2020/map/services/drawing/drawing.service.mjs +3 -2
  7. package/dist/esm2020/map/services/map-feature.service.mjs +17 -4
  8. package/dist/esm2020/map/services/map-management.service.mjs +2 -2
  9. package/dist/esm2020/map/services/message-registrator.service.mjs +3 -2
  10. package/dist/esm2020/src/map/messages/commands/draw-selection-area.command.mjs +1 -1
  11. package/dist/esm2020/src/map/messages/commands/fit-to-polygons.command.mjs +13 -0
  12. package/dist/esm2020/src/map/messages/index.mjs +2 -1
  13. package/dist/esm2020/src/map/messages/queries/get-features-in-area.query.mjs +1 -1
  14. package/dist/esm2020/src/map/models/index.mjs +1 -2
  15. package/dist/esm2020/src/map/services/drawing/drawing.service.mjs +3 -2
  16. package/dist/esm2020/src/map/services/map-feature.service.mjs +17 -4
  17. package/dist/esm2020/src/map/services/map-management.service.mjs +2 -2
  18. package/dist/esm2020/src/map/services/message-registrator.service.mjs +3 -2
  19. package/dist/fesm2015/maps-components-src-map.mjs +30 -59
  20. package/dist/fesm2015/maps-components-src-map.mjs.map +1 -1
  21. package/dist/fesm2015/maps-components.mjs +30 -59
  22. package/dist/fesm2015/maps-components.mjs.map +1 -1
  23. package/dist/fesm2020/maps-components-src-map.mjs +30 -59
  24. package/dist/fesm2020/maps-components-src-map.mjs.map +1 -1
  25. package/dist/fesm2020/maps-components.mjs +30 -59
  26. package/dist/fesm2020/maps-components.mjs.map +1 -1
  27. package/dist/map/messages/commands/draw-selection-area.command.d.ts +2 -1
  28. package/dist/map/messages/commands/fit-to-polygons.command.d.ts +9 -0
  29. package/dist/map/messages/index.d.ts +1 -0
  30. package/dist/map/messages/queries/get-features-in-area.query.d.ts +1 -1
  31. package/dist/map/models/index.d.ts +0 -1
  32. package/dist/map/services/map-feature.service.d.ts +2 -0
  33. package/dist/package.json +1 -0
  34. package/dist/src/map/messages/commands/draw-selection-area.command.d.ts +2 -1
  35. package/dist/src/map/messages/commands/fit-to-polygons.command.d.ts +9 -0
  36. package/dist/src/map/messages/index.d.ts +1 -0
  37. package/dist/src/map/messages/queries/get-features-in-area.query.d.ts +1 -1
  38. package/dist/src/map/models/index.d.ts +0 -1
  39. package/dist/src/map/services/map-feature.service.d.ts +2 -0
  40. package/package.json +3 -2
  41. package/dist/esm2020/map/models/dictionary.mjs +0 -56
  42. package/dist/esm2020/src/map/models/dictionary.mjs +0 -56
  43. package/dist/map/models/dictionary.d.ts +0 -17
  44. 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';
@@ -194,62 +195,6 @@ var FeatureOutputFormat;
194
195
  FeatureOutputFormat[FeatureOutputFormat["WKT"] = 2] = "WKT";
195
196
  })(FeatureOutputFormat || (FeatureOutputFormat = {}));
196
197
 
197
- class Dictionary {
198
- constructor() {
199
- this.collection = {};
200
- this._keys = new Set();
201
- this.has = (key) => this._keys.has(key);
202
- }
203
- get keys() {
204
- return Array.from(this._keys);
205
- }
206
- get size() {
207
- return this._keys.size;
208
- }
209
- static clone(dic, action) {
210
- return Dictionary.create(dic.collection, action);
211
- }
212
- static create(dic, action) {
213
- let keyList = Object.keys(dic);
214
- const result = new Dictionary();
215
- for (let i = 0; i < keyList.length; i++) {
216
- let key = keyList[i];
217
- result._keys.add(key);
218
- result.collection[key] = action ? action(dic[key], key) : dic[key];
219
- }
220
- return result;
221
- }
222
- find(predicate) {
223
- let result = null;
224
- this.forEach((e) => {
225
- if (result === null && predicate(e))
226
- result = e;
227
- });
228
- return result;
229
- }
230
- take(key) {
231
- return this._keys.has(key) ? this.collection[key] : null;
232
- }
233
- put(key, value) {
234
- if (value == null)
235
- return;
236
- this.collection[key] = value;
237
- this._keys.add(key);
238
- }
239
- rmv(key) {
240
- if (!this._keys.has(key))
241
- return;
242
- delete this.collection[key];
243
- this._keys.delete(key);
244
- }
245
- forEach(callback) {
246
- let keys = Object.keys(this.collection);
247
- for (let i = 0; i < keys.length; i++) {
248
- callback(this.collection[keys[i]], i);
249
- }
250
- }
251
- }
252
-
253
198
  /**
254
199
  *
255
200
  * 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.
@@ -419,6 +364,18 @@ class CalculateAreaExecutor extends PostboyExecutor {
419
364
  }
420
365
  CalculateAreaExecutor.ID = '172ecf46-86b5-4f46-a5f1-96ba2cbb1694';
421
366
 
367
+ class FitToPolygonsCommand extends PostboyGenericMessage {
368
+ constructor(features, zoomAfter = 0) {
369
+ super();
370
+ this.features = features;
371
+ this.zoomAfter = zoomAfter;
372
+ }
373
+ get id() {
374
+ return FitToPolygonsCommand.ID;
375
+ }
376
+ }
377
+ FitToPolygonsCommand.ID = 'a9e42b23-ffaf-4c46-8370-e0432cd14d60';
378
+
422
379
  class AddLayerCommand extends PostboyGenericMessage {
423
380
  constructor(layer) {
424
381
  super();
@@ -757,15 +714,28 @@ class MapFeatureService {
757
714
  up() {
758
715
  this.observeMapRender();
759
716
  this.observeFitToFeatures();
717
+ this.observeFitToPolygons();
760
718
  }
761
719
  observeMapRender() {
762
720
  this.postboy.subscribe(MapRenderedEvent.ID).subscribe((m) => {
763
721
  this.map = m.map;
722
+ if (this.fitPolygonsWaiting)
723
+ this.postboy.fire(this.fitPolygonsWaiting);
764
724
  });
765
725
  }
766
726
  observeFitToFeatures() {
767
- this.postboy.subscribe(FitToFeaturesCommand.ID).subscribe((m) => {
768
- this.fitToGeometries(m.features.map((f) => f.getGeometry()), m.zoomAfter);
727
+ this.postboy.subscribe(FitToFeaturesCommand.ID).subscribe((cmd) => {
728
+ this.fitToGeometries(cmd.features.map((f) => f.getGeometry()), cmd.zoomAfter);
729
+ });
730
+ }
731
+ observeFitToPolygons() {
732
+ this.postboy.subscribe(FitToPolygonsCommand.ID).subscribe((cmd) => {
733
+ if (!this.map) {
734
+ this.fitPolygonsWaiting = cmd;
735
+ return;
736
+ }
737
+ this.fitPolygonsWaiting = undefined;
738
+ this.fitToGeometries(cmd.features.map((f) => f.feature.getGeometry()), cmd.zoomAfter);
769
739
  });
770
740
  }
771
741
  fitToGeometries(geometries, zoomAfter) {
@@ -1056,6 +1026,7 @@ class MessageRegistratorService extends PostboyAbstractRegistrator {
1056
1026
  this.registerSubject(MapClickEvent.ID);
1057
1027
  this.registerSubject(CloseTooltipCommand.ID);
1058
1028
  this.registerSubject(FitToFeaturesCommand.ID);
1029
+ this.registerSubject(FitToPolygonsCommand.ID);
1059
1030
  this.registerSubject(MapMoveEndEvent.ID);
1060
1031
  this.registerSubject(CancelDrawingCommand.ID);
1061
1032
  this.registerSubject(StartDrawingCommand.ID);
@@ -2140,5 +2111,5 @@ class StringifyFeatureHelper {
2140
2111
  * Generated bundle index. Do not edit.
2141
2112
  */
2142
2113
 
2143
- 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 };
2114
+ 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 };
2144
2115
  //# sourceMappingURL=maps-components.mjs.map