@artstesh/maps 5.1.3 → 5.1.5
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/messages/executors/calculate-area.executor.mjs +13 -0
- package/dist/esm2022/map/messages/index.mjs +2 -1
- package/dist/esm2022/map/models/polygon.model.mjs +4 -1
- package/dist/esm2022/map/services/feature.service.mjs +7 -1
- package/dist/esm2022/map/services/message-registrator.service.mjs +3 -1
- package/dist/esm2022/src/map/messages/executors/calculate-area.executor.mjs +13 -0
- package/dist/esm2022/src/map/messages/index.mjs +2 -1
- package/dist/esm2022/src/map/models/polygon.model.mjs +4 -1
- package/dist/esm2022/src/map/services/feature.service.mjs +7 -1
- package/dist/esm2022/src/map/services/message-registrator.service.mjs +3 -1
- package/dist/fesm2022/maps-components-src-map.mjs +22 -1
- package/dist/fesm2022/maps-components-src-map.mjs.map +1 -1
- package/dist/fesm2022/maps-components.mjs +22 -1
- package/dist/fesm2022/maps-components.mjs.map +1 -1
- package/dist/map/messages/executors/calculate-area.executor.d.ts +10 -0
- package/dist/map/messages/index.d.ts +1 -0
- package/dist/map/services/feature.service.d.ts +1 -0
- package/dist/src/map/messages/executors/calculate-area.executor.d.ts +10 -0
- package/dist/src/map/messages/index.d.ts +1 -0
- package/dist/src/map/services/feature.service.d.ts +1 -0
- package/package.json +1 -1
|
@@ -11,6 +11,7 @@ import { get, useGeographic, transform } from 'ol/proj';
|
|
|
11
11
|
import { PostboyGenericMessage, PostboyCallbackMessage, PostboyExecutor, PostboyService, PostboyAbstractRegistrator } from '@artstesh/postboy';
|
|
12
12
|
import { Draw, Modify, Translate } from 'ol/interaction';
|
|
13
13
|
import { createRegularPolygon, createBox } from 'ol/interaction/Draw';
|
|
14
|
+
import * as Sphere from 'ol/sphere';
|
|
14
15
|
import { first, filter, auditTime } from 'rxjs/operators';
|
|
15
16
|
import { Vector, XYZ } from 'ol/source';
|
|
16
17
|
import TileLayer from 'ol/layer/Tile';
|
|
@@ -176,6 +177,8 @@ class PolygonModel {
|
|
|
176
177
|
this.info = info;
|
|
177
178
|
this.id = id == null ? IdGenerator.get() : id;
|
|
178
179
|
this._feature = feature;
|
|
180
|
+
if (this.info)
|
|
181
|
+
this._feature?.set(MapConstants.FeatureInfo, this.info);
|
|
179
182
|
[this.lng, this.lat] = getCenter(this._feature.getGeometry()?.getExtent());
|
|
180
183
|
}
|
|
181
184
|
get feature() {
|
|
@@ -430,6 +433,18 @@ class SetMapCenterCommand extends PostboyGenericMessage {
|
|
|
430
433
|
}
|
|
431
434
|
}
|
|
432
435
|
|
|
436
|
+
class CalculateAreaExecutor extends PostboyExecutor {
|
|
437
|
+
polygon;
|
|
438
|
+
static ID = '172ecf46-86b5-4f46-a5f1-96ba2cbb1694';
|
|
439
|
+
constructor(polygon) {
|
|
440
|
+
super();
|
|
441
|
+
this.polygon = polygon;
|
|
442
|
+
}
|
|
443
|
+
get id() {
|
|
444
|
+
return CalculateAreaExecutor.ID;
|
|
445
|
+
}
|
|
446
|
+
}
|
|
447
|
+
|
|
433
448
|
class AddLayerCommand extends PostboyGenericMessage {
|
|
434
449
|
layer;
|
|
435
450
|
static ID = 'd93e250f-92bc-43ac-9c6a-46c521a1aaa5';
|
|
@@ -564,6 +579,11 @@ class FeatureService {
|
|
|
564
579
|
return g1.intersectsCoordinate(g2.getInteriorPoint().getCoordinates());
|
|
565
580
|
return false;
|
|
566
581
|
}
|
|
582
|
+
static calculateArea(g) {
|
|
583
|
+
if (!g)
|
|
584
|
+
return 0;
|
|
585
|
+
return Sphere.getArea(g, { projection: 'EPSG:4326' });
|
|
586
|
+
}
|
|
567
587
|
}
|
|
568
588
|
|
|
569
589
|
class GetFeaturesInAreaQuery extends PostboyCallbackMessage {
|
|
@@ -1095,6 +1115,7 @@ class MessageRegistratorService extends PostboyAbstractRegistrator {
|
|
|
1095
1115
|
}
|
|
1096
1116
|
setExecutors() {
|
|
1097
1117
|
this.registerExecutor(FilterFeaturesInAreaExecutor.ID, (e) => FeatureService.filterFeaturesInArea(e));
|
|
1118
|
+
this.registerExecutor(CalculateAreaExecutor.ID, (e) => FeatureService.calculateArea(e.polygon?.feature?.getGeometry()));
|
|
1098
1119
|
this.registerExecutor(GenerateDrawExecutor.ID, (e) => DrawingGenerationService.getDraw(e));
|
|
1099
1120
|
this.registerExecutor(GenerateZoomControlExecutor.ID, (e) => ZoomControlFactory.build(e.settings));
|
|
1100
1121
|
}
|
|
@@ -2183,5 +2204,5 @@ class StringifyFeatureHelper {
|
|
|
2183
2204
|
* Generated bundle index. Do not edit.
|
|
2184
2205
|
*/
|
|
2185
2206
|
|
|
2186
|
-
export { AddControlCommand, CancelDrawingCommand, CancelFeatureModificationCommand, CloseTooltipCommand, ClusterLayerComponent, ClusterLayerSettings, Dictionary, DrawSelectionAreaCommand, DrawingType, FeatureLayerComponent, FeatureLayerSettings, FeatureOutputFormat, MapClickEvent, MapControl, MapControlZoomComponent, MapLyrs, MapLyrsLabel, MapModule, MapMoveEndEvent, MapPlateComponent, MapPostboyService, MapRenderedEvent, MapSettings, MarkerModel, MarkerStyleHelper, MarkersComponent, MessageRegistratorService, ModifyFeatureCommand, OsmTileLayerComponent, PolygonModel, PolygonStyleHelper, PolygonsComponent, RemoveControlCommand, SetMapCenterCommand, StartDrawingCommand, StringifyFeatureHelper, TextStyleHelper, TileLayerComponent, TileLayerSettings, TooltipComponent, TooltipSettings, ZoomControlSettings };
|
|
2207
|
+
export { AddControlCommand, CalculateAreaExecutor, CancelDrawingCommand, CancelFeatureModificationCommand, CloseTooltipCommand, ClusterLayerComponent, ClusterLayerSettings, Dictionary, DrawSelectionAreaCommand, DrawingType, FeatureLayerComponent, FeatureLayerSettings, FeatureOutputFormat, MapClickEvent, MapControl, MapControlZoomComponent, MapLyrs, MapLyrsLabel, MapModule, MapMoveEndEvent, MapPlateComponent, MapPostboyService, MapRenderedEvent, MapSettings, MarkerModel, MarkerStyleHelper, MarkersComponent, MessageRegistratorService, ModifyFeatureCommand, OsmTileLayerComponent, PolygonModel, PolygonStyleHelper, PolygonsComponent, RemoveControlCommand, SetMapCenterCommand, StartDrawingCommand, StringifyFeatureHelper, TextStyleHelper, TileLayerComponent, TileLayerSettings, TooltipComponent, TooltipSettings, ZoomControlSettings };
|
|
2187
2208
|
//# sourceMappingURL=maps-components.mjs.map
|