@provoly/dashboard 0.18.5 → 0.18.6

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.
Files changed (47) hide show
  1. package/dataset/style/_o-pry-dataset-card.scss +0 -1
  2. package/dataset/style/_o-pry-dataset-detail.scss +4 -0
  3. package/esm2022/admin/components/admin-dataset/shared/admin-form-dataset/admin-form-dataset.component.mjs +3 -3
  4. package/esm2022/dataset/components/dataset-card/dataset-card.component.mjs +3 -3
  5. package/esm2022/dataset/components/dataset.component.mjs +3 -3
  6. package/esm2022/dataset/style/css.component.mjs +2 -2
  7. package/esm2022/filters/date/date-filter.component.mjs +8 -4
  8. package/esm2022/filters/list/list-filter.component.mjs +4 -3
  9. package/esm2022/filters/number/number-filter.component.mjs +3 -3
  10. package/esm2022/filters/text/text-filter.component.mjs +3 -3
  11. package/esm2022/lib/core/store/search/search.effects.mjs +2 -2
  12. package/esm2022/lib/dashboard/filter/base-filter.component.mjs +4 -1
  13. package/esm2022/lib/dashboard/item-utils.mjs +1 -60
  14. package/esm2022/lib/dashboard/store/dashboard.effects.mjs +3 -4
  15. package/esm2022/presentation/components/presentation.component.mjs +1 -3
  16. package/esm2022/widgets/widget-map/component/widget-map-layer.service.mjs +39 -38
  17. package/esm2022/widgets/widget-map/component/widget-map.component.mjs +12 -12
  18. package/esm2022/widgets/widget-map/pipe/widget-map-geometry-fields-for.pipe.mjs +3 -3
  19. package/esm2022/widgets/widget-map/utils/widget-map.utils.mjs +262 -216
  20. package/fesm2022/provoly-dashboard-admin.mjs +2 -2
  21. package/fesm2022/provoly-dashboard-admin.mjs.map +1 -1
  22. package/fesm2022/provoly-dashboard-dataset.mjs +6 -6
  23. package/fesm2022/provoly-dashboard-dataset.mjs.map +1 -1
  24. package/fesm2022/provoly-dashboard-filters-date.mjs +7 -3
  25. package/fesm2022/provoly-dashboard-filters-date.mjs.map +1 -1
  26. package/fesm2022/provoly-dashboard-filters-list.mjs +3 -2
  27. package/fesm2022/provoly-dashboard-filters-list.mjs.map +1 -1
  28. package/fesm2022/provoly-dashboard-filters-number.mjs +2 -2
  29. package/fesm2022/provoly-dashboard-filters-number.mjs.map +1 -1
  30. package/fesm2022/provoly-dashboard-filters-text.mjs +2 -2
  31. package/fesm2022/provoly-dashboard-filters-text.mjs.map +1 -1
  32. package/fesm2022/provoly-dashboard-presentation.mjs +0 -2
  33. package/fesm2022/provoly-dashboard-presentation.mjs.map +1 -1
  34. package/fesm2022/provoly-dashboard-widgets-widget-map.mjs +377 -331
  35. package/fesm2022/provoly-dashboard-widgets-widget-map.mjs.map +1 -1
  36. package/fesm2022/provoly-dashboard.mjs +34 -90
  37. package/fesm2022/provoly-dashboard.mjs.map +1 -1
  38. package/filters/date/date-filter.component.d.ts +1 -0
  39. package/lib/dashboard/filter/base-filter.component.d.ts +4 -2
  40. package/lib/dashboard/item-utils.d.ts +0 -8
  41. package/lib/dashboard/store/dashboard.effects.d.ts +0 -3
  42. package/package.json +7 -7
  43. package/styles/components/_a-table.scss +1 -1
  44. package/styles/components/_m-filter.scss +23 -23
  45. package/styles/components/_m-form-label-field.scss +6 -0
  46. package/styles-theme/components-theme/_m-filter.theme.scss +19 -4
  47. package/widgets/widget-map/utils/widget-map.utils.d.ts +23 -17
