@artstesh/maps 1.1.23 → 1.1.25

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/bundles/maps-components-src-map.umd.js +77 -5
  2. package/dist/bundles/maps-components-src-map.umd.js.map +1 -1
  3. package/dist/bundles/maps-components.umd.js +77 -5
  4. package/dist/bundles/maps-components.umd.js.map +1 -1
  5. package/dist/esm2015/map/messages/commands/modify-feature.command.js +7 -5
  6. package/dist/esm2015/map/messages/executors/polygon-self-intersection.executor.js +9 -0
  7. package/dist/esm2015/map/messages/index.js +2 -1
  8. package/dist/esm2015/map/public-api.js +2 -1
  9. package/dist/esm2015/map/services/drawing/feature-modification.service.js +3 -2
  10. package/dist/esm2015/map/services/feature.service.js +53 -2
  11. package/dist/esm2015/map/services/message-registrator.service.js +3 -2
  12. package/dist/esm2015/src/map/messages/commands/modify-feature.command.js +7 -5
  13. package/dist/esm2015/src/map/messages/executors/polygon-self-intersection.executor.js +9 -0
  14. package/dist/esm2015/src/map/messages/index.js +2 -1
  15. package/dist/esm2015/src/map/public-api.js +2 -1
  16. package/dist/esm2015/src/map/services/drawing/feature-modification.service.js +3 -2
  17. package/dist/esm2015/src/map/services/feature.service.js +53 -2
  18. package/dist/esm2015/src/map/services/message-registrator.service.js +3 -2
  19. package/dist/fesm2015/maps-components-src-map.js +71 -7
  20. package/dist/fesm2015/maps-components-src-map.js.map +1 -1
  21. package/dist/fesm2015/maps-components.js +71 -7
  22. package/dist/fesm2015/maps-components.js.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
@@ -905,16 +905,19 @@
905
905
  /**
906
906
  * Constructs an instance of the class.
907
907
  *
908
- * @param {PolygonModel} model - The polygon model to be used.
909
- * @param {Style} style - The style configuration for the polygon.
910
- * @param {FeatureOutputFormat} [format=FeatureOutputFormat.GeoJson] - The output format of the features. Default is GeoJson.
908
+ * @param {PolygonModel} model - The model representing the polygon data.
909
+ * @param {Style} style - The style to be applied to the polygon.
910
+ * @param {FeatureOutputFormat} [format=FeatureOutputFormat.GeoJson] - The output format of the feature, defaults to GeoJson.
911
+ * @param {boolean} [draggable=true] - Determines whether the polygon is draggable, defaults to true.
911
912
  */
912
- function ModifyFeatureCommand(model, style, format) {
913
+ function ModifyFeatureCommand(model, style, format, draggable) {
913
914
  if (format === void 0) { format = exports.FeatureOutputFormat.GeoJson; }
915
+ if (draggable === void 0) { draggable = true; }
914
916
  var _this = _super.call(this) || this;
915
917
  _this.model = model;
916
918
  _this.style = style;
917
919
  _this.format = format;
920
+ _this.draggable = draggable;
918
921
  return _this;
919
922
  }
920
923
  return ModifyFeatureCommand;
@@ -1188,6 +1191,17 @@
1188
1191
  }(postboy.PostboyExecutor));
1189
1192
  GetMapPositionExecutor.ID = '52c95689-d09b-4082-ba58-9183ea96a213';
1190
1193
 
