adb-shared 7.0.15 → 22.0.0-beta.1

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.
@@ -1,900 +1,2277 @@
1
- import * as i1$1 from '@angular/common';
2
- import { CommonModule } from '@angular/common';
3
- import * as i0 from '@angular/core';
4
- import { forwardRef, ChangeDetectionStrategy, Component, InjectionToken, Inject, Injectable, Input, signal, effect, NgModule } from '@angular/core';
5
- import * as i4 from '@angular/forms';
6
- import { NG_VALUE_ACCESSOR, FormControl, FormGroup, FormArray, Validators, FormsModule, ReactiveFormsModule } from '@angular/forms';
7
- import * as Leaflet from 'leaflet';
8
- import Leaflet__default from 'leaflet';
9
- import '@geoman-io/leaflet-geoman-free';
10
- import { Subscription, combineLatest, map, debounceTime } from 'rxjs';
11
- import * as i1 from '@ngx-translate/core';
12
- import { TranslatePipe } from '@ngx-translate/core';
13
- import * as i1$2 from '@angular/router';
14
- import { RouterModule } from '@angular/router';
15
- import { finalize } from 'rxjs/operators';
16
- import * as i3 from '@angular/common/http';
17
- import * as i5 from 'adb-shared';
18
- import { AdbDatePickerModule, AdbPipesModule, AdbFilterSectionModule, AdbPickerModule } from 'adb-shared';
19
- import { addYears, startOfYear, endOfYear, startOfDay, endOfDay, parseISO } from 'date-fns';
20
-
21
- class AdbMapUtils {
22
- static INITIAL_CENTER_LAT = 62;
23
- static INITIAL_CENTER_LNG = 17;
24
- static OverlayMaps = {
25
- 'Altitude': new Leaflet.TileLayer.WMS("https://maps.sgu.se/lmv/hojdmodell/v1.1?SERVICE=WMS", { layers: "terrangskuggning", format: "image/png", transparent: true, opacity: 0.3, maxZoom: 16, version: "1.3.0" }),
26
- 'Fjällkarta': new Leaflet.TileLayer.WMS('api/maps/mountain', {
27
- minZoom: 6,
28
- maxZoom: 18,
29
- maxNativeZoom: 14,
30
- attribution: '© <a href="https://www.lantmateriet.se/">Fjällkart</a>',
31
- wms: true
32
- }),
33
- 'Kommuner': new Leaflet.TileLayer.WMS('https://sosgeo.artdata.slu.se/geoserver/GeoRegion/wms?', {
34
- layers: 'GeoRegion:Municipality',
35
- version: '1.1.0',
36
- transparent: true,
37
- format: 'image/png'
38
- }),
39
- 'Län': new Leaflet.TileLayer.WMS('https://sosgeo.artdata.slu.se/geoserver/GeoRegion/wms?', {
40
- layers: 'GeoRegion:County',
41
- version: '1.1.0',
42
- transparent: true,
43
- format: 'image/png'
44
- }),
45
- 'Ortnamn': new Leaflet.TileLayer.WMS("https://maps.sgu.se/lmv/topowebb-skikt/v1.1?SERVICE=WMS", {
46
- layers: "text",
47
- format: "image/png",
48
- transparent: true,
49
- version: "1.3.0",
50
- }),
51
- 'Ekonomisk zon': new Leaflet.TileLayer.WMS("https://sosgeo.artdata.slu.se/geoserver/it.geosolutions/wms?", {
52
- layers: "it.geosolutions:Ekonomiska_zonens_yttre_avgränsningslinjer_linje",
53
- format: "image/png",
54
- transparent: true,
55
- version: "1.1.0"
56
- })
57
- };
58
- static Providers = [
59
- {
60
- name: 'Open Streetmap',
61
- id: 3,
62
- url: 'https://{s}.tile.openstreetmap.org/{z}/{x}/{y}.png',
63
- minZoom: 0,
64
- maxZoom: 18,
65
- params: {
66
- maxNativeZoom: 18,
67
- attribution: '© <a href="https://www.openstreetmap.org/copyright">OpenStreetMap</a> contributors'
68
- },
69
- wms: false
70
- },
71
- {
72
- name: 'Sveriges gränser',
73
- id: 7,
74
- url: 'https://sosgeo.artdata.slu.se/geoserver/it.geosolutions/wms',
75
- minZoom: 6,
76
- maxZoom: 18,
77
- params: {
78
- maxNativeZoom: 14,
79
- attribution: '© <a href="https://www.lantmateriet.se/">Sveriges gränser</a>',
80
- layers: 'it.geosolutions:Sverige_epsg5845', styles: 'municipality_name_yellow',
81
- epsg: 5845
82
- },
83
- wms: true
84
- }
85
- ];
86
- //NOTE: Will be move
87
- static redListMapper2 = {
88
- 'VU': '228',
89
- 'EN': '229',
90
- 'CR': '230',
91
- 'RE': '231',
92
- 'DD': '232',
93
- 'NT': '233'
94
- };
95
- static createMap(elementId, options = {}) {
96
- const map = Leaflet.map(elementId, {
97
- zoomAnimation: false,
98
- fadeAnimation: false,
99
- markerZoomAnimation: false,
100
- inertia: false,
101
- scrollWheelZoom: options.scrollZoom ?? true,
102
- zoomControl: options.zoom ?? true,
103
- dragging: options.zoom ?? true,
104
- minZoom: -1,
105
- zoomDelta: 1
106
- });
107
- map.setView([62, 17], 5);
108
- Leaflet.control.scale().addTo(map);
109
- if (options.providers !== false) {
110
- this.addProviders(map);
111
- }
112
- return map;
113
- }
114
- static addProviders(map) {
115
- const backgroundMaps = {};
116
- for (const value of Object.values(AdbMapUtils.Providers)) {
117
- backgroundMaps[value.name] = value.wms
118
- ? Leaflet.tileLayer.wms(value.url, value.params)
119
- : Leaflet.tileLayer(value.url, value.params);
120
- }
121
- if (backgroundMaps['Open Streetmap']) {
122
- map.addLayer(backgroundMaps['Open Streetmap']);
123
- }
124
- Leaflet.control.layers(backgroundMaps, AdbMapUtils.OverlayMaps).addTo(map);
125
- }
126
- }
127
-
128
- class PolygonDrawerInput {
129
- subscriptions = new Subscription();
130
- mapId = "" + Math.floor(Math.random() * Date.now());
131
- map;
132
- polygonDraw = false;
133
- shapeLayer;
134
- geoJson;
135
- ngAfterViewInit() {
136
- this.map = AdbMapUtils.createMap(this.mapId, {
137
- zoom: true,
138
- scrollZoom: true,
139
- providers: true
140
- });
141
- this.map.whenReady(() => {
142
- this.initDraw();
143
- this.renderInitialShape();
144
- });
145
- }
146
- ngOnInit() { }
147
- ngOnDestroy() {
148
- this.subscriptions.unsubscribe();
149
- }
150
- initDraw() {
151
- this.map.pm.removeControls();
152
- this.map.pm.enableDraw('Polygon', {
153
- tooltips: false,
154
- finishOn: 'snap',
155
- snapDistance: 30,
156
- snapMiddle: false
157
- });
158
- this.map.on("pm:create", (e) => {
159
- if (e.shape !== 'Polygon' && e.shape !== 'Circle')
160
- return;
161
- this.polygonDraw = false;
162
- this.map.pm.disableDraw();
163
- this.clearShape();
164
- this.shapeLayer = e.layer;
165
- if (this.shapeLayer instanceof Leaflet__default.Path) {
166
- this.shapeLayer.setStyle({ fillOpacity: 0.5 });
167
- }
168
- this.shapeLayer.interactive = false;
169
- this.map.fitBounds(this.shapeLayer.getBounds());
170
- const geo = this.shapeLayer.toGeoJSON();
171
- if (this.shapeLayer instanceof Leaflet__default.Circle) {
172
- geo.properties = {
173
- ...geo.properties,
174
- radius: Math.ceil(this.shapeLayer.getRadius())
175
- };
176
- }
177
- this.onChange(geo);
178
- });
179
- }
180
- renderInitialShape() {
181
- if (this.geoJson?.type === "Feature") {
182
- this.shapeLayer = Leaflet__default.geoJSON(this.geoJson, {
183
- interactive: false
184
- });
185
- this.map.addLayer(this.shapeLayer);
186
- this.map.fitBounds(this.shapeLayer.getBounds());
187
- }
188
- else {
189
- this.map.setView([AdbMapUtils.INITIAL_CENTER_LAT, AdbMapUtils.INITIAL_CENTER_LNG], 5);
190
- }
191
- }
192
- clearShape() {
193
- if (this.shapeLayer) {
194
- this.map.removeLayer(this.shapeLayer);
195
- this.shapeLayer = null;
196
- }
197
- }
198
- onDrawPolygon() {
199
- this.polygonDraw = true;
200
- this.map.pm.enableDraw("Polygon", {
201
- allowSelfIntersection: false,
202
- snappable: false
203
- });
204
- }
205
- onDrawCircle() {
206
- this.polygonDraw = true;
207
- this.map.pm.enableDraw("Circle", {
208
- allowSelfIntersection: false,
209
- snappable: false
210
- });
211
- }
212
- onUndoStep() {
213
- const draw = this.map.pm.Draw?.Polygon;
214
- draw?._removeLastVertex();
215
- }
216
- onDeleteShape() {
217
- this.clearShape();
218
- this.map.pm.disableDraw();
219
- this.polygonDraw = false;
220
- this.onChange(null);
221
- this.map.setView([62, 17], 5);
222
- }
223
- // ControlValueAccessor
224
- onChange = () => { };
225
- onTouched = () => { };
226
- writeValue(geoJson) {
227
- this.geoJson = geoJson;
228
- }
229
- registerOnChange(fn) {
230
- this.onChange = fn;
231
- }
232
- registerOnTouched(fn) {
233
- this.onTouched = fn;
234
- }
235
- setDisabledState(isDisabled) { }
236
- static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "21.2.25", ngImport: i0, type: PolygonDrawerInput, deps: [], target: i0.ɵɵFactoryTarget.Component });
237
- static ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "17.0.0", version: "21.2.25", type: PolygonDrawerInput, isStandalone: false, selector: "adb-polygon-drawer", providers: [
238
- {
239
- provide: NG_VALUE_ACCESSOR,
240
- useExisting: forwardRef(() => PolygonDrawerInput),
241
- multi: true
242
- }
243
- ], ngImport: i0, template: "<div class=\"mb-1 d-flex gap-1 flex-wrap align-items-start\">\r\n <button class=\"btn btn-secondary\" type=\"button\" [disabled]=\"shapeLayer\" (click)=\"onDrawPolygon()\" title=\"Polygon\">\r\n <span class=\"bi bi-pentagon\"></span> {{'OBSERVATION.DRAW'|translate}}\r\n </button>\r\n <button class=\"btn btn-secondary\" type=\"button\" [disabled]=\"shapeLayer\" (click)=\"onDrawCircle()\" title=\"Circle\">\r\n <span class=\"bi bi-circle\"></span> {{'OBSERVATION.DRAW_CIRCLE'|translate}}\r\n </button>\r\n @if (shapeLayer) {\r\n <button class=\"btn btn-secondary\" type=\"button\" (click)=\"onDeleteShape()\" title=\"Ta bort\">\r\n <span class=\"bi bi-x\"></span>\r\n </button>\r\n }\r\n @if (polygonDraw) {\r\n <button class=\"btn btn-secondary\" type=\"button\" (click)=\"onUndoStep()\" title=\"\u00C5ngra\">\r\n <span class=\"bi bi-arrow-counterclockwise\"></span>\r\n </button>\r\n }\r\n</div>\r\n<div [id]=\"mapId\" class=\"border\" style=\"height:20rem\"></div>", dependencies: [{ kind: "pipe", type: i1.TranslatePipe, name: "translate" }], changeDetection: i0.ChangeDetectionStrategy.Eager });
244
- }
245
- i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "21.2.25", ngImport: i0, type: PolygonDrawerInput, decorators: [{
246
- type: Component,
247
- args: [{ selector: "adb-polygon-drawer", standalone: false, changeDetection: ChangeDetectionStrategy.Eager, providers: [
248
- {
249
- provide: NG_VALUE_ACCESSOR,
250
- useExisting: forwardRef(() => PolygonDrawerInput),
251
- multi: true
252
- }
253
- ], template: "<div class=\"mb-1 d-flex gap-1 flex-wrap align-items-start\">\r\n <button class=\"btn btn-secondary\" type=\"button\" [disabled]=\"shapeLayer\" (click)=\"onDrawPolygon()\" title=\"Polygon\">\r\n <span class=\"bi bi-pentagon\"></span> {{'OBSERVATION.DRAW'|translate}}\r\n </button>\r\n <button class=\"btn btn-secondary\" type=\"button\" [disabled]=\"shapeLayer\" (click)=\"onDrawCircle()\" title=\"Circle\">\r\n <span class=\"bi bi-circle\"></span> {{'OBSERVATION.DRAW_CIRCLE'|translate}}\r\n </button>\r\n @if (shapeLayer) {\r\n <button class=\"btn btn-secondary\" type=\"button\" (click)=\"onDeleteShape()\" title=\"Ta bort\">\r\n <span class=\"bi bi-x\"></span>\r\n </button>\r\n }\r\n @if (polygonDraw) {\r\n <button class=\"btn btn-secondary\" type=\"button\" (click)=\"onUndoStep()\" title=\"\u00C5ngra\">\r\n <span class=\"bi bi-arrow-counterclockwise\"></span>\r\n </button>\r\n }\r\n</div>\r\n<div [id]=\"mapId\" class=\"border\" style=\"height:20rem\"></div>" }]
254
- }] });
255
-
256
- var AdbMapFilterType;
257
- (function (AdbMapFilterType) {
258
- AdbMapFilterType["Taxon"] = "taxon";
259
- AdbMapFilterType["Area"] = "area";
260
- AdbMapFilterType["OwnArea"] = "ownArea";
261
- AdbMapFilterType["Time"] = "time";
262
- AdbMapFilterType["RedList"] = "redlist";
263
- AdbMapFilterType["RiskList"] = "risklist";
264
- AdbMapFilterType["TaxaLists"] = "taxonLists";
265
- AdbMapFilterType["Datasources"] = "datasources";
266
- })(AdbMapFilterType || (AdbMapFilterType = {}));
267
- class VisibleFilters {
268
- showTaxon;
269
- showTime;
270
- showArea;
271
- showOwnArea;
272
- showTaxaLists;
273
- showDatasets;
274
- }
275
- const ADB_MAP_CONFIG = new InjectionToken('ADB_MAP_CONFIG');
276
- class AdbMapConfigService {
277
- log;
278
- artfaktaTaxonLists;
279
- observationFeatures;
280
- taxaListsApi;
281
- filters;
282
- observationPage;
283
- dynamic;
284
- constructor(config) {
285
- this.log = config.log ?? false;
286
- this.dynamic = config.dynamic ?? false;
287
- this.artfaktaTaxonLists = config.artfaktaTaxonLists ?? 'https://artfakta.se/metadata/listor';
288
- this.taxaListsApi = config.api + '/taxalists';
289
- this.observationFeatures = config.api + '/observation-features';
290
- this.observationPage = config.observationPage ?? 'https://mobil.artportalen.se/observationer';
291
- this.filters = {
292
- showTaxon: this.hasFilter(AdbMapFilterType.Taxon, config.filters),
293
- showTime: this.hasFilter(AdbMapFilterType.Time, config.filters),
294
- showArea: this.hasFilter(AdbMapFilterType.Area, config.filters),
295
- showOwnArea: this.hasFilter(AdbMapFilterType.OwnArea, config.filters),
296
- showTaxaLists: this.hasFilter(AdbMapFilterType.TaxaLists, config.filters),
297
- showDatasets: this.hasFilter(AdbMapFilterType.Datasources, config.filters)
298
- };
299
- }
300
- hasFilter(f, filters) {
301
- return filters?.includes(f) ?? true;
302
- }
303
- static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "21.2.25", ngImport: i0, type: AdbMapConfigService, deps: [{ token: ADB_MAP_CONFIG }], target: i0.ɵɵFactoryTarget.Injectable });
304
- static ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "21.2.25", ngImport: i0, type: AdbMapConfigService });
305
- }
306
- i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "21.2.25", ngImport: i0, type: AdbMapConfigService, decorators: [{
307
- type: Injectable
308
- }], ctorParameters: () => [{ type: undefined, decorators: [{
309
- type: Inject,
310
- args: [ADB_MAP_CONFIG]
311
- }] }] });
312
-
313
- class TreeviewComponent {
314
- nodes = [];
315
- selectedIds = [];
316
- onChange = () => { };
317
- onTouched = () => { };
318
- writeValue(ids) {
319
- this.selectedIds = ids ?? [];
320
- this.applySelection(this.nodes);
321
- }
322
- registerOnChange(fn) {
323
- this.onChange = fn;
324
- }
325
- registerOnTouched(fn) {
326
- this.onTouched = fn;
327
- }
328
- setDisabledState(isDisabled) {
329
- this.setReadOnly(this.nodes, isDisabled);
330
- }
331
- onLeafToggle(node) {
332
- if (node._readOnly)
333
- return;
334
- node._selected = !node._selected;
335
- this.selectedIds = TreeviewComponent.collectSelectedLeafIds(this.nodes);
336
- this.onChange(this.selectedIds);
337
- this.onTouched();
338
- }
339
- applySelection(nodes) {
340
- for (const node of nodes) {
341
- if (node.children?.length) {
342
- this.applySelection(node.children);
343
- }
344
- else {
345
- node._selected = this.selectedIds.includes(node.id);
346
- }
347
- }
348
- }
349
- setReadOnly(nodes, readOnly) {
350
- for (const node of nodes) {
351
- node._readOnly = readOnly;
352
- if (node.children?.length) {
353
- this.setReadOnly(node.children, readOnly);
354
- }
355
- }
356
- }
357
- static collectSelectedLeafIds(nodes) {
358
- const ids = [];
359
- for (const node of nodes) {
360
- if (node.children?.length) {
361
- ids.push(...this.collectSelectedLeafIds(node.children));
362
- }
363
- else if (node._selected) {
364
- ids.push(node.id);
365
- }
366
- }
367
- return ids;
368
- }
369
- static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "21.2.25", ngImport: i0, type: TreeviewComponent, deps: [], target: i0.ɵɵFactoryTarget.Component });
370
- static ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "17.0.0", version: "21.2.25", type: TreeviewComponent, isStandalone: false, selector: "app-treeview", inputs: { nodes: "nodes" }, providers: [
371
- {
372
- provide: NG_VALUE_ACCESSOR,
373
- useExisting: forwardRef(() => TreeviewComponent),
374
- multi: true
375
- }
376
- ], ngImport: i0, template: "<ng-container *ngTemplateOutlet=\"nodeTpl; context: { $implicit: nodes }\">\r\n</ng-container>\r\n<ng-template #nodeTpl let-nodes>\r\n @for (node of nodes; track node) {\r\n <div class=\"ms-3\">\r\n @if(!node.children || node.children.length === 0){\r\n <div class=\"d-flex align-items-center gap-2\">\r\n <input id=\"{{node.id}}\" type=\"checkbox\" class=\"form-check-input m-0\" [checked]=\"node._selected\" [disabled]=\"node._readOnly\" (change)=\"onLeafToggle(node)\" />\r\n <label for=\"{{node.id}}\">{{ node.name }}</label>\r\n </div>\r\n }\r\n @else {\r\n {{ node.name }}\r\n <div>\r\n <ng-container *ngTemplateOutlet=\"nodeTpl; context: { $implicit: node.children }\">\r\n </ng-container>\r\n </div>\r\n }\r\n </div>\r\n}\r\n</ng-template>", dependencies: [{ kind: "directive", type: i1$1.NgTemplateOutlet, selector: "[ngTemplateOutlet]", inputs: ["ngTemplateOutletContext", "ngTemplateOutlet", "ngTemplateOutletInjector"] }], changeDetection: i0.ChangeDetectionStrategy.Eager });
377
- }
378
- i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "21.2.25", ngImport: i0, type: TreeviewComponent, decorators: [{
379
- type: Component,
380
- args: [{ selector: 'app-treeview', standalone: false, changeDetection: ChangeDetectionStrategy.Eager, providers: [
381
- {
382
- provide: NG_VALUE_ACCESSOR,
383
- useExisting: forwardRef(() => TreeviewComponent),
384
- multi: true
385
- }
386
- ], template: "<ng-container *ngTemplateOutlet=\"nodeTpl; context: { $implicit: nodes }\">\r\n</ng-container>\r\n<ng-template #nodeTpl let-nodes>\r\n @for (node of nodes; track node) {\r\n <div class=\"ms-3\">\r\n @if(!node.children || node.children.length === 0){\r\n <div class=\"d-flex align-items-center gap-2\">\r\n <input id=\"{{node.id}}\" type=\"checkbox\" class=\"form-check-input m-0\" [checked]=\"node._selected\" [disabled]=\"node._readOnly\" (change)=\"onLeafToggle(node)\" />\r\n <label for=\"{{node.id}}\">{{ node.name }}</label>\r\n </div>\r\n }\r\n @else {\r\n {{ node.name }}\r\n <div>\r\n <ng-container *ngTemplateOutlet=\"nodeTpl; context: { $implicit: node.children }\">\r\n </ng-container>\r\n </div>\r\n }\r\n </div>\r\n}\r\n</ng-template>" }]
387
- }], propDecorators: { nodes: [{
388
- type: Input
389
- }] } });
390
-
391
- class AdbObsMapComponent {
392
- activatedRoute;
393
- config;
394
- router;
395
- http;
396
- subscriptions = new Subscription();
397
- error;
398
- mapLoading = signal(false, ...(ngDevMode ? [{ debugName: "mapLoading" }] : /* istanbul ignore next */ []));
399
- siteLayer;
400
- hasBox;
401
- count;
402
- mapId = '' + Math.floor(Math.random() * Date.now());
403
- map = Leaflet.map;
404
- //Lock start
405
- mapReady = signal(false, ...(ngDevMode ? [{ debugName: "mapReady" }] : /* istanbul ignore next */ []));
406
- hasQueryParams = false;
407
- hasUrlParams = false;
408
- queryParams;
409
- urlParams;
410
- //Lock end
411
- constructor(activatedRoute, config, router, http) {
412
- this.activatedRoute = activatedRoute;
413
- this.config = config;
414
- this.router = router;
415
- this.http = http;
416
- effect(() => {
417
- // This will re-run whenever mapReady() changes
418
- if (this.mapReady() && this.hasQueryParams && this.hasUrlParams) {
419
- this.tryLoad();
420
- }
421
- });
422
- }
423
- ngAfterViewInit() {
424
- this.map = AdbMapUtils.createMap(this.mapId, {
425
- zoom: true,
426
- scrollZoom: false,
427
- providers: true
428
- });
429
- this.map.whenReady(() => {
430
- this.mapReady.set(true);
431
- if (this.config.dynamic) {
432
- this.attachUserListeners();
433
- }
434
- });
435
- }
436
- // Loads data only after:
437
- // - the Leaflet map is ready
438
- // - Angular has emitted query params (may be empty)
439
- // - Angular has emitted route params (may be empty)
440
- tryLoad() {
441
- if (!this.mapReady() || !this.hasQueryParams || !this.hasUrlParams) {
442
- return;
443
- }
444
- const params = { ...this.queryParams };
445
- this.hasBox = params['bbox'] ? true : false;
446
- if (this.urlParams.has('taxonId')) {
447
- params['taxonId'] = this.urlParams.get('taxonId');
448
- }
449
- this.loadFeature(params);
450
- }
451
- ngOnInit() {
452
- this.subscriptions.add(this.activatedRoute.queryParams.subscribe(q => {
453
- this.queryParams = q ?? {};
454
- this.hasQueryParams = true;
455
- this.tryLoad();
456
- }));
457
- this.subscriptions.add(this.activatedRoute.paramMap.subscribe(p => {
458
- this.urlParams = p;
459
- this.hasUrlParams = true;
460
- this.tryLoad();
461
- }));
462
- }
463
- attachUserListeners() {
464
- const container = this.map.getContainer();
465
- const zoomIn = container.querySelector('.leaflet-control-zoom-in');
466
- const zoomOut = container.querySelector('.leaflet-control-zoom-out');
467
- zoomIn?.addEventListener('click', () => { this.onUserInputRoute(); });
468
- zoomOut?.addEventListener('click', () => { this.onUserInputRoute(); });
469
- this.map.on('dragend', () => {
470
- this.onUserInputRoute();
471
- });
472
- }
473
- onUserInputRoute() {
474
- const bounds = this.map.getBounds();
475
- const bbox = this.getMapBoundsToBbox(bounds).join(',');
476
- this.router.navigate([], {
477
- relativeTo: this.activatedRoute,
478
- queryParams: { bbox },
479
- queryParamsHandling: 'merge'
480
- });
481
- }
482
- loadFeature(qParams) {
483
- if (this.siteLayer) {
484
- this.map.removeLayer(this.siteLayer);
485
- this.siteLayer = undefined;
486
- }
487
- this.mapLoading.set(true);
488
- this.error = null;
489
- const url = this.config.observationFeatures;
490
- this.subscriptions.add(this.http.get(url, { observe: 'response', params: qParams }).
491
- pipe(finalize(() => {
492
- this.mapLoading.set(false);
493
- })).
494
- subscribe({
495
- next: (response) => {
496
- if (!response.body) {
497
- throw new Error('No GeoJson body');
498
- }
499
- const geo = response.body;
500
- geo.properties = { count: response.headers.get('X-Observations-TotalCount') };
501
- this.buildMap(geo);
502
- }, error: err => {
503
- this.error = err;
504
- }
505
- }));
506
- }
507
- buildMap(geojson) {
508
- if (this.siteLayer) {
509
- this.map.removeLayer(this.siteLayer);
510
- }
511
- this.count = geojson?.properties?.count;
512
- this.siteLayer = Leaflet.geoJson(geojson, {
513
- style: (feature) => this.getPolygonStyle(feature.properties),
514
- pointToLayer: (feature, latlng) => {
515
- const marker = Leaflet.marker(latlng, {
516
- interactive: this.config.dynamic,
517
- icon: Leaflet.divIcon({
518
- className: '',
519
- html: '<div class="adb-map-marker"></div>',
520
- iconAnchor: [3, 3]
521
- })
522
- });
523
- if (feature.properties && feature.properties['Occurrence.OccurrenceId']) {
524
- marker.on('click', () => {
525
- window.location.href = this.config.observationPage + '/' + feature.properties['Occurrence.OccurrenceId'];
526
- });
527
- }
528
- return marker;
529
- }, onEachFeature: (feature, layer) => {
530
- if (feature.geometry.type === "Polygon" ||
531
- feature.geometry.type === "MultiPolygon") {
532
- if (feature.properties.ObservationsCount > 0) {
533
- if (this.config.dynamic) {
534
- layer.on('click', () => {
535
- const boundBox = JSON.stringify(this.getMapBoundsToBbox(layer.getBounds()));
536
- this.router.navigate([], { queryParams: { bbox: boundBox }, queryParamsHandling: 'merge' });
537
- });
538
- layer.on('mouseover', () => {
539
- layer.setStyle({ className: 'svg cursor-pointer' });
540
- });
541
- layer.on('mouseout', () => {
542
- layer.setStyle({ className: 'svg' });
543
- });
544
- }
545
- }
546
- if (!this.config.dynamic) {
547
- layer.setStyle({ interactive: false });
548
- }
549
- else if (feature.properties.FeatureType) { //area
550
- layer.setStyle({ interactive: false });
551
- }
552
- }
553
- }
554
- });
555
- const circleLayer = Leaflet.featureGroup();
556
- circleLayer.addTo(this.siteLayer);
557
- this.map.addLayer(this.siteLayer);
558
- if (geojson.bbox) {
559
- const [minLon, minLat, maxLon, maxLat] = geojson.bbox;
560
- const bounds = Leaflet.latLngBounds([[minLat, minLon], [maxLat, maxLon]]);
561
- if (bounds.isValid()) {
562
- // Safari sometimes needs extra time after layer adds
563
- setTimeout(() => {
564
- this.map.invalidateSize({ animate: false });
565
- this.map.fitBounds(bounds, { animate: false });
566
- }, 50); // 30–50ms works best in Safari
567
- }
568
- }
569
- }
570
- getMapBoundsToBbox(bounds) {
571
- return [
572
- bounds.getWest(),
573
- bounds.getSouth(),
574
- bounds.getEast(),
575
- bounds.getNorth()
576
- ];
577
- }
578
- getPolygonStyle(props) {
579
- if (props.location) {
580
- //Its locations
581
- return {
582
- weight: 2,
583
- color: '#005e67',
584
- fill: false
585
- };
586
- }
587
- else if (props.FeatureId) {
588
- // featurearea
589
- return {
590
- weight: 2,
591
- fill: true,
592
- fillOpacity: 0.1,
593
- color: '#005e67',
594
- fillColor: '#007681'
595
- };
596
- }
597
- else {
598
- //its heatmaps
599
- const base = {
600
- weight: 1,
601
- fill: true,
602
- fillOpacity: 0.8
603
- };
604
- if (props.FeatureType) {
605
- return { ...base, color: '#249ca3', fillColor: '#2FB3BB' };
606
- }
607
- if (props.ObservationsCount < 10) {
608
- return { ...base, color: '#249ca3', fillColor: '#2FB3BB' };
609
- }
610
- if (props.ObservationsCount < 500) {
611
- return { ...base, color: '#005e67', fillColor: '#007681' };
612
- }
613
- return { ...base, color: '#00393D', fillColor: '#00393D' };
614
- }
615
- }
616
- ngOnDestroy() {
617
- this.subscriptions.unsubscribe();
618
- }
619
- static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "21.2.25", ngImport: i0, type: AdbObsMapComponent, deps: [{ token: i1$2.ActivatedRoute }, { token: AdbMapConfigService }, { token: i1$2.Router }, { token: i3.HttpClient }], target: i0.ɵɵFactoryTarget.Component });
620
- static ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "17.0.0", version: "21.2.25", type: AdbObsMapComponent, isStandalone: false, selector: "adb-obs-map", ngImport: i0, template: "@if(hasBox&&!mapLoading()){\r\n<div class=\"mb-1 d-flex justify-content-between flex-wrap\">\r\n <a [routerLink]=\"[]\" [queryParams]=\"{bbox:null,z:null}\" queryParamsHandling=\"merge\" class=\"d-flex gap-1 align-items-baseline\">\r\n <span class=\"bi bi-chevron-left\"></span>\r\n Tillbaka upp\r\n </a>\r\n</div>\r\n}\r\n@if(error){\r\n<div class=\"alert alert-danger\">\r\n {{'ERROR.SERVER_ERROR'|translate}}\r\n</div>\r\n}\r\n<div [class.loading]=\"mapLoading()\">\r\n <div [id]=\"mapId\" class=\"mb-1 map-container\"></div>\r\n</div>\r\n<div class=\"mb-1 d-flex gap-3 justify-content-between flex-wrap\">\r\n @if (!mapLoading()&&count) {\r\n <div class=\"d-flex align-items-center gap-1\">\r\n <div class=\"legend map-heat-low\"></div>\r\n &lt;10\r\n </div>\r\n <div class=\"d-flex align-items-center gap-1\">\r\n <div class=\"legend map-heat-medium\"></div>\r\n 10 - 500\r\n </div>\r\n <div class=\"d-flex align-items-center gap-1\">\r\n <div class=\"legend map-heat-high\"></div>\r\n &gt;500\r\n </div>\r\n <div class=\"ms-auto\">\r\n {{count|adbSpacing}} {{'OBSERVATION.OBSERVATIONS'|translate}}\r\n </div>\r\n }\r\n</div>", dependencies: [{ kind: "directive", type: i1$2.RouterLink, selector: "[routerLink]", inputs: ["target", "queryParams", "fragment", "queryParamsHandling", "state", "info", "relativeTo", "preserveFragment", "skipLocationChange", "replaceUrl", "routerLink"] }, { kind: "pipe", type: i5.NumberSpacingPipe, name: "adbSpacing" }, { kind: "pipe", type: i1.TranslatePipe, name: "translate" }], changeDetection: i0.ChangeDetectionStrategy.Eager });
621
- }
622
- i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "21.2.25", ngImport: i0, type: AdbObsMapComponent, decorators: [{
623
- type: Component,
624
- args: [{ selector: 'adb-obs-map', changeDetection: ChangeDetectionStrategy.Eager, standalone: false, template: "@if(hasBox&&!mapLoading()){\r\n<div class=\"mb-1 d-flex justify-content-between flex-wrap\">\r\n <a [routerLink]=\"[]\" [queryParams]=\"{bbox:null,z:null}\" queryParamsHandling=\"merge\" class=\"d-flex gap-1 align-items-baseline\">\r\n <span class=\"bi bi-chevron-left\"></span>\r\n Tillbaka upp\r\n </a>\r\n</div>\r\n}\r\n@if(error){\r\n<div class=\"alert alert-danger\">\r\n {{'ERROR.SERVER_ERROR'|translate}}\r\n</div>\r\n}\r\n<div [class.loading]=\"mapLoading()\">\r\n <div [id]=\"mapId\" class=\"mb-1 map-container\"></div>\r\n</div>\r\n<div class=\"mb-1 d-flex gap-3 justify-content-between flex-wrap\">\r\n @if (!mapLoading()&&count) {\r\n <div class=\"d-flex align-items-center gap-1\">\r\n <div class=\"legend map-heat-low\"></div>\r\n &lt;10\r\n </div>\r\n <div class=\"d-flex align-items-center gap-1\">\r\n <div class=\"legend map-heat-medium\"></div>\r\n 10 - 500\r\n </div>\r\n <div class=\"d-flex align-items-center gap-1\">\r\n <div class=\"legend map-heat-high\"></div>\r\n &gt;500\r\n </div>\r\n <div class=\"ms-auto\">\r\n {{count|adbSpacing}} {{'OBSERVATION.OBSERVATIONS'|translate}}\r\n </div>\r\n }\r\n</div>" }]
625
- }], ctorParameters: () => [{ type: i1$2.ActivatedRoute }, { type: AdbMapConfigService }, { type: i1$2.Router }, { type: i3.HttpClient }] });
626
-
1
+ import * as i1$2 from "@angular/common";
2
+ import { CommonModule } from "@angular/common";
3
+ import * as i0 from "@angular/core";
4
+ import { ChangeDetectionStrategy, Component, ElementRef, Inject, Injectable, InjectionToken, Input, NgModule, afterRenderEffect, computed, effect, forwardRef, inject, input, output, signal } from "@angular/core";
5
+ import * as i3 from "@angular/forms";
6
+ import { FormArray, FormControl, FormGroup, FormsModule, NG_VALUE_ACCESSOR, ReactiveFormsModule, Validators } from "@angular/forms";
7
+ import GeoJSON from "ol/format/GeoJSON.js";
8
+ import Draw from "ol/interaction/Draw.js";
9
+ import VectorLayer from "ol/layer/Vector.js";
10
+ import VectorSource from "ol/source/Vector.js";
11
+ import CircleGeometry from "ol/geom/Circle.js";
12
+ import Polygon, { circular } from "ol/geom/Polygon.js";
13
+ import { fromLonLat, toLonLat, transformExtent } from "ol/proj.js";
14
+ import { getDistance } from "ol/sphere.js";
15
+ import Map from "ol/Map.js";
16
+ import View from "ol/View.js";
17
+ import TileLayer from "ol/layer/Tile.js";
18
+ import TileWMS from "ol/source/TileWMS.js";
19
+ import XYZ from "ol/source/XYZ.js";
20
+ import Control from "ol/control/Control.js";
21
+ import ScaleLine from "ol/control/ScaleLine.js";
22
+ import { defaults } from "ol/control/defaults.js";
23
+ import { defaults as defaults$1 } from "ol/interaction/defaults.js";
24
+ import { Circle, Fill, RegularShape, Stroke, Style, Text } from "ol/style.js";
25
+ import * as i1$3 from "@ngx-translate/core";
26
+ import { TranslatePipe } from "@ngx-translate/core";
27
+ import * as i1 from "@angular/router";
28
+ import { NavigationEnd, RouterModule } from "@angular/router";
29
+ import Feature from "ol/Feature.js";
30
+ import { extend, getCenter, getForViewAndSize, isEmpty } from "ol/extent.js";
31
+ import { finalize } from "rxjs/operators";
32
+ import { takeUntilDestroyed } from "@angular/core/rxjs-interop";
33
+ import * as i2 from "@angular/common/http";
34
+ import { HttpClient } from "@angular/common/http";
35
+ import { Subscription, combineLatest, debounceTime, map } from "rxjs";
36
+ import LineString from "ol/geom/LineString.js";
37
+ import MultiPolygon from "ol/geom/MultiPolygon.js";
38
+ import * as i1$1 from "adb-shared";
39
+ import { AdbButtonsModule, AdbDatePickerModule, AdbDirectivesModule, AdbFilterSectionModule, AdbPickerModule, AdbPipesModule } from "adb-shared";
40
+ import { addYears, endOfDay, endOfYear, parseISO, startOfDay, startOfYear } from "date-fns";
627
41
  const DateTypes = {
628
- THIS_YEAR: '1',
629
- LAST_YEAR: '2',
630
- ALL_YEAR: '3',
631
- LAST_5_YEAR: '4',
632
- LAST_25_YEAR: '5',
633
- CUSTOM: '6',
42
+ THIS_YEAR: "1",
43
+ LAST_YEAR: "2",
44
+ ALL_YEAR: "3",
45
+ LAST_5_YEAR: "4",
46
+ LAST_25_YEAR: "5",
47
+ CUSTOM: "6"
634
48
  };
