@artstesh/maps 1.0.9 → 1.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/bundles/maps-components-src-map.umd.js +402 -51
- package/dist/bundles/maps-components-src-map.umd.js.map +1 -1
- package/dist/bundles/maps-components.umd.js +402 -51
- package/dist/bundles/maps-components.umd.js.map +1 -1
- package/dist/esm2015/map/helpers/polygon-style.helper.js +19 -2
- package/dist/esm2015/map/map-plate/map-plate.component.js +7 -1
- package/dist/esm2015/map/messages/commands/cancel-feature-modification.command.js +8 -0
- package/dist/esm2015/map/messages/commands/draw-selection-area.command.js +14 -0
- package/dist/esm2015/map/messages/commands/modify-feature.command.js +15 -0
- package/dist/esm2015/map/messages/executors/filter-features-in-area.executor.js +13 -0
- package/dist/esm2015/map/messages/executors/generate-draw.executor.js +14 -0
- package/dist/esm2015/map/messages/index.js +4 -1
- package/dist/esm2015/map/messages/queries/get-features-in-area.query.js +13 -0
- package/dist/esm2015/map/models/dictionary.js +56 -0
- package/dist/esm2015/map/models/drawing-type.enum.js +2 -1
- package/dist/esm2015/map/models/index.js +2 -1
- package/dist/esm2015/map/services/drawing/drawing-generation.service.js +16 -21
- package/dist/esm2015/map/services/drawing/drawing.service.js +33 -15
- package/dist/esm2015/map/services/drawing/feature-modification.service.js +104 -0
- package/dist/esm2015/map/services/feature.service.js +16 -0
- package/dist/esm2015/map/services/map-management.service.js +31 -9
- package/dist/esm2015/map/services/message-registrator.service.js +23 -8
- package/dist/esm2015/src/map/helpers/polygon-style.helper.js +19 -2
- package/dist/esm2015/src/map/map-plate/map-plate.component.js +7 -1
- package/dist/esm2015/src/map/messages/commands/cancel-feature-modification.command.js +8 -0
- package/dist/esm2015/src/map/messages/commands/draw-selection-area.command.js +14 -0
- package/dist/esm2015/src/map/messages/commands/modify-feature.command.js +15 -0
- package/dist/esm2015/src/map/messages/executors/filter-features-in-area.executor.js +13 -0
- package/dist/esm2015/src/map/messages/executors/generate-draw.executor.js +14 -0
- package/dist/esm2015/src/map/messages/index.js +4 -1
- package/dist/esm2015/src/map/messages/queries/get-features-in-area.query.js +13 -0
- package/dist/esm2015/src/map/models/dictionary.js +56 -0
- package/dist/esm2015/src/map/models/drawing-type.enum.js +2 -1
- package/dist/esm2015/src/map/models/index.js +2 -1
- package/dist/esm2015/src/map/services/drawing/drawing-generation.service.js +16 -21
- package/dist/esm2015/src/map/services/drawing/drawing.service.js +33 -15
- package/dist/esm2015/src/map/services/drawing/feature-modification.service.js +104 -0
- package/dist/esm2015/src/map/services/feature.service.js +16 -0
- package/dist/esm2015/src/map/services/map-management.service.js +31 -9
- package/dist/esm2015/src/map/services/message-registrator.service.js +23 -8
- package/dist/fesm2015/maps-components-src-map.js +327 -44
- package/dist/fesm2015/maps-components-src-map.js.map +1 -1
- package/dist/fesm2015/maps-components.js +327 -44
- package/dist/fesm2015/maps-components.js.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/esm2015/map/messages/queries/generate-draw.query.js +0 -14
- package/dist/esm2015/src/map/messages/queries/generate-draw.query.js +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 i6 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';
|
|
@@ -180,6 +180,7 @@ var DrawingType;
|
|
|
180
180
|
(function (DrawingType) {
|
|
181
181
|
DrawingType[DrawingType["Polygon"] = 1] = "Polygon";
|
|
182
182
|
DrawingType[DrawingType["Circle"] = 2] = "Circle";
|
|
183
|
+
DrawingType[DrawingType["Square"] = 3] = "Square";
|
|
183
184
|
})(DrawingType || (DrawingType = {}));
|
|
184
185
|
|
|
185
186
|
var FeatureOutputFormat;
|
|
@@ -188,6 +189,62 @@ var FeatureOutputFormat;
|
|
|
188
189
|
FeatureOutputFormat[FeatureOutputFormat["WKT"] = 2] = "WKT";
|
|
189
190
|
})(FeatureOutputFormat || (FeatureOutputFormat = {}));
|
|
190
191
|
|
|
192
|
+
class Dictionary {
|
|
193
|
+
constructor() {
|
|
194
|
+
this.collection = {};
|
|
195
|
+
this._keys = new Set();
|
|
196
|
+
this.has = (key) => this._keys.has(key);
|
|
197
|
+
}
|
|
198
|
+
get keys() {
|
|
199
|
+
return Array.from(this._keys);
|
|
200
|
+
}
|
|
201
|
+
get size() {
|
|
202
|
+
return this._keys.size;
|
|
203
|
+
}
|
|
204
|
+
static clone(dic, action) {
|
|
205
|
+
return Dictionary.create(dic.collection, action);
|
|
206
|
+
}
|
|
207
|
+
static create(dic, action) {
|
|
208
|
+
let keyList = Object.keys(dic);
|
|
209
|
+
const result = new Dictionary();
|
|
210
|
+
for (let i = 0; i < keyList.length; i++) {
|
|
211
|
+
let key = keyList[i];
|
|
212
|
+
result._keys.add(key);
|
|
213
|
+
result.collection[key] = action ? action(dic[key], key) : dic[key];
|
|
214
|
+
}
|
|
215
|
+
return result;
|
|
216
|
+
}
|
|
217
|
+
find(predicate) {
|
|
218
|
+
let result = null;
|
|
219
|
+
this.forEach((e) => {
|
|
220
|
+
if (result === null && predicate(e))
|
|
221
|
+
result = e;
|
|
222
|
+
});
|
|
223
|
+
return result;
|
|
224
|
+
}
|
|
225
|
+
take(key) {
|
|
226
|
+
return this._keys.has(key) ? this.collection[key] : null;
|
|
227
|
+
}
|
|
228
|
+
put(key, value) {
|
|
229
|
+
if (value == null)
|
|
230
|
+
return;
|
|
231
|
+
this.collection[key] = value;
|
|
232
|
+
this._keys.add(key);
|
|
233
|
+
}
|
|
234
|
+
rmv(key) {
|
|
235
|
+
if (!this._keys.has(key))
|
|
236
|
+
return;
|
|
237
|
+
delete this.collection[key];
|
|
238
|
+
this._keys.delete(key);
|
|
239
|
+
}
|
|
240
|
+
forEach(callback) {
|
|
241
|
+
let keys = Object.keys(this.collection);
|
|
242
|
+
for (let i = 0; i < keys.length; i++) {
|
|
243
|
+
callback(this.collection[keys[i]], i);
|
|
244
|
+
}
|
|
245
|
+
}
|
|
246
|
+
}
|
|
247
|
+
|
|
191
248
|
class MapRenderedEvent extends PostboyGenericMessage {
|
|
192
249
|
constructor(map) {
|
|
193
250
|
super();
|
|
@@ -255,6 +312,39 @@ class CancelDrawingCommand extends PostboyGenericMessage {
|
|
|
255
312
|
}
|
|
256
313
|
CancelDrawingCommand.ID = '7d38d983-feba-4176-a66b-18175e5ecd6b';
|
|
257
314
|
|
|
315
|
+
class DrawSelectionAreaCommand extends PostboyCallbackMessage {
|
|
316
|
+
constructor(type, style, ignore = new Set()) {
|
|
317
|
+
super();
|
|
318
|
+
this.type = type;
|
|
319
|
+
this.style = style;
|
|
320
|
+
this.ignore = ignore;
|
|
321
|
+
}
|
|
322
|
+
get id() {
|
|
323
|
+
return DrawSelectionAreaCommand.ID;
|
|
324
|
+
}
|
|
325
|
+
}
|
|
326
|
+
DrawSelectionAreaCommand.ID = '573d8a0d-f25b-42b7-9ad7-0ac6d86ac362';
|
|
327
|
+
|
|
328
|
+
class ModifyFeatureCommand extends PostboyCallbackMessage {
|
|
329
|
+
constructor(model, style, format = FeatureOutputFormat.GeoJson) {
|
|
330
|
+
super();
|
|
331
|
+
this.model = model;
|
|
332
|
+
this.style = style;
|
|
333
|
+
this.format = format;
|
|
334
|
+
}
|
|
335
|
+
get id() {
|
|
336
|
+
return ModifyFeatureCommand.ID;
|
|
337
|
+
}
|
|
338
|
+
}
|
|
339
|
+
ModifyFeatureCommand.ID = 'ead85caa-24c6-4844-a68c-2cea91774c8c';
|
|
340
|
+
|
|
341
|
+
class CancelFeatureModificationCommand extends PostboyGenericMessage {
|
|
342
|
+
get id() {
|
|
343
|
+
return CancelFeatureModificationCommand.ID;
|
|
344
|
+
}
|
|
345
|
+
}
|
|
346
|
+
CancelFeatureModificationCommand.ID = '9c9fb40f-ea95-4704-8177-0e9ecabf36fa';
|
|
347
|
+
|
|
258
348
|
class AddLayerCommand extends PostboyGenericMessage {
|
|
259
349
|
constructor(layer) {
|
|
260
350
|
super();
|
|
@@ -344,7 +434,67 @@ class DrawingFinishedEvent extends PostboyGenericMessage {
|
|
|
344
434
|
}
|
|
345
435
|
DrawingFinishedEvent.ID = 'c724b68e-b4eb-4783-90f1-a8e31973fd36';
|
|
346
436
|
|
|
347
|
-
class
|
|
437
|
+
class DrawingGenerationService {
|
|
438
|
+
static getDraw(ev) {
|
|
439
|
+
return new Draw({
|
|
440
|
+
source: ev.layer.getSource(),
|
|
441
|
+
type: ev.type === DrawingType.Polygon ? 'Polygon' : 'Circle',
|
|
442
|
+
style: ev.style,
|
|
443
|
+
geometryFunction: DrawingGenerationService.geometryFunc(ev.type),
|
|
444
|
+
});
|
|
445
|
+
}
|
|
446
|
+
static geometryFunc(type) {
|
|
447
|
+
switch (type) {
|
|
448
|
+
case DrawingType.Circle:
|
|
449
|
+
return createRegularPolygon(32);
|
|
450
|
+
case DrawingType.Square:
|
|
451
|
+
return createRegularPolygon(4);
|
|
452
|
+
}
|
|
453
|
+
return undefined;
|
|
454
|
+
}
|
|
455
|
+
}
|
|
456
|
+
|
|
457
|
+
class FeatureService {
|
|
458
|
+
constructor() { }
|
|
459
|
+
static filterFeaturesInArea(query) {
|
|
460
|
+
return query.features.filter((f) => FeatureService.booleanIntersects(query.area, f.getGeometry()));
|
|
461
|
+
}
|
|
462
|
+
static booleanIntersects(g1, g2) {
|
|
463
|
+
if (g2.getType() === 'Point')
|
|
464
|
+
return g1.intersectsCoordinate(g2.getCoordinates());
|
|
465
|
+
if (g2.getType() === 'Circle')
|
|
466
|
+
return g1.intersectsCoordinate(g2.getCenter());
|
|
467
|
+
if (g2.getType() === 'Polygon')
|
|
468
|
+
return g1.intersectsCoordinate(g2.getInteriorPoint().getCoordinates());
|
|
469
|
+
return false;
|
|
470
|
+
}
|
|
471
|
+
}
|
|
472
|
+
|
|
473
|
+
class GetFeaturesInAreaQuery extends PostboyCallbackMessage {
|
|
474
|
+
constructor(area, ignore = new Set()) {
|
|
475
|
+
super();
|
|
476
|
+
this.area = area;
|
|
477
|
+
this.ignore = ignore;
|
|
478
|
+
}
|
|
479
|
+
get id() {
|
|
480
|
+
return GetFeaturesInAreaQuery.ID;
|
|
481
|
+
}
|
|
482
|
+
}
|
|
483
|
+
GetFeaturesInAreaQuery.ID = 'efcf4271-a07a-40e0-9f02-d4dade40b8ac';
|
|
484
|
+
|
|
485
|
+
class FilterFeaturesInAreaExecutor extends PostboyExecutor {
|
|
486
|
+
constructor(area, features) {
|
|
487
|
+
super();
|
|
488
|
+
this.area = area;
|
|
489
|
+
this.features = features;
|
|
490
|
+
}
|
|
491
|
+
get id() {
|
|
492
|
+
return FilterFeaturesInAreaExecutor.ID;
|
|
493
|
+
}
|
|
494
|
+
}
|
|
495
|
+
FilterFeaturesInAreaExecutor.ID = '36bb2d94-8028-4512-90dd-2386af3fc67c';
|
|
496
|
+
|
|
497
|
+
class GenerateDrawExecutor extends PostboyExecutor {
|
|
348
498
|
constructor(layer, style, type) {
|
|
349
499
|
super();
|
|
350
500
|
this.layer = layer;
|
|
@@ -352,10 +502,10 @@ class GenerateDrawQuery extends PostboyCallbackMessage {
|
|
|
352
502
|
this.type = type;
|
|
353
503
|
}
|
|
354
504
|
get id() {
|
|
355
|
-
return
|
|
505
|
+
return GenerateDrawExecutor.ID;
|
|
356
506
|
}
|
|
357
507
|
}
|
|
358
|
-
|
|
508
|
+
GenerateDrawExecutor.ID = 'f01c99ba-0953-4ab5-82f9-04e6fbb678c1';
|
|
359
509
|
|
|
360
510
|
class MapPostboyService extends PostboyService {
|
|
361
511
|
constructor() {
|
|
@@ -372,7 +522,7 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "12.2.17", ngImpo
|
|
|
372
522
|
class MapManagementService {
|
|
373
523
|
constructor(postboy) {
|
|
374
524
|
this.postboy = postboy;
|
|
375
|
-
this.layers =
|
|
525
|
+
this.layers = new Dictionary();
|
|
376
526
|
}
|
|
377
527
|
up() {
|
|
378
528
|
this.observeMapRender();
|
|
@@ -382,6 +532,7 @@ class MapManagementService {
|
|
|
382
532
|
this.observeAddTile();
|
|
383
533
|
this.observeRemoveTile();
|
|
384
534
|
this.observeLayerQuery();
|
|
535
|
+
this.observeFeaturesInArea();
|
|
385
536
|
}
|
|
386
537
|
observeRemoveTile() {
|
|
387
538
|
this.postboy.subscribe(RemoveTileCommand.ID).subscribe((c) => {
|
|
@@ -391,7 +542,7 @@ class MapManagementService {
|
|
|
391
542
|
});
|
|
392
543
|
}
|
|
393
544
|
observeLayerQuery() {
|
|
394
|
-
this.postboy.subscribe(GetLayerQuery.ID).subscribe((ev) =>
|
|
545
|
+
this.postboy.subscribe(GetLayerQuery.ID).subscribe((ev) => ev.finish(this.layers.take(ev.name)));
|
|
395
546
|
}
|
|
396
547
|
observeAddTile() {
|
|
397
548
|
this.postboy.subscribe(AddTileCommand.ID).subscribe((c) => {
|
|
@@ -409,18 +560,18 @@ class MapManagementService {
|
|
|
409
560
|
this.postboy.subscribe(AddLayerCommand.ID).subscribe((c) => {
|
|
410
561
|
if (!this.map)
|
|
411
562
|
return;
|
|
412
|
-
this.layers
|
|
563
|
+
this.layers.put(c.layer.get('name'), c.layer);
|
|
413
564
|
this.map.addLayer(c.layer);
|
|
414
565
|
});
|
|
415
566
|
}
|
|
416
567
|
observePlaceFeatures() {
|
|
417
568
|
this.postboy.subscribe(PlaceLayerFeaturesCommand.ID).subscribe((c) => {
|
|
418
|
-
var _a
|
|
419
|
-
if (!this.layers
|
|
569
|
+
var _a;
|
|
570
|
+
if (!this.layers.has(c.layer))
|
|
420
571
|
return;
|
|
421
|
-
let source =
|
|
572
|
+
let source = this.layers.take(c.layer).getSource();
|
|
422
573
|
if (!!source['getSource'])
|
|
423
|
-
source = (
|
|
574
|
+
source = (_a = source) === null || _a === void 0 ? void 0 : _a.getSource();
|
|
424
575
|
source === null || source === void 0 ? void 0 : source.clear();
|
|
425
576
|
source === null || source === void 0 ? void 0 : source.addFeatures(c.features);
|
|
426
577
|
});
|
|
@@ -429,10 +580,27 @@ class MapManagementService {
|
|
|
429
580
|
this.postboy.subscribe(RemoveLayerCommand.ID).subscribe((c) => {
|
|
430
581
|
if (!this.map)
|
|
431
582
|
return;
|
|
432
|
-
|
|
583
|
+
this.layers.rmv(c.layer.get('name'));
|
|
433
584
|
this.map.removeLayer(c.layer);
|
|
434
585
|
});
|
|
435
586
|
}
|
|
587
|
+
observeFeaturesInArea() {
|
|
588
|
+
this.postboy.subscribe(GetFeaturesInAreaQuery.ID).subscribe((qr) => {
|
|
589
|
+
let result = new Dictionary();
|
|
590
|
+
this.layers.forEach((l) => {
|
|
591
|
+
var _a, _b;
|
|
592
|
+
let layerName = l.get('name');
|
|
593
|
+
if (qr.ignore.has(layerName) || layerName === MapConstants.DrawingLayerId)
|
|
594
|
+
return;
|
|
595
|
+
let source = l.getSource();
|
|
596
|
+
if (!!source['getSource'])
|
|
597
|
+
source = (_a = source) === null || _a === void 0 ? void 0 : _a.getSource();
|
|
598
|
+
let features = this.postboy.execute(new FilterFeaturesInAreaExecutor(qr.area, (_b = source === null || source === void 0 ? void 0 : source.getFeatures()) !== null && _b !== void 0 ? _b : []));
|
|
599
|
+
result.put(layerName, features.map((e) => (Object.assign({ id: e.getId() }, e.get(MapConstants.FeatureInfo)))));
|
|
600
|
+
});
|
|
601
|
+
qr.finish(result);
|
|
602
|
+
});
|
|
603
|
+
}
|
|
436
604
|
}
|
|
437
605
|
MapManagementService.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "12.2.17", ngImport: i0, type: MapManagementService, deps: [{ token: MapPostboyService }], target: i0.ɵɵFactoryTarget.Injectable });
|
|
438
606
|
MapManagementService.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "12.2.17", ngImport: i0, type: MapManagementService });
|
|
@@ -550,27 +718,43 @@ class DrawingService {
|
|
|
550
718
|
this.postboy = postboy;
|
|
551
719
|
}
|
|
552
720
|
up() {
|
|
721
|
+
this.observeDrawing();
|
|
722
|
+
this.observeSelectArea();
|
|
723
|
+
this.observeMapRender();
|
|
724
|
+
}
|
|
725
|
+
observeSelectArea() {
|
|
726
|
+
this.postboy.subscribe(DrawSelectionAreaCommand.ID).subscribe((ev) => {
|
|
727
|
+
const drawingCommand = new StartDrawingCommand(ev.type, ev.style);
|
|
728
|
+
drawingCommand.result.subscribe((r) => {
|
|
729
|
+
if (!r) {
|
|
730
|
+
ev.finish(new Dictionary());
|
|
731
|
+
return;
|
|
732
|
+
}
|
|
733
|
+
const area = PolygonModel.fromGeoJson(1, r).feature.getGeometry();
|
|
734
|
+
const getFeaturesCommand = new GetFeaturesInAreaQuery(area, ev.ignore);
|
|
735
|
+
getFeaturesCommand.result.subscribe((result) => ev.finish(result));
|
|
736
|
+
this.postboy.fire(getFeaturesCommand);
|
|
737
|
+
});
|
|
738
|
+
this.postboy.fire(drawingCommand);
|
|
739
|
+
});
|
|
740
|
+
}
|
|
741
|
+
observeDrawing() {
|
|
553
742
|
this.postboy.subscribe(StartDrawingCommand.ID).subscribe((ev) => {
|
|
554
743
|
this.draw((l) => {
|
|
744
|
+
var _a;
|
|
555
745
|
if (!l || !this.map) {
|
|
556
746
|
this.clearInteraction(l);
|
|
557
747
|
return;
|
|
558
748
|
}
|
|
559
|
-
const
|
|
560
|
-
|
|
561
|
-
|
|
562
|
-
|
|
563
|
-
|
|
564
|
-
|
|
565
|
-
this.drawInteraction.on('drawend', (evt) => {
|
|
566
|
-
cancelSub.unsubscribe();
|
|
567
|
-
this.onEnd(evt, ev, l);
|
|
568
|
-
});
|
|
749
|
+
const cancelSub = this.observeCancelation(ev, l);
|
|
750
|
+
this.drawInteraction = this.postboy.execute(new GenerateDrawExecutor(l, ev.style, ev.type));
|
|
751
|
+
(_a = this.map) === null || _a === void 0 ? void 0 : _a.addInteraction(this.drawInteraction);
|
|
752
|
+
this.drawInteraction.on('drawend', (evt) => {
|
|
753
|
+
cancelSub.unsubscribe();
|
|
754
|
+
this.onEnd(evt, ev, l);
|
|
569
755
|
});
|
|
570
|
-
this.postboy.fire(drawQuery);
|
|
571
756
|
});
|
|
572
757
|
});
|
|
573
|
-
this.observeMapRender();
|
|
574
758
|
}
|
|
575
759
|
onEnd(evt, command, layer) {
|
|
576
760
|
command.finish(command.format === FeatureOutputFormat.GeoJson
|
|
@@ -612,31 +796,101 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "12.2.17", ngImpo
|
|
|
612
796
|
type: Injectable
|
|
613
797
|
}], ctorParameters: function () { return [{ type: MapPostboyService }]; } });
|
|
614
798
|
|
|
615
|
-
class
|
|
799
|
+
class FeatureModificationService {
|
|
616
800
|
constructor(postboy) {
|
|
617
801
|
this.postboy = postboy;
|
|
618
802
|
}
|
|
619
803
|
up() {
|
|
620
|
-
this.
|
|
621
|
-
|
|
622
|
-
|
|
623
|
-
|
|
624
|
-
|
|
625
|
-
|
|
626
|
-
|
|
804
|
+
this.observeModification();
|
|
805
|
+
this.observeMapRender();
|
|
806
|
+
}
|
|
807
|
+
observeModification() {
|
|
808
|
+
this.postboy.subscribe(ModifyFeatureCommand.ID).subscribe((ev) => {
|
|
809
|
+
this.defineLayer((l) => {
|
|
810
|
+
if (!l || !this.map) {
|
|
811
|
+
this.clearInteraction(l);
|
|
812
|
+
return;
|
|
813
|
+
}
|
|
814
|
+
this.observeCancelation(ev, l);
|
|
815
|
+
this.initFeature(l, ev.model.feature);
|
|
816
|
+
this.addModify(ev);
|
|
817
|
+
this.addDragging(ev);
|
|
818
|
+
});
|
|
819
|
+
});
|
|
820
|
+
}
|
|
821
|
+
initFeature(layer, feature) {
|
|
822
|
+
var _a, _b;
|
|
823
|
+
(_a = layer.getSource()) === null || _a === void 0 ? void 0 : _a.clear();
|
|
824
|
+
(_b = layer.getSource()) === null || _b === void 0 ? void 0 : _b.addFeature(feature);
|
|
825
|
+
}
|
|
826
|
+
addModify(command) {
|
|
827
|
+
var _a;
|
|
828
|
+
this.modify = new Modify({
|
|
829
|
+
features: new Collection([command.model.feature]),
|
|
830
|
+
style: command.style,
|
|
831
|
+
});
|
|
832
|
+
this.modify.on('modifyend', () => {
|
|
833
|
+
this.onModified(command);
|
|
834
|
+
command.model.feature.changed();
|
|
835
|
+
});
|
|
836
|
+
(_a = this.map) === null || _a === void 0 ? void 0 : _a.addInteraction(this.modify);
|
|
837
|
+
}
|
|
838
|
+
addDragging(command) {
|
|
839
|
+
var _a;
|
|
840
|
+
this.translate = new Translate({
|
|
841
|
+
features: new Collection([command.model.feature]),
|
|
842
|
+
condition: (ev) => {
|
|
843
|
+
var _a;
|
|
844
|
+
const clone = command.model.feature.clone();
|
|
845
|
+
(_a = clone.getGeometry()) === null || _a === void 0 ? void 0 : _a.scale(0.999);
|
|
846
|
+
return clone.getGeometry().intersectsCoordinate(ev.coordinate);
|
|
847
|
+
},
|
|
848
|
+
});
|
|
849
|
+
this.translate.on('translateend', () => this.onModified(command));
|
|
850
|
+
(_a = this.map) === null || _a === void 0 ? void 0 : _a.addInteraction(this.translate);
|
|
851
|
+
}
|
|
852
|
+
onModified(command) {
|
|
853
|
+
command.next(command.format === FeatureOutputFormat.GeoJson
|
|
854
|
+
? new GeoJSON().writeFeature(command.model.feature)
|
|
855
|
+
: new WKT().writeFeature(command.model.feature));
|
|
856
|
+
}
|
|
857
|
+
observeMapRender() {
|
|
858
|
+
this.postboy.subscribe(MapRenderedEvent.ID).subscribe((m) => {
|
|
859
|
+
this.map = m.map;
|
|
860
|
+
});
|
|
861
|
+
}
|
|
862
|
+
defineLayer(action) {
|
|
863
|
+
const query = new GetLayerQuery(MapConstants.DrawingLayerId);
|
|
864
|
+
query.result.subscribe((l) => action(l));
|
|
865
|
+
this.postboy.fire(query);
|
|
866
|
+
}
|
|
867
|
+
observeCancelation(ev, layer) {
|
|
868
|
+
return this.postboy
|
|
869
|
+
.subscribe(CancelFeatureModificationCommand.ID)
|
|
870
|
+
.pipe(first())
|
|
871
|
+
.subscribe(() => {
|
|
872
|
+
ev.finish(null);
|
|
873
|
+
this.clearInteraction(layer);
|
|
627
874
|
});
|
|
628
875
|
}
|
|
876
|
+
clearInteraction(layer) {
|
|
877
|
+
var _a, _b;
|
|
878
|
+
if (this.modify)
|
|
879
|
+
(_a = this.map) === null || _a === void 0 ? void 0 : _a.removeInteraction(this.modify);
|
|
880
|
+
if (this.translate)
|
|
881
|
+
(_b = this.map) === null || _b === void 0 ? void 0 : _b.removeInteraction(this.translate);
|
|
882
|
+
}
|
|
629
883
|
}
|
|
630
|
-
|
|
631
|
-
|
|
632
|
-
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "12.2.17", ngImport: i0, type:
|
|
884
|
+
FeatureModificationService.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "12.2.17", ngImport: i0, type: FeatureModificationService, deps: [{ token: MapPostboyService }], target: i0.ɵɵFactoryTarget.Injectable });
|
|
885
|
+
FeatureModificationService.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "12.2.17", ngImport: i0, type: FeatureModificationService });
|
|
886
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "12.2.17", ngImport: i0, type: FeatureModificationService, decorators: [{
|
|
633
887
|
type: Injectable
|
|
634
888
|
}], ctorParameters: function () { return [{ type: MapPostboyService }]; } });
|
|
635
889
|
|
|
636
890
|
class MessageRegistratorService extends PostboyAbstractRegistrator {
|
|
637
|
-
constructor(service, management, state,
|
|
891
|
+
constructor(service, management, state, mapFeature, interaction, drawing, featureModification) {
|
|
638
892
|
super(service);
|
|
639
|
-
this.registerServices([management, state, interaction,
|
|
893
|
+
this.registerServices([management, state, interaction, mapFeature, drawing, featureModification]);
|
|
640
894
|
}
|
|
641
895
|
_up() {
|
|
642
896
|
this.registerReplay(MapRenderedEvent.ID);
|
|
@@ -653,14 +907,22 @@ class MessageRegistratorService extends PostboyAbstractRegistrator {
|
|
|
653
907
|
this.registerSubject(StartDrawingCommand.ID);
|
|
654
908
|
this.registerSubject(GetLayerQuery.ID);
|
|
655
909
|
this.registerSubject(DrawingFinishedEvent.ID);
|
|
656
|
-
this.registerSubject(
|
|
910
|
+
this.registerSubject(GetFeaturesInAreaQuery.ID);
|
|
911
|
+
this.registerSubject(DrawSelectionAreaCommand.ID);
|
|
912
|
+
this.registerSubject(CancelFeatureModificationCommand.ID);
|
|
913
|
+
this.registerSubject(ModifyFeatureCommand.ID);
|
|
914
|
+
this.setExecutors();
|
|
915
|
+
}
|
|
916
|
+
setExecutors() {
|
|
917
|
+
this.registerExecutor(FilterFeaturesInAreaExecutor.ID, (e) => FeatureService.filterFeaturesInArea(e));
|
|
918
|
+
this.registerExecutor(GenerateDrawExecutor.ID, (e) => DrawingGenerationService.getDraw(e));
|
|
657
919
|
}
|
|
658
920
|
}
|
|
659
|
-
MessageRegistratorService.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "12.2.17", ngImport: i0, type: MessageRegistratorService, deps: [{ token: MapPostboyService }, { token: MapManagementService }, { token: MapStateService }, { token: MapFeatureService }, { token: MapClickService }, { token: DrawingService }, { token:
|
|
921
|
+
MessageRegistratorService.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "12.2.17", ngImport: i0, type: MessageRegistratorService, deps: [{ token: MapPostboyService }, { token: MapManagementService }, { token: MapStateService }, { token: MapFeatureService }, { token: MapClickService }, { token: DrawingService }, { token: FeatureModificationService }], target: i0.ɵɵFactoryTarget.Injectable });
|
|
660
922
|
MessageRegistratorService.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "12.2.17", ngImport: i0, type: MessageRegistratorService });
|
|
661
923
|
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "12.2.17", ngImport: i0, type: MessageRegistratorService, decorators: [{
|
|
662
924
|
type: Injectable
|
|
663
|
-
}], ctorParameters: function () { return [{ type: MapPostboyService }, { type: MapManagementService }, { type: MapStateService }, { type: MapFeatureService }, { type: MapClickService }, { type: DrawingService }, { type:
|
|
925
|
+
}], ctorParameters: function () { return [{ type: MapPostboyService }, { type: MapManagementService }, { type: MapStateService }, { type: MapFeatureService }, { type: MapClickService }, { type: DrawingService }, { type: FeatureModificationService }]; } });
|
|
664
926
|
|
|
665
927
|
class TileLayerSettings {
|
|
666
928
|
constructor() {
|
|
@@ -1238,6 +1500,8 @@ MapPlateComponent.ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "12.0.0", vers
|
|
|
1238
1500
|
MapFeatureService,
|
|
1239
1501
|
DrawingService,
|
|
1240
1502
|
DrawingGenerationService,
|
|
1503
|
+
FeatureService,
|
|
1504
|
+
FeatureModificationService,
|
|
1241
1505
|
], 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"], components: [{ type: OsmTileLayerComponent, selector: "lib-osm-tile-layer", inputs: ["url", "map"] }, { type: FeatureLayerComponent, selector: "lib-feature-layer", inputs: ["settings"] }], directives: [{ type: i6.NgIf, selector: "[ngIf]", inputs: ["ngIf", "ngIfThen", "ngIfElse"] }], changeDetection: i0.ChangeDetectionStrategy.OnPush });
|
|
1242
1506
|
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "12.2.17", ngImport: i0, type: MapPlateComponent, decorators: [{
|
|
1243
1507
|
type: Component,
|
|
@@ -1254,6 +1518,8 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "12.2.17", ngImpo
|
|
|
1254
1518
|
MapFeatureService,
|
|
1255
1519
|
DrawingService,
|
|
1256
1520
|
DrawingGenerationService,
|
|
1521
|
+
FeatureService,
|
|
1522
|
+
FeatureModificationService,
|
|
1257
1523
|
],
|
|
1258
1524
|
}]
|
|
1259
1525
|
}], ctorParameters: function () { return [{ type: i0.ElementRef }, { type: MapPostboyService }, { type: MapPlateFactory }, { type: MessageRegistratorService }, { type: i0.ChangeDetectorRef }]; }, propDecorators: { settings: [{
|
|
@@ -1528,6 +1794,23 @@ class PolygonStyleHelper {
|
|
|
1528
1794
|
}),
|
|
1529
1795
|
});
|
|
1530
1796
|
}
|
|
1797
|
+
static edit(fill, stroke, strokeWidth = 1, pinRadius = 5) {
|
|
1798
|
+
return new Style({
|
|
1799
|
+
image: new Circle({
|
|
1800
|
+
fill: new Fill({
|
|
1801
|
+
color: stroke,
|
|
1802
|
+
}),
|
|
1803
|
+
radius: pinRadius,
|
|
1804
|
+
}),
|
|
1805
|
+
fill: new Fill({
|
|
1806
|
+
color: fill,
|
|
1807
|
+
}),
|
|
1808
|
+
stroke: new Stroke({
|
|
1809
|
+
color: stroke,
|
|
1810
|
+
width: strokeWidth,
|
|
1811
|
+
}),
|
|
1812
|
+
});
|
|
1813
|
+
}
|
|
1531
1814
|
}
|
|
1532
1815
|
|
|
1533
1816
|
class TextStyleHelper {
|
|
@@ -1602,5 +1885,5 @@ class StringifyFeatureHelper {
|
|
|
1602
1885
|
* Generated bundle index. Do not edit.
|
|
1603
1886
|
*/
|
|
1604
1887
|
|
|
1605
|
-
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 };
|
|
1888
|
+
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 };
|
|
1606
1889
|
//# sourceMappingURL=maps-components-src-map.js.map
|