1194
+ var PolygonSelfIntersectionExecutor = /** @class */ (function (_super) {
1195
+ __extends(PolygonSelfIntersectionExecutor, _super);
1196
+ function PolygonSelfIntersectionExecutor(polygon) {
1197
+ var _this = _super.call(this) || this;
1198
+ _this.polygon = polygon;
1199
+ return _this;
1200
+ }
1201
+ return PolygonSelfIntersectionExecutor;
1202
+ }(postboy.PostboyGenericMessage));
1203
+ PolygonSelfIntersectionExecutor.ID = 'a4ef116d-fe40-4e92-9d4a-653f8b398c62';
1204
+
1191
1205
  /**
1192
1206
  * Class representing a query to get features within a specified geographical area.
1193
1207
  * The query optionally takes a set of layer names to ignore during the operation.
@@ -1364,6 +1378,20 @@
1364
1378
  return 0;
1365
1379
  return Sphere__namespace.getArea(g, { projection: 'EPSG:4326' });
1366
1380
  };
1381
+ FeatureService.polygonSelfIntersects = function (feature) {
1382
+ if (feature.getGeometry().getType() !== 'Polygon')
1383
+ return false;
1384
+ var intersections = 0;
1385
+ var segments = FeatureService.getSegmentsFromCoordinates(feature.getGeometry());
1386
+ for (var i = 0; i < segments.length; i++) {
1387
+ for (var z = i + 1; z < segments.length; z++) {
1388
+ if (!intersections && this.segmentIntersection(segments[i].getCoordinates(), segments[z].getCoordinates())) {
1389
+ intersections++;
1390
+ }
1391
+ }
1392
+ }
1393
+ return intersections !== 0;
1394
+ };
1367
1395
  FeatureService.booleanIntersects = function (g1, g2) {
1368
1396
  if (g2.getType() === 'Point')
1369
1397
  return g1.intersectsCoordinate(g2.getCoordinates());
@@ -1373,6 +1401,43 @@
1373
1401
  return g1.intersectsCoordinate(g2.getInteriorPoint().getCoordinates());
1374
1402
  return false;
1375
1403
  };
1404
+ FeatureService.getSegmentsFromCoordinates = function (geom$1) {
1405
+ if (!geom$1)
1406
+ return [];
1407
+ var coords = geom$1.getCoordinates();
1408
+ var line = new geom.LineString(coords[0]);
1409
+ var segments = [];
1410
+ line.forEachSegment(function (s1, s2) {
1411
+ var l = new geom.LineString([s1, s2]);
1412
+ l.scale(0.999); // bug of the OL, as I see
1413
+ segments.push(l);
1414
+ });
1415
+ return segments;
1416
+ };
1417
+ FeatureService.segmentIntersection = function (s1, s2) {
1418
+ var a = s1[0], b = s1[1], c = s2[0], d = s2[1];
1419
+ var o1 = this.orientation(a, b, c);
1420
+ var o2 = this.orientation(a, b, d);
1421
+ var o3 = this.orientation(c, d, a);
1422
+ var o4 = this.orientation(c, d, b);
1423
+ return ((o1 != o2 && o3 != o4) ||
1424
+ (o1 == 0 && this.onSegment(a, d, b)) ||
1425
+ (o2 == 0 && this.onSegment(a, d, b)) ||
1426
+ (o3 == 0 && this.onSegment(d, a, d)) ||
1427
+ (o4 == 0 && this.onSegment(d, b, d)));
1428
+ };
1429
+ FeatureService.orientation = function (p, q, r) {
1430
+ var val = (q[1] - p[1]) * (r[0] - q[0]) - (q[0] - p[0]) * (r[1] - q[1]);
1431
+ if (val == 0)
1432
+ return 0; // collinear
1433
+ return val > 0 ? 1 : 2; // clock or counterclock wise
1434
+ };
1435
+ FeatureService.onSegment = function (p, q, r) {
1436
+ return (q[0] <= (p[0] > r[0] ? p[0] : r[0]) &&
1437
+ q[0] >= (p[0] < r[0] ? p[0] : r[0]) &&
1438
+ q[1] <= (p[1] > r[1] ? p[1] : r[1]) &&
1439
+ q[1] >= (p[1] < r[1] ? p[1] : r[1]));
1440
+ };
1376
1441
  return FeatureService;
1377
1442
  }());
1378
1443
 
@@ -1821,7 +1886,8 @@
1821
1886
  _this.observeCancelation(ev, l);
1822
1887
  _this.initFeature(l, ev.model.feature);
1823
1888
  _this.addModify(ev);
1824
- _this.addDragging(ev);
1889
+ if (ev.draggable)
1890
+ _this.addDragging(ev);
1825
1891
  });
1826
1892
  });
1827
1893
  };
@@ -1974,6 +2040,7 @@
1974
2040
  this.recordExecutor(FilterFeaturesInAreaExecutor, function (e) { return FeatureService.filterFeaturesInArea(e); });
1975
2041
  this.recordExecutor(FilterFeaturesInPointExecutor, function (e) { return FeatureService.filterFeaturesInPoint(e); });
1976
2042
  this.recordExecutor(CalculateAreaExecutor, function (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()); });
2043
+ this.recordExecutor(PolygonSelfIntersectionExecutor, function (e) { return FeatureService.polygonSelfIntersects(e.polygon.feature); });
1977
2044
  this.recordExecutor(GenerateDrawExecutor, function (e) { return DrawingGenerationService.getDraw(e); });
1978
2045
  this.recordExecutor(GenerateZoomControlExecutor, function (e) { return ZoomControlFactory.build(e.settings); });
1979
2046
  this.recordExecutor(GetMapPositionExecutor, function () { return _this.state.getMapPosition(); });
@@ -3620,6 +3687,10 @@
3620
3687
  * Generated bundle index. Do not edit.
3621
3688
  */
3622
3689
 
3690
+ Object.defineProperty(exports, 'Style', {
3691
+ enumerable: true,
3692
+ get: function () { return style.Style; }
3693
+ });
3623
3694
  exports.AddControlCommand = AddControlCommand;
3624
3695
  exports.CalculateAreaExecutor = CalculateAreaExecutor;
3625
3696
  exports.CancelDrawingCommand = CancelDrawingCommand;
@@ -3657,6 +3728,7 @@
3657
3728
  exports.ModifyFeatureCommand = ModifyFeatureCommand;
3658
3729
  exports.OsmTileLayerComponent = OsmTileLayerComponent;
3659
3730
  exports.PolygonModel = PolygonModel;
3731
+ exports.PolygonSelfIntersectionExecutor = PolygonSelfIntersectionExecutor;
3660
3732
  exports.PolygonStyleHelper = PolygonStyleHelper;
3661
3733
  exports.PolygonsComponent = PolygonsComponent;
3662
3734
  exports.RemoveControlCommand = RemoveControlCommand;