@artstesh/maps 4.1.24 → 4.1.26

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 (33) hide show
  1. package/dist/esm2020/map/messages/commands/modify-feature.command.mjs +7 -5
  2. package/dist/esm2020/map/messages/executors/polygon-self-intersection.executor.mjs +9 -0
  3. package/dist/esm2020/map/messages/index.mjs +2 -1
  4. package/dist/esm2020/map/public-api.mjs +2 -1
  5. package/dist/esm2020/map/services/drawing/feature-modification.service.mjs +3 -2
  6. package/dist/esm2020/map/services/feature.service.mjs +53 -2
  7. package/dist/esm2020/map/services/message-registrator.service.mjs +3 -2
  8. package/dist/esm2020/src/map/messages/commands/modify-feature.command.mjs +7 -5
  9. package/dist/esm2020/src/map/messages/executors/polygon-self-intersection.executor.mjs +9 -0
  10. package/dist/esm2020/src/map/messages/index.mjs +2 -1
  11. package/dist/esm2020/src/map/public-api.mjs +2 -1
  12. package/dist/esm2020/src/map/services/drawing/feature-modification.service.mjs +3 -2
  13. package/dist/esm2020/src/map/services/feature.service.mjs +53 -2
  14. package/dist/esm2020/src/map/services/message-registrator.service.mjs +3 -2
  15. package/dist/fesm2015/maps-components-src-map.mjs +71 -7
  16. package/dist/fesm2015/maps-components-src-map.mjs.map +1 -1
  17. package/dist/fesm2015/maps-components.mjs +71 -7
  18. package/dist/fesm2015/maps-components.mjs.map +1 -1
  19. package/dist/fesm2020/maps-components-src-map.mjs +71 -7
  20. package/dist/fesm2020/maps-components-src-map.mjs.map +1 -1
  21. package/dist/fesm2020/maps-components.mjs +71 -7
  22. package/dist/fesm2020/maps-components.mjs.map +1 -1
  23. package/dist/map/messages/commands/modify-feature.command.d.ts +6 -4
  24. package/dist/map/messages/executors/polygon-self-intersection.executor.d.ts +7 -0
  25. package/dist/map/messages/index.d.ts +1 -0
  26. package/dist/map/public-api.d.ts +1 -0
  27. package/dist/map/services/feature.service.d.ts +5 -0
  28. package/dist/src/map/messages/commands/modify-feature.command.d.ts +6 -4
  29. package/dist/src/map/messages/executors/polygon-self-intersection.executor.d.ts +7 -0
  30. package/dist/src/map/messages/index.d.ts +1 -0
  31. package/dist/src/map/public-api.d.ts +1 -0
  32. package/dist/src/map/services/feature.service.d.ts +5 -0
  33. package/package.json +1 -1
