@artstesh/maps 3.1.3 → 3.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/esm2020/map/messages/executors/calculate-area.executor.mjs +12 -0
- package/dist/esm2020/map/messages/index.mjs +2 -1
- package/dist/esm2020/map/models/polygon.model.mjs +4 -1
- package/dist/esm2020/map/services/feature.service.mjs +7 -1
- package/dist/esm2020/map/services/message-registrator.service.mjs +3 -1
- package/dist/esm2020/src/map/messages/executors/calculate-area.executor.mjs +12 -0
- package/dist/esm2020/src/map/messages/index.mjs +2 -1
- package/dist/esm2020/src/map/models/polygon.model.mjs +4 -1
- package/dist/esm2020/src/map/services/feature.service.mjs +7 -1
- package/dist/esm2020/src/map/services/message-registrator.service.mjs +3 -1
- package/dist/fesm2015/maps-components-src-map.mjs +23 -3
- package/dist/fesm2015/maps-components-src-map.mjs.map +1 -1
- package/dist/fesm2015/maps-components.mjs +23 -3
- package/dist/fesm2015/maps-components.mjs.map +1 -1
- package/dist/fesm2020/maps-components-src-map.mjs +21 -1
- package/dist/fesm2020/maps-components-src-map.mjs.map +1 -1
- package/dist/fesm2020/maps-components.mjs +21 -1
- package/dist/fesm2020/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';
|
|
@@ -156,11 +157,13 @@ class MarkerModel {
|
|
|
156
157
|
|
|
157
158
|
class PolygonModel {
|
|
158
159
|
constructor(feature, id, info) {
|
|
159
|
-
var _a;
|
|
160
|
+
var _a, _b;
|
|
160
161
|
this.info = info;
|
|
161
162
|
this.id = id == null ? IdGenerator.get() : id;
|
|
162
163
|
this._feature = feature;
|
|
163
|
-
|
|
164
|
+
if (this.info)
|
|
165
|
+
(_a = this._feature) === null || _a === void 0 ? void 0 : _a.set(MapConstants.FeatureInfo, this.info);
|
|
166
|
+
[this.lng, this.lat] = getCenter((_b = this._feature.getGeometry()) === null || _b === void 0 ? void 0 : _b.getExtent());
|
|
164
167
|
}
|
|
165
168
|
static fromGeoJson(id, json, info) {
|
|
166
169
|
let feature = new GeoJSON().readFeature(json);
|
|
@@ -405,6 +408,17 @@ class SetMapCenterCommand extends PostboyGenericMessage {
|
|
|
405
408
|
}
|
|
406
409
|
SetMapCenterCommand.ID = 'd50e89c9-6707-4f8c-ab57-65fcef232182';
|
|
407
410
|
|
|
411
|
+
class CalculateAreaExecutor extends PostboyExecutor {
|
|
412
|
+
constructor(polygon) {
|
|
413
|
+
super();
|
|
414
|
+
this.polygon = polygon;
|
|
415
|
+
}
|
|
416
|
+
get id() {
|
|
417
|
+
return CalculateAreaExecutor.ID;
|
|
418
|
+
}
|
|
419
|
+
}
|
|
420
|
+
CalculateAreaExecutor.ID = '172ecf46-86b5-4f46-a5f1-96ba2cbb1694';
|
|
421
|
+
|
|
408
422
|
class AddLayerCommand extends PostboyGenericMessage {
|
|
409
423
|
constructor(layer) {
|
|
410
424
|
super();
|
|
@@ -530,6 +544,11 @@ class FeatureService {
|
|
|
530
544
|
return g1.intersectsCoordinate(g2.getInteriorPoint().getCoordinates());
|
|
531
545
|
return false;
|
|
532
546
|
}
|
|
547
|
+
static calculateArea(g) {
|
|
548
|
+
if (!g)
|
|
549
|
+
return 0;
|
|
550
|
+
return Sphere.getArea(g, { projection: 'EPSG:4326' });
|
|
551
|
+
}
|
|
533
552
|
}
|
|
534
553
|
|
|
535
554
|
class GetFeaturesInAreaQuery extends PostboyCallbackMessage {
|
|
@@ -1050,6 +1069,7 @@ class MessageRegistratorService extends PostboyAbstractRegistrator {
|
|
|
1050
1069
|
}
|
|
1051
1070
|
setExecutors() {
|
|
1052
1071
|
this.registerExecutor(FilterFeaturesInAreaExecutor.ID, (e) => FeatureService.filterFeaturesInArea(e));
|
|
1072
|
+
this.registerExecutor(CalculateAreaExecutor.ID, (e) => { var _a, _b; return FeatureService.calculateArea((_b = (_a = e.polygon) === null || _a === void 0 ? void 0 : _a.feature) === null || _b === void 0 ? void 0 : _b.getGeometry()); });
|
|
1053
1073
|
this.registerExecutor(GenerateDrawExecutor.ID, (e) => DrawingGenerationService.getDraw(e));
|
|
1054
1074
|
this.registerExecutor(GenerateZoomControlExecutor.ID, (e) => ZoomControlFactory.build(e.settings));
|
|
1055
1075
|
}
|
|
@@ -2120,5 +2140,5 @@ class StringifyFeatureHelper {
|
|
|
2120
2140
|
* Generated bundle index. Do not edit.
|
|
2121
2141
|
*/
|
|
2122
2142
|
|
|
2123
|
-
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 };
|
|
2143
|
+
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 };
|
|
2124
2144
|
//# sourceMappingURL=maps-components.mjs.map
|