@provoly/dashboard 0.20.0 → 0.20.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.
@@ -17,7 +17,7 @@ import { toLonLat, get, transform, fromLonLat } from 'ol/proj';
17
17
  import { register } from 'ol/proj/proj4';
18
18
  import { Vector, TileWMS, WMTS, XYZ, Cluster, DataTile } from 'ol/source';
19
19
  import proj4 from 'proj4';
20
- import { BehaviorSubject, map, combineLatest, filter, distinctUntilChanged, startWith, debounceTime, delay, mergeMap, of, from, switchMap } from 'rxjs';
20
+ import { BehaviorSubject, map, combineLatest, filter, distinctUntilChanged, startWith, debounceTime, delay, mergeMap, of, from, switchMap, catchError } from 'rxjs';
21
21
  import { ScaleLine, Attribution, defaults } from 'ol/control';
22
22
  import { Polygon, Circle as Circle$1, LineString } from 'ol/geom';
23
23
  import PointerInteraction from 'ol/interaction/Pointer';
@@ -1055,29 +1055,6 @@ class WidgetMapUtils {
1055
1055
  }
1056
1056
  return geometry;
1057
1057
  }
1058
- static extractGeometries(value, points, type) {
1059
- const valueSimple = value.value;
1060
- if (typeof valueSimple !== 'string' && typeof valueSimple !== 'number') {
1061
- if (type === 'point' && valueSimple.type === FieldType.POINT) {
1062
- points.push(valueSimple.coordinates);
1063
- }
1064
- if (type === 'point' && valueSimple.type === FieldType.MULTIPOINT) {
1065
- points.push(...valueSimple.coordinates);
1066
- }
1067
- if (type === 'line' && valueSimple.type === FieldType.LINE) {
1068
- points.push(valueSimple.coordinates);
1069
- }
1070
- if (type === 'line' && valueSimple.type === FieldType.MULTILINE) {
1071
- points.push(...valueSimple.coordinates);
1072
- }
1073
- if (type === 'polygon' && valueSimple.type === FieldType.POLYGON) {
1074
- points.push(valueSimple.coordinates);
1075
- }
1076
- if (type === 'polygon' && valueSimple.type === FieldType.MULTIPOLYGON) {
1077
- points.push(...valueSimple.coordinates);
1078
- }
1079
- }
1080
- }
1081
1058
  static projectExtentAggregationResponse(field, extentResponse, layer, wmsCapabilities, map) {
1082
1059
  const projBox = get(field.crs ?? DEFAULT_PROJECTION);
1083
1060
  const response = extentResponse.values;
@@ -1092,6 +1069,7 @@ class WidgetMapUtils {
1092
1069
  response[0].value.bottom_right.lon !== undefined) {
1093
1070
  return {
1094
1071
  datasource: layer.datasourceId,
1072
+ error: false,
1095
1073
  extent: [
1096
1074
  transform([
1097
1075
  parseFloat(extentResponse.values[0].value.top_left.lon),
@@ -1106,7 +1084,8 @@ class WidgetMapUtils {
1106
1084
  }
1107
1085
  return {
1108
1086
  datasource: layer.datasourceId,
1109
- extent: XMLUtils.getLayerExtent(layer.paramLayer, map, wmsCapabilities[layer.url]?.doc) ?? []
1087
+ extent: XMLUtils.getLayerExtent(layer.paramLayer, map, wmsCapabilities[layer.url]?.doc) ?? [],
1088
+ error: false
1110
1089
  };
1111
1090
  }
1112
1091
  static { this.DEFAULT_HEATMAP_RADIUS = 25; }
@@ -1580,7 +1559,10 @@ class WidgetMapComponent extends DataWidgetComponent {
1580
1559
  new MapboxVectorLayer({
1581
1560
  properties: { title: 'background' },
1582
1561
  styleUrl
1583
- })
1562
+ }) /* ,
1563
+ new TileLayer({
1564
+ source: new TileDebug()
1565
+ }) */
1584
1566
  ];
1585
1567
  }));
1586
1568
  this.options$
@@ -1717,17 +1699,19 @@ class WidgetMapComponent extends DataWidgetComponent {
1717
1699
  .aggregate([layer.datasourceId], {
1718
1700
  ordinate: { operation: Operation.EXTENT, attribute: attr.id, label: attr.name, keep0: false }
1719
1701
  })
1720
- .pipe(map((extentResponse) => {
1721
- return WidgetMapUtils.projectExtentAggregationResponse(field, extentResponse, layer, wmsCapabilities, this.map);
1722
- })))
1702
+ .pipe(map((extentResponse) => WidgetMapUtils.projectExtentAggregationResponse(field, extentResponse, layer, wmsCapabilities, this.map)), catchError(() => of({ datasource: layer.datasourceId, extent: [], error: true }))))
1723
1703
  .flat())
