@artstesh/maps 4.0.9 → 4.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/esm2020/map/helpers/polygon-style.helper.mjs +19 -2
- package/dist/esm2020/map/map-plate/map-plate.component.mjs +7 -1
- package/dist/esm2020/map/messages/commands/cancel-feature-modification.command.mjs +8 -0
- package/dist/esm2020/map/messages/commands/draw-selection-area.command.mjs +14 -0
- package/dist/esm2020/map/messages/commands/modify-feature.command.mjs +15 -0
- package/dist/esm2020/map/messages/executors/filter-features-in-area.executor.mjs +13 -0
- package/dist/esm2020/map/messages/executors/generate-draw.executor.mjs +14 -0
- package/dist/esm2020/map/messages/index.mjs +4 -1
- 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 +16 -21
- package/dist/esm2020/map/services/drawing/drawing.service.mjs +32 -14
- package/dist/esm2020/map/services/drawing/feature-modification.service.mjs +99 -0
- package/dist/esm2020/map/services/feature.service.mjs +16 -0
- package/dist/esm2020/map/services/map-management.service.mjs +28 -7
- package/dist/esm2020/map/services/message-registrator.service.mjs +23 -8
- package/dist/esm2020/src/map/helpers/polygon-style.helper.mjs +19 -2
- package/dist/esm2020/src/map/map-plate/map-plate.component.mjs +7 -1
- package/dist/esm2020/src/map/messages/commands/cancel-feature-modification.command.mjs +8 -0
- package/dist/esm2020/src/map/messages/commands/draw-selection-area.command.mjs +14 -0
- package/dist/esm2020/src/map/messages/commands/modify-feature.command.mjs +15 -0
- package/dist/esm2020/src/map/messages/executors/filter-features-in-area.executor.mjs +13 -0
- package/dist/esm2020/src/map/messages/executors/generate-draw.executor.mjs +14 -0
- package/dist/esm2020/src/map/messages/index.mjs +4 -1
- 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 +16 -21
- package/dist/esm2020/src/map/services/drawing/drawing.service.mjs +32 -14
- package/dist/esm2020/src/map/services/drawing/feature-modification.service.mjs +99 -0
- package/dist/esm2020/src/map/services/feature.service.mjs +16 -0
- package/dist/esm2020/src/map/services/map-management.service.mjs +28 -7
- package/dist/esm2020/src/map/services/message-registrator.service.mjs +23 -8
- package/dist/fesm2015/maps-components-src-map.mjs +325 -43
- package/dist/fesm2015/maps-components-src-map.mjs.map +1 -1
- package/dist/fesm2015/maps-components.mjs +325 -43
- package/dist/fesm2015/maps-components.mjs.map +1 -1
- package/dist/fesm2020/maps-components-src-map.mjs +318 -41
- package/dist/fesm2020/maps-components-src-map.mjs.map +1 -1
- package/dist/fesm2020/maps-components.mjs +318 -41
- package/dist/fesm2020/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/esm2020/map/messages/queries/generate-draw.query.mjs +0 -14
- package/dist/esm2020/src/map/messages/queries/generate-draw.query.mjs +0 -14
|
@@ -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';
|
|
@@ -179,6 +179,7 @@ var DrawingType;
|
|
|
179
179
|
(function (DrawingType) {
|
|
180
180
|
DrawingType[DrawingType["Polygon"] = 1] = "Polygon";
|
|
181
181
|
DrawingType[DrawingType["Circle"] = 2] = "Circle";
|
|
182
|
+
DrawingType[DrawingType["Square"] = 3] = "Square";
|
|
182
183
|
})(DrawingType || (DrawingType = {}));
|
|
183
184
|
|
|
184
185
|
var FeatureOutputFormat;
|
|
@@ -187,6 +188,62 @@ var FeatureOutputFormat;
|
|
|
187
188
|
FeatureOutputFormat[FeatureOutputFormat["WKT"] = 2] = "WKT";
|
|
188
189
|
})(FeatureOutputFormat || (FeatureOutputFormat = {}));
|
|
189
190
|
|
|
191
|
+
class Dictionary {
|
|
192
|
+
constructor() {
|
|
193
|
+
this.collection = {};
|
|
194
|
+
this._keys = new Set();
|
|
195
|
+
this.has = (key) => this._keys.has(key);
|
|
196
|
+
}
|
|
197
|
+
get keys() {
|
|
198
|
+
return Array.from(this._keys);
|
|
199
|
+
}
|
|
200
|
+
get size() {
|
|
201
|
+
return this._keys.size;
|
|
202
|
+
}
|
|
203
|
+
static clone(dic, action) {
|
|
204
|
+
return Dictionary.create(dic.collection, action);
|
|
205
|
+
}
|
|
206
|
+
static create(dic, action) {
|
|
207
|
+
let keyList = Object.keys(dic);
|
|
208
|
+
const result = new Dictionary();
|
|
209
|
+
for (let i = 0; i < keyList.length; i++) {
|
|
210
|
+
let key = keyList[i];
|
|
211
|
+
result._keys.add(key);
|
|
212
|
+
result.collection[key] = action ? action(dic[key], key) : dic[key];
|
|
213
|
+
}
|
|
214
|
+
return result;
|
|
215
|
+
}
|
|
216
|
+
find(predicate) {
|
|
217
|
+
let result = null;
|
|
218
|
+
this.forEach((e) => {
|
|
219
|
+
if (result === null && predicate(e))
|
|
220
|
+
result = e;
|
|
221
|
+
});
|
|
222
|
+
return result;
|
|
223
|
+
}
|
|
224
|
+
take(key) {
|
|
225
|
+
return this._keys.has(key) ? this.collection[key] : null;
|
|
226
|
+
}
|
|
227
|
+
put(key, value) {
|
|
228
|
+
if (value == null)
|
|
229
|
+
return;
|
|
230
|
+
this.collection[key] = value;
|
|
231
|
+
this._keys.add(key);
|
|
232
|
+
}
|
|
233
|
+
rmv(key) {
|
|
234
|
+
if (!this._keys.has(key))
|
|
235
|
+
return;
|
|
236
|
+
delete this.collection[key];
|
|
237
|
+
this._keys.delete(key);
|
|
238
|
+
}
|
|
239
|
+
forEach(callback) {
|
|
240
|
+
let keys = Object.keys(this.collection);
|
|
241
|
+
for (let i = 0; i < keys.length; i++) {
|
|
242
|
+
callback(this.collection[keys[i]], i);
|
|
243
|
+
}
|
|
244
|
+
}
|
|
245
|
+
}
|
|
246
|
+
|
|
190
247
|
class MapRenderedEvent extends PostboyGenericMessage {
|
|
191
248
|
constructor(map) {
|
|
192
249
|
super();
|
|
@@ -254,6 +311,39 @@ class CancelDrawingCommand extends PostboyGenericMessage {
|
|
|
254
311
|
}
|
|
255
312
|
CancelDrawingCommand.ID = '7d38d983-feba-4176-a66b-18175e5ecd6b';
|
|
256
313
|
|
|
314
|
+
class DrawSelectionAreaCommand extends PostboyCallbackMessage {
|
|
315
|
+
constructor(type, style, ignore = new Set()) {
|
|
316
|
+
super();
|
|
317
|
+
this.type = type;
|
|
318
|
+
this.style = style;
|
|
319
|
+
this.ignore = ignore;
|
|
320
|
+
}
|
|
321
|
+
get id() {
|
|
322
|
+
return DrawSelectionAreaCommand.ID;
|
|
323
|
+
}
|
|
324
|
+
}
|
|
325
|
+
DrawSelectionAreaCommand.ID = '573d8a0d-f25b-42b7-9ad7-0ac6d86ac362';
|
|
326
|
+
|
|
327
|
+
class ModifyFeatureCommand extends PostboyCallbackMessage {
|
|
328
|
+
constructor(model, style, format = FeatureOutputFormat.GeoJson) {
|
|
329
|
+
super();
|
|
330
|
+
this.model = model;
|
|
331
|
+
this.style = style;
|
|
332
|
+
this.format = format;
|
|
333
|
+
}
|
|
334
|
+
get id() {
|
|
335
|
+
return ModifyFeatureCommand.ID;
|
|
336
|
+
}
|
|
337
|
+
}
|
|
338
|
+
ModifyFeatureCommand.ID = 'ead85caa-24c6-4844-a68c-2cea91774c8c';
|
|
339
|
+
|
|
340
|
+
class CancelFeatureModificationCommand extends PostboyGenericMessage {
|
|
341
|
+
get id() {
|
|
342
|
+
return CancelFeatureModificationCommand.ID;
|
|
343
|
+
}
|
|
344
|
+
}
|
|
345
|
+
CancelFeatureModificationCommand.ID = '9c9fb40f-ea95-4704-8177-0e9ecabf36fa';
|
|
346
|
+
|
|
257
347
|
class AddLayerCommand extends PostboyGenericMessage {
|
|
258
348
|
constructor(layer) {
|
|
259
349
|
super();
|
|
@@ -343,7 +433,67 @@ class DrawingFinishedEvent extends PostboyGenericMessage {
|
|
|
343
433
|
}
|
|
344
434
|
DrawingFinishedEvent.ID = 'c724b68e-b4eb-4783-90f1-a8e31973fd36';
|
|
345
435
|
|
|
346
|
-
class
|
|
436
|
+
class DrawingGenerationService {
|
|
437
|
+
static getDraw(ev) {
|
|
438
|
+
return new Draw({
|
|
439
|
+
source: ev.layer.getSource(),
|
|
440
|
+
type: ev.type === DrawingType.Polygon ? 'Polygon' : 'Circle',
|
|
441
|
+
style: ev.style,
|
|
442
|
+
geometryFunction: DrawingGenerationService.geometryFunc(ev.type),
|
|
443
|
+
});
|
|
444
|
+
}
|
|
445
|
+
static geometryFunc(type) {
|
|
446
|
+
switch (type) {
|
|
447
|
+
case DrawingType.Circle:
|
|
448
|
+
return createRegularPolygon(32);
|
|
449
|
+
case DrawingType.Square:
|
|
450
|
+
return createRegularPolygon(4);
|
|
451
|
+
}
|
|
452
|
+
return undefined;
|
|
453
|
+
}
|
|
454
|
+
}
|
|
455
|
+
|
|
456
|
+
class FeatureService {
|
|
457
|
+
constructor() { }
|
|
458
|
+
static filterFeaturesInArea(query) {
|
|
459
|
+
return query.features.filter((f) => FeatureService.booleanIntersects(query.area, f.getGeometry()));
|
|
460
|
+
}
|
|
461
|
+
static booleanIntersects(g1, g2) {
|
|
462
|
+
if (g2.getType() === 'Point')
|
|
463
|
+
return g1.intersectsCoordinate(g2.getCoordinates());
|
|
464
|
+
if (g2.getType() === 'Circle')
|
|
465
|
+
return g1.intersectsCoordinate(g2.getCenter());
|
|
466
|
+
if (g2.getType() === 'Polygon')
|
|
467
|
+
return g1.intersectsCoordinate(g2.getInteriorPoint().getCoordinates());
|
|
468
|
+
return false;
|
|
469
|
+
}
|
|
470
|
+
}
|
|
471
|
+
|
|
472
|
+
class GetFeaturesInAreaQuery extends PostboyCallbackMessage {
|
|
473
|
+
constructor(area, ignore = new Set()) {
|
|
474
|
+
super();
|
|
475
|
+
this.area = area;
|
|
476
|
+
this.ignore = ignore;
|
|
477
|
+
}
|
|
478
|
+
get id() {
|
|
479
|
+
return GetFeaturesInAreaQuery.ID;
|
|
480
|
+
}
|
|
481
|
+
}
|
|
482
|
+
GetFeaturesInAreaQuery.ID = 'efcf4271-a07a-40e0-9f02-d4dade40b8ac';
|
|
483
|
+
|
|
484
|
+
class FilterFeaturesInAreaExecutor extends PostboyExecutor {
|
|
485
|
+
constructor(area, features) {
|
|
486
|
+
super();
|
|
487
|
+
this.area = area;
|
|
488
|
+
this.features = features;
|
|
489
|
+
}
|
|
490
|
+
get id() {
|
|
491
|
+
return FilterFeaturesInAreaExecutor.ID;
|
|
492
|
+
}
|
|
493
|
+
}
|
|
494
|
+
FilterFeaturesInAreaExecutor.ID = '36bb2d94-8028-4512-90dd-2386af3fc67c';
|
|
495
|
+
|
|
496
|
+
class GenerateDrawExecutor extends PostboyExecutor {
|
|
347
497
|
constructor(layer, style, type) {
|
|
348
498
|
super();
|
|
349
499
|
this.layer = layer;
|
|
@@ -351,10 +501,10 @@ class GenerateDrawQuery extends PostboyCallbackMessage {
|
|
|
351
501
|
this.type = type;
|
|
352
502
|
}
|
|
353
503
|
get id() {
|
|
354
|
-
return
|
|
504
|
+
return GenerateDrawExecutor.ID;
|
|
355
505
|
}
|
|
356
506
|
}
|
|
357
|
-
|
|
507
|
+
GenerateDrawExecutor.ID = 'f01c99ba-0953-4ab5-82f9-04e6fbb678c1';
|
|
358
508
|
|
|
359
509
|
class MapPostboyService extends PostboyService {
|
|
360
510
|
constructor() {
|
|
@@ -371,7 +521,7 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "15.2.10", ngImpo
|
|
|
371
521
|
class MapManagementService {
|
|
372
522
|
constructor(postboy) {
|
|
373
523
|
this.postboy = postboy;
|
|
374
|
-
this.layers =
|
|
524
|
+
this.layers = new Dictionary();
|
|
375
525
|
}
|
|
376
526
|
up() {
|
|
377
527
|
this.observeMapRender();
|
|
@@ -381,6 +531,7 @@ class MapManagementService {
|
|
|
381
531
|
this.observeAddTile();
|
|
382
532
|
this.observeRemoveTile();
|
|
383
533
|
this.observeLayerQuery();
|
|
534
|
+
this.observeFeaturesInArea();
|
|
384
535
|
}
|
|
385
536
|
observeRemoveTile() {
|
|
386
537
|
this.postboy.subscribe(RemoveTileCommand.ID).subscribe((c) => {
|
|
@@ -390,7 +541,7 @@ class MapManagementService {
|
|
|
390
541
|
});
|
|
391
542
|
}
|
|
392
543
|
observeLayerQuery() {
|
|
393
|
-
this.postboy.subscribe(GetLayerQuery.ID).subscribe((ev) => ev.finish(this.layers
|
|
544
|
+
this.postboy.subscribe(GetLayerQuery.ID).subscribe((ev) => ev.finish(this.layers.take(ev.name)));
|
|
394
545
|
}
|
|
395
546
|
observeAddTile() {
|
|
396
547
|
this.postboy.subscribe(AddTileCommand.ID).subscribe((c) => {
|
|
@@ -408,15 +559,15 @@ class MapManagementService {
|
|
|
408
559
|
this.postboy.subscribe(AddLayerCommand.ID).subscribe((c) => {
|
|
409
560
|
if (!this.map)
|
|
410
561
|
return;
|
|
411
|
-
this.layers
|
|
562
|
+
this.layers.put(c.layer.get('name'), c.layer);
|
|
412
563
|
this.map.addLayer(c.layer);
|
|
413
564
|
});
|
|
414
565
|
}
|
|
415
566
|
observePlaceFeatures() {
|
|
416
567
|
this.postboy.subscribe(PlaceLayerFeaturesCommand.ID).subscribe((c) => {
|
|
417
|
-
if (!this.layers
|
|
568
|
+
if (!this.layers.has(c.layer))
|
|
418
569
|
return;
|
|
419
|
-
let source = this.layers
|
|
570
|
+
let source = this.layers.take(c.layer).getSource();
|
|
420
571
|
if (!!source['getSource'])
|
|
421
572
|
source = source?.getSource();
|
|
422
573
|
source?.clear();
|
|
@@ -427,10 +578,26 @@ class MapManagementService {
|
|
|
427
578
|
this.postboy.subscribe(RemoveLayerCommand.ID).subscribe((c) => {
|
|
428
579
|
if (!this.map)
|
|
429
580
|
return;
|
|
430
|
-
|
|
581
|
+
this.layers.rmv(c.layer.get('name'));
|
|
431
582
|
this.map.removeLayer(c.layer);
|
|
432
583
|
});
|
|
433
584
|
}
|
|
585
|
+
observeFeaturesInArea() {
|
|
586
|
+
this.postboy.subscribe(GetFeaturesInAreaQuery.ID).subscribe((qr) => {
|
|
587
|
+
let result = new Dictionary();
|
|
588
|
+
this.layers.forEach((l) => {
|
|
589
|
+
let layerName = l.get('name');
|
|
590
|
+
if (qr.ignore.has(layerName) || layerName === MapConstants.DrawingLayerId)
|
|
591
|
+
return;
|
|
592
|
+
let source = l.getSource();
|
|
593
|
+
if (!!source['getSource'])
|
|
594
|
+
source = source?.getSource();
|
|
595
|
+
let features = this.postboy.execute(new FilterFeaturesInAreaExecutor(qr.area, source?.getFeatures() ?? []));
|
|
596
|
+
result.put(layerName, features.map((e) => ({ id: e.getId(), ...e.get(MapConstants.FeatureInfo) })));
|
|
597
|
+
});
|
|
598
|
+
qr.finish(result);
|
|
599
|
+
});
|
|
600
|
+
}
|
|
434
601
|
}
|
|
435
602
|
MapManagementService.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "15.2.10", ngImport: i0, type: MapManagementService, deps: [{ token: MapPostboyService }], target: i0.ɵɵFactoryTarget.Injectable });
|
|
436
603
|
MapManagementService.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "15.2.10", ngImport: i0, type: MapManagementService });
|
|
@@ -544,26 +711,42 @@ class DrawingService {
|
|
|
544
711
|
this.postboy = postboy;
|
|
545
712
|
}
|
|
546
713
|
up() {
|
|
714
|
+
this.observeDrawing();
|
|
715
|
+
this.observeSelectArea();
|
|
716
|
+
this.observeMapRender();
|
|
717
|
+
}
|
|
718
|
+
observeSelectArea() {
|
|
719
|
+
this.postboy.subscribe(DrawSelectionAreaCommand.ID).subscribe((ev) => {
|
|
720
|
+
const drawingCommand = new StartDrawingCommand(ev.type, ev.style);
|
|
721
|
+
drawingCommand.result.subscribe((r) => {
|
|
722
|
+
if (!r) {
|
|
723
|
+
ev.finish(new Dictionary());
|
|
724
|
+
return;
|
|
725
|
+
}
|
|
726
|
+
const area = PolygonModel.fromGeoJson(1, r).feature.getGeometry();
|
|
727
|
+
const getFeaturesCommand = new GetFeaturesInAreaQuery(area, ev.ignore);
|
|
728
|
+
getFeaturesCommand.result.subscribe((result) => ev.finish(result));
|
|
729
|
+
this.postboy.fire(getFeaturesCommand);
|
|
730
|
+
});
|
|
731
|
+
this.postboy.fire(drawingCommand);
|
|
732
|
+
});
|
|
733
|
+
}
|
|
734
|
+
observeDrawing() {
|
|
547
735
|
this.postboy.subscribe(StartDrawingCommand.ID).subscribe((ev) => {
|
|
548
736
|
this.draw((l) => {
|
|
549
737
|
if (!l || !this.map) {
|
|
550
738
|
this.clearInteraction(l);
|
|
551
739
|
return;
|
|
552
740
|
}
|
|
553
|
-
const
|
|
554
|
-
|
|
555
|
-
|
|
556
|
-
|
|
557
|
-
|
|
558
|
-
this.
|
|
559
|
-
cancelSub.unsubscribe();
|
|
560
|
-
this.onEnd(evt, ev, l);
|
|
561
|
-
});
|
|
741
|
+
const cancelSub = this.observeCancelation(ev, l);
|
|
742
|
+
this.drawInteraction = this.postboy.execute(new GenerateDrawExecutor(l, ev.style, ev.type));
|
|
743
|
+
this.map?.addInteraction(this.drawInteraction);
|
|
744
|
+
this.drawInteraction.on('drawend', (evt) => {
|
|
745
|
+
cancelSub.unsubscribe();
|
|
746
|
+
this.onEnd(evt, ev, l);
|
|
562
747
|
});
|
|
563
|
-
this.postboy.fire(drawQuery);
|
|
564
748
|
});
|
|
565
749
|
});
|
|
566
|
-
this.observeMapRender();
|
|
567
750
|
}
|
|
568
751
|
onEnd(evt, command, layer) {
|
|
569
752
|
command.finish(command.format === FeatureOutputFormat.GeoJson
|
|
@@ -604,31 +787,96 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "15.2.10", ngImpo
|
|
|
604
787
|
type: Injectable
|
|
605
788
|
}], ctorParameters: function () { return [{ type: MapPostboyService }]; } });
|
|
606
789
|
|
|
607
|
-
class
|
|
790
|
+
class FeatureModificationService {
|
|
608
791
|
constructor(postboy) {
|
|
609
792
|
this.postboy = postboy;
|
|
610
793
|
}
|
|
611
794
|
up() {
|
|
612
|
-
this.
|
|
613
|
-
|
|
614
|
-
|
|
615
|
-
|
|
616
|
-
|
|
617
|
-
|
|
618
|
-
|
|
795
|
+
this.observeModification();
|
|
796
|
+
this.observeMapRender();
|
|
797
|
+
}
|
|
798
|
+
observeModification() {
|
|
799
|
+
this.postboy.subscribe(ModifyFeatureCommand.ID).subscribe((ev) => {
|
|
800
|
+
this.defineLayer((l) => {
|
|
801
|
+
if (!l || !this.map) {
|
|
802
|
+
this.clearInteraction(l);
|
|
803
|
+
return;
|
|
804
|
+
}
|
|
805
|
+
this.observeCancelation(ev, l);
|
|
806
|
+
this.initFeature(l, ev.model.feature);
|
|
807
|
+
this.addModify(ev);
|
|
808
|
+
this.addDragging(ev);
|
|
809
|
+
});
|
|
810
|
+
});
|
|
811
|
+
}
|
|
812
|
+
initFeature(layer, feature) {
|
|
813
|
+
layer.getSource()?.clear();
|
|
814
|
+
layer.getSource()?.addFeature(feature);
|
|
815
|
+
}
|
|
816
|
+
addModify(command) {
|
|
817
|
+
this.modify = new Modify({
|
|
818
|
+
features: new Collection([command.model.feature]),
|
|
819
|
+
style: command.style,
|
|
820
|
+
});
|
|
821
|
+
this.modify.on('modifyend', () => {
|
|
822
|
+
this.onModified(command);
|
|
823
|
+
command.model.feature.changed();
|
|
824
|
+
});
|
|
825
|
+
this.map?.addInteraction(this.modify);
|
|
826
|
+
}
|
|
827
|
+
addDragging(command) {
|
|
828
|
+
this.translate = new Translate({
|
|
829
|
+
features: new Collection([command.model.feature]),
|
|
830
|
+
condition: (ev) => {
|
|
831
|
+
const clone = command.model.feature.clone();
|
|
832
|
+
clone.getGeometry()?.scale(0.999);
|
|
833
|
+
return clone.getGeometry().intersectsCoordinate(ev.coordinate);
|
|
834
|
+
},
|
|
835
|
+
});
|
|
836
|
+
this.translate.on('translateend', () => this.onModified(command));
|
|
837
|
+
this.map?.addInteraction(this.translate);
|
|
838
|
+
}
|
|
839
|
+
onModified(command) {
|
|
840
|
+
command.next(command.format === FeatureOutputFormat.GeoJson
|
|
841
|
+
? new GeoJSON().writeFeature(command.model.feature)
|
|
842
|
+
: new WKT().writeFeature(command.model.feature));
|
|
843
|
+
}
|
|
844
|
+
observeMapRender() {
|
|
845
|
+
this.postboy.subscribe(MapRenderedEvent.ID).subscribe((m) => {
|
|
846
|
+
this.map = m.map;
|
|
847
|
+
});
|
|
848
|
+
}
|
|
849
|
+
defineLayer(action) {
|
|
850
|
+
const query = new GetLayerQuery(MapConstants.DrawingLayerId);
|
|
851
|
+
query.result.subscribe((l) => action(l));
|
|
852
|
+
this.postboy.fire(query);
|
|
853
|
+
}
|
|
854
|
+
observeCancelation(ev, layer) {
|
|
855
|
+
return this.postboy
|
|
856
|
+
.subscribe(CancelFeatureModificationCommand.ID)
|
|
857
|
+
.pipe(first())
|
|
858
|
+
.subscribe(() => {
|
|
859
|
+
ev.finish(null);
|
|
860
|
+
this.clearInteraction(layer);
|
|
619
861
|
});
|
|
620
862
|
}
|
|
863
|
+
clearInteraction(layer) {
|
|
864
|
+
if (this.modify)
|
|
865
|
+
this.map?.removeInteraction(this.modify);
|
|
866
|
+
if (this.translate)
|
|
867
|
+
this.map?.removeInteraction(this.translate);
|
|
868
|
+
}
|
|
621
869
|
}
|
|
622
|
-
|
|
623
|
-
|
|
624
|
-
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "15.2.10", ngImport: i0, type:
|
|
870
|
+
FeatureModificationService.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "15.2.10", ngImport: i0, type: FeatureModificationService, deps: [{ token: MapPostboyService }], target: i0.ɵɵFactoryTarget.Injectable });
|
|
871
|
+
FeatureModificationService.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "15.2.10", ngImport: i0, type: FeatureModificationService });
|
|
872
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "15.2.10", ngImport: i0, type: FeatureModificationService, decorators: [{
|
|
625
873
|
type: Injectable
|
|
626
874
|
}], ctorParameters: function () { return [{ type: MapPostboyService }]; } });
|
|
627
875
|
|
|
628
876
|
class MessageRegistratorService extends PostboyAbstractRegistrator {
|
|
629
|
-
constructor(service, management, state,
|
|
877
|
+
constructor(service, management, state, mapFeature, interaction, drawing, featureModification) {
|
|
630
878
|
super(service);
|
|
631
|
-
this.registerServices([management, state, interaction,
|
|
879
|
+
this.registerServices([management, state, interaction, mapFeature, drawing, featureModification]);
|
|
632
880
|
}
|
|
633
881
|
_up() {
|
|
634
882
|
this.registerReplay(MapRenderedEvent.ID);
|
|
@@ -645,14 +893,22 @@ class MessageRegistratorService extends PostboyAbstractRegistrator {
|
|
|
645
893
|
this.registerSubject(StartDrawingCommand.ID);
|
|
646
894
|
this.registerSubject(GetLayerQuery.ID);
|
|
647
895
|
this.registerSubject(DrawingFinishedEvent.ID);
|
|
648
|
-
this.registerSubject(
|
|
896
|
+
this.registerSubject(GetFeaturesInAreaQuery.ID);
|
|
897
|
+
this.registerSubject(DrawSelectionAreaCommand.ID);
|
|
898
|
+
this.registerSubject(CancelFeatureModificationCommand.ID);
|
|
899
|
+
this.registerSubject(ModifyFeatureCommand.ID);
|
|
900
|
+
this.setExecutors();
|
|
901
|
+
}
|
|
902
|
+
setExecutors() {
|
|
903
|
+
this.registerExecutor(FilterFeaturesInAreaExecutor.ID, (e) => FeatureService.filterFeaturesInArea(e));
|
|
904
|
+
this.registerExecutor(GenerateDrawExecutor.ID, (e) => DrawingGenerationService.getDraw(e));
|
|
649
905
|
}
|
|
650
906
|
}
|
|
651
|
-
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:
|
|
907
|
+
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: FeatureModificationService }], target: i0.ɵɵFactoryTarget.Injectable });
|
|
652
908
|
MessageRegistratorService.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "15.2.10", ngImport: i0, type: MessageRegistratorService });
|
|
653
909
|
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "15.2.10", ngImport: i0, type: MessageRegistratorService, decorators: [{
|
|
654
910
|
type: Injectable
|
|
655
|
-
}], ctorParameters: function () { return [{ type: MapPostboyService }, { type: MapManagementService }, { type: MapStateService }, { type: MapFeatureService }, { type: MapClickService }, { type: DrawingService }, { type:
|
|
911
|
+
}], ctorParameters: function () { return [{ type: MapPostboyService }, { type: MapManagementService }, { type: MapStateService }, { type: MapFeatureService }, { type: MapClickService }, { type: DrawingService }, { type: FeatureModificationService }]; } });
|
|
656
912
|
|
|
657
913
|
class TileLayerSettings {
|
|
658
914
|
constructor() {
|
|
@@ -1205,6 +1461,8 @@ MapPlateComponent.ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "14.0.0", vers
|
|
|
1205
1461
|
MapFeatureService,
|
|
1206
1462
|
DrawingService,
|
|
1207
1463
|
DrawingGenerationService,
|
|
1464
|
+
FeatureService,
|
|
1465
|
+
FeatureModificationService,
|
|
1208
1466
|
], 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 });
|
|
1209
1467
|
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "15.2.10", ngImport: i0, type: MapPlateComponent, decorators: [{
|
|
1210
1468
|
type: Component,
|
|
@@ -1216,6 +1474,8 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "15.2.10", ngImpo
|
|
|
1216
1474
|
MapFeatureService,
|
|
1217
1475
|
DrawingService,
|
|
1218
1476
|
DrawingGenerationService,
|
|
1477
|
+
FeatureService,
|
|
1478
|
+
FeatureModificationService,
|
|
1219
1479
|
], 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"] }]
|
|
1220
1480
|
}], ctorParameters: function () { return [{ type: i0.ElementRef }, { type: MapPostboyService }, { type: MapPlateFactory }, { type: MessageRegistratorService }, { type: i0.ChangeDetectorRef }]; }, propDecorators: { settings: [{
|
|
1221
1481
|
type: Input
|
|
@@ -1470,6 +1730,23 @@ class PolygonStyleHelper {
|
|
|
1470
1730
|
}),
|
|
1471
1731
|
});
|
|
1472
1732
|
}
|
|
1733
|
+
static edit(fill, stroke, strokeWidth = 1, pinRadius = 5) {
|
|
1734
|
+
return new Style({
|
|
1735
|
+
image: new Circle({
|
|
1736
|
+
fill: new Fill({
|
|
1737
|
+
color: stroke,
|
|
1738
|
+
}),
|
|
1739
|
+
radius: pinRadius,
|
|
1740
|
+
}),
|
|
1741
|
+
fill: new Fill({
|
|
1742
|
+
color: fill,
|
|
1743
|
+
}),
|
|
1744
|
+
stroke: new Stroke({
|
|
1745
|
+
color: stroke,
|
|
1746
|
+
width: strokeWidth,
|
|
1747
|
+
}),
|
|
1748
|
+
});
|
|
1749
|
+
}
|
|
1473
1750
|
}
|
|
1474
1751
|
|
|
1475
1752
|
class TextStyleHelper {
|
|
@@ -1548,5 +1825,5 @@ class StringifyFeatureHelper {
|
|
|
1548
1825
|
* Generated bundle index. Do not edit.
|
|
1549
1826
|
*/
|
|
1550
1827
|
|
|
1551
|
-
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 };
|
|
1828
|
+
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 };
|
|
1552
1829
|
//# sourceMappingURL=maps-components.mjs.map
|