@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.
- package/dist/esm2020/map/messages/commands/modify-feature.command.mjs +7 -5
- package/dist/esm2020/map/messages/executors/polygon-self-intersection.executor.mjs +9 -0
- package/dist/esm2020/map/messages/index.mjs +2 -1
- package/dist/esm2020/map/public-api.mjs +2 -1
- package/dist/esm2020/map/services/drawing/feature-modification.service.mjs +3 -2
- package/dist/esm2020/map/services/feature.service.mjs +53 -2
- package/dist/esm2020/map/services/message-registrator.service.mjs +3 -2
- package/dist/esm2020/src/map/messages/commands/modify-feature.command.mjs +7 -5
- package/dist/esm2020/src/map/messages/executors/polygon-self-intersection.executor.mjs +9 -0
- package/dist/esm2020/src/map/messages/index.mjs +2 -1
- package/dist/esm2020/src/map/public-api.mjs +2 -1
- package/dist/esm2020/src/map/services/drawing/feature-modification.service.mjs +3 -2
- package/dist/esm2020/src/map/services/feature.service.mjs +53 -2
- package/dist/esm2020/src/map/services/message-registrator.service.mjs +3 -2
- package/dist/fesm2015/maps-components-src-map.mjs +71 -7
- package/dist/fesm2015/maps-components-src-map.mjs.map +1 -1
- package/dist/fesm2015/maps-components.mjs +71 -7
- package/dist/fesm2015/maps-components.mjs.map +1 -1
- package/dist/fesm2020/maps-components-src-map.mjs +71 -7
- package/dist/fesm2020/maps-components-src-map.mjs.map +1 -1
- package/dist/fesm2020/maps-components.mjs +71 -7
- package/dist/fesm2020/maps-components.mjs.map +1 -1
- package/dist/map/messages/commands/modify-feature.command.d.ts +6 -4
- package/dist/map/messages/executors/polygon-self-intersection.executor.d.ts +7 -0
- package/dist/map/messages/index.d.ts +1 -0
- package/dist/map/public-api.d.ts +1 -0
- package/dist/map/services/feature.service.d.ts +5 -0
- package/dist/src/map/messages/commands/modify-feature.command.d.ts +6 -4
- package/dist/src/map/messages/executors/polygon-self-intersection.executor.d.ts +7 -0
- package/dist/src/map/messages/index.d.ts +1 -0
- package/dist/src/map/public-api.d.ts +1 -0
- package/dist/src/map/services/feature.service.d.ts +5 -0
- 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 {
|
|
@@ -387,15 +388,17 @@ class ModifyFeatureCommand extends PostboyCallbackMessage {
|
|
|
387
388
|
/**
|
|
388
389
|
* Constructs an instance of the class.
|
|
389
390
|
*
|
|
390
|
-
* @param {PolygonModel} model - The
|
|
391
|
-
* @param {Style} style - The style
|
|
392
|
-
* @param {FeatureOutputFormat} [format=FeatureOutputFormat.GeoJson] - The output format of the
|
|
391
|
+
* @param {PolygonModel} model - The model representing the polygon data.
|
|
392
|
+
* @param {Style} style - The style to be applied to the polygon.
|
|
393
|
+
* @param {FeatureOutputFormat} [format=FeatureOutputFormat.GeoJson] - The output format of the feature, defaults to GeoJson.
|
|
394
|
+
* @param {boolean} [draggable=true] - Determines whether the polygon is draggable, defaults to true.
|
|
393
395
|
*/
|
|
394
|
-
constructor(model, style, format = FeatureOutputFormat.GeoJson) {
|
|
396
|
+
constructor(model, style, format = FeatureOutputFormat.GeoJson, draggable = true) {
|
|
395
397
|
super();
|
|
396
398
|
this.model = model;
|
|
397
399
|
this.style = style;
|
|
398
400
|
this.format = format;
|
|
401
|
+
this.draggable = draggable;
|
|
399
402
|
}
|
|
400
403
|
}
|
|
401
404
|
ModifyFeatureCommand.ID = '8f76507e-f18d-4232-bab7-f3d4e3d707bb';
|
|
@@ -626,6 +629,14 @@ class GetMapPositionExecutor extends PostboyExecutor {
|
|
|
626
629
|
}
|
|
627
630
|
GetMapPositionExecutor.ID = '52c95689-d09b-4082-ba58-9183ea96a213';
|
|
628
631
|
|
|
632
|
+
class PolygonSelfIntersectionExecutor extends PostboyGenericMessage {
|
|
633
|
+
constructor(polygon) {
|
|
634
|
+
super();
|
|
635
|
+
this.polygon = polygon;
|
|
636
|
+
}
|
|
637
|
+
}
|
|
638
|
+
PolygonSelfIntersectionExecutor.ID = 'a4ef116d-fe40-4e92-9d4a-653f8b398c62';
|
|
639
|
+
|
|
629
640
|
/**
|
|
630
641
|
* Class representing a query to get features within a specified geographical area.
|
|
631
642
|
* The query optionally takes a set of layer names to ignore during the operation.
|
|
@@ -763,6 +774,20 @@ class FeatureService {
|
|
|
763
774
|
return 0;
|
|
764
775
|
return Sphere.getArea(g, { projection: 'EPSG:4326' });
|
|
765
776
|
}
|
|
777
|
+
static polygonSelfIntersects(feature) {
|
|
778
|
+
if (feature.getGeometry().getType() !== 'Polygon')
|
|
779
|
+
return false;
|
|
780
|
+
let intersections = 0;
|
|
781
|
+
const segments = FeatureService.getSegmentsFromCoordinates(feature.getGeometry());
|
|
782
|
+
for (let i = 0; i < segments.length; i++) {
|
|
783
|
+
for (let z = i + 1; z < segments.length; z++) {
|
|
784
|
+
if (!intersections && this.segmentIntersection(segments[i].getCoordinates(), segments[z].getCoordinates())) {
|
|
785
|
+
intersections++;
|
|
786
|
+
}
|
|
787
|
+
}
|
|
788
|
+
}
|
|
789
|
+
return intersections !== 0;
|
|
790
|
+
}
|
|
766
791
|
static booleanIntersects(g1, g2) {
|
|
767
792
|
if (g2.getType() === 'Point')
|
|
768
793
|
return g1.intersectsCoordinate(g2.getCoordinates());
|
|
@@ -772,6 +797,43 @@ class FeatureService {
|
|
|
772
797
|
return g1.intersectsCoordinate(g2.getInteriorPoint().getCoordinates());
|
|
773
798
|
return false;
|
|
774
799
|
}
|
|
800
|
+
static getSegmentsFromCoordinates(geom) {
|
|
801
|
+
if (!geom)
|
|
802
|
+
return [];
|
|
803
|
+
const coords = geom.getCoordinates();
|
|
804
|
+
const line = new LineString(coords[0]);
|
|
805
|
+
const segments = [];
|
|
806
|
+
line.forEachSegment((s1, s2) => {
|
|
807
|
+
const l = new LineString([s1, s2]);
|
|
808
|
+
l.scale(0.999); // bug of the OL, as I see
|
|
809
|
+
segments.push(l);
|
|
810
|
+
});
|
|
811
|
+
return segments;
|
|
812
|
+
}
|
|
813
|
+
static segmentIntersection(s1, s2) {
|
|
814
|
+
const a = s1[0], b = s1[1], c = s2[0], d = s2[1];
|
|
815
|
+
const o1 = this.orientation(a, b, c);
|
|
816
|
+
const o2 = this.orientation(a, b, d);
|
|
817
|
+
const o3 = this.orientation(c, d, a);
|
|
818
|
+
const o4 = this.orientation(c, d, b);
|
|
819
|
+
return ((o1 != o2 && o3 != o4) ||
|
|
820
|
+
(o1 == 0 && this.onSegment(a, d, b)) ||
|
|
821
|
+
(o2 == 0 && this.onSegment(a, d, b)) ||
|
|
822
|
+
(o3 == 0 && this.onSegment(d, a, d)) ||
|
|
823
|
+
(o4 == 0 && this.onSegment(d, b, d)));
|
|
824
|
+
}
|
|
825
|
+
static orientation(p, q, r) {
|
|
826
|
+
const val = (q[1] - p[1]) * (r[0] - q[0]) - (q[0] - p[0]) * (r[1] - q[1]);
|
|
827
|
+
if (val == 0)
|
|
828
|
+
return 0; // collinear
|
|
829
|
+
return val > 0 ? 1 : 2; // clock or counterclock wise
|
|
830
|
+
}
|
|
831
|
+
static onSegment(p, q, r) {
|
|
832
|
+
return (q[0] <= (p[0] > r[0] ? p[0] : r[0]) &&
|
|
833
|
+
q[0] >= (p[0] < r[0] ? p[0] : r[0]) &&
|
|
834
|
+
q[1] <= (p[1] > r[1] ? p[1] : r[1]) &&
|
|
835
|
+
q[1] >= (p[1] < r[1] ? p[1] : r[1]));
|
|
836
|
+
}
|
|
775
837
|
}
|
|
776
838
|
|
|
777
839
|
class GenerateDrawExecutor extends PostboyExecutor {
|
|
@@ -1169,7 +1231,8 @@ class FeatureModificationService {
|
|
|
1169
1231
|
this.observeCancelation(ev, l);
|
|
1170
1232
|
this.initFeature(l, ev.model.feature);
|
|
1171
1233
|
this.addModify(ev);
|
|
1172
|
-
|
|
1234
|
+
if (ev.draggable)
|
|
1235
|
+
this.addDragging(ev);
|
|
1173
1236
|
});
|
|
1174
1237
|
});
|
|
1175
1238
|
}
|
|
@@ -1305,6 +1368,7 @@ class MessageRegistratorService extends PostboyAbstractRegistrator {
|
|
|
1305
1368
|
this.recordExecutor(FilterFeaturesInAreaExecutor, (e) => FeatureService.filterFeaturesInArea(e));
|
|
1306
1369
|
this.recordExecutor(FilterFeaturesInPointExecutor, (e) => FeatureService.filterFeaturesInPoint(e));
|
|
1307
1370
|
this.recordExecutor(CalculateAreaExecutor, (e) => FeatureService.calculateArea(e.polygon?.feature?.getGeometry()));
|
|
1371
|
+
this.recordExecutor(PolygonSelfIntersectionExecutor, (e) => FeatureService.polygonSelfIntersects(e.polygon.feature));
|
|
1308
1372
|
this.recordExecutor(GenerateDrawExecutor, (e) => DrawingGenerationService.getDraw(e));
|
|
1309
1373
|
this.recordExecutor(GenerateZoomControlExecutor, (e) => ZoomControlFactory.build(e.settings));
|
|
1310
1374
|
this.recordExecutor(GetMapPositionExecutor, () => this.state.getMapPosition());
|
|
@@ -2775,5 +2839,5 @@ class StringifyFeatureHelper {
|
|
|
2775
2839
|
* Generated bundle index. Do not edit.
|
|
2776
2840
|
*/
|
|
2777
2841
|
|
|
2778
|
-
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 };
|
|
2842
|
+
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 };
|
|
2779
2843
|
//# sourceMappingURL=maps-components.mjs.map
|