Mercurial > gemma
comparison client/src/components/Pdftool.vue @ 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 | 528fa710650b |
comparison
equal
deleted
inserted
replaced
5174:b73e8cc494f6 | 5175:6038f782e51d |
---|---|
119 import { displayError } from "@/lib/errors"; | 119 import { displayError } from "@/lib/errors"; |
120 import { pdfgen, templateLoader } from "@/lib/mixins"; | 120 import { pdfgen, templateLoader } from "@/lib/mixins"; |
121 import sanitize from "sanitize-filename"; | 121 import sanitize from "sanitize-filename"; |
122 import { WFS } from "ol/format"; | 122 import { WFS } from "ol/format"; |
123 import { equalTo as equalToFilter } from "ol/format/filter"; | 123 import { equalTo as equalToFilter } from "ol/format/filter"; |
124 import { intersects } from "ol/extent"; | |
124 | 125 |
125 const paperSizes = { | 126 const paperSizes = { |
126 // in millimeter, landscape [width, height] | 127 // in millimeter, landscape [width, height] |
127 a3: [420, 297], | 128 a3: [420, 297], |
128 a4: [297, 210] | 129 a4: [297, 210] |
479 ); | 480 ); |
480 break; | 481 break; |
481 } | 482 } |
482 } | 483 } |
483 }); | 484 }); |
485 // Check if the bottlenck in the current view Extent | |
486 const isBottlenckVisible = () => { | |
487 const currentExtent = map.getView().calculateExtent(map.getSize()); | |
488 const btnExtent = map | |
489 .getLayer("BOTTLENECKS") | |
490 .getSource() | |
491 .getFeatures() | |
492 .find(f => f.get("objnam") === this.bottleneckForPrint) | |
493 .getGeometry() | |
494 .getExtent(); | |
495 return intersects(currentExtent, btnExtent); | |
496 }; | |
484 let filename = "map"; | 497 let filename = "map"; |
485 if (this.bottleneckForPrint && soundingsVisible) { | 498 if ( |
499 this.bottleneckForPrint && | |
500 (soundingsVisible || isBottlenckVisible()) | |
501 ) { | |
486 filename = `BN-${sanitize(this.bottleneckForPrint).replace( | 502 filename = `BN-${sanitize(this.bottleneckForPrint).replace( |
487 / /g, | 503 / /g, |
488 "-" | 504 "-" |
489 )}`; | 505 )}`; |
490 if (this.selectedSurvey) { | 506 if (this.selectedSurvey) { |