@artstesh/maps 4.0.8 → 4.0.10
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 +7 -1
- package/dist/esm2020/map/messages/commands/draw-selection-area.command.mjs +14 -0
- package/dist/esm2020/map/messages/index.mjs +2 -1
- package/dist/esm2020/map/messages/queries/filter-features-in-area.query.mjs +13 -0
- package/dist/esm2020/map/messages/queries/generate-draw.query.mjs +14 -0
- package/dist/esm2020/map/messages/queries/get-features-in-area.query.mjs +13 -0
- package/dist/esm2020/map/models/dictionary.mjs +56 -0
- package/dist/esm2020/map/models/drawing-type.enum.mjs +2 -1
- package/dist/esm2020/map/models/index.mjs +2 -1
- package/dist/esm2020/map/services/drawing/drawing-generation.service.mjs +28 -0
- package/dist/esm2020/map/services/drawing/drawing.service.mjs +36 -14
- package/dist/esm2020/map/services/feature.service.mjs +29 -0
- package/dist/esm2020/map/services/map-management.service.mjs +36 -7
- package/dist/esm2020/map/services/message-registrator.service.mjs +15 -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 +7 -1
- package/dist/esm2020/src/map/messages/commands/draw-selection-area.command.mjs +14 -0
- package/dist/esm2020/src/map/messages/index.mjs +2 -1
- package/dist/esm2020/src/map/messages/queries/filter-features-in-area.query.mjs +13 -0
- package/dist/esm2020/src/map/messages/queries/generate-draw.query.mjs +14 -0
- package/dist/esm2020/src/map/messages/queries/get-features-in-area.query.mjs +13 -0
- package/dist/esm2020/src/map/models/dictionary.mjs +56 -0
- package/dist/esm2020/src/map/models/drawing-type.enum.mjs +2 -1
- package/dist/esm2020/src/map/models/index.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 +36 -14
- package/dist/esm2020/src/map/services/feature.service.mjs +29 -0
- package/dist/esm2020/src/map/services/map-management.service.mjs +36 -7
- package/dist/esm2020/src/map/services/message-registrator.service.mjs +15 -5
- package/dist/fesm2015/maps-components-src-map.mjs +286 -28
- package/dist/fesm2015/maps-components-src-map.mjs.map +1 -1
- package/dist/fesm2015/maps-components.mjs +286 -28
- package/dist/fesm2015/maps-components.mjs.map +1 -1
- package/dist/fesm2020/maps-components-src-map.mjs +284 -27
- package/dist/fesm2020/maps-components-src-map.mjs.map +1 -1
- package/dist/fesm2020/maps-components.mjs +284 -27
- 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/commands/draw-selection-area.command.d.ts +12 -0
- package/dist/map/messages/index.d.ts +1 -0
- package/dist/map/messages/queries/filter-features-in-area.query.d.ts +10 -0
- package/dist/map/messages/queries/generate-draw.query.d.ts +14 -0
- package/dist/map/messages/queries/get-features-in-area.query.d.ts +11 -0
- package/dist/map/models/dictionary.d.ts +17 -0
- package/dist/map/models/drawing-type.enum.d.ts +2 -1
- package/dist/map/models/index.d.ts +1 -0
- package/dist/map/services/drawing/drawing-generation.service.d.ts +10 -0
- package/dist/map/services/drawing/drawing.service.d.ts +2 -0
- package/dist/map/services/feature.service.d.ts +11 -0
- package/dist/map/services/map-management.service.d.ts +1 -0
- package/dist/map/services/message-registrator.service.d.ts +3 -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/commands/draw-selection-area.command.d.ts +12 -0
- package/dist/src/map/messages/index.d.ts +1 -0
- package/dist/src/map/messages/queries/filter-features-in-area.query.d.ts +10 -0
- package/dist/src/map/messages/queries/generate-draw.query.d.ts +14 -0
- package/dist/src/map/messages/queries/get-features-in-area.query.d.ts +11 -0
- package/dist/src/map/models/dictionary.d.ts +17 -0
- package/dist/src/map/models/drawing-type.enum.d.ts +2 -1
- package/dist/src/map/models/index.d.ts +1 -0
- package/dist/src/map/services/drawing/drawing-generation.service.d.ts +10 -0
- package/dist/src/map/services/drawing/drawing.service.d.ts +2 -0
- package/dist/src/map/services/feature.service.d.ts +11 -0
- package/dist/src/map/services/map-management.service.d.ts +1 -0
- package/dist/src/map/services/message-registrator.service.d.ts +3 -1
- package/package.json +2 -2
|
@@ -3,26 +3,28 @@ 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
|
-
import {
|
|
11
|
+
import { forkJoin, combineLatest } from 'rxjs';
|
|
12
|
+
import { tap, first, filter, auditTime } from 'rxjs/operators';
|
|
12
13
|
import { Vector, XYZ } from 'ol/source';
|
|
13
14
|
import { Draw } from 'ol/interaction';
|
|
15
|
+
import { createRegularPolygon } from 'ol/interaction/Draw';
|
|
14
16
|
import TileLayer from 'ol/layer/Tile';
|
|
15
17
|
import OSM from 'ol/source/OSM';
|
|
16
18
|
import { Vector as Vector$1 } from 'ol/layer';
|
|
17
19
|
import { bbox } from 'ol/loadingstrategy';
|
|
18
|
-
import { fromExtent } from 'ol/geom/Polygon';
|
|
20
|
+
import Polygon, { fromExtent } from 'ol/geom/Polygon';
|
|
19
21
|
import Cluster from 'ol/source/Cluster';
|
|
20
|
-
import { combineLatest } from 'rxjs';
|
|
21
22
|
import Map from 'ol/Map';
|
|
22
23
|
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() {
|
|
@@ -176,6 +178,7 @@ class PolygonModel {
|
|
|
176
178
|
var DrawingType;
|
|
177
179
|
(function (DrawingType) {
|
|
178
180
|
DrawingType[DrawingType["Polygon"] = 1] = "Polygon";
|
|
181
|
+
DrawingType[DrawingType["Circle"] = 2] = "Circle";
|
|
179
182
|
})(DrawingType || (DrawingType = {}));
|
|
180
183
|
|
|
181
184
|
var FeatureOutputFormat;
|
|
@@ -184,6 +187,62 @@ var FeatureOutputFormat;
|
|
|
184
187
|
FeatureOutputFormat[FeatureOutputFormat["WKT"] = 2] = "WKT";
|
|
185
188
|
})(FeatureOutputFormat || (FeatureOutputFormat = {}));
|
|
186
189
|
|
|
190
|
+
class Dictionary {
|
|
191
|
+
constructor() {
|
|
192
|
+
this.collection = {};
|
|
193
|
+
this._keys = new Set();
|
|
194
|
+
this.has = (key) => this._keys.has(key);
|
|
195
|
+
}
|
|
196
|
+
get keys() {
|
|
197
|
+
return Array.from(this._keys);
|
|
198
|
+
}
|
|
199
|
+
get size() {
|
|
200
|
+
return this._keys.size;
|
|
201
|
+
}
|
|
202
|
+
static clone(dic, action) {
|
|
203
|
+
return Dictionary.create(dic.collection, action);
|
|
204
|
+
}
|
|
205
|
+
static create(dic, action) {
|
|
206
|
+
let keyList = Object.keys(dic);
|
|
207
|
+
const result = new Dictionary();
|
|
208
|
+
for (let i = 0; i < keyList.length; i++) {
|
|
209
|
+
let key = keyList[i];
|
|
210
|
+
result._keys.add(key);
|
|
211
|
+
result.collection[key] = action ? action(dic[key], key) : dic[key];
|
|
212
|
+
}
|
|
213
|
+
return result;
|
|
214
|
+
}
|
|
215
|
+
find(predicate) {
|
|
216
|
+
let result = null;
|
|
217
|
+
this.forEach((e) => {
|
|
218
|
+
if (result === null && predicate(e))
|
|
219
|
+
result = e;
|
|
220
|
+
});
|
|
221
|
+
return result;
|
|
222
|
+
}
|
|
223
|
+
take(key) {
|
|
224
|
+
return this._keys.has(key) ? this.collection[key] : null;
|
|
225
|
+
}
|
|
226
|
+
put(key, value) {
|
|
227
|
+
if (value == null)
|
|
228
|
+
return;
|
|
229
|
+
this.collection[key] = value;
|
|
230
|
+
this._keys.add(key);
|
|
231
|
+
}
|
|
232
|
+
rmv(key) {
|
|
233
|
+
if (!this._keys.has(key))
|
|
234
|
+
return;
|
|
235
|
+
delete this.collection[key];
|
|
236
|
+
this._keys.delete(key);
|
|
237
|
+
}
|
|
238
|
+
forEach(callback) {
|
|
239
|
+
let keys = Object.keys(this.collection);
|
|
240
|
+
for (let i = 0; i < keys.length; i++) {
|
|
241
|
+
callback(this.collection[keys[i]], i);
|
|
242
|
+
}
|
|
243
|
+
}
|
|
244
|
+
}
|
|
245
|
+
|
|
187
246
|
class MapRenderedEvent extends PostboyGenericMessage {
|
|
188
247
|
constructor(map) {
|
|
189
248
|
super();
|
|
@@ -251,6 +310,19 @@ class CancelDrawingCommand extends PostboyGenericMessage {
|
|
|
251
310
|
}
|
|
252
311
|
CancelDrawingCommand.ID = '7d38d983-feba-4176-a66b-18175e5ecd6b';
|
|
253
312
|
|
|
313
|
+
class DrawSelectionAreaCommand extends PostboyCallbackMessage {
|
|
314
|
+
constructor(type, style, ignore = new Set()) {
|
|
315
|
+
super();
|
|
316
|
+
this.type = type;
|
|
317
|
+
this.style = style;
|
|
318
|
+
this.ignore = ignore;
|
|
319
|
+
}
|
|
320
|
+
get id() {
|
|
321
|
+
return DrawSelectionAreaCommand.ID;
|
|
322
|
+
}
|
|
323
|
+
}
|
|
324
|
+
DrawSelectionAreaCommand.ID = '573d8a0d-f25b-42b7-9ad7-0ac6d86ac362';
|
|
325
|
+
|
|
254
326
|
class AddLayerCommand extends PostboyGenericMessage {
|
|
255
327
|
constructor(layer) {
|
|
256
328
|
super();
|
|
@@ -340,6 +412,43 @@ class DrawingFinishedEvent extends PostboyGenericMessage {
|
|
|
340
412
|
}
|
|
341
413
|
DrawingFinishedEvent.ID = 'c724b68e-b4eb-4783-90f1-a8e31973fd36';
|
|
342
414
|
|
|
415
|
+
class GenerateDrawQuery extends PostboyCallbackMessage {
|
|
416
|
+
constructor(layer, style, type) {
|
|
417
|
+
super();
|
|
418
|
+
this.layer = layer;
|
|
419
|
+
this.style = style;
|
|
420
|
+
this.type = type;
|
|
421
|
+
}
|
|
422
|
+
get id() {
|
|
423
|
+
return GenerateDrawQuery.ID;
|
|
424
|
+
}
|
|
425
|
+
}
|
|
426
|
+
GenerateDrawQuery.ID = 'f01c99ba-0953-4ab5-82f9-04e6fbb678c1';
|
|
427
|
+
|
|
428
|
+
class FilterFeaturesInAreaQuery extends PostboyCallbackMessage {
|
|
429
|
+
constructor(area, features) {
|
|
430
|
+
super();
|
|
431
|
+
this.area = area;
|
|
432
|
+
this.features = features;
|
|
433
|
+
}
|
|
434
|
+
get id() {
|
|
435
|
+
return FilterFeaturesInAreaQuery.ID;
|
|
436
|
+
}
|
|
437
|
+
}
|
|
438
|
+
FilterFeaturesInAreaQuery.ID = '36bb2d94-8028-4512-90dd-2386af3fc67c';
|
|
439
|
+
|
|
440
|
+
class GetFeaturesInAreaQuery extends PostboyCallbackMessage {
|
|
441
|
+
constructor(area, ignore = new Set()) {
|
|
442
|
+
super();
|
|
443
|
+
this.area = area;
|
|
444
|
+
this.ignore = ignore;
|
|
445
|
+
}
|
|
446
|
+
get id() {
|
|
447
|
+
return GetFeaturesInAreaQuery.ID;
|
|
448
|
+
}
|
|
449
|
+
}
|
|
450
|
+
GetFeaturesInAreaQuery.ID = 'efcf4271-a07a-40e0-9f02-d4dade40b8ac';
|
|
451
|
+
|
|
343
452
|
class MapPostboyService extends PostboyService {
|
|
344
453
|
constructor() {
|
|
345
454
|
super();
|
|
@@ -355,7 +464,7 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "15.2.10", ngImpo
|
|
|
355
464
|
class MapManagementService {
|
|
356
465
|
constructor(postboy) {
|
|
357
466
|
this.postboy = postboy;
|
|
358
|
-
this.layers =
|
|
467
|
+
this.layers = new Dictionary();
|
|
359
468
|
}
|
|
360
469
|
up() {
|
|
361
470
|
this.observeMapRender();
|
|
@@ -365,6 +474,7 @@ class MapManagementService {
|
|
|
365
474
|
this.observeAddTile();
|
|
366
475
|
this.observeRemoveTile();
|
|
367
476
|
this.observeLayerQuery();
|
|
477
|
+
this.observeFeaturesInArea();
|
|
368
478
|
}
|
|
369
479
|
observeRemoveTile() {
|
|
370
480
|
this.postboy.subscribe(RemoveTileCommand.ID).subscribe((c) => {
|
|
@@ -374,7 +484,7 @@ class MapManagementService {
|
|
|
374
484
|
});
|
|
375
485
|
}
|
|
376
486
|
observeLayerQuery() {
|
|
377
|
-
this.postboy.subscribe(GetLayerQuery.ID).subscribe((ev) => ev.finish(this.layers
|
|
487
|
+
this.postboy.subscribe(GetLayerQuery.ID).subscribe((ev) => ev.finish(this.layers.take(ev.name)));
|
|
378
488
|
}
|
|
379
489
|
observeAddTile() {
|
|
380
490
|
this.postboy.subscribe(AddTileCommand.ID).subscribe((c) => {
|
|
@@ -392,15 +502,15 @@ class MapManagementService {
|
|
|
392
502
|
this.postboy.subscribe(AddLayerCommand.ID).subscribe((c) => {
|
|
393
503
|
if (!this.map)
|
|
394
504
|
return;
|
|
395
|
-
this.layers
|
|
505
|
+
this.layers.put(c.layer.get('name'), c.layer);
|
|
396
506
|
this.map.addLayer(c.layer);
|
|
397
507
|
});
|
|
398
508
|
}
|
|
399
509
|
observePlaceFeatures() {
|
|
400
510
|
this.postboy.subscribe(PlaceLayerFeaturesCommand.ID).subscribe((c) => {
|
|
401
|
-
if (!this.layers
|
|
511
|
+
if (!this.layers.has(c.layer))
|
|
402
512
|
return;
|
|
403
|
-
let source = this.layers
|
|
513
|
+
let source = this.layers.take(c.layer).getSource();
|
|
404
514
|
if (!!source['getSource'])
|
|
405
515
|
source = source?.getSource();
|
|
406
516
|
source?.clear();
|
|
@@ -411,10 +521,32 @@ class MapManagementService {
|
|
|
411
521
|
this.postboy.subscribe(RemoveLayerCommand.ID).subscribe((c) => {
|
|
412
522
|
if (!this.map)
|
|
413
523
|
return;
|
|
414
|
-
|
|
524
|
+
this.layers.rmv(c.layer.get('name'));
|
|
415
525
|
this.map.removeLayer(c.layer);
|
|
416
526
|
});
|
|
417
527
|
}
|
|
528
|
+
observeFeaturesInArea() {
|
|
529
|
+
this.postboy.subscribe(GetFeaturesInAreaQuery.ID).subscribe((qr) => {
|
|
530
|
+
let result = new Dictionary();
|
|
531
|
+
const queue = [];
|
|
532
|
+
const queries = [];
|
|
533
|
+
this.layers.forEach((l) => {
|
|
534
|
+
let layerName = l.get('name');
|
|
535
|
+
if (qr.ignore.has(layerName) || layerName === MapConstants.DrawingLayerId)
|
|
536
|
+
return;
|
|
537
|
+
let source = l.getSource();
|
|
538
|
+
if (!!source['getSource'])
|
|
539
|
+
source = source?.getSource();
|
|
540
|
+
const query = new FilterFeaturesInAreaQuery(qr.area, source?.getFeatures() ?? []);
|
|
541
|
+
queue.push(query.result.pipe(tap((r) => {
|
|
542
|
+
result.put(l.get('name'), r.map((e) => ({ id: e.getId(), ...e.get(MapConstants.FeatureInfo) })));
|
|
543
|
+
})));
|
|
544
|
+
queries.push(query);
|
|
545
|
+
});
|
|
546
|
+
forkJoin(queue).subscribe(() => qr.finish(result));
|
|
547
|
+
queries.forEach((q) => this.postboy.fire(q));
|
|
548
|
+
});
|
|
549
|
+
}
|
|
418
550
|
}
|
|
419
551
|
MapManagementService.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "15.2.10", ngImport: i0, type: MapManagementService, deps: [{ token: MapPostboyService }], target: i0.ɵɵFactoryTarget.Injectable });
|
|
420
552
|
MapManagementService.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "15.2.10", ngImport: i0, type: MapManagementService });
|
|
@@ -528,26 +660,46 @@ class DrawingService {
|
|
|
528
660
|
this.postboy = postboy;
|
|
529
661
|
}
|
|
530
662
|
up() {
|
|
663
|
+
this.observeDrawing();
|
|
664
|
+
this.observeSelectArea();
|
|
665
|
+
this.observeMapRender();
|
|
666
|
+
}
|
|
667
|
+
observeSelectArea() {
|
|
668
|
+
this.postboy.subscribe(DrawSelectionAreaCommand.ID).subscribe((ev) => {
|
|
669
|
+
const drawingCommand = new StartDrawingCommand(ev.type, ev.style);
|
|
670
|
+
drawingCommand.result.subscribe((r) => {
|
|
671
|
+
if (!r) {
|
|
672
|
+
ev.finish(new Dictionary());
|
|
673
|
+
return;
|
|
674
|
+
}
|
|
675
|
+
const area = PolygonModel.fromGeoJson(1, r).feature.getGeometry();
|
|
676
|
+
const getFeaturesCommand = new GetFeaturesInAreaQuery(area, ev.ignore);
|
|
677
|
+
getFeaturesCommand.result.subscribe((result) => ev.finish(result));
|
|
678
|
+
this.postboy.fire(getFeaturesCommand);
|
|
679
|
+
});
|
|
680
|
+
this.postboy.fire(drawingCommand);
|
|
681
|
+
});
|
|
682
|
+
}
|
|
683
|
+
observeDrawing() {
|
|
531
684
|
this.postboy.subscribe(StartDrawingCommand.ID).subscribe((ev) => {
|
|
532
685
|
this.draw((l) => {
|
|
533
686
|
if (!l || !this.map) {
|
|
534
687
|
this.clearInteraction(l);
|
|
535
688
|
return;
|
|
536
689
|
}
|
|
537
|
-
const
|
|
538
|
-
|
|
539
|
-
|
|
540
|
-
|
|
541
|
-
|
|
542
|
-
|
|
543
|
-
|
|
544
|
-
|
|
545
|
-
|
|
546
|
-
this.onEnd(evt, ev, l);
|
|
690
|
+
const drawQuery = new GenerateDrawQuery(l, ev.style, ev.type);
|
|
691
|
+
drawQuery.result.subscribe((draw) => {
|
|
692
|
+
const cancelSub = this.observeCancelation(ev, l);
|
|
693
|
+
this.drawInteraction = draw;
|
|
694
|
+
this.map?.addInteraction(this.drawInteraction);
|
|
695
|
+
this.drawInteraction.on('drawend', (evt) => {
|
|
696
|
+
cancelSub.unsubscribe();
|
|
697
|
+
this.onEnd(evt, ev, l);
|
|
698
|
+
});
|
|
547
699
|
});
|
|
700
|
+
this.postboy.fire(drawQuery);
|
|
548
701
|
});
|
|
549
702
|
});
|
|
550
|
-
this.observeMapRender();
|
|
551
703
|
}
|
|
552
704
|
onEnd(evt, command, layer) {
|
|
553
705
|
command.finish(command.format === FeatureOutputFormat.GeoJson
|
|
@@ -588,10 +740,56 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "15.2.10", ngImpo
|
|
|
588
740
|
type: Injectable
|
|
589
741
|
}], ctorParameters: function () { return [{ type: MapPostboyService }]; } });
|
|
590
742
|
|
|
743
|
+
class DrawingGenerationService {
|
|
744
|
+
constructor(postboy) {
|
|
745
|
+
this.postboy = postboy;
|
|
746
|
+
}
|
|
747
|
+
up() {
|
|
748
|
+
this.postboy.subscribe(GenerateDrawQuery.ID).subscribe((ev) => {
|
|
749
|
+
ev.finish(new Draw({
|
|
750
|
+
source: ev.layer.getSource(),
|
|
751
|
+
type: DrawingType[ev.type],
|
|
752
|
+
style: ev.style,
|
|
753
|
+
geometryFunction: ev.type !== DrawingType.Circle ? undefined : createRegularPolygon(32),
|
|
754
|
+
}));
|
|
755
|
+
});
|
|
756
|
+
}
|
|
757
|
+
}
|
|
758
|
+
DrawingGenerationService.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "15.2.10", ngImport: i0, type: DrawingGenerationService, deps: [{ token: MapPostboyService }], target: i0.ɵɵFactoryTarget.Injectable });
|
|
759
|
+
DrawingGenerationService.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "15.2.10", ngImport: i0, type: DrawingGenerationService });
|
|
760
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "15.2.10", ngImport: i0, type: DrawingGenerationService, decorators: [{
|
|
761
|
+
type: Injectable
|
|
762
|
+
}], ctorParameters: function () { return [{ type: MapPostboyService }]; } });
|
|
763
|
+
|
|
764
|
+
class FeatureService {
|
|
765
|
+
constructor(postboy) {
|
|
766
|
+
this.postboy = postboy;
|
|
767
|
+
}
|
|
768
|
+
up() {
|
|
769
|
+
this.postboy.subscribe(FilterFeaturesInAreaQuery.ID).subscribe((qr) => {
|
|
770
|
+
qr.finish(qr.features.filter((f) => FeatureService.booleanIntersects(qr.area, f.getGeometry())));
|
|
771
|
+
});
|
|
772
|
+
}
|
|
773
|
+
static booleanIntersects(g1, g2) {
|
|
774
|
+
if (g2.getType() === 'Point')
|
|
775
|
+
return g1.intersectsCoordinate(g2.getCoordinates());
|
|
776
|
+
if (g2.getType() === 'Circle')
|
|
777
|
+
return g1.intersectsCoordinate(g2.getCenter());
|
|
778
|
+
if (g2.getType() === 'Polygon')
|
|
779
|
+
return g1.intersectsCoordinate(g2.getInteriorPoint().getCoordinates());
|
|
780
|
+
return false;
|
|
781
|
+
}
|
|
782
|
+
}
|
|
783
|
+
FeatureService.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "15.2.10", ngImport: i0, type: FeatureService, deps: [{ token: MapPostboyService }], target: i0.ɵɵFactoryTarget.Injectable });
|
|
784
|
+
FeatureService.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "15.2.10", ngImport: i0, type: FeatureService });
|
|
785
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "15.2.10", ngImport: i0, type: FeatureService, decorators: [{
|
|
786
|
+
type: Injectable
|
|
787
|
+
}], ctorParameters: function () { return [{ type: MapPostboyService }]; } });
|
|
788
|
+
|
|
591
789
|
class MessageRegistratorService extends PostboyAbstractRegistrator {
|
|
592
|
-
constructor(service, management, state,
|
|
790
|
+
constructor(service, management, state, mapFeature, interaction, drawing, drawGenerator, feature) {
|
|
593
791
|
super(service);
|
|
594
|
-
this.registerServices([management, state, interaction,
|
|
792
|
+
this.registerServices([management, state, interaction, mapFeature, drawing, drawGenerator, feature]);
|
|
595
793
|
}
|
|
596
794
|
_up() {
|
|
597
795
|
this.registerReplay(MapRenderedEvent.ID);
|
|
@@ -608,13 +806,17 @@ class MessageRegistratorService extends PostboyAbstractRegistrator {
|
|
|
608
806
|
this.registerSubject(StartDrawingCommand.ID);
|
|
609
807
|
this.registerSubject(GetLayerQuery.ID);
|
|
610
808
|
this.registerSubject(DrawingFinishedEvent.ID);
|
|
809
|
+
this.registerSubject(GenerateDrawQuery.ID);
|
|
810
|
+
this.registerSubject(FilterFeaturesInAreaQuery.ID);
|
|
811
|
+
this.registerSubject(GetFeaturesInAreaQuery.ID);
|
|
812
|
+
this.registerSubject(DrawSelectionAreaCommand.ID);
|
|
611
813
|
}
|
|
612
814
|
}
|
|
613
|
-
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 });
|
|
815
|
+
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 }, { token: FeatureService }], target: i0.ɵɵFactoryTarget.Injectable });
|
|
614
816
|
MessageRegistratorService.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "15.2.10", ngImport: i0, type: MessageRegistratorService });
|
|
615
817
|
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "15.2.10", ngImport: i0, type: MessageRegistratorService, decorators: [{
|
|
616
818
|
type: Injectable
|
|
617
|
-
}], ctorParameters: function () { return [{ type: MapPostboyService }, { type: MapManagementService }, { type: MapStateService }, { type: MapFeatureService }, { type: MapClickService }, { type: DrawingService }]; } });
|
|
819
|
+
}], ctorParameters: function () { return [{ type: MapPostboyService }, { type: MapManagementService }, { type: MapStateService }, { type: MapFeatureService }, { type: MapClickService }, { type: DrawingService }, { type: DrawingGenerationService }, { type: FeatureService }]; } });
|
|
618
820
|
|
|
619
821
|
class TileLayerSettings {
|
|
620
822
|
constructor() {
|
|
@@ -1166,6 +1368,8 @@ MapPlateComponent.ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "14.0.0", vers
|
|
|
1166
1368
|
MapClickService,
|
|
1167
1369
|
MapFeatureService,
|
|
1168
1370
|
DrawingService,
|
|
1371
|
+
DrawingGenerationService,
|
|
1372
|
+
FeatureService,
|
|
1169
1373
|
], 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 });
|
|
1170
1374
|
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "15.2.10", ngImport: i0, type: MapPlateComponent, decorators: [{
|
|
1171
1375
|
type: Component,
|
|
@@ -1176,6 +1380,8 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "15.2.10", ngImpo
|
|
|
1176
1380
|
MapClickService,
|
|
1177
1381
|
MapFeatureService,
|
|
1178
1382
|
DrawingService,
|
|
1383
|
+
DrawingGenerationService,
|
|
1384
|
+
FeatureService,
|
|
1179
1385
|
], 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"] }]
|
|
1180
1386
|
}], ctorParameters: function () { return [{ type: i0.ElementRef }, { type: MapPostboyService }, { type: MapPlateFactory }, { type: MessageRegistratorService }, { type: i0.ChangeDetectorRef }]; }, propDecorators: { settings: [{
|
|
1181
1387
|
type: Input
|
|
@@ -1445,6 +1651,57 @@ class TextStyleHelper {
|
|
|
1445
1651
|
}
|
|
1446
1652
|
}
|
|
1447
1653
|
|
|
1654
|
+
class StringifyFeatureHelper {
|
|
1655
|
+
static polygon(feature, format = FeatureOutputFormat.GeoJson) {
|
|
1656
|
+
return format === FeatureOutputFormat.GeoJson
|
|
1657
|
+
? new GeoJSON().writeFeature(feature)
|
|
1658
|
+
: new WKT().writeFeature(feature);
|
|
1659
|
+
}
|
|
1660
|
+
static circle(feature, format = FeatureOutputFormat.GeoJson) {
|
|
1661
|
+
// const clone = feature.clone();
|
|
1662
|
+
// clone.setGeometry(fromCircle(feature.getGeometry()! as Circle));
|
|
1663
|
+
const tetemp = feature.getGeometryName();
|
|
1664
|
+
const circle = feature.getGeometry();
|
|
1665
|
+
// const temp = StringifyFeatureHelper.drawCircle(circle.getCenter(), circle.getRadius());
|
|
1666
|
+
const ttt = feature.getGeometry().getExtent();
|
|
1667
|
+
const eastPoint = [ttt[2], (ttt[1] + ttt[3]) / 2];
|
|
1668
|
+
const aaa = [
|
|
1669
|
+
...transform([ttt[0], ttt[1]], 'EPSG:4326', 'EPSG:3857'),
|
|
1670
|
+
...transform([ttt[2], ttt[3]], 'EPSG:4326', 'EPSG:3857'),
|
|
1671
|
+
];
|
|
1672
|
+
const radius = (aaa[2] - aaa[0]) / 2;
|
|
1673
|
+
const radius2 = new LineString([circle.getCenter(), eastPoint]).getLength();
|
|
1674
|
+
const polygonGeom = new Polygon(StringifyFeatureHelper.drawCircle(circle.getCenter(), radius));
|
|
1675
|
+
// var edgeCoordinate = [circle.getCenter()[0] + radius, circle.getCenter()[1]];
|
|
1676
|
+
// var wgs84Sphere = new Sphere(6378137);
|
|
1677
|
+
return StringifyFeatureHelper.polygon(new Feature(polygonGeom), format);
|
|
1678
|
+
// const rad = circle.getRadius();
|
|
1679
|
+
// const degrees = 180 / Math.PI; // radians to degrees
|
|
1680
|
+
// const radians = Math.PI / 180; // degrees to radians
|
|
1681
|
+
// const rlat = rad * degrees * 1000;
|
|
1682
|
+
// const rlng = rad * radians;
|
|
1683
|
+
// return StringifyFeatureHelper.polygon(new Feature<Geometry>(circular(circle.getCenter(),circle.getRadius() * METERS_PER_UNIT)), format);
|
|
1684
|
+
}
|
|
1685
|
+
static drawCircle(point, radius) {
|
|
1686
|
+
const tetetemp = transform(point, 'EPSG:4326', 'EPSG:3857');
|
|
1687
|
+
// const tetetemp = point;
|
|
1688
|
+
const radians = Math.PI / 180; // degrees to radians
|
|
1689
|
+
const degrees = 180 / Math.PI; // radians to degrees
|
|
1690
|
+
const earthsradius = 6378137.0;
|
|
1691
|
+
const rlat = (radius / earthsradius) * degrees;
|
|
1692
|
+
const rlng = rlat / Math.cos(tetetemp[1] * radians);
|
|
1693
|
+
const extp = [];
|
|
1694
|
+
for (let i = 0; i <= 32; i++) {
|
|
1695
|
+
const theta = Math.PI * (i / 16);
|
|
1696
|
+
extp.push([
|
|
1697
|
+
tetetemp[0] + rlng * Math.cos(theta) * METERS_PER_UNIT,
|
|
1698
|
+
tetetemp[1] + rlat * Math.sin(theta) * METERS_PER_UNIT,
|
|
1699
|
+
]);
|
|
1700
|
+
}
|
|
1701
|
+
return [extp.map((e) => transform(e, 'EPSG:3857', 'EPSG:4326'))];
|
|
1702
|
+
}
|
|
1703
|
+
}
|
|
1704
|
+
|
|
1448
1705
|
/*
|
|
1449
1706
|
* Public API Surface of maps
|
|
1450
1707
|
*/
|
|
@@ -1453,5 +1710,5 @@ class TextStyleHelper {
|
|
|
1453
1710
|
* Generated bundle index. Do not edit.
|
|
1454
1711
|
*/
|
|
1455
1712
|
|
|
1456
|
-
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 };
|
|
1713
|
+
export { CancelDrawingCommand, CloseTooltipCommand, ClusterLayerComponent, ClusterLayerSettings, Dictionary, DrawSelectionAreaCommand, 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 };
|
|
1457
1714
|
//# sourceMappingURL=maps-components-src-map.mjs.map
|