@artstesh/maps 5.1.4 → 5.1.6
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/map-settings.mjs +2 -2
- 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/map-settings.mjs +2 -2
- 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 +21 -2
- package/dist/fesm2022/maps-components-src-map.mjs.map +1 -1
- package/dist/fesm2022/maps-components.mjs +21 -2
- 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';
|
|
@@ -108,7 +109,7 @@ class MapSettings {
|
|
|
108
109
|
return false;
|
|
109
110
|
if (this.language !== model.language)
|
|
110
111
|
return false;
|
|
111
|
-
return this.center.length
|
|
112
|
+
return this.center.length === model.center.length && !this.center.filter((c, i) => c !== model.center[i]).length;
|
|
112
113
|
}
|
|
113
114
|
}
|
|
114
115
|
|
|
@@ -432,6 +433,18 @@ class SetMapCenterCommand extends PostboyGenericMessage {
|
|
|
432
433
|
}
|
|
433
434
|
}
|
|
434
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
|
+
|
|
435
448
|
class AddLayerCommand extends PostboyGenericMessage {
|
|
436
449
|
layer;
|
|
437
450
|
static ID = 'd93e250f-92bc-43ac-9c6a-46c521a1aaa5';
|
|
@@ -566,6 +579,11 @@ class FeatureService {
|
|
|
566
579
|
return g1.intersectsCoordinate(g2.getInteriorPoint().getCoordinates());
|
|
567
580
|
return false;
|
|
568
581
|
}
|
|
582
|
+
static calculateArea(g) {
|
|
583
|
+
if (!g)
|
|
584
|
+
return 0;
|
|
585
|
+
return Sphere.getArea(g, { projection: 'EPSG:4326' });
|
|
586
|
+
}
|
|
569
587
|
}
|
|
570
588
|
|
|
571
589
|
class GetFeaturesInAreaQuery extends PostboyCallbackMessage {
|
|
@@ -1097,6 +1115,7 @@ class MessageRegistratorService extends PostboyAbstractRegistrator {
|
|
|
1097
1115
|
}
|
|
1098
1116
|
setExecutors() {
|
|
1099
1117
|
this.registerExecutor(FilterFeaturesInAreaExecutor.ID, (e) => FeatureService.filterFeaturesInArea(e));
|
|
1118
|
+
this.registerExecutor(CalculateAreaExecutor.ID, (e) => FeatureService.calculateArea(e.polygon?.feature?.getGeometry()));
|
|
1100
1119
|
this.registerExecutor(GenerateDrawExecutor.ID, (e) => DrawingGenerationService.getDraw(e));
|
|
1101
1120
|
this.registerExecutor(GenerateZoomControlExecutor.ID, (e) => ZoomControlFactory.build(e.settings));
|
|
1102
1121
|
}
|
|
@@ -2185,5 +2204,5 @@ class StringifyFeatureHelper {
|
|
|
2185
2204
|
* Generated bundle index. Do not edit.
|
|
2186
2205
|
*/
|
|
2187
2206
|
|
|
2188
|
-
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 };
|
|
2189
2208
|
//# sourceMappingURL=maps-components.mjs.map
|