49
+ const MapConstants = {
50
+ INITIAL_METERS_PER_PIXEL: 200,
51
+ LOCATION_MARKER_BACKGROUND_COLOR: "#f3db60",
52
+ LOCATION_MARKER_BORDER_COLOR: "#665500",
53
+ OBSERVATION_MARKER_BACKGROUND_COLOR: "#007c91",
54
+ CLUSTER_MARKER_BACKGROUND_COLOR: "#1e90ff",
55
+ CLUSTER_MARKER_BORDER_COLOR: "#000",
56
+ SELECTED_MARKER_BORDER_COLOR: "#000",
57
+ LOCATION_POLYGON_BORDER_COLOR: "#005e67",
58
+ GENERALIZED_POLYGON_BORDER_COLOR: "#b3261e",
59
+ GENERALIZED_POLYGON_BACKGROUND_COLOR: "rgba(179, 38, 30, 0.15)",
60
+ SELECTED_COLOR: "#ff00ff",
61
+ UNCERTAINTY_BORDER_COLOR: "#777",
62
+ SEARCH_AREA_BORDER_COLOR: "#1e90ff",
63
+ AFTER_CUTOFF_YEAR_COLOR: "#3366cc",
64
+ BEFORE_CUTOFF_YEAR_COLOR: "#8a3fd0",
65
+ MARKER_RADIUS: 6,
66
+ CLUSTER_MARKER_RADIUS: 8,
67
+ HOVER_RADIUS: 10
68
+ };
69
+ var AdbMapUtils = class AdbMapUtils {
70
+ static locationSymbol(feature, selected = false, hovered = false) {
71
+ const props = feature.getProperties();
72
+ const cluster = props["groupingType"] === "pixelCluster" || props["isCluster"];
73
+ const point = ["Point", "MultiPoint"].includes(feature.getGeometry()?.getType());
74
+ const text = point && !cluster && props["observationCount"] === 1 && (props["locations"]?.count === 1 || !!props["location"]) ? new Text({
75
+ text: "1",
76
+ offsetY: 2,
77
+ font: "bold 10px sans-serif",
78
+ fill: new Fill({ color: "#000" }),
79
+ stroke: new Stroke({
80
+ color: "#fff",
81
+ width: 2
82
+ })
83
+ }) : null;
84
+ if (selected) return new Style({
85
+ text,
86
+ image: new Circle({
87
+ radius: hovered ? MapConstants.HOVER_RADIUS : cluster ? MapConstants.CLUSTER_MARKER_RADIUS : MapConstants.MARKER_RADIUS,
88
+ fill: new Fill({ color: MapConstants.SELECTED_COLOR }),
89
+ stroke: new Stroke({
90
+ color: MapConstants.SELECTED_MARKER_BORDER_COLOR,
91
+ width: 2
92
+ })
93
+ }),
94
+ stroke: new Stroke({
95
+ color: MapConstants.SELECTED_COLOR,
96
+ width: 3
97
+ }),
98
+ fill: new Fill({ color: "transparent" })
99
+ });
100
+ if (point) return new Style({
101
+ text,
102
+ image: new Circle({
103
+ radius: hovered ? MapConstants.HOVER_RADIUS : cluster ? MapConstants.CLUSTER_MARKER_RADIUS : MapConstants.MARKER_RADIUS,
104
+ fill: new Fill({ color: cluster ? MapConstants.CLUSTER_MARKER_BACKGROUND_COLOR : MapConstants.LOCATION_MARKER_BACKGROUND_COLOR }),
105
+ stroke: new Stroke({
106
+ color: cluster ? MapConstants.CLUSTER_MARKER_BORDER_COLOR : MapConstants.LOCATION_MARKER_BORDER_COLOR,
107
+ width: cluster ? 2 : 1
108
+ })
109
+ })
110
+ });
111
+ return new Style({
112
+ fill: new Fill({ color: "transparent" }),
113
+ stroke: new Stroke({
114
+ color: MapConstants.LOCATION_POLYGON_BORDER_COLOR,
115
+ width: hovered ? 4 : 2
116
+ })
117
+ });
118
+ }
119
+ static isNotRecovered(presentation) {
120
+ return presentation?.status === "NotRecovered";
121
+ }
122
+ static aggregatedSymbol(style, presentation, cutoffYear, selected, geometryType = null) {
123
+ if (!selected && presentation?.generalized && ["Polygon", "MultiPolygon"].includes(geometryType)) {
124
+ style.setStroke(new Stroke({
125
+ color: MapConstants.GENERALIZED_POLYGON_BORDER_COLOR,
126
+ width: style.getStroke().getWidth()
127
+ }));
128
+ style.setFill(new Fill({ color: MapConstants.GENERALIZED_POLYGON_BACKGROUND_COLOR }));
129
+ return style;
130
+ }
131
+ let symbol = style;
132
+ const notRecovered = this.isNotRecovered(presentation);
133
+ const notPresent = presentation?.status === "NotPresent";
134
+ if (notRecovered || notPresent) {
135
+ style.setText(null);
136
+ symbol = [style, new Style({ image: new RegularShape({
137
+ points: notRecovered ? 4 : 2,
138
+ radius: 5,
139
+ radius2: 0,
140
+ angle: notRecovered ? Math.PI / 4 : Math.PI / 2,
141
+ stroke: new Stroke({
142
+ color: "#000",
143
+ width: 1.5,
144
+ lineJoin: "round"
145
+ })
146
+ }) })];
147
+ }
148
+ if (selected || !cutoffYear) return symbol;
149
+ const status = presentation?.cutoffYearStatus;
150
+ if (status !== "Until" && status !== "After") return symbol;
151
+ const before = status === "Until";
152
+ const color = before ? MapConstants.BEFORE_CUTOFF_YEAR_COLOR : MapConstants.AFTER_CUTOFF_YEAR_COLOR;
153
+ const image = style.getImage();
154
+ if (image instanceof Circle) {
155
+ image.setFill(before ? null : new Fill({ color }));
156
+ image.setStroke(new Stroke({
157
+ color: before ? color : "#000",
158
+ width: before ? 2 : image.getStroke().getWidth()
159
+ }));
160
+ } else style.setStroke(new Stroke({
161
+ color,
162
+ width: style.getStroke().getWidth()
163
+ }));
164
+ return symbol;
165
+ }
166
+ static createUncertaintyCircle(center, radius) {
167
+ const latitude = toLonLat(center)[1];
168
+ return new CircleGeometry(center, radius / Math.cos(latitude * Math.PI / 180));
169
+ }
170
+ static INITIAL_METERS_PER_PIXEL = 500;
171
+ static INITIAL_CENTER_LAT = 62;
172
+ static INITIAL_CENTER_LNG = 17;
173
+ static gridLevels(result) {
174
+ const counts = (result?.features ?? []).map((feature) => feature.properties?.ObservationsCount).filter((count) => typeof count === "number");
175
+ if (!counts.length) return [];
176
+ const max = Math.max(...counts);
177
+ const first = Math.ceil(max / 3);
178
+ const second = Math.ceil(2 * max / 3);
179
+ return [
180
+ {
181
+ min: max === 0 ? 0 : 1,
182
+ max: first,
183
+ color: "#2fb3bb"
184
+ },
185
+ {
186
+ min: first + 1,
187
+ max: second,
188
+ color: "#005e67"
189
+ },
190
+ {
191
+ min: second + 1,
192
+ max,
193
+ color: "#00393d"
194
+ }
195
+ ].filter((level) => level.min <= level.max);
196
+ }
197
+ static getMetersPerPixel(bbox, mapWidth) {
198
+ if (bbox && mapWidth > 0) {
199
+ const [minLon, minLat, maxLon, maxLat] = bbox.split(",").map(Number);
200
+ const centerLat = (minLat + maxLat) / 2;
201
+ return getDistance([minLon, centerLat], [maxLon, centerLat]) / mapWidth;
202
+ }
203
+ return AdbMapUtils.INITIAL_METERS_PER_PIXEL;
204
+ }
205
+ static OverlayMaps = {
206
+ "Altitude": AdbMapUtils.wms("https://maps.sgu.se/lmv/hojdmodell/v1.1?SERVICE=WMS", {
207
+ layers: "terrangskuggning",
208
+ format: "image/png",
209
+ transparent: true,
210
+ opacity: .3,
211
+ maxZoom: 16,
212
+ version: "1.3.0"
213
+ }),
214
+ "Fjällkarta": AdbMapUtils.wms("api/maps/mountain", {
215
+ minZoom: 6,
216
+ maxZoom: 18,
217
+ maxNativeZoom: 14,
218
+ attribution: "© <a href=\"https://www.lantmateriet.se/\">Fjällkart</a>",
219
+ wms: true
220
+ }),
221
+ "Kommuner": AdbMapUtils.wms("https://sosgeo.artdata.slu.se/geoserver/GeoRegion/wms?", {
222
+ layers: "GeoRegion:Municipality",
223
+ version: "1.1.0",
224
+ transparent: true,
225
+ format: "image/png"
226
+ }),
227
+ "Län": AdbMapUtils.wms("https://sosgeo.artdata.slu.se/geoserver/GeoRegion/wms?", {
228
+ layers: "GeoRegion:County",
229
+ version: "1.1.0",
230
+ transparent: true,
231
+ format: "image/png"
232
+ }),
233
+ "Ortnamn": AdbMapUtils.wms("https://maps.sgu.se/lmv/topowebb-skikt/v1.1?SERVICE=WMS", {
234
+ layers: "text",
235
+ format: "image/png",
236
+ transparent: true,
237
+ version: "1.3.0"
238
+ }),
239
+ "Ekonomisk zon": AdbMapUtils.wms("https://sosgeo.artdata.slu.se/geoserver/it.geosolutions/wms?", {
240
+ layers: "it.geosolutions:Ekonomiska_zonens_yttre_avgränsningslinjer_linje",
241
+ format: "image/png",
242
+ transparent: true,
243
+ version: "1.1.0"
244
+ })
245
+ };
246
+ static Providers = [{
247
+ name: "Open Streetmap",
248
+ id: 3,
249
+ url: "https://{s}.tile.openstreetmap.org/{z}/{x}/{y}.png",
250
+ minZoom: 0,
251
+ maxZoom: 18,
252
+ params: {
253
+ maxNativeZoom: 18,
254
+ attribution: "© <a href=\"https://www.openstreetmap.org/copyright\">OpenStreetMap</a> contributors"
255
+ },
256
+ wms: false
257
+ }, {
258
+ name: "Sveriges gränser",
259
+ id: 7,
260
+ url: "https://sosgeo.artdata.slu.se/geoserver/it.geosolutions/wms",
261
+ minZoom: 6,
262
+ maxZoom: 18,
263
+ params: {
264
+ maxNativeZoom: 14,
265
+ attribution: "© <a href=\"https://www.lantmateriet.se/\">Sveriges gränser</a>",
266
+ layers: "it.geosolutions:Sverige_epsg5845",
267
+ styles: "municipality_name_yellow",
268
+ epsg: 5845
269
+ },
270
+ wms: true
271
+ }];
272
+ static wms(url, options) {
273
+ const { opacity = 1, attribution, minZoom, maxZoom, maxNativeZoom, epsg, wms, ...parameters } = options;
274
+ const params = Object.fromEntries(Object.entries(parameters).map(([key, value]) => [key.toUpperCase(), value]));
275
+ return new TileLayer({
276
+ opacity,
277
+ minZoom,
278
+ maxZoom,
279
+ source: new TileWMS({
280
+ url,
281
+ params,
282
+ attributions: attribution
283
+ })
284
+ });
285
+ }
286
+ static createMap(elementId, options = {}) {
287
+ const map = new Map({
288
+ target: elementId,
289
+ view: new View({
290
+ center: fromLonLat([AdbMapUtils.INITIAL_CENTER_LNG, AdbMapUtils.INITIAL_CENTER_LAT]),
291
+ zoom: 5,
292
+ minZoom: 0,
293
+ maxZoom: 20
294
+ }),
295
+ controls: defaults({ zoom: options.zoom ?? true }).extend([new ScaleLine()]),
296
+ interactions: defaults$1({
297
+ mouseWheelZoom: options.scrollZoom ?? true,
298
+ dragPan: options.zoom ?? true
299
+ })
300
+ });
301
+ if (options.providers !== false) this.addProviders(map);
302
+ return map;
303
+ }
304
+ static addProviders(map) {
305
+ const element = document.createElement("details");
306
+ element.className = "ol-control adb-map-layers";
307
+ const summary = document.createElement("summary");
308
+ summary.textContent = "Kartlager";
309
+ element.append(summary);
310
+ const backgrounds = this.Providers.map((provider) => {
311
+ const layer = provider.wms ? this.wms(provider.url, provider.params) : new TileLayer({ source: new XYZ({
312
+ url: provider.url.replace("{s}", "{a-c}"),
313
+ attributions: provider.params.attribution,
314
+ maxZoom: provider.params.maxNativeZoom
315
+ }) });
316
+ return {
317
+ name: provider.name,
318
+ layer
319
+ };
320
+ });
321
+ const overlays = Object.entries(this.OverlayMaps).map(([name, original]) => ({
322
+ name,
323
+ layer: new TileLayer({
324
+ source: new TileWMS({
325
+ url: original.getSource().getUrls()[0],
326
+ params: original.getSource().getParams(),
327
+ attributions: original.getSource().getAttributions()
328
+ }),
329
+ opacity: original.getOpacity(),
330
+ minZoom: original.getMinZoom(),
331
+ maxZoom: original.getMaxZoom()
332
+ })
333
+ }));
334
+ for (const [index, entry] of [...backgrounds, ...overlays].entries()) {
335
+ const background = index < backgrounds.length;
336
+ entry.layer.setVisible(index === 0);
337
+ map.addLayer(entry.layer);
338
+ const label = document.createElement("label");
339
+ const input = document.createElement("input");
340
+ input.type = background ? "radio" : "checkbox";
341
+ input.name = `background-${map.getTarget()}`;
342
+ input.checked = entry.layer.getVisible();
343
+ input.addEventListener("change", () => {
344
+ if (background) backgrounds.forEach((item) => item.layer.setVisible(item === entry));
345
+ else entry.layer.setVisible(input.checked);
346
+ });
347
+ label.append(input, document.createTextNode(entry.name));
348
+ element.append(label);
349
+ if (index === 0) element.append(document.createElement("hr"));
350
+ }
351
+ map.addControl(new Control({ element }));
352
+ }
353
+ static createFile(source, fileName = "map-download") {
354
+ const link = document.createElement("a");
355
+ link.href = URL.createObjectURL(source);
356
+ link.download = fileName;
357
+ document.body.appendChild(link);
358
+ link.click();
359
+ document.body.removeChild(link);
360
+ URL.revokeObjectURL(link.href);
361
+ return true;
362
+ }
363
+ };
364
+ var PolygonDrawerInput = class PolygonDrawerInput {
365
+ mapId = "draw-" + Math.floor(Math.random() * Date.now());
366
+ map;
367
+ polygonDraw = false;
368
+ disabled = false;
369
+ shapeLayer = false;
370
+ source = new VectorSource();
371
+ format = new GeoJSON();
372
+ draw;
373
+ geoJson;
374
+ resizeObserver;
375
+ pendingFit = false;
376
+ onChange = (value) => {};
377
+ onTouched = () => {};
378
+ ngAfterViewInit() {
379
+ this.map = AdbMapUtils.createMap(this.mapId, {
380
+ zoom: true,
381
+ scrollZoom: true,
382
+ providers: true
383
+ });
384
+ this.map.addLayer(new VectorLayer({ source: this.source }));
385
+ this.resizeObserver = new ResizeObserver(() => {
386
+ this.map.updateSize();
387
+ this.fitShape();
388
+ });
389
+ this.resizeObserver.observe(this.map.getTargetElement());
390
+ this.renderValue();
391
+ }
392
+ onDrawPolygon() {
393
+ this.startDraw("Polygon");
394
+ }
395
+ onDrawCircle() {
396
+ this.startDraw("Circle");
397
+ }
398
+ startDraw(type) {
399
+ if (this.disabled) return;
400
+ this.stopDraw();
401
+ this.polygonDraw = true;
402
+ this.draw = new Draw({
403
+ source: this.source,
404
+ type
405
+ });
406
+ this.map.addInteraction(this.draw);
407
+ this.draw.on("drawend", (event) => {
408
+ this.source.clear();
409
+ const geometry = event.feature.getGeometry();
410
+ const options = { featureProjection: this.map.getView().getProjection() };
411
+ let geo;
412
+ if (geometry instanceof CircleGeometry) {
413
+ const center = toLonLat(geometry.getCenter());
414
+ const edge = toLonLat([geometry.getCenter()[0] + geometry.getRadius(), geometry.getCenter()[1]]);
415
+ const radius = Math.ceil(getDistance(center, edge));
416
+ geo = {
417
+ type: "Feature",
418
+ geometry: this.format.writeGeometryObject(circular(center, radius, 64)),
419
+ properties: { radius }
420
+ };
421
+ } else geo = this.format.writeFeatureObject(event.feature, options);
422
+ this.geoJson = geo;
423
+ this.shapeLayer = true;
424
+ this.onChange(geo);
425
+ this.onTouched();
426
+ this.stopDraw();
427
+ });
428
+ }
429
+ stopDraw() {
430
+ if (this.draw) this.map.removeInteraction(this.draw);
431
+ this.draw = void 0;
432
+ this.polygonDraw = false;
433
+ }
434
+ onUndoStep() {
435
+ this.draw?.removeLastPoint();
436
+ }
437
+ onDeleteShape() {
438
+ if (this.disabled) return;
439
+ this.stopDraw();
440
+ this.source.clear();
441
+ this.pendingFit = false;
442
+ this.shapeLayer = false;
443
+ this.geoJson = null;
444
+ this.onChange(null);
445
+ this.onTouched();
446
+ this.map.getView().setCenter(fromLonLat([AdbMapUtils.INITIAL_CENTER_LNG, AdbMapUtils.INITIAL_CENTER_LAT]));
447
+ this.map.getView().setZoom(5);
448
+ }
449
+ renderValue() {
450
+ if (!this.map) return;
451
+ this.source.clear();
452
+ this.pendingFit = false;
453
+ this.shapeLayer = false;
454
+ if (this.geoJson?.type !== "Feature") return;
455
+ const feature = this.format.readFeatures(this.geoJson, { featureProjection: this.map.getView().getProjection() })[0];
456
+ if (this.geoJson.geometry.type === "Point" && this.geoJson.properties?.radius) {
457
+ const latitude = this.geoJson.geometry.coordinates[1];
458
+ feature.setGeometry(new CircleGeometry(fromLonLat(this.geoJson.geometry.coordinates), this.geoJson.properties.radius / Math.cos(latitude * Math.PI / 180)));
459
+ }
460
+ this.source.addFeature(feature);
461
+ this.shapeLayer = true;
462
+ this.pendingFit = true;
463
+ this.fitShape();
464
+ }
465
+ fitShape() {
466
+ const size = this.map.getSize();
467
+ if (!this.pendingFit || !size?.[0] || !size[1]) return;
468
+ this.map.getView().fit(this.source.getExtent(), {
469
+ padding: [
470
+ 20,
471
+ 20,
472
+ 20,
473
+ 20
474
+ ],
475
+ maxZoom: 18
476
+ });
477
+ this.pendingFit = false;
478
+ }
479
+ writeValue(value) {
480
+ this.geoJson = value;
481
+ this.renderValue();
482
+ }
483
+ registerOnChange(fn) {
484
+ this.onChange = fn;
485
+ }
486
+ registerOnTouched(fn) {
487
+ this.onTouched = fn;
488
+ }
489
+ setDisabledState(disabled) {
490
+ this.disabled = disabled;
491
+ if (disabled && this.map) this.stopDraw();
492
+ }
493
+ ngOnDestroy() {
494
+ this.resizeObserver?.disconnect();
495
+ this.map?.dispose();
496
+ }
497
+ static ɵfac = i0.ɵɵngDeclareFactory({
498
+ minVersion: "12.0.0",
499
+ version: "22.2.4",
500
+ ngImport: i0,
501
+ type: PolygonDrawerInput,
502
+ deps: [],
503
+ target: i0.ɵɵFactoryTarget.Component
504
+ });
505
+ static ɵcmp = i0.ɵɵngDeclareComponent({
506
+ minVersion: "17.0.0",
507
+ version: "22.2.4",
508
+ type: PolygonDrawerInput,
509
+ isStandalone: false,
510
+ selector: "adb-polygon-drawer",
511
+ providers: [{
512
+ provide: NG_VALUE_ACCESSOR,
513
+ useExisting: forwardRef(() => PolygonDrawerInput),
514
+ multi: true
515
+ }],
516
+ ngImport: i0,
517
+ template: "<div class=\"mb-1 d-flex gap-1 flex-wrap align-items-start\">\n <button class=\"btn btn-secondary\" type=\"button\" [disabled]=\"disabled || shapeLayer\" (click)=\"onDrawPolygon()\" title=\"Polygon\">\n <span class=\"bi bi-pentagon\"></span> {{'OBSERVATION.DRAW'|translate}}\n </button>\n <button class=\"btn btn-secondary\" type=\"button\" [disabled]=\"disabled || shapeLayer\" (click)=\"onDrawCircle()\" title=\"Circle\">\n <span class=\"bi bi-circle\"></span> {{'OBSERVATION.DRAW_CIRCLE'|translate}}\n </button>\n @if (shapeLayer) {\n <button class=\"btn btn-secondary\" type=\"button\" [disabled]=\"disabled\" (click)=\"onDeleteShape()\" title=\"Ta bort\">\n <span class=\"bi bi-x\"></span>\n </button>\n }\n @if (polygonDraw) {\n <button class=\"btn btn-secondary\" type=\"button\" [disabled]=\"disabled\" (click)=\"onUndoStep()\" title=\"Ångra\">\n <span class=\"bi bi-arrow-counterclockwise\"></span>\n </button>\n }\n</div>\n<div [id]=\"mapId\" class=\"border\" style=\"height:20rem\"></div>",
518
+ dependencies: [{
519
+ kind: "pipe",
520
+ type: i1$3.TranslatePipe,
521
+ name: "translate"
522
+ }],
523
+ changeDetection: i0.ChangeDetectionStrategy.Eager
524
+ });
525
+ };
526
+ i0.ɵɵngDeclareClassMetadata({
527
+ minVersion: "12.0.0",
528
+ version: "22.2.4",
529
+ ngImport: i0,
530
+ type: PolygonDrawerInput,
531
+ decorators: [{
532
+ type: Component,
533
+ args: [{
534
+ selector: "adb-polygon-drawer",
535
+ standalone: false,
536
+ changeDetection: ChangeDetectionStrategy.Eager,
537
+ providers: [{
538
+ provide: NG_VALUE_ACCESSOR,
539
+ useExisting: forwardRef(() => PolygonDrawerInput),
540
+ multi: true
541
+ }],
542
+ template: "<div class=\"mb-1 d-flex gap-1 flex-wrap align-items-start\">\n <button class=\"btn btn-secondary\" type=\"button\" [disabled]=\"disabled || shapeLayer\" (click)=\"onDrawPolygon()\" title=\"Polygon\">\n <span class=\"bi bi-pentagon\"></span> {{'OBSERVATION.DRAW'|translate}}\n </button>\n <button class=\"btn btn-secondary\" type=\"button\" [disabled]=\"disabled || shapeLayer\" (click)=\"onDrawCircle()\" title=\"Circle\">\n <span class=\"bi bi-circle\"></span> {{'OBSERVATION.DRAW_CIRCLE'|translate}}\n </button>\n @if (shapeLayer) {\n <button class=\"btn btn-secondary\" type=\"button\" [disabled]=\"disabled\" (click)=\"onDeleteShape()\" title=\"Ta bort\">\n <span class=\"bi bi-x\"></span>\n </button>\n }\n @if (polygonDraw) {\n <button class=\"btn btn-secondary\" type=\"button\" [disabled]=\"disabled\" (click)=\"onUndoStep()\" title=\"Ångra\">\n <span class=\"bi bi-arrow-counterclockwise\"></span>\n </button>\n }\n</div>\n<div [id]=\"mapId\" class=\"border\" style=\"height:20rem\"></div>"
543
+ }]
544
+ }]
545
+ });
546
+ const ADB_MAP_CONFIG = new InjectionToken("ADB_MAP_CONFIG");
547
+ var AdbMapConfigService = class AdbMapConfigService {
548
+ artfaktaTaxonLists;
549
+ observationFeatures;
550
+ taxaListsApi;
551
+ dynamic;
552
+ enableClusterSelection;
553
+ dataProviderIds;
554
+ constructor(config) {
555
+ this.dynamic = config.dynamic ?? false;
556
+ this.dataProviderIds = config.dataProviderIds === void 0 ? void 0 : Object.freeze([...config.dataProviderIds]);
557
+ this.enableClusterSelection = config.enableClusterSelection ?? false;
558
+ this.artfaktaTaxonLists = config.artfaktaTaxonLists ?? "https://artfakta.se/metadata/listor";
559
+ this.taxaListsApi = config.api + "/taxalists";
560
+ this.observationFeatures = config.api + "/observation-features";
561
+ }
562
+ static ɵfac = i0.ɵɵngDeclareFactory({
563
+ minVersion: "12.0.0",
564
+ version: "22.2.4",
565
+ ngImport: i0,
566
+ type: AdbMapConfigService,
567
+ deps: [{ token: ADB_MAP_CONFIG }],
568
+ target: i0.ɵɵFactoryTarget.Injectable
569
+ });
570
+ static ɵprov = i0.ɵɵngDeclareInjectable({
571
+ minVersion: "12.0.0",
572
+ version: "22.2.4",
573
+ ngImport: i0,
574
+ type: AdbMapConfigService
575
+ });
576
+ };
577
+ i0.ɵɵngDeclareClassMetadata({
578
+ minVersion: "12.0.0",
579
+ version: "22.2.4",
580
+ ngImport: i0,
581
+ type: AdbMapConfigService,
582
+ decorators: [{ type: Injectable }],
583
+ ctorParameters: () => [{
584
+ type: void 0,
585
+ decorators: [{
586
+ type: Inject,
587
+ args: [ADB_MAP_CONFIG]
588
+ }]
589
+ }]
590
+ });
591
+ var TreeviewComponent = class TreeviewComponent {
592
+ nodes = [];
593
+ selectedIds = [];
594
+ onChange = () => {};
595
+ onTouched = () => {};
596
+ writeValue(ids) {
597
+ this.selectedIds = ids ?? [];
598
+ this.applySelection(this.nodes);
599
+ }
600
+ registerOnChange(fn) {
601
+ this.onChange = fn;
602
+ }
603
+ registerOnTouched(fn) {
604
+ this.onTouched = fn;
605
+ }
606
+ setDisabledState(isDisabled) {
607
+ this.setReadOnly(this.nodes, isDisabled);
608
+ }
609
+ onLeafToggle(node) {
610
+ if (node._readOnly) return;
611
+ node._selected = !node._selected;
612
+ this.selectedIds = TreeviewComponent.collectSelectedLeafIds(this.nodes);
613
+ this.onChange(this.selectedIds);
614
+ this.onTouched();
615
+ }
616
+ applySelection(nodes) {
617
+ for (const node of nodes) if (node.children?.length) this.applySelection(node.children);
618
+ else node._selected = this.selectedIds.includes(node.id);
619
+ }
620
+ setReadOnly(nodes, readOnly) {
621
+ for (const node of nodes) {
622
+ node._readOnly = readOnly;
623
+ if (node.children?.length) this.setReadOnly(node.children, readOnly);
624
+ }
625
+ }
626
+ static collectSelectedLeafIds(nodes) {
627
+ const ids = [];
628
+ for (const node of nodes) if (node.children?.length) ids.push(...this.collectSelectedLeafIds(node.children));
629
+ else if (node._selected) ids.push(node.id);
630
+ return ids;
631
+ }
632
+ static ɵfac = i0.ɵɵngDeclareFactory({
633
+ minVersion: "12.0.0",
634
+ version: "22.2.4",
635
+ ngImport: i0,
636
+ type: TreeviewComponent,
637
+ deps: [],
638
+ target: i0.ɵɵFactoryTarget.Component
639
+ });
640
+ static ɵcmp = i0.ɵɵngDeclareComponent({
641
+ minVersion: "17.0.0",
642
+ version: "22.2.4",
643
+ type: TreeviewComponent,
644
+ isStandalone: false,
645
+ selector: "app-treeview",
646
+ inputs: { nodes: "nodes" },
647
+ providers: [{
648
+ provide: NG_VALUE_ACCESSOR,
649
+ useExisting: forwardRef(() => TreeviewComponent),
650
+ multi: true
651
+ }],
652
+ ngImport: i0,
653
+ template: "<ng-container *ngTemplateOutlet=\"nodeTpl; context: { $implicit: nodes }\">\n</ng-container>\n<ng-template #nodeTpl let-nodes>\n @for (node of nodes; track node) {\n <div class=\"ms-3\">\n @if(!node.children || node.children.length === 0){\n <div class=\"d-flex align-items-center gap-2\">\n <input id=\"{{node.id}}\" type=\"checkbox\" class=\"form-check-input m-0\" [checked]=\"node._selected\" [disabled]=\"node._readOnly\" (change)=\"onLeafToggle(node)\" />\n <label for=\"{{node.id}}\">{{ node.name }}</label>\n </div>\n }\n @else {\n {{ node.name }}\n <div>\n <ng-container *ngTemplateOutlet=\"nodeTpl; context: { $implicit: node.children }\">\n </ng-container>\n </div>\n }\n </div>\n}\n</ng-template>",
654
+ dependencies: [{
655
+ kind: "directive",
656
+ type: i1$2.NgTemplateOutlet,
657
+ selector: "[ngTemplateOutlet]",
658
+ inputs: [
659
+ "ngTemplateOutletContext",
660
+ "ngTemplateOutlet",
661
+ "ngTemplateOutletInjector"
662
+ ]
663
+ }],
664
+ changeDetection: i0.ChangeDetectionStrategy.Eager
665
+ });
666
+ };
667
+ i0.ɵɵngDeclareClassMetadata({
668
+ minVersion: "12.0.0",
669
+ version: "22.2.4",
670
+ ngImport: i0,
671
+ type: TreeviewComponent,
672
+ decorators: [{
673
+ type: Component,
674
+ args: [{
675
+ selector: "app-treeview",
676
+ standalone: false,
677
+ changeDetection: ChangeDetectionStrategy.Eager,
678
+ providers: [{
679
+ provide: NG_VALUE_ACCESSOR,
680
+ useExisting: forwardRef(() => TreeviewComponent),
681
+ multi: true
682
+ }],
683
+ template: "<ng-container *ngTemplateOutlet=\"nodeTpl; context: { $implicit: nodes }\">\n</ng-container>\n<ng-template #nodeTpl let-nodes>\n @for (node of nodes; track node) {\n <div class=\"ms-3\">\n @if(!node.children || node.children.length === 0){\n <div class=\"d-flex align-items-center gap-2\">\n <input id=\"{{node.id}}\" type=\"checkbox\" class=\"form-check-input m-0\" [checked]=\"node._selected\" [disabled]=\"node._readOnly\" (change)=\"onLeafToggle(node)\" />\n <label for=\"{{node.id}}\">{{ node.name }}</label>\n </div>\n }\n @else {\n {{ node.name }}\n <div>\n <ng-container *ngTemplateOutlet=\"nodeTpl; context: { $implicit: node.children }\">\n </ng-container>\n </div>\n }\n </div>\n}\n</ng-template>"
684
+ }]
685
+ }],
686
+ propDecorators: { nodes: [{ type: Input }] }
687
+ });
688
+ var AdbBffMapDataSource = class AdbBffMapDataSource {
689
+ http = inject(HttpClient);
690
+ load(request) {
691
+ const params = {
692
+ ...request.params,
693
+ mpp: request.metersPerPixel
694
+ };
695
+ const array = (value) => value == null ? [] : Array.isArray(value) ? value : [value];
696
+ const sources = request.dataProviderIds?.length ? [...request.dataProviderIds] : params["ds"] ?? params["source"];
697
+ if (sources != null) params["source"] = sources;
698
+ const lists = [
699
+ ...array(params["list"]),
700
+ ...array(params["rc"]),
701
+ ...array(params["rlc"]),
702
+ ...params["eu"] ? [5] : []
703
+ ];
704
+ if (lists.length) params["list"] = lists;
705
+ for (const key of [
706
+ "ds",
707
+ "rc",
708
+ "rlc",
709
+ "eu",
710
+ "presentationMode"
711
+ ]) delete params[key];
712
+ for (const key of Object.keys(params)) if (params[key] == null) delete params[key];
713
+ return this.http.get(request.url, { params }).pipe(map((response) => {
714
+ const geoJson = response?.geoJson;
715
+ if (!geoJson || geoJson.type !== "FeatureCollection") throw new Error("Invalid BFF GeoJSON response");
716
+ return {
717
+ ...geoJson,
718
+ properties: {
719
+ ...geoJson.properties,
720
+ count: response.observationsTotalCount ?? geoJson.properties?.count
721
+ }
722
+ };
723
+ }));
724
+ }
725
+ static ɵfac = i0.ɵɵngDeclareFactory({
726
+ minVersion: "12.0.0",
727
+ version: "22.2.4",
728
+ ngImport: i0,
729
+ type: AdbBffMapDataSource,
730
+ deps: [],
731
+ target: i0.ɵɵFactoryTarget.Injectable
732
+ });
733
+ static ɵprov = i0.ɵɵngDeclareInjectable({
734
+ minVersion: "12.0.0",
735
+ version: "22.2.4",
736
+ ngImport: i0,
737
+ type: AdbBffMapDataSource,
738
+ providedIn: "root"
739
+ });
740
+ };
741
+ i0.ɵɵngDeclareClassMetadata({
742
+ minVersion: "12.0.0",
743
+ version: "22.2.4",
744
+ ngImport: i0,
745
+ type: AdbBffMapDataSource,
746
+ decorators: [{
747
+ type: Injectable,
748
+ args: [{ providedIn: "root" }]
749
+ }]
750
+ });
751
+ const ADB_MAP_DATA_SOURCE = new InjectionToken("ADB_MAP_DATA_SOURCE", {
752
+ providedIn: "root",
753
+ factory: () => inject(AdbBffMapDataSource)
754
+ });
755
+ var MapFeaturePickerComponent = class MapFeaturePickerComponent {
756
+ locationOptions = input.required(...ngDevMode ? [{ debugName: "locationOptions" }] : /* istanbul ignore next */ []);
757
+ featureChosen = output();
758
+ dismissed = output();
759
+ position = signal({
760
+ left: 0,
761
+ top: 0
762
+ }, ...ngDevMode ? [{ debugName: "position" }] : /* istanbul ignore next */ []);
763
+ host = inject(ElementRef);
764
+ features = computed(() => {
765
+ const { features, extent } = this.locationOptions();
766
+ const hits = features.filter((feature) => !["FilterArea.Area", "FilterArea.OwnPolygon"].includes(feature.get("FeatureType")));
767
+ const point = hits.find((feature) => ["Point", "MultiPoint"].includes(feature.getGeometry().getType()));
768
+ return point ? [point] : hits.filter((feature) => !feature.get("locations") || this.hasVisibleEdge(feature, extent));
769
+ }, ...ngDevMode ? [{ debugName: "features" }] : /* istanbul ignore next */ []);
770
+ choices = computed(() => {
771
+ const choices = [];
772
+ const ids = /* @__PURE__ */ new Set();
773
+ for (const feature of this.features()) {
774
+ if (feature.get("groupingType") === "pixelCluster" || feature.get("isCluster")) continue;
775
+ for (const item of feature.get("locations")?.items ?? []) {
776
+ if (ids.has(item.locationId)) continue;
777
+ ids.add(item.locationId);
778
+ choices.push({
779
+ feature,
780
+ item
781
+ });
782
+ }
783
+ }
784
+ return choices;
785
+ }, ...ngDevMode ? [{ debugName: "choices" }] : /* istanbul ignore next */ []);
786
+ constructor() {
787
+ effect(() => {
788
+ const choices = this.choices();
789
+ if (choices.length > 1) return;
790
+ if (choices.length === 1) this.choose(choices[0], false);
791
+ else if (this.features().length) this.pick(this.features()[0]);
792
+ else this.dismissed.emit(false);
793
+ });
794
+ afterRenderEffect(() => {
795
+ if (this.choices().length < 2) return;
796
+ const { pixel } = this.locationOptions();
797
+ const host = this.host.nativeElement;
798
+ const panel = host.querySelector("section");
799
+ if (!panel) return;
800
+ this.position.set({
801
+ left: Math.max(0, Math.min(pixel[0], host.clientWidth - panel.offsetWidth)),
802
+ top: Math.max(0, Math.min(pixel[1], host.clientHeight - panel.offsetHeight))
803
+ });
804
+ panel.querySelector(".list-group-item-action")?.focus({ preventScroll: true });
805
+ });
806
+ }
807
+ choose(choice, restoreFocus = true) {
808
+ const properties = choice.feature.getProperties();
809
+ delete properties["geometry"];
810
+ properties["locations"] = {
811
+ ...properties["locations"],
812
+ count: 1,
813
+ ids: [choice.item.locationId],
814
+ items: [choice.item]
815
+ };
816
+ this.featureChosen.emit({
817
+ feature: choice.feature,
818
+ properties,
819
+ selectMode: this.locationOptions().selectMode,
820
+ restoreFocus
821
+ });
822
+ }
823
+ pick(feature) {
824
+ const properties = feature.getProperties();
825
+ delete properties["geometry"];
826
+ this.featureChosen.emit({
827
+ feature,
828
+ properties,
829
+ selectMode: this.locationOptions().selectMode,
830
+ restoreFocus: false
831
+ });
832
+ }
833
+ hasVisibleEdge(feature, extent) {
834
+ const geometry = feature.getGeometry();
835
+ const polygons = geometry instanceof MultiPolygon ? geometry.getPolygons() : geometry instanceof Polygon ? [geometry] : null;
836
+ if (!polygons) return true;
837
+ return polygons.some((polygon) => polygon.getLinearRings().some((ring) => new LineString(ring.getCoordinates()).intersectsExtent(extent)));
838
+ }
839
+ static ɵfac = i0.ɵɵngDeclareFactory({
840
+ minVersion: "12.0.0",
841
+ version: "22.2.4",
842
+ ngImport: i0,
843
+ type: MapFeaturePickerComponent,
844
+ deps: [],
845
+ target: i0.ɵɵFactoryTarget.Component
846
+ });
847
+ static ɵcmp = i0.ɵɵngDeclareComponent({
848
+ minVersion: "17.0.0",
849
+ version: "22.2.4",
850
+ type: MapFeaturePickerComponent,
851
+ isStandalone: false,
852
+ selector: "adb-map-feature-picker",
853
+ inputs: { locationOptions: {
854
+ classPropertyName: "locationOptions",
855
+ publicName: "locationOptions",
856
+ isSignal: true,
857
+ isRequired: true,
858
+ transformFunction: null
859
+ } },
860
+ outputs: {
861
+ featureChosen: "featureChosen",
862
+ dismissed: "dismissed"
863
+ },
864
+ host: { classAttribute: "adb-map-feature-picker" },
865
+ ngImport: i0,
866
+ template: "@if (choices().length > 1) {\n<section class=\"adb-plate-primary shadow adb-map-feature-picker-panel\" [style.left.px]=\"position().left\" [style.top.px]=\"position().top\" [attr.aria-label]=\"'MAP.FEATURE_PICKER.TITLE' | translate\"\n (adbClickOutside)=\"dismissed.emit(false)\"\n (keydown.escape)=\"$event.stopPropagation(); dismissed.emit(true)\">\n <div class=\"d-flex align-items-center justify-content-between gap-3 mb-2\">\n <h2 class=\"h6 mb-0\">{{'MAP.FEATURE_PICKER.TITLE' | translate}}</h2>\n <button type=\"button\" class=\"btn-close\" [attr.aria-label]=\"'MAP.FEATURE_PICKER.CLOSE' | translate\" (click)=\"dismissed.emit(true)\"></button>\n </div>\n <ul class=\"list-group list-group-flush\">\n @for (choice of choices(); track choice.item.locationId) {\n <li class=\"list-group-item p-0\">\n <button type=\"button\" class=\"list-group-item list-group-item-action border-0 text-break\" (click)=\"choose(choice)\">\n @if (choice.item.locality) {\n {{choice.item.locality}}\n @if (choice.item.municipality) {, {{choice.item.municipality}}}\n } @else if (choice.item.municipality) {\n {{choice.item.municipality}}\n }\n ({{choice.item.locationId}})\n </button>\n </li>\n }\n </ul>\n</section>\n}\n",
867
+ dependencies: [{
868
+ kind: "directive",
869
+ type: i1$1.ClickOutsideDirective,
870
+ selector: "[adbClickOutside]",
871
+ outputs: ["adbClickOutside"]
872
+ }, {
873
+ kind: "pipe",
874
+ type: i1$3.TranslatePipe,
875
+ name: "translate"
876
+ }],
877
+ changeDetection: i0.ChangeDetectionStrategy.Eager
878
+ });
879
+ };
880
+ i0.ɵɵngDeclareClassMetadata({
881
+ minVersion: "12.0.0",
882
+ version: "22.2.4",
883
+ ngImport: i0,
884
+ type: MapFeaturePickerComponent,
885
+ decorators: [{
886
+ type: Component,
887
+ args: [{
888
+ selector: "adb-map-feature-picker",
889
+ host: { class: "adb-map-feature-picker" },
890
+ changeDetection: ChangeDetectionStrategy.Eager,
891
+ standalone: false,
892
+ template: "@if (choices().length > 1) {\n<section class=\"adb-plate-primary shadow adb-map-feature-picker-panel\" [style.left.px]=\"position().left\" [style.top.px]=\"position().top\" [attr.aria-label]=\"'MAP.FEATURE_PICKER.TITLE' | translate\"\n (adbClickOutside)=\"dismissed.emit(false)\"\n (keydown.escape)=\"$event.stopPropagation(); dismissed.emit(true)\">\n <div class=\"d-flex align-items-center justify-content-between gap-3 mb-2\">\n <h2 class=\"h6 mb-0\">{{'MAP.FEATURE_PICKER.TITLE' | translate}}</h2>\n <button type=\"button\" class=\"btn-close\" [attr.aria-label]=\"'MAP.FEATURE_PICKER.CLOSE' | translate\" (click)=\"dismissed.emit(true)\"></button>\n </div>\n <ul class=\"list-group list-group-flush\">\n @for (choice of choices(); track choice.item.locationId) {\n <li class=\"list-group-item p-0\">\n <button type=\"button\" class=\"list-group-item list-group-item-action border-0 text-break\" (click)=\"choose(choice)\">\n @if (choice.item.locality) {\n {{choice.item.locality}}\n @if (choice.item.municipality) {, {{choice.item.municipality}}}\n } @else if (choice.item.municipality) {\n {{choice.item.municipality}}\n }\n ({{choice.item.locationId}})\n </button>\n </li>\n }\n </ul>\n</section>\n}\n"
893
+ }]
894
+ }],
895
+ ctorParameters: () => [],
896
+ propDecorators: {
897
+ locationOptions: [{
898
+ type: i0.Input,
899
+ args: [{
900
+ isSignal: true,
901
+ alias: "locationOptions",
902
+ required: true
903
+ }]
904
+ }],
905
+ featureChosen: [{
906
+ type: i0.Output,
907
+ args: ["featureChosen"]
908
+ }],
909
+ dismissed: [{
910
+ type: i0.Output,
911
+ args: ["dismissed"]
912
+ }]
913
+ }
914
+ });
915
+ var MapLegendComponent = class MapLegendComponent {
916
+ generalizedBackgroundColor = MapConstants.GENERALIZED_POLYGON_BACKGROUND_COLOR;
917
+ result = input(null, ...ngDevMode ? [{ debugName: "result" }] : /* istanbul ignore next */ []);
918
+ cutoffYear = input(null, ...ngDevMode ? [{ debugName: "cutoffYear" }] : /* istanbul ignore next */ []);
919
+ loading = input(false, ...ngDevMode ? [{ debugName: "loading" }] : /* istanbul ignore next */ []);
920
+ showObservationStatus = input(false, ...ngDevMode ? [{ debugName: "showObservationStatus" }] : /* istanbul ignore next */ []);
921
+ gridLevels = computed(() => AdbMapUtils.gridLevels(this.result()), ...ngDevMode ? [{ debugName: "gridLevels" }] : /* istanbul ignore next */ []);
922
+ features = computed(() => (this.result()?.features ?? []).filter((feature) => feature.properties?.FeatureType !== "FilterArea.Area"), ...ngDevMode ? [{ debugName: "features" }] : /* istanbul ignore next */ []);
923
+ hasNotRecovered = computed(() => this.showObservationStatus() && this.features().some((feature) => AdbMapUtils.isNotRecovered(feature.properties?.presentation)), ...ngDevMode ? [{ debugName: "hasNotRecovered" }] : /* istanbul ignore next */ []);
924
+ hasNotPresent = computed(() => this.showObservationStatus() && this.features().some((feature) => feature.properties?.presentation?.status === "NotPresent"), ...ngDevMode ? [{ debugName: "hasNotPresent" }] : /* istanbul ignore next */ []);
925
+ hasGeneralizedPolygons = computed(() => this.showObservationStatus() && this.features().some((feature) => feature.properties?.presentation?.generalized && ["Polygon", "MultiPolygon"].includes(feature.geometry?.type)), ...ngDevMode ? [{ debugName: "hasGeneralizedPolygons" }] : /* istanbul ignore next */ []);
926
+ hasCutoff = computed(() => this.cutoffYear() !== null && this.features().some((feature) => ["Until", "After"].includes(feature.properties?.presentation?.cutoffYearStatus)), ...ngDevMode ? [{ debugName: "hasCutoff" }] : /* istanbul ignore next */ []);
927
+ hasLocations = computed(() => this.features().some((feature) => feature.properties?.groupingType !== "pixelCluster" && !feature.properties?.isCluster && (feature.properties?.locations || feature.properties?.location || ["Point", "MultiPoint"].includes(feature.geometry?.type))), ...ngDevMode ? [{ debugName: "hasLocations" }] : /* istanbul ignore next */ []);
928
+ hasClusters = computed(() => this.features().some((feature) => feature.properties?.groupingType === "pixelCluster" || feature.properties?.isCluster), ...ngDevMode ? [{ debugName: "hasClusters" }] : /* istanbul ignore next */ []);
929
+ static ɵfac = i0.ɵɵngDeclareFactory({
930
+ minVersion: "12.0.0",
931
+ version: "22.2.4",
932
+ ngImport: i0,
933
+ type: MapLegendComponent,
934
+ deps: [],
935
+ target: i0.ɵɵFactoryTarget.Component
936
+ });
937
+ static ɵcmp = i0.ɵɵngDeclareComponent({
938
+ minVersion: "17.0.0",
939
+ version: "22.2.4",
940
+ type: MapLegendComponent,
941
+ isStandalone: false,
942
+ selector: "adb-map-legend",
943
+ inputs: {
944
+ result: {
945
+ classPropertyName: "result",
946
+ publicName: "result",
947
+ isSignal: true,
948
+ isRequired: false,
949
+ transformFunction: null
950
+ },
951
+ cutoffYear: {
952
+ classPropertyName: "cutoffYear",
953
+ publicName: "cutoffYear",
954
+ isSignal: true,
955
+ isRequired: false,
956
+ transformFunction: null
957
+ },
958
+ loading: {
959
+ classPropertyName: "loading",
960
+ publicName: "loading",
961
+ isSignal: true,
962
+ isRequired: false,
963
+ transformFunction: null
964
+ },
965
+ showObservationStatus: {
966
+ classPropertyName: "showObservationStatus",
967
+ publicName: "showObservationStatus",
968
+ isSignal: true,
969
+ isRequired: false,
970
+ transformFunction: null
971
+ }
972
+ },
973
+ ngImport: i0,
974
+ template: "<div class=\"bg-light border p-1 d-flex column-gap-1 align-items-center flex-wrap\">\n @if (hasLocations() || hasClusters()) {\n <div class=\"d-flex align-items-start gap-2 w-100\">\n <ul class=\"list-unstyled mb-0 d-flex flex-grow-1 flex-wrap column-gap-3 row-gap-1\">\n @if (hasCutoff()) {\n <li class=\"d-flex align-items-center gap-1\">\n <span class=\"legend legend-before\" aria-hidden=\"true\"></span>\n {{'MAP.LEGEND.BEFORE' | translate}} {{cutoffYear()}}\n </li>\n <li class=\"d-flex align-items-center gap-1\">\n <span class=\"legend legend-after\" aria-hidden=\"true\"></span>\n {{'MAP.LEGEND.FROM' | translate}} {{cutoffYear()}}\n </li>\n } @else if (hasLocations()) {\n <li class=\"d-flex align-items-center gap-1\">\n <span class=\"map-symbol-circle map-symbol-bg-5\" aria-hidden=\"true\"></span>\n {{'MAP.LEGEND.LOCATION' | translate}}\n </li>\n }\n @if (hasClusters() && !hasCutoff()) {\n <li class=\"d-flex align-items-center gap-1\">\n <span class=\"legend legend-cluster\" aria-hidden=\"true\"></span>\n {{'MAP.LEGEND.CLUSTER' | translate}}\n </li>\n }\n @if (hasNotRecovered()) {\n <li class=\"d-flex align-items-center gap-1\">\n <span class=\"map-symbol-circle-x map-symbol-bg-5\" aria-hidden=\"true\"></span>\n {{'MAP.LEGEND.NOT_RECOVERED' | translate}}\n </li>\n }\n @if (hasNotPresent()) {\n <li class=\"d-flex align-items-center gap-1\">\n <span class=\"map-symbol-circle map-symbol-bg-5 d-inline-flex align-items-center justify-content-center\" aria-hidden=\"true\">\n <svg width=\"12\" height=\"12\" viewBox=\"0 0 12 12\" focusable=\"false\">\n <line x1=\"2\" y1=\"6\" x2=\"10\" y2=\"6\" stroke=\"currentColor\" stroke-width=\"1.5\" />\n </svg>\n </span>\n {{'MAP.LEGEND.NOT_PRESENT' | translate}}\n </li>\n }\n @if (hasGeneralizedPolygons()) {\n <li class=\"d-flex align-items-center gap-1\">\n <span class=\"legend border border-2 border-danger\"\n [style.background-color]=\"generalizedBackgroundColor\" aria-hidden=\"true\"></span>\n {{'MAP.LEGEND.GENERALIZED_LOCATION' | translate}}\n </li>\n }\n </ul>\n <adb-help-button class=\"ms-auto flex-shrink-0\">\n <dl>\n <dt>{{'MAP.LEGEND.LOCATION' | translate}}</dt>\n <dd>{{'MAP.LEGEND.LOCATION_HELP' | translate}}</dd>\n <dt>{{'MAP.LEGEND.CLUSTER' | translate}}</dt>\n <dd>{{'MAP.LEGEND.CLUSTER_HELP' | translate}}</dd>\n </dl>\n </adb-help-button>\n </div>\n @if (hasCutoff() && hasClusters()) {\n <small class=\"d-block w-100\">{{'MAP.LEGEND.CLUSTER_SIZE' | translate}}</small>\n }\n }\n @if (!loading()) {\n @for (level of gridLevels(); track $index) {\n <div class=\"d-flex align-items-center gap-1\">\n <span class=\"legend border border-dark\" [style.background-color]=\"level.color\" aria-hidden=\"true\"></span>\n <small>\n @if ($first) {\n &lt; {{level.max + 1 | adbSpacing}}\n } @else if ($last) {\n &gt; {{level.min - 1 | adbSpacing}}\n } @else {\n {{level.min | adbSpacing}}–{{level.max | adbSpacing}}\n }\n </small>\n </div>\n }\n }\n</div>\n",
975
+ dependencies: [
976
+ {
977
+ kind: "component",
978
+ type: i1$1.AdbHelpButtonComponent,
979
+ selector: "adb-help-button",
980
+ inputs: ["buttonClass", "label"]
981
+ },
982
+ {
983
+ kind: "pipe",
984
+ type: i1$1.NumberSpacingPipe,
985
+ name: "adbSpacing"
986
+ },
987
+ {
988
+ kind: "pipe",
989
+ type: i1$3.TranslatePipe,
990
+ name: "translate"
991
+ }
992
+ ],
993
+ changeDetection: i0.ChangeDetectionStrategy.Eager
994
+ });
995
+ };
996
+ i0.ɵɵngDeclareClassMetadata({
997
+ minVersion: "12.0.0",
998
+ version: "22.2.4",
999
+ ngImport: i0,
1000
+ type: MapLegendComponent,
1001
+ decorators: [{
1002
+ type: Component,
1003
+ args: [{
1004
+ selector: "adb-map-legend",
1005
+ changeDetection: ChangeDetectionStrategy.Eager,
1006
+ standalone: false,
1007
+ template: "<div class=\"bg-light border p-1 d-flex column-gap-1 align-items-center flex-wrap\">\n @if (hasLocations() || hasClusters()) {\n <div class=\"d-flex align-items-start gap-2 w-100\">\n <ul class=\"list-unstyled mb-0 d-flex flex-grow-1 flex-wrap column-gap-3 row-gap-1\">\n @if (hasCutoff()) {\n <li class=\"d-flex align-items-center gap-1\">\n <span class=\"legend legend-before\" aria-hidden=\"true\"></span>\n {{'MAP.LEGEND.BEFORE' | translate}} {{cutoffYear()}}\n </li>\n <li class=\"d-flex align-items-center gap-1\">\n <span class=\"legend legend-after\" aria-hidden=\"true\"></span>\n {{'MAP.LEGEND.FROM' | translate}} {{cutoffYear()}}\n </li>\n } @else if (hasLocations()) {\n <li class=\"d-flex align-items-center gap-1\">\n <span class=\"map-symbol-circle map-symbol-bg-5\" aria-hidden=\"true\"></span>\n {{'MAP.LEGEND.LOCATION' | translate}}\n </li>\n }\n @if (hasClusters() && !hasCutoff()) {\n <li class=\"d-flex align-items-center gap-1\">\n <span class=\"legend legend-cluster\" aria-hidden=\"true\"></span>\n {{'MAP.LEGEND.CLUSTER' | translate}}\n </li>\n }\n @if (hasNotRecovered()) {\n <li class=\"d-flex align-items-center gap-1\">\n <span class=\"map-symbol-circle-x map-symbol-bg-5\" aria-hidden=\"true\"></span>\n {{'MAP.LEGEND.NOT_RECOVERED' | translate}}\n </li>\n }\n @if (hasNotPresent()) {\n <li class=\"d-flex align-items-center gap-1\">\n <span class=\"map-symbol-circle map-symbol-bg-5 d-inline-flex align-items-center justify-content-center\" aria-hidden=\"true\">\n <svg width=\"12\" height=\"12\" viewBox=\"0 0 12 12\" focusable=\"false\">\n <line x1=\"2\" y1=\"6\" x2=\"10\" y2=\"6\" stroke=\"currentColor\" stroke-width=\"1.5\" />\n </svg>\n </span>\n {{'MAP.LEGEND.NOT_PRESENT' | translate}}\n </li>\n }\n @if (hasGeneralizedPolygons()) {\n <li class=\"d-flex align-items-center gap-1\">\n <span class=\"legend border border-2 border-danger\"\n [style.background-color]=\"generalizedBackgroundColor\" aria-hidden=\"true\"></span>\n {{'MAP.LEGEND.GENERALIZED_LOCATION' | translate}}\n </li>\n }\n </ul>\n <adb-help-button class=\"ms-auto flex-shrink-0\">\n <dl>\n <dt>{{'MAP.LEGEND.LOCATION' | translate}}</dt>\n <dd>{{'MAP.LEGEND.LOCATION_HELP' | translate}}</dd>\n <dt>{{'MAP.LEGEND.CLUSTER' | translate}}</dt>\n <dd>{{'MAP.LEGEND.CLUSTER_HELP' | translate}}</dd>\n </dl>\n </adb-help-button>\n </div>\n @if (hasCutoff() && hasClusters()) {\n <small class=\"d-block w-100\">{{'MAP.LEGEND.CLUSTER_SIZE' | translate}}</small>\n }\n }\n @if (!loading()) {\n @for (level of gridLevels(); track $index) {\n <div class=\"d-flex align-items-center gap-1\">\n <span class=\"legend border border-dark\" [style.background-color]=\"level.color\" aria-hidden=\"true\"></span>\n <small>\n @if ($first) {\n &lt; {{level.max + 1 | adbSpacing}}\n } @else if ($last) {\n &gt; {{level.min - 1 | adbSpacing}}\n } @else {\n {{level.min | adbSpacing}}–{{level.max | adbSpacing}}\n }\n </small>\n </div>\n }\n }\n</div>\n"
1008
+ }]
1009
+ }],
1010
+ propDecorators: {
1011
+ result: [{
1012
+ type: i0.Input,
1013
+ args: [{
1014
+ isSignal: true,
1015
+ alias: "result",
1016
+ required: false
1017
+ }]
1018
+ }],
1019
+ cutoffYear: [{
1020
+ type: i0.Input,
1021
+ args: [{
1022
+ isSignal: true,
1023
+ alias: "cutoffYear",
1024
+ required: false
1025
+ }]
1026
+ }],
1027
+ loading: [{
1028
+ type: i0.Input,
1029
+ args: [{
1030
+ isSignal: true,
1031
+ alias: "loading",
1032
+ required: false
1033
+ }]
1034
+ }],
1035
+ showObservationStatus: [{
1036
+ type: i0.Input,
1037
+ args: [{
1038
+ isSignal: true,
1039
+ alias: "showObservationStatus",
1040
+ required: false
1041
+ }]
1042
+ }]
1043
+ }
1044
+ });
1045
+ var AdbMapComponent = class AdbMapComponent {
1046
+ activatedRoute;
1047
+ config;
1048
+ router;
1049
+ showLegend = input(true, ...ngDevMode ? [{ debugName: "showLegend" }] : /* istanbul ignore next */ []);
1050
+ showHeader = input(true, ...ngDevMode ? [{ debugName: "showHeader" }] : /* istanbul ignore next */ []);
1051
+ allowPresentationMode = input(false, ...ngDevMode ? [{ debugName: "allowPresentationMode" }] : /* istanbul ignore next */ []);
1052
+ presentationMode = input("locations", ...ngDevMode ? [{ debugName: "presentationMode" }] : /* istanbul ignore next */ []);
1053
+ route = signal(null, ...ngDevMode ? [{ debugName: "route" }] : /* istanbul ignore next */ []);
1054
+ activePresentationMode = computed(() => {
1055
+ const mode = this.route()?.queryParams["presentationMode"];
1056
+ if (this.allowPresentationMode() && (mode === "locations" || mode === "observations")) return mode;
1057
+ return this.presentationMode();
1058
+ }, ...ngDevMode ? [{ debugName: "activePresentationMode" }] : /* istanbul ignore next */ []);
1059
+ dataSource = inject(ADB_MAP_DATA_SOURCE);
1060
+ requestedParams = "";
1061
+ settingsOpen = signal(false, ...ngDevMode ? [{ debugName: "settingsOpen" }] : /* istanbul ignore next */ []);
1062
+ savingSettings = signal(false, ...ngDevMode ? [{ debugName: "savingSettings" }] : /* istanbul ignore next */ []);
1063
+ settingsError = signal(false, ...ngDevMode ? [{ debugName: "settingsError" }] : /* istanbul ignore next */ []);
1064
+ settingsForm = new FormGroup({
1065
+ presentationMode: new FormControl("locations"),
1066
+ uncertain: new FormControl(false),
1067
+ cutoff: new FormControl("", Validators.pattern(/^[1-9]\d*$/))
1068
+ });
1069
+ preserveViewOnNextLoad = false;
1070
+ error;
1071
+ mapLoading = signal(false, ...ngDevMode ? [{ debugName: "mapLoading" }] : /* istanbul ignore next */ []);
1072
+ locationSelected = output();
1073
+ clusterSelected = output();
1074
+ siteSource = new VectorSource();
1075
+ uncertaintySource = new VectorSource();
1076
+ siteLayer = new VectorLayer({
1077
+ source: this.siteSource,
1078
+ style: (feature) => this.featureStyle(feature)
1079
+ });
1080
+ format = new GeoJSON();
1081
+ resizeObserver;
1082
+ requestSubscription;
1083
+ hoveredFeature;
1084
+ selectedFeature = null;
1085
+ locationOptions = signal(null, ...ngDevMode ? [{ debugName: "locationOptions" }] : /* istanbul ignore next */ []);
1086
+ fittedView = "";
1087
+ pendingExtent;
1088
+ mapResult = signal(null, ...ngDevMode ? [{ debugName: "mapResult" }] : /* istanbul ignore next */ []);
1089
+ cutoffYear = computed(() => this.activePresentationMode() === "observations" ? this.route()?.queryParams["cutoff"] ?? null : null, ...ngDevMode ? [{ debugName: "cutoffYear" }] : /* istanbul ignore next */ []);
1090
+ gridLevels = computed(() => AdbMapUtils.gridLevels(this.mapResult()), ...ngDevMode ? [{ debugName: "gridLevels" }] : /* istanbul ignore next */ []);
1091
+ mapId = "" + Math.floor(Math.random() * Date.now());
1092
+ map;
1093
+ mapReady = signal(false, ...ngDevMode ? [{ debugName: "mapReady" }] : /* istanbul ignore next */ []);
1094
+ queryParams = {};
1095
+ constructor(activatedRoute, config, router) {
1096
+ this.activatedRoute = activatedRoute;
1097
+ this.config = config;
1098
+ this.router = router;
1099
+ this.route.set(this.activatedRoute.snapshot);
1100
+ this.settingsForm.controls.presentationMode.valueChanges.pipe(takeUntilDestroyed()).subscribe((mode) => {
1101
+ const cutoff = this.settingsForm.controls.cutoff;
1102
+ if (this.allowPresentationMode() && mode === "observations") cutoff.enable();
1103
+ else cutoff.disable();
1104
+ });
1105
+ this.router.events.pipe(takeUntilDestroyed()).subscribe((event) => {
1106
+ if (event instanceof NavigationEnd) this.route.set(this.activatedRoute.snapshot);
1107
+ });
1108
+ effect(() => {
1109
+ if (!this.mapReady()) return;
1110
+ const snapshot = this.route();
1111
+ this.queryParams = snapshot.queryParams;
1112
+ this.siteLayer.changed();
1113
+ const params = { ...snapshot.queryParams };
1114
+ delete params["presentationMode"];
1115
+ if (this.activePresentationMode() === "locations") delete params["cutoff"];
1116
+ if (snapshot.paramMap.has("taxonId")) params["taxonId"] = snapshot.paramMap.get("taxonId");
1117
+ const requestKey = JSON.stringify(params);
1118
+ if (requestKey === this.requestedParams) {
1119
+ this.preserveViewOnNextLoad = false;
1120
+ return;
1121
+ }
1122
+ this.requestedParams = requestKey;
1123
+ this.loadFeature(params);
1124
+ });
1125
+ }
1126
+ ngAfterViewInit() {
1127
+ this.map = AdbMapUtils.createMap(this.mapId, {
1128
+ zoom: true,
1129
+ scrollZoom: false,
1130
+ providers: true
1131
+ });
1132
+ this.map.addLayer(new VectorLayer({
1133
+ source: this.uncertaintySource,
1134
+ style: new Style({ stroke: new Stroke({
1135
+ color: MapConstants.UNCERTAINTY_BORDER_COLOR,
1136
+ width: 1
1137
+ }) })
1138
+ }));
1139
+ this.map.addLayer(this.siteLayer);
1140
+ this.resizeObserver = new ResizeObserver(() => {
1141
+ this.closeLocationPicker(false);
1142
+ this.map.updateSize();
1143
+ const size = this.map.getSize();
1144
+ if (size?.[0] && size[1]) this.mapReady.set(true);
1145
+ this.fitPendingExtent();
1146
+ });
1147
+ this.resizeObserver.observe(this.map.getTargetElement());
1148
+ this.fittedView = this.viewKey();
1149
+ const size = this.map.getSize();
1150
+ if (size?.[0] && size[1]) this.mapReady.set(true);
1151
+ this.attachUserListeners();
1152
+ }
1153
+ openSettings() {
1154
+ this.settingsForm.reset({
1155
+ presentationMode: this.activePresentationMode(),
1156
+ uncertain: this.queryParams["uncertain"] === "true",
1157
+ cutoff: {
1158
+ value: this.queryParams["cutoff"] ?? "",
1159
+ disabled: !this.allowPresentationMode() || this.activePresentationMode() !== "observations"
1160
+ }
1161
+ });
1162
+ this.settingsError.set(false);
1163
+ this.closeLocationPicker(false);
1164
+ this.settingsOpen.set(true);
1165
+ }
1166
+ cancelSettings(button) {
1167
+ this.settingsForm.reset();
1168
+ this.settingsOpen.set(false);
1169
+ button.focus({ preventScroll: true });
1170
+ }
1171
+ async saveSettings(button) {
1172
+ if (this.settingsForm.invalid || this.savingSettings()) return;
1173
+ this.savingSettings.set(true);
1174
+ this.settingsError.set(false);
1175
+ this.preserveViewOnNextLoad = true;
1176
+ try {
1177
+ if (await this.router.navigate([], {
1178
+ relativeTo: this.activatedRoute,
1179
+ queryParams: {
1180
+ uncertain: this.settingsForm.value.uncertain || null,
1181
+ presentationMode: this.allowPresentationMode() ? this.settingsForm.value.presentationMode : null,
1182
+ cutoff: this.allowPresentationMode() ? this.settingsForm.value.cutoff || null : null
1183
+ },
1184
+ queryParamsHandling: "merge"
1185
+ })) this.cancelSettings(button);
1186
+ else this.settingsError.set(true);
1187
+ } catch {
1188
+ this.settingsError.set(true);
1189
+ } finally {
1190
+ if (this.settingsError()) this.preserveViewOnNextLoad = false;
1191
+ this.savingSettings.set(false);
1192
+ }
1193
+ }
1194
+ onExport() {
1195
+ const json = this.format.writeFeatures(this.siteSource.getFeatures(), {
1196
+ featureProjection: this.map.getView().getProjection(),
1197
+ dataProjection: "EPSG:4326"
1198
+ });
1199
+ AdbMapUtils.createFile(new Blob([json], { type: "application/geo+json" }), "sites.geojson");
1200
+ }
1201
+ attachUserListeners() {
1202
+ this.map.on("moveend", () => {
1203
+ this.closeLocationPicker(false);
1204
+ if (this.viewKey() === this.fittedView) return;
1205
+ if (this.config.dynamic) {
1206
+ const bbox = this.currentBbox();
1207
+ if (bbox !== this.queryParams?.["bbox"]) this.router.navigate([], {
1208
+ relativeTo: this.activatedRoute,
1209
+ queryParams: { bbox },
1210
+ queryParamsHandling: "merge"
1211
+ });
1212
+ }
1213
+ });
1214
+ this.map.on("pointermove", (event) => {
1215
+ const feature = this.config.dynamic ? this.map.forEachFeatureAtPixel(event.pixel, (feature) => ["FilterArea.Area", "FilterArea.OwnPolygon"].includes(feature.get("FeatureType")) ? null : feature, { layerFilter: (layer) => layer === this.siteLayer }) : void 0;
1216
+ this.map.getTargetElement().style.cursor = feature ? "pointer" : "";
1217
+ if (this.hoveredFeature !== feature) {
1218
+ this.hoveredFeature = feature;
1219
+ this.siteLayer.changed();
1220
+ }
1221
+ });
1222
+ this.map.on("singleclick", (event) => {
1223
+ if (!this.config.dynamic) return;
1224
+ this.locationOptions.set({
1225
+ features: this.map.getFeaturesAtPixel(event.pixel, { layerFilter: (layer) => layer === this.siteLayer }),
1226
+ pixel: event.pixel,
1227
+ extent: this.map.getView().calculateExtent(this.map.getSize()),
1228
+ selectMode: this.config.enableClusterSelection && (event.originalEvent.ctrlKey || event.originalEvent.metaKey)
1229
+ });
1230
+ });
1231
+ }
1232
+ closeLocationPicker(restoreFocus = true) {
1233
+ this.locationOptions.set(null);
1234
+ this.hoveredFeature = null;
1235
+ this.siteLayer.changed();
1236
+ if (restoreFocus) this.map.getTargetElement().focus({ preventScroll: true });
1237
+ }
1238
+ onFeatureChosen(selection) {
1239
+ this.closeLocationPicker(selection.restoreFocus);
1240
+ const { feature, properties: props } = selection;
1241
+ const cluster = props["groupingType"] === "pixelCluster" || props["isCluster"];
1242
+ const location = !cluster && !!(props["location"] || props["observationCount"]);
1243
+ if ((cluster || location) && this.config.enableClusterSelection && selection.selectMode) {
1244
+ this.selectedFeature = feature;
1245
+ this.siteLayer.changed();
1246
+ delete props["geometry"];
1247
+ if (cluster) this.clusterSelected.emit(props);
1248
+ else this.locationSelected.emit(props);
1249
+ return;
1250
+ }
1251
+ if (location) {
1252
+ delete props["geometry"];
1253
+ this.locationSelected.emit(props);
1254
+ } else if (cluster || props["ObservationsCount"] > 0) {
1255
+ let extent = feature.getGeometry().getExtent();
1256
+ if (cluster) {
1257
+ const projectedCenter = getCenter(extent);
1258
+ const center = toLonLat(projectedCenter);
1259
+ const radius = props["cluster"].radiusMeters;
1260
+ extent = new CircleGeometry(projectedCenter, radius / Math.cos(center[1] * Math.PI / 180)).getExtent();
1261
+ const view = this.map.getView();
1262
+ const size = this.map.getSize();
1263
+ const fitSize = [size[0] - 40, size[1] - 40];
1264
+ if (view.getResolutionForExtent(extent, fitSize) >= view.getResolution()) extent = getForViewAndSize(projectedCenter, view.getResolution() / 2, 0, fitSize);
1265
+ }
1266
+ const bbox = transformExtent(extent, this.map.getView().getProjection(), "EPSG:4326").join(",");
1267
+ this.router.navigate([], {
1268
+ relativeTo: this.activatedRoute,
1269
+ queryParams: { bbox },
1270
+ queryParamsHandling: "merge"
1271
+ });
1272
+ }
1273
+ }
1274
+ currentBbox() {
1275
+ return transformExtent(this.map.getView().calculateExtent(this.map.getSize()), this.map.getView().getProjection(), "EPSG:4326").join(",");
1276
+ }
1277
+ loadFeature(qParams) {
1278
+ this.requestSubscription?.unsubscribe();
1279
+ this.mapLoading.set(true);
1280
+ this.error = null;
1281
+ const fitView = !this.preserveViewOnNextLoad && (!qParams["bbox"] || qParams["bbox"] !== this.currentBbox());
1282
+ this.preserveViewOnNextLoad = false;
1283
+ const requestedView = this.viewKey();
1284
+ this.requestSubscription = this.dataSource.load({
1285
+ url: this.config.observationFeatures,
1286
+ params: qParams,
1287
+ metersPerPixel: this.getMetersPerPixel(qParams),
1288
+ dataProviderIds: this.config.dataProviderIds
1289
+ }).pipe(finalize(() => {
1290
+ this.mapLoading.set(false);
1291
+ })).subscribe({
1292
+ next: (geo) => {
1293
+ this.buildMap(geo, fitView && requestedView === this.viewKey());
1294
+ },
1295
+ error: (err) => {
1296
+ this.requestedParams = "";
1297
+ this.error = err;
1298
+ }
1299
+ });
1300
+ }
1301
+ getMetersPerPixel(qParams) {
1302
+ return qParams.bbox ? AdbMapUtils.getMetersPerPixel(qParams.bbox, this.map.getSize()?.[0]) : MapConstants.INITIAL_METERS_PER_PIXEL;
1303
+ }
1304
+ buildMap(geojson, fitView) {
1305
+ this.mapResult.set(geojson);
1306
+ const features = this.format.readFeatures(geojson, { featureProjection: this.map.getView().getProjection() });
1307
+ this.closeLocationPicker(false);
1308
+ this.selectedFeature = null;
1309
+ this.siteSource.clear();
1310
+ this.uncertaintySource.clear();
1311
+ this.siteSource.addFeatures(features);
1312
+ if (this.queryParams?.["uncertain"] === "true") for (const feature of features) {
1313
+ const props = feature.getProperties();
1314
+ if (props["groupingType"] !== "singleLocation") continue;
1315
+ const location = props["locations"]?.items?.[0];
1316
+ const radius = location?.coordinateUncertaintyInMeters;
1317
+ const geometry = feature.getGeometry();
1318
+ if (geometry.getType() === "Point" && location?.type === "Point" && radius > 0) {
1319
+ const center = geometry.getExtent().slice(0, 2);
1320
+ this.uncertaintySource.addFeature(new Feature(AdbMapUtils.createUncertaintyCircle(center, radius)));
1321
+ }
1322
+ }
1323
+ this.pendingExtent = void 0;
1324
+ if (!fitView) return;
1325
+ const extent = geojson.bbox ? transformExtent(geojson.bbox, "EPSG:4326", this.map.getView().getProjection()) : extend(this.siteSource.getExtent(), this.uncertaintySource.getExtent());
1326
+ if (!isEmpty(extent)) {
1327
+ this.pendingExtent = extent;
1328
+ this.fitPendingExtent();
1329
+ }
1330
+ }
1331
+ viewKey() {
1332
+ return [...this.map.getView().getCenter(), this.map.getView().getResolution()].join(",");
1333
+ }
1334
+ fitPendingExtent() {
1335
+ const size = this.map.getSize();
1336
+ if (!this.pendingExtent || !size?.[0] || !size[1]) return;
1337
+ this.map.getView().fit(this.pendingExtent, {
1338
+ padding: [
1339
+ 20,
1340
+ 20,
1341
+ 20,
1342
+ 20
1343
+ ],
1344
+ maxZoom: 18
1345
+ });
1346
+ this.fittedView = this.viewKey();
1347
+ this.pendingExtent = void 0;
1348
+ }
1349
+ featureStyle(feature) {
1350
+ const props = feature.getProperties();
1351
+ if (["FilterArea.Area", "FilterArea.OwnPolygon"].includes(props["FeatureType"])) return new Style({
1352
+ stroke: new Stroke({
1353
+ color: MapConstants.SEARCH_AREA_BORDER_COLOR,
1354
+ width: 2
1355
+ }),
1356
+ fill: new Fill({ color: "transparent" })
1357
+ });
1358
+ const cluster = props["groupingType"] === "pixelCluster" || props["isCluster"];
1359
+ const location = props["locations"] || props["location"];
1360
+ const point = ["Point", "MultiPoint"].includes(feature.getGeometry()?.getType());
1361
+ if (cluster || location || point) return this.activePresentationMode() === "observations" ? this.aggregatedSymbol(feature) : this.locationSymbol(feature);
1362
+ if (props["FeatureId"]) return new Style({
1363
+ stroke: new Stroke({
1364
+ color: "#005e67",
1365
+ width: 2
1366
+ }),
1367
+ fill: new Fill({ color: "rgba(0,118,129,0.1)" })
1368
+ });
1369
+ const color = this.gridLevels().find((level) => props["ObservationsCount"] <= level.max)?.color ?? "#2FB3BB";
1370
+ return new Style({
1371
+ stroke: new Stroke({
1372
+ color: "#212529",
1373
+ width: 1
1374
+ }),
1375
+ fill: new Fill({ color })
1376
+ });
1377
+ }
1378
+ locationSymbol(feature) {
1379
+ return AdbMapUtils.locationSymbol(feature, feature === this.selectedFeature, feature === this.hoveredFeature);
1380
+ }
1381
+ aggregatedSymbol(feature) {
1382
+ return AdbMapUtils.aggregatedSymbol(this.locationSymbol(feature), feature.get("presentation"), this.cutoffYear(), feature === this.selectedFeature, feature.getGeometry()?.getType());
1383
+ }
1384
+ ngOnDestroy() {
1385
+ this.requestSubscription?.unsubscribe();
1386
+ this.resizeObserver?.disconnect();
1387
+ this.map?.dispose();
1388
+ }
1389
+ static ɵfac = i0.ɵɵngDeclareFactory({
1390
+ minVersion: "12.0.0",
1391
+ version: "22.2.4",
1392
+ ngImport: i0,
1393
+ type: AdbMapComponent,
1394
+ deps: [
1395
+ { token: i1.ActivatedRoute },
1396
+ { token: AdbMapConfigService },
1397
+ { token: i1.Router }
1398
+ ],
1399
+ target: i0.ɵɵFactoryTarget.Component
1400
+ });
1401
+ static ɵcmp = i0.ɵɵngDeclareComponent({
1402
+ minVersion: "17.0.0",
1403
+ version: "22.2.4",
1404
+ type: AdbMapComponent,
1405
+ isStandalone: false,
1406
+ selector: "adb-map",
1407
+ inputs: {
1408
+ showLegend: {
1409
+ classPropertyName: "showLegend",
1410
+ publicName: "showLegend",
1411
+ isSignal: true,
1412
+ isRequired: false,
1413
+ transformFunction: null
1414
+ },
1415
+ showHeader: {
1416
+ classPropertyName: "showHeader",
1417
+ publicName: "showHeader",
1418
+ isSignal: true,
1419
+ isRequired: false,
1420
+ transformFunction: null
1421
+ },
1422
+ allowPresentationMode: {
1423
+ classPropertyName: "allowPresentationMode",
1424
+ publicName: "allowPresentationMode",
1425
+ isSignal: true,
1426
+ isRequired: false,
1427
+ transformFunction: null
1428
+ },
1429
+ presentationMode: {
1430
+ classPropertyName: "presentationMode",
1431
+ publicName: "presentationMode",
1432
+ isSignal: true,
1433
+ isRequired: false,
1434
+ transformFunction: null
1435
+ }
1436
+ },
1437
+ outputs: {
1438
+ locationSelected: "locationSelected",
1439
+ clusterSelected: "clusterSelected"
1440
+ },
1441
+ ngImport: i0,
1442
+ template: "@if(error){\n<div class=\"d-flex align-items-baseline gap-2 p-2 mb-3\" role=\"alert\">\n <span class=\"bi bi-circle-fill text-danger\" aria-hidden=\"true\"></span>\n <span>{{'ERROR.SERVER_ERROR'|translate}}</span>\n</div>\n}\n<div [class.loading]=\"mapLoading()\">\n <div class=\"d-flex align-items-center justify-content-end flex-wrap gap-1 border p-1\" [class.d-none]=\"!showHeader()\">\n @if (!mapLoading() && mapResult()?.properties?.count != null) {\n <span class=\"me-auto\">{{mapResult().properties.count | adbSpacing}} {{'MAP.OBSERVATIONS' | translate}}</span>\n }\n <button type=\"button\" class=\"btn btn-sm btn-secondary\" [attr.aria-label]=\"'MAP.FULLSCREEN' | translate\" [title]=\"'MAP.FULLSCREEN' | translate\" [disabled]=\"settingsOpen()\">\n <span class=\"bi bi-fullscreen\" aria-hidden=\"true\"></span>\n </button>\n <button type=\"button\" class=\"btn btn-sm btn-secondary\" [attr.aria-label]=\"'MAP.EXPORT' | translate\" [title]=\"'MAP.EXPORT' | translate\" [disabled]=\"settingsOpen()\" (click)=\"onExport()\">\n <span class=\"bi bi-download\" aria-hidden=\"true\"></span>\n </button>\n <button #settingsButton type=\"button\" class=\"btn btn-sm btn-secondary\" [attr.aria-label]=\"'MAP.SETTINGS.TITLE' | translate\"\n [title]=\"'MAP.SETTINGS.TITLE' | translate\" [attr.aria-expanded]=\"settingsOpen()\" [attr.aria-controls]=\"mapId + '-settings'\"\n (click)=\"settingsOpen() ? cancelSettings(settingsButton) : openSettings()\">\n <span class=\"bi bi-gear\" aria-hidden=\"true\"></span>\n </button>\n </div>\n <div class=\"position-relative\">\n <div [id]=\"mapId\" tabindex=\"0\" class=\"border-start border-end adb-map\" [class.invisible]=\"settingsOpen()\" [attr.inert]=\"settingsOpen() ? '' : null\"></div>\n @if (locationOptions(); as options) {\n <adb-map-feature-picker [locationOptions]=\"options\" (featureChosen)=\"onFeatureChosen($event)\" (dismissed)=\"closeLocationPicker($event)\" />\n }\n @if (settingsOpen()) {\n <form [id]=\"mapId + '-settings'\" [formGroup]=\"settingsForm\" (ngSubmit)=\"saveSettings(settingsButton)\"\n class=\"form p-3 position-absolute top-0 start-0 w-100 h-100 overflow-auto m-0\"\n [class.loading]=\"savingSettings()\" [attr.aria-labelledby]=\"mapId + '-settings-title'\" [attr.aria-busy]=\"savingSettings()\"\n (keydown.escape)=\"cancelSettings(settingsButton); $event.stopPropagation()\">\n <h2 [id]=\"mapId + '-settings-title'\" class=\"h5\">{{'MAP.SETTINGS.TITLE' | translate}}</h2>\n <div class=\"form-check mb-3\">\n <input [id]=\"mapId + '-uncertain'\" type=\"checkbox\" formControlName=\"uncertain\" class=\"form-check-input\">\n <label [for]=\"mapId + '-uncertain'\" class=\"form-check-label\">{{'MAP.SETTINGS.UNCERTAINTY' | translate}}</label>\n </div>\n @if (allowPresentationMode()) {\n <div class=\"mb-3\">\n <label [for]=\"mapId + '-presentation-mode'\">{{'MAP.SETTINGS.PRESENTATION_MODE' | translate}}</label>\n <select [id]=\"mapId + '-presentation-mode'\" formControlName=\"presentationMode\" class=\"form-select\">\n <option value=\"locations\">{{'MAP.SETTINGS.LOCATIONS_MODE' | translate}}</option>\n <option value=\"observations\">{{'MAP.SETTINGS.OBSERVATIONS_MODE' | translate}}</option>\n </select>\n </div>\n @if (settingsForm.controls.presentationMode.value === 'observations') {\n <div class=\"mb-3\">\n <label [for]=\"mapId + '-cutoff'\">{{'MAP.SETTINGS.CUTOFF' | translate}}</label>\n <input [id]=\"mapId + '-cutoff'\" type=\"text\" inputmode=\"numeric\" formControlName=\"cutoff\" class=\"form-control\"\n [attr.aria-invalid]=\"settingsForm.controls.cutoff.invalid\" [attr.aria-describedby]=\"mapId + '-cutoff-error'\">\n @if (settingsForm.controls.cutoff.invalid) {\n <div [id]=\"mapId + '-cutoff-error'\" class=\"invalid-feedback\">{{'MAP.SETTINGS.INVALID_CUTOFF' | translate}}</div>\n }\n </div>\n }\n }\n @if (settingsError()) {\n <div class=\"d-flex align-items-baseline gap-2 p-2 mb-3\" role=\"alert\">\n <span class=\"bi bi-circle-fill text-danger\" aria-hidden=\"true\"></span>\n <span>{{'MAP.SETTINGS.SAVE_ERROR' | translate}}</span>\n </div>\n }\n <div class=\"d-flex justify-content-end gap-2\">\n <button type=\"button\" class=\"btn btn-secondary\" (click)=\"cancelSettings(settingsButton)\">{{'MAP.SETTINGS.CANCEL' | translate}}</button>\n <button type=\"submit\" class=\"btn btn-primary\" [disabled]=\"settingsForm.invalid || settingsForm.pristine\">{{'MAP.SETTINGS.SAVE' | translate}}</button>\n </div>\n </form>\n }\n </div>\n</div>\n@if (showLegend() && !settingsOpen()) {\n <adb-map-legend [result]=\"mapResult()\" [cutoffYear]=\"cutoffYear()\" [loading]=\"mapLoading()\"\n [showObservationStatus]=\"activePresentationMode() === 'observations'\" />\n}\n",
1443
+ dependencies: [
1444
+ {
1445
+ kind: "directive",
1446
+ type: i3.ɵNgNoValidate,
1447
+ selector: "form:not([ngNoForm]):not([ngNativeValidate])"
1448
+ },
1449
+ {
1450
+ kind: "directive",
1451
+ type: i3.NgSelectOption,
1452
+ selector: "option",
1453
+ inputs: ["ngValue", "value"]
1454
+ },
1455
+ {
1456
+ kind: "directive",
1457
+ type: i3.ɵNgSelectMultipleOption,
1458
+ selector: "option",
1459
+ inputs: ["ngValue", "value"]
1460
+ },
1461
+ {
1462
+ kind: "directive",
1463
+ type: i3.DefaultValueAccessor,
1464
+ selector: "input:not([type=checkbox]):not([ngNoCva])[formControlName],textarea:not([ngNoCva])[formControlName],input:not([type=checkbox]):not([ngNoCva])[formControl],textarea:not([ngNoCva])[formControl],input:not([type=checkbox]):not([ngNoCva])[ngModel],textarea:not([ngNoCva])[ngModel],[ngDefaultControl]"
1465
+ },
1466
+ {
1467
+ kind: "directive",
1468
+ type: i3.CheckboxControlValueAccessor,
1469
+ selector: "input[type=checkbox]:not([ngNoCva])[formControlName],input[type=checkbox]:not([ngNoCva])[formControl],input[type=checkbox]:not([ngNoCva])[ngModel]"
1470
+ },
1471
+ {
1472
+ kind: "directive",
1473
+ type: i3.SelectControlValueAccessor,
1474
+ selector: "select:not([multiple]):not([ngNoCva])[formControlName],select:not([multiple]):not([ngNoCva])[formControl],select:not([multiple]):not([ngNoCva])[ngModel]",
1475
+ inputs: ["compareWith"]
1476
+ },
1477
+ {
1478
+ kind: "directive",
1479
+ type: i3.NgControlStatus,
1480
+ selector: "[formControlName],[ngModel],[formControl]"
1481
+ },
1482
+ {
1483
+ kind: "directive",
1484
+ type: i3.NgControlStatusGroup,
1485
+ selector: "[formGroupName],[formArrayName],[ngModelGroup],[formGroup],[formArray],form:not([ngNoForm]),[ngForm]"
1486
+ },
1487
+ {
1488
+ kind: "directive",
1489
+ type: i3.FormGroupDirective,
1490
+ selector: "[formGroup]",
1491
+ inputs: ["formGroup"],
1492
+ outputs: ["ngSubmit"],
1493
+ exportAs: ["ngForm"]
1494
+ },
1495
+ {
1496
+ kind: "directive",
1497
+ type: i3.FormControlName,
1498
+ selector: "[formControlName]",
1499
+ inputs: [
1500
+ "formControlName",
1501
+ "disabled",
1502
+ "ngModel"
1503
+ ],
1504
+ outputs: ["ngModelChange"]
1505
+ },
1506
+ {
1507
+ kind: "component",
1508
+ type: MapFeaturePickerComponent,
1509
+ selector: "adb-map-feature-picker",
1510
+ inputs: ["locationOptions"],
1511
+ outputs: ["featureChosen", "dismissed"]
1512
+ },
1513
+ {
1514
+ kind: "component",
1515
+ type: MapLegendComponent,
1516
+ selector: "adb-map-legend",
1517
+ inputs: [
1518
+ "result",
1519
+ "cutoffYear",
1520
+ "loading",
1521
+ "showObservationStatus"
1522
+ ]
1523
+ },
1524
+ {
1525
+ kind: "pipe",
1526
+ type: i1$1.NumberSpacingPipe,
1527
+ name: "adbSpacing"
1528
+ },
1529
+ {
1530
+ kind: "pipe",
1531
+ type: i1$3.TranslatePipe,
1532
+ name: "translate"
1533
+ }
1534
+ ],
1535
+ changeDetection: i0.ChangeDetectionStrategy.Eager
1536
+ });
1537
+ };
1538
+ i0.ɵɵngDeclareClassMetadata({
1539
+ minVersion: "12.0.0",
1540
+ version: "22.2.4",
1541
+ ngImport: i0,
1542
+ type: AdbMapComponent,
1543
+ decorators: [{
1544
+ type: Component,
1545
+ args: [{
1546
+ selector: "adb-map",
1547
+ changeDetection: ChangeDetectionStrategy.Eager,
1548
+ standalone: false,
1549
+ template: "@if(error){\n<div class=\"d-flex align-items-baseline gap-2 p-2 mb-3\" role=\"alert\">\n <span class=\"bi bi-circle-fill text-danger\" aria-hidden=\"true\"></span>\n <span>{{'ERROR.SERVER_ERROR'|translate}}</span>\n</div>\n}\n<div [class.loading]=\"mapLoading()\">\n <div class=\"d-flex align-items-center justify-content-end flex-wrap gap-1 border p-1\" [class.d-none]=\"!showHeader()\">\n @if (!mapLoading() && mapResult()?.properties?.count != null) {\n <span class=\"me-auto\">{{mapResult().properties.count | adbSpacing}} {{'MAP.OBSERVATIONS' | translate}}</span>\n }\n <button type=\"button\" class=\"btn btn-sm btn-secondary\" [attr.aria-label]=\"'MAP.FULLSCREEN' | translate\" [title]=\"'MAP.FULLSCREEN' | translate\" [disabled]=\"settingsOpen()\">\n <span class=\"bi bi-fullscreen\" aria-hidden=\"true\"></span>\n </button>\n <button type=\"button\" class=\"btn btn-sm btn-secondary\" [attr.aria-label]=\"'MAP.EXPORT' | translate\" [title]=\"'MAP.EXPORT' | translate\" [disabled]=\"settingsOpen()\" (click)=\"onExport()\">\n <span class=\"bi bi-download\" aria-hidden=\"true\"></span>\n </button>\n <button #settingsButton type=\"button\" class=\"btn btn-sm btn-secondary\" [attr.aria-label]=\"'MAP.SETTINGS.TITLE' | translate\"\n [title]=\"'MAP.SETTINGS.TITLE' | translate\" [attr.aria-expanded]=\"settingsOpen()\" [attr.aria-controls]=\"mapId + '-settings'\"\n (click)=\"settingsOpen() ? cancelSettings(settingsButton) : openSettings()\">\n <span class=\"bi bi-gear\" aria-hidden=\"true\"></span>\n </button>\n </div>\n <div class=\"position-relative\">\n <div [id]=\"mapId\" tabindex=\"0\" class=\"border-start border-end adb-map\" [class.invisible]=\"settingsOpen()\" [attr.inert]=\"settingsOpen() ? '' : null\"></div>\n @if (locationOptions(); as options) {\n <adb-map-feature-picker [locationOptions]=\"options\" (featureChosen)=\"onFeatureChosen($event)\" (dismissed)=\"closeLocationPicker($event)\" />\n }\n @if (settingsOpen()) {\n <form [id]=\"mapId + '-settings'\" [formGroup]=\"settingsForm\" (ngSubmit)=\"saveSettings(settingsButton)\"\n class=\"form p-3 position-absolute top-0 start-0 w-100 h-100 overflow-auto m-0\"\n [class.loading]=\"savingSettings()\" [attr.aria-labelledby]=\"mapId + '-settings-title'\" [attr.aria-busy]=\"savingSettings()\"\n (keydown.escape)=\"cancelSettings(settingsButton); $event.stopPropagation()\">\n <h2 [id]=\"mapId + '-settings-title'\" class=\"h5\">{{'MAP.SETTINGS.TITLE' | translate}}</h2>\n <div class=\"form-check mb-3\">\n <input [id]=\"mapId + '-uncertain'\" type=\"checkbox\" formControlName=\"uncertain\" class=\"form-check-input\">\n <label [for]=\"mapId + '-uncertain'\" class=\"form-check-label\">{{'MAP.SETTINGS.UNCERTAINTY' | translate}}</label>\n </div>\n @if (allowPresentationMode()) {\n <div class=\"mb-3\">\n <label [for]=\"mapId + '-presentation-mode'\">{{'MAP.SETTINGS.PRESENTATION_MODE' | translate}}</label>\n <select [id]=\"mapId + '-presentation-mode'\" formControlName=\"presentationMode\" class=\"form-select\">\n <option value=\"locations\">{{'MAP.SETTINGS.LOCATIONS_MODE' | translate}}</option>\n <option value=\"observations\">{{'MAP.SETTINGS.OBSERVATIONS_MODE' | translate}}</option>\n </select>\n </div>\n @if (settingsForm.controls.presentationMode.value === 'observations') {\n <div class=\"mb-3\">\n <label [for]=\"mapId + '-cutoff'\">{{'MAP.SETTINGS.CUTOFF' | translate}}</label>\n <input [id]=\"mapId + '-cutoff'\" type=\"text\" inputmode=\"numeric\" formControlName=\"cutoff\" class=\"form-control\"\n [attr.aria-invalid]=\"settingsForm.controls.cutoff.invalid\" [attr.aria-describedby]=\"mapId + '-cutoff-error'\">\n @if (settingsForm.controls.cutoff.invalid) {\n <div [id]=\"mapId + '-cutoff-error'\" class=\"invalid-feedback\">{{'MAP.SETTINGS.INVALID_CUTOFF' | translate}}</div>\n }\n </div>\n }\n }\n @if (settingsError()) {\n <div class=\"d-flex align-items-baseline gap-2 p-2 mb-3\" role=\"alert\">\n <span class=\"bi bi-circle-fill text-danger\" aria-hidden=\"true\"></span>\n <span>{{'MAP.SETTINGS.SAVE_ERROR' | translate}}</span>\n </div>\n }\n <div class=\"d-flex justify-content-end gap-2\">\n <button type=\"button\" class=\"btn btn-secondary\" (click)=\"cancelSettings(settingsButton)\">{{'MAP.SETTINGS.CANCEL' | translate}}</button>\n <button type=\"submit\" class=\"btn btn-primary\" [disabled]=\"settingsForm.invalid || settingsForm.pristine\">{{'MAP.SETTINGS.SAVE' | translate}}</button>\n </div>\n </form>\n }\n </div>\n</div>\n@if (showLegend() && !settingsOpen()) {\n <adb-map-legend [result]=\"mapResult()\" [cutoffYear]=\"cutoffYear()\" [loading]=\"mapLoading()\"\n [showObservationStatus]=\"activePresentationMode() === 'observations'\" />\n}\n"
1550
+ }]
1551
+ }],
1552
+ ctorParameters: () => [
1553
+ { type: i1.ActivatedRoute },
1554
+ { type: AdbMapConfigService },
1555
+ { type: i1.Router }
1556
+ ],
1557
+ propDecorators: {
1558
+ showLegend: [{
1559
+ type: i0.Input,
1560
+ args: [{
1561
+ isSignal: true,
1562
+ alias: "showLegend",
1563
+ required: false
1564
+ }]
1565
+ }],
1566
+ showHeader: [{
1567
+ type: i0.Input,
1568
+ args: [{
1569
+ isSignal: true,
1570
+ alias: "showHeader",
1571
+ required: false
1572
+ }]
1573
+ }],
1574
+ allowPresentationMode: [{
1575
+ type: i0.Input,
1576
+ args: [{
1577
+ isSignal: true,
1578
+ alias: "allowPresentationMode",
1579
+ required: false
1580
+ }]
1581
+ }],
1582
+ presentationMode: [{
1583
+ type: i0.Input,
1584
+ args: [{
1585
+ isSignal: true,
1586
+ alias: "presentationMode",
1587
+ required: false
1588
+ }]
1589
+ }],
1590
+ locationSelected: [{
1591
+ type: i0.Output,
1592
+ args: ["locationSelected"]
1593
+ }],
1594
+ clusterSelected: [{
1595
+ type: i0.Output,
1596
+ args: ["clusterSelected"]
1597
+ }]
1598
+ }
1599
+ });
1600
+ var AdbLocationMapComponent = class AdbLocationMapComponent {
1601
+ geoJson = input.required(...ngDevMode ? [{ debugName: "geoJson" }] : /* istanbul ignore next */ []);
1602
+ mapId = "location-map-" + Math.floor(Math.random() * Date.now());
1603
+ map;
1604
+ resizeObserver;
1605
+ pendingExtent = null;
1606
+ source = new VectorSource();
1607
+ uncertaintySource = new VectorSource();
1608
+ format = new GeoJSON();
1609
+ ngAfterViewInit() {
1610
+ this.map = AdbMapUtils.createMap(this.mapId, { scrollZoom: false });
1611
+ this.map.addLayer(new VectorLayer({
1612
+ source: this.uncertaintySource,
1613
+ style: new Style({ stroke: new Stroke({
1614
+ color: MapConstants.UNCERTAINTY_BORDER_COLOR,
1615
+ width: 1
1616
+ }) })
1617
+ }));
1618
+ this.map.addLayer(new VectorLayer({
1619
+ source: this.source,
1620
+ style: new Style({
1621
+ image: new Circle({
1622
+ radius: MapConstants.MARKER_RADIUS,
1623
+ fill: new Fill({ color: MapConstants.LOCATION_MARKER_BACKGROUND_COLOR }),
1624
+ stroke: new Stroke({
1625
+ color: MapConstants.LOCATION_MARKER_BORDER_COLOR,
1626
+ width: 1
1627
+ })
1628
+ }),
1629
+ stroke: new Stroke({
1630
+ color: MapConstants.LOCATION_POLYGON_BORDER_COLOR,
1631
+ width: 2
1632
+ }),
1633
+ fill: new Fill({ color: "transparent" })
1634
+ })
1635
+ }));
1636
+ this.resizeObserver = new ResizeObserver(() => {
1637
+ this.map.updateSize();
1638
+ this.fitPendingExtent();
1639
+ });
1640
+ this.resizeObserver.observe(this.map.getTargetElement());
1641
+ this.renderMap();
1642
+ }
1643
+ ngOnChanges() {
1644
+ this.renderMap();
1645
+ }
1646
+ renderMap() {
1647
+ if (!this.map) return;
1648
+ this.source.clear();
1649
+ this.uncertaintySource.clear();
1650
+ this.pendingExtent = null;
1651
+ const geo = this.geoJson();
1652
+ if (!geo) return;
1653
+ const features = this.format.readFeatures(geo, { featureProjection: this.map.getView().getProjection() });
1654
+ this.source.addFeatures(features);
1655
+ for (const feature of features) {
1656
+ const geometry = feature.getGeometry();
1657
+ const properties = feature.getProperties();
1658
+ const radius = properties["location"]?.coordinateUncertaintyInMeters ?? properties["locations"]?.items?.[0]?.coordinateUncertaintyInMeters;
1659
+ if (geometry?.getType() === "Point" && radius > 0) {
1660
+ const center = geometry.getExtent().slice(0, 2);
1661
+ this.uncertaintySource.addFeature(new Feature(AdbMapUtils.createUncertaintyCircle(center, radius)));
1662
+ }
1663
+ }
1664
+ const extent = extend(this.source.getExtent(), this.uncertaintySource.getExtent());
1665
+ if (!isEmpty(extent)) {
1666
+ this.pendingExtent = extent;
1667
+ this.fitPendingExtent();
1668
+ }
1669
+ }
1670
+ fitPendingExtent() {
1671
+ const size = this.map.getSize();
1672
+ if (!this.pendingExtent || !size?.[0] || !size[1]) return;
1673
+ this.map.getView().fit(this.pendingExtent, {
1674
+ padding: [
1675
+ 20,
1676
+ 20,
1677
+ 20,
1678
+ 20
1679
+ ],
1680
+ maxZoom: 18
1681
+ });
1682
+ this.pendingExtent = null;
1683
+ }
1684
+ ngOnDestroy() {
1685
+ this.resizeObserver?.disconnect();
1686
+ this.map?.dispose();
1687
+ }
1688
+ static ɵfac = i0.ɵɵngDeclareFactory({
1689
+ minVersion: "12.0.0",
1690
+ version: "22.2.4",
1691
+ ngImport: i0,
1692
+ type: AdbLocationMapComponent,
1693
+ deps: [],
1694
+ target: i0.ɵɵFactoryTarget.Component
1695
+ });
1696
+ static ɵcmp = i0.ɵɵngDeclareComponent({
1697
+ minVersion: "17.1.0",
1698
+ version: "22.2.4",
1699
+ type: AdbLocationMapComponent,
1700
+ isStandalone: false,
1701
+ selector: "adb-location-map",
1702
+ inputs: { geoJson: {
1703
+ classPropertyName: "geoJson",
1704
+ publicName: "geoJson",
1705
+ isSignal: true,
1706
+ isRequired: true,
1707
+ transformFunction: null
1708
+ } },
1709
+ usesOnChanges: true,
1710
+ ngImport: i0,
1711
+ template: "<div [id]=\"mapId\" tabindex=\"0\" class=\"border adb-map\"></div>\n",
1712
+ changeDetection: i0.ChangeDetectionStrategy.Eager
1713
+ });
1714
+ };
1715
+ i0.ɵɵngDeclareClassMetadata({
1716
+ minVersion: "12.0.0",
1717
+ version: "22.2.4",
1718
+ ngImport: i0,
1719
+ type: AdbLocationMapComponent,
1720
+ decorators: [{
1721
+ type: Component,
1722
+ args: [{
1723
+ selector: "adb-location-map",
1724
+ changeDetection: ChangeDetectionStrategy.Eager,
1725
+ standalone: false,
1726
+ template: "<div [id]=\"mapId\" tabindex=\"0\" class=\"border adb-map\"></div>\n"
1727
+ }]
1728
+ }],
1729
+ propDecorators: { geoJson: [{
1730
+ type: i0.Input,
1731
+ args: [{
1732
+ isSignal: true,
1733
+ alias: "geoJson",
1734
+ required: true
1735
+ }]
1736
+ }] }
1737
+ });
1738
+ var AdbMapFilters = class AdbMapFilters {
1739
+ cdr;
1740
+ config;
1741
+ http;
1742
+ router;
1743
+ activatedRoute;
1744
+ inline = false;
1745
+ hiddenFilters = input([], ...ngDevMode ? [{ debugName: "hiddenFilters" }] : /* istanbul ignore next */ []);
1746
+ visibleFilters = computed(() => ({
1747
+ taxon: !this.hiddenFilters().includes("taxon"),
1748
+ time: !this.hiddenFilters().includes("time"),
1749
+ area: !this.hiddenFilters().includes("area"),
1750
+ ownArea: !this.hiddenFilters().includes("ownArea"),
1751
+ taxaLists: !this.hiddenFilters().includes("taxonLists"),
1752
+ datasources: !this.hiddenFilters().includes("datasources")
1753
+ }), ...ngDevMode ? [{ debugName: "visibleFilters" }] : /* istanbul ignore next */ []);
1754
+ static datasets = [
1755
+ "1",
1756
+ "3",
1757
+ "5",
1758
+ "6",
1759
+ "4",
1760
+ "8"
1761
+ ];
1762
+ subscriptions = new Subscription();
1763
+ form;
1764
+ thisYear = /* @__PURE__ */ new Date();
1765
+ lastYear = addYears(/* @__PURE__ */ new Date(), -1);
1766
+ queryParamsMap;
1767
+ hasOwnArea;
1768
+ geo;
1769
+ area;
1770
+ areasArray;
1771
+ dataSetCount;
1772
+ taxonListCount;
1773
+ riskListCount;
1774
+ redListCount;
1775
+ areaCount;
1776
+ periodCount;
1777
+ listsError;
1778
+ taxaLists;
1779
+ hasTaxonInUrlParameter;
1780
+ dsControls;
1781
+ dateStartConfig;
1782
+ dateEndConfig;
1783
+ artfakta;
1784
+ constructor(cdr, config, http, router, activatedRoute) {
1785
+ this.cdr = cdr;
1786
+ this.config = config;
1787
+ this.http = http;
1788
+ this.router = router;
1789
+ this.activatedRoute = activatedRoute;
1790
+ this.artfakta = this.config.artfaktaTaxonLists;
1791
+ }
1792
+ ngOnInit() {
1793
+ const lists$ = this.http.get(this.config.taxaListsApi, { params: { limit: -1 } });
1794
+ const combined$ = combineLatest([
1795
+ this.activatedRoute.paramMap,
1796
+ this.activatedRoute.queryParamMap,
1797
+ lists$
1798
+ ]).pipe(map((results) => ({
1799
+ params: results[0],
1800
+ qParams: results[1],
1801
+ lists: results[2]
1802
+ })), debounceTime(0));
1803
+ this.subscriptions.add(combined$.subscribe((result) => {
1804
+ this.form = this.createForm(result.params, result.qParams, result.lists);
1805
+ this.cdr.markForCheck();
1806
+ }));
1807
+ }
1808
+ removeArea(index) {
1809
+ this.form.get("areas").removeAt(index);
1810
+ this.form.markAsDirty();
1811
+ }
1812
+ addArea() {
1813
+ this.form.get("areas").push(new FormControl(null));
1814
+ this.form.updateValueAndValidity();
1815
+ this.form.markAsDirty();
1816
+ }
1817
+ onSubmit() {
1818
+ const data = this.form.value;
1819
+ let params = {};
1820
+ params.p = data.period ?? null;
1821
+ if (data.period === DateTypes.THIS_YEAR) {
1822
+ params.startAt = startOfYear(this.thisYear).toISOString();
1823
+ params.endAt = null;
1824
+ } else if (data.period === DateTypes.LAST_YEAR) {
1825
+ params.startAt = startOfYear(this.lastYear).toISOString();
1826
+ params.endAt = endOfYear(this.lastYear).toISOString();
1827
+ } else if (data.period === DateTypes.ALL_YEAR) {
1828
+ params.startAt = null;
1829
+ params.endAt = null;
1830
+ params.p = null;
1831
+ } else if (data.period === DateTypes.LAST_5_YEAR) {
1832
+ params.startAt = startOfYear(addYears(/* @__PURE__ */ new Date(), -5)).toISOString();
1833
+ params.endAt = null;
1834
+ } else if (data.period === DateTypes.LAST_25_YEAR) {
1835
+ params.startAt = startOfYear(addYears(/* @__PURE__ */ new Date(), -25)).toISOString();
1836
+ params.endAt = null;
1837
+ } else if (data.period === DateTypes.CUSTOM) {
1838
+ params.startAt = startOfDay(data.startAt).toISOString();
1839
+ params.endAt = endOfDay(data.endAt).toISOString();
1840
+ }
1841
+ if (this.hasOwnArea && data.geo) params.geo = JSON.stringify(data.geo.geometry?.coordinates[0]);
1842
+ const cleaned = data.areas?.filter((v) => v != null && v !== "");
1843
+ if (cleaned.length > 0) params.area = cleaned;
1844
+ if (this.activatedRoute.snapshot.paramMap.has("taxonId")) params.taxonId = this.activatedRoute.snapshot.paramMap.get("taxonId");
1845
+ else params.taxonId = data.taxonId ?? null;
1846
+ if (data.list?.length > 0) params.list = data.list;
1847
+ if (data.ds?.length > 0) {
1848
+ const selected = data.ds.filter((f) => f.selected).map((m) => m.id);
1849
+ params.ds = selected.length ? selected : null;
1850
+ }
1851
+ const locationIds = this.activatedRoute.snapshot.queryParamMap.getAll("locationId");
1852
+ if (locationIds.length) params.locationId = locationIds;
1853
+ this.router.navigate([], {
1854
+ queryParams: params,
1855
+ relativeTo: this.activatedRoute
1856
+ });
1857
+ }
1858
+ createForm(params, qMap, lists) {
1859
+ this.hasTaxonInUrlParameter = params["taxonId"];
1860
+ this.hasOwnArea = qMap.has("geo") && this.visibleFilters().ownArea;
1861
+ const areas = qMap.getAll("area").filter((a) => a != null && a.trim() !== "" && a.includes("-"));
1862
+ const form = new FormGroup({
1863
+ period: new FormControl(qMap.has("p") ? qMap.get("p") : "3"),
1864
+ areas: new FormArray((Array.isArray(areas) && areas.length ? areas : [null]).map((a) => new FormControl(a))),
1865
+ geo: new FormControl(qMap.has("geo") ? {
1866
+ type: "Feature",
1867
+ geometry: {
1868
+ type: "Polygon",
1869
+ coordinates: [JSON.parse(qMap.get("geo"))]
1870
+ }
1871
+ } : null)
1872
+ });
1873
+ this.areasArray = form.get("areas");
1874
+ this.periodCount = qMap.has("p") && qMap.get("p") !== "3" ? 1 : 0;
1875
+ this.areaCount = areas.length + (this.hasOwnArea ? 1 : 0);
1876
+ if (!this.hasTaxonInUrlParameter) {
1877
+ form.addControl("taxonId", new FormControl(qMap.get("taxonId") ?? null));
1878
+ const selectedTaxonList = qMap.has("list") ? qMap.getAll("list").map((val) => Number(val)).filter((val) => !isNaN(val)) : null;
1879
+ this.taxaLists = lists;
1880
+ this.taxonListCount = selectedTaxonList?.length;
1881
+ form.addControl("list", new FormControl(selectedTaxonList));
1882
+ let datasets = qMap.has("ds") ? Array.isArray(qMap.getAll("ds")) ? qMap.getAll("ds") : [qMap.get("ds")] : null;
1883
+ this.dataSetCount = datasets?.length;
1884
+ form.addControl("ds", new FormArray(AdbMapFilters.datasets.map((id) => new FormGroup({
1885
+ id: new FormControl(id),
1886
+ selected: new FormControl(datasets?.includes(id))
1887
+ }))));
1888
+ this.dsControls = form.get("ds").controls;
1889
+ }
1890
+ this.updateCustomDate(form, qMap.get("p"), qMap);
1891
+ this.subscriptions.add(form.get("period").valueChanges.subscribe((period) => {
1892
+ this.updateCustomDate(form, period, qMap);
1893
+ }));
1894
+ return form;
1895
+ }
1896
+ updateCustomDate(form, period, qMap) {
1897
+ if (form.contains("startAt")) form.removeControl("startAt");
1898
+ if (form.contains("endAt")) form.removeControl("endAt");
1899
+ if (period === DateTypes.CUSTOM) {
1900
+ let start = qMap.has("startAt") ? parseISO(qMap.get("startAt")) : null;
1901
+ let end = qMap.has("endAt") ? parseISO(qMap.get("endAt")) : null;
1902
+ if (qMap.get("p") !== DateTypes.CUSTOM) {
1903
+ start = /* @__PURE__ */ new Date();
1904
+ end = /* @__PURE__ */ new Date();
1905
+ }
1906
+ this.dateStartConfig = { maxDate: end ?? /* @__PURE__ */ new Date() };
1907
+ this.dateEndConfig = {
1908
+ minDate: start ?? null,
1909
+ maxDate: /* @__PURE__ */ new Date()
1910
+ };
1911
+ const startControl = new FormControl(start, Validators.required);
1912
+ const endControl = new FormControl(end, Validators.required);
1913
+ form.addControl("startAt", startControl);
1914
+ form.addControl("endAt", endControl);
1915
+ this.subscriptions.add(startControl.valueChanges.subscribe((startAt) => {
1916
+ this.dateEndConfig = {
1917
+ minDate: startAt ?? null,
1918
+ maxDate: /* @__PURE__ */ new Date()
1919
+ };
1920
+ }));
1921
+ this.subscriptions.add(endControl.valueChanges.subscribe((endAt) => {
1922
+ this.dateStartConfig = { maxDate: endAt ?? /* @__PURE__ */ new Date() };
1923
+ }));
1924
+ }
1925
+ }
1926
+ ngOnDestroy() {
1927
+ this.subscriptions.unsubscribe();
1928
+ }
1929
+ static ɵfac = i0.ɵɵngDeclareFactory({
1930
+ minVersion: "12.0.0",
1931
+ version: "22.2.4",
1932
+ ngImport: i0,
1933
+ type: AdbMapFilters,
1934
+ deps: [
1935
+ { token: i0.ChangeDetectorRef },
1936
+ { token: AdbMapConfigService },
1937
+ { token: i2.HttpClient },
1938
+ { token: i1.Router },
1939
+ { token: i1.ActivatedRoute }
1940
+ ],
1941
+ target: i0.ɵɵFactoryTarget.Component
1942
+ });
1943
+ static ɵcmp = i0.ɵɵngDeclareComponent({
1944
+ minVersion: "17.0.0",
1945
+ version: "22.2.4",
1946
+ type: AdbMapFilters,
1947
+ isStandalone: false,
1948
+ selector: "adb-map-filters",
1949
+ inputs: {
1950
+ inline: {
1951
+ classPropertyName: "inline",
1952
+ publicName: "inline",
1953
+ isSignal: false,
1954
+ isRequired: false,
1955
+ transformFunction: null
1956
+ },
1957
+ hiddenFilters: {
1958
+ classPropertyName: "hiddenFilters",
1959
+ publicName: "hiddenFilters",
1960
+ isSignal: true,
1961
+ isRequired: false,
1962
+ transformFunction: null
1963
+ }
1964
+ },
1965
+ ngImport: i0,
1966
+ template: "@if(form){\n<form [formGroup]=\"form\" class=\"form mb-3\" (ngSubmit)=\"onSubmit()\">\n <div class=\"mb-3\">\n @if(visibleFilters().taxon){\n <adb-filter-section titleResource=\"TAXON.TAXA\" [expanded]=\"true\">\n @if(!hasTaxonInUrlParameter){\n <div class=\"mb-3\">\n <label for=\"species\">{{'TAXON.TAXON'|translate}}</label>\n <adb-taxon-picker formControlName=\"taxonId\" id=\"species\"></adb-taxon-picker>\n </div>\n }\n </adb-filter-section>\n }\n @if(visibleFilters().time){\n <adb-filter-section [count]=\"periodCount\" titleResource=\"OBSERVATION.PERIOD\">\n <div class=\"mb-1\">\n <select class=\"form-select\" formControlName=\"period\" id=\"period\">\n <option value=\"1\">{{thisYear|date:'yyyy'}}</option>\n <option value=\"2\">{{lastYear|date:'yyyy'}}</option>\n <option value=\"3\">{{'OBSERVATION.ALL_YEAR'|translate}}</option>\n <option value=\"4\">{{'OBSERVATION.LAST_5_YEAR'|translate}}</option>\n <option value=\"5\">{{'OBSERVATION.LAST_25_YEAR'|translate}}</option>\n <option value=\"6\">{{'OBSERVATION.CUSTOMIZED'|translate}}</option>\n </select>\n </div>\n @if (form.value?.period==='6') {\n <div class=\"mb-2\">\n <label for=\"startAt\">{{'FROM' |translate}}</label>\n <input adbDatepicker type=\"text\" class=\"form-control datepicker\" id=\"startAt\" formControlName=\"startAt\" [settings]=\"dateStartConfig\">\n </div>\n <div class=\"mb-2\">\n <label for=\"endAt\">{{'TO' |translate}}</label>\n <input adbDatepicker type=\"text\" class=\"form-control datepicker\" id=\"endAt\" formControlName=\"endAt\" [settings]=\"dateEndConfig\">\n </div>\n }\n </adb-filter-section>\n }\n @if(visibleFilters().area){\n <adb-filter-section [count]=\"areaCount\" titleResource=\"GEOGRAPHY\" [lazy]=\"true\">\n <ng-template>\n @if(visibleFilters().ownArea){\n <div role=\"tablist\" aria-label=\"{{'AREA'|translate}}\" class=\"d-flex gap-2 justify-content-end\">\n <button class=\"btn btn-link p-0\" [class.text-dark]=\"!hasOwnArea\" (click)=\"hasOwnArea=false\" role=\"tab\" id=\"tab-select\" aria-selected=\"{{!hasOwnArea}}\" aria-controls=\"panel-select\">\n {{'CHOOSE'|translate}}\n </button>\n <button class=\"btn btn-link p-0\" [class.text-dark]=\"hasOwnArea\" (click)=\"hasOwnArea=true\" role=\"tab\" id=\"tab-draw\" aria-selected=\"false\" aria-controls=\"panel-draw\">\n {{'OWN_AREA'|translate}}\n </button>\n </div>\n }\n <div class=\"mb-2\">\n @if(hasOwnArea&&visibleFilters().ownArea){\n <div class=\"pt-1\" role=\"tabpanel\" id=\"area-draw\" aria-labelledby=\"tab-draw\">\n <div>\n <adb-polygon-drawer formControlName=\"geo\"></adb-polygon-drawer>\n </div>\n </div>\n }@else{\n <div role=\"tabpanel\" id=\"area-select\" aria-labelledby=\"tab-select\">\n <div formArrayName=\"areas\">\n <div class=\"d-flex align-items-end mb-1\">\n <label>{{'AREAS'|translate}}</label>\n <button class=\"ms-auto text-dark btn btn-sm btn-secondary\" attr.aria-label=\"{{'OBSERVATION.ADD_AREA'|translate}}\" title=\"{{'OBSERVATION.ADD_AREA'|translate}}\" type=\"button\" (click)=\"addArea()\">\n <span class=\"bi bi-plus\"></span>\n </button>\n </div>\n @for (ctrl of areasArray.controls; track ctrl; let i = $index; let last = $last) {\n <div class=\"d-flex mb-2\">\n <adb-area-picker id=\"area-{{i}}\" [formControlName]=\"i\"></adb-area-picker>\n @if(areasArray.length>1){\n <button class=\"btn btn-secondary ms-1\" attr.aria-label=\"{{'DELETE'|translate}}\" title=\"{{'DELETE'|translate}}\" type=\"button\" (click)=\"removeArea(i)\">\n <span class=\"bi bi-trash\"></span>\n </button>\n }\n </div>\n }\n </div>\n </div>\n }\n </div>\n </ng-template>\n </adb-filter-section>\n }\n @if(form.get('taxonId')){\n @if(visibleFilters().taxaLists){\n <adb-filter-section [count]=\"taxonListCount\" titleResource=\"LISTS.NATURE_CONSERVATION_LISTS\">\n <div class=\"mb-3\">\n <app-treeview formControlName=\"list\" [nodes]=\"taxaLists\"></app-treeview>\n </div>\n {{'LISTS.READ_MORE'|translate}}\n <a [href]=\"artfakta\">{{'LISTS.LIST_CONTENT'|translate}}</a>\n </adb-filter-section>\n }\n @if(visibleFilters().datasources){\n <adb-filter-section [count]=\"dataSetCount\" titleResource=\"DATASET.DATASETS\">\n @if (form.get('ds')) {\n <div formArrayName=\"ds\">\n @for (item of dsControls; track item; let i = $index) {\n <div [formGroupName]=\"i\" class=\"form-check\">\n <input type=\"checkbox\" formControlName=\"selected\" [id]=\"'ds-' + item.value.id\" class=\"form-check-input\">\n <label [for]=\"'ds-' + item.value.id\" class=\"form-check-label\">{{ 'PROVIDERS.'+item.value.id |translate }}</label>\n </div>\n }\n </div>\n }\n </adb-filter-section>\n }\n }\n </div>\n <div class=\"d-flex justify-content-end gap-2\">\n @if (inline) {\n <a class=\"btn btn-secondary\" [routerLink]=\"[]\">\n {{'CANCEL'|translate}}\n </a>\n }\n <a [routerLink]=\"[]\" class=\"btn btn-secondary\" [queryParams]=\"null\">\n {{'CLEAR'|translate}}\n </a>\n <button type=\"submit\" class=\"btn btn-primary\" [disabled]=\"form.invalid||form.pristine\">{{'FILTER'|translate}}</button>\n </div>\n</form>\n}\n",
1967
+ dependencies: [
1968
+ {
1969
+ kind: "directive",
1970
+ type: i3.ɵNgNoValidate,
1971
+ selector: "form:not([ngNoForm]):not([ngNativeValidate])"
1972
+ },
1973
+ {
1974
+ kind: "directive",
1975
+ type: i3.NgSelectOption,
1976
+ selector: "option",
1977
+ inputs: ["ngValue", "value"]
1978
+ },
1979
+ {
1980
+ kind: "directive",
1981
+ type: i3.ɵNgSelectMultipleOption,
1982
+ selector: "option",
1983
+ inputs: ["ngValue", "value"]
1984
+ },
1985
+ {
1986
+ kind: "directive",
1987
+ type: i3.DefaultValueAccessor,
1988
+ selector: "input:not([type=checkbox]):not([ngNoCva])[formControlName],textarea:not([ngNoCva])[formControlName],input:not([type=checkbox]):not([ngNoCva])[formControl],textarea:not([ngNoCva])[formControl],input:not([type=checkbox]):not([ngNoCva])[ngModel],textarea:not([ngNoCva])[ngModel],[ngDefaultControl]"
1989
+ },
1990
+ {
1991
+ kind: "directive",
1992
+ type: i3.CheckboxControlValueAccessor,
1993
+ selector: "input[type=checkbox]:not([ngNoCva])[formControlName],input[type=checkbox]:not([ngNoCva])[formControl],input[type=checkbox]:not([ngNoCva])[ngModel]"
1994
+ },
1995
+ {
1996
+ kind: "directive",
1997
+ type: i3.SelectControlValueAccessor,
1998
+ selector: "select:not([multiple]):not([ngNoCva])[formControlName],select:not([multiple]):not([ngNoCva])[formControl],select:not([multiple]):not([ngNoCva])[ngModel]",
1999
+ inputs: ["compareWith"]
2000
+ },
2001
+ {
2002
+ kind: "directive",
2003
+ type: i3.NgControlStatus,
2004
+ selector: "[formControlName],[ngModel],[formControl]"
2005
+ },
2006
+ {
2007
+ kind: "directive",
2008
+ type: i3.NgControlStatusGroup,
2009
+ selector: "[formGroupName],[formArrayName],[ngModelGroup],[formGroup],[formArray],form:not([ngNoForm]),[ngForm]"
2010
+ },
2011
+ {
2012
+ kind: "directive",
2013
+ type: i1.RouterLink,
2014
+ selector: "[routerLink]",
2015
+ inputs: [
2016
+ "target",
2017
+ "queryParams",
2018
+ "fragment",
2019
+ "queryParamsHandling",
2020
+ "state",
2021
+ "info",
2022
+ "relativeTo",
2023
+ "preserveFragment",
2024
+ "skipLocationChange",
2025
+ "replaceUrl",
2026
+ "browserUrl",
2027
+ "routerLink"
2028
+ ]
2029
+ },
2030
+ {
2031
+ kind: "directive",
2032
+ type: i3.FormGroupDirective,
2033
+ selector: "[formGroup]",
2034
+ inputs: ["formGroup"],
2035
+ outputs: ["ngSubmit"],
2036
+ exportAs: ["ngForm"]
2037
+ },
2038
+ {
2039
+ kind: "directive",
2040
+ type: i3.FormControlName,
2041
+ selector: "[formControlName]",
2042
+ inputs: [
2043
+ "formControlName",
2044
+ "disabled",
2045
+ "ngModel"
2046
+ ],
2047
+ outputs: ["ngModelChange"]
2048
+ },
2049
+ {
2050
+ kind: "directive",
2051
+ type: i3.FormGroupName,
2052
+ selector: "[formGroupName]",
2053
+ inputs: ["formGroupName"]
2054
+ },
2055
+ {
2056
+ kind: "directive",
2057
+ type: i3.FormArrayName,
2058
+ selector: "[formArrayName]",
2059
+ inputs: ["formArrayName"]
2060
+ },
2061
+ {
2062
+ kind: "directive",
2063
+ type: i1$1.AdbDatePickerDirective,
2064
+ selector: "input[adbDatepicker]",
2065
+ inputs: [
2066
+ "format",
2067
+ "toLeft",
2068
+ "settings"
2069
+ ],
2070
+ outputs: ["adbBlur"]
2071
+ },
2072
+ {
2073
+ kind: "component",
2074
+ type: i1$1.FilterSectionComponent,
2075
+ selector: "adb-filter-section",
2076
+ inputs: [
2077
+ "count",
2078
+ "titleResource",
2079
+ "helpResource",
2080
+ "lazy",
2081
+ "expanded"
2082
+ ],
2083
+ outputs: ["expandedChange"]
2084
+ },
2085
+ {
2086
+ kind: "component",
2087
+ type: i1$1.AdbAreaPickerComponent,
2088
+ selector: "adb-area-picker",
2089
+ inputs: [
2090
+ "placeholder",
2091
+ "useObject",
2092
+ "prefill"
2093
+ ]
2094
+ },
2095
+ {
2096
+ kind: "component",
2097
+ type: i1$1.AdbTaxonPickerComponent,
2098
+ selector: "adb-taxon-picker",
2099
+ inputs: [
2100
+ "placeholder",
2101
+ "useObject",
2102
+ "prefill"
2103
+ ]
2104
+ },
2105
+ {
2106
+ kind: "component",
2107
+ type: PolygonDrawerInput,
2108
+ selector: "adb-polygon-drawer"
2109
+ },
2110
+ {
2111
+ kind: "component",
2112
+ type: TreeviewComponent,
2113
+ selector: "app-treeview",
2114
+ inputs: ["nodes"]
2115
+ },
2116
+ {
2117
+ kind: "pipe",
2118
+ type: i1$2.DatePipe,
2119
+ name: "date"
2120
+ },
2121
+ {
2122
+ kind: "pipe",
2123
+ type: i1$3.TranslatePipe,
2124
+ name: "translate"
2125
+ }
2126
+ ],
2127
+ changeDetection: i0.ChangeDetectionStrategy.Eager
2128
+ });
2129
+ };
2130
+ i0.ɵɵngDeclareClassMetadata({
2131
+ minVersion: "12.0.0",
2132
+ version: "22.2.4",
2133
+ ngImport: i0,
2134
+ type: AdbMapFilters,
2135
+ decorators: [{
2136
+ type: Component,
2137
+ args: [{
2138
+ selector: "adb-map-filters",
2139
+ changeDetection: ChangeDetectionStrategy.Eager,
2140
+ standalone: false,
2141
+ template: "@if(form){\n<form [formGroup]=\"form\" class=\"form mb-3\" (ngSubmit)=\"onSubmit()\">\n <div class=\"mb-3\">\n @if(visibleFilters().taxon){\n <adb-filter-section titleResource=\"TAXON.TAXA\" [expanded]=\"true\">\n @if(!hasTaxonInUrlParameter){\n <div class=\"mb-3\">\n <label for=\"species\">{{'TAXON.TAXON'|translate}}</label>\n <adb-taxon-picker formControlName=\"taxonId\" id=\"species\"></adb-taxon-picker>\n </div>\n }\n </adb-filter-section>\n }\n @if(visibleFilters().time){\n <adb-filter-section [count]=\"periodCount\" titleResource=\"OBSERVATION.PERIOD\">\n <div class=\"mb-1\">\n <select class=\"form-select\" formControlName=\"period\" id=\"period\">\n <option value=\"1\">{{thisYear|date:'yyyy'}}</option>\n <option value=\"2\">{{lastYear|date:'yyyy'}}</option>\n <option value=\"3\">{{'OBSERVATION.ALL_YEAR'|translate}}</option>\n <option value=\"4\">{{'OBSERVATION.LAST_5_YEAR'|translate}}</option>\n <option value=\"5\">{{'OBSERVATION.LAST_25_YEAR'|translate}}</option>\n <option value=\"6\">{{'OBSERVATION.CUSTOMIZED'|translate}}</option>\n </select>\n </div>\n @if (form.value?.period==='6') {\n <div class=\"mb-2\">\n <label for=\"startAt\">{{'FROM' |translate}}</label>\n <input adbDatepicker type=\"text\" class=\"form-control datepicker\" id=\"startAt\" formControlName=\"startAt\" [settings]=\"dateStartConfig\">\n </div>\n <div class=\"mb-2\">\n <label for=\"endAt\">{{'TO' |translate}}</label>\n <input adbDatepicker type=\"text\" class=\"form-control datepicker\" id=\"endAt\" formControlName=\"endAt\" [settings]=\"dateEndConfig\">\n </div>\n }\n </adb-filter-section>\n }\n @if(visibleFilters().area){\n <adb-filter-section [count]=\"areaCount\" titleResource=\"GEOGRAPHY\" [lazy]=\"true\">\n <ng-template>\n @if(visibleFilters().ownArea){\n <div role=\"tablist\" aria-label=\"{{'AREA'|translate}}\" class=\"d-flex gap-2 justify-content-end\">\n <button class=\"btn btn-link p-0\" [class.text-dark]=\"!hasOwnArea\" (click)=\"hasOwnArea=false\" role=\"tab\" id=\"tab-select\" aria-selected=\"{{!hasOwnArea}}\" aria-controls=\"panel-select\">\n {{'CHOOSE'|translate}}\n </button>\n <button class=\"btn btn-link p-0\" [class.text-dark]=\"hasOwnArea\" (click)=\"hasOwnArea=true\" role=\"tab\" id=\"tab-draw\" aria-selected=\"false\" aria-controls=\"panel-draw\">\n {{'OWN_AREA'|translate}}\n </button>\n </div>\n }\n <div class=\"mb-2\">\n @if(hasOwnArea&&visibleFilters().ownArea){\n <div class=\"pt-1\" role=\"tabpanel\" id=\"area-draw\" aria-labelledby=\"tab-draw\">\n <div>\n <adb-polygon-drawer formControlName=\"geo\"></adb-polygon-drawer>\n </div>\n </div>\n }@else{\n <div role=\"tabpanel\" id=\"area-select\" aria-labelledby=\"tab-select\">\n <div formArrayName=\"areas\">\n <div class=\"d-flex align-items-end mb-1\">\n <label>{{'AREAS'|translate}}</label>\n <button class=\"ms-auto text-dark btn btn-sm btn-secondary\" attr.aria-label=\"{{'OBSERVATION.ADD_AREA'|translate}}\" title=\"{{'OBSERVATION.ADD_AREA'|translate}}\" type=\"button\" (click)=\"addArea()\">\n <span class=\"bi bi-plus\"></span>\n </button>\n </div>\n @for (ctrl of areasArray.controls; track ctrl; let i = $index; let last = $last) {\n <div class=\"d-flex mb-2\">\n <adb-area-picker id=\"area-{{i}}\" [formControlName]=\"i\"></adb-area-picker>\n @if(areasArray.length>1){\n <button class=\"btn btn-secondary ms-1\" attr.aria-label=\"{{'DELETE'|translate}}\" title=\"{{'DELETE'|translate}}\" type=\"button\" (click)=\"removeArea(i)\">\n <span class=\"bi bi-trash\"></span>\n </button>\n }\n </div>\n }\n </div>\n </div>\n }\n </div>\n </ng-template>\n </adb-filter-section>\n }\n @if(form.get('taxonId')){\n @if(visibleFilters().taxaLists){\n <adb-filter-section [count]=\"taxonListCount\" titleResource=\"LISTS.NATURE_CONSERVATION_LISTS\">\n <div class=\"mb-3\">\n <app-treeview formControlName=\"list\" [nodes]=\"taxaLists\"></app-treeview>\n </div>\n {{'LISTS.READ_MORE'|translate}}\n <a [href]=\"artfakta\">{{'LISTS.LIST_CONTENT'|translate}}</a>\n </adb-filter-section>\n }\n @if(visibleFilters().datasources){\n <adb-filter-section [count]=\"dataSetCount\" titleResource=\"DATASET.DATASETS\">\n @if (form.get('ds')) {\n <div formArrayName=\"ds\">\n @for (item of dsControls; track item; let i = $index) {\n <div [formGroupName]=\"i\" class=\"form-check\">\n <input type=\"checkbox\" formControlName=\"selected\" [id]=\"'ds-' + item.value.id\" class=\"form-check-input\">\n <label [for]=\"'ds-' + item.value.id\" class=\"form-check-label\">{{ 'PROVIDERS.'+item.value.id |translate }}</label>\n </div>\n }\n </div>\n }\n </adb-filter-section>\n }\n }\n </div>\n <div class=\"d-flex justify-content-end gap-2\">\n @if (inline) {\n <a class=\"btn btn-secondary\" [routerLink]=\"[]\">\n {{'CANCEL'|translate}}\n </a>\n }\n <a [routerLink]=\"[]\" class=\"btn btn-secondary\" [queryParams]=\"null\">\n {{'CLEAR'|translate}}\n </a>\n <button type=\"submit\" class=\"btn btn-primary\" [disabled]=\"form.invalid||form.pristine\">{{'FILTER'|translate}}</button>\n </div>\n</form>\n}\n"
2142
+ }]
2143
+ }],
2144
+ ctorParameters: () => [
2145
+ { type: i0.ChangeDetectorRef },
2146
+ { type: AdbMapConfigService },
2147
+ { type: i2.HttpClient },
2148
+ { type: i1.Router },
2149
+ { type: i1.ActivatedRoute }
2150
+ ],
2151
+ propDecorators: {
2152
+ inline: [{ type: Input }],
2153
+ hiddenFilters: [{
2154
+ type: i0.Input,
2155
+ args: [{
2156
+ isSignal: true,
2157
+ alias: "hiddenFilters",
2158
+ required: false
2159
+ }]
2160
+ }]
2161
+ }
2162
+ });
2163
+ var AdbMapModule = class AdbMapModule {
2164
+ static forRoot(config) {
2165
+ return {
2166
+ ngModule: AdbMapModule,
2167
+ providers: [{
2168
+ provide: ADB_MAP_CONFIG,
2169
+ useValue: config
2170
+ }]
2171
+ };
2172
+ }
2173
+ static ɵfac = i0.ɵɵngDeclareFactory({
2174
+ minVersion: "12.0.0",
2175
+ version: "22.2.4",
2176
+ ngImport: i0,
2177
+ type: AdbMapModule,
2178
+ deps: [],
2179
+ target: i0.ɵɵFactoryTarget.NgModule
2180
+ });
2181
+ static ɵmod = i0.ɵɵngDeclareNgModule({
2182
+ minVersion: "14.0.0",
2183
+ version: "22.2.4",
2184
+ ngImport: i0,
2185
+ type: AdbMapModule,
2186
+ declarations: [
2187
+ AdbLocationMapComponent,
2188
+ MapFeaturePickerComponent,
2189
+ MapLegendComponent,
2190
+ AdbMapComponent,
2191
+ PolygonDrawerInput,
2192
+ AdbMapFilters,
2193
+ TreeviewComponent
2194
+ ],
2195
+ imports: [
2196
+ CommonModule,
2197
+ AdbButtonsModule,
2198
+ AdbDirectivesModule,
2199
+ FormsModule,
2200
+ RouterModule,
2201
+ ReactiveFormsModule,
2202
+ AdbDatePickerModule,
2203
+ AdbPipesModule,
2204
+ AdbFilterSectionModule,
2205
+ AdbPickerModule,
2206
+ TranslatePipe
2207
+ ],
2208
+ exports: [
2209
+ AdbLocationMapComponent,
2210
+ AdbMapComponent,
2211
+ PolygonDrawerInput,
2212
+ AdbMapFilters
2213
+ ]
2214
+ });
2215
+ static ɵinj = i0.ɵɵngDeclareInjector({
2216
+ minVersion: "12.0.0",
2217
+ version: "22.2.4",
2218
+ ngImport: i0,
2219
+ type: AdbMapModule,
2220
+ providers: [AdbMapConfigService],
2221
+ imports: [
2222
+ CommonModule,
2223
+ AdbButtonsModule,
2224
+ AdbDirectivesModule,
2225
+ FormsModule,
2226
+ RouterModule,
2227
+ ReactiveFormsModule,
2228
+ AdbDatePickerModule,
2229
+ AdbPipesModule,
2230
+ AdbFilterSectionModule,
2231
+ AdbPickerModule
2232
+ ]
2233
+ });
2234
+ };
2235
+ i0.ɵɵngDeclareClassMetadata({
2236
+ minVersion: "12.0.0",
2237
+ version: "22.2.4",
2238
+ ngImport: i0,
2239
+ type: AdbMapModule,
2240
+ decorators: [{
2241
+ type: NgModule,
2242
+ args: [{
2243
+ imports: [
2244
+ CommonModule,
2245
+ AdbButtonsModule,
2246
+ AdbDirectivesModule,
2247
+ FormsModule,
2248
+ RouterModule,
2249
+ ReactiveFormsModule,
2250
+ AdbDatePickerModule,
2251
+ AdbPipesModule,
2252
+ AdbFilterSectionModule,
2253
+ AdbPickerModule,
2254
+ TranslatePipe
2255
+ ],
2256
+ declarations: [
2257
+ AdbLocationMapComponent,
2258
+ MapFeaturePickerComponent,
2259
+ MapLegendComponent,
2260
+ AdbMapComponent,
2261
+ PolygonDrawerInput,
2262
+ AdbMapFilters,
2263
+ TreeviewComponent
2264
+ ],
2265
+ exports: [
2266
+ AdbLocationMapComponent,
2267
+ AdbMapComponent,
2268
+ PolygonDrawerInput,
2269
+ AdbMapFilters
2270
+ ],
2271
+ providers: [AdbMapConfigService]
2272
+ }]
2273
+ }]
2274
+ });
2275
+ export { ADB_MAP_CONFIG, ADB_MAP_DATA_SOURCE, AdbBffMapDataSource, AdbLocationMapComponent, AdbMapComponent, AdbMapConfigService, AdbMapFilters, AdbMapModule, AdbMapUtils, PolygonDrawerInput };
635
2276
 
