@artstesh/maps 4.0.8 → 4.0.9
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/helpers/index.mjs +2 -1
- package/dist/esm2020/map/helpers/stringify-feature.helper.mjs +58 -0
- package/dist/esm2020/map/map-plate/map-plate.component.mjs +4 -1
- package/dist/esm2020/map/messages/queries/generate-draw.query.mjs +14 -0
- package/dist/esm2020/map/models/drawing-type.enum.mjs +2 -1
- package/dist/esm2020/map/services/drawing/drawing-generation.service.mjs +28 -0
- package/dist/esm2020/map/services/drawing/drawing.service.mjs +13 -13
- package/dist/esm2020/map/services/message-registrator.service.mjs +8 -5
- package/dist/esm2020/src/map/helpers/index.mjs +2 -1
- package/dist/esm2020/src/map/helpers/stringify-feature.helper.mjs +58 -0
- package/dist/esm2020/src/map/map-plate/map-plate.component.mjs +4 -1
- package/dist/esm2020/src/map/messages/queries/generate-draw.query.mjs +14 -0
- package/dist/esm2020/src/map/models/drawing-type.enum.mjs +2 -1
- package/dist/esm2020/src/map/services/drawing/drawing-generation.service.mjs +28 -0
- package/dist/esm2020/src/map/services/drawing/drawing.service.mjs +13 -13
- package/dist/esm2020/src/map/services/message-registrator.service.mjs +8 -5
- package/dist/fesm2015/maps-components-src-map.mjs +110 -18
- package/dist/fesm2015/maps-components-src-map.mjs.map +1 -1
- package/dist/fesm2015/maps-components.mjs +110 -18
- package/dist/fesm2015/maps-components.mjs.map +1 -1
- package/dist/fesm2020/maps-components-src-map.mjs +109 -18
- package/dist/fesm2020/maps-components-src-map.mjs.map +1 -1
- package/dist/fesm2020/maps-components.mjs +109 -18
- package/dist/fesm2020/maps-components.mjs.map +1 -1
- package/dist/map/helpers/index.d.ts +1 -0
- package/dist/map/helpers/stringify-feature.helper.d.ts +8 -0
- package/dist/map/messages/queries/generate-draw.query.d.ts +14 -0
- package/dist/map/models/drawing-type.enum.d.ts +2 -1
- package/dist/map/services/drawing/drawing-generation.service.d.ts +10 -0
- package/dist/map/services/message-registrator.service.d.ts +2 -1
- package/dist/src/map/helpers/index.d.ts +1 -0
- package/dist/src/map/helpers/stringify-feature.helper.d.ts +8 -0
- package/dist/src/map/messages/queries/generate-draw.query.d.ts +14 -0
- package/dist/src/map/models/drawing-type.enum.d.ts +2 -1
- package/dist/src/map/services/drawing/drawing-generation.service.d.ts +10 -0
- package/dist/src/map/services/message-registrator.service.d.ts +2 -1
- package/package.json +1 -1
|
@@ -3,19 +3,20 @@ 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 } 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
|
-
import { get, useGeographic } from 'ol/proj';
|
|
9
|
+
import { get, useGeographic, transform } from 'ol/proj';
|
|
10
10
|
import { PostboyGenericMessage, PostboyCallbackMessage, PostboyService, PostboyAbstractRegistrator } from '@artstesh/postboy';
|
|
11
11
|
import { first, filter, auditTime } from 'rxjs/operators';
|
|
12
12
|
import { Vector, XYZ } from 'ol/source';
|
|
13
13
|
import { Draw } from 'ol/interaction';
|
|
14
|
+
import { createRegularPolygon } from 'ol/interaction/Draw';
|
|
14
15
|
import TileLayer from 'ol/layer/Tile';
|
|
15
16
|
import OSM from 'ol/source/OSM';
|
|
16
17
|
import { Vector as Vector$1 } from 'ol/layer';
|
|
17
18
|
import { bbox } from 'ol/loadingstrategy';
|
|
18
|
-
import { fromExtent } from 'ol/geom/Polygon';
|
|
19
|
+
import Polygon, { fromExtent } from 'ol/geom/Polygon';
|
|
19
20
|
import Cluster from 'ol/source/Cluster';
|
|
20
21
|
import { combineLatest } from 'rxjs';
|
|
21
22
|
import Map from 'ol/Map';
|
|
@@ -23,6 +24,7 @@ import View from 'ol/View';
|
|
|
23
24
|
import Overlay from 'ol/Overlay';
|
|
24
25
|
import Style from 'ol/style/Style';
|
|
25
26
|
import { Icon, Circle, Fill, Stroke, Text } from 'ol/style';
|
|
27
|
+
import { METERS_PER_UNIT } from 'ol/proj/epsg4326';
|
|
26
28
|
|
|
27
29
|
class DestructibleComponent {
|
|
28
30
|
constructor() {
|
|
@@ -177,6 +179,7 @@ class PolygonModel {
|
|
|
177
179
|
var DrawingType;
|
|
178
180
|
(function (DrawingType) {
|
|
179
181
|
DrawingType[DrawingType["Polygon"] = 1] = "Polygon";
|
|
182
|
+
DrawingType[DrawingType["Circle"] = 2] = "Circle";
|
|
180
183
|
})(DrawingType || (DrawingType = {}));
|
|
181
184
|
|
|
182
185
|
var FeatureOutputFormat;
|
|
@@ -341,6 +344,19 @@ class DrawingFinishedEvent extends PostboyGenericMessage {
|
|
|
341
344
|
}
|
|
342
345
|
DrawingFinishedEvent.ID = 'c724b68e-b4eb-4783-90f1-a8e31973fd36';
|
|
343
346
|
|
|
347
|
+
class GenerateDrawQuery extends PostboyCallbackMessage {
|
|
348
|
+
constructor(layer, style, type) {
|
|
349
|
+
super();
|
|
350
|
+
this.layer = layer;
|
|
351
|
+
this.style = style;
|
|
352
|
+
this.type = type;
|
|
353
|
+
}
|
|
354
|
+
get id() {
|
|
355
|
+
return GenerateDrawQuery.ID;
|
|
356
|
+
}
|
|
357
|
+
}
|
|
358
|
+
GenerateDrawQuery.ID = 'f01c99ba-0953-4ab5-82f9-04e6fbb678c1';
|
|
359
|
+
|
|
344
360
|
class MapPostboyService extends PostboyService {
|
|
345
361
|
constructor() {
|
|
346
362
|
super();
|
|
@@ -540,17 +556,18 @@ class DrawingService {
|
|
|
540
556
|
this.clearInteraction(l);
|
|
541
557
|
return;
|
|
542
558
|
}
|
|
543
|
-
const
|
|
544
|
-
|
|
545
|
-
|
|
546
|
-
|
|
547
|
-
|
|
548
|
-
|
|
549
|
-
|
|
550
|
-
|
|
551
|
-
|
|
552
|
-
|
|
559
|
+
const drawQuery = new GenerateDrawQuery(l, ev.style, ev.type);
|
|
560
|
+
drawQuery.result.subscribe((draw) => {
|
|
561
|
+
var _a;
|
|
562
|
+
const cancelSub = this.observeCancelation(ev, l);
|
|
563
|
+
this.drawInteraction = draw;
|
|
564
|
+
(_a = this.map) === null || _a === void 0 ? void 0 : _a.addInteraction(this.drawInteraction);
|
|
565
|
+
this.drawInteraction.on('drawend', (evt) => {
|
|
566
|
+
cancelSub.unsubscribe();
|
|
567
|
+
this.onEnd(evt, ev, l);
|
|
568
|
+
});
|
|
553
569
|
});
|
|
570
|
+
this.postboy.fire(drawQuery);
|
|
554
571
|
});
|
|
555
572
|
});
|
|
556
573
|
this.observeMapRender();
|
|
@@ -595,10 +612,31 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "15.2.10", ngImpo
|
|
|
595
612
|
type: Injectable
|
|
596
613
|
}], ctorParameters: function () { return [{ type: MapPostboyService }]; } });
|
|
597
614
|
|
|
615
|
+
class DrawingGenerationService {
|
|
616
|
+
constructor(postboy) {
|
|
617
|
+
this.postboy = postboy;
|
|
618
|
+
}
|
|
619
|
+
up() {
|
|
620
|
+
this.postboy.subscribe(GenerateDrawQuery.ID).subscribe((ev) => {
|
|
621
|
+
ev.finish(new Draw({
|
|
622
|
+
source: ev.layer.getSource(),
|
|
623
|
+
type: DrawingType[ev.type],
|
|
624
|
+
style: ev.style,
|
|
625
|
+
geometryFunction: ev.type !== DrawingType.Circle ? undefined : createRegularPolygon(32),
|
|
626
|
+
}));
|
|
627
|
+
});
|
|
628
|
+
}
|
|
629
|
+
}
|
|
630
|
+
DrawingGenerationService.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "15.2.10", ngImport: i0, type: DrawingGenerationService, deps: [{ token: MapPostboyService }], target: i0.ɵɵFactoryTarget.Injectable });
|
|
631
|
+
DrawingGenerationService.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "15.2.10", ngImport: i0, type: DrawingGenerationService });
|
|
632
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "15.2.10", ngImport: i0, type: DrawingGenerationService, decorators: [{
|
|
633
|
+
type: Injectable
|
|
634
|
+
}], ctorParameters: function () { return [{ type: MapPostboyService }]; } });
|
|
635
|
+
|
|
598
636
|
class MessageRegistratorService extends PostboyAbstractRegistrator {
|
|
599
|
-
constructor(service, management, state, feature, interaction, drawing) {
|
|
637
|
+
constructor(service, management, state, feature, interaction, drawing, drawGenerator) {
|
|
600
638
|
super(service);
|
|
601
|
-
this.registerServices([management, state, interaction, feature, drawing]);
|
|
639
|
+
this.registerServices([management, state, interaction, feature, drawing, drawGenerator]);
|
|
602
640
|
}
|
|
603
641
|
_up() {
|
|
604
642
|
this.registerReplay(MapRenderedEvent.ID);
|
|
@@ -615,13 +653,14 @@ class MessageRegistratorService extends PostboyAbstractRegistrator {
|
|
|
615
653
|
this.registerSubject(StartDrawingCommand.ID);
|
|
616
654
|
this.registerSubject(GetLayerQuery.ID);
|
|
617
655
|
this.registerSubject(DrawingFinishedEvent.ID);
|
|
656
|
+
this.registerSubject(GenerateDrawQuery.ID);
|
|
618
657
|
}
|
|
619
658
|
}
|
|
620
|
-
MessageRegistratorService.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "15.2.10", ngImport: i0, type: MessageRegistratorService, deps: [{ token: MapPostboyService }, { token: MapManagementService }, { token: MapStateService }, { token: MapFeatureService }, { token: MapClickService }, { token: DrawingService }], target: i0.ɵɵFactoryTarget.Injectable });
|
|
659
|
+
MessageRegistratorService.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "15.2.10", ngImport: i0, type: MessageRegistratorService, deps: [{ token: MapPostboyService }, { token: MapManagementService }, { token: MapStateService }, { token: MapFeatureService }, { token: MapClickService }, { token: DrawingService }, { token: DrawingGenerationService }], target: i0.ɵɵFactoryTarget.Injectable });
|
|
621
660
|
MessageRegistratorService.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "15.2.10", ngImport: i0, type: MessageRegistratorService });
|
|
622
661
|
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "15.2.10", ngImport: i0, type: MessageRegistratorService, decorators: [{
|
|
623
662
|
type: Injectable
|
|
624
|
-
}], ctorParameters: function () { return [{ type: MapPostboyService }, { type: MapManagementService }, { type: MapStateService }, { type: MapFeatureService }, { type: MapClickService }, { type: DrawingService }]; } });
|
|
663
|
+
}], ctorParameters: function () { return [{ type: MapPostboyService }, { type: MapManagementService }, { type: MapStateService }, { type: MapFeatureService }, { type: MapClickService }, { type: DrawingService }, { type: DrawingGenerationService }]; } });
|
|
625
664
|
|
|
626
665
|
class TileLayerSettings {
|
|
627
666
|
constructor() {
|
|
@@ -1178,6 +1217,7 @@ MapPlateComponent.ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "14.0.0", vers
|
|
|
1178
1217
|
MapClickService,
|
|
1179
1218
|
MapFeatureService,
|
|
1180
1219
|
DrawingService,
|
|
1220
|
+
DrawingGenerationService,
|
|
1181
1221
|
], usesInheritance: true, ngImport: i0, template: "<ng-content></ng-content>\r\n<lib-osm-tile-layer *ngIf=\"osmUrl && map\" [map]=\"map\" [url]=\"osmUrl\"></lib-osm-tile-layer>\r\n<lib-feature-layer *ngIf=\"map\" [settings]=\"drawingLayerSettings\"></lib-feature-layer>\r\n", styles: ["lib-map-plate{position:relative;display:flex;flex-direction:column;height:100%}\n"], dependencies: [{ kind: "directive", type: i4.NgIf, selector: "[ngIf]", inputs: ["ngIf", "ngIfThen", "ngIfElse"] }, { kind: "component", type: OsmTileLayerComponent, selector: "lib-osm-tile-layer", inputs: ["url", "map"] }, { kind: "component", type: FeatureLayerComponent, selector: "lib-feature-layer", inputs: ["settings"] }], changeDetection: i0.ChangeDetectionStrategy.OnPush });
|
|
1182
1222
|
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "15.2.10", ngImport: i0, type: MapPlateComponent, decorators: [{
|
|
1183
1223
|
type: Component,
|
|
@@ -1188,6 +1228,7 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "15.2.10", ngImpo
|
|
|
1188
1228
|
MapClickService,
|
|
1189
1229
|
MapFeatureService,
|
|
1190
1230
|
DrawingService,
|
|
1231
|
+
DrawingGenerationService,
|
|
1191
1232
|
], template: "<ng-content></ng-content>\r\n<lib-osm-tile-layer *ngIf=\"osmUrl && map\" [map]=\"map\" [url]=\"osmUrl\"></lib-osm-tile-layer>\r\n<lib-feature-layer *ngIf=\"map\" [settings]=\"drawingLayerSettings\"></lib-feature-layer>\r\n", styles: ["lib-map-plate{position:relative;display:flex;flex-direction:column;height:100%}\n"] }]
|
|
1192
1233
|
}], ctorParameters: function () { return [{ type: i0.ElementRef }, { type: MapPostboyService }, { type: MapPlateFactory }, { type: MessageRegistratorService }, { type: i0.ChangeDetectorRef }]; }, propDecorators: { settings: [{
|
|
1193
1234
|
type: Input
|
|
@@ -1461,6 +1502,57 @@ class TextStyleHelper {
|
|
|
1461
1502
|
}
|
|
1462
1503
|
}
|
|
1463
1504
|
|
|
1505
|
+
class StringifyFeatureHelper {
|
|
1506
|
+
static polygon(feature, format = FeatureOutputFormat.GeoJson) {
|
|
1507
|
+
return format === FeatureOutputFormat.GeoJson
|
|
1508
|
+
? new GeoJSON().writeFeature(feature)
|
|
1509
|
+
: new WKT().writeFeature(feature);
|
|
1510
|
+
}
|
|
1511
|
+
static circle(feature, format = FeatureOutputFormat.GeoJson) {
|
|
1512
|
+
// const clone = feature.clone();
|
|
1513
|
+
// clone.setGeometry(fromCircle(feature.getGeometry()! as Circle));
|
|
1514
|
+
const tetemp = feature.getGeometryName();
|
|
1515
|
+
const circle = feature.getGeometry();
|
|
1516
|
+
// const temp = StringifyFeatureHelper.drawCircle(circle.getCenter(), circle.getRadius());
|
|
1517
|
+
const ttt = feature.getGeometry().getExtent();
|
|
1518
|
+
const eastPoint = [ttt[2], (ttt[1] + ttt[3]) / 2];
|
|
1519
|
+
const aaa = [
|
|
1520
|
+
...transform([ttt[0], ttt[1]], 'EPSG:4326', 'EPSG:3857'),
|
|
1521
|
+
...transform([ttt[2], ttt[3]], 'EPSG:4326', 'EPSG:3857'),
|
|
1522
|
+
];
|
|
1523
|
+
const radius = (aaa[2] - aaa[0]) / 2;
|
|
1524
|
+
const radius2 = new LineString([circle.getCenter(), eastPoint]).getLength();
|
|
1525
|
+
const polygonGeom = new Polygon(StringifyFeatureHelper.drawCircle(circle.getCenter(), radius));
|
|
1526
|
+
// var edgeCoordinate = [circle.getCenter()[0] + radius, circle.getCenter()[1]];
|
|
1527
|
+
// var wgs84Sphere = new Sphere(6378137);
|
|
1528
|
+
return StringifyFeatureHelper.polygon(new Feature(polygonGeom), format);
|
|
1529
|
+
// const rad = circle.getRadius();
|
|
1530
|
+
// const degrees = 180 / Math.PI; // radians to degrees
|
|
1531
|
+
// const radians = Math.PI / 180; // degrees to radians
|
|
1532
|
+
// const rlat = rad * degrees * 1000;
|
|
1533
|
+
// const rlng = rad * radians;
|
|
1534
|
+
// return StringifyFeatureHelper.polygon(new Feature<Geometry>(circular(circle.getCenter(),circle.getRadius() * METERS_PER_UNIT)), format);
|
|
1535
|
+
}
|
|
1536
|
+
static drawCircle(point, radius) {
|
|
1537
|
+
const tetetemp = transform(point, 'EPSG:4326', 'EPSG:3857');
|
|
1538
|
+
// const tetetemp = point;
|
|
1539
|
+
const radians = Math.PI / 180; // degrees to radians
|
|
1540
|
+
const degrees = 180 / Math.PI; // radians to degrees
|
|
1541
|
+
const earthsradius = 6378137.0;
|
|
1542
|
+
const rlat = (radius / earthsradius) * degrees;
|
|
1543
|
+
const rlng = rlat / Math.cos(tetetemp[1] * radians);
|
|
1544
|
+
const extp = [];
|
|
1545
|
+
for (let i = 0; i <= 32; i++) {
|
|
1546
|
+
const theta = Math.PI * (i / 16);
|
|
1547
|
+
extp.push([
|
|
1548
|
+
tetetemp[0] + rlng * Math.cos(theta) * METERS_PER_UNIT,
|
|
1549
|
+
tetetemp[1] + rlat * Math.sin(theta) * METERS_PER_UNIT,
|
|
1550
|
+
]);
|
|
1551
|
+
}
|
|
1552
|
+
return [extp.map((e) => transform(e, 'EPSG:3857', 'EPSG:4326'))];
|
|
1553
|
+
}
|
|
1554
|
+
}
|
|
1555
|
+
|
|
1464
1556
|
/*
|
|
1465
1557
|
* Public API Surface of maps
|
|
1466
1558
|
*/
|
|
@@ -1473,5 +1565,5 @@ class TextStyleHelper {
|
|
|
1473
1565
|
* Generated bundle index. Do not edit.
|
|
1474
1566
|
*/
|
|
1475
1567
|
|
|
1476
|
-
export { CancelDrawingCommand, CloseTooltipCommand, ClusterLayerComponent, ClusterLayerSettings, DrawingType, FeatureLayerComponent, FeatureLayerSettings, FeatureOutputFormat, MapClickEvent, MapLyrs, MapLyrsLabel, MapModule, MapMoveEndEvent, MapPlateComponent, MapPostboyService, MapRenderedEvent, MapSettings, MarkerModel, MarkerStyleHelper, MarkersComponent, MessageRegistratorService, OsmTileLayerComponent, PolygonModel, PolygonStyleHelper, PolygonsComponent, StartDrawingCommand, TextStyleHelper, TileLayerComponent, TileLayerSettings, TooltipComponent, TooltipSettings };
|
|
1568
|
+
export { CancelDrawingCommand, CloseTooltipCommand, ClusterLayerComponent, ClusterLayerSettings, DrawingType, FeatureLayerComponent, FeatureLayerSettings, FeatureOutputFormat, MapClickEvent, MapLyrs, MapLyrsLabel, MapModule, MapMoveEndEvent, MapPlateComponent, MapPostboyService, MapRenderedEvent, MapSettings, MarkerModel, MarkerStyleHelper, MarkersComponent, MessageRegistratorService, OsmTileLayerComponent, PolygonModel, PolygonStyleHelper, PolygonsComponent, StartDrawingCommand, StringifyFeatureHelper, TextStyleHelper, TileLayerComponent, TileLayerSettings, TooltipComponent, TooltipSettings };
|
|
1477
1569
|
//# sourceMappingURL=maps-components.mjs.map
|