@artstesh/maps 6.1.2 → 6.1.4
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/esm2022/map/map-plate/features/polygons/polygons.component.mjs +6 -2
- package/dist/esm2022/map/messages/executors/polygon-self-intersection.executor.mjs +10 -0
- package/dist/esm2022/map/messages/index.mjs +2 -1
- package/dist/esm2022/map/services/feature.service.mjs +53 -2
- package/dist/esm2022/map/services/message-registrator.service.mjs +3 -2
- package/dist/esm2022/src/map/map-plate/features/polygons/polygons.component.mjs +6 -2
- package/dist/esm2022/src/map/messages/executors/polygon-self-intersection.executor.mjs +10 -0
- package/dist/esm2022/src/map/messages/index.mjs +2 -1
- package/dist/esm2022/src/map/services/feature.service.mjs +53 -2
- package/dist/esm2022/src/map/services/message-registrator.service.mjs +3 -2
- package/dist/fesm2022/maps-components-src-map.mjs +67 -3
- package/dist/fesm2022/maps-components-src-map.mjs.map +1 -1
- package/dist/fesm2022/maps-components.mjs +67 -3
- package/dist/fesm2022/maps-components.mjs.map +1 -1
- 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/services/feature.service.d.ts +5 -0
- 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/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';
|
|
@@ -664,6 +664,15 @@ class GetMapPositionExecutor extends PostboyExecutor {
|
|
|
664
664
|
}
|
|
665
665
|
}
|
|
666
666
|
|
|
667
|
+
class PolygonSelfIntersectionExecutor extends PostboyGenericMessage {
|
|
668
|
+
polygon;
|
|
669
|
+
static ID = 'a4ef116d-fe40-4e92-9d4a-653f8b398c62';
|
|
670
|
+
constructor(polygon) {
|
|
671
|
+
super();
|
|
672
|
+
this.polygon = polygon;
|
|
673
|
+
}
|
|
674
|
+
}
|
|
675
|
+
|
|
667
676
|
/**
|
|
668
677
|
* Class representing a query to get features within a specified geographical area.
|
|
669
678
|
* The query optionally takes a set of layer names to ignore during the operation.
|
|
@@ -815,6 +824,20 @@ class FeatureService {
|
|
|
815
824
|
return 0;
|
|
816
825
|
return Sphere.getArea(g, { projection: 'EPSG:4326' });
|
|
817
826
|
}
|
|
827
|
+
static polygonSelfIntersects(feature) {
|
|
828
|
+
if (feature.getGeometry().getType() !== 'Polygon')
|
|
829
|
+
return false;
|
|
830
|
+
let intersections = 0;
|
|
831
|
+
const segments = FeatureService.getSegmentsFromCoordinates(feature.getGeometry());
|
|
832
|
+
for (let i = 0; i < segments.length; i++) {
|
|
833
|
+
for (let z = i + 1; z < segments.length; z++) {
|
|
834
|
+
if (!intersections && this.segmentIntersection(segments[i].getCoordinates(), segments[z].getCoordinates())) {
|
|
835
|
+
intersections++;
|
|
836
|
+
}
|
|
837
|
+
}
|
|
838
|
+
}
|
|
839
|
+
return intersections !== 0;
|
|
840
|
+
}
|
|
818
841
|
static booleanIntersects(g1, g2) {
|
|
819
842
|
if (g2.getType() === 'Point')
|
|
820
843
|
return g1.intersectsCoordinate(g2.getCoordinates());
|
|
@@ -824,6 +847,43 @@ class FeatureService {
|
|
|
824
847
|
return g1.intersectsCoordinate(g2.getInteriorPoint().getCoordinates());
|
|
825
848
|
return false;
|
|
826
849
|
}
|
|
850
|
+
static getSegmentsFromCoordinates(geom) {
|
|
851
|
+
if (!geom)
|
|
852
|
+
return [];
|
|
853
|
+
const coords = geom.getCoordinates();
|
|
854
|
+
const line = new LineString(coords[0]);
|
|
855
|
+
const segments = [];
|
|
856
|
+
line.forEachSegment((s1, s2) => {
|
|
857
|
+
const l = new LineString([s1, s2]);
|
|
858
|
+
l.scale(0.999); // bug of the OL, as I see
|
|
859
|
+
segments.push(l);
|
|
860
|
+
});
|
|
861
|
+
return segments;
|
|
862
|
+
}
|
|
863
|
+
static segmentIntersection(s1, s2) {
|
|
864
|
+
const a = s1[0], b = s1[1], c = s2[0], d = s2[1];
|
|
865
|
+
const o1 = this.orientation(a, b, c);
|
|
866
|
+
const o2 = this.orientation(a, b, d);
|
|
867
|
+
const o3 = this.orientation(c, d, a);
|
|
868
|
+
const o4 = this.orientation(c, d, b);
|
|
869
|
+
return ((o1 != o2 && o3 != o4) ||
|
|
870
|
+
(o1 == 0 && this.onSegment(a, d, b)) ||
|
|
871
|
+
(o2 == 0 && this.onSegment(a, d, b)) ||
|
|
872
|
+
(o3 == 0 && this.onSegment(d, a, d)) ||
|
|
873
|
+
(o4 == 0 && this.onSegment(d, b, d)));
|
|
874
|
+
}
|
|
875
|
+
static orientation(p, q, r) {
|
|
876
|
+
const val = (q[1] - p[1]) * (r[0] - q[0]) - (q[0] - p[0]) * (r[1] - q[1]);
|
|
877
|
+
if (val == 0)
|
|
878
|
+
return 0; // collinear
|
|
879
|
+
return val > 0 ? 1 : 2; // clock or counterclock wise
|
|
880
|
+
}
|
|
881
|
+
static onSegment(p, q, r) {
|
|
882
|
+
return (q[0] <= (p[0] > r[0] ? p[0] : r[0]) &&
|
|
883
|
+
q[0] >= (p[0] < r[0] ? p[0] : r[0]) &&
|
|
884
|
+
q[1] <= (p[1] > r[1] ? p[1] : r[1]) &&
|
|
885
|
+
q[1] >= (p[1] < r[1] ? p[1] : r[1]));
|
|
886
|
+
}
|
|
827
887
|
}
|
|
828
888
|
|
|
829
889
|
class GenerateDrawExecutor extends PostboyExecutor {
|
|
@@ -1377,6 +1437,7 @@ class MessageRegistratorService extends PostboyAbstractRegistrator {
|
|
|
1377
1437
|
this.recordExecutor(FilterFeaturesInAreaExecutor, (e) => FeatureService.filterFeaturesInArea(e));
|
|
1378
1438
|
this.recordExecutor(FilterFeaturesInPointExecutor, (e) => FeatureService.filterFeaturesInPoint(e));
|
|
1379
1439
|
this.recordExecutor(CalculateAreaExecutor, (e) => FeatureService.calculateArea(e.polygon?.feature?.getGeometry()));
|
|
1440
|
+
this.recordExecutor(PolygonSelfIntersectionExecutor, (e) => FeatureService.polygonSelfIntersects(e.polygon.feature));
|
|
1380
1441
|
this.recordExecutor(GenerateDrawExecutor, (e) => DrawingGenerationService.getDraw(e));
|
|
1381
1442
|
this.recordExecutor(GenerateZoomControlExecutor, (e) => ZoomControlFactory.build(e.settings));
|
|
1382
1443
|
this.recordExecutor(GetMapPositionExecutor, () => this.state.getMapPosition());
|
|
@@ -2448,7 +2509,10 @@ class PolygonsComponent extends DestructibleComponent {
|
|
|
2448
2509
|
putPolygons() {
|
|
2449
2510
|
if (!this._polygons)
|
|
2450
2511
|
return;
|
|
2451
|
-
this.postboy.fire(new PlaceLayerFeaturesCommand(this.layerName, this._polygons.map((m) =>
|
|
2512
|
+
this.postboy.fire(new PlaceLayerFeaturesCommand(this.layerName, this._polygons.map((m) => {
|
|
2513
|
+
m.feature.set(MapConstants.FeatureLayerName, this.layerName);
|
|
2514
|
+
return m.feature;
|
|
2515
|
+
})));
|
|
2452
2516
|
}
|
|
2453
2517
|
static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "17.3.7", ngImport: i0, type: PolygonsComponent, deps: [{ token: MapPostboyService }], target: i0.ɵɵFactoryTarget.Component });
|
|
2454
2518
|
static ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "14.0.0", version: "17.3.7", type: PolygonsComponent, selector: "art-polygons", inputs: { layerName: "layerName", polygons: "polygons" }, usesInheritance: true, ngImport: i0, template: '', isInline: true, changeDetection: i0.ChangeDetectionStrategy.OnPush });
|
|
@@ -2885,5 +2949,5 @@ class StringifyFeatureHelper {
|
|
|
2885
2949
|
* Generated bundle index. Do not edit.
|
|
2886
2950
|
*/
|
|
2887
2951
|
|
|
2888
|
-
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 };
|
|
2952
|
+
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 };
|
|
2889
2953
|
//# sourceMappingURL=maps-components.mjs.map
|