@provoly/dashboard 0.18.5 → 0.18.7
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dataset/style/_o-pry-dataset-card.scss +0 -1
- package/dataset/style/_o-pry-dataset-detail.scss +4 -0
- package/esm2022/admin/components/admin-dataset/shared/admin-form-dataset/admin-form-dataset.component.mjs +3 -3
- package/esm2022/dataset/components/dataset-card/dataset-card.component.mjs +3 -3
- package/esm2022/dataset/components/dataset.component.mjs +3 -3
- package/esm2022/dataset/style/css.component.mjs +2 -2
- package/esm2022/filters/date/date-filter.component.mjs +8 -4
- package/esm2022/filters/list/list-filter.component.mjs +4 -3
- package/esm2022/filters/number/number-filter.component.mjs +3 -3
- package/esm2022/filters/text/text-filter.component.mjs +3 -3
- package/esm2022/lib/core/i18n/en.translations.mjs +2 -1
- package/esm2022/lib/core/i18n/fr.translations.mjs +2 -1
- package/esm2022/lib/core/store/search/search.effects.mjs +2 -2
- package/esm2022/lib/core/toolbox/toolbox-manifest.service.mjs +12 -1
- package/esm2022/lib/core/toolbox/toolbox-menu.service.mjs +3 -2
- package/esm2022/lib/dashboard/filter/base-filter.component.mjs +4 -1
- package/esm2022/lib/dashboard/item-utils.mjs +1 -60
- package/esm2022/lib/dashboard/store/dashboard.effects.mjs +3 -4
- package/esm2022/presentation/components/presentation.component.mjs +1 -3
- package/esm2022/widgets/widget-map/component/widget-map-layer.service.mjs +39 -38
- package/esm2022/widgets/widget-map/component/widget-map.component.mjs +12 -12
- package/esm2022/widgets/widget-map/pipe/widget-map-geometry-fields-for.pipe.mjs +3 -3
- package/esm2022/widgets/widget-map/utils/widget-map.utils.mjs +262 -216
- package/esm2022/widgets/widget-template/component/widget-template.component.mjs +13 -4
- package/esm2022/widgets/widget-template/i18n/en.translations.mjs +11 -0
- package/esm2022/widgets/widget-template/i18n/fr.translations.mjs +11 -0
- package/esm2022/widgets/widget-template/widget-template.module.mjs +19 -7
- package/fesm2022/provoly-dashboard-admin.mjs +2 -2
- package/fesm2022/provoly-dashboard-admin.mjs.map +1 -1
- package/fesm2022/provoly-dashboard-dataset.mjs +6 -6
- package/fesm2022/provoly-dashboard-dataset.mjs.map +1 -1
- package/fesm2022/provoly-dashboard-filters-date.mjs +7 -3
- package/fesm2022/provoly-dashboard-filters-date.mjs.map +1 -1
- package/fesm2022/provoly-dashboard-filters-list.mjs +3 -2
- package/fesm2022/provoly-dashboard-filters-list.mjs.map +1 -1
- package/fesm2022/provoly-dashboard-filters-number.mjs +2 -2
- package/fesm2022/provoly-dashboard-filters-number.mjs.map +1 -1
- package/fesm2022/provoly-dashboard-filters-text.mjs +2 -2
- package/fesm2022/provoly-dashboard-filters-text.mjs.map +1 -1
- package/fesm2022/provoly-dashboard-presentation.mjs +0 -2
- package/fesm2022/provoly-dashboard-presentation.mjs.map +1 -1
- package/fesm2022/provoly-dashboard-widgets-widget-map.mjs +377 -331
- package/fesm2022/provoly-dashboard-widgets-widget-map.mjs.map +1 -1
- package/fesm2022/provoly-dashboard-widgets-widget-template.mjs +48 -8
- package/fesm2022/provoly-dashboard-widgets-widget-template.mjs.map +1 -1
- package/fesm2022/provoly-dashboard.mjs +49 -91
- package/fesm2022/provoly-dashboard.mjs.map +1 -1
- package/filters/date/date-filter.component.d.ts +1 -0
- package/lib/core/i18n/en.translations.d.ts +1 -0
- package/lib/core/i18n/fr.translations.d.ts +1 -0
- package/lib/dashboard/filter/base-filter.component.d.ts +4 -2
- package/lib/dashboard/item-utils.d.ts +0 -8
- package/lib/dashboard/store/dashboard.effects.d.ts +0 -3
- package/package.json +1 -1
- package/styles/components/_a-form-field.scss +0 -1
- package/styles/components/_a-table.scss +1 -1
- package/styles/components/_m-filter.scss +23 -23
- package/styles/components/_m-form-label-field.scss +6 -0
- package/styles-theme/components-theme/_m-filter.theme.scss +19 -4
- package/widgets/widget-map/utils/widget-map.utils.d.ts +23 -17
- package/widgets/widget-template/component/widget-template.component.d.ts +2 -0
- package/widgets/widget-template/i18n/en.translations.d.ts +10 -0
- package/widgets/widget-template/i18n/fr.translations.d.ts +10 -0
- package/widgets/widget-template/widget-template.module.d.ts +4 -2
|
@@ -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,
|
|
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 =
|
|
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 =
|
|
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 =
|
|
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) *
|
|
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:
|
|
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
|
-
|
|
690
|
-
|
|
691
|
-
|
|
692
|
-
|
|
693
|
-
|
|
694
|
-
|
|
695
|
-
|
|
696
|
-
|
|
697
|
-
|
|
698
|
-
|
|
699
|
-
|
|
700
|
-
|
|
701
|
-
|
|
702
|
-
|
|
703
|
-
|
|
704
|
-
|
|
705
|
-
|
|
706
|
-
|
|
707
|
-
|
|
708
|
-
|
|
709
|
-
|
|
710
|
-
|
|
711
|
-
|
|
712
|
-
|
|
713
|
-
|
|
714
|
-
|
|
715
|
-
|
|
716
|
-
|
|
717
|
-
|
|
718
|
-
|
|
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
|
-
|
|
724
|
-
|
|
725
|
-
|
|
726
|
-
|
|
727
|
-
|
|
728
|
-
|
|
729
|
-
|
|
730
|
-
|
|
731
|
-
|
|
732
|
-
|
|
733
|
-
|
|
734
|
-
|
|
735
|
-
|
|
736
|
-
|
|
737
|
-
|
|
738
|
-
|
|
739
|
-
|
|
740
|
-
|
|
741
|
-
|
|
742
|
-
|
|
743
|
-
|
|
744
|
-
|
|
745
|
-
};
|
|
746
|
-
})
|
|
747
|
-
|
|
748
|
-
|
|
749
|
-
|
|
750
|
-
|
|
751
|
-
|
|
752
|
-
|
|
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
|
-
|
|
758
|
-
|
|
759
|
-
|
|
760
|
-
|
|
761
|
-
|
|
762
|
-
|
|
763
|
-
|
|
764
|
-
}
|
|
765
|
-
|
|
766
|
-
|
|
767
|
-
|
|
768
|
-
|
|
769
|
-
|
|
770
|
-
|
|
771
|
-
|
|
772
|
-
|
|
773
|
-
}
|
|
774
|
-
|
|
775
|
-
|
|
776
|
-
|
|
777
|
-
|
|
778
|
-
|
|
779
|
-
|
|
780
|
-
|
|
781
|
-
|
|
782
|
-
|
|
783
|
-
|
|
784
|
-
|
|
785
|
-
|
|
786
|
-
|
|
787
|
-
}
|
|
788
|
-
|
|
789
|
-
|
|
790
|
-
|
|
791
|
-
|
|
792
|
-
|
|
793
|
-
|
|
794
|
-
|
|
795
|
-
|
|
796
|
-
|
|
797
|
-
|
|
798
|
-
|
|
799
|
-
|
|
800
|
-
|
|
801
|
-
|
|
802
|
-
|
|
803
|
-
|
|
804
|
-
|
|
805
|
-
|
|
806
|
-
|
|
807
|
-
|
|
808
|
-
|
|
809
|
-
|
|
810
|
-
|
|
811
|
-
|
|
812
|
-
|
|
813
|
-
|
|
814
|
-
|
|
815
|
-
|
|
816
|
-
|
|
817
|
-
|
|
818
|
-
|
|
819
|
-
|
|
820
|
-
|
|
821
|
-
|
|
822
|
-
|
|
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
|
-
|
|
826
|
-
|
|
827
|
-
|
|
828
|
-
}
|
|
905
|
+
});
|
|
906
|
+
mapContext.globalAlpha = 1;
|
|
907
|
+
resolve(mapCanvas.toDataURL('image/png'));
|
|
829
908
|
});
|
|
830
|
-
|
|
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
|
-
|
|
868
|
-
|
|
869
|
-
|
|
870
|
-
|
|
871
|
-
|
|
872
|
-
|
|
873
|
-
|
|
874
|
-
|
|
875
|
-
|
|
876
|
-
|
|
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
|
-
|
|
880
|
-
|
|
881
|
-
|
|
882
|
-
|
|
883
|
-
|
|
884
|
-
|
|
885
|
-
|
|
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
|
-
|
|
907
|
-
layer.order =
|
|
951
|
+
if (index === 0 && !layer.order) {
|
|
952
|
+
layer.order = 0;
|
|
908
953
|
}
|
|
909
|
-
}
|
|
910
|
-
|
|
911
|
-
|
|
912
|
-
|
|
913
|
-
|
|
914
|
-
|
|
915
|
-
|
|
916
|
-
|
|
917
|
-
|
|
918
|
-
|
|
919
|
-
|
|
920
|
-
|
|
921
|
-
|
|
922
|
-
|
|
923
|
-
|
|
924
|
-
|
|
925
|
-
|
|
926
|
-
|
|
927
|
-
|
|
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
|
|
986
|
+
});
|
|
987
|
+
return layers.sort((l1, l2) => (l1.order ?? 1) - (l2.order ?? 1));
|
|
932
988
|
}
|
|
933
|
-
static
|
|
934
|
-
|
|
935
|
-
|
|
936
|
-
|
|
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
|
-
|
|
942
|
-
|
|
943
|
-
|
|
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
|
-
|
|
952
|
-
|
|
953
|
-
|
|
954
|
-
|
|
955
|
-
|
|
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
|
-
|
|
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
|
-
|
|
977
|
-
|
|
978
|
-
|
|
979
|
-
|
|
980
|
-
|
|
981
|
-
|
|
982
|
-
|
|
983
|
-
|
|
984
|
-
|
|
985
|
-
|
|
986
|
-
|
|
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 {
|
|
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
|