@@ -6,7 +6,7 @@ import { Injectable, Component, ViewEncapsulation, Pipe, ViewContainerRef, Templ
6
6
  import * as i5 from '@angular/forms';
7
7
  import { FormsModule } from '@angular/forms';
8
8
  import * as i2 from '@provoly/dashboard';
9
- import { widgetMapConfig, DashboardActions, ContextMenuActions, TooltipMode, ItemUtils, FieldType, DEFAULT_PROJECTION, ClassSelectors, FieldSelectors, DataWidgetComponent, WIDGET_HEADER_HEIGHT, NamedQueryTypes, DashboardSelectors, ConfigSelectors, DatasourceUtils, GeoMetadata, GeometricFieldTypes, Operation, DataSourceSelectors, ResultsetUtils, PRY_GEOAUTH_TOKEN, BaseWidgetModule, PryCoreModule, PryDashboardModule, PrySelectModule, PryIconModule, PryToggleModule, PryOverlayModule, PryI18nModule, PryRangeModule } from '@provoly/dashboard';
9
+ import { widgetMapConfig, DashboardActions, ContextMenuActions, TooltipMode, DEFAULT_PROJECTION, ItemUtils, FieldType, ClassSelectors, FieldSelectors, DataWidgetComponent, WIDGET_HEADER_HEIGHT, NamedQueryTypes, DashboardSelectors, ConfigSelectors, DatasourceUtils, GeoMetadata, GeometricFieldTypes, Operation, DataSourceSelectors, ResultsetUtils, PRY_GEOAUTH_TOKEN, BaseWidgetModule, PryCoreModule, PryDashboardModule, PrySelectModule, PryIconModule, PryToggleModule, PryOverlayModule, PryI18nModule, PryRangeModule } from '@provoly/dashboard';
10
10
  import * as i6 from '@provoly/dashboard/components/checkbox';
11
11
  import { PryCheckboxModule } from '@provoly/dashboard/components/checkbox';
12
12
  import equal from 'fast-deep-equal/es6';
@@ -27,11 +27,11 @@ import VectorTileLayer from 'ol/layer/VectorTile';
27
27
  import RenderBox from 'ol/render/Box';
28
28
  import VectorSource from 'ol/source/Vector';
29
29
  import { Style, Fill, Stroke, Circle, Text } from 'ol/style';
30
+ import MapboxVectorLayer from 'ol/layer/MapboxVector';
30
31
  import { GeoJSON, MVT } from 'ol/format';
31
32
  import VectorTile from 'ol/source/VectorTile';
32
33
  import CircleStyle from 'ol/style/Circle';
33
34
  import WMTSTileGrid from 'ol/tilegrid/WMTS';
34
- import MapboxVectorLayer from 'ol/layer/MapboxVector';
35
35
  import * as i1 from '@ngrx/store';
36
36
 
37
37
  class SelectionInteraction extends PointerInteraction {
@@ -346,6 +346,80 @@ class CqlUtils {
346
346
  }
347
347
  }
348
348
 
349
+ class XMLUtils {
350
+ static find(childs, name) {
351
+ if (!!childs) {
352
+ for (let i = 0; i < childs.length; i++) {
353
+ const node = childs[i];
354
+ if (node.nodeName === name) {
355
+ return node;
356
+ }
357
+ }
358
+ }
359
+ return null;
360
+ }
361
+ static findAll(childs, name) {
362
+ const result = [];
363
+ for (let i = 0; i < childs.length; i++) {
364
+ const node = childs[i];
365
+ if (node.nodeName === name) {
366
+ result.push(node);
367
+ }
368
+ }
369
+ return result;
370
+ }
371
+ static findWith(childs, attribute, value) {
372
+ for (let i = 0; i < childs.length; i++) {
373
+ const node = childs[i];
374
+ const attrNode = XMLUtils.find(node.childNodes, attribute);
375
+ if (attrNode?.textContent === value) {
376
+ return node;
377
+ }
378
+ }
379
+ return null;
380
+ }
381
+ static getMatchingLayer(paramLayer, doc) {
382
+ const WMSCapability = XMLUtils.find(doc.childNodes, 'WMS_Capabilities');
383
+ if (WMSCapability) {
384
+ const Capabilities = XMLUtils.find(WMSCapability.childNodes, 'Capability');
385
+ if (Capabilities) {
386
+ const Layer = XMLUtils.find(Capabilities.childNodes, 'Layer');
387
+ if (Layer) {
388
+ let matchingLayer = XMLUtils.findWith(Layer.childNodes, 'Name', paramLayer);
389
+ const split = paramLayer.split(':');
390
+ if (!matchingLayer && split.length >= 2) {
391
+ // Try again, splitting on ":" in the name to ignore namespace if present
392
+ matchingLayer = XMLUtils.findWith(Layer.childNodes, 'Name', split[split.length - 1]);
393
+ }
394
+ return matchingLayer;
395
+ }
396
+ }
397
+ }
398
+ return null;
399
+ }
400
+ static getLayerExtent(paramLayer, map, doc) {
401
+ if (!doc) {
402
+ return null;
403
+ }
404
+ const matchingLayer = XMLUtils.getMatchingLayer(paramLayer, doc);
405
+ if (matchingLayer) {
406
+ const boundingBox = XMLUtils.find(matchingLayer.childNodes, 'BoundingBox');
407
+ if (boundingBox) {
408
+ // @ts-ignore
409
+ const attributes = boundingBox.attributes;
410
+ const projBox = get(attributes.CRS.textContent ?? DEFAULT_PROJECTION);
411
+ if (projBox) {
412
+ return [
413
+ transform([parseFloat(attributes.minx.textContent), parseFloat(attributes.miny.textContent)], projBox, map.getView().getProjection()),
414
+ transform([parseFloat(attributes.maxx.textContent), parseFloat(attributes.maxy.textContent)], projBox, map.getView().getProjection())
415
+ ];
416
+ }
417
+ }
418
+ }
419
+ return null;
420
+ }
421
+ }
422
+
349
423
  class WidgetMapLayerService {
350
424
  constructor() {
351
425
  this.styleCache = {};
@@ -400,12 +474,12 @@ class WidgetMapLayerService {
400
474
  },
401
475
  heatmap: (layer, attributesForClass, layerClassesId, resultSet, range, itemStyles, map) => {
402
476
  const heatmap = new Heatmap({
403
- minZoom: layer.minZoom ?? DEFAULT_ZOOM_MIN,
404
- maxZoom: layer.maxZoom ?? DEFAULT_ZOOM_MAX,
477
+ minZoom: layer.minZoom ?? WidgetMapUtils.DEFAULT_ZOOM_MIN,
478
+ maxZoom: layer.maxZoom ?? WidgetMapUtils.DEFAULT_ZOOM_MAX,
405
479
  opacity: (layer.opacity ?? 100) / 100,
406
480
  source: new Vector({ attributions: [layer.attribution ?? ''] }),
407
- blur: (layer.radius ?? DEFAULT_HEATMAP_RADIUS) / 2,
408
- radius: layer.radius ?? DEFAULT_HEATMAP_RADIUS,
481
+ blur: (layer.radius ?? WidgetMapUtils.DEFAULT_HEATMAP_RADIUS) / 2,
482
+ radius: layer.radius ?? WidgetMapUtils.DEFAULT_HEATMAP_RADIUS,
409
483
  weight: (feature) => {
410
484
  const value = ItemUtils.getAttributeCalculatedValue(feature, attributesForClass[feature.get('oClass')].intensityAttribute);
411
485
  const atScale = (value - range.min) / (range.max - range.min);
@@ -415,32 +489,32 @@ class WidgetMapLayerService {
415
489
  layerClassesId.forEach((classId) => {
416
490
  (resultSet.items[classId] || [])
417
491
  .filter((item) => {
418
- const location = ItemUtils.readGeometry(item, 'point', attributesForClass[classId].locationAttribute);
492
+ const location = WidgetMapUtils.readGeometry(map.getView().getProjection(), item, 'point', attributesForClass[classId].locationAttribute);
419
493
  return !!location;
420
494
  })
421
495
  .forEach((item) => {
422
496
  heatmap
423
497
  .getSource()
424
- ?.addFeature(getFeatureFromItem(item, 'heatpoint', attributesForClass[item.oClass].locationAttribute));
498
+ ?.addFeature(WidgetMapUtils.getFeatureFromItem(map.getView().getProjection(), item, 'heatpoint', attributesForClass[item.oClass].locationAttribute));
425
499
  });
426
500
  });
427
501
  return heatmap;
428
502
  },
429
503
  marker: (layer, attributesForClass, layerClassesId, resultSet, range, itemStyles, map) => {
430
504
  const vectorLayer = new VectorLayer({
431
- minZoom: layer.minZoom ?? DEFAULT_ZOOM_MIN,
432
- maxZoom: layer.maxZoom ?? DEFAULT_ZOOM_MAX,
505
+ minZoom: layer.minZoom ?? WidgetMapUtils.DEFAULT_ZOOM_MIN,
506
+ maxZoom: layer.maxZoom ?? WidgetMapUtils.DEFAULT_ZOOM_MAX,
433
507
  opacity: (layer.opacity ?? 100) / 100,
434
508
  source: new VectorSource({ attributions: [layer.attribution ?? ''] })
435
509
  });
436
510
  layerClassesId.forEach((classId) => {
437
511
  (resultSet.items[classId] || [])
438
512
  .filter((item) => {
439
- const location = ItemUtils.readGeometry(item, 'point', attributesForClass[item.oClass].locationAttribute);
513
+ const location = WidgetMapUtils.readGeometry(map.getView().getProjection(), item, 'point', attributesForClass[item.oClass].locationAttribute);
440
514
  return !!location;
441
515
  })
442
516
  .forEach(async (item) => {
443
- const itemFeature = getFeatureFromItem(item, 'marker', attributesForClass[item.oClass].locationAttribute, itemStyles[item.id]?.classic, itemStyles[item.id]?.bordered);
517
+ const itemFeature = WidgetMapUtils.getFeatureFromItem(map.getView().getProjection(), item, 'marker', attributesForClass[item.oClass].locationAttribute, itemStyles[item.id]?.classic, itemStyles[item.id]?.bordered);
444
518
  itemFeature.setStyle(itemFeature.get('classicStyle'));
445
519
  vectorLayer.getSource()?.addFeature(itemFeature);
446
520
  });
@@ -448,37 +522,38 @@ class WidgetMapLayerService {
448
522
  return this.makeClustered(vectorLayer, layer);
449
523
  },
450
524
  point: (layer, attributesForClass, layerClassesId, resultSet, range, itemStyles, map) => {
451
- return this.layerFromGeoJsonGeometry(layer, layerClassesId, resultSet, attributesForClass, 'point');
525
+ return this.layerFromGeoJsonGeometry(map.getView().getProjection(), layer, layerClassesId, resultSet, attributesForClass, 'point');
452
526
  },
453
527
  line: (layer, attributesForClass, layerClassesId, resultSet, range, itemStyles, map) => {
454
- return this.layerFromGeoJsonGeometry(layer, layerClassesId, resultSet, attributesForClass, 'line');
528
+ return this.layerFromGeoJsonGeometry(map.getView().getProjection(), layer, layerClassesId, resultSet, attributesForClass, 'line');
455
529
  },
456
530
  'multi-line': (layer, attributesForClass, layerClassesId, resultSet, range, itemStyles, map) => {
457
- return this.layerFromGeoJsonGeometry(layer, layerClassesId, resultSet, attributesForClass, 'multi-line');
531
+ return this.layerFromGeoJsonGeometry(map.getView().getProjection(), layer, layerClassesId, resultSet, attributesForClass, 'multi-line');
458
532
  },
459
533
  polygon: (layer, attributesForClass, layerClassesId, resultSet, range, itemStyles, map) => {
460
- return this.layerFromGeoJsonGeometry(layer, layerClassesId, resultSet, attributesForClass, 'polygon');
534
+ return this.layerFromGeoJsonGeometry(map.getView().getProjection(), layer, layerClassesId, resultSet, attributesForClass, 'polygon');
461
535
  },
462
536
  'multi-polygon': (layer, attributesForClass, layerClassesId, resultSet, range, itemStyles, map) => {
463
- return this.layerFromGeoJsonGeometry(layer, layerClassesId, resultSet, attributesForClass, 'multi-polygon');
537
+ return this.layerFromGeoJsonGeometry(map.getView().getProjection(), layer, layerClassesId, resultSet, attributesForClass, 'multi-polygon');
464
538
  },
465
539
  bubble: (layer, attributesForClass, layerClassesId, resultSet, range, itemStyles, map) => {
466
540
  const bubbleLayer = new VectorLayer({
467
- minZoom: layer.minZoom ?? DEFAULT_ZOOM_MIN,
468
- maxZoom: layer.maxZoom ?? DEFAULT_ZOOM_MAX,
541
+ minZoom: layer.minZoom ?? WidgetMapUtils.DEFAULT_ZOOM_MIN,
542
+ maxZoom: layer.maxZoom ?? WidgetMapUtils.DEFAULT_ZOOM_MAX,
469
543
  opacity: (layer.opacity ?? 100) / 100,
470
544
  source: new VectorSource({ attributions: [layer.attribution ?? ''] })
471
545
  });
472
546
  layerClassesId.forEach((classId) => {
473
547
  (resultSet.items[classId] || [])
474
548
  .filter((item) => {
475
- const location = ItemUtils.readGeometry(item, 'point', attributesForClass[item.oClass].locationAttribute);
549
+ const location = WidgetMapUtils.readGeometry(map.getView().getProjection(), item, 'point', attributesForClass[item.oClass].locationAttribute);
476
550
  return !!location;
477
551
  })
478
552
  .forEach((item) => {
479
553
  const value = ItemUtils.getAttributeCalculatedValue(item, attributesForClass[item.oClass].intensityAttribute);
480
554
  const atScale = (value - range.min) / (range.max - range.min);
481
- const itemFeature = getCircleFeatureFromItem(item, attributesForClass[item.oClass].locationAttribute, (layer.intensityAsc ? atScale : 1 - atScale) * (layer.radiusFactor ?? DEFAULT_RADIUS_INTENSITY_FACTOR), this.circleStyle, this.selectedCircleStyle);
555
+ const itemFeature = WidgetMapUtils.getCircleFeatureFromItem(map.getView().getProjection(), item, attributesForClass[item.oClass].locationAttribute, (layer.intensityAsc ? atScale : 1 - atScale) *
556
+ (layer.radiusFactor ?? WidgetMapUtils.DEFAULT_RADIUS_INTENSITY_FACTOR), this.circleStyle, this.selectedCircleStyle);
482
557
  itemFeature.setStyle(itemFeature.get('classicStyle'));
483
558
  bubbleLayer.getSource()?.addFeature(itemFeature);
484
559
  });
@@ -487,16 +562,16 @@ class WidgetMapLayerService {
487
562
  },
488
563
  relation: (layer, attributesForClass, layerClassesId, resultSet, range, itemStyles, map) => {
489
564
  return new VectorLayer({
490
- minZoom: layer.minZoom ?? DEFAULT_ZOOM_MIN,
491
- maxZoom: layer.maxZoom ?? DEFAULT_ZOOM_MAX,
565
+ minZoom: layer.minZoom ?? WidgetMapUtils.DEFAULT_ZOOM_MIN,
566
+ maxZoom: layer.maxZoom ?? WidgetMapUtils.DEFAULT_ZOOM_MAX,
492
567
  opacity: (layer.opacity ?? 100) / 100,
493
568
  source: new VectorSource({ attributions: [layer.attribution ?? ''] })
494
569
  });
495
570
  },
496
571
  wms: (layer, attributesForClass, layerClassesId, resultSet, range, itemStyles, map) => {
497
572
  const impl = new Tile({
498
- minZoom: layer.minZoom ?? DEFAULT_ZOOM_MIN,
499
- maxZoom: layer.maxZoom ?? DEFAULT_ZOOM_MAX,
573
+ minZoom: layer.minZoom ?? WidgetMapUtils.DEFAULT_ZOOM_MIN,
574
+ maxZoom: layer.maxZoom ?? WidgetMapUtils.DEFAULT_ZOOM_MAX,
500
575
  opacity: (layer.opacity ?? 100) / 100,
501
576
  source: new TileWMS({
502
577
  attributions: [layer.attribution ?? ''],
@@ -524,8 +599,8 @@ class WidgetMapLayerService {
524
599
  matrixIds[z] = z;
525
600
  }
526
601
  return new Tile({
527
- minZoom: layer.minZoom ?? DEFAULT_ZOOM_MIN,
528
- maxZoom: layer.maxZoom ?? DEFAULT_ZOOM_MAX,
602
+ minZoom: layer.minZoom ?? WidgetMapUtils.DEFAULT_ZOOM_MIN,
603
+ maxZoom: layer.maxZoom ?? WidgetMapUtils.DEFAULT_ZOOM_MAX,
529
604
  opacity: (layer.opacity ?? 100) / 100,
530
605
  source: new WMTS({
531
606
  attributions: [layer.attribution ?? ''],
@@ -552,8 +627,8 @@ class WidgetMapLayerService {
552
627
  },
553
628
  featurelayer: (layer, attributesForClass, layerClassesId, resultSet, range, itemStyles, map) => {
554
629
  return new VectorLayer({
555
- minZoom: layer.minZoom ?? DEFAULT_ZOOM_MIN,
556
- maxZoom: layer.maxZoom ?? DEFAULT_ZOOM_MAX,
630
+ minZoom: layer.minZoom ?? WidgetMapUtils.DEFAULT_ZOOM_MIN,
631
+ maxZoom: layer.maxZoom ?? WidgetMapUtils.DEFAULT_ZOOM_MAX,
557
632
  opacity: (layer.opacity ?? 100) / 100,
558
633
  source: new VectorSource({
559
634
  attributions: [layer.attribution ?? ''],
@@ -564,8 +639,8 @@ class WidgetMapLayerService {
564
639
  },
565
640
  vectortile: (layer, attributesForClass, layerClassesId, resultSet, range, itemStyles, map) => {
566
641
  return new VectorTileLayer({
567
- minZoom: layer.minZoom ?? DEFAULT_ZOOM_MIN,
568
- maxZoom: layer.maxZoom ?? DEFAULT_ZOOM_MAX,
642
+ minZoom: layer.minZoom ?? WidgetMapUtils.DEFAULT_ZOOM_MIN,
643
+ maxZoom: layer.maxZoom ?? WidgetMapUtils.DEFAULT_ZOOM_MAX,
569
644
  opacity: (layer.opacity ?? 100) / 100,
570
645
  source: new VectorTile({
571
646
  attributions: [layer.attribution ?? ''],
@@ -576,8 +651,8 @@ class WidgetMapLayerService {
576
651
  },
577
652
  rastertile: (layer, attributesForClass, layerClassesId, resultSet, range, itemStyles, map) => {
578
653
  return new Tile({
579
- minZoom: layer.minZoom ?? DEFAULT_ZOOM_MIN,
580
- maxZoom: layer.maxZoom ?? DEFAULT_ZOOM_MAX,
654
+ minZoom: layer.minZoom ?? WidgetMapUtils.DEFAULT_ZOOM_MIN,
655
+ maxZoom: layer.maxZoom ?? WidgetMapUtils.DEFAULT_ZOOM_MAX,
581
656
  opacity: (layer.opacity ?? 100) / 100,
582
657
  source: new XYZ({
583
658
  url: layer.url,
@@ -593,10 +668,10 @@ class WidgetMapLayerService {
593
668
  get implementationList() {
594
669
  return Object.keys(this.layersImplementation).filter((implementation) => implementation !== 'geoserver');
595
670
  }
596
- layerFromGeoJsonGeometry(layer, layerClassesId, resultSet, attributesForClass, type) {
671
+ layerFromGeoJsonGeometry(projection, layer, layerClassesId, resultSet, attributesForClass, type) {
597
672
  const vectorLayer = new VectorLayer({
598
- minZoom: layer.minZoom ?? DEFAULT_ZOOM_MIN,
599
- maxZoom: layer.maxZoom ?? DEFAULT_ZOOM_MAX,
673
+ minZoom: layer.minZoom ?? WidgetMapUtils.DEFAULT_ZOOM_MIN,
674
+ maxZoom: layer.maxZoom ?? WidgetMapUtils.DEFAULT_ZOOM_MAX,
600
675
  opacity: (layer.opacity ?? 100) / 100,
601
676
  source: new VectorSource({ attributions: [layer.attribution ?? ''] })
602
677
  });
@@ -604,14 +679,14 @@ class WidgetMapLayerService {
604
679
  (resultSet.items[classId] || [])
605
680
  .map((item) => ({
606
681
  item,
607
- location: ItemUtils.readGeometry(item, type, attributesForClass[item.oClass].locationAttribute)
682
+ location: WidgetMapUtils.readGeometry(projection, item, type, attributesForClass[item.oClass].locationAttribute)
608
683
  }))
609
684
  .filter(({ location }) => !!location)
610
685
  .forEach(async (subItem) => {
611
686
  const itemFeature = new Feature({
612
687
  ...subItem.item,
613
688
  type,
614
- geometry: subItem.location,
689
+ geometry: subItem.location ?? undefined,
615
690
  classicStyle: type === 'point' ? this.pointStyle : this.circleStyle,
616
691
  selectedStyle: type === 'point' ? this.selectedPointStyle : this.selectedCircleStyle
617
692
  });
@@ -686,310 +761,281 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "16.1.6", ngImpor
686
761
  }]
687
762
  }] });
688
763
 
689
- const populateLocationAttribute = (layer, resultSet, classesNotFiltered, fields) => {
690
- if (['heatmap', 'marker', 'bubble', 'point', 'line', 'polygon', 'multi-line', 'multi-polygon', 'auto'].includes(layer.type) &&
691
- !!resultSet &&
692
- !!classesNotFiltered &&
693
- classesNotFiltered.length > 0) {
694
- const specificLayer = layer;
695
- const classes = classesNotFiltered.filter((cl) => specificLayer.classes?.includes(cl.id) || !specificLayer.classes || specificLayer.classes.length === 0);
696
- if (!specificLayer.attribute) {
697
- // No location attribute available, then try to guess one that will be ok
698
- const geometry = geometryForLayer(layer);
699
- let candidates = [];
700
- if (Object.keys(resultSet.items).length > 0) {
701
- // Based on items that we have to display
702
- candidates = Object.keys(resultSet.items)
703
- .map((key) => ({ items: resultSet.items[key], oClass: classes.find((cl) => cl.id === key) }))
704
- .map(({ items, oClass }) => (oClass ?? { attributes: [] }).attributes
705
- .map((attr) => ({ attr, field: fields.find((f) => f.id === attr.field) }))
706
- .filter((attr) => attr.field?.type === geometry))
707
- .reduce((p, c) => [...p, ...c], []);
708
- }
709
- else {
710
- // We don't have any items to display, so allow all corresponding geometry fields
711
- candidates = classesNotFiltered
712
- .map((clazz) => clazz.attributes)
713
- .flat()
714
- .map((attr) => ({ attr, field: fields.find((field) => field.id === attr.field) }))
715
- .filter(({ attr, field }) => field?.type === geometry);
716
- }
717
- if (candidates.length > 0) {
718
- specificLayer.attribute = candidates[0].attr.name;
764
+ class WidgetMapUtils {
765
+ static populateLocationAttribute(layer, resultSet, classesNotFiltered, fields) {
766
+ if (['heatmap', 'marker', 'bubble', 'point', 'line', 'polygon', 'multi-line', 'multi-polygon', 'auto'].includes(layer.type) &&
767
+ !!resultSet &&
768
+ !!classesNotFiltered &&
769
+ classesNotFiltered.length > 0) {
770
+ const specificLayer = layer;
771
+ const classes = classesNotFiltered.filter((cl) => specificLayer.classes?.includes(cl.id) || !specificLayer.classes || specificLayer.classes.length === 0);
772
+ if (!specificLayer.attribute) {
773
+ // No location attribute available, then try to guess one that will be ok
774
+ const geometry = WidgetMapUtils.geometryForLayer(layer);
775
+ let candidates = [];
776
+ if (Object.keys(resultSet.items).length > 0) {
777
+ // Based on items that we have to display
778
+ candidates = Object.keys(resultSet.items)
779
+ .map((key) => ({ items: resultSet.items[key], oClass: classes.find((cl) => cl.id === key) }))
780
+ .map(({ items, oClass }) => (oClass ?? { attributes: [] }).attributes
781
+ .map((attr) => ({ attr, field: fields.find((f) => f.id === attr.field) }))
782
+ .filter((attr) => attr.field?.type === geometry))
783
+ .reduce((p, c) => [...p, ...c], []);
784
+ }
785
+ else {
786
+ // We don't have any items to display, so allow all corresponding geometry fields
787
+ candidates = classesNotFiltered
788
+ .map((clazz) => clazz.attributes)
789
+ .flat()
790
+ .map((attr) => ({ attr, field: fields.find((field) => field.id === attr.field) }))
791
+ .filter(({ attr, field }) => field?.type === geometry);
792
+ }
793
+ if (candidates.length > 0) {
794
+ specificLayer.attribute = candidates[0].attr.name;
795
+ }
719
796
  }
720
797
  }
721
798
  }
722
- };
723
- const populateIntensityAttribute = (layer, resultSet, classesNotFiltered, fields) => {
724
- if (['heatmap', 'bubble'].includes(layer.type) &&
725
- !!resultSet &&
726
- !!classesNotFiltered &&
727
- classesNotFiltered.length > 0) {
728
- const specificLayer = layer;
729
- const classes = classesNotFiltered.filter((cl) => (specificLayer.classes?.includes(cl.id) || !specificLayer.classes || specificLayer.classes.length === 0) &&
730
- cl.attributes.find((attr) => attr.name === (specificLayer?.attribute ?? [])));
731
- if (!specificLayer.intensityAttribute) {
732
- // No intensity attribute available, then take the maximum intensity matching attribute
733
- const candidatesDry = Object.keys(resultSet.items)
734
- .map((key) => ({ items: resultSet.items[key], oClass: classes.find((cl) => cl.id === key) }))
735
- .map(({ items, oClass }) => {
736
- return (oClass ?? { attributes: [] }).attributes
737
- .map((attr) => ({ attr, field: fields.find((f) => f.id === attr.field) }))
738
- .filter((attr) => attr.field?.type === FieldType.DECIMAL || attr.field?.type === FieldType.INTEGER)
739
- .map((attr) => {
740
- const attrValues = ItemUtils.pertinentValue(items, attr.attr);
741
- return {
742
- min: Math.min(...attrValues),
743
- max: Math.max(...attrValues),
744
- name: attr.attr.name
745
- };
746
- });
747
- })
748
- .reduce((p, c) => [...p, ...c], [])
749
- .sort((a, b) => b.max - a.max);
750
- if (candidatesDry.length > 0) {
751
- specificLayer.intensityAttribute = candidatesDry[0].name;
752
- specificLayer.intensityAsc = true;
799
+ static populateIntensityAttribute(layer, resultSet, classesNotFiltered, fields) {
800
+ if (['heatmap', 'bubble'].includes(layer.type) &&
801
+ !!resultSet &&
802
+ !!classesNotFiltered &&
803
+ classesNotFiltered.length > 0) {
804
+ const specificLayer = layer;
805
+ const classes = classesNotFiltered.filter((cl) => (specificLayer.classes?.includes(cl.id) || !specificLayer.classes || specificLayer.classes.length === 0) &&
806
+ cl.attributes.find((attr) => attr.name === (specificLayer?.attribute ?? [])));
807
+ if (!specificLayer.intensityAttribute) {
808
+ // No intensity attribute available, then take the maximum intensity matching attribute
809
+ const candidatesDry = Object.keys(resultSet.items)
810
+ .map((key) => ({ items: resultSet.items[key], oClass: classes.find((cl) => cl.id === key) }))
811
+ .map(({ items, oClass }) => {
812
+ return (oClass ?? { attributes: [] }).attributes
813
+ .map((attr) => ({ attr, field: fields.find((f) => f.id === attr.field) }))
814
+ .filter((attr) => attr.field?.type === FieldType.DECIMAL || attr.field?.type === FieldType.INTEGER)
815
+ .map((attr) => {
816
+ const attrValues = ItemUtils.pertinentValue(items, attr.attr);
817
+ return {
818
+ min: Math.min(...attrValues),
819
+ max: Math.max(...attrValues),
820
+ name: attr.attr.name
821
+ };
822
+ });
823
+ })
824
+ .reduce((p, c) => [...p, ...c], [])
825
+ .sort((a, b) => b.max - a.max);
826
+ if (candidatesDry.length > 0) {
827
+ specificLayer.intensityAttribute = candidatesDry[0].name;
828
+ specificLayer.intensityAsc = true;
829
+ }
753
830
  }
754
831
  }
755
832
  }
756
- };
757
- const getFeatureFromItem = (item, type, locationAttribute, iconStyle, selectedIconStyle) => {
758
- return new Feature({
759
- ...item,
760
- type,
761
- geometry: ItemUtils.readGeometry(item, 'point', locationAttribute),
762
- classicStyle: iconStyle ?? null,
763
- selectedStyle: selectedIconStyle ?? null
764
- });
765
- };
766
- const getCircleFeatureFromItem = (item, locationAttribute, radius, iconStyle, selectedIconStyle) => {
767
- return new Feature({
768
- ...item,
769
- geometry: new Circle$1(ItemUtils.readGeometry(item, 'point', locationAttribute).getCoordinates(), radius),
770
- classicStyle: iconStyle,
771
- selectedStyle: selectedIconStyle,
772
- type: 'bubble'
773
- });
774
- };
775
- const getLinkFeature = (relation, featureSource, featureDestination) => {
776
- return new Feature({
777
- ...relation,
778
- geometry: new LineString([
779
- // @ts-ignore
780
- featureSource.getGeometry()?.getCoordinates() ?? featureSource.getGeometry()?.getCenter() ?? [0, 0],
781
- // @ts-ignore
782
- featureDestination.getGeometry()?.getCoordinates() ?? featureDestination.getGeometry()?.getCenter() ?? [0, 0]
783
- ]),
784
- source: featureSource,
785
- destination: featureDestination,
786
- type: 'link'
787
- });
788
- };
789
- const getMapAsPng = (map) => {
790
- return new Promise((resolve, reject) => {
791
- map.once('rendercomplete', function () {
792
- const mapCanvas = document.createElement('canvas');
793
- const size = map.getSize() || [100, 100];
794
- mapCanvas.width = size[0];
795
- mapCanvas.height = size[1];
796
- const mapContext = mapCanvas.getContext('2d') || null;
797
- Array.prototype.forEach.call(document.querySelectorAll('.ol-layer canvas, canvas.ol-layer'), (canvas) => {
798
- if (canvas.width > 0) {
799
- const opacity = canvas.parentNode.style.opacity || canvas.style.opacity;
800
- mapContext.globalAlpha = opacity === '' ? 1 : Number(opacity);
801
- const backgroundColor = canvas.parentNode.style.backgroundColor;
802
- if (backgroundColor) {
803
- mapContext.fillStyle = backgroundColor;
804
- mapContext.fillRect(0, 0, canvas.width, canvas.height);
805
- }
806
- let matrix;
807
- const transform = canvas.style.transform;
808
- if (transform) {
809
- // Get the transform parameters from the style's transform matrix
810
- matrix = transform
811
- .match(/^matrix\(([^(]*)\)$/)[1]
812
- .split(',')
813
- .map(Number);
814
- }
815
- else {
816
- matrix = [
817
- parseFloat(canvas.style.width) / canvas.width,
818
- 0,
819
- 0,
820
- parseFloat(canvas.style.height) / canvas.height,
821
- 0,
822
- 0
823
- ];
833
+ static getFeatureFromItem(projection, item, type, locationAttribute, iconStyle, selectedIconStyle) {
834
+ return new Feature({
835
+ ...item,
836
+ type,
837
+ geometry: WidgetMapUtils.readGeometry(projection, item, 'point', locationAttribute) ?? undefined,
838
+ classicStyle: iconStyle ?? null,
839
+ selectedStyle: selectedIconStyle ?? null
840
+ });
841
+ }
842
+ static getCircleFeatureFromItem(projection, item, locationAttribute, radius, iconStyle, selectedIconStyle) {
843
+ return new Feature({
844
+ ...item,
845
+ geometry: new Circle$1(WidgetMapUtils.readGeometry(projection, item, 'point', locationAttribute).getCoordinates(), radius),
846
+ classicStyle: iconStyle,
847
+ selectedStyle: selectedIconStyle,
848
+ type: 'bubble'
849
+ });
850
+ }
851
+ static getLinkFeature(relation, featureSource, featureDestination) {
852
+ return new Feature({
853
+ ...relation,
854
+ geometry: new LineString([
855
+ // @ts-ignore
856
+ featureSource.getGeometry()?.getCoordinates() ?? featureSource.getGeometry()?.getCenter() ?? [0, 0],
857
+ // @ts-ignore
858
+ featureDestination.getGeometry()?.getCoordinates() ?? featureDestination.getGeometry()?.getCenter() ?? [0, 0]
859
+ ]),
860
+ source: featureSource,
861
+ destination: featureDestination,
862
+ type: 'link'
863
+ });
864
+ }
865
+ static getMapAsPng(map) {
866
+ return new Promise((resolve, reject) => {
867
+ map.once('rendercomplete', function () {
868
+ const mapCanvas = document.createElement('canvas');
869
+ const size = map.getSize() || [100, 100];
870
+ mapCanvas.width = size[0];
871
+ mapCanvas.height = size[1];
872
+ const mapContext = mapCanvas.getContext('2d') || null;
873
+ Array.prototype.forEach.call(document.querySelectorAll('.ol-layer canvas, canvas.ol-layer'), (canvas) => {
874
+ if (canvas.width > 0) {
875
+ const opacity = canvas.parentNode.style.opacity || canvas.style.opacity;
876
+ mapContext.globalAlpha = opacity === '' ? 1 : Number(opacity);
877
+ const backgroundColor = canvas.parentNode.style.backgroundColor;
878
+ if (backgroundColor) {
879
+ mapContext.fillStyle = backgroundColor;
880
+ mapContext.fillRect(0, 0, canvas.width, canvas.height);
881
+ }
882
+ let matrix;
883
+ const transform = canvas.style.transform;
884
+ if (transform) {
885
+ // Get the transform parameters from the style's transform matrix
886
+ matrix = transform
887
+ .match(/^matrix\(([^(]*)\)$/)[1]
888
+ .split(',')
889
+ .map(Number);
890
+ }
891
+ else {
892
+ matrix = [
893
+ parseFloat(canvas.style.width) / canvas.width,
894
+ 0,
895
+ 0,
896
+ parseFloat(canvas.style.height) / canvas.height,
897
+ 0,
898
+ 0
899
+ ];
900
+ }
901
+ // Apply the transform to the export map context
902
+ CanvasRenderingContext2D.prototype.setTransform.apply(mapContext, matrix);
903
+ mapContext.drawImage(canvas, 0, 0);
824
904
  }
825
- // Apply the transform to the export map context
826
- CanvasRenderingContext2D.prototype.setTransform.apply(mapContext, matrix);
827
- mapContext.drawImage(canvas, 0, 0);
828
- }
905
+ });
906
+ mapContext.globalAlpha = 1;
907
+ resolve(mapCanvas.toDataURL('image/png'));
829
908
  });
830
- mapContext.globalAlpha = 1;
831
- resolve(mapCanvas.toDataURL('image/png'));
909
+ map.renderSync();
832
910
  });
833
- map.renderSync();
834
- });
835
- };
836
- const exportMapAsImage = (map, filename) => {
837
- getMapAsPng(map).then((data) => {
838
- const link = document.createElement('a');
839
- link.download = filename;
840
- link.href = data;
841
- link.click();
842
- });
843
- };
844
- const geometryForLayer = (layer) => {
845
- switch (layer.type) {
846
- case 'marker':
847
- case 'heatmap':
848
- case 'bubble':
849
- case 'point':
850
- return FieldType.POINT;
851
- case 'line':
852
- return FieldType.LINE;
853
- case 'polygon':
854
- return FieldType.POLYGON;
855
- case 'multi-line':
856
- return FieldType.MULTILINE;
857
- case 'multi-polygon':
858
- return FieldType.MULTIPOLYGON;
859
- case 'auto':
860
- return geometryForLayer({
861
- type: WidgetMapLayerService.translateFieldTypeToLayerType(layer.subType)
862
- });
863
- default:
864
- return FieldType.POINT;
865
911
  }
866
- };
867
- const assignLayersOrder = (_layers) => {
868
- const layers = JSON.parse(JSON.stringify(_layers));
869
- layers.sort((l1, l2) => (l2.background ? 0 : 1) - (l1.background ? 0 : 1));
870
- // Assign sure things
871
- layers.forEach((layer, index) => {
872
- if (layer.background) {
873
- layer.order = BACKGROUND_ORDER;
874
- }
875
- if (index === 0 && !layer.order) {
876
- layer.order = 0;
912
+ static exportMapAsImage(map, filename) {
913
+ WidgetMapUtils.getMapAsPng(map).then((data) => {
914
+ const link = document.createElement('a');
915
+ link.download = filename;
916
+ link.href = data;
917
+ link.click();
918
+ });
919
+ }
920
+ static geometryForLayer(layer) {
921
+ switch (layer.type) {
922
+ case 'marker':
923
+ case 'heatmap':
924
+ case 'bubble':
925
+ case 'point':
926
+ return FieldType.POINT;
927
+ case 'line':
928
+ return FieldType.LINE;
929
+ case 'polygon':
930
+ return FieldType.POLYGON;
931
+ case 'multi-line':
932
+ return FieldType.MULTILINE;
933
+ case 'multi-polygon':
934
+ return FieldType.MULTIPOLYGON;
935
+ case 'auto':
936
+ return WidgetMapUtils.geometryForLayer({
937
+ type: WidgetMapLayerService.translateFieldTypeToLayerType(layer.subType)
938
+ });
939
+ default:
940
+ return FieldType.POINT;
877
941
  }
878
- });
879
- layers.forEach((layer, index) => {
880
- if (layer.order === undefined) {
881
- let [distanceToFirstPreviousOrder, distanceToFirstNextOrder] = [
882
- layers
883
- .slice(0, index)
884
- .reverse()
885
- .findIndex((element) => element.order !== undefined) + 1,
886
- layers.slice(index + 1).findIndex((element) => element.order !== undefined)
887
- ];
888
- let [previousOrderIndex, nextOrderIndex] = [
889
- distanceToFirstPreviousOrder > -1 ? index - distanceToFirstPreviousOrder : 0,
890
- distanceToFirstNextOrder + index + 1
891
- ];
892
- let [previousOrder, nextOrder] = [
893
- distanceToFirstPreviousOrder > -1 ? layers[previousOrderIndex].order : 0,
894
- distanceToFirstNextOrder > -1 ? layers[nextOrderIndex].order : -1
895
- ];
896
- if (nextOrder > 0 && nextOrder < previousOrder) {
897
- const newOrder = previousOrder + (nextOrderIndex - previousOrderIndex);
898
- console.warn(`the order property of layer no ${index + 2} was preset but doesn't follow the order of the other layers`);
899
- nextOrder = newOrder;
900
- }
901
- if (nextOrder > 0) {
902
- let relativeIndex = index - previousOrderIndex;
903
- layer.order =
904
- previousOrder + ((nextOrder - previousOrder) / (nextOrderIndex - previousOrderIndex)) * relativeIndex;
942
+ }
943
+ static assignLayersOrder(_layers) {
944
+ const layers = JSON.parse(JSON.stringify(_layers));
945
+ layers.sort((l1, l2) => (l2.background ? 0 : 1) - (l1.background ? 0 : 1));
946
+ // Assign sure things
947
+ layers.forEach((layer, index) => {
948
+ if (layer.background) {
949
+ layer.order = WidgetMapUtils.BACKGROUND_ORDER;
905
950
  }
906
- else {
907
- layer.order = previousOrder + distanceToFirstPreviousOrder;
951
+ if (index === 0 && !layer.order) {
952
+ layer.order = 0;
908
953
  }
909
- }
910
- });
911
- return layers.sort((l1, l2) => (l1.order ?? 1) - (l2.order ?? 1));
912
- };
913
- const DEFAULT_HEATMAP_RADIUS = 25;
914
- const DEFAULT_RADIUS_INTENSITY_FACTOR = 10000;
915
- const DEFAULT_ZOOM_MIN = 3;
916
- const DEFAULT_ZOOM_START = 10;
917
- const DEFAULT_ZOOM_MAX = 18;
918
- const DEFAULT_MAP_CENTER = [2.2827217347381525, 48.864706031557716];
919
- const BACKGROUND_ORDER = 9999;
920
-
921
- class XMLUtils {
922
- static find(childs, name) {
923
- if (!!childs) {
924
- for (let i = 0; i < childs.length; i++) {
925
- const node = childs[i];
926
- if (node.nodeName === name) {
927
- return node;
954
+ });
955
+ layers.forEach((layer, index) => {
956
+ if (layer.order === undefined) {
957
+ let [distanceToFirstPreviousOrder, distanceToFirstNextOrder] = [
958
+ layers
959
+ .slice(0, index)
960
+ .reverse()
961
+ .findIndex((element) => element.order !== undefined) + 1,
962
+ layers.slice(index + 1).findIndex((element) => element.order !== undefined)
963
+ ];
964
+ let [previousOrderIndex, nextOrderIndex] = [
965
+ distanceToFirstPreviousOrder > -1 ? index - distanceToFirstPreviousOrder : 0,
966
+ distanceToFirstNextOrder + index + 1
967
+ ];
968
+ let [previousOrder, nextOrder] = [
969
+ distanceToFirstPreviousOrder > -1 ? layers[previousOrderIndex].order : 0,
970
+ distanceToFirstNextOrder > -1 ? layers[nextOrderIndex].order : -1
971
+ ];
972
+ if (nextOrder > 0 && nextOrder < previousOrder) {
973
+ const newOrder = previousOrder + (nextOrderIndex - previousOrderIndex);
974
+ console.warn(`the order property of layer no ${index + 2} was preset but doesn't follow the order of the other layers`);
975
+ nextOrder = newOrder;
976
+ }
977
+ if (nextOrder > 0) {
978
+ let relativeIndex = index - previousOrderIndex;
979
+ layer.order =
980
+ previousOrder + ((nextOrder - previousOrder) / (nextOrderIndex - previousOrderIndex)) * relativeIndex;
981
+ }
982
+ else {
983
+ layer.order = previousOrder + distanceToFirstPreviousOrder;
928
984
  }
929
985
  }
930
- }
931
- return null;
986
+ });
987
+ return layers.sort((l1, l2) => (l1.order ?? 1) - (l2.order ?? 1));
932
988
  }
933
- static findAll(childs, name) {
934
- const result = [];
935
- for (let i = 0; i < childs.length; i++) {
936
- const node = childs[i];
937
- if (node.nodeName === name) {
938
- result.push(node);
939
- }
989
+ static readGeometry(projection, item, type, attribute) {
990
+ if (!attribute || !item.attributes[attribute.name]) {
991
+ // @ts-ignore
992
+ return null;
940
993
  }
941
- return result;
942
- }
943
- static findWith(childs, attribute, value) {
944
- for (let i = 0; i < childs.length; i++) {
945
- const node = childs[i];
946
- const attrNode = XMLUtils.find(node.childNodes, attribute);
947
- if (attrNode?.textContent === value) {
948
- return node;
949
- }
994
+ let value = item.attributes[attribute.name];
995
+ if (value.type === 'MULTI') {
996
+ value = value.values[0];
950
997
  }
951
- return null;
952
- }
953
- static getMatchingLayer(paramLayer, doc) {
954
- const WMSCapability = XMLUtils.find(doc.childNodes, 'WMS_Capabilities');
955
- if (WMSCapability) {
956
- const Capabilities = XMLUtils.find(WMSCapability.childNodes, 'Capability');
957
- if (Capabilities) {
958
- const Layer = XMLUtils.find(Capabilities.childNodes, 'Layer');
959
- if (Layer) {
960
- let matchingLayer = XMLUtils.findWith(Layer.childNodes, 'Name', paramLayer);
961
- const split = paramLayer.split(':');
962
- if (!matchingLayer && split.length >= 2) {
963
- // Try again, splitting on ":" in the name to ignore namespace if present
964
- matchingLayer = XMLUtils.findWith(Layer.childNodes, 'Name', split[split.length - 1]);
965
- }
966
- return matchingLayer;
967
- }
968
- }
998
+ let geometry;
999
+ try {
1000
+ geometry = new GeoJSON().readGeometry(value.value, {
1001
+ featureProjection: projection
1002
+ });
969
1003
  }
970
- return null;
971
- }
972
- static getLayerExtent(paramLayer, map, doc) {
973
- if (!doc) {
974
- return null;
1004
+ catch (e) {
1005
+ console.warn('error reading Geometry', value.value, e);
975
1006
  }
976
- const matchingLayer = XMLUtils.getMatchingLayer(paramLayer, doc);
977
- if (matchingLayer) {
978
- const boundingBox = XMLUtils.find(matchingLayer.childNodes, 'BoundingBox');
979
- if (boundingBox) {
980
- // @ts-ignore
981
- const attributes = boundingBox.attributes;
982
- const projBox = get(attributes.CRS.textContent ?? DEFAULT_PROJECTION);
983
- if (projBox) {
984
- return [
985
- transform([parseFloat(attributes.minx.textContent), parseFloat(attributes.miny.textContent)], projBox, map.getView().getProjection()),
986
- transform([parseFloat(attributes.maxx.textContent), parseFloat(attributes.maxy.textContent)], projBox, map.getView().getProjection())
987
- ];
988
- }
1007
+ return geometry;
1008
+ }
1009
+ static extractGeometries(value, points, type) {
1010
+ const valueSimple = value.value;
1011
+ if (typeof valueSimple !== 'string' && typeof valueSimple !== 'number') {
1012
+ if (type === 'point' && valueSimple.type === FieldType.POINT) {
1013
+ points.push(valueSimple.coordinates);
1014
+ }
1015
+ if (type === 'point' && valueSimple.type === FieldType.MULTIPOINT) {
1016
+ points.push(...valueSimple.coordinates);
1017
+ }
1018
+ if (type === 'line' && valueSimple.type === FieldType.LINE) {
1019
+ points.push(valueSimple.coordinates);
1020
+ }
1021
+ if (type === 'line' && valueSimple.type === FieldType.MULTILINE) {
1022
+ points.push(...valueSimple.coordinates);
1023
+ }
1024
+ if (type === 'polygon' && valueSimple.type === FieldType.POLYGON) {
1025
+ points.push(valueSimple.coordinates);
1026
+ }
1027
+ if (type === 'polygon' && valueSimple.type === FieldType.MULTIPOLYGON) {
1028
+ points.push(...valueSimple.coordinates);
989
1029
  }
990
1030
  }
991
- return null;
992
1031
  }
1032
+ static { this.DEFAULT_HEATMAP_RADIUS = 25; }
1033
+ static { this.DEFAULT_RADIUS_INTENSITY_FACTOR = 10000; }
1034
+ static { this.DEFAULT_ZOOM_MIN = 3; }
1035
+ static { this.DEFAULT_ZOOM_START = 10; }
1036
+ static { this.DEFAULT_ZOOM_MAX = 18; }
1037
+ static { this.DEFAULT_MAP_CENTER = [2.2827217347381525, 48.864706031557716]; }
1038
+ static { this.BACKGROUND_ORDER = 9999; }
993
1039
  }
994
1040
 
995
1041
  class PryWidgetMapCssComponent {
@@ -1012,7 +1058,7 @@ class GeometryFieldsForPipe {
1012
1058
  transform(value, ...args) {
1013
1059
  const specificLayer = value;
1014
1060
  const limitToClasses = args[0].classes;
1015
- const type = geometryForLayer({ type: args[0].type });
1061
+ const type = WidgetMapUtils.geometryForLayer({ type: args[0].type });
1016
1062
  return combineLatest([this.classes$, this.fields$]).pipe(filter(([classes, fields]) => !!classes && !!fields && classes.length > 0 && fields.length > 0), map(([classes, fields]) => {
1017
1063
  const potentialFields = classes
1018
1064
  .map((cl) => cl.id)
@@ -1236,8 +1282,8 @@ class WidgetMapComponent extends DataWidgetComponent {
1236
1282
  : [])
1237
1283
  ];
1238
1284
  autoOptions.layers?.forEach((layer, i) => {
1239
- populateLocationAttribute(layer, resultSet, classes, fields);
1240
- populateIntensityAttribute(layer, resultSet, classes, fields);
1285
+ WidgetMapUtils.populateLocationAttribute(layer, resultSet, classes, fields);
1286
+ WidgetMapUtils.populateIntensityAttribute(layer, resultSet, classes, fields);
1241
1287
  if (autoOptions.attributions) {
1242
1288
  layer.attribution = layer.attribution ?? '';
1243
1289
  }
@@ -1279,7 +1325,7 @@ class WidgetMapComponent extends DataWidgetComponent {
1279
1325
  this.emitManifest();
1280
1326
  }
1281
1327
  }
1282
- autoOptions.layers = assignLayersOrder(autoOptions.layers);
1328
+ autoOptions.layers = WidgetMapUtils.assignLayersOrder(autoOptions.layers);
1283
1329
  return autoOptions;
1284
1330
  }), distinctUntilChanged((p, c) => equal(p, c)));
1285
1331
  this.subscriptions.add(this.options$.pipe(filter((opt) => !!opt)).subscribe((options) => {
@@ -1348,10 +1394,10 @@ class WidgetMapComponent extends DataWidgetComponent {
1348
1394
  }));
1349
1395
  this.options$
1350
1396
  .pipe(map((options) => ({
1351
- center: fromLonLat(options.center ?? DEFAULT_MAP_CENTER),
1352
- maxZoom: options.zoom?.max ?? DEFAULT_ZOOM_MAX,
1353
- minZoom: options.zoom?.min ?? DEFAULT_ZOOM_MIN,
1354
- zoom: options.zoom?.start ?? DEFAULT_ZOOM_START
1397
+ center: fromLonLat(options.center ?? WidgetMapUtils.DEFAULT_MAP_CENTER),
1398
+ maxZoom: options.zoom?.max ?? WidgetMapUtils.DEFAULT_ZOOM_MAX,
1399
+ minZoom: options.zoom?.min ?? WidgetMapUtils.DEFAULT_ZOOM_MIN,
1400
+ zoom: options.zoom?.start ?? WidgetMapUtils.DEFAULT_ZOOM_START
1355
1401
  })), distinctUntilChanged())
1356
1402
  .subscribe((view) => this.map.setView(new View(view)));
1357
1403
  this.fitOption$ = this.options$.pipe(map((options) => !!options.fit), distinctUntilChanged());
@@ -1433,7 +1479,7 @@ class WidgetMapComponent extends DataWidgetComponent {
1433
1479
  const source = features.find((f) => f.get('id') === relation.source);
1434
1480
  const dest = features.find((f) => f.get('id') === relation.destination);
1435
1481
  if (!!source && !!dest) {
1436
- hasRelationLayer.getSource()?.addFeature(getLinkFeature(relation, source, dest));
1482
+ hasRelationLayer.getSource()?.addFeature(WidgetMapUtils.getLinkFeature(relation, source, dest));
1437
1483
  }
1438
1484
  });
1439
1485
  }
@@ -1818,10 +1864,10 @@ class WidgetMapComponent extends DataWidgetComponent {
1818
1864
  layer.style = $event.currentTarget?.value;
1819
1865
  }
1820
1866
  export() {
1821
- exportMapAsImage(this.map, 'map.png');
1867
+ WidgetMapUtils.exportMapAsImage(this.map, 'map.png');
1822
1868
  }
1823
1869
  toImage() {
1824
- return getMapAsPng(this.map);
1870
+ return WidgetMapUtils.getMapAsPng(this.map);
1825
1871
  }
1826
1872
  changeClustered(layer, $event) {
1827
1873
  layer.clustered = $event;
@@ -2195,5 +2241,5 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "16.1.6", ngImpor
2195
2241
  * Generated bundle index. Do not edit.
2196
2242
  */
2197
2243
 
2198
- export { BACKGROUND_ORDER, CqlUtils, DEFAULT_HEATMAP_RADIUS, DEFAULT_MAP_CENTER, DEFAULT_RADIUS_INTENSITY_FACTOR, DEFAULT_ZOOM_MAX, DEFAULT_ZOOM_MIN, DEFAULT_ZOOM_START, GeometryFieldsForPipe, InteractionManager, PryWidgetMapCssComponent, SelectionInteraction, TOOLTIP_PADDING, WidgetMapComponent, WidgetMapLayerService, WidgetMapLegendUrlPipe, WidgetMapModule, XMLUtils, assignLayersOrder, exportMapAsImage, geometryForLayer, getCircleFeatureFromItem, getFeatureFromItem, getLinkFeature, getMapAsPng, populateIntensityAttribute, populateLocationAttribute };
2244
+ export { CqlUtils, GeometryFieldsForPipe, InteractionManager, PryWidgetMapCssComponent, SelectionInteraction, TOOLTIP_PADDING, WidgetMapComponent, WidgetMapLayerService, WidgetMapLegendUrlPipe, WidgetMapModule, WidgetMapUtils, XMLUtils };
2199
2245
  //# sourceMappingURL=provoly-dashboard-widgets-widget-map.mjs.map