@artstesh/maps 5.0.9 → 5.0.11
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/polygon-style.helper.mjs +19 -2
- package/dist/esm2022/map/map-plate/map-plate.component.mjs +7 -1
- package/dist/esm2022/map/messages/commands/cancel-feature-modification.command.mjs +8 -0
- package/dist/esm2022/map/messages/commands/draw-selection-area.command.mjs +17 -0
- package/dist/esm2022/map/messages/commands/modify-feature.command.mjs +18 -0
- package/dist/esm2022/map/messages/executors/filter-features-in-area.executor.mjs +15 -0
- package/dist/esm2022/map/messages/executors/generate-draw.executor.mjs +17 -0
- package/dist/esm2022/map/messages/index.mjs +4 -1
- package/dist/esm2022/map/messages/queries/get-features-in-area.query.mjs +15 -0
- package/dist/esm2022/map/models/dictionary.mjs +54 -0
- package/dist/esm2022/map/models/drawing-type.enum.mjs +2 -1
- package/dist/esm2022/map/models/index.mjs +2 -1
- package/dist/esm2022/map/services/drawing/drawing-generation.service.mjs +16 -22
- package/dist/esm2022/map/services/drawing/drawing.service.mjs +32 -14
- package/dist/esm2022/map/services/drawing/feature-modification.service.mjs +103 -0
- package/dist/esm2022/map/services/feature.service.mjs +16 -0
- package/dist/esm2022/map/services/map-management.service.mjs +28 -7
- package/dist/esm2022/map/services/message-registrator.service.mjs +23 -8
- package/dist/esm2022/src/map/helpers/polygon-style.helper.mjs +19 -2
- package/dist/esm2022/src/map/map-plate/map-plate.component.mjs +7 -1
- package/dist/esm2022/src/map/messages/commands/cancel-feature-modification.command.mjs +8 -0
- package/dist/esm2022/src/map/messages/commands/draw-selection-area.command.mjs +17 -0
- package/dist/esm2022/src/map/messages/commands/modify-feature.command.mjs +18 -0
- package/dist/esm2022/src/map/messages/executors/filter-features-in-area.executor.mjs +15 -0
- package/dist/esm2022/src/map/messages/executors/generate-draw.executor.mjs +17 -0
- package/dist/esm2022/src/map/messages/index.mjs +4 -1
- package/dist/esm2022/src/map/messages/queries/get-features-in-area.query.mjs +15 -0
- package/dist/esm2022/src/map/models/dictionary.mjs +54 -0
- package/dist/esm2022/src/map/models/drawing-type.enum.mjs +2 -1
- package/dist/esm2022/src/map/models/index.mjs +2 -1
- package/dist/esm2022/src/map/services/drawing/drawing-generation.service.mjs +16 -22
- package/dist/esm2022/src/map/services/drawing/drawing.service.mjs +32 -14
- package/dist/esm2022/src/map/services/drawing/feature-modification.service.mjs +103 -0
- package/dist/esm2022/src/map/services/feature.service.mjs +16 -0
- package/dist/esm2022/src/map/services/map-management.service.mjs +28 -7
- package/dist/esm2022/src/map/services/message-registrator.service.mjs +23 -8
- package/dist/fesm2022/maps-components-src-map.mjs +328 -40
- package/dist/fesm2022/maps-components-src-map.mjs.map +1 -1
- package/dist/fesm2022/maps-components.mjs +328 -40
- package/dist/fesm2022/maps-components.mjs.map +1 -1
- package/dist/map/helpers/polygon-style.helper.d.ts +1 -0
- package/dist/map/messages/commands/cancel-feature-modification.command.d.ts +5 -0
- package/dist/map/messages/commands/draw-selection-area.command.d.ts +12 -0
- package/dist/map/messages/commands/modify-feature.command.d.ts +11 -0
- package/dist/map/messages/executors/filter-features-in-area.executor.d.ts +10 -0
- package/dist/map/messages/{queries/generate-draw.query.d.ts → executors/generate-draw.executor.d.ts} +2 -2
- package/dist/map/messages/index.d.ts +3 -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 +5 -9
- package/dist/map/services/drawing/drawing.service.d.ts +2 -0
- package/dist/map/services/drawing/feature-modification.service.d.ts +22 -0
- package/dist/map/services/feature.service.d.ts +8 -0
- package/dist/map/services/map-management.service.d.ts +1 -0
- package/dist/map/services/message-registrator.service.d.ts +3 -2
- package/dist/package.json +1 -1
- package/dist/src/map/helpers/polygon-style.helper.d.ts +1 -0
- package/dist/src/map/messages/commands/cancel-feature-modification.command.d.ts +5 -0
- package/dist/src/map/messages/commands/draw-selection-area.command.d.ts +12 -0
- package/dist/src/map/messages/commands/modify-feature.command.d.ts +11 -0
- package/dist/src/map/messages/executors/filter-features-in-area.executor.d.ts +10 -0
- package/dist/src/map/messages/{queries/generate-draw.query.d.ts → executors/generate-draw.executor.d.ts} +2 -2
- package/dist/src/map/messages/index.d.ts +3 -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 +5 -9
- package/dist/src/map/services/drawing/drawing.service.d.ts +2 -0
- package/dist/src/map/services/drawing/feature-modification.service.d.ts +22 -0
- package/dist/src/map/services/feature.service.d.ts +8 -0
- package/dist/src/map/services/map-management.service.d.ts +1 -0
- package/dist/src/map/services/message-registrator.service.d.ts +3 -2
- package/package.json +2 -2
- package/dist/esm2022/map/messages/queries/generate-draw.query.mjs +0 -17
- package/dist/esm2022/src/map/messages/queries/generate-draw.query.mjs +0 -17
|
@@ -2,16 +2,16 @@ import * as i0 from '@angular/core';
|
|
|
2
2
|
import { Component, Injectable, ChangeDetectionStrategy, Input, ViewChild, NgModule } from '@angular/core';
|
|
3
3
|
import * as i4 from '@angular/common';
|
|
4
4
|
import { CommonModule } from '@angular/common';
|
|
5
|
-
import { Feature } from 'ol';
|
|
5
|
+
import { Feature, Collection } from 'ol';
|
|
6
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
9
|
import { get, useGeographic, transform } from 'ol/proj';
|
|
10
|
-
import { PostboyGenericMessage, PostboyCallbackMessage, PostboyService, PostboyAbstractRegistrator } from '@artstesh/postboy';
|
|
10
|
+
import { PostboyGenericMessage, PostboyCallbackMessage, PostboyExecutor, PostboyService, PostboyAbstractRegistrator } from '@artstesh/postboy';
|
|
11
|
+
import { Draw, Modify, Translate } from 'ol/interaction';
|
|
12
|
+
import { createRegularPolygon } from 'ol/interaction/Draw';
|
|
11
13
|
import { first, filter, auditTime } from 'rxjs/operators';
|
|
12
14
|
import { Vector, XYZ } from 'ol/source';
|
|
13
|
-
import { Draw } from 'ol/interaction';
|
|
14
|
-
import { createRegularPolygon } from 'ol/interaction/Draw';
|
|
15
15
|
import TileLayer from 'ol/layer/Tile';
|
|
16
16
|
import OSM from 'ol/source/OSM';
|
|
17
17
|
import { Vector as Vector$1 } from 'ol/layer';
|
|
@@ -186,6 +186,7 @@ var DrawingType;
|
|
|
186
186
|
(function (DrawingType) {
|
|
187
187
|
DrawingType[DrawingType["Polygon"] = 1] = "Polygon";
|
|
188
188
|
DrawingType[DrawingType["Circle"] = 2] = "Circle";
|
|
189
|
+
DrawingType[DrawingType["Square"] = 3] = "Square";
|
|
189
190
|
})(DrawingType || (DrawingType = {}));
|
|
190
191
|
|
|
191
192
|
var FeatureOutputFormat;
|
|
@@ -194,6 +195,60 @@ var FeatureOutputFormat;
|
|
|
194
195
|
FeatureOutputFormat[FeatureOutputFormat["WKT"] = 2] = "WKT";
|
|
195
196
|
})(FeatureOutputFormat || (FeatureOutputFormat = {}));
|
|
196
197
|
|
|
198
|
+
class Dictionary {
|
|
199
|
+
collection = {};
|
|
200
|
+
_keys = new Set();
|
|
201
|
+
get keys() {
|
|
202
|
+
return Array.from(this._keys);
|
|
203
|
+
}
|
|
204
|
+
get size() {
|
|
205
|
+
return this._keys.size;
|
|
206
|
+
}
|
|
207
|
+
static clone(dic, action) {
|
|
208
|
+
return Dictionary.create(dic.collection, action);
|
|
209
|
+
}
|
|
210
|
+
static create(dic, action) {
|
|
211
|
+
let keyList = Object.keys(dic);
|
|
212
|
+
const result = new Dictionary();
|
|
213
|
+
for (let i = 0; i < keyList.length; i++) {
|
|
214
|
+
let key = keyList[i];
|
|
215
|
+
result._keys.add(key);
|
|
216
|
+
result.collection[key] = action ? action(dic[key], key) : dic[key];
|
|
217
|
+
}
|
|
218
|
+
return result;
|
|
219
|
+
}
|
|
220
|
+
find(predicate) {
|
|
221
|
+
let result = null;
|
|
222
|
+
this.forEach((e) => {
|
|
223
|
+
if (result === null && predicate(e))
|
|
224
|
+
result = e;
|
|
225
|
+
});
|
|
226
|
+
return result;
|
|
227
|
+
}
|
|
228
|
+
has = (key) => this._keys.has(key);
|
|
229
|
+
take(key) {
|
|
230
|
+
return this._keys.has(key) ? this.collection[key] : null;
|
|
231
|
+
}
|
|
232
|
+
put(key, value) {
|
|
233
|
+
if (value == null)
|
|
234
|
+
return;
|
|
235
|
+
this.collection[key] = value;
|
|
236
|
+
this._keys.add(key);
|
|
237
|
+
}
|
|
238
|
+
rmv(key) {
|
|
239
|
+
if (!this._keys.has(key))
|
|
240
|
+
return;
|
|
241
|
+
delete this.collection[key];
|
|
242
|
+
this._keys.delete(key);
|
|
243
|
+
}
|
|
244
|
+
forEach(callback) {
|
|
245
|
+
let keys = Object.keys(this.collection);
|
|
246
|
+
for (let i = 0; i < keys.length; i++) {
|
|
247
|
+
callback(this.collection[keys[i]], i);
|
|
248
|
+
}
|
|
249
|
+
}
|
|
250
|
+
}
|
|
251
|
+
|
|
197
252
|
class MapRenderedEvent extends PostboyGenericMessage {
|
|
198
253
|
map;
|
|
199
254
|
static ID = 'b6121807-3b89-4cd3-82cf-089d2cefdc4f';
|
|
@@ -271,6 +326,45 @@ class CancelDrawingCommand extends PostboyGenericMessage {
|
|
|
271
326
|
}
|
|
272
327
|
}
|
|
273
328
|
|
|
329
|
+
class DrawSelectionAreaCommand extends PostboyCallbackMessage {
|
|
330
|
+
type;
|
|
331
|
+
style;
|
|
332
|
+
ignore;
|
|
333
|
+
static ID = '573d8a0d-f25b-42b7-9ad7-0ac6d86ac362';
|
|
334
|
+
constructor(type, style, ignore = new Set()) {
|
|
335
|
+
super();
|
|
336
|
+
this.type = type;
|
|
337
|
+
this.style = style;
|
|
338
|
+
this.ignore = ignore;
|
|
339
|
+
}
|
|
340
|
+
get id() {
|
|
341
|
+
return DrawSelectionAreaCommand.ID;
|
|
342
|
+
}
|
|
343
|
+
}
|
|
344
|
+
|
|
345
|
+
class ModifyFeatureCommand extends PostboyCallbackMessage {
|
|
346
|
+
model;
|
|
347
|
+
style;
|
|
348
|
+
format;
|
|
349
|
+
static ID = 'ead85caa-24c6-4844-a68c-2cea91774c8c';
|
|
350
|
+
constructor(model, style, format = FeatureOutputFormat.GeoJson) {
|
|
351
|
+
super();
|
|
352
|
+
this.model = model;
|
|
353
|
+
this.style = style;
|
|
354
|
+
this.format = format;
|
|
355
|
+
}
|
|
356
|
+
get id() {
|
|
357
|
+
return ModifyFeatureCommand.ID;
|
|
358
|
+
}
|
|
359
|
+
}
|
|
360
|
+
|
|
361
|
+
class CancelFeatureModificationCommand extends PostboyGenericMessage {
|
|
362
|
+
static ID = '9c9fb40f-ea95-4704-8177-0e9ecabf36fa';
|
|
363
|
+
get id() {
|
|
364
|
+
return CancelFeatureModificationCommand.ID;
|
|
365
|
+
}
|
|
366
|
+
}
|
|
367
|
+
|
|
274
368
|
class AddLayerCommand extends PostboyGenericMessage {
|
|
275
369
|
layer;
|
|
276
370
|
static ID = 'd93e250f-92bc-43ac-9c6a-46c521a1aaa5';
|
|
@@ -369,7 +463,71 @@ class DrawingFinishedEvent extends PostboyGenericMessage {
|
|
|
369
463
|
}
|
|
370
464
|
}
|
|
371
465
|
|
|
372
|
-
class
|
|
466
|
+
class DrawingGenerationService {
|
|
467
|
+
static getDraw(ev) {
|
|
468
|
+
return new Draw({
|
|
469
|
+
source: ev.layer.getSource(),
|
|
470
|
+
type: ev.type === DrawingType.Polygon ? 'Polygon' : 'Circle',
|
|
471
|
+
style: ev.style,
|
|
472
|
+
geometryFunction: DrawingGenerationService.geometryFunc(ev.type),
|
|
473
|
+
});
|
|
474
|
+
}
|
|
475
|
+
static geometryFunc(type) {
|
|
476
|
+
switch (type) {
|
|
477
|
+
case DrawingType.Circle:
|
|
478
|
+
return createRegularPolygon(32);
|
|
479
|
+
case DrawingType.Square:
|
|
480
|
+
return createRegularPolygon(4);
|
|
481
|
+
}
|
|
482
|
+
return undefined;
|
|
483
|
+
}
|
|
484
|
+
}
|
|
485
|
+
|
|
486
|
+
class FeatureService {
|
|
487
|
+
constructor() { }
|
|
488
|
+
static filterFeaturesInArea(query) {
|
|
489
|
+
return query.features.filter((f) => FeatureService.booleanIntersects(query.area, f.getGeometry()));
|
|
490
|
+
}
|
|
491
|
+
static booleanIntersects(g1, g2) {
|
|
492
|
+
if (g2.getType() === 'Point')
|
|
493
|
+
return g1.intersectsCoordinate(g2.getCoordinates());
|
|
494
|
+
if (g2.getType() === 'Circle')
|
|
495
|
+
return g1.intersectsCoordinate(g2.getCenter());
|
|
496
|
+
if (g2.getType() === 'Polygon')
|
|
497
|
+
return g1.intersectsCoordinate(g2.getInteriorPoint().getCoordinates());
|
|
498
|
+
return false;
|
|
499
|
+
}
|
|
500
|
+
}
|
|
501
|
+
|
|
502
|
+
class GetFeaturesInAreaQuery extends PostboyCallbackMessage {
|
|
503
|
+
area;
|
|
504
|
+
ignore;
|
|
505
|
+
static ID = 'efcf4271-a07a-40e0-9f02-d4dade40b8ac';
|
|
506
|
+
constructor(area, ignore = new Set()) {
|
|
507
|
+
super();
|
|
508
|
+
this.area = area;
|
|
509
|
+
this.ignore = ignore;
|
|
510
|
+
}
|
|
511
|
+
get id() {
|
|
512
|
+
return GetFeaturesInAreaQuery.ID;
|
|
513
|
+
}
|
|
514
|
+
}
|
|
515
|
+
|
|
516
|
+
class FilterFeaturesInAreaExecutor extends PostboyExecutor {
|
|
517
|
+
area;
|
|
518
|
+
features;
|
|
519
|
+
static ID = '36bb2d94-8028-4512-90dd-2386af3fc67c';
|
|
520
|
+
constructor(area, features) {
|
|
521
|
+
super();
|
|
522
|
+
this.area = area;
|
|
523
|
+
this.features = features;
|
|
524
|
+
}
|
|
525
|
+
get id() {
|
|
526
|
+
return FilterFeaturesInAreaExecutor.ID;
|
|
527
|
+
}
|
|
528
|
+
}
|
|
529
|
+
|
|
530
|
+
class GenerateDrawExecutor extends PostboyExecutor {
|
|
373
531
|
layer;
|
|
374
532
|
style;
|
|
375
533
|
type;
|
|
@@ -381,7 +539,7 @@ class GenerateDrawQuery extends PostboyCallbackMessage {
|
|
|
381
539
|
this.type = type;
|
|
382
540
|
}
|
|
383
541
|
get id() {
|
|
384
|
-
return
|
|
542
|
+
return GenerateDrawExecutor.ID;
|
|
385
543
|
}
|
|
386
544
|
}
|
|
387
545
|
|
|
@@ -400,7 +558,7 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "16.2.12", ngImpo
|
|
|
400
558
|
class MapManagementService {
|
|
401
559
|
postboy;
|
|
402
560
|
map;
|
|
403
|
-
layers =
|
|
561
|
+
layers = new Dictionary();
|
|
404
562
|
constructor(postboy) {
|
|
405
563
|
this.postboy = postboy;
|
|
406
564
|
}
|
|
@@ -412,6 +570,7 @@ class MapManagementService {
|
|
|
412
570
|
this.observeAddTile();
|
|
413
571
|
this.observeRemoveTile();
|
|
414
572
|
this.observeLayerQuery();
|
|
573
|
+
this.observeFeaturesInArea();
|
|
415
574
|
}
|
|
416
575
|
observeRemoveTile() {
|
|
417
576
|
this.postboy.subscribe(RemoveTileCommand.ID).subscribe((c) => {
|
|
@@ -421,7 +580,7 @@ class MapManagementService {
|
|
|
421
580
|
});
|
|
422
581
|
}
|
|
423
582
|
observeLayerQuery() {
|
|
424
|
-
this.postboy.subscribe(GetLayerQuery.ID).subscribe((ev) => ev.finish(this.layers
|
|
583
|
+
this.postboy.subscribe(GetLayerQuery.ID).subscribe((ev) => ev.finish(this.layers.take(ev.name)));
|
|
425
584
|
}
|
|
426
585
|
observeAddTile() {
|
|
427
586
|
this.postboy.subscribe(AddTileCommand.ID).subscribe((c) => {
|
|
@@ -439,15 +598,15 @@ class MapManagementService {
|
|
|
439
598
|
this.postboy.subscribe(AddLayerCommand.ID).subscribe((c) => {
|
|
440
599
|
if (!this.map)
|
|
441
600
|
return;
|
|
442
|
-
this.layers
|
|
601
|
+
this.layers.put(c.layer.get('name'), c.layer);
|
|
443
602
|
this.map.addLayer(c.layer);
|
|
444
603
|
});
|
|
445
604
|
}
|
|
446
605
|
observePlaceFeatures() {
|
|
447
606
|
this.postboy.subscribe(PlaceLayerFeaturesCommand.ID).subscribe((c) => {
|
|
448
|
-
if (!this.layers
|
|
607
|
+
if (!this.layers.has(c.layer))
|
|
449
608
|
return;
|
|
450
|
-
let source = this.layers
|
|
609
|
+
let source = this.layers.take(c.layer).getSource();
|
|
451
610
|
if (!!source['getSource'])
|
|
452
611
|
source = source?.getSource();
|
|
453
612
|
source?.clear();
|
|
@@ -458,10 +617,26 @@ class MapManagementService {
|
|
|
458
617
|
this.postboy.subscribe(RemoveLayerCommand.ID).subscribe((c) => {
|
|
459
618
|
if (!this.map)
|
|
460
619
|
return;
|
|
461
|
-
|
|
620
|
+
this.layers.rmv(c.layer.get('name'));
|
|
462
621
|
this.map.removeLayer(c.layer);
|
|
463
622
|
});
|
|
464
623
|
}
|
|
624
|
+
observeFeaturesInArea() {
|
|
625
|
+
this.postboy.subscribe(GetFeaturesInAreaQuery.ID).subscribe((qr) => {
|
|
626
|
+
let result = new Dictionary();
|
|
627
|
+
this.layers.forEach((l) => {
|
|
628
|
+
let layerName = l.get('name');
|
|
629
|
+
if (qr.ignore.has(layerName) || layerName === MapConstants.DrawingLayerId)
|
|
630
|
+
return;
|
|
631
|
+
let source = l.getSource();
|
|
632
|
+
if (!!source['getSource'])
|
|
633
|
+
source = source?.getSource();
|
|
634
|
+
let features = this.postboy.execute(new FilterFeaturesInAreaExecutor(qr.area, source?.getFeatures() ?? []));
|
|
635
|
+
result.put(layerName, features.map((e) => ({ id: e.getId(), ...e.get(MapConstants.FeatureInfo) })));
|
|
636
|
+
});
|
|
637
|
+
qr.finish(result);
|
|
638
|
+
});
|
|
639
|
+
}
|
|
465
640
|
static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "16.2.12", ngImport: i0, type: MapManagementService, deps: [{ token: MapPostboyService }], target: i0.ɵɵFactoryTarget.Injectable });
|
|
466
641
|
static ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "16.2.12", ngImport: i0, type: MapManagementService });
|
|
467
642
|
}
|
|
@@ -584,26 +759,42 @@ class DrawingService {
|
|
|
584
759
|
this.postboy = postboy;
|
|
585
760
|
}
|
|
586
761
|
up() {
|
|
762
|
+
this.observeDrawing();
|
|
763
|
+
this.observeSelectArea();
|
|
764
|
+
this.observeMapRender();
|
|
765
|
+
}
|
|
766
|
+
observeSelectArea() {
|
|
767
|
+
this.postboy.subscribe(DrawSelectionAreaCommand.ID).subscribe((ev) => {
|
|
768
|
+
const drawingCommand = new StartDrawingCommand(ev.type, ev.style);
|
|
769
|
+
drawingCommand.result.subscribe((r) => {
|
|
770
|
+
if (!r) {
|
|
771
|
+
ev.finish(new Dictionary());
|
|
772
|
+
return;
|
|
773
|
+
}
|
|
774
|
+
const area = PolygonModel.fromGeoJson(1, r).feature.getGeometry();
|
|
775
|
+
const getFeaturesCommand = new GetFeaturesInAreaQuery(area, ev.ignore);
|
|
776
|
+
getFeaturesCommand.result.subscribe((result) => ev.finish(result));
|
|
777
|
+
this.postboy.fire(getFeaturesCommand);
|
|
778
|
+
});
|
|
779
|
+
this.postboy.fire(drawingCommand);
|
|
780
|
+
});
|
|
781
|
+
}
|
|
782
|
+
observeDrawing() {
|
|
587
783
|
this.postboy.subscribe(StartDrawingCommand.ID).subscribe((ev) => {
|
|
588
784
|
this.draw((l) => {
|
|
589
785
|
if (!l || !this.map) {
|
|
590
786
|
this.clearInteraction(l);
|
|
591
787
|
return;
|
|
592
788
|
}
|
|
593
|
-
const
|
|
594
|
-
|
|
595
|
-
|
|
596
|
-
|
|
597
|
-
|
|
598
|
-
this.
|
|
599
|
-
cancelSub.unsubscribe();
|
|
600
|
-
this.onEnd(evt, ev, l);
|
|
601
|
-
});
|
|
789
|
+
const cancelSub = this.observeCancelation(ev, l);
|
|
790
|
+
this.drawInteraction = this.postboy.execute(new GenerateDrawExecutor(l, ev.style, ev.type));
|
|
791
|
+
this.map?.addInteraction(this.drawInteraction);
|
|
792
|
+
this.drawInteraction.on('drawend', (evt) => {
|
|
793
|
+
cancelSub.unsubscribe();
|
|
794
|
+
this.onEnd(evt, ev, l);
|
|
602
795
|
});
|
|
603
|
-
this.postboy.fire(drawQuery);
|
|
604
796
|
});
|
|
605
797
|
});
|
|
606
|
-
this.observeMapRender();
|
|
607
798
|
}
|
|
608
799
|
onEnd(evt, command, layer) {
|
|
609
800
|
command.finish(command.format === FeatureOutputFormat.GeoJson
|
|
@@ -644,32 +835,100 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "16.2.12", ngImpo
|
|
|
644
835
|
type: Injectable
|
|
645
836
|
}], ctorParameters: function () { return [{ type: MapPostboyService }]; } });
|
|
646
837
|
|
|
647
|
-
class
|
|
838
|
+
class FeatureModificationService {
|
|
648
839
|
postboy;
|
|
840
|
+
modify;
|
|
841
|
+
translate;
|
|
842
|
+
map;
|
|
649
843
|
constructor(postboy) {
|
|
650
844
|
this.postboy = postboy;
|
|
651
845
|
}
|
|
652
846
|
up() {
|
|
653
|
-
this.
|
|
654
|
-
|
|
655
|
-
|
|
656
|
-
|
|
657
|
-
|
|
658
|
-
|
|
659
|
-
|
|
847
|
+
this.observeModification();
|
|
848
|
+
this.observeMapRender();
|
|
849
|
+
}
|
|
850
|
+
observeModification() {
|
|
851
|
+
this.postboy.subscribe(ModifyFeatureCommand.ID).subscribe((ev) => {
|
|
852
|
+
this.defineLayer((l) => {
|
|
853
|
+
if (!l || !this.map) {
|
|
854
|
+
this.clearInteraction(l);
|
|
855
|
+
return;
|
|
856
|
+
}
|
|
857
|
+
this.observeCancelation(ev, l);
|
|
858
|
+
this.initFeature(l, ev.model.feature);
|
|
859
|
+
this.addModify(ev);
|
|
860
|
+
this.addDragging(ev);
|
|
861
|
+
});
|
|
660
862
|
});
|
|
661
863
|
}
|
|
662
|
-
|
|
663
|
-
|
|
864
|
+
initFeature(layer, feature) {
|
|
865
|
+
layer.getSource()?.clear();
|
|
866
|
+
layer.getSource()?.addFeature(feature);
|
|
867
|
+
}
|
|
868
|
+
addModify(command) {
|
|
869
|
+
this.modify = new Modify({
|
|
870
|
+
features: new Collection([command.model.feature]),
|
|
871
|
+
style: command.style,
|
|
872
|
+
});
|
|
873
|
+
this.modify.on('modifyend', () => {
|
|
874
|
+
this.onModified(command);
|
|
875
|
+
command.model.feature.changed();
|
|
876
|
+
});
|
|
877
|
+
this.map?.addInteraction(this.modify);
|
|
878
|
+
}
|
|
879
|
+
addDragging(command) {
|
|
880
|
+
this.translate = new Translate({
|
|
881
|
+
features: new Collection([command.model.feature]),
|
|
882
|
+
condition: (ev) => {
|
|
883
|
+
const clone = command.model.feature.clone();
|
|
884
|
+
clone.getGeometry()?.scale(0.999);
|
|
885
|
+
return clone.getGeometry().intersectsCoordinate(ev.coordinate);
|
|
886
|
+
},
|
|
887
|
+
});
|
|
888
|
+
this.translate.on('translateend', () => this.onModified(command));
|
|
889
|
+
this.map?.addInteraction(this.translate);
|
|
890
|
+
}
|
|
891
|
+
onModified(command) {
|
|
892
|
+
command.next(command.format === FeatureOutputFormat.GeoJson
|
|
893
|
+
? new GeoJSON().writeFeature(command.model.feature)
|
|
894
|
+
: new WKT().writeFeature(command.model.feature));
|
|
895
|
+
}
|
|
896
|
+
observeMapRender() {
|
|
897
|
+
this.postboy.subscribe(MapRenderedEvent.ID).subscribe((m) => {
|
|
898
|
+
this.map = m.map;
|
|
899
|
+
});
|
|
900
|
+
}
|
|
901
|
+
defineLayer(action) {
|
|
902
|
+
const query = new GetLayerQuery(MapConstants.DrawingLayerId);
|
|
903
|
+
query.result.subscribe((l) => action(l));
|
|
904
|
+
this.postboy.fire(query);
|
|
905
|
+
}
|
|
906
|
+
observeCancelation(ev, layer) {
|
|
907
|
+
return this.postboy
|
|
908
|
+
.subscribe(CancelFeatureModificationCommand.ID)
|
|
909
|
+
.pipe(first())
|
|
910
|
+
.subscribe(() => {
|
|
911
|
+
ev.finish(null);
|
|
912
|
+
this.clearInteraction(layer);
|
|
913
|
+
});
|
|
914
|
+
}
|
|
915
|
+
clearInteraction(layer) {
|
|
916
|
+
if (this.modify)
|
|
917
|
+
this.map?.removeInteraction(this.modify);
|
|
918
|
+
if (this.translate)
|
|
919
|
+
this.map?.removeInteraction(this.translate);
|
|
920
|
+
}
|
|
921
|
+
static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "16.2.12", ngImport: i0, type: FeatureModificationService, deps: [{ token: MapPostboyService }], target: i0.ɵɵFactoryTarget.Injectable });
|
|
922
|
+
static ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "16.2.12", ngImport: i0, type: FeatureModificationService });
|
|
664
923
|
}
|
|
665
|
-
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "16.2.12", ngImport: i0, type:
|
|
924
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "16.2.12", ngImport: i0, type: FeatureModificationService, decorators: [{
|
|
666
925
|
type: Injectable
|
|
667
926
|
}], ctorParameters: function () { return [{ type: MapPostboyService }]; } });
|
|
668
927
|
|
|
669
928
|
class MessageRegistratorService extends PostboyAbstractRegistrator {
|
|
670
|
-
constructor(service, management, state,
|
|
929
|
+
constructor(service, management, state, mapFeature, interaction, drawing, featureModification) {
|
|
671
930
|
super(service);
|
|
672
|
-
this.registerServices([management, state, interaction,
|
|
931
|
+
this.registerServices([management, state, interaction, mapFeature, drawing, featureModification]);
|
|
673
932
|
}
|
|
674
933
|
_up() {
|
|
675
934
|
this.registerReplay(MapRenderedEvent.ID);
|
|
@@ -686,14 +945,22 @@ class MessageRegistratorService extends PostboyAbstractRegistrator {
|
|
|
686
945
|
this.registerSubject(StartDrawingCommand.ID);
|
|
687
946
|
this.registerSubject(GetLayerQuery.ID);
|
|
688
947
|
this.registerSubject(DrawingFinishedEvent.ID);
|
|
689
|
-
this.registerSubject(
|
|
948
|
+
this.registerSubject(GetFeaturesInAreaQuery.ID);
|
|
949
|
+
this.registerSubject(DrawSelectionAreaCommand.ID);
|
|
950
|
+
this.registerSubject(CancelFeatureModificationCommand.ID);
|
|
951
|
+
this.registerSubject(ModifyFeatureCommand.ID);
|
|
952
|
+
this.setExecutors();
|
|
690
953
|
}
|
|
691
|
-
|
|
954
|
+
setExecutors() {
|
|
955
|
+
this.registerExecutor(FilterFeaturesInAreaExecutor.ID, (e) => FeatureService.filterFeaturesInArea(e));
|
|
956
|
+
this.registerExecutor(GenerateDrawExecutor.ID, (e) => DrawingGenerationService.getDraw(e));
|
|
957
|
+
}
|
|
958
|
+
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: FeatureModificationService }], target: i0.ɵɵFactoryTarget.Injectable });
|
|
692
959
|
static ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "16.2.12", ngImport: i0, type: MessageRegistratorService });
|
|
693
960
|
}
|
|
694
961
|
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "16.2.12", ngImport: i0, type: MessageRegistratorService, decorators: [{
|
|
695
962
|
type: Injectable
|
|
696
|
-
}], ctorParameters: function () { return [{ type: MapPostboyService }, { type: MapManagementService }, { type: MapStateService }, { type: MapFeatureService }, { type: MapClickService }, { type: DrawingService }, { type:
|
|
963
|
+
}], ctorParameters: function () { return [{ type: MapPostboyService }, { type: MapManagementService }, { type: MapStateService }, { type: MapFeatureService }, { type: MapClickService }, { type: DrawingService }, { type: FeatureModificationService }]; } });
|
|
697
964
|
|
|
698
965
|
class TileLayerSettings {
|
|
699
966
|
maxZoom = 19;
|
|
@@ -1259,6 +1526,8 @@ class MapPlateComponent extends DestructibleComponent {
|
|
|
1259
1526
|
MapFeatureService,
|
|
1260
1527
|
DrawingService,
|
|
1261
1528
|
DrawingGenerationService,
|
|
1529
|
+
FeatureService,
|
|
1530
|
+
FeatureModificationService,
|
|
1262
1531
|
], 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 });
|
|
1263
1532
|
}
|
|
1264
1533
|
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "16.2.12", ngImport: i0, type: MapPlateComponent, decorators: [{
|
|
@@ -1271,6 +1540,8 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "16.2.12", ngImpo
|
|
|
1271
1540
|
MapFeatureService,
|
|
1272
1541
|
DrawingService,
|
|
1273
1542
|
DrawingGenerationService,
|
|
1543
|
+
FeatureService,
|
|
1544
|
+
FeatureModificationService,
|
|
1274
1545
|
], 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"] }]
|
|
1275
1546
|
}], ctorParameters: function () { return [{ type: i0.ElementRef }, { type: MapPostboyService }, { type: MapPlateFactory }, { type: MessageRegistratorService }, { type: i0.ChangeDetectorRef }]; }, propDecorators: { settings: [{
|
|
1276
1547
|
type: Input
|
|
@@ -1533,6 +1804,23 @@ class PolygonStyleHelper {
|
|
|
1533
1804
|
}),
|
|
1534
1805
|
});
|
|
1535
1806
|
}
|
|
1807
|
+
static edit(fill, stroke, strokeWidth = 1, pinRadius = 5) {
|
|
1808
|
+
return new Style({
|
|
1809
|
+
image: new Circle({
|
|
1810
|
+
fill: new Fill({
|
|
1811
|
+
color: stroke,
|
|
1812
|
+
}),
|
|
1813
|
+
radius: pinRadius,
|
|
1814
|
+
}),
|
|
1815
|
+
fill: new Fill({
|
|
1816
|
+
color: fill,
|
|
1817
|
+
}),
|
|
1818
|
+
stroke: new Stroke({
|
|
1819
|
+
color: stroke,
|
|
1820
|
+
width: strokeWidth,
|
|
1821
|
+
}),
|
|
1822
|
+
});
|
|
1823
|
+
}
|
|
1536
1824
|
}
|
|
1537
1825
|
|
|
1538
1826
|
class TextStyleHelper {
|
|
@@ -1611,5 +1899,5 @@ class StringifyFeatureHelper {
|
|
|
1611
1899
|
* Generated bundle index. Do not edit.
|
|
1612
1900
|
*/
|
|
1613
1901
|
|
|
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 };
|
|
1902
|
+
export { CancelDrawingCommand, CancelFeatureModificationCommand, CloseTooltipCommand, ClusterLayerComponent, ClusterLayerSettings, Dictionary, DrawSelectionAreaCommand, DrawingType, FeatureLayerComponent, FeatureLayerSettings, FeatureOutputFormat, MapClickEvent, MapLyrs, MapLyrsLabel, MapModule, MapMoveEndEvent, MapPlateComponent, MapPostboyService, MapRenderedEvent, MapSettings, MarkerModel, MarkerStyleHelper, MarkersComponent, MessageRegistratorService, ModifyFeatureCommand, OsmTileLayerComponent, PolygonModel, PolygonStyleHelper, PolygonsComponent, StartDrawingCommand, StringifyFeatureHelper, TextStyleHelper, TileLayerComponent, TileLayerSettings, TooltipComponent, TooltipSettings };
|
|
1615
1903
|
//# sourceMappingURL=maps-components.mjs.map
|