@artstesh/maps 6.0.6 → 6.0.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 (27) hide show
  1. package/dist/esm2022/map/messages/executors/filter-features-in-point.executor.mjs +20 -0
  2. package/dist/esm2022/map/messages/index.mjs +3 -1
  3. package/dist/esm2022/map/messages/queries/get-features-in-point.query.mjs +21 -0
  4. package/dist/esm2022/map/services/feature.service.mjs +5 -1
  5. package/dist/esm2022/map/services/map-management.service.mjs +28 -12
  6. package/dist/esm2022/map/services/message-registrator.service.mjs +5 -2
  7. package/dist/esm2022/src/map/messages/executors/filter-features-in-point.executor.mjs +20 -0
  8. package/dist/esm2022/src/map/messages/index.mjs +3 -1
  9. package/dist/esm2022/src/map/messages/queries/get-features-in-point.query.mjs +21 -0
  10. package/dist/esm2022/src/map/services/feature.service.mjs +5 -1
  11. package/dist/esm2022/src/map/services/map-management.service.mjs +28 -12
  12. package/dist/esm2022/src/map/services/message-registrator.service.mjs +5 -2
  13. package/dist/fesm2022/maps-components-src-map.mjs +71 -11
  14. package/dist/fesm2022/maps-components-src-map.mjs.map +1 -1
  15. package/dist/fesm2022/maps-components.mjs +71 -11
  16. package/dist/fesm2022/maps-components.mjs.map +1 -1
  17. package/dist/map/messages/executors/filter-features-in-point.executor.d.ts +14 -0
  18. package/dist/map/messages/index.d.ts +2 -0
  19. package/dist/map/messages/queries/get-features-in-point.query.d.ts +15 -0
  20. package/dist/map/services/feature.service.d.ts +2 -0
  21. package/dist/map/services/map-management.service.d.ts +2 -0
  22. package/dist/src/map/messages/executors/filter-features-in-point.executor.d.ts +14 -0
  23. package/dist/src/map/messages/index.d.ts +2 -0
  24. package/dist/src/map/messages/queries/get-features-in-point.query.d.ts +15 -0
  25. package/dist/src/map/services/feature.service.d.ts +2 -0
  26. package/dist/src/map/services/map-management.service.d.ts +2 -0
  27. package/package.json +1 -1
@@ -447,6 +447,45 @@ class FilterFeaturesInAreaExecutor extends PostboyExecutor {
447
447
  }
448
448
  }
449
449
 