@@ -3,7 +3,7 @@ import { Component, Injectable, ChangeDetectionStrategy, Input, ViewChild, NgMod
3
3
  import * as i4 from '@angular/common';
4
4
  import { CommonModule } from '@angular/common';
5
5
  import { Feature, Collection } from 'ol';
6
- import { Point } from 'ol/geom';
6
+ import { Point, LineString } from 'ol/geom';
7
7
  import { GeoJSON, WKT } from 'ol/format';
8
8
  import { getCenter, createEmpty, extend } from 'ol/extent';
9
9
  import Polygon, { circular, fromExtent } from 'ol/geom/Polygon';
@@ -27,6 +27,7 @@ import View from 'ol/View';
27
27
  import Overlay from 'ol/Overlay';
28
28
  import Style from 'ol/style/Style';
29
29
  import { Icon, Circle, Fill, Stroke, Text } from 'ol/style';
30
+ export { Style } from 'ol/style';
30
31
  import { METERS_PER_UNIT } from 'ol/proj/epsg4326';
31
32
 
32
33
  class DestructibleComponent {
@@ -388,15 +389,17 @@ class ModifyFeatureCommand extends PostboyCallbackMessage {
388
389
  /**
389
390
  * Constructs an instance of the class.
390
391
  *
391
- * @param {PolygonModel} model - The polygon model to be used.
392
- * @param {Style} style - The style configuration for the polygon.
393
- * @param {FeatureOutputFormat} [format=FeatureOutputFormat.GeoJson] - The output format of the features. Default is GeoJson.
392
+ * @param {PolygonModel} model - The model representing the polygon data.
393
+ * @param {Style} style - The style to be applied to the polygon.
394
+ * @param {FeatureOutputFormat} [format=FeatureOutputFormat.GeoJson] - The output format of the feature, defaults to GeoJson.
395
+ * @param {boolean} [draggable=true] - Determines whether the polygon is draggable, defaults to true.
394
396
  */
395
- constructor(model, style, format = FeatureOutputFormat.GeoJson) {
397
+ constructor(model, style, format = FeatureOutputFormat.GeoJson, draggable = true) {
396
398
  super();
397
399
  this.model = model;
398
400
  this.style = style;
399
401
  this.format = format;
402
+ this.draggable = draggable;
400
403
  }
401
404
  }
402
405
  ModifyFeatureCommand.ID = '8f76507e-f18d-4232-bab7-f3d4e3d707bb';
@@ -627,6 +630,14 @@ class GetMapPositionExecutor extends PostboyExecutor {
627
630
  }
628
631
  GetMapPositionExecutor.ID = '52c95689-d09b-4082-ba58-9183ea96a213';
629
632
 
633
+ class PolygonSelfIntersectionExecutor extends PostboyGenericMessage {
634
+ constructor(polygon) {
635
+ super();
636
+ this.polygon = polygon;
637
+ }
638
+ }
639
+ PolygonSelfIntersectionExecutor.ID = 'a4ef116d-fe40-4e92-9d4a-653f8b398c62';
640
+
630
641
  /**
631
642
  * Class representing a query to get features within a specified geographical area.
632
643
  * The query optionally takes a set of layer names to ignore during the operation.
@@ -764,6 +775,20 @@ class FeatureService {
764
775
  return 0;
765
776
  return Sphere.getArea(g, { projection: 'EPSG:4326' });
766
777
  }
778
+ static polygonSelfIntersects(feature) {
779
+ if (feature.getGeometry().getType() !== 'Polygon')
780
+ return false;
781
+ let intersections = 0;
782
+ const segments = FeatureService.getSegmentsFromCoordinates(feature.getGeometry());
783
+ for (let i = 0; i < segments.length; i++) {
784
+ for (let z = i + 1; z < segments.length; z++) {
785
+ if (!intersections && this.segmentIntersection(segments[i].getCoordinates(), segments[z].getCoordinates())) {
786
+ intersections++;
787
+ }
788
+ }
789
+ }
790
+ return intersections !== 0;
791
+ }
767
792
  static booleanIntersects(g1, g2) {
768
793
  if (g2.getType() === 'Point')
769
794
  return g1.intersectsCoordinate(g2.getCoordinates());
@@ -773,6 +798,43 @@ class FeatureService {
773
798
  return g1.intersectsCoordinate(g2.getInteriorPoint().getCoordinates());
774
799
  return false;
775
800
  }
801
+ static getSegmentsFromCoordinates(geom) {
802
+ if (!geom)
803
+ return [];
804
+ const coords = geom.getCoordinates();
805
+ const line = new LineString(coords[0]);
806
+ const segments = [];
807
+ line.forEachSegment((s1, s2) => {
808
+ const l = new LineString([s1, s2]);
809
+ l.scale(0.999); // bug of the OL, as I see
810
+ segments.push(l);
811
+ });
812
+ return segments;
813
+ }
814
+ static segmentIntersection(s1, s2) {
815
+ const a = s1[0], b = s1[1], c = s2[0], d = s2[1];
816
+ const o1 = this.orientation(a, b, c);
817
+ const o2 = this.orientation(a, b, d);
818
+ const o3 = this.orientation(c, d, a);
819
+ const o4 = this.orientation(c, d, b);
820
+ return ((o1 != o2 && o3 != o4) ||
821
+ (o1 == 0 && this.onSegment(a, d, b)) ||
822
+ (o2 == 0 && this.onSegment(a, d, b)) ||
823
+ (o3 == 0 && this.onSegment(d, a, d)) ||
824
+ (o4 == 0 && this.onSegment(d, b, d)));
825
+ }
826
+ static orientation(p, q, r) {
827
+ const val = (q[1] - p[1]) * (r[0] - q[0]) - (q[0] - p[0]) * (r[1] - q[1]);
828
+ if (val == 0)
829
+ return 0; // collinear
830
+ return val > 0 ? 1 : 2; // clock or counterclock wise
831
+ }
832
+ static onSegment(p, q, r) {
833
+ return (q[0] <= (p[0] > r[0] ? p[0] : r[0]) &&
834
+ q[0] >= (p[0] < r[0] ? p[0] : r[0]) &&
835
+ q[1] <= (p[1] > r[1] ? p[1] : r[1]) &&
836
+ q[1] >= (p[1] < r[1] ? p[1] : r[1]));
837
+ }
776
838
  }
777
839
 
778
840
  class GenerateDrawExecutor extends PostboyExecutor {
@@ -1179,7 +1241,8 @@ class FeatureModificationService {
1179
1241
  this.observeCancelation(ev, l);
1180
1242
  this.initFeature(l, ev.model.feature);
1181
1243
  this.addModify(ev);
1182
- this.addDragging(ev);
1244
+ if (ev.draggable)
1245
+ this.addDragging(ev);
1183
1246
  });
1184
1247
  });
1185
1248
  }
@@ -1320,6 +1383,7 @@ class MessageRegistratorService extends PostboyAbstractRegistrator {
1320
1383
  this.recordExecutor(FilterFeaturesInAreaExecutor, (e) => FeatureService.filterFeaturesInArea(e));
1321
1384
  this.recordExecutor(FilterFeaturesInPointExecutor, (e) => FeatureService.filterFeaturesInPoint(e));
1322
1385
  this.recordExecutor(CalculateAreaExecutor, (e) => { var _a, _b; return FeatureService.calculateArea((_b = (_a = e.polygon) === null || _a === void 0 ? void 0 : _a.feature) === null || _b === void 0 ? void 0 : _b.getGeometry()); });
1386
+ this.recordExecutor(PolygonSelfIntersectionExecutor, (e) => FeatureService.polygonSelfIntersects(e.polygon.feature));
1323
1387
  this.recordExecutor(GenerateDrawExecutor, (e) => DrawingGenerationService.getDraw(e));
1324
1388
  this.recordExecutor(GenerateZoomControlExecutor, (e) => ZoomControlFactory.build(e.settings));
1325
1389
  this.recordExecutor(GetMapPositionExecutor, () => this.state.getMapPosition());
@@ -2798,5 +2862,5 @@ class StringifyFeatureHelper {
2798
2862
  * Generated bundle index. Do not edit.
2799
2863
  */
2800
2864
 
2801
- export { AddControlCommand, CalculateAreaExecutor, CancelDrawingCommand, CancelFeatureModificationCommand, CloseTooltipCommand, ClusterLayerComponent, ClusterLayerSettings, DrawSelectionAreaCommand, DrawingType, FeatureLayerComponent, FeatureLayerSettings, FeatureOutputFormat, FilterFeaturesInAreaExecutor, FilterFeaturesInPointExecutor, FitToFeaturesCommand, FitToPolygonsCommand, GetFeaturesInAreaQuery, GetFeaturesInPointQuery, GetMapPositionExecutor, MapClickEvent, MapConstants, MapControl, MapControlZoomComponent, MapFeatureHoveredEvent, MapLyrs, MapLyrsLabel, MapModule, MapMoveEndEvent, MapPlateComponent, MapPointerMoveEvent, MapPostboyService, MapRenderedEvent, MapSettings, MarkerModel, MarkerStyleHelper, MarkersComponent, MessageRegistratorService, ModifyFeatureCommand, OsmTileLayerComponent, PolygonModel, PolygonStyleHelper, PolygonsComponent, RemoveControlCommand, SetMapCenterCommand, StartDrawingCommand, StringifyFeatureHelper, TextStyleHelper, TileLayerComponent, TileLayerSettings, TooltipComponent, TooltipSettings, ZoomControlSettings };
2865
+ export { AddControlCommand, CalculateAreaExecutor, CancelDrawingCommand, CancelFeatureModificationCommand, CloseTooltipCommand, ClusterLayerComponent, ClusterLayerSettings, DrawSelectionAreaCommand, DrawingType, FeatureLayerComponent, FeatureLayerSettings, FeatureOutputFormat, FilterFeaturesInAreaExecutor, FilterFeaturesInPointExecutor, FitToFeaturesCommand, FitToPolygonsCommand, GetFeaturesInAreaQuery, GetFeaturesInPointQuery, GetMapPositionExecutor, MapClickEvent, MapConstants, MapControl, MapControlZoomComponent, MapFeatureHoveredEvent, MapLyrs, MapLyrsLabel, MapModule, MapMoveEndEvent, MapPlateComponent, MapPointerMoveEvent, MapPostboyService, MapRenderedEvent, MapSettings, MarkerModel, MarkerStyleHelper, MarkersComponent, MessageRegistratorService, ModifyFeatureCommand, OsmTileLayerComponent, PolygonModel, PolygonSelfIntersectionExecutor, PolygonStyleHelper, PolygonsComponent, RemoveControlCommand, SetMapCenterCommand, StartDrawingCommand, StringifyFeatureHelper, TextStyleHelper, TileLayerComponent, TileLayerSettings, TooltipComponent, TooltipSettings, ZoomControlSettings };
2802
2866
  //# sourceMappingURL=maps-components.mjs.map