1724
1704
  .flat(),
1725
1705
  ...(options.layers?.filter((layer) => layer.type === 'wms') ?? [])
1726
1706
  .filter((layer) => layer.fit)
1727
- .map((layer) => of({
1728
- datasource: `wms-${layer.paramLayer}`,
1729
- extent: XMLUtils.getLayerExtent(layer.paramLayer, this.map, wmsCapabilities[layer.url]?.doc) ?? []
1730
- }))
1707
+ .map((layer) => {
1708
+ const extent = XMLUtils.getLayerExtent(layer.paramLayer, this.map, wmsCapabilities[layer.url]?.doc);
1709
+ return of({
1710
+ datasource: `wms-${layer.paramLayer}`,
1711
+ extent: extent ?? [],
1712
+ error: !extent
1713
+ });
1714
+ })
1731
1715
  ])
1732
1716
  : of([])), startWith([]));
1733
1717
  this.legendLayers$ = this.options$.pipe(map((options) => (options.layers ?? []).filter((layer) => ['geoserver', 'wms'].includes(layer.type))), delay(10));
@@ -1744,26 +1728,33 @@ class WidgetMapComponent extends DataWidgetComponent {
1744
1728
  this.fitExtents$,
1745
1729
  this.datasourceFilters$
1746
1730
  ]).subscribe(([mapStyleLayer, layers, selectedIds, extents, filters]) => {
1747
- const toApplyLayers = [...layers, ...mapStyleLayer];
1748
- this.map.setLayers(toApplyLayers);
1749
- this.map
1750
- .getAllLayers()
1751
- .filter((layer) => !(layer instanceof Tile))
1752
- .forEach((layer) => {
1753
- const getFeatures = layer.getSource()?.getFeatures;
1754
- if (typeof getFeatures === 'function') {
1755
- layer.getSource()?.getFeatures().forEach((feature) => {
1756
- const type = feature.get('type');
1757
- if (['bubble', 'marker', 'point', 'line', 'polygon', 'multi-line', 'multi-polygon'].includes(type)) {
1758
- feature.setStyle(feature.get(selectedIds.includes(feature.get('id')) ? 'selectedStyle' : 'classicStyle'));
1759
- }
1760
- });
1761
- }
1762
- });
1763
- setTimeout(() => {
1731
+ const neededCalculatedExtents = layers.filter((layer) => ['geoserver', 'wms'].includes(layer.get('type')) && layer.get('fit')).length;
1732
+ const nbCalculatedExtents = extents.filter((extent) => !extent.error).length;
1733
+ if (nbCalculatedExtents >= neededCalculatedExtents) {
1764
1734
  this.fitMapForObjects(selectedIds, extents, filters);
1765
1735
  this.map.updateSize();
1766
- }, 200);
1736
+ setTimeout(() => {
1737
+ const toApplyLayers = [...layers, ...mapStyleLayer];
1738
+ this.map.setLayers(toApplyLayers);
1739
+ this.map
1740
+ .getAllLayers()
1741
+ .filter((layer) => !(layer instanceof Tile))
1742
+ .forEach((layer) => {
1743
+ const getFeatures = layer.getSource()?.getFeatures;
1744
+ if (typeof getFeatures === 'function') {
1745
+ layer.getSource()?.getFeatures().forEach((feature) => {
1746
+ const type = feature.get('type');
1747
+ if (['bubble', 'marker', 'point', 'line', 'polygon', 'multi-line', 'multi-polygon'].includes(type)) {
1748
+ feature.setStyle(feature.get(selectedIds.includes(feature.get('id')) ? 'selectedStyle' : 'classicStyle'));
1749
+ }
1750
+ });
1751
+ }
1752
+ });
1753
+ }, 100);
1754
+ }
1755
+ else {
1756
+ this.map.setLayers([...mapStyleLayer]);
1757
+ }
1767
1758
  }));
1768
1759
  this.subscriptions.add(combineLatest([this.wmsFeatures$, this.classicFeatures$, this.widgetSize$, this.displayHeader$]).subscribe(([wmsFeatures, classicFeatures, size, header]) => {
1769
1760
  if (this.map) {