changeset 5175:6038f782e51d detectvisiblesoundings

client: Improve detecting of bottleneck for pdf-generation * check the existence of bottleneck on the current viewport when it has no SR to include the its name in the exported pdf filename
author Fadi Abbud <fadi.abbud@intevation.de>
date Tue, 21 Apr 2020 16:30:28 +0200
parents b73e8cc494f6
children 698d0971ddc5
files client/src/components/Pdftool.vue
diffstat 1 files changed, 17 insertions(+), 1 deletions(-) [+]
line wrap: on
line diff
--- a/client/src/components/Pdftool.vue	Tue Apr 21 13:45:54 2020 +0200
+++ b/client/src/components/Pdftool.vue	Tue Apr 21 16:30:28 2020 +0200
@@ -121,6 +121,7 @@
 import sanitize from "sanitize-filename";
 import { WFS } from "ol/format";
 import { equalTo as equalToFilter } from "ol/format/filter";
+import { intersects } from "ol/extent";
 
 const paperSizes = {
   // in millimeter, landscape [width, height]
@@ -481,8 +482,23 @@
               }
             }
           });
+          // Check if the bottlenck in the current view Extent
+          const isBottlenckVisible = () => {
+            const currentExtent = map.getView().calculateExtent(map.getSize());
+            const btnExtent = map
+              .getLayer("BOTTLENECKS")
+              .getSource()
+              .getFeatures()
+              .find(f => f.get("objnam") === this.bottleneckForPrint)
+              .getGeometry()
+              .getExtent();
+            return intersects(currentExtent, btnExtent);
+          };
           let filename = "map";
-          if (this.bottleneckForPrint && soundingsVisible) {
+          if (
+            this.bottleneckForPrint &&
+            (soundingsVisible || isBottlenckVisible())
+          ) {
             filename = `BN-${sanitize(this.bottleneckForPrint).replace(
               / /g,
               "-"