450
+ /**
451
+ * Represents a query to retrieve features located at a specific geographical point.
452
+ * The query is defined by latitude, longitude, and an optional set of features to ignore.
453
+ */
454
+ class GetFeaturesInPointQuery extends PostboyCallbackMessage {
455
+ lat;
456
+ lng;
457
+ ignore;
458
+ static ID = '7c051c97-bbf1-47eb-baa3-4d1eef6f281f';
459
+ constructor(lat, lng, ignore = new Set()) {
460
+ super();
461
+ this.lat = lat;
462
+ this.lng = lng;
463
+ this.ignore = ignore;
464
+ }
465
+ get id() {
466
+ return GetFeaturesInPointQuery.ID;
467
+ }
468
+ }
469
+
470
+ /**
471
+ * The FilterFeaturesInPointExecutor class is responsible for filtering features within a given point.
472
+ */
473
+ class FilterFeaturesInPointExecutor extends PostboyExecutor {
474
+ lat;
475
+ lng;
476
+ features;
477
+ static ID = '5b859282-5d5a-47ca-a6ad-863a66c8b82b';
478
+ get id() {
479
+ return FilterFeaturesInPointExecutor.ID;
480
+ }
481
+ constructor(lat, lng, features) {
482
+ super();
483
+ this.lat = lat;
484
+ this.lng = lng;
485
+ this.features = features;
486
+ }
487
+ }
488
+
450
489
  class AddLayerCommand extends PostboyGenericMessage {
451
490
  layer;
452
491
  static ID = 'd93e250f-92bc-43ac-9c6a-46c521a1aaa5';
@@ -572,6 +611,9 @@ class FeatureService {
572
611
  static filterFeaturesInArea(query) {
573
612
  return query.features.filter((f) => FeatureService.booleanIntersects(query.area, f.getGeometry()));
574
613
  }
614
+ static filterFeaturesInPoint(query) {
615
+ return query.features.filter((f) => FeatureService.booleanIntersects(f.getGeometry(), new Point([query.lng, query.lat])));
616
+ }
575
617
  static calculateArea(g) {
576
618
  if (!g)
577
619
  return 0;
@@ -656,6 +698,7 @@ class MapManagementService {
656
698
  this.observeRemoveTile();
657
699
  this.observeLayerQuery();
658
700
  this.observeFeaturesInArea();
701
+ this.observeFeaturesInPoint();
659
702
  }
660
703
  observeRemoveTile() {
661
704
  this.postboy.subscribe(RemoveTileCommand.ID).subscribe((c) => {
@@ -709,19 +752,34 @@ class MapManagementService {
709
752
  observeFeaturesInArea() {
710
753
  this.postboy.subscribe(GetFeaturesInAreaQuery.ID).subscribe((qr) => {
711
754
  let result = new Dictionary();
712
- this.layers.forEach((l) => {
713
- let layerName = l.get('name');
714
- if (qr.ignore.has(layerName) || layerName === MapConstants.DrawingLayerId)
715
- return;
716
- let source = l.getSource();
717
- if (!!source['getSource'])
718
- source = source?.getSource();
719
- let features = this.postboy.execute(new FilterFeaturesInAreaExecutor(qr.area, source?.getFeatures() ?? []));
720
- result.put(layerName, features.map((e) => ({ id: e.getId(), ...e.get(MapConstants.FeatureInfo) })));
721
- });
755
+ this.forEachLayer((l, s) => {
756
+ let features = this.postboy.execute(new FilterFeaturesInAreaExecutor(qr.area, s?.getFeatures() ?? []));
757
+ result.put(l.get('name'), features.map((e) => ({ id: e.getId(), ...e.get(MapConstants.FeatureInfo) })));
758
+ }, qr.ignore);
759
+ qr.finish(result);
760
+ });
761
+ }
762
+ observeFeaturesInPoint() {
763
+ this.postboy.subscribe(GetFeaturesInPointQuery.ID).subscribe((qr) => {
764
+ let result = new Dictionary();
765
+ this.forEachLayer((l, s) => {
766
+ let features = this.postboy.execute(new FilterFeaturesInPointExecutor(qr.lat, qr.lng, s?.getFeatures() ?? []));
767
+ result.put(l.get('name'), features.map((e) => ({ id: e.getId(), ...e.get(MapConstants.FeatureInfo) })));
768
+ }, qr.ignore);
722
769
  qr.finish(result);
723
770
  });
724
771
  }
772
+ forEachLayer(action, ignore) {
773
+ this.layers.forEach((l) => {
774
+ let layerName = l.get('name');
775
+ if (ignore.has(layerName) || layerName === MapConstants.DrawingLayerId)
776
+ return;
777
+ let source = l.getSource();
778
+ if (!!source['getSource'])
779
+ source = source?.getSource();
780
+ action(l, source);
781
+ });
782
+ }
725
783
  static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "17.3.7", ngImport: i0, type: MapManagementService, deps: [{ token: MapPostboyService }], target: i0.ɵɵFactoryTarget.Injectable });
726
784
  static ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "17.3.7", ngImport: i0, type: MapManagementService });
727
785
  }
@@ -1108,10 +1166,12 @@ class MessageRegistratorService extends PostboyAbstractRegistrator {
1108
1166
  this.registerSubject(DrawSelectionAreaCommand.ID);
1109
1167
  this.registerSubject(CancelFeatureModificationCommand.ID);
1110
1168
  this.registerSubject(ModifyFeatureCommand.ID);
1169
+ this.registerSubject(GetFeaturesInPointQuery.ID);
1111
1170
  this.setExecutors();
1112
1171
  }
1113
1172
  setExecutors() {
1114
1173
  this.registerExecutor(FilterFeaturesInAreaExecutor.ID, (e) => FeatureService.filterFeaturesInArea(e));
1174
+ this.registerExecutor(FilterFeaturesInPointExecutor.ID, (e) => FeatureService.filterFeaturesInPoint(e));
1115
1175
  this.registerExecutor(CalculateAreaExecutor.ID, (e) => FeatureService.calculateArea(e.polygon?.feature?.getGeometry()));
1116
1176
  this.registerExecutor(GenerateDrawExecutor.ID, (e) => DrawingGenerationService.getDraw(e));
1117
1177
  this.registerExecutor(GenerateZoomControlExecutor.ID, (e) => ZoomControlFactory.build(e.settings));
@@ -2590,5 +2650,5 @@ class StringifyFeatureHelper {
2590
2650
  * Generated bundle index. Do not edit.
2591
2651
  */
2592
2652
 
2593
- export { AddControlCommand, CalculateAreaExecutor, CancelDrawingCommand, CancelFeatureModificationCommand, CloseTooltipCommand, ClusterLayerComponent, ClusterLayerSettings, DrawSelectionAreaCommand, DrawingType, FeatureLayerComponent, FeatureLayerSettings, FeatureOutputFormat, FilterFeaturesInAreaExecutor, FitToPolygonsCommand, GetFeaturesInAreaQuery, GetMapPositionExecutor, 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 };
2653
+ export { AddControlCommand, CalculateAreaExecutor, CancelDrawingCommand, CancelFeatureModificationCommand, CloseTooltipCommand, ClusterLayerComponent, ClusterLayerSettings, DrawSelectionAreaCommand, DrawingType, FeatureLayerComponent, FeatureLayerSettings, FeatureOutputFormat, FilterFeaturesInAreaExecutor, FilterFeaturesInPointExecutor, FitToPolygonsCommand, GetFeaturesInAreaQuery, GetFeaturesInPointQuery, GetMapPositionExecutor, 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 };
2594
2654
  //# sourceMappingURL=maps-components.mjs.map