636
- class AdbMapFilters {
637
- cdr;
638
- config;
639
- http;
640
- router;
641
- activatedRoute;
642
- inline = false;
643
- static datasets = ['1', '3', '5', '6', '4', '8'];
644
- subscriptions = new Subscription();
645
- form;
646
- thisYear = new Date();
647
- lastYear = addYears(new Date(), -1);
648
- queryParamsMap;
649
- hasOwnArea;
650
- geo;
651
- area;
652
- areasArray;
653
- dataSetCount;
654
- taxonListCount;
655
- riskListCount;
656
- redListCount;
657
- areaCount;
658
- periodCount;
659
- listsError;
660
- filters;
661
- taxaLists;
662
- hasTaxonInUrlParameter;
663
- dsControls;
664
- dateStartConfig;
665
- dateEndConfig;
666
- artfakta;
667
- constructor(cdr, config, http, router, activatedRoute) {
668
- this.cdr = cdr;
669
- this.config = config;
670
- this.http = http;
671
- this.router = router;
672
- this.activatedRoute = activatedRoute;
673
- this.filters = config.filters;
674
- this.artfakta = this.config.artfaktaTaxonLists;
675
- }
676
- ngOnInit() {
677
- const lists$ = this.http.get(this.config.taxaListsApi, { params: { limit: -1 } });
678
- const combined$ = combineLatest([this.activatedRoute.paramMap, this.activatedRoute.queryParamMap, lists$])
679
- .pipe(map(results => ({ params: results[0], qParams: results[1], lists: results[2] })), debounceTime(0));
680
- this.subscriptions.add(combined$.subscribe(result => {
681
- this.form = this.createForm(result.params, result.qParams, result.lists);
682
- this.cdr.markForCheck();
683
- }));
684
- }
685
- removeArea(index) {
686
- this.form.get('areas').removeAt(index);
687
- this.form.markAsDirty();
688
- }
689
- addArea() {
690
- const areas = this.form.get('areas');
691
- areas.push(new FormControl(null));
692
- this.form.updateValueAndValidity();
693
- this.form.markAsDirty();
694
- }
695
- onSubmit() {
696
- const data = this.form.value;
697
- let params = {};
698
- params.p = data.period ?? null;
699
- if (data.period === DateTypes.THIS_YEAR) {
700
- params.startAt = startOfYear(this.thisYear).toISOString();
701
- params.endAt = null;
702
- }
703
- else if (data.period === DateTypes.LAST_YEAR) {
704
- params.startAt = startOfYear(this.lastYear).toISOString();
705
- params.endAt = endOfYear(this.lastYear).toISOString();
706
- }
707
- else if (data.period === DateTypes.ALL_YEAR) {
708
- params.startAt = null;
709
- params.endAt = null;
710
- params.p = null;
711
- }
712
- else if (data.period === DateTypes.LAST_5_YEAR) {
713
- params.startAt = startOfYear(addYears(new Date(), -5)).toISOString();
714
- params.endAt = null;
715
- }
716
- else if (data.period === DateTypes.LAST_25_YEAR) {
717
- params.startAt = startOfYear(addYears(new Date(), -25)).toISOString();
718
- params.endAt = null;
719
- }
720
- else if (data.period === DateTypes.CUSTOM) {
721
- params.startAt = startOfDay(data.startAt).toISOString();
722
- params.endAt = endOfDay(data.endAt).toISOString();
723
- }
724
- if (this.hasOwnArea && data.geo) {
725
- params.geo = JSON.stringify(data.geo.geometry?.coordinates[0]);
726
- }
727
- const cleaned = data.areas?.filter(v => v != null && v !== '');
728
- if (cleaned.length > 0) {
729
- params.area = cleaned;
730
- }
731
- if (this.activatedRoute.snapshot.paramMap.has('taxonId')) {
732
- params.taxonId = this.activatedRoute.snapshot.paramMap.get('taxonId');
733
- }
734
- else {
735
- params.taxonId = data.taxonId ?? null;
736
- }
737
- if (data.list?.length > 0) {
738
- params.list = data.list;
739
- }
740
- if (data.ds?.length > 0) {
741
- const selected = data.ds.filter(f => f.selected).map(m => m.id);
742
- params.ds = selected.length ? selected : null;
743
- }
744
- this.router.navigate([], { queryParams: params, relativeTo: this.activatedRoute });
745
- }
746
- createForm(params, qMap, lists) {
747
- this.hasTaxonInUrlParameter = params['taxonId'];
748
- this.hasOwnArea = qMap.has('geo') && this.filters.showOwnArea;
749
- const areas = qMap.getAll('area').filter(a => a != null && a.trim() !== '' && a.includes('-'));
750
- const form = new FormGroup({
751
- period: new FormControl(qMap.has('p') ? qMap.get('p') : '3'),
752
- areas: new FormArray((Array.isArray(areas) && areas.length ? areas : [null]).map(a => new FormControl(a))),
753
- geo: new FormControl(qMap.has('geo') ? {
754
- type: 'Feature',
755
- geometry: { type: 'Polygon', coordinates: [JSON.parse(qMap.get('geo'))] }
756
- } : null)
757
- });
758
- this.areasArray = form.get('areas');
759
- this.periodCount = qMap.has('p') && qMap.get('p') !== '3' ? 1 : 0;
760
- this.areaCount = areas?.length;
761
- if (!this.hasTaxonInUrlParameter) {
762
- form.addControl('taxonId', new FormControl(qMap.get('taxonId') ?? null));
763
- const selectedTaxonList = qMap.has('list') ? qMap.getAll('list').map(val => Number(val)).filter(val => !isNaN(val)) : null;
764
- this.taxaLists = lists;
765
- this.taxonListCount = selectedTaxonList?.length;
766
- form.addControl('list', new FormControl(selectedTaxonList));
767
- let datasets = qMap.has('ds') ? (Array.isArray(qMap.getAll('ds')) ? qMap.getAll('ds') : [qMap.get('ds')]) : null;
768
- this.dataSetCount = datasets?.length;
769
- form.addControl('ds', new FormArray(AdbMapFilters.datasets.map(id => new FormGroup({
770
- id: new FormControl(id),
771
- selected: new FormControl(datasets?.includes(id))
772
- }))));
773
- this.dsControls = form.get('ds').controls;
774
- }
775
- this.updateCustomDate(form, qMap.get('p'), qMap);
776
- this.subscriptions.add(form.get('period').valueChanges.subscribe(period => {
777
- this.updateCustomDate(form, period, qMap);
778
- }));
779
- return form;
780
- }
781
- updateCustomDate(form, period, qMap) {
782
- if (form.contains('startAt')) {
783
- form.removeControl('startAt');
784
- }
785
- if (form.contains('endAt')) {
786
- form.removeControl('endAt');
787
- }
788
- if (period === DateTypes.CUSTOM) {
789
- let start = qMap.has('startAt') ? parseISO(qMap.get('startAt')) : null;
790
- let end = qMap.has('endAt') ? parseISO(qMap.get('endAt')) : null;
791
- if (qMap.get('p') !== DateTypes.CUSTOM) {
792
- start = new Date();
793
- end = new Date();
794
- }
795
- this.dateStartConfig = { maxDate: end ?? new Date() };
796
- this.dateEndConfig = { minDate: start ?? null, maxDate: new Date() };
797
- const startControl = new FormControl(start, Validators.required);
798
- const endControl = new FormControl(end, Validators.required);
799
- form.addControl('startAt', startControl);
800
- form.addControl('endAt', endControl);
801
- this.subscriptions.add(startControl.valueChanges.subscribe(startAt => {
802
- this.dateEndConfig = { minDate: startAt ?? null, maxDate: new Date() };
803
- }));
804
- this.subscriptions.add(endControl.valueChanges.subscribe(endAt => {
805
- this.dateStartConfig = { maxDate: endAt ?? new Date() };
806
- }));
807
- }
808
- }
809
- ngOnDestroy() {
810
- this.subscriptions.unsubscribe();
811
- }
812
- static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "21.2.25", ngImport: i0, type: AdbMapFilters, deps: [{ token: i0.ChangeDetectorRef }, { token: AdbMapConfigService }, { token: i3.HttpClient }, { token: i1$2.Router }, { token: i1$2.ActivatedRoute }], target: i0.ɵɵFactoryTarget.Component });
813
- static ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "17.0.0", version: "21.2.25", type: AdbMapFilters, isStandalone: false, selector: "adb-map-filters", inputs: { inline: "inline" }, ngImport: i0, template: "@if(form){\r\n<form [formGroup]=\"form\" class=\"form mb-3\" (ngSubmit)=\"onSubmit()\">\r\n <div class=\"mb-3\">\r\n <adb-filter-section titleResource=\"TAXON.TAXA\" [expanded]=\"true\">\r\n @if(filters.showTaxon&&!hasTaxonInUrlParameter){\r\n <div class=\"mb-3\">\r\n <label for=\"species\">{{'TAXON.TAXON'|translate}}</label>\r\n <adb-taxon-picker formControlName=\"taxonId\" id=\"species\"></adb-taxon-picker>\r\n </div>\r\n }\r\n </adb-filter-section>\r\n @if(filters.showTime){\r\n <adb-filter-section [count]=\"periodCount\" titleResource=\"OBSERVATION.PERIOD\">\r\n <div class=\"mb-1\">\r\n <select class=\"form-select\" formControlName=\"period\" id=\"period\">\r\n <option value=\"1\">{{thisYear|date:'yyyy'}}</option>\r\n <option value=\"2\">{{lastYear|date:'yyyy'}}</option>\r\n <option value=\"3\">{{'OBSERVATION.ALL_YEAR'|translate}}</option>\r\n <option value=\"4\">{{'OBSERVATION.LAST_5_YEAR'|translate}}</option>\r\n <option value=\"5\">{{'OBSERVATION.LAST_25_YEAR'|translate}}</option>\r\n <option value=\"6\">{{'OBSERVATION.CUSTOMIZED'|translate}}</option>\r\n </select>\r\n </div>\r\n @if (form.value?.period==='6') {\r\n <div class=\"mb-2\">\r\n <label for=\"startAt\">{{'FROM' |translate}}</label>\r\n <input adbDatepicker type=\"text\" class=\"form-control datepicker\" id=\"startAt\" formControlName=\"startAt\" [settings]=\"dateStartConfig\">\r\n </div>\r\n <div class=\"mb-2\">\r\n <label for=\"endAt\">{{'TO' |translate}}</label>\r\n <input adbDatepicker type=\"text\" class=\"form-control datepicker\" id=\"endAt\" formControlName=\"endAt\" [settings]=\"dateEndConfig\">\r\n </div>\r\n }\r\n </adb-filter-section>\r\n }\r\n @if(filters.showArea){\r\n <adb-filter-section [count]=\"areaCount\" titleResource=\"GEOGRAPHY\" [lazy]=\"true\">\r\n <ng-template>\r\n @if(filters.showOwnArea){\r\n <div role=\"tablist\" aria-label=\"{{'AREA'|translate}}\" class=\"d-flex gap-2 justify-content-end\">\r\n <button class=\"btn btn-link p-0\" [class.text-dark]=\"!hasOwnArea\" (click)=\"hasOwnArea=false\" role=\"tab\" id=\"tab-select\" aria-selected=\"{{!hasOwnArea}}\" aria-controls=\"panel-select\">\r\n {{'CHOOSE'|translate}}\r\n </button>\r\n <button class=\"btn btn-link p-0\" [class.text-dark]=\"hasOwnArea\" (click)=\"hasOwnArea=true\" role=\"tab\" id=\"tab-draw\" aria-selected=\"false\" aria-controls=\"panel-draw\">\r\n {{'OWN_AREA'|translate}}\r\n </button>\r\n </div>\r\n }\r\n <div class=\"mb-2\">\r\n @if(hasOwnArea&&filters.showOwnArea){\r\n <div class=\"pt-1\" role=\"tabpanel\" id=\"area-draw\" aria-labelledby=\"tab-draw\">\r\n <div>\r\n <adb-polygon-drawer formControlName=\"geo\"></adb-polygon-drawer>\r\n </div>\r\n </div>\r\n }@else{\r\n <div role=\"tabpanel\" id=\"area-select\" aria-labelledby=\"tab-select\">\r\n <div formArrayName=\"areas\">\r\n <div class=\"d-flex align-items-end mb-1\">\r\n <label>{{'AREAS'|translate}}</label>\r\n <button class=\"ms-auto text-dark btn btn-sm btn-secondary\" attr.aria-label=\"{{'OBSERVATION.ADD_AREA'|translate}}\" title=\"{{'OBSERVATION.ADD_AREA'|translate}}\" type=\"button\" (click)=\"addArea()\">\r\n <span class=\"bi bi-plus\"></span>\r\n </button>\r\n </div>\r\n @for (ctrl of areasArray.controls; track ctrl; let i = $index; let last = $last) {\r\n <div class=\"d-flex mb-2\">\r\n <adb-area-picker id=\"area-{{i}}\" [formControlName]=\"i\"></adb-area-picker>\r\n @if(areasArray.length>1){\r\n <button class=\"btn btn-secondary ms-1\" attr.aria-label=\"{{'DELETE'|translate}}\" title=\"{{'DELETE'|translate}}\" type=\"button\" (click)=\"removeArea(i)\">\r\n <span class=\"bi bi-trash\"></span>\r\n </button>\r\n }\r\n </div>\r\n }\r\n </div>\r\n </div>\r\n }\r\n </div>\r\n </ng-template>\r\n </adb-filter-section>\r\n }\r\n @if(form.get('taxonId')){\r\n @if(filters.showTaxaLists){\r\n <adb-filter-section [count]=\"taxonListCount\" titleResource=\"LISTS.NATURE_CONSERVATION_LISTS\">\r\n <div class=\"mb-3\">\r\n <app-treeview formControlName=\"list\" [nodes]=\"taxaLists\"></app-treeview>\r\n </div>\r\n {{'LISTS.READ_MORE'|translate}}\r\n <a [href]=\"artfakta\">{{'LISTS.LIST_CONTENT'|translate}}</a>\r\n </adb-filter-section>\r\n }\r\n @if(filters.showDatasets){\r\n <adb-filter-section [count]=\"dataSetCount\" titleResource=\"DATASET.DATASETS\">\r\n @if (form.get('ds')) {\r\n <div formArrayName=\"ds\">\r\n @for (item of dsControls; track item; let i = $index) {\r\n <div [formGroupName]=\"i\" class=\"form-check\">\r\n <input type=\"checkbox\" formControlName=\"selected\" [id]=\"'ds-' + item.value.id\" class=\"form-check-input\">\r\n <label [for]=\"'ds-' + item.value.id\" class=\"form-check-label\">{{ 'PROVIDERS.'+item.value.id |translate }}</label>\r\n </div>\r\n }\r\n </div>\r\n }\r\n </adb-filter-section>\r\n }\r\n }\r\n </div>\r\n <div class=\"d-flex justify-content-end gap-2\">\r\n @if (inline) {\r\n <a class=\"btn btn-secondary\" [routerLink]=\"[]\">\r\n {{'CANCEL'|translate}}\r\n </a>\r\n }\r\n <button type=\"submit\" class=\"btn btn-primary\" [disabled]=\"form.invalid||form.pristine\">{{'FILTER'|translate}}</button>\r\n </div>\r\n</form>\r\n}", dependencies: [{ kind: "directive", type: i4.ɵNgNoValidate, selector: "form:not([ngNoForm]):not([ngNativeValidate])" }, { kind: "directive", type: i4.NgSelectOption, selector: "option", inputs: ["ngValue", "value"] }, { kind: "directive", type: i4.ɵNgSelectMultipleOption, selector: "option", inputs: ["ngValue", "value"] }, { kind: "directive", type: i4.DefaultValueAccessor, selector: "input:not([type=checkbox])[formControlName],textarea[formControlName],input:not([type=checkbox])[formControl],textarea[formControl],input:not([type=checkbox])[ngModel],textarea[ngModel],[ngDefaultControl]" }, { kind: "directive", type: i4.CheckboxControlValueAccessor, selector: "input[type=checkbox][formControlName],input[type=checkbox][formControl],input[type=checkbox][ngModel]" }, { kind: "directive", type: i4.SelectControlValueAccessor, selector: "select:not([multiple])[formControlName],select:not([multiple])[formControl],select:not([multiple])[ngModel]", inputs: ["compareWith"] }, { kind: "directive", type: i4.NgControlStatus, selector: "[formControlName],[ngModel],[formControl]" }, { kind: "directive", type: i4.NgControlStatusGroup, selector: "[formGroupName],[formArrayName],[ngModelGroup],[formGroup],[formArray],form:not([ngNoForm]),[ngForm]" }, { kind: "directive", type: i1$2.RouterLink, selector: "[routerLink]", inputs: ["target", "queryParams", "fragment", "queryParamsHandling", "state", "info", "relativeTo", "preserveFragment", "skipLocationChange", "replaceUrl", "routerLink"] }, { kind: "directive", type: i4.FormGroupDirective, selector: "[formGroup]", inputs: ["formGroup"], outputs: ["ngSubmit"], exportAs: ["ngForm"] }, { kind: "directive", type: i4.FormControlName, selector: "[formControlName]", inputs: ["formControlName", "disabled", "ngModel"], outputs: ["ngModelChange"] }, { kind: "directive", type: i4.FormGroupName, selector: "[formGroupName]", inputs: ["formGroupName"] }, { kind: "directive", type: i4.FormArrayName, selector: "[formArrayName]", inputs: ["formArrayName"] }, { kind: "directive", type: i5.AdbDatePickerDirective, selector: "input[adbDatepicker]", inputs: ["format", "toLeft", "settings"], outputs: ["adbBlur"] }, { kind: "component", type: i5.FilterSectionComponent, selector: "adb-filter-section", inputs: ["count", "titleResource", "helpResource", "lazy", "expanded"], outputs: ["expandedChange"] }, { kind: "component", type: i5.AdbAreaPickerComponent, selector: "adb-area-picker", inputs: ["placeholder", "useObject", "prefill"] }, { kind: "component", type: i5.AdbTaxonPickerComponent, selector: "adb-taxon-picker", inputs: ["placeholder", "useObject", "prefill"] }, { kind: "component", type: PolygonDrawerInput, selector: "adb-polygon-drawer" }, { kind: "component", type: TreeviewComponent, selector: "app-treeview", inputs: ["nodes"] }, { kind: "pipe", type: i1$1.DatePipe, name: "date" }, { kind: "pipe", type: i1.TranslatePipe, name: "translate" }], changeDetection: i0.ChangeDetectionStrategy.Eager });
814
- }
815
- i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "21.2.25", ngImport: i0, type: AdbMapFilters, decorators: [{
816
- type: Component,
817
- args: [{ selector: 'adb-map-filters', changeDetection: ChangeDetectionStrategy.Eager, standalone: false, template: "@if(form){\r\n<form [formGroup]=\"form\" class=\"form mb-3\" (ngSubmit)=\"onSubmit()\">\r\n <div class=\"mb-3\">\r\n <adb-filter-section titleResource=\"TAXON.TAXA\" [expanded]=\"true\">\r\n @if(filters.showTaxon&&!hasTaxonInUrlParameter){\r\n <div class=\"mb-3\">\r\n <label for=\"species\">{{'TAXON.TAXON'|translate}}</label>\r\n <adb-taxon-picker formControlName=\"taxonId\" id=\"species\"></adb-taxon-picker>\r\n </div>\r\n }\r\n </adb-filter-section>\r\n @if(filters.showTime){\r\n <adb-filter-section [count]=\"periodCount\" titleResource=\"OBSERVATION.PERIOD\">\r\n <div class=\"mb-1\">\r\n <select class=\"form-select\" formControlName=\"period\" id=\"period\">\r\n <option value=\"1\">{{thisYear|date:'yyyy'}}</option>\r\n <option value=\"2\">{{lastYear|date:'yyyy'}}</option>\r\n <option value=\"3\">{{'OBSERVATION.ALL_YEAR'|translate}}</option>\r\n <option value=\"4\">{{'OBSERVATION.LAST_5_YEAR'|translate}}</option>\r\n <option value=\"5\">{{'OBSERVATION.LAST_25_YEAR'|translate}}</option>\r\n <option value=\"6\">{{'OBSERVATION.CUSTOMIZED'|translate}}</option>\r\n </select>\r\n </div>\r\n @if (form.value?.period==='6') {\r\n <div class=\"mb-2\">\r\n <label for=\"startAt\">{{'FROM' |translate}}</label>\r\n <input adbDatepicker type=\"text\" class=\"form-control datepicker\" id=\"startAt\" formControlName=\"startAt\" [settings]=\"dateStartConfig\">\r\n </div>\r\n <div class=\"mb-2\">\r\n <label for=\"endAt\">{{'TO' |translate}}</label>\r\n <input adbDatepicker type=\"text\" class=\"form-control datepicker\" id=\"endAt\" formControlName=\"endAt\" [settings]=\"dateEndConfig\">\r\n </div>\r\n }\r\n </adb-filter-section>\r\n }\r\n @if(filters.showArea){\r\n <adb-filter-section [count]=\"areaCount\" titleResource=\"GEOGRAPHY\" [lazy]=\"true\">\r\n <ng-template>\r\n @if(filters.showOwnArea){\r\n <div role=\"tablist\" aria-label=\"{{'AREA'|translate}}\" class=\"d-flex gap-2 justify-content-end\">\r\n <button class=\"btn btn-link p-0\" [class.text-dark]=\"!hasOwnArea\" (click)=\"hasOwnArea=false\" role=\"tab\" id=\"tab-select\" aria-selected=\"{{!hasOwnArea}}\" aria-controls=\"panel-select\">\r\n {{'CHOOSE'|translate}}\r\n </button>\r\n <button class=\"btn btn-link p-0\" [class.text-dark]=\"hasOwnArea\" (click)=\"hasOwnArea=true\" role=\"tab\" id=\"tab-draw\" aria-selected=\"false\" aria-controls=\"panel-draw\">\r\n {{'OWN_AREA'|translate}}\r\n </button>\r\n </div>\r\n }\r\n <div class=\"mb-2\">\r\n @if(hasOwnArea&&filters.showOwnArea){\r\n <div class=\"pt-1\" role=\"tabpanel\" id=\"area-draw\" aria-labelledby=\"tab-draw\">\r\n <div>\r\n <adb-polygon-drawer formControlName=\"geo\"></adb-polygon-drawer>\r\n </div>\r\n </div>\r\n }@else{\r\n <div role=\"tabpanel\" id=\"area-select\" aria-labelledby=\"tab-select\">\r\n <div formArrayName=\"areas\">\r\n <div class=\"d-flex align-items-end mb-1\">\r\n <label>{{'AREAS'|translate}}</label>\r\n <button class=\"ms-auto text-dark btn btn-sm btn-secondary\" attr.aria-label=\"{{'OBSERVATION.ADD_AREA'|translate}}\" title=\"{{'OBSERVATION.ADD_AREA'|translate}}\" type=\"button\" (click)=\"addArea()\">\r\n <span class=\"bi bi-plus\"></span>\r\n </button>\r\n </div>\r\n @for (ctrl of areasArray.controls; track ctrl; let i = $index; let last = $last) {\r\n <div class=\"d-flex mb-2\">\r\n <adb-area-picker id=\"area-{{i}}\" [formControlName]=\"i\"></adb-area-picker>\r\n @if(areasArray.length>1){\r\n <button class=\"btn btn-secondary ms-1\" attr.aria-label=\"{{'DELETE'|translate}}\" title=\"{{'DELETE'|translate}}\" type=\"button\" (click)=\"removeArea(i)\">\r\n <span class=\"bi bi-trash\"></span>\r\n </button>\r\n }\r\n </div>\r\n }\r\n </div>\r\n </div>\r\n }\r\n </div>\r\n </ng-template>\r\n </adb-filter-section>\r\n }\r\n @if(form.get('taxonId')){\r\n @if(filters.showTaxaLists){\r\n <adb-filter-section [count]=\"taxonListCount\" titleResource=\"LISTS.NATURE_CONSERVATION_LISTS\">\r\n <div class=\"mb-3\">\r\n <app-treeview formControlName=\"list\" [nodes]=\"taxaLists\"></app-treeview>\r\n </div>\r\n {{'LISTS.READ_MORE'|translate}}\r\n <a [href]=\"artfakta\">{{'LISTS.LIST_CONTENT'|translate}}</a>\r\n </adb-filter-section>\r\n }\r\n @if(filters.showDatasets){\r\n <adb-filter-section [count]=\"dataSetCount\" titleResource=\"DATASET.DATASETS\">\r\n @if (form.get('ds')) {\r\n <div formArrayName=\"ds\">\r\n @for (item of dsControls; track item; let i = $index) {\r\n <div [formGroupName]=\"i\" class=\"form-check\">\r\n <input type=\"checkbox\" formControlName=\"selected\" [id]=\"'ds-' + item.value.id\" class=\"form-check-input\">\r\n <label [for]=\"'ds-' + item.value.id\" class=\"form-check-label\">{{ 'PROVIDERS.'+item.value.id |translate }}</label>\r\n </div>\r\n }\r\n </div>\r\n }\r\n </adb-filter-section>\r\n }\r\n }\r\n </div>\r\n <div class=\"d-flex justify-content-end gap-2\">\r\n @if (inline) {\r\n <a class=\"btn btn-secondary\" [routerLink]=\"[]\">\r\n {{'CANCEL'|translate}}\r\n </a>\r\n }\r\n <button type=\"submit\" class=\"btn btn-primary\" [disabled]=\"form.invalid||form.pristine\">{{'FILTER'|translate}}</button>\r\n </div>\r\n</form>\r\n}" }]
818
- }], ctorParameters: () => [{ type: i0.ChangeDetectorRef }, { type: AdbMapConfigService }, { type: i3.HttpClient }, { type: i1$2.Router }, { type: i1$2.ActivatedRoute }], propDecorators: { inline: [{
819
- type: Input
820
- }] } });
821
-
822
- class AdbMapModule {
823
- static forRoot(config) {
824
- return {
825
- ngModule: AdbMapModule,
826
- providers: [
827
- {
828
- provide: ADB_MAP_CONFIG,
829
- useValue: config
830
- }
831
- ]
832
- };
833
- }
834
- static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "21.2.25", ngImport: i0, type: AdbMapModule, deps: [], target: i0.ɵɵFactoryTarget.NgModule });
835
- static ɵmod = i0.ɵɵngDeclareNgModule({ minVersion: "14.0.0", version: "21.2.25", ngImport: i0, type: AdbMapModule, declarations: [AdbObsMapComponent,
836
- PolygonDrawerInput,
837
- AdbMapFilters,
838
- TreeviewComponent], imports: [CommonModule,
839
- FormsModule,
840
- RouterModule,
841
- ReactiveFormsModule,
842
- AdbDatePickerModule,
843
- AdbPipesModule,
844
- AdbFilterSectionModule,
845
- AdbPickerModule,
846
- TranslatePipe], exports: [AdbObsMapComponent,
847
- PolygonDrawerInput,
848
- AdbMapFilters] });
849
- static ɵinj = i0.ɵɵngDeclareInjector({ minVersion: "12.0.0", version: "21.2.25", ngImport: i0, type: AdbMapModule, providers: [
850
- AdbMapConfigService
851
- ], imports: [CommonModule,
852
- FormsModule,
853
- RouterModule,
854
- ReactiveFormsModule,
855
- AdbDatePickerModule,
856
- AdbPipesModule,
857
- AdbFilterSectionModule,
858
- AdbPickerModule] });
859
- }
860
- i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "21.2.25", ngImport: i0, type: AdbMapModule, decorators: [{
861
- type: NgModule,
862
- args: [{
863
- imports: [
864
- CommonModule,
865
- FormsModule,
866
- RouterModule,
867
- ReactiveFormsModule,
868
- AdbDatePickerModule,
869
- AdbPipesModule,
870
- AdbFilterSectionModule,
871
- AdbPickerModule,
872
- TranslatePipe
873
- ],
874
- declarations: [
875
- AdbObsMapComponent,
876
- PolygonDrawerInput,
877
- AdbMapFilters,
878
- TreeviewComponent,
879
- // Stats,
880
- // AdbGeojsonPolygonDirective
881
- ],
882
- exports: [
883
- AdbObsMapComponent,
884
- PolygonDrawerInput,
885
- AdbMapFilters,
886
- // Stats,
887
- // AdbGeojsonPolygonDirective
888
- ],
889
- providers: [
890
- AdbMapConfigService
891
- ]
892
- }]
893
- }] });
894
-
895
- /**
896
- * Generated bundle index. Do not edit.
897
- */
898
-
899
- export { ADB_MAP_CONFIG, AdbMapConfigService, AdbMapFilterType, AdbMapFilters, AdbMapModule, AdbMapUtils, AdbObsMapComponent, PolygonDrawerInput, VisibleFilters };
900
- //# sourceMappingURL=adb-shared-map.mjs.map
2277
+ //# sourceMappingURL=adb-shared-map.mjs.map