@artstesh/maps 5.0.8 → 5.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/esm2022/map/helpers/index.mjs +2 -1
- package/dist/esm2022/map/helpers/stringify-feature.helper.mjs +58 -0
- package/dist/esm2022/map/map-plate/map-plate.component.mjs +4 -1
- package/dist/esm2022/map/messages/queries/generate-draw.query.mjs +17 -0
- package/dist/esm2022/map/models/drawing-type.enum.mjs +2 -1
- package/dist/esm2022/map/services/drawing/drawing-generation.service.mjs +29 -0
- package/dist/esm2022/map/services/drawing/drawing.service.mjs +13 -13
- package/dist/esm2022/map/services/message-registrator.service.mjs +8 -5
- package/dist/esm2022/src/map/helpers/index.mjs +2 -1
- package/dist/esm2022/src/map/helpers/stringify-feature.helper.mjs +58 -0
- package/dist/esm2022/src/map/map-plate/map-plate.component.mjs +4 -1
- package/dist/esm2022/src/map/messages/queries/generate-draw.query.mjs +17 -0
- package/dist/esm2022/src/map/models/drawing-type.enum.mjs +2 -1
- package/dist/esm2022/src/map/services/drawing/drawing-generation.service.mjs +29 -0
- package/dist/esm2022/src/map/services/drawing/drawing.service.mjs +13 -13
- package/dist/esm2022/src/map/services/message-registrator.service.mjs +8 -5
- package/dist/fesm2022/maps-components-src-map.mjs +113 -18
- package/dist/fesm2022/maps-components-src-map.mjs.map +1 -1
- package/dist/fesm2022/maps-components.mjs +113 -18
- package/dist/fesm2022/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
|
subs = [];
|
|
@@ -183,6 +185,7 @@ class PolygonModel {
|
|
|
183
185
|
var DrawingType;
|
|
184
186
|
(function (DrawingType) {
|
|
185
187
|
DrawingType[DrawingType["Polygon"] = 1] = "Polygon";
|
|
188
|
+
DrawingType[DrawingType["Circle"] = 2] = "Circle";
|
|
186
189
|
})(DrawingType || (DrawingType = {}));
|
|
187
190
|
|
|
188
191
|
var FeatureOutputFormat;
|
|
@@ -366,6 +369,22 @@ class DrawingFinishedEvent extends PostboyGenericMessage {
|
|
|
366
369
|
}
|
|
367
370
|
}
|
|
368
371
|
|
|
372
|
+
class GenerateDrawQuery extends PostboyCallbackMessage {
|
|
373
|
+
layer;
|
|
374
|
+
style;
|
|
375
|
+
type;
|
|
376
|
+
static ID = 'f01c99ba-0953-4ab5-82f9-04e6fbb678c1';
|
|
377
|
+
constructor(layer, style, type) {
|
|
378
|
+
super();
|
|
379
|
+
this.layer = layer;
|
|
380
|
+
this.style = style;
|
|
381
|
+
this.type = type;
|
|
382
|
+
}
|
|
383
|
+
get id() {
|
|
384
|
+
return GenerateDrawQuery.ID;
|
|
385
|
+
}
|
|
386
|
+
}
|
|
387
|
+
|
|
369
388
|
class MapPostboyService extends PostboyService {
|
|
370
389
|
constructor() {
|
|
371
390
|
super();
|
|
@@ -571,17 +590,17 @@ class DrawingService {
|
|
|
571
590
|
this.clearInteraction(l);
|
|
572
591
|
return;
|
|
573
592
|
}
|
|
574
|
-
const
|
|
575
|
-
|
|
576
|
-
|
|
577
|
-
|
|
578
|
-
|
|
579
|
-
|
|
580
|
-
|
|
581
|
-
|
|
582
|
-
|
|
583
|
-
this.onEnd(evt, ev, l);
|
|
593
|
+
const drawQuery = new GenerateDrawQuery(l, ev.style, ev.type);
|
|
594
|
+
drawQuery.result.subscribe((draw) => {
|
|
595
|
+
const cancelSub = this.observeCancelation(ev, l);
|
|
596
|
+
this.drawInteraction = draw;
|
|
597
|
+
this.map?.addInteraction(this.drawInteraction);
|
|
598
|
+
this.drawInteraction.on('drawend', (evt) => {
|
|
599
|
+
cancelSub.unsubscribe();
|
|
600
|
+
this.onEnd(evt, ev, l);
|
|
601
|
+
});
|
|
584
602
|
});
|
|
603
|
+
this.postboy.fire(drawQuery);
|
|
585
604
|
});
|
|
586
605
|
});
|
|
587
606
|
this.observeMapRender();
|
|
@@ -625,10 +644,32 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "16.2.12", ngImpo
|
|
|
625
644
|
type: Injectable
|
|
626
645
|
}], ctorParameters: function () { return [{ type: MapPostboyService }]; } });
|
|
627
646
|
|
|
647
|
+
class DrawingGenerationService {
|
|
648
|
+
postboy;
|
|
649
|
+
constructor(postboy) {
|
|
650
|
+
this.postboy = postboy;
|
|
651
|
+
}
|
|
652
|
+
up() {
|
|
653
|
+
this.postboy.subscribe(GenerateDrawQuery.ID).subscribe((ev) => {
|
|
654
|
+
ev.finish(new Draw({
|
|
655
|
+
source: ev.layer.getSource(),
|
|
656
|
+
type: DrawingType[ev.type],
|
|
657
|
+
style: ev.style,
|
|
658
|
+
geometryFunction: ev.type !== DrawingType.Circle ? undefined : createRegularPolygon(32),
|
|
659
|
+
}));
|
|
660
|
+
});
|
|
661
|
+
}
|
|
662
|
+
static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "16.2.12", ngImport: i0, type: DrawingGenerationService, deps: [{ token: MapPostboyService }], target: i0.ɵɵFactoryTarget.Injectable });
|
|
663
|
+
static ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "16.2.12", ngImport: i0, type: DrawingGenerationService });
|
|
664
|
+
}
|
|
665
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "16.2.12", ngImport: i0, type: DrawingGenerationService, decorators: [{
|
|
666
|
+
type: Injectable
|
|
667
|
+
}], ctorParameters: function () { return [{ type: MapPostboyService }]; } });
|
|
668
|
+
|
|
628
669
|
class MessageRegistratorService extends PostboyAbstractRegistrator {
|
|
629
|
-
constructor(service, management, state, feature, interaction, drawing) {
|
|
670
|
+
constructor(service, management, state, feature, interaction, drawing, drawGenerator) {
|
|
630
671
|
super(service);
|
|
631
|
-
this.registerServices([management, state, interaction, feature, drawing]);
|
|
672
|
+
this.registerServices([management, state, interaction, feature, drawing, drawGenerator]);
|
|
632
673
|
}
|
|
633
674
|
_up() {
|
|
634
675
|
this.registerReplay(MapRenderedEvent.ID);
|
|
@@ -645,13 +686,14 @@ class MessageRegistratorService extends PostboyAbstractRegistrator {
|
|
|
645
686
|
this.registerSubject(StartDrawingCommand.ID);
|
|
646
687
|
this.registerSubject(GetLayerQuery.ID);
|
|
647
688
|
this.registerSubject(DrawingFinishedEvent.ID);
|
|
689
|
+
this.registerSubject(GenerateDrawQuery.ID);
|
|
648
690
|
}
|
|
649
|
-
static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "16.2.12", ngImport: i0, type: MessageRegistratorService, deps: [{ token: MapPostboyService }, { token: MapManagementService }, { token: MapStateService }, { token: MapFeatureService }, { token: MapClickService }, { token: DrawingService }], target: i0.ɵɵFactoryTarget.Injectable });
|
|
691
|
+
static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "16.2.12", ngImport: i0, type: MessageRegistratorService, deps: [{ token: MapPostboyService }, { token: MapManagementService }, { token: MapStateService }, { token: MapFeatureService }, { token: MapClickService }, { token: DrawingService }, { token: DrawingGenerationService }], target: i0.ɵɵFactoryTarget.Injectable });
|
|
650
692
|
static ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "16.2.12", ngImport: i0, type: MessageRegistratorService });
|
|
651
693
|
}
|
|
652
694
|
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "16.2.12", ngImport: i0, type: MessageRegistratorService, decorators: [{
|
|
653
695
|
type: Injectable
|
|
654
|
-
}], ctorParameters: function () { return [{ type: MapPostboyService }, { type: MapManagementService }, { type: MapStateService }, { type: MapFeatureService }, { type: MapClickService }, { type: DrawingService }]; } });
|
|
696
|
+
}], ctorParameters: function () { return [{ type: MapPostboyService }, { type: MapManagementService }, { type: MapStateService }, { type: MapFeatureService }, { type: MapClickService }, { type: DrawingService }, { type: DrawingGenerationService }]; } });
|
|
655
697
|
|
|
656
698
|
class TileLayerSettings {
|
|
657
699
|
maxZoom = 19;
|
|
@@ -1216,6 +1258,7 @@ class MapPlateComponent extends DestructibleComponent {
|
|
|
1216
1258
|
MapClickService,
|
|
1217
1259
|
MapFeatureService,
|
|
1218
1260
|
DrawingService,
|
|
1261
|
+
DrawingGenerationService,
|
|
1219
1262
|
], 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 });
|
|
1220
1263
|
}
|
|
1221
1264
|
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "16.2.12", ngImport: i0, type: MapPlateComponent, decorators: [{
|
|
@@ -1227,6 +1270,7 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "16.2.12", ngImpo
|
|
|
1227
1270
|
MapClickService,
|
|
1228
1271
|
MapFeatureService,
|
|
1229
1272
|
DrawingService,
|
|
1273
|
+
DrawingGenerationService,
|
|
1230
1274
|
], 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"] }]
|
|
1231
1275
|
}], ctorParameters: function () { return [{ type: i0.ElementRef }, { type: MapPostboyService }, { type: MapPlateFactory }, { type: MessageRegistratorService }, { type: i0.ChangeDetectorRef }]; }, propDecorators: { settings: [{
|
|
1232
1276
|
type: Input
|
|
@@ -1504,6 +1548,57 @@ class TextStyleHelper {
|
|
|
1504
1548
|
}
|
|
1505
1549
|
}
|
|
1506
1550
|
|
|
1551
|
+
class StringifyFeatureHelper {
|
|
1552
|
+
static polygon(feature, format = FeatureOutputFormat.GeoJson) {
|
|
1553
|
+
return format === FeatureOutputFormat.GeoJson
|
|
1554
|
+
? new GeoJSON().writeFeature(feature)
|
|
1555
|
+
: new WKT().writeFeature(feature);
|
|
1556
|
+
}
|
|
1557
|
+
static circle(feature, format = FeatureOutputFormat.GeoJson) {
|
|
1558
|
+
// const clone = feature.clone();
|
|
1559
|
+
// clone.setGeometry(fromCircle(feature.getGeometry()! as Circle));
|
|
1560
|
+
const tetemp = feature.getGeometryName();
|
|
1561
|
+
const circle = feature.getGeometry();
|
|
1562
|
+
// const temp = StringifyFeatureHelper.drawCircle(circle.getCenter(), circle.getRadius());
|
|
1563
|
+
const ttt = feature.getGeometry().getExtent();
|
|
1564
|
+
const eastPoint = [ttt[2], (ttt[1] + ttt[3]) / 2];
|
|
1565
|
+
const aaa = [
|
|
1566
|
+
...transform([ttt[0], ttt[1]], 'EPSG:4326', 'EPSG:3857'),
|
|
1567
|
+
...transform([ttt[2], ttt[3]], 'EPSG:4326', 'EPSG:3857'),
|
|
1568
|
+
];
|
|
1569
|
+
const radius = (aaa[2] - aaa[0]) / 2;
|
|
1570
|
+
const radius2 = new LineString([circle.getCenter(), eastPoint]).getLength();
|
|
1571
|
+
const polygonGeom = new Polygon(StringifyFeatureHelper.drawCircle(circle.getCenter(), radius));
|
|
1572
|
+
// var edgeCoordinate = [circle.getCenter()[0] + radius, circle.getCenter()[1]];
|
|
1573
|
+
// var wgs84Sphere = new Sphere(6378137);
|
|
1574
|
+
return StringifyFeatureHelper.polygon(new Feature(polygonGeom), format);
|
|
1575
|
+
// const rad = circle.getRadius();
|
|
1576
|
+
// const degrees = 180 / Math.PI; // radians to degrees
|
|
1577
|
+
// const radians = Math.PI / 180; // degrees to radians
|
|
1578
|
+
// const rlat = rad * degrees * 1000;
|
|
1579
|
+
// const rlng = rad * radians;
|
|
1580
|
+
// return StringifyFeatureHelper.polygon(new Feature<Geometry>(circular(circle.getCenter(),circle.getRadius() * METERS_PER_UNIT)), format);
|
|
1581
|
+
}
|
|
1582
|
+
static drawCircle(point, radius) {
|
|
1583
|
+
const tetetemp = transform(point, 'EPSG:4326', 'EPSG:3857');
|
|
1584
|
+
// const tetetemp = point;
|
|
1585
|
+
const radians = Math.PI / 180; // degrees to radians
|
|
1586
|
+
const degrees = 180 / Math.PI; // radians to degrees
|
|
1587
|
+
const earthsradius = 6378137.0;
|
|
1588
|
+
const rlat = (radius / earthsradius) * degrees;
|
|
1589
|
+
const rlng = rlat / Math.cos(tetetemp[1] * radians);
|
|
1590
|
+
const extp = [];
|
|
1591
|
+
for (let i = 0; i <= 32; i++) {
|
|
1592
|
+
const theta = Math.PI * (i / 16);
|
|
1593
|
+
extp.push([
|
|
1594
|
+
tetetemp[0] + rlng * Math.cos(theta) * METERS_PER_UNIT,
|
|
1595
|
+
tetetemp[1] + rlat * Math.sin(theta) * METERS_PER_UNIT,
|
|
1596
|
+
]);
|
|
1597
|
+
}
|
|
1598
|
+
return [extp.map((e) => transform(e, 'EPSG:3857', 'EPSG:4326'))];
|
|
1599
|
+
}
|
|
1600
|
+
}
|
|
1601
|
+
|
|
1507
1602
|
/*
|
|
1508
1603
|
* Public API Surface of maps
|
|
1509
1604
|
*/
|
|
@@ -1516,5 +1611,5 @@ class TextStyleHelper {
|
|
|
1516
1611
|
* Generated bundle index. Do not edit.
|
|
1517
1612
|
*/
|
|
1518
1613
|
|
|
1519
|
-
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 };
|
|
1614
|
+
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 };
|
|
1520
1615
|
//# sourceMappingURL=maps-components.mjs.map
|