annotate client/src/components/Pdftool.vue @ 5627:7768f14f6535 729-node-js-newer-version

Transformed scss variables into css custom properties
author Luisa Beerboom <lbeerboom@intevation.de>
date Tue, 09 May 2023 13:17:58 +0200
parents 3b842e951317
children 84d01a536bec
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
1272
bc55ffaeb639 cleaned up client/src directory
Markus Kottlaender <markus@intevation.de>
parents:
diff changeset
1 <template>
1480
9b81ac91a43e fix: linting
Thomas Junk <thomas.junk@intevation.de>
parents: 1433
diff changeset
2 <div
9b81ac91a43e fix: linting
Thomas Junk <thomas.junk@intevation.de>
parents: 1433
diff changeset
3 :class="[
9b81ac91a43e fix: linting
Thomas Junk <thomas.junk@intevation.de>
parents: 1433
diff changeset
4 'box ui-element rounded bg-white text-nowrap',
9b81ac91a43e fix: linting
Thomas Junk <thomas.junk@intevation.de>
parents: 1433
diff changeset
5 { expanded: showPdfTool }
9b81ac91a43e fix: linting
Thomas Junk <thomas.junk@intevation.de>
parents: 1433
diff changeset
6 ]"
9b81ac91a43e fix: linting
Thomas Junk <thomas.junk@intevation.de>
parents: 1433
diff changeset
7 >
4981
9f0830a1845d squashed the total layout to enable display of long fm importnames
Thomas Junk <thomas.junk@intevation.de>
parents: 4869
diff changeset
8 <div style="width: 17rem">
2387
f185503ef35a client: unified box's header styles by creating a reusable component
Markus Kottlaender <markus@intevation.de>
parents: 2376
diff changeset
9 <UIBoxHeader
f185503ef35a client: unified box's header styles by creating a reusable component
Markus Kottlaender <markus@intevation.de>
parents: 2376
diff changeset
10 icon="file-pdf"
2754
d0f6c222f4f9 client:correct a set of strings marking
Fadi Abbud <fadi.abbud@intevation.de>
parents: 2737
diff changeset
11 :title="generatePdfLable"
2387
f185503ef35a client: unified box's header styles by creating a reusable component
Markus Kottlaender <markus@intevation.de>
parents: 2376
diff changeset
12 :closeCallback="close"
f185503ef35a client: unified box's header styles by creating a reusable component
Markus Kottlaender <markus@intevation.de>
parents: 2376
diff changeset
13 />
2534
bb5286acfee2 client: reduced spacings between and inside boxes and more compact main menu
Markus Kottlaender <markus@intevation.de>
parents: 2387
diff changeset
14 <div class="box-body">
2114
910c21ea531a linting
Thomas Junk <thomas.junk@intevation.de>
parents: 2112
diff changeset
15 <select
910c21ea531a linting
Thomas Junk <thomas.junk@intevation.de>
parents: 2112
diff changeset
16 @change="applyTemplateToForm"
910c21ea531a linting
Thomas Junk <thomas.junk@intevation.de>
parents: 2112
diff changeset
17 v-model="form.template"
910c21ea531a linting
Thomas Junk <thomas.junk@intevation.de>
parents: 2112
diff changeset
18 class="form-control d-block mb-2 w-100 font-weight-bold"
910c21ea531a linting
Thomas Junk <thomas.junk@intevation.de>
parents: 2112
diff changeset
19 >
2124
af136b1a854e linting
Markus Kottlaender <markus@intevation.de>
parents: 2114
diff changeset
20 <option
2257
ce6fd3d4a3a2 client: pdf-gen: moved template handling from store to components
Markus Kottlaender <markus@intevation.de>
parents: 2247
diff changeset
21 v-for="template in templates"
2214
5a4b0c85e7a8 values in template select are now the actual objects
Markus Kottlaender <markus@intevation.de>
parents: 2212
diff changeset
22 :value="template"
2124
af136b1a854e linting
Markus Kottlaender <markus@intevation.de>
parents: 2114
diff changeset
23 :key="template.name"
2114
910c21ea531a linting
Thomas Junk <thomas.junk@intevation.de>
parents: 2112
diff changeset
24 >
2754
d0f6c222f4f9 client:correct a set of strings marking
Fadi Abbud <fadi.abbud@intevation.de>
parents: 2737
diff changeset
25 {{ template.name }}
2124
af136b1a854e linting
Markus Kottlaender <markus@intevation.de>
parents: 2114
diff changeset
26 </option>
2112
8c0a0f237c2d improved behavior of pdf generation form
Markus Kottlaender <markus@intevation.de>
parents: 2111
diff changeset
27 </select>
2114
910c21ea531a linting
Thomas Junk <thomas.junk@intevation.de>
parents: 2112
diff changeset
28 <select
910c21ea531a linting
Thomas Junk <thomas.junk@intevation.de>
parents: 2112
diff changeset
29 v-model="form.format"
910c21ea531a linting
Thomas Junk <thomas.junk@intevation.de>
parents: 2112
diff changeset
30 class="form-control form-control-sm d-block mb-2 w-100"
910c21ea531a linting
Thomas Junk <thomas.junk@intevation.de>
parents: 2112
diff changeset
31 >
1635
ca48145dba9c client: improve pdf generation
Bernhard Reiter <bernhard@intevation.de>
parents: 1613
diff changeset
32 <option value="landscape"><translate>landscape</translate></option>
ca48145dba9c client: improve pdf generation
Bernhard Reiter <bernhard@intevation.de>
parents: 1613
diff changeset
33 <option value="portrait"><translate>portrait</translate></option>
ca48145dba9c client: improve pdf generation
Bernhard Reiter <bernhard@intevation.de>
parents: 1613
diff changeset
34 </select>
2112
8c0a0f237c2d improved behavior of pdf generation form
Markus Kottlaender <markus@intevation.de>
parents: 2111
diff changeset
35 <div class="d-flex">
8c0a0f237c2d improved behavior of pdf generation form
Markus Kottlaender <markus@intevation.de>
parents: 2111
diff changeset
36 <div class="flex-fill mr-2">
2114
910c21ea531a linting
Thomas Junk <thomas.junk@intevation.de>
parents: 2112
diff changeset
37 <select
910c21ea531a linting
Thomas Junk <thomas.junk@intevation.de>
parents: 2112
diff changeset
38 v-model="form.resolution"
910c21ea531a linting
Thomas Junk <thomas.junk@intevation.de>
parents: 2112
diff changeset
39 class="form-control form-control-sm mb-2 d-block w-100"
910c21ea531a linting
Thomas Junk <thomas.junk@intevation.de>
parents: 2112
diff changeset
40 >
2225
bc1780dd7cd1 PDF generation: changed option names in resolution select
Markus Kottlaender <markus@intevation.de>
parents: 2224
diff changeset
41 <option value="80"><translate>80 dpi</translate></option>
bc1780dd7cd1 PDF generation: changed option names in resolution select
Markus Kottlaender <markus@intevation.de>
parents: 2224
diff changeset
42 <option value="120"><translate>120 dpi</translate></option>
bc1780dd7cd1 PDF generation: changed option names in resolution select
Markus Kottlaender <markus@intevation.de>
parents: 2224
diff changeset
43 <option value="200"><translate>200 dpi</translate></option>
2112
8c0a0f237c2d improved behavior of pdf generation form
Markus Kottlaender <markus@intevation.de>
parents: 2111
diff changeset
44 </select>
8c0a0f237c2d improved behavior of pdf generation form
Markus Kottlaender <markus@intevation.de>
parents: 2111
diff changeset
45 </div>
8c0a0f237c2d improved behavior of pdf generation form
Markus Kottlaender <markus@intevation.de>
parents: 2111
diff changeset
46 <div class="flex-fill ml-2">
2114
910c21ea531a linting
Thomas Junk <thomas.junk@intevation.de>
parents: 2112
diff changeset
47 <select
910c21ea531a linting
Thomas Junk <thomas.junk@intevation.de>
parents: 2112
diff changeset
48 v-model="form.paperSize"
910c21ea531a linting
Thomas Junk <thomas.junk@intevation.de>
parents: 2112
diff changeset
49 class="form-control form-control-sm mb-2 d-block w-100"
910c21ea531a linting
Thomas Junk <thomas.junk@intevation.de>
parents: 2112
diff changeset
50 >
2220
d926292d81b6 PDF generation: changed form labels/option texts
Markus Kottlaender <markus@intevation.de>
parents: 2219
diff changeset
51 <option value="a4"><translate>A4</translate></option>
d926292d81b6 PDF generation: changed form labels/option texts
Markus Kottlaender <markus@intevation.de>
parents: 2219
diff changeset
52 <option value="a3"><translate>A3</translate></option>
2112
8c0a0f237c2d improved behavior of pdf generation form
Markus Kottlaender <markus@intevation.de>
parents: 2111
diff changeset
53 </select>
8c0a0f237c2d improved behavior of pdf generation form
Markus Kottlaender <markus@intevation.de>
parents: 2111
diff changeset
54 </div>
8c0a0f237c2d improved behavior of pdf generation form
Markus Kottlaender <markus@intevation.de>
parents: 2111
diff changeset
55 </div>
4034
917c72e8360d client: pdf-gen: implement basic print scaling
Fadi Abbud <fadi.abbud@intevation.de>
parents: 3993
diff changeset
56 <div class="d-flex flex-fill-row">
917c72e8360d client: pdf-gen: implement basic print scaling
Fadi Abbud <fadi.abbud@intevation.de>
parents: 3993
diff changeset
57 <small class="my-auto text-muted">
917c72e8360d client: pdf-gen: implement basic print scaling
Fadi Abbud <fadi.abbud@intevation.de>
parents: 3993
diff changeset
58 <translate>Scale to 1:</translate>
917c72e8360d client: pdf-gen: implement basic print scaling
Fadi Abbud <fadi.abbud@intevation.de>
parents: 3993
diff changeset
59 </small>
917c72e8360d client: pdf-gen: implement basic print scaling
Fadi Abbud <fadi.abbud@intevation.de>
parents: 3993
diff changeset
60 <input
917c72e8360d client: pdf-gen: implement basic print scaling
Fadi Abbud <fadi.abbud@intevation.de>
parents: 3993
diff changeset
61 class="form-control form-control-sm w-100 ml-2"
5282
12e2422ae57c Show current scale dominator as placeholder in PDF export [ci by swilde]
Fadi Abbud <fadi.abbud@intevation.de>
parents: 5265
diff changeset
62 :placeholder="scalePlaceholder"
4034
917c72e8360d client: pdf-gen: implement basic print scaling
Fadi Abbud <fadi.abbud@intevation.de>
parents: 3993
diff changeset
63 v-model.number="form.scale"
917c72e8360d client: pdf-gen: implement basic print scaling
Fadi Abbud <fadi.abbud@intevation.de>
parents: 3993
diff changeset
64 type="number"
917c72e8360d client: pdf-gen: implement basic print scaling
Fadi Abbud <fadi.abbud@intevation.de>
parents: 3993
diff changeset
65 />
917c72e8360d client: pdf-gen: implement basic print scaling
Fadi Abbud <fadi.abbud@intevation.de>
parents: 3993
diff changeset
66 </div>
1361
ea3a89a1813a remove trailing whitespace, add headers for Makefile, add the missed authors
Fadi Abbud <fadi.abbud@intevation.de>
parents: 1299
diff changeset
67 <button
ea3a89a1813a remove trailing whitespace, add headers for Makefile, add the missed authors
Fadi Abbud <fadi.abbud@intevation.de>
parents: 1299
diff changeset
68 @click="download"
2275
a6cfa06c5983 client: pdf-gen: added cancel button
Markus Kottlaender <markus@intevation.de>
parents: 2265
diff changeset
69 :key="'downloadBtn'"
1361
ea3a89a1813a remove trailing whitespace, add headers for Makefile, add the missed authors
Fadi Abbud <fadi.abbud@intevation.de>
parents: 1299
diff changeset
70 type="button"
2275
a6cfa06c5983 client: pdf-gen: added cancel button
Markus Kottlaender <markus@intevation.de>
parents: 2265
diff changeset
71 v-if="readyToGenerate"
2112
8c0a0f237c2d improved behavior of pdf generation form
Markus Kottlaender <markus@intevation.de>
parents: 2111
diff changeset
72 class="btn btn-sm btn-info d-block w-100 mt-2"
5264
528fa710650b client: disable PDF Generation button while layers still loading
Fadi Abbud <fadi.abbud@intevation.de>
parents: 5175
diff changeset
73 :disabled="sourcesLoading > 0"
1480
9b81ac91a43e fix: linting
Thomas Junk <thomas.junk@intevation.de>
parents: 1433
diff changeset
74 >
9b81ac91a43e fix: linting
Thomas Junk <thomas.junk@intevation.de>
parents: 1433
diff changeset
75 <translate>Generate PDF</translate>
9b81ac91a43e fix: linting
Thomas Junk <thomas.junk@intevation.de>
parents: 1433
diff changeset
76 </button>
2275
a6cfa06c5983 client: pdf-gen: added cancel button
Markus Kottlaender <markus@intevation.de>
parents: 2265
diff changeset
77 <button
a6cfa06c5983 client: pdf-gen: added cancel button
Markus Kottlaender <markus@intevation.de>
parents: 2265
diff changeset
78 @click="cancel"
a6cfa06c5983 client: pdf-gen: added cancel button
Markus Kottlaender <markus@intevation.de>
parents: 2265
diff changeset
79 :key="'cancelBtn'"
a6cfa06c5983 client: pdf-gen: added cancel button
Markus Kottlaender <markus@intevation.de>
parents: 2265
diff changeset
80 type="button"
a6cfa06c5983 client: pdf-gen: added cancel button
Markus Kottlaender <markus@intevation.de>
parents: 2265
diff changeset
81 v-else
a6cfa06c5983 client: pdf-gen: added cancel button
Markus Kottlaender <markus@intevation.de>
parents: 2265
diff changeset
82 class="btn btn-sm btn-danger d-block w-100 mt-2"
a6cfa06c5983 client: pdf-gen: added cancel button
Markus Kottlaender <markus@intevation.de>
parents: 2265
diff changeset
83 >
a6cfa06c5983 client: pdf-gen: added cancel button
Markus Kottlaender <markus@intevation.de>
parents: 2265
diff changeset
84 <font-awesome-icon class="mr-1" icon="spinner" spin />
a6cfa06c5983 client: pdf-gen: added cancel button
Markus Kottlaender <markus@intevation.de>
parents: 2265
diff changeset
85 <translate>Cancel</translate>
a6cfa06c5983 client: pdf-gen: added cancel button
Markus Kottlaender <markus@intevation.de>
parents: 2265
diff changeset
86 </button>
1361
ea3a89a1813a remove trailing whitespace, add headers for Makefile, add the missed authors
Fadi Abbud <fadi.abbud@intevation.de>
parents: 1299
diff changeset
87 </div>
1272
bc55ffaeb639 cleaned up client/src directory
Markus Kottlaender <markus@intevation.de>
parents:
diff changeset
88 </div>
1361
ea3a89a1813a remove trailing whitespace, add headers for Makefile, add the missed authors
Fadi Abbud <fadi.abbud@intevation.de>
parents: 1299
diff changeset
89 </div>
1272
bc55ffaeb639 cleaned up client/src directory
Markus Kottlaender <markus@intevation.de>
parents:
diff changeset
90 </template>
bc55ffaeb639 cleaned up client/src directory
Markus Kottlaender <markus@intevation.de>
parents:
diff changeset
91
3202
7c59955fbcca dialogs: styling
Thomas Junk <thomas.junk@intevation.de>
parents: 3127
diff changeset
92 <style lang="scss" scoped>
7c59955fbcca dialogs: styling
Thomas Junk <thomas.junk@intevation.de>
parents: 3127
diff changeset
93 input,
7c59955fbcca dialogs: styling
Thomas Junk <thomas.junk@intevation.de>
parents: 3127
diff changeset
94 select {
7c59955fbcca dialogs: styling
Thomas Junk <thomas.junk@intevation.de>
parents: 3127
diff changeset
95 font-size: 0.8em;
7c59955fbcca dialogs: styling
Thomas Junk <thomas.junk@intevation.de>
parents: 3127
diff changeset
96 }
7c59955fbcca dialogs: styling
Thomas Junk <thomas.junk@intevation.de>
parents: 3127
diff changeset
97 </style>
7c59955fbcca dialogs: styling
Thomas Junk <thomas.junk@intevation.de>
parents: 3127
diff changeset
98
1272
bc55ffaeb639 cleaned up client/src directory
Markus Kottlaender <markus@intevation.de>
parents:
diff changeset
99 <script>
1362
ca33ad696594 remove the first empyty lines
Fadi Abbud <fadi.abbud@intevation.de>
parents: 1361
diff changeset
100 /* This is Free Software under GNU Affero General Public License v >= 3.0
1272
bc55ffaeb639 cleaned up client/src directory
Markus Kottlaender <markus@intevation.de>
parents:
diff changeset
101 * without warranty, see README.md and license for details.
1361
ea3a89a1813a remove trailing whitespace, add headers for Makefile, add the missed authors
Fadi Abbud <fadi.abbud@intevation.de>
parents: 1299
diff changeset
102 *
1272
bc55ffaeb639 cleaned up client/src directory
Markus Kottlaender <markus@intevation.de>
parents:
diff changeset
103 * SPDX-License-Identifier: AGPL-3.0-or-later
bc55ffaeb639 cleaned up client/src directory
Markus Kottlaender <markus@intevation.de>
parents:
diff changeset
104 * License-Filename: LICENSES/AGPL-3.0.txt
1361
ea3a89a1813a remove trailing whitespace, add headers for Makefile, add the missed authors
Fadi Abbud <fadi.abbud@intevation.de>
parents: 1299
diff changeset
105 *
1878
f030182f82f1 client: fix style warning for pdfexport
Bernhard Reiter <bernhard@intevation.de>
parents: 1876
diff changeset
106 * Copyright (C) 2018, 2019 by via donau
1272
bc55ffaeb639 cleaned up client/src directory
Markus Kottlaender <markus@intevation.de>
parents:
diff changeset
107 * – Österreichische Wasserstraßen-Gesellschaft mbH
bc55ffaeb639 cleaned up client/src directory
Markus Kottlaender <markus@intevation.de>
parents:
diff changeset
108 * Software engineering by Intevation GmbH
1361
ea3a89a1813a remove trailing whitespace, add headers for Makefile, add the missed authors
Fadi Abbud <fadi.abbud@intevation.de>
parents: 1299
diff changeset
109 *
1272
bc55ffaeb639 cleaned up client/src directory
Markus Kottlaender <markus@intevation.de>
parents:
diff changeset
110 * Author(s):
1635
ca48145dba9c client: improve pdf generation
Bernhard Reiter <bernhard@intevation.de>
parents: 1613
diff changeset
111 * * Markus Kottländer <markus.kottlaender@intevation.de>
ca48145dba9c client: improve pdf generation
Bernhard Reiter <bernhard@intevation.de>
parents: 1613
diff changeset
112 * * Bernhard E. Reiter <bernhard@intevation.de>
1878
f030182f82f1 client: fix style warning for pdfexport
Bernhard Reiter <bernhard@intevation.de>
parents: 1876
diff changeset
113 * * Fadi Abbud <fadi.abbud@intevation.de>
1272
bc55ffaeb639 cleaned up client/src directory
Markus Kottlaender <markus@intevation.de>
parents:
diff changeset
114 */
3044
c71373594719 client: map: prepared store to hold multiple map objects
Markus Kottlaender <markus@intevation.de>
parents: 3006
diff changeset
115 import { mapState, mapGetters } from "vuex";
3780
2b6734a6730a include svg2pdf. substitute upstream jsdpf with yworks-fork
Thomas Junk <thomas.junk@intevation.de>
parents: 3408
diff changeset
116 import jsPDF from "jspdf-yworks";
2985
1b8bb4f89227 client: removed .js and .vue extention from imports
Markus Kottlaender <markus@intevation.de>
parents: 2959
diff changeset
117 import "@/lib/font-linbiolinum";
1b8bb4f89227 client: removed .js and .vue extention from imports
Markus Kottlaender <markus@intevation.de>
parents: 2959
diff changeset
118 import { getPointResolution } from "ol/proj";
2947
a6eea3002e6e client: cleanup import paths
Fadi Abbud <fadi.abbud@intevation.de>
parents: 2767
diff changeset
119 import { HTTP } from "@/lib/http";
2985
1b8bb4f89227 client: removed .js and .vue extention from imports
Markus Kottlaender <markus@intevation.de>
parents: 2959
diff changeset
120 import { displayError } from "@/lib/errors";
3802
e8a950cf6c02 Move Template loading and Imageprocessing to mixin
Thomas Junk <thomas.junk@intevation.de>
parents: 3790
diff changeset
121 import { pdfgen, templateLoader } from "@/lib/mixins";
4473
3543af71d04c client: pdf-gen: improve file naming for the exported pdf
Fadi Abbud <fadi.abbud@intevation.de>
parents: 4454
diff changeset
122 import sanitize from "sanitize-filename";
5172
d750fb514a82 first draft for SR-detection
Thomas Junk <thomas.junk@intevation.de>
parents: 4981
diff changeset
123 import { WFS } from "ol/format";
5174
b73e8cc494f6 limit to selected survey
Thomas Junk <thomas.junk@intevation.de>
parents: 5173
diff changeset
124 import { equalTo as equalToFilter } from "ol/format/filter";
5175
6038f782e51d client: Improve detecting of bottleneck for pdf-generation
Fadi Abbud <fadi.abbud@intevation.de>
parents: 5174
diff changeset
125 import { intersects } from "ol/extent";
1272
bc55ffaeb639 cleaned up client/src directory
Markus Kottlaender <markus@intevation.de>
parents:
diff changeset
126
3840
387f239018c7 pdf_tool: retain default template, when custom template is uploaded
Thomas Junk <thomas.junk@intevation.de>
parents: 3802
diff changeset
127 const paperSizes = {
1635
ca48145dba9c client: improve pdf generation
Bernhard Reiter <bernhard@intevation.de>
parents: 1613
diff changeset
128 // in millimeter, landscape [width, height]
ca48145dba9c client: improve pdf generation
Bernhard Reiter <bernhard@intevation.de>
parents: 1613
diff changeset
129 a3: [420, 297],
ca48145dba9c client: improve pdf generation
Bernhard Reiter <bernhard@intevation.de>
parents: 1613
diff changeset
130 a4: [297, 210]
ca48145dba9c client: improve pdf generation
Bernhard Reiter <bernhard@intevation.de>
parents: 1613
diff changeset
131 };
ca48145dba9c client: improve pdf generation
Bernhard Reiter <bernhard@intevation.de>
parents: 1613
diff changeset
132
3840
387f239018c7 pdf_tool: retain default template, when custom template is uploaded
Thomas Junk <thomas.junk@intevation.de>
parents: 3802
diff changeset
133 const DEFAULT_TEMPLATE = "Default";
387f239018c7 pdf_tool: retain default template, when custom template is uploaded
Thomas Junk <thomas.junk@intevation.de>
parents: 3802
diff changeset
134
1272
bc55ffaeb639 cleaned up client/src directory
Markus Kottlaender <markus@intevation.de>
parents:
diff changeset
135 export default {
3802
e8a950cf6c02 Move Template loading and Imageprocessing to mixin
Thomas Junk <thomas.junk@intevation.de>
parents: 3790
diff changeset
136 mixins: [pdfgen, templateLoader],
1272
bc55ffaeb639 cleaned up client/src directory
Markus Kottlaender <markus@intevation.de>
parents:
diff changeset
137 name: "pdftool",
bc55ffaeb639 cleaned up client/src directory
Markus Kottlaender <markus@intevation.de>
parents:
diff changeset
138 data() {
bc55ffaeb639 cleaned up client/src directory
Markus Kottlaender <markus@intevation.de>
parents:
diff changeset
139 return {
bc55ffaeb639 cleaned up client/src directory
Markus Kottlaender <markus@intevation.de>
parents:
diff changeset
140 form: {
2112
8c0a0f237c2d improved behavior of pdf generation form
Markus Kottlaender <markus@intevation.de>
parents: 2111
diff changeset
141 template: null,
1272
bc55ffaeb639 cleaned up client/src directory
Markus Kottlaender <markus@intevation.de>
parents:
diff changeset
142 format: "landscape",
1635
ca48145dba9c client: improve pdf generation
Bernhard Reiter <bernhard@intevation.de>
parents: 1613
diff changeset
143 paperSize: "a4",
1881
f512cfb63e53 pdf-generation: add select box to pdf tool to choose the resolutions
Fadi Abbud <fadi.abbud@intevation.de>
parents: 1879
diff changeset
144 downloadType: "download",
4034
917c72e8360d client: pdf-gen: implement basic print scaling
Fadi Abbud <fadi.abbud@intevation.de>
parents: 3993
diff changeset
145 resolution: "80",
917c72e8360d client: pdf-gen: implement basic print scaling
Fadi Abbud <fadi.abbud@intevation.de>
parents: 3993
diff changeset
146 scale: null
1947
4235fa8f59d7 clien: pdf-gen: load logo externally; add prepare step
Bernhard Reiter <bernhard@intevation.de>
parents: 1936
diff changeset
147 },
2265
940ae7c20326 client: pdf-gen: use default template when backend does not provide any
Markus Kottlaender <markus@intevation.de>
parents: 2260
diff changeset
148 templates: [
940ae7c20326 client: pdf-gen: use default template when backend does not provide any
Markus Kottlaender <markus@intevation.de>
parents: 2260
diff changeset
149 {
3840
387f239018c7 pdf_tool: retain default template, when custom template is uploaded
Thomas Junk <thomas.junk@intevation.de>
parents: 3802
diff changeset
150 name: DEFAULT_TEMPLATE,
2265
940ae7c20326 client: pdf-gen: use default template when backend does not provide any
Markus Kottlaender <markus@intevation.de>
parents: 2260
diff changeset
151 properties: {
940ae7c20326 client: pdf-gen: use default template when backend does not provide any
Markus Kottlaender <markus@intevation.de>
parents: 2260
diff changeset
152 format: "landscape",
940ae7c20326 client: pdf-gen: use default template when backend does not provide any
Markus Kottlaender <markus@intevation.de>
parents: 2260
diff changeset
153 paperSize: "a4",
940ae7c20326 client: pdf-gen: use default template when backend does not provide any
Markus Kottlaender <markus@intevation.de>
parents: 2260
diff changeset
154 resolution: "80"
940ae7c20326 client: pdf-gen: use default template when backend does not provide any
Markus Kottlaender <markus@intevation.de>
parents: 2260
diff changeset
155 },
940ae7c20326 client: pdf-gen: use default template when backend does not provide any
Markus Kottlaender <markus@intevation.de>
parents: 2260
diff changeset
156 elements: [
940ae7c20326 client: pdf-gen: use default template when backend does not provide any
Markus Kottlaender <markus@intevation.de>
parents: 2260
diff changeset
157 {
940ae7c20326 client: pdf-gen: use default template when backend does not provide any
Markus Kottlaender <markus@intevation.de>
parents: 2260
diff changeset
158 type: "scalebar",
940ae7c20326 client: pdf-gen: use default template when backend does not provide any
Markus Kottlaender <markus@intevation.de>
parents: 2260
diff changeset
159 position: "bottomright",
4480
004d08038319 client: pdf-gen: add bottleneck info to default template and improve it
Fadi Abbud <fadi.abbud@intevation.de>
parents: 4473
diff changeset
160 offset: { x: 1, y: 1 }
2265
940ae7c20326 client: pdf-gen: use default template when backend does not provide any
Markus Kottlaender <markus@intevation.de>
parents: 2260
diff changeset
161 },
940ae7c20326 client: pdf-gen: use default template when backend does not provide any
Markus Kottlaender <markus@intevation.de>
parents: 2260
diff changeset
162 {
940ae7c20326 client: pdf-gen: use default template when backend does not provide any
Markus Kottlaender <markus@intevation.de>
parents: 2260
diff changeset
163 type: "textbox",
940ae7c20326 client: pdf-gen: use default template when backend does not provide any
Markus Kottlaender <markus@intevation.de>
parents: 2260
diff changeset
164 position: "bottomleft",
4480
004d08038319 client: pdf-gen: add bottleneck info to default template and improve it
Fadi Abbud <fadi.abbud@intevation.de>
parents: 4473
diff changeset
165 offset: { x: 1, y: 1 },
2265
940ae7c20326 client: pdf-gen: use default template when backend does not provide any
Markus Kottlaender <markus@intevation.de>
parents: 2260
diff changeset
166 fontSize: 8,
2284
9f327f197ddd client: translation: mark some strings for translations
Fadi Abbud <fadi.abbud@intevation.de>
parents: 2275
diff changeset
167 text: this.$gettext("Generated by") + " " + "{user}, {date}"
2265
940ae7c20326 client: pdf-gen: use default template when backend does not provide any
Markus Kottlaender <markus@intevation.de>
parents: 2260
diff changeset
168 },
940ae7c20326 client: pdf-gen: use default template when backend does not provide any
Markus Kottlaender <markus@intevation.de>
parents: 2260
diff changeset
169 {
940ae7c20326 client: pdf-gen: use default template when backend does not provide any
Markus Kottlaender <markus@intevation.de>
parents: 2260
diff changeset
170 type: "northarrow",
3840
387f239018c7 pdf_tool: retain default template, when custom template is uploaded
Thomas Junk <thomas.junk@intevation.de>
parents: 3802
diff changeset
171 position: "topleft",
2265
940ae7c20326 client: pdf-gen: use default template when backend does not provide any
Markus Kottlaender <markus@intevation.de>
parents: 2260
diff changeset
172 offset: { x: 6, y: 4 },
940ae7c20326 client: pdf-gen: use default template when backend does not provide any
Markus Kottlaender <markus@intevation.de>
parents: 2260
diff changeset
173 size: 2
4480
004d08038319 client: pdf-gen: add bottleneck info to default template and improve it
Fadi Abbud <fadi.abbud@intevation.de>
parents: 4473
diff changeset
174 },
004d08038319 client: pdf-gen: add bottleneck info to default template and improve it
Fadi Abbud <fadi.abbud@intevation.de>
parents: 4473
diff changeset
175 {
004d08038319 client: pdf-gen: add bottleneck info to default template and improve it
Fadi Abbud <fadi.abbud@intevation.de>
parents: 4473
diff changeset
176 type: "bottleneck",
004d08038319 client: pdf-gen: add bottleneck info to default template and improve it
Fadi Abbud <fadi.abbud@intevation.de>
parents: 4473
diff changeset
177 position: "topright",
004d08038319 client: pdf-gen: add bottleneck info to default template and improve it
Fadi Abbud <fadi.abbud@intevation.de>
parents: 4473
diff changeset
178 offset: { x: 2, y: 2 }
004d08038319 client: pdf-gen: add bottleneck info to default template and improve it
Fadi Abbud <fadi.abbud@intevation.de>
parents: 4473
diff changeset
179 },
004d08038319 client: pdf-gen: add bottleneck info to default template and improve it
Fadi Abbud <fadi.abbud@intevation.de>
parents: 4473
diff changeset
180 {
004d08038319 client: pdf-gen: add bottleneck info to default template and improve it
Fadi Abbud <fadi.abbud@intevation.de>
parents: 4473
diff changeset
181 type: "legend",
004d08038319 client: pdf-gen: add bottleneck info to default template and improve it
Fadi Abbud <fadi.abbud@intevation.de>
parents: 4473
diff changeset
182 position: "topright",
004d08038319 client: pdf-gen: add bottleneck info to default template and improve it
Fadi Abbud <fadi.abbud@intevation.de>
parents: 4473
diff changeset
183 offset: { x: 2, y: 25 }
2265
940ae7c20326 client: pdf-gen: use default template when backend does not provide any
Markus Kottlaender <markus@intevation.de>
parents: 2260
diff changeset
184 }
940ae7c20326 client: pdf-gen: use default template when backend does not provide any
Markus Kottlaender <markus@intevation.de>
parents: 2260
diff changeset
185 ]
940ae7c20326 client: pdf-gen: use default template when backend does not provide any
Markus Kottlaender <markus@intevation.de>
parents: 2260
diff changeset
186 }
940ae7c20326 client: pdf-gen: use default template when backend does not provide any
Markus Kottlaender <markus@intevation.de>
parents: 2260
diff changeset
187 ],
2247
e6fba449aa3c merged pdf-export in default
Markus Kottlaender <markus@intevation.de>
parents: 2240
diff changeset
188 templateData: null,
2218
631ca0412db9 adjusted positioning of pdf elements
Markus Kottlaender <markus@intevation.de>
parents: 2215
diff changeset
189 pdf: {
631ca0412db9 adjusted positioning of pdf elements
Markus Kottlaender <markus@intevation.de>
parents: 2215
diff changeset
190 doc: null,
631ca0412db9 adjusted positioning of pdf elements
Markus Kottlaender <markus@intevation.de>
parents: 2215
diff changeset
191 width: null,
631ca0412db9 adjusted positioning of pdf elements
Markus Kottlaender <markus@intevation.de>
parents: 2215
diff changeset
192 height: null
631ca0412db9 adjusted positioning of pdf elements
Markus Kottlaender <markus@intevation.de>
parents: 2215
diff changeset
193 },
1947
4235fa8f59d7 clien: pdf-gen: load logo externally; add prepare step
Bernhard Reiter <bernhard@intevation.de>
parents: 1936
diff changeset
194 logoImageForPDF: null, // a HTMLImageElement instance
2275
a6cfa06c5983 client: pdf-gen: added cancel button
Markus Kottlaender <markus@intevation.de>
parents: 2265
diff changeset
195 readyToGenerate: true, // if the user is allowed to press the button
a6cfa06c5983 client: pdf-gen: added cancel button
Markus Kottlaender <markus@intevation.de>
parents: 2265
diff changeset
196 rendercompleteListener: null,
a6cfa06c5983 client: pdf-gen: added cancel button
Markus Kottlaender <markus@intevation.de>
parents: 2265
diff changeset
197 mapSize: null,
3980
7316b7e8246f improve PDFTool
Thomas Junk <thomas.junk@intevation.de>
parents: 3960
diff changeset
198 resolution: null
1272
bc55ffaeb639 cleaned up client/src directory
Markus Kottlaender <markus@intevation.de>
parents:
diff changeset
199 };
bc55ffaeb639 cleaned up client/src directory
Markus Kottlaender <markus@intevation.de>
parents:
diff changeset
200 },
bc55ffaeb639 cleaned up client/src directory
Markus Kottlaender <markus@intevation.de>
parents:
diff changeset
201 computed: {
2257
ce6fd3d4a3a2 client: pdf-gen: moved template handling from store to components
Markus Kottlaender <markus@intevation.de>
parents: 2247
diff changeset
202 ...mapState("application", ["showPdfTool", "logoForPDF"]),
4488
bff6c5c1db4f client: pdf-gen: improve adding bottleneck info to pdf
Fadi Abbud <fadi.abbud@intevation.de>
parents: 4480
diff changeset
203 ...mapState("bottlenecks", [
bff6c5c1db4f client: pdf-gen: improve adding bottleneck info to pdf
Fadi Abbud <fadi.abbud@intevation.de>
parents: 4480
diff changeset
204 "selectedBottleneck",
bff6c5c1db4f client: pdf-gen: improve adding bottleneck info to pdf
Fadi Abbud <fadi.abbud@intevation.de>
parents: 4480
diff changeset
205 "selectedSurvey",
bff6c5c1db4f client: pdf-gen: improve adding bottleneck info to pdf
Fadi Abbud <fadi.abbud@intevation.de>
parents: 4480
diff changeset
206 "bottleneckForPrint"
bff6c5c1db4f client: pdf-gen: improve adding bottleneck info to pdf
Fadi Abbud <fadi.abbud@intevation.de>
parents: 4480
diff changeset
207 ]),
5264
528fa710650b client: disable PDF Generation button while layers still loading
Fadi Abbud <fadi.abbud@intevation.de>
parents: 5175
diff changeset
208 ...mapState("map", ["isolinesLegendImgDataURL", "openLayersMaps"]),
3044
c71373594719 client: map: prepared store to hold multiple map objects
Markus Kottlaender <markus@intevation.de>
parents: 3006
diff changeset
209 ...mapGetters("map", ["openLayersMap"]),
2754
d0f6c222f4f9 client:correct a set of strings marking
Fadi Abbud <fadi.abbud@intevation.de>
parents: 2737
diff changeset
210 generatePdfLable() {
d0f6c222f4f9 client:correct a set of strings marking
Fadi Abbud <fadi.abbud@intevation.de>
parents: 2737
diff changeset
211 return this.$gettext("Generate PDF");
5264
528fa710650b client: disable PDF Generation button while layers still loading
Fadi Abbud <fadi.abbud@intevation.de>
parents: 5175
diff changeset
212 },
528fa710650b client: disable PDF Generation button while layers still loading
Fadi Abbud <fadi.abbud@intevation.de>
parents: 5175
diff changeset
213 sourcesLoading() {
528fa710650b client: disable PDF Generation button while layers still loading
Fadi Abbud <fadi.abbud@intevation.de>
parents: 5175
diff changeset
214 let counter = 0;
528fa710650b client: disable PDF Generation button while layers still loading
Fadi Abbud <fadi.abbud@intevation.de>
parents: 5175
diff changeset
215 this.openLayersMaps.forEach(map => {
528fa710650b client: disable PDF Generation button while layers still loading
Fadi Abbud <fadi.abbud@intevation.de>
parents: 5175
diff changeset
216 let layers = map.getLayers().getArray();
528fa710650b client: disable PDF Generation button while layers still loading
Fadi Abbud <fadi.abbud@intevation.de>
parents: 5175
diff changeset
217 for (let i = 0; i < layers.length; i++) {
528fa710650b client: disable PDF Generation button while layers still loading
Fadi Abbud <fadi.abbud@intevation.de>
parents: 5175
diff changeset
218 if (layers[i].getSource().loading) counter++;
528fa710650b client: disable PDF Generation button while layers still loading
Fadi Abbud <fadi.abbud@intevation.de>
parents: 5175
diff changeset
219 }
528fa710650b client: disable PDF Generation button while layers still loading
Fadi Abbud <fadi.abbud@intevation.de>
parents: 5175
diff changeset
220 });
528fa710650b client: disable PDF Generation button while layers still loading
Fadi Abbud <fadi.abbud@intevation.de>
parents: 5175
diff changeset
221 return counter;
5282
12e2422ae57c Show current scale dominator as placeholder in PDF export [ci by swilde]
Fadi Abbud <fadi.abbud@intevation.de>
parents: 5265
diff changeset
222 },
12e2422ae57c Show current scale dominator as placeholder in PDF export [ci by swilde]
Fadi Abbud <fadi.abbud@intevation.de>
parents: 5265
diff changeset
223 scalePlaceholder() {
12e2422ae57c Show current scale dominator as placeholder in PDF export [ci by swilde]
Fadi Abbud <fadi.abbud@intevation.de>
parents: 5265
diff changeset
224 if (typeof this.openLayersMap() !== "undefined") {
12e2422ae57c Show current scale dominator as placeholder in PDF export [ci by swilde]
Fadi Abbud <fadi.abbud@intevation.de>
parents: 5265
diff changeset
225 return this.calculateScaleDenominator();
12e2422ae57c Show current scale dominator as placeholder in PDF export [ci by swilde]
Fadi Abbud <fadi.abbud@intevation.de>
parents: 5265
diff changeset
226 } else {
12e2422ae57c Show current scale dominator as placeholder in PDF export [ci by swilde]
Fadi Abbud <fadi.abbud@intevation.de>
parents: 5265
diff changeset
227 return "10000";
12e2422ae57c Show current scale dominator as placeholder in PDF export [ci by swilde]
Fadi Abbud <fadi.abbud@intevation.de>
parents: 5265
diff changeset
228 }
2376
6efd7ecd3a7d client: pdf-gen: generate more expressive filename
Markus Kottlaender <markus@intevation.de>
parents: 2325
diff changeset
229 }
1272
bc55ffaeb639 cleaned up client/src directory
Markus Kottlaender <markus@intevation.de>
parents:
diff changeset
230 },
bc55ffaeb639 cleaned up client/src directory
Markus Kottlaender <markus@intevation.de>
parents:
diff changeset
231 methods: {
2387
f185503ef35a client: unified box's header styles by creating a reusable component
Markus Kottlaender <markus@intevation.de>
parents: 2376
diff changeset
232 close() {
f185503ef35a client: unified box's header styles by creating a reusable component
Markus Kottlaender <markus@intevation.de>
parents: 2376
diff changeset
233 this.$store.commit("application/showPdfTool", false);
f185503ef35a client: unified box's header styles by creating a reusable component
Markus Kottlaender <markus@intevation.de>
parents: 2376
diff changeset
234 },
2112
8c0a0f237c2d improved behavior of pdf generation form
Markus Kottlaender <markus@intevation.de>
parents: 2111
diff changeset
235 // When a template is chosen from the dropdown, its propoerties are
8c0a0f237c2d improved behavior of pdf generation form
Markus Kottlaender <markus@intevation.de>
parents: 2111
diff changeset
236 // applied to the rest of the form.
8c0a0f237c2d improved behavior of pdf generation form
Markus Kottlaender <markus@intevation.de>
parents: 2111
diff changeset
237 applyTemplateToForm() {
3840
387f239018c7 pdf_tool: retain default template, when custom template is uploaded
Thomas Junk <thomas.junk@intevation.de>
parents: 3802
diff changeset
238 if (this.form.template && this.form.template.name !== DEFAULT_TEMPLATE) {
3802
e8a950cf6c02 Move Template loading and Imageprocessing to mixin
Thomas Junk <thomas.junk@intevation.de>
parents: 3790
diff changeset
239 this.loadTemplates(
e8a950cf6c02 Move Template loading and Imageprocessing to mixin
Thomas Junk <thomas.junk@intevation.de>
parents: 3790
diff changeset
240 `/templates/${this.form.template.type}/${this.form.template.name}`
3227
6d4d8e7ef881 client: adjust route for pdftemplate,pdftool and add check type to uploaded templates
Fadi Abbud <fadi.abbud@intevation.de>
parents: 3222
diff changeset
241 )
2247
e6fba449aa3c merged pdf-export in default
Markus Kottlaender <markus@intevation.de>
parents: 2240
diff changeset
242 .then(response => {
3802
e8a950cf6c02 Move Template loading and Imageprocessing to mixin
Thomas Junk <thomas.junk@intevation.de>
parents: 3790
diff changeset
243 this.prepareImages(response.data.template_data.elements).then(
e8a950cf6c02 Move Template loading and Imageprocessing to mixin
Thomas Junk <thomas.junk@intevation.de>
parents: 3790
diff changeset
244 values => {
e8a950cf6c02 Move Template loading and Imageprocessing to mixin
Thomas Junk <thomas.junk@intevation.de>
parents: 3790
diff changeset
245 values.forEach(v => {
e8a950cf6c02 Move Template loading and Imageprocessing to mixin
Thomas Junk <thomas.junk@intevation.de>
parents: 3790
diff changeset
246 response.data.template_data.elements[v.index].url = v.url;
e8a950cf6c02 Move Template loading and Imageprocessing to mixin
Thomas Junk <thomas.junk@intevation.de>
parents: 3790
diff changeset
247 });
3840
387f239018c7 pdf_tool: retain default template, when custom template is uploaded
Thomas Junk <thomas.junk@intevation.de>
parents: 3802
diff changeset
248 this.setTemplate(response.data.template_data);
3802
e8a950cf6c02 Move Template loading and Imageprocessing to mixin
Thomas Junk <thomas.junk@intevation.de>
parents: 3790
diff changeset
249 }
3786
a2da2328bb86 PDFTool: prefetch images of template and convert to dataURI
Thomas Junk <thomas.junk@intevation.de>
parents: 3781
diff changeset
250 );
2247
e6fba449aa3c merged pdf-export in default
Markus Kottlaender <markus@intevation.de>
parents: 2240
diff changeset
251 })
4868
008bc1ae8897 exception handling
Thomas Junk <thomas.junk@intevation.de>
parents: 4735
diff changeset
252 .catch(error => {
4869
6b054b91d9b2 backend not reachable as error message etd. Login adjusted
Thomas Junk <thomas.junk@intevation.de>
parents: 4868
diff changeset
253 let message = "Backend not reachable";
4868
008bc1ae8897 exception handling
Thomas Junk <thomas.junk@intevation.de>
parents: 4735
diff changeset
254 if (error.response) {
008bc1ae8897 exception handling
Thomas Junk <thomas.junk@intevation.de>
parents: 4735
diff changeset
255 const { status, data } = error.response;
008bc1ae8897 exception handling
Thomas Junk <thomas.junk@intevation.de>
parents: 4735
diff changeset
256 message = `${status}: ${data.message || data}`;
008bc1ae8897 exception handling
Thomas Junk <thomas.junk@intevation.de>
parents: 4735
diff changeset
257 }
2247
e6fba449aa3c merged pdf-export in default
Markus Kottlaender <markus@intevation.de>
parents: 2240
diff changeset
258 displayError({
2284
9f327f197ddd client: translation: mark some strings for translations
Fadi Abbud <fadi.abbud@intevation.de>
parents: 2275
diff changeset
259 title: this.$gettext("Backend Error"),
4868
008bc1ae8897 exception handling
Thomas Junk <thomas.junk@intevation.de>
parents: 4735
diff changeset
260 message: message
2247
e6fba449aa3c merged pdf-export in default
Markus Kottlaender <markus@intevation.de>
parents: 2240
diff changeset
261 });
e6fba449aa3c merged pdf-export in default
Markus Kottlaender <markus@intevation.de>
parents: 2240
diff changeset
262 });
3840
387f239018c7 pdf_tool: retain default template, when custom template is uploaded
Thomas Junk <thomas.junk@intevation.de>
parents: 3802
diff changeset
263 } else {
387f239018c7 pdf_tool: retain default template, when custom template is uploaded
Thomas Junk <thomas.junk@intevation.de>
parents: 3802
diff changeset
264 this.setTemplate(this.templates[0]);
2112
8c0a0f237c2d improved behavior of pdf generation form
Markus Kottlaender <markus@intevation.de>
parents: 2111
diff changeset
265 }
8c0a0f237c2d improved behavior of pdf generation form
Markus Kottlaender <markus@intevation.de>
parents: 2111
diff changeset
266 },
3840
387f239018c7 pdf_tool: retain default template, when custom template is uploaded
Thomas Junk <thomas.junk@intevation.de>
parents: 3802
diff changeset
267 setTemplate(template) {
387f239018c7 pdf_tool: retain default template, when custom template is uploaded
Thomas Junk <thomas.junk@intevation.de>
parents: 3802
diff changeset
268 this.templateData = template;
387f239018c7 pdf_tool: retain default template, when custom template is uploaded
Thomas Junk <thomas.junk@intevation.de>
parents: 3802
diff changeset
269 this.form.format = this.templateData.properties.format;
387f239018c7 pdf_tool: retain default template, when custom template is uploaded
Thomas Junk <thomas.junk@intevation.de>
parents: 3802
diff changeset
270 this.form.paperSize = this.templateData.properties.paperSize;
387f239018c7 pdf_tool: retain default template, when custom template is uploaded
Thomas Junk <thomas.junk@intevation.de>
parents: 3802
diff changeset
271 this.form.resolution = this.templateData.properties.resolution;
387f239018c7 pdf_tool: retain default template, when custom template is uploaded
Thomas Junk <thomas.junk@intevation.de>
parents: 3802
diff changeset
272 },
5310
660147046ddd Client: Implement handling zpg-exception info in pdf
Fadi Abbud <fadi.abbud@intevation.de>
parents: 5288
diff changeset
273 getSoundingInfo() {
5172
d750fb514a82 first draft for SR-detection
Thomas Junk <thomas.junk@intevation.de>
parents: 4981
diff changeset
274 return new Promise((resolve, reject) => {
d750fb514a82 first draft for SR-detection
Thomas Junk <thomas.junk@intevation.de>
parents: 4981
diff changeset
275 const map = this.openLayersMap();
d750fb514a82 first draft for SR-detection
Thomas Junk <thomas.junk@intevation.de>
parents: 4981
diff changeset
276 const currentExtent = map.getView().calculateExtent(map.getSize());
5174
b73e8cc494f6 limit to selected survey
Thomas Junk <thomas.junk@intevation.de>
parents: 5173
diff changeset
277 const params = {
5173
58ef2c163d14 use correct projection. console.log removed.
Thomas Junk <thomas.junk@intevation.de>
parents: 5172
diff changeset
278 srsName: "EPSG:3857",
5172
d750fb514a82 first draft for SR-detection
Thomas Junk <thomas.junk@intevation.de>
parents: 4981
diff changeset
279 featureNS: "gemma",
d750fb514a82 first draft for SR-detection
Thomas Junk <thomas.junk@intevation.de>
parents: 4981
diff changeset
280 featurePrefix: "gemma",
5433
0c8342c7ec8b Fix for PDF-Tool.
Thomas Junk <thomas.junk@intevation.de>
parents: 5426
diff changeset
281 featureTypes: ["sounding_results_areas_geoserver"],
5172
d750fb514a82 first draft for SR-detection
Thomas Junk <thomas.junk@intevation.de>
parents: 4981
diff changeset
282 outputFormat: "application/json",
d750fb514a82 first draft for SR-detection
Thomas Junk <thomas.junk@intevation.de>
parents: 4981
diff changeset
283 bbox: currentExtent,
d750fb514a82 first draft for SR-detection
Thomas Junk <thomas.junk@intevation.de>
parents: 4981
diff changeset
284 geometryName: "areas"
5174
b73e8cc494f6 limit to selected survey
Thomas Junk <thomas.junk@intevation.de>
parents: 5173
diff changeset
285 };
5433
0c8342c7ec8b Fix for PDF-Tool.
Thomas Junk <thomas.junk@intevation.de>
parents: 5426
diff changeset
286 const survey = this.selectedSurvey;
0c8342c7ec8b Fix for PDF-Tool.
Thomas Junk <thomas.junk@intevation.de>
parents: 5426
diff changeset
287 if (survey) {
0c8342c7ec8b Fix for PDF-Tool.
Thomas Junk <thomas.junk@intevation.de>
parents: 5426
diff changeset
288 if (survey["survey_type"] === "marking") {
0c8342c7ec8b Fix for PDF-Tool.
Thomas Junk <thomas.junk@intevation.de>
parents: 5426
diff changeset
289 params["featureTypes"] = [
0c8342c7ec8b Fix for PDF-Tool.
Thomas Junk <thomas.junk@intevation.de>
parents: 5426
diff changeset
290 "sounding_results_marking_points_geoserver"
0c8342c7ec8b Fix for PDF-Tool.
Thomas Junk <thomas.junk@intevation.de>
parents: 5426
diff changeset
291 ];
0c8342c7ec8b Fix for PDF-Tool.
Thomas Junk <thomas.junk@intevation.de>
parents: 5426
diff changeset
292 params["geometryName"] = "points";
0c8342c7ec8b Fix for PDF-Tool.
Thomas Junk <thomas.junk@intevation.de>
parents: 5426
diff changeset
293 }
5174
b73e8cc494f6 limit to selected survey
Thomas Junk <thomas.junk@intevation.de>
parents: 5173
diff changeset
294 params["filter"] = equalToFilter(
b73e8cc494f6 limit to selected survey
Thomas Junk <thomas.junk@intevation.de>
parents: 5173
diff changeset
295 "bottleneck_id",
b73e8cc494f6 limit to selected survey
Thomas Junk <thomas.junk@intevation.de>
parents: 5173
diff changeset
296 this.selectedSurvey.bottleneck_id
b73e8cc494f6 limit to selected survey
Thomas Junk <thomas.junk@intevation.de>
parents: 5173
diff changeset
297 );
b73e8cc494f6 limit to selected survey
Thomas Junk <thomas.junk@intevation.de>
parents: 5173
diff changeset
298 }
b73e8cc494f6 limit to selected survey
Thomas Junk <thomas.junk@intevation.de>
parents: 5173
diff changeset
299 const getSoundingResultFeatures = new WFS().writeGetFeature(params);
5172
d750fb514a82 first draft for SR-detection
Thomas Junk <thomas.junk@intevation.de>
parents: 4981
diff changeset
300 HTTP.post(
d750fb514a82 first draft for SR-detection
Thomas Junk <thomas.junk@intevation.de>
parents: 4981
diff changeset
301 "/internal/wfs",
d750fb514a82 first draft for SR-detection
Thomas Junk <thomas.junk@intevation.de>
parents: 4981
diff changeset
302 new XMLSerializer().serializeToString(getSoundingResultFeatures),
d750fb514a82 first draft for SR-detection
Thomas Junk <thomas.junk@intevation.de>
parents: 4981
diff changeset
303 {
d750fb514a82 first draft for SR-detection
Thomas Junk <thomas.junk@intevation.de>
parents: 4981
diff changeset
304 headers: {
d750fb514a82 first draft for SR-detection
Thomas Junk <thomas.junk@intevation.de>
parents: 4981
diff changeset
305 "X-Gemma-Auth": localStorage.getItem("token"),
d750fb514a82 first draft for SR-detection
Thomas Junk <thomas.junk@intevation.de>
parents: 4981
diff changeset
306 "Content-type": "text/xml; charset=UTF-8"
d750fb514a82 first draft for SR-detection
Thomas Junk <thomas.junk@intevation.de>
parents: 4981
diff changeset
307 }
d750fb514a82 first draft for SR-detection
Thomas Junk <thomas.junk@intevation.de>
parents: 4981
diff changeset
308 }
d750fb514a82 first draft for SR-detection
Thomas Junk <thomas.junk@intevation.de>
parents: 4981
diff changeset
309 )
d750fb514a82 first draft for SR-detection
Thomas Junk <thomas.junk@intevation.de>
parents: 4981
diff changeset
310 .then(response => {
d750fb514a82 first draft for SR-detection
Thomas Junk <thomas.junk@intevation.de>
parents: 4981
diff changeset
311 resolve(response);
d750fb514a82 first draft for SR-detection
Thomas Junk <thomas.junk@intevation.de>
parents: 4981
diff changeset
312 })
d750fb514a82 first draft for SR-detection
Thomas Junk <thomas.junk@intevation.de>
parents: 4981
diff changeset
313 .catch(error => {
d750fb514a82 first draft for SR-detection
Thomas Junk <thomas.junk@intevation.de>
parents: 4981
diff changeset
314 reject(error);
d750fb514a82 first draft for SR-detection
Thomas Junk <thomas.junk@intevation.de>
parents: 4981
diff changeset
315 });
d750fb514a82 first draft for SR-detection
Thomas Junk <thomas.junk@intevation.de>
parents: 4981
diff changeset
316 });
d750fb514a82 first draft for SR-detection
Thomas Junk <thomas.junk@intevation.de>
parents: 4981
diff changeset
317 },
1272
bc55ffaeb639 cleaned up client/src directory
Markus Kottlaender <markus@intevation.de>
parents:
diff changeset
318 download() {
5310
660147046ddd Client: Implement handling zpg-exception info in pdf
Fadi Abbud <fadi.abbud@intevation.de>
parents: 5288
diff changeset
319 this.getSoundingInfo()
5172
d750fb514a82 first draft for SR-detection
Thomas Junk <thomas.junk@intevation.de>
parents: 4981
diff changeset
320 .then(response => {
5310
660147046ddd Client: Implement handling zpg-exception info in pdf
Fadi Abbud <fadi.abbud@intevation.de>
parents: 5288
diff changeset
321 let soundingInfo = {};
660147046ddd Client: Implement handling zpg-exception info in pdf
Fadi Abbud <fadi.abbud@intevation.de>
parents: 5288
diff changeset
322 if (this.selectedSurvey) {
660147046ddd Client: Implement handling zpg-exception info in pdf
Fadi Abbud <fadi.abbud@intevation.de>
parents: 5288
diff changeset
323 soundingInfo = {
660147046ddd Client: Implement handling zpg-exception info in pdf
Fadi Abbud <fadi.abbud@intevation.de>
parents: 5288
diff changeset
324 number: response.data.numberMatched || 0,
660147046ddd Client: Implement handling zpg-exception info in pdf
Fadi Abbud <fadi.abbud@intevation.de>
parents: 5288
diff changeset
325 feature:
660147046ddd Client: Implement handling zpg-exception info in pdf
Fadi Abbud <fadi.abbud@intevation.de>
parents: 5288
diff changeset
326 response.data.features.filter(
5312
11e013b8b1a9 Client: Fix one condition (zpg_exception)
Fadi Abbud <fadi.abbud@intevation.de>
parents: 5310
diff changeset
327 f => f.properties.date_info === this.selectedSurvey.date_info
5310
660147046ddd Client: Implement handling zpg-exception info in pdf
Fadi Abbud <fadi.abbud@intevation.de>
parents: 5288
diff changeset
328 )[0] || {}
660147046ddd Client: Implement handling zpg-exception info in pdf
Fadi Abbud <fadi.abbud@intevation.de>
parents: 5288
diff changeset
329 };
660147046ddd Client: Implement handling zpg-exception info in pdf
Fadi Abbud <fadi.abbud@intevation.de>
parents: 5288
diff changeset
330 } else {
660147046ddd Client: Implement handling zpg-exception info in pdf
Fadi Abbud <fadi.abbud@intevation.de>
parents: 5288
diff changeset
331 soundingInfo = { number: 0, feature: {} };
660147046ddd Client: Implement handling zpg-exception info in pdf
Fadi Abbud <fadi.abbud@intevation.de>
parents: 5288
diff changeset
332 }
660147046ddd Client: Implement handling zpg-exception info in pdf
Fadi Abbud <fadi.abbud@intevation.de>
parents: 5288
diff changeset
333 this.$store.commit("bottlenecks/setSoundingInfo", soundingInfo);
660147046ddd Client: Implement handling zpg-exception info in pdf
Fadi Abbud <fadi.abbud@intevation.de>
parents: 5288
diff changeset
334 this.generatePDF(soundingInfo);
5172
d750fb514a82 first draft for SR-detection
Thomas Junk <thomas.junk@intevation.de>
parents: 4981
diff changeset
335 })
d750fb514a82 first draft for SR-detection
Thomas Junk <thomas.junk@intevation.de>
parents: 4981
diff changeset
336 .catch(error => {
d750fb514a82 first draft for SR-detection
Thomas Junk <thomas.junk@intevation.de>
parents: 4981
diff changeset
337 let message = "Backend not reachable";
d750fb514a82 first draft for SR-detection
Thomas Junk <thomas.junk@intevation.de>
parents: 4981
diff changeset
338 if (error.response) {
d750fb514a82 first draft for SR-detection
Thomas Junk <thomas.junk@intevation.de>
parents: 4981
diff changeset
339 const { status, data } = error.response;
d750fb514a82 first draft for SR-detection
Thomas Junk <thomas.junk@intevation.de>
parents: 4981
diff changeset
340 message = `${status}: ${data.message || data}`;
d750fb514a82 first draft for SR-detection
Thomas Junk <thomas.junk@intevation.de>
parents: 4981
diff changeset
341 }
d750fb514a82 first draft for SR-detection
Thomas Junk <thomas.junk@intevation.de>
parents: 4981
diff changeset
342 displayError({
d750fb514a82 first draft for SR-detection
Thomas Junk <thomas.junk@intevation.de>
parents: 4981
diff changeset
343 title: this.$gettext("Backend Error"),
d750fb514a82 first draft for SR-detection
Thomas Junk <thomas.junk@intevation.de>
parents: 4981
diff changeset
344 message: message
d750fb514a82 first draft for SR-detection
Thomas Junk <thomas.junk@intevation.de>
parents: 4981
diff changeset
345 });
d750fb514a82 first draft for SR-detection
Thomas Junk <thomas.junk@intevation.de>
parents: 4981
diff changeset
346 });
d750fb514a82 first draft for SR-detection
Thomas Junk <thomas.junk@intevation.de>
parents: 4981
diff changeset
347 },
5310
660147046ddd Client: Implement handling zpg-exception info in pdf
Fadi Abbud <fadi.abbud@intevation.de>
parents: 5288
diff changeset
348 generatePDF(soundingInfo) {
3981
8ec8d9bc5468 document algorithm
Thomas Junk <thomas.junk@intevation.de>
parents: 3980
diff changeset
349 /**
8ec8d9bc5468 document algorithm
Thomas Junk <thomas.junk@intevation.de>
parents: 3980
diff changeset
350 * In order to generate the image with the appropriate resolution
8ec8d9bc5468 document algorithm
Thomas Junk <thomas.junk@intevation.de>
parents: 3980
diff changeset
351 * we have to temporaily scale the visible part of the map.
8ec8d9bc5468 document algorithm
Thomas Junk <thomas.junk@intevation.de>
parents: 3980
diff changeset
352 * The newly rendered canvas is converted to Base64 DataURL.
8ec8d9bc5468 document algorithm
Thomas Junk <thomas.junk@intevation.de>
parents: 3980
diff changeset
353 * After that is done, the resolution is resetted to its previous state.
8ec8d9bc5468 document algorithm
Thomas Junk <thomas.junk@intevation.de>
parents: 3980
diff changeset
354 *
8ec8d9bc5468 document algorithm
Thomas Junk <thomas.junk@intevation.de>
parents: 3980
diff changeset
355 * calculateExtent() and fit() do not give the desired result
8ec8d9bc5468 document algorithm
Thomas Junk <thomas.junk@intevation.de>
parents: 3980
diff changeset
356 * when the view is rotated so we replace them completely by setting resolution
8ec8d9bc5468 document algorithm
Thomas Junk <thomas.junk@intevation.de>
parents: 3980
diff changeset
357 *
8ec8d9bc5468 document algorithm
Thomas Junk <thomas.junk@intevation.de>
parents: 3980
diff changeset
358 * Details: https://gis.stackexchange.com/questions/328933/openlayers-generating-clientside-pdfs
8ec8d9bc5468 document algorithm
Thomas Junk <thomas.junk@intevation.de>
parents: 3980
diff changeset
359 *
8ec8d9bc5468 document algorithm
Thomas Junk <thomas.junk@intevation.de>
parents: 3980
diff changeset
360 */
5288
48bef30cdb72 Client: limit displaying of error popup to only pdf-export mode(ECDIS layer)
Fadi Abbud <fadi.abbud@intevation.de>
parents: 5282
diff changeset
361 this.$store.commit("application/setOngoingPDFExport", true);
1947
4235fa8f59d7 clien: pdf-gen: load logo externally; add prepare step
Bernhard Reiter <bernhard@intevation.de>
parents: 1936
diff changeset
362 this.readyToGenerate = false;
5282
12e2422ae57c Show current scale dominator as placeholder in PDF export [ci by swilde]
Fadi Abbud <fadi.abbud@intevation.de>
parents: 5265
diff changeset
363 this.setPDFDimension();
1874
bad32adafef2 client: add real pdf generation with jspdf
Bernhard Reiter <bernhard@intevation.de>
parents: 1635
diff changeset
364 // FUTURE: consider margins
5282
12e2422ae57c Show current scale dominator as placeholder in PDF export [ci by swilde]
Fadi Abbud <fadi.abbud@intevation.de>
parents: 5265
diff changeset
365 const mapSizeForPrint = this.setMapSizForPrint();
3127
0374197c384f client: fix openLayersMap getter calls
Markus Kottlaender <markus@intevation.de>
parents: 3044
diff changeset
366 var map = this.openLayersMap();
3981
8ec8d9bc5468 document algorithm
Thomas Junk <thomas.junk@intevation.de>
parents: 3980
diff changeset
367 this.mapSize = map.getSize();
3980
7316b7e8246f improve PDFTool
Thomas Junk <thomas.junk@intevation.de>
parents: 3960
diff changeset
368 this.resolution = map.getView().getResolution();
1883
76a6d334e681 Client: pdf-gen: refactor addScaleBar
Bernhard Reiter <bernhard@intevation.de>
parents: 1882
diff changeset
369
2218
631ca0412db9 adjusted positioning of pdf elements
Markus Kottlaender <markus@intevation.de>
parents: 2215
diff changeset
370 this.pdf.doc = new jsPDF(this.form.format, "mm", this.form.paperSize);
2275
a6cfa06c5983 client: pdf-gen: added cancel button
Markus Kottlaender <markus@intevation.de>
parents: 2265
diff changeset
371 this.rendercompleteListener = map.once("rendercomplete", event => {
1874
bad32adafef2 client: add real pdf generation with jspdf
Bernhard Reiter <bernhard@intevation.de>
parents: 1635
diff changeset
372 let canvas = event.context.canvas;
5282
12e2422ae57c Show current scale dominator as placeholder in PDF export [ci by swilde]
Fadi Abbud <fadi.abbud@intevation.de>
parents: 5265
diff changeset
373 let scaleDenominator = this.calculateScaleDenominator();
3980
7316b7e8246f improve PDFTool
Thomas Junk <thomas.junk@intevation.de>
parents: 3960
diff changeset
374 var snapshot = canvas.toDataURL("image/jpeg");
7316b7e8246f improve PDFTool
Thomas Junk <thomas.junk@intevation.de>
parents: 3960
diff changeset
375 this.pdf.doc.addImage(
7316b7e8246f improve PDFTool
Thomas Junk <thomas.junk@intevation.de>
parents: 3960
diff changeset
376 snapshot,
7316b7e8246f improve PDFTool
Thomas Junk <thomas.junk@intevation.de>
parents: 3960
diff changeset
377 "JPEG",
7316b7e8246f improve PDFTool
Thomas Junk <thomas.junk@intevation.de>
parents: 3960
diff changeset
378 0,
7316b7e8246f improve PDFTool
Thomas Junk <thomas.junk@intevation.de>
parents: 3960
diff changeset
379 0,
2227
9b545e470b94 PDF generation: logo image, adjusted templates
Markus Kottlaender <markus@intevation.de>
parents: 2226
diff changeset
380 this.pdf.width,
3980
7316b7e8246f improve PDFTool
Thomas Junk <thomas.junk@intevation.de>
parents: 3960
diff changeset
381 this.pdf.height
2227
9b545e470b94 PDF generation: logo image, adjusted templates
Markus Kottlaender <markus@intevation.de>
parents: 2226
diff changeset
382 );
3980
7316b7e8246f improve PDFTool
Thomas Junk <thomas.junk@intevation.de>
parents: 3960
diff changeset
383 if (this.templateData) {
7316b7e8246f improve PDFTool
Thomas Junk <thomas.junk@intevation.de>
parents: 3960
diff changeset
384 this.pdf.doc.setFont("linbiolinum", "normal");
7316b7e8246f improve PDFTool
Thomas Junk <thomas.junk@intevation.de>
parents: 3960
diff changeset
385 let defaultFontSize = 11,
7316b7e8246f improve PDFTool
Thomas Junk <thomas.junk@intevation.de>
parents: 3960
diff changeset
386 defaultRounding = 2,
7316b7e8246f improve PDFTool
Thomas Junk <thomas.junk@intevation.de>
parents: 3960
diff changeset
387 defaultTextColor = "black",
7316b7e8246f improve PDFTool
Thomas Junk <thomas.junk@intevation.de>
parents: 3960
diff changeset
388 defaultBgColor = "white",
7316b7e8246f improve PDFTool
Thomas Junk <thomas.junk@intevation.de>
parents: 3960
diff changeset
389 defaultPadding = 3,
7316b7e8246f improve PDFTool
Thomas Junk <thomas.junk@intevation.de>
parents: 3960
diff changeset
390 defaultOffset = { x: 0, y: 0 },
3993
6672b780722f client: pdf-gen: improve addtext for pdf
Fadi Abbud <fadi.abbud@intevation.de>
parents: 3981
diff changeset
391 defaultBorderColor = "white";
3980
7316b7e8246f improve PDFTool
Thomas Junk <thomas.junk@intevation.de>
parents: 3960
diff changeset
392 this.templateData.elements.forEach(e => {
7316b7e8246f improve PDFTool
Thomas Junk <thomas.junk@intevation.de>
parents: 3960
diff changeset
393 switch (e.type) {
7316b7e8246f improve PDFTool
Thomas Junk <thomas.junk@intevation.de>
parents: 3960
diff changeset
394 case "text": {
7316b7e8246f improve PDFTool
Thomas Junk <thomas.junk@intevation.de>
parents: 3960
diff changeset
395 this.addText(
7316b7e8246f improve PDFTool
Thomas Junk <thomas.junk@intevation.de>
parents: 3960
diff changeset
396 e.position,
7316b7e8246f improve PDFTool
Thomas Junk <thomas.junk@intevation.de>
parents: 3960
diff changeset
397 e.offset || defaultOffset,
3993
6672b780722f client: pdf-gen: improve addtext for pdf
Fadi Abbud <fadi.abbud@intevation.de>
parents: 3981
diff changeset
398 e.width,
3980
7316b7e8246f improve PDFTool
Thomas Junk <thomas.junk@intevation.de>
parents: 3960
diff changeset
399 e.fontSize || defaultFontSize,
7316b7e8246f improve PDFTool
Thomas Junk <thomas.junk@intevation.de>
parents: 3960
diff changeset
400 e.color || defaultTextColor,
5310
660147046ddd Client: Implement handling zpg-exception info in pdf
Fadi Abbud <fadi.abbud@intevation.de>
parents: 5288
diff changeset
401 e.text,
660147046ddd Client: Implement handling zpg-exception info in pdf
Fadi Abbud <fadi.abbud@intevation.de>
parents: 5288
diff changeset
402 soundingInfo
3980
7316b7e8246f improve PDFTool
Thomas Junk <thomas.junk@intevation.de>
parents: 3960
diff changeset
403 );
7316b7e8246f improve PDFTool
Thomas Junk <thomas.junk@intevation.de>
parents: 3960
diff changeset
404 break;
7316b7e8246f improve PDFTool
Thomas Junk <thomas.junk@intevation.de>
parents: 3960
diff changeset
405 }
7316b7e8246f improve PDFTool
Thomas Junk <thomas.junk@intevation.de>
parents: 3960
diff changeset
406 case "box": {
7316b7e8246f improve PDFTool
Thomas Junk <thomas.junk@intevation.de>
parents: 3960
diff changeset
407 this.addBox(
7316b7e8246f improve PDFTool
Thomas Junk <thomas.junk@intevation.de>
parents: 3960
diff changeset
408 e.position,
7316b7e8246f improve PDFTool
Thomas Junk <thomas.junk@intevation.de>
parents: 3960
diff changeset
409 e.offset || defaultOffset,
7316b7e8246f improve PDFTool
Thomas Junk <thomas.junk@intevation.de>
parents: 3960
diff changeset
410 e.width,
7316b7e8246f improve PDFTool
Thomas Junk <thomas.junk@intevation.de>
parents: 3960
diff changeset
411 e.height,
7316b7e8246f improve PDFTool
Thomas Junk <thomas.junk@intevation.de>
parents: 3960
diff changeset
412 e.rounding === 0 || e.rounding ? e.rounding : defaultRounding,
7316b7e8246f improve PDFTool
Thomas Junk <thomas.junk@intevation.de>
parents: 3960
diff changeset
413 e.color || defaultBgColor,
7316b7e8246f improve PDFTool
Thomas Junk <thomas.junk@intevation.de>
parents: 3960
diff changeset
414 e.brcolor || defaultBorderColor
7316b7e8246f improve PDFTool
Thomas Junk <thomas.junk@intevation.de>
parents: 3960
diff changeset
415 );
7316b7e8246f improve PDFTool
Thomas Junk <thomas.junk@intevation.de>
parents: 3960
diff changeset
416 break;
7316b7e8246f improve PDFTool
Thomas Junk <thomas.junk@intevation.de>
parents: 3960
diff changeset
417 }
7316b7e8246f improve PDFTool
Thomas Junk <thomas.junk@intevation.de>
parents: 3960
diff changeset
418 case "textbox": {
7316b7e8246f improve PDFTool
Thomas Junk <thomas.junk@intevation.de>
parents: 3960
diff changeset
419 this.addTextBox(
7316b7e8246f improve PDFTool
Thomas Junk <thomas.junk@intevation.de>
parents: 3960
diff changeset
420 e.position,
7316b7e8246f improve PDFTool
Thomas Junk <thomas.junk@intevation.de>
parents: 3960
diff changeset
421 e.offset || defaultOffset,
7316b7e8246f improve PDFTool
Thomas Junk <thomas.junk@intevation.de>
parents: 3960
diff changeset
422 e.width,
7316b7e8246f improve PDFTool
Thomas Junk <thomas.junk@intevation.de>
parents: 3960
diff changeset
423 e.height,
7316b7e8246f improve PDFTool
Thomas Junk <thomas.junk@intevation.de>
parents: 3960
diff changeset
424 e.rounding === 0 || e.rounding ? e.rounding : defaultRounding,
7316b7e8246f improve PDFTool
Thomas Junk <thomas.junk@intevation.de>
parents: 3960
diff changeset
425 e.padding || defaultPadding,
7316b7e8246f improve PDFTool
Thomas Junk <thomas.junk@intevation.de>
parents: 3960
diff changeset
426 e.fontSize || defaultFontSize,
7316b7e8246f improve PDFTool
Thomas Junk <thomas.junk@intevation.de>
parents: 3960
diff changeset
427 e.color || defaultTextColor,
7316b7e8246f improve PDFTool
Thomas Junk <thomas.junk@intevation.de>
parents: 3960
diff changeset
428 e.background || defaultBgColor,
7316b7e8246f improve PDFTool
Thomas Junk <thomas.junk@intevation.de>
parents: 3960
diff changeset
429 e.text,
7316b7e8246f improve PDFTool
Thomas Junk <thomas.junk@intevation.de>
parents: 3960
diff changeset
430 e.brcolor || defaultBorderColor
7316b7e8246f improve PDFTool
Thomas Junk <thomas.junk@intevation.de>
parents: 3960
diff changeset
431 );
7316b7e8246f improve PDFTool
Thomas Junk <thomas.junk@intevation.de>
parents: 3960
diff changeset
432 break;
2223
85142493096c PDF generation: improved positioning, prepared demo templates
Markus Kottlaender <markus@intevation.de>
parents: 2222
diff changeset
433 }
3980
7316b7e8246f improve PDFTool
Thomas Junk <thomas.junk@intevation.de>
parents: 3960
diff changeset
434 case "image": {
7316b7e8246f improve PDFTool
Thomas Junk <thomas.junk@intevation.de>
parents: 3960
diff changeset
435 this.addImage(
7316b7e8246f improve PDFTool
Thomas Junk <thomas.junk@intevation.de>
parents: 3960
diff changeset
436 e.url,
7316b7e8246f improve PDFTool
Thomas Junk <thomas.junk@intevation.de>
parents: 3960
diff changeset
437 e.format,
7316b7e8246f improve PDFTool
Thomas Junk <thomas.junk@intevation.de>
parents: 3960
diff changeset
438 e.position,
7316b7e8246f improve PDFTool
Thomas Junk <thomas.junk@intevation.de>
parents: 3960
diff changeset
439 e.offset || defaultOffset,
7316b7e8246f improve PDFTool
Thomas Junk <thomas.junk@intevation.de>
parents: 3960
diff changeset
440 e.width,
7316b7e8246f improve PDFTool
Thomas Junk <thomas.junk@intevation.de>
parents: 3960
diff changeset
441 e.height
7316b7e8246f improve PDFTool
Thomas Junk <thomas.junk@intevation.de>
parents: 3960
diff changeset
442 );
7316b7e8246f improve PDFTool
Thomas Junk <thomas.junk@intevation.de>
parents: 3960
diff changeset
443 break;
7316b7e8246f improve PDFTool
Thomas Junk <thomas.junk@intevation.de>
parents: 3960
diff changeset
444 }
7316b7e8246f improve PDFTool
Thomas Junk <thomas.junk@intevation.de>
parents: 3960
diff changeset
445 case "bottleneck": {
7316b7e8246f improve PDFTool
Thomas Junk <thomas.junk@intevation.de>
parents: 3960
diff changeset
446 this.addBottleneckInfo(
7316b7e8246f improve PDFTool
Thomas Junk <thomas.junk@intevation.de>
parents: 3960
diff changeset
447 e.position,
7316b7e8246f improve PDFTool
Thomas Junk <thomas.junk@intevation.de>
parents: 3960
diff changeset
448 e.offset || defaultOffset,
7316b7e8246f improve PDFTool
Thomas Junk <thomas.junk@intevation.de>
parents: 3960
diff changeset
449 e.rounding === 0 || e.rounding ? e.rounding : defaultRounding,
7316b7e8246f improve PDFTool
Thomas Junk <thomas.junk@intevation.de>
parents: 3960
diff changeset
450 e.color || defaultTextColor,
5174
b73e8cc494f6 limit to selected survey
Thomas Junk <thomas.junk@intevation.de>
parents: 5173
diff changeset
451 e.brcolor || defaultBorderColor,
5310
660147046ddd Client: Implement handling zpg-exception info in pdf
Fadi Abbud <fadi.abbud@intevation.de>
parents: 5288
diff changeset
452 soundingInfo.number > 0
3980
7316b7e8246f improve PDFTool
Thomas Junk <thomas.junk@intevation.de>
parents: 3960
diff changeset
453 );
7316b7e8246f improve PDFTool
Thomas Junk <thomas.junk@intevation.de>
parents: 3960
diff changeset
454 break;
7316b7e8246f improve PDFTool
Thomas Junk <thomas.junk@intevation.de>
parents: 3960
diff changeset
455 }
7316b7e8246f improve PDFTool
Thomas Junk <thomas.junk@intevation.de>
parents: 3960
diff changeset
456 case "legend": {
7316b7e8246f improve PDFTool
Thomas Junk <thomas.junk@intevation.de>
parents: 3960
diff changeset
457 this.addLegend(
7316b7e8246f improve PDFTool
Thomas Junk <thomas.junk@intevation.de>
parents: 3960
diff changeset
458 e.position,
7316b7e8246f improve PDFTool
Thomas Junk <thomas.junk@intevation.de>
parents: 3960
diff changeset
459 e.offset || defaultOffset,
7316b7e8246f improve PDFTool
Thomas Junk <thomas.junk@intevation.de>
parents: 3960
diff changeset
460 e.rounding === 0 || e.rounding ? e.rounding : defaultRounding,
5174
b73e8cc494f6 limit to selected survey
Thomas Junk <thomas.junk@intevation.de>
parents: 5173
diff changeset
461 e.brcolor || defaultBorderColor,
5310
660147046ddd Client: Implement handling zpg-exception info in pdf
Fadi Abbud <fadi.abbud@intevation.de>
parents: 5288
diff changeset
462 soundingInfo.number > 0
3980
7316b7e8246f improve PDFTool
Thomas Junk <thomas.junk@intevation.de>
parents: 3960
diff changeset
463 );
7316b7e8246f improve PDFTool
Thomas Junk <thomas.junk@intevation.de>
parents: 3960
diff changeset
464 break;
7316b7e8246f improve PDFTool
Thomas Junk <thomas.junk@intevation.de>
parents: 3960
diff changeset
465 }
7316b7e8246f improve PDFTool
Thomas Junk <thomas.junk@intevation.de>
parents: 3960
diff changeset
466 case "scalebar": {
7316b7e8246f improve PDFTool
Thomas Junk <thomas.junk@intevation.de>
parents: 3960
diff changeset
467 this.addScaleBar(
7316b7e8246f improve PDFTool
Thomas Junk <thomas.junk@intevation.de>
parents: 3960
diff changeset
468 scaleDenominator,
7316b7e8246f improve PDFTool
Thomas Junk <thomas.junk@intevation.de>
parents: 3960
diff changeset
469 e.position,
7316b7e8246f improve PDFTool
Thomas Junk <thomas.junk@intevation.de>
parents: 3960
diff changeset
470 e.offset || defaultOffset,
7316b7e8246f improve PDFTool
Thomas Junk <thomas.junk@intevation.de>
parents: 3960
diff changeset
471 e.rounding === 0 || e.rounding ? e.rounding : defaultRounding,
7316b7e8246f improve PDFTool
Thomas Junk <thomas.junk@intevation.de>
parents: 3960
diff changeset
472 e.brcolor || defaultBorderColor
7316b7e8246f improve PDFTool
Thomas Junk <thomas.junk@intevation.de>
parents: 3960
diff changeset
473 );
7316b7e8246f improve PDFTool
Thomas Junk <thomas.junk@intevation.de>
parents: 3960
diff changeset
474 break;
7316b7e8246f improve PDFTool
Thomas Junk <thomas.junk@intevation.de>
parents: 3960
diff changeset
475 }
7316b7e8246f improve PDFTool
Thomas Junk <thomas.junk@intevation.de>
parents: 3960
diff changeset
476 case "scale": {
7316b7e8246f improve PDFTool
Thomas Junk <thomas.junk@intevation.de>
parents: 3960
diff changeset
477 this.addScale(
7316b7e8246f improve PDFTool
Thomas Junk <thomas.junk@intevation.de>
parents: 3960
diff changeset
478 scaleDenominator,
7316b7e8246f improve PDFTool
Thomas Junk <thomas.junk@intevation.de>
parents: 3960
diff changeset
479 e.position,
7316b7e8246f improve PDFTool
Thomas Junk <thomas.junk@intevation.de>
parents: 3960
diff changeset
480 e.width,
7316b7e8246f improve PDFTool
Thomas Junk <thomas.junk@intevation.de>
parents: 3960
diff changeset
481 e.offset || defaultOffset,
7316b7e8246f improve PDFTool
Thomas Junk <thomas.junk@intevation.de>
parents: 3960
diff changeset
482 e.fontSize || defaultFontSize,
7316b7e8246f improve PDFTool
Thomas Junk <thomas.junk@intevation.de>
parents: 3960
diff changeset
483 e.color || defaultTextColor
7316b7e8246f improve PDFTool
Thomas Junk <thomas.junk@intevation.de>
parents: 3960
diff changeset
484 );
7316b7e8246f improve PDFTool
Thomas Junk <thomas.junk@intevation.de>
parents: 3960
diff changeset
485 break;
7316b7e8246f improve PDFTool
Thomas Junk <thomas.junk@intevation.de>
parents: 3960
diff changeset
486 }
7316b7e8246f improve PDFTool
Thomas Junk <thomas.junk@intevation.de>
parents: 3960
diff changeset
487 case "northarrow": {
7316b7e8246f improve PDFTool
Thomas Junk <thomas.junk@intevation.de>
parents: 3960
diff changeset
488 this.addNorthArrow(
7316b7e8246f improve PDFTool
Thomas Junk <thomas.junk@intevation.de>
parents: 3960
diff changeset
489 e.position,
7316b7e8246f improve PDFTool
Thomas Junk <thomas.junk@intevation.de>
parents: 3960
diff changeset
490 e.offset || defaultOffset,
7316b7e8246f improve PDFTool
Thomas Junk <thomas.junk@intevation.de>
parents: 3960
diff changeset
491 e.size
7316b7e8246f improve PDFTool
Thomas Junk <thomas.junk@intevation.de>
parents: 3960
diff changeset
492 );
7316b7e8246f improve PDFTool
Thomas Junk <thomas.junk@intevation.de>
parents: 3960
diff changeset
493 break;
7316b7e8246f improve PDFTool
Thomas Junk <thomas.junk@intevation.de>
parents: 3960
diff changeset
494 }
7316b7e8246f improve PDFTool
Thomas Junk <thomas.junk@intevation.de>
parents: 3960
diff changeset
495 }
2205
59c21dee6315 pdf-gen: improve pdftool to use value from template
Fadi Abbud <fadi.abbud@intevation.de>
parents: 2124
diff changeset
496 });
5175
6038f782e51d client: Improve detecting of bottleneck for pdf-generation
Fadi Abbud <fadi.abbud@intevation.de>
parents: 5174
diff changeset
497 // Check if the bottlenck in the current view Extent
6038f782e51d client: Improve detecting of bottleneck for pdf-generation
Fadi Abbud <fadi.abbud@intevation.de>
parents: 5174
diff changeset
498 const isBottlenckVisible = () => {
6038f782e51d client: Improve detecting of bottleneck for pdf-generation
Fadi Abbud <fadi.abbud@intevation.de>
parents: 5174
diff changeset
499 const currentExtent = map.getView().calculateExtent(map.getSize());
6038f782e51d client: Improve detecting of bottleneck for pdf-generation
Fadi Abbud <fadi.abbud@intevation.de>
parents: 5174
diff changeset
500 const btnExtent = map
6038f782e51d client: Improve detecting of bottleneck for pdf-generation
Fadi Abbud <fadi.abbud@intevation.de>
parents: 5174
diff changeset
501 .getLayer("BOTTLENECKS")
6038f782e51d client: Improve detecting of bottleneck for pdf-generation
Fadi Abbud <fadi.abbud@intevation.de>
parents: 5174
diff changeset
502 .getSource()
6038f782e51d client: Improve detecting of bottleneck for pdf-generation
Fadi Abbud <fadi.abbud@intevation.de>
parents: 5174
diff changeset
503 .getFeatures()
6038f782e51d client: Improve detecting of bottleneck for pdf-generation
Fadi Abbud <fadi.abbud@intevation.de>
parents: 5174
diff changeset
504 .find(f => f.get("objnam") === this.bottleneckForPrint)
6038f782e51d client: Improve detecting of bottleneck for pdf-generation
Fadi Abbud <fadi.abbud@intevation.de>
parents: 5174
diff changeset
505 .getGeometry()
6038f782e51d client: Improve detecting of bottleneck for pdf-generation
Fadi Abbud <fadi.abbud@intevation.de>
parents: 5174
diff changeset
506 .getExtent();
6038f782e51d client: Improve detecting of bottleneck for pdf-generation
Fadi Abbud <fadi.abbud@intevation.de>
parents: 5174
diff changeset
507 return intersects(currentExtent, btnExtent);
6038f782e51d client: Improve detecting of bottleneck for pdf-generation
Fadi Abbud <fadi.abbud@intevation.de>
parents: 5174
diff changeset
508 };
5174
b73e8cc494f6 limit to selected survey
Thomas Junk <thomas.junk@intevation.de>
parents: 5173
diff changeset
509 let filename = "map";
5175
6038f782e51d client: Improve detecting of bottleneck for pdf-generation
Fadi Abbud <fadi.abbud@intevation.de>
parents: 5174
diff changeset
510 if (
6038f782e51d client: Improve detecting of bottleneck for pdf-generation
Fadi Abbud <fadi.abbud@intevation.de>
parents: 5174
diff changeset
511 this.bottleneckForPrint &&
5310
660147046ddd Client: Implement handling zpg-exception info in pdf
Fadi Abbud <fadi.abbud@intevation.de>
parents: 5288
diff changeset
512 (soundingInfo.number > 0 || isBottlenckVisible())
5175
6038f782e51d client: Improve detecting of bottleneck for pdf-generation
Fadi Abbud <fadi.abbud@intevation.de>
parents: 5174
diff changeset
513 ) {
5174
b73e8cc494f6 limit to selected survey
Thomas Junk <thomas.junk@intevation.de>
parents: 5173
diff changeset
514 filename = `BN-${sanitize(this.bottleneckForPrint).replace(
b73e8cc494f6 limit to selected survey
Thomas Junk <thomas.junk@intevation.de>
parents: 5173
diff changeset
515 / /g,
b73e8cc494f6 limit to selected survey
Thomas Junk <thomas.junk@intevation.de>
parents: 5173
diff changeset
516 "-"
b73e8cc494f6 limit to selected survey
Thomas Junk <thomas.junk@intevation.de>
parents: 5173
diff changeset
517 )}`;
b73e8cc494f6 limit to selected survey
Thomas Junk <thomas.junk@intevation.de>
parents: 5173
diff changeset
518 if (this.selectedSurvey) {
b73e8cc494f6 limit to selected survey
Thomas Junk <thomas.junk@intevation.de>
parents: 5173
diff changeset
519 filename +=
b73e8cc494f6 limit to selected survey
Thomas Junk <thomas.junk@intevation.de>
parents: 5173
diff changeset
520 "-sr" + this.selectedSurvey.date_info.replace(/-/g, "");
b73e8cc494f6 limit to selected survey
Thomas Junk <thomas.junk@intevation.de>
parents: 5173
diff changeset
521 }
b73e8cc494f6 limit to selected survey
Thomas Junk <thomas.junk@intevation.de>
parents: 5173
diff changeset
522 }
b73e8cc494f6 limit to selected survey
Thomas Junk <thomas.junk@intevation.de>
parents: 5173
diff changeset
523 this.pdf.doc.save(`${filename}-${this.dateForPDF()}.pdf`);
3980
7316b7e8246f improve PDFTool
Thomas Junk <thomas.junk@intevation.de>
parents: 3960
diff changeset
524 }
7316b7e8246f improve PDFTool
Thomas Junk <thomas.junk@intevation.de>
parents: 3960
diff changeset
525 map.setSize(this.mapSize);
7316b7e8246f improve PDFTool
Thomas Junk <thomas.junk@intevation.de>
parents: 3960
diff changeset
526 map.getView().setResolution(this.resolution);
7316b7e8246f improve PDFTool
Thomas Junk <thomas.junk@intevation.de>
parents: 3960
diff changeset
527 this.readyToGenerate = true;
5288
48bef30cdb72 Client: limit displaying of error popup to only pdf-export mode(ECDIS layer)
Fadi Abbud <fadi.abbud@intevation.de>
parents: 5282
diff changeset
528 this.$store.commit("application/setOngoingPDFExport", false);
1874
bad32adafef2 client: add real pdf generation with jspdf
Bernhard Reiter <bernhard@intevation.de>
parents: 1635
diff changeset
529 });
4034
917c72e8360d client: pdf-gen: implement basic print scaling
Fadi Abbud <fadi.abbud@intevation.de>
parents: 3993
diff changeset
530
3980
7316b7e8246f improve PDFTool
Thomas Junk <thomas.junk@intevation.de>
parents: 3960
diff changeset
531 const size = map.getSize();
7316b7e8246f improve PDFTool
Thomas Junk <thomas.junk@intevation.de>
parents: 3960
diff changeset
532 const [width, height] = mapSizeForPrint;
2227
9b545e470b94 PDF generation: logo image, adjusted templates
Markus Kottlaender <markus@intevation.de>
parents: 2226
diff changeset
533 map.setSize(mapSizeForPrint);
3980
7316b7e8246f improve PDFTool
Thomas Junk <thomas.junk@intevation.de>
parents: 3960
diff changeset
534 const scaling = Math.min(width / size[0], height / size[1]);
4034
917c72e8360d client: pdf-gen: implement basic print scaling
Fadi Abbud <fadi.abbud@intevation.de>
parents: 3993
diff changeset
535 map
917c72e8360d client: pdf-gen: implement basic print scaling
Fadi Abbud <fadi.abbud@intevation.de>
parents: 3993
diff changeset
536 .getView()
917c72e8360d client: pdf-gen: implement basic print scaling
Fadi Abbud <fadi.abbud@intevation.de>
parents: 3993
diff changeset
537 .setResolution(
917c72e8360d client: pdf-gen: implement basic print scaling
Fadi Abbud <fadi.abbud@intevation.de>
parents: 3993
diff changeset
538 this.form.scale
917c72e8360d client: pdf-gen: implement basic print scaling
Fadi Abbud <fadi.abbud@intevation.de>
parents: 3993
diff changeset
539 ? this.getResolutionFromScale()
917c72e8360d client: pdf-gen: implement basic print scaling
Fadi Abbud <fadi.abbud@intevation.de>
parents: 3993
diff changeset
540 : this.resolution / scaling
917c72e8360d client: pdf-gen: implement basic print scaling
Fadi Abbud <fadi.abbud@intevation.de>
parents: 3993
diff changeset
541 );
917c72e8360d client: pdf-gen: implement basic print scaling
Fadi Abbud <fadi.abbud@intevation.de>
parents: 3993
diff changeset
542 },
917c72e8360d client: pdf-gen: implement basic print scaling
Fadi Abbud <fadi.abbud@intevation.de>
parents: 3993
diff changeset
543 getResolutionFromScale() {
4077
d34e9b8ad396 fix scaling issues
Thomas Junk <thomas.junk@intevation.de>
parents: 4034
diff changeset
544 const scaling = Math.round(this.form.scale / 1000);
d34e9b8ad396 fix scaling issues
Thomas Junk <thomas.junk@intevation.de>
parents: 4034
diff changeset
545 return scaling / this.getMeterPerPixel(this.form.resolution / 25.4);
4034
917c72e8360d client: pdf-gen: implement basic print scaling
Fadi Abbud <fadi.abbud@intevation.de>
parents: 3993
diff changeset
546 },
4077
d34e9b8ad396 fix scaling issues
Thomas Junk <thomas.junk@intevation.de>
parents: 4034
diff changeset
547 getMeterPerPixel(f) {
4034
917c72e8360d client: pdf-gen: implement basic print scaling
Fadi Abbud <fadi.abbud@intevation.de>
parents: 3993
diff changeset
548 var map = this.openLayersMap();
917c72e8360d client: pdf-gen: implement basic print scaling
Fadi Abbud <fadi.abbud@intevation.de>
parents: 3993
diff changeset
549 let view = map.getView();
917c72e8360d client: pdf-gen: implement basic print scaling
Fadi Abbud <fadi.abbud@intevation.de>
parents: 3993
diff changeset
550 let proj = view.getProjection();
917c72e8360d client: pdf-gen: implement basic print scaling
Fadi Abbud <fadi.abbud@intevation.de>
parents: 3993
diff changeset
551 return (
4077
d34e9b8ad396 fix scaling issues
Thomas Junk <thomas.junk@intevation.de>
parents: 4034
diff changeset
552 getPointResolution(proj, f, view.getCenter()) * proj.getMetersPerUnit()
4034
917c72e8360d client: pdf-gen: implement basic print scaling
Fadi Abbud <fadi.abbud@intevation.de>
parents: 3993
diff changeset
553 );
2275
a6cfa06c5983 client: pdf-gen: added cancel button
Markus Kottlaender <markus@intevation.de>
parents: 2265
diff changeset
554 },
a6cfa06c5983 client: pdf-gen: added cancel button
Markus Kottlaender <markus@intevation.de>
parents: 2265
diff changeset
555 cancel() {
4416
5b2023c2c41e pdftool: independent if cancel crashes, the cancel button should vanish
Thomas Junk <thomas.junk@intevation.de>
parents: 4088
diff changeset
556 try {
5b2023c2c41e pdftool: independent if cancel crashes, the cancel button should vanish
Thomas Junk <thomas.junk@intevation.de>
parents: 4088
diff changeset
557 this.openLayersMap().un(
5b2023c2c41e pdftool: independent if cancel crashes, the cancel button should vanish
Thomas Junk <thomas.junk@intevation.de>
parents: 4088
diff changeset
558 this.rendercompleteListener.type,
5b2023c2c41e pdftool: independent if cancel crashes, the cancel button should vanish
Thomas Junk <thomas.junk@intevation.de>
parents: 4088
diff changeset
559 this.rendercompleteListener.listener
5b2023c2c41e pdftool: independent if cancel crashes, the cancel button should vanish
Thomas Junk <thomas.junk@intevation.de>
parents: 4088
diff changeset
560 );
5b2023c2c41e pdftool: independent if cancel crashes, the cancel button should vanish
Thomas Junk <thomas.junk@intevation.de>
parents: 4088
diff changeset
561 this.openLayersMap().setSize(this.mapSize);
5b2023c2c41e pdftool: independent if cancel crashes, the cancel button should vanish
Thomas Junk <thomas.junk@intevation.de>
parents: 4088
diff changeset
562 this.openLayersMap()
5b2023c2c41e pdftool: independent if cancel crashes, the cancel button should vanish
Thomas Junk <thomas.junk@intevation.de>
parents: 4088
diff changeset
563 .getView()
5265
a97e79a07579 client: fix resetting the map resolution by canceling the pdf-generation
Fadi Abbud <fadi.abbud@intevation.de>
parents: 5264
diff changeset
564 .setResolution(this.resolution);
4416
5b2023c2c41e pdftool: independent if cancel crashes, the cancel button should vanish
Thomas Junk <thomas.junk@intevation.de>
parents: 4088
diff changeset
565 } finally {
5288
48bef30cdb72 Client: limit displaying of error popup to only pdf-export mode(ECDIS layer)
Fadi Abbud <fadi.abbud@intevation.de>
parents: 5282
diff changeset
566 this.$store.commit("application/setOngoingPDFExport", false);
4416
5b2023c2c41e pdftool: independent if cancel crashes, the cancel button should vanish
Thomas Junk <thomas.junk@intevation.de>
parents: 4088
diff changeset
567 this.readyToGenerate = true;
5b2023c2c41e pdftool: independent if cancel crashes, the cancel button should vanish
Thomas Junk <thomas.junk@intevation.de>
parents: 4088
diff changeset
568 }
1876
e53924abb4a2 client: export some elements to pdf
Fadi Abbud <fadi.abbud@intevation.de>
parents: 1874
diff changeset
569 },
2737
4a5c0e7cb75b client:pdf-gen: add template element
Fadi Abbud <fadi.abbud@intevation.de>
parents: 2714
diff changeset
570 // add the used map scale and papersize
2767
3063f1485ad6 client:fix typo
Fadi Abbud <fadi.abbud@intevation.de>
parents: 2754
diff changeset
571 addScale(scaleDenominator, position, width, offset, fontSize, color) {
2737
4a5c0e7cb75b client:pdf-gen: add template element
Fadi Abbud <fadi.abbud@intevation.de>
parents: 2714
diff changeset
572 //TODO: check the correctence of the scalnominator value here.
4a5c0e7cb75b client:pdf-gen: add template element
Fadi Abbud <fadi.abbud@intevation.de>
parents: 2714
diff changeset
573 let str =
4a5c0e7cb75b client:pdf-gen: add template element
Fadi Abbud <fadi.abbud@intevation.de>
parents: 2714
diff changeset
574 this.$gettext("Scale") +
4a5c0e7cb75b client:pdf-gen: add template element
Fadi Abbud <fadi.abbud@intevation.de>
parents: 2714
diff changeset
575 " 1 : " +
2767
3063f1485ad6 client:fix typo
Fadi Abbud <fadi.abbud@intevation.de>
parents: 2754
diff changeset
576 scaleDenominator +
2737
4a5c0e7cb75b client:pdf-gen: add template element
Fadi Abbud <fadi.abbud@intevation.de>
parents: 2714
diff changeset
577 " " +
4a5c0e7cb75b client:pdf-gen: add template element
Fadi Abbud <fadi.abbud@intevation.de>
parents: 2714
diff changeset
578 "(DIN" +
4a5c0e7cb75b client:pdf-gen: add template element
Fadi Abbud <fadi.abbud@intevation.de>
parents: 2714
diff changeset
579 " " +
4a5c0e7cb75b client:pdf-gen: add template element
Fadi Abbud <fadi.abbud@intevation.de>
parents: 2714
diff changeset
580 this.form.paperSize.toUpperCase() +
4a5c0e7cb75b client:pdf-gen: add template element
Fadi Abbud <fadi.abbud@intevation.de>
parents: 2714
diff changeset
581 ")";
4a5c0e7cb75b client:pdf-gen: add template element
Fadi Abbud <fadi.abbud@intevation.de>
parents: 2714
diff changeset
582 this.addText(position, offset, width, fontSize, color, str);
4a5c0e7cb75b client:pdf-gen: add template element
Fadi Abbud <fadi.abbud@intevation.de>
parents: 2714
diff changeset
583 },
2767
3063f1485ad6 client:fix typo
Fadi Abbud <fadi.abbud@intevation.de>
parents: 2754
diff changeset
584 addScaleBar(scaleDenominator, position, offset, rounding, brcolor) {
3063f1485ad6 client:fix typo
Fadi Abbud <fadi.abbud@intevation.de>
parents: 2754
diff changeset
585 // scaleDenominator is the x in 1:x of the map scale
1897
c78efb1ddb02 client: pdf-gen: improve scalebar to show nice values
Bernhard Reiter <bernhard@intevation.de>
parents: 1887
diff changeset
586
2218
631ca0412db9 adjusted positioning of pdf elements
Markus Kottlaender <markus@intevation.de>
parents: 2215
diff changeset
587 // hardcode maximal width for now
1933
1aa2921d8832 client: pdf-gen: make scalebar box size dynamic
Bernhard Reiter <bernhard@intevation.de>
parents: 1931
diff changeset
588 let maxWidth = 80; // in mm
1aa2921d8832 client: pdf-gen: make scalebar box size dynamic
Bernhard Reiter <bernhard@intevation.de>
parents: 1931
diff changeset
589
1897
c78efb1ddb02 client: pdf-gen: improve scalebar to show nice values
Bernhard Reiter <bernhard@intevation.de>
parents: 1887
diff changeset
590 // reduce width until we'll find a nice number for printing
c78efb1ddb02 client: pdf-gen: improve scalebar to show nice values
Bernhard Reiter <bernhard@intevation.de>
parents: 1887
diff changeset
591 // strategy:
c78efb1ddb02 client: pdf-gen: improve scalebar to show nice values
Bernhard Reiter <bernhard@intevation.de>
parents: 1887
diff changeset
592 // 1. check which unit prefix we shall use to get [10:10000[
c78efb1ddb02 client: pdf-gen: improve scalebar to show nice values
Bernhard Reiter <bernhard@intevation.de>
parents: 1887
diff changeset
593 // 2. using a mapping for the leading digit to get [1:10[
c78efb1ddb02 client: pdf-gen: improve scalebar to show nice values
Bernhard Reiter <bernhard@intevation.de>
parents: 1887
diff changeset
594 // 3. select a smaller number which is nicely dividable
c78efb1ddb02 client: pdf-gen: improve scalebar to show nice values
Bernhard Reiter <bernhard@intevation.de>
parents: 1887
diff changeset
595 // 4. scale up again to get length in paper mm and to be shown
c78efb1ddb02 client: pdf-gen: improve scalebar to show nice values
Bernhard Reiter <bernhard@intevation.de>
parents: 1887
diff changeset
596
c78efb1ddb02 client: pdf-gen: improve scalebar to show nice values
Bernhard Reiter <bernhard@intevation.de>
parents: 1887
diff changeset
597 // from https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Math/log10#Polyfill
c78efb1ddb02 client: pdf-gen: improve scalebar to show nice values
Bernhard Reiter <bernhard@intevation.de>
parents: 1887
diff changeset
598 let log10 =
c78efb1ddb02 client: pdf-gen: improve scalebar to show nice values
Bernhard Reiter <bernhard@intevation.de>
parents: 1887
diff changeset
599 Math.log10 || // more precise, but unsupported by IE
c78efb1ddb02 client: pdf-gen: improve scalebar to show nice values
Bernhard Reiter <bernhard@intevation.de>
parents: 1887
diff changeset
600 function(x) {
c78efb1ddb02 client: pdf-gen: improve scalebar to show nice values
Bernhard Reiter <bernhard@intevation.de>
parents: 1887
diff changeset
601 return Math.log(x) * Math.LOG10E;
c78efb1ddb02 client: pdf-gen: improve scalebar to show nice values
Bernhard Reiter <bernhard@intevation.de>
parents: 1887
diff changeset
602 };
c78efb1ddb02 client: pdf-gen: improve scalebar to show nice values
Bernhard Reiter <bernhard@intevation.de>
parents: 1887
diff changeset
603
2767
3063f1485ad6 client:fix typo
Fadi Abbud <fadi.abbud@intevation.de>
parents: 2754
diff changeset
604 let maxLength = maxWidth * scaleDenominator;
1897
c78efb1ddb02 client: pdf-gen: improve scalebar to show nice values
Bernhard Reiter <bernhard@intevation.de>
parents: 1887
diff changeset
605
c78efb1ddb02 client: pdf-gen: improve scalebar to show nice values
Bernhard Reiter <bernhard@intevation.de>
parents: 1887
diff changeset
606 let unit = "mm";
1914
3d2b55d2d8a6 client: pdf-gen: fix scale bar calculation
Bernhard Reiter <bernhard@intevation.de>
parents: 1903
diff changeset
607 let unitConversionFactor = 1;
3d2b55d2d8a6 client: pdf-gen: fix scale bar calculation
Bernhard Reiter <bernhard@intevation.de>
parents: 1903
diff changeset
608 if (maxLength >= 1e7) {
3d2b55d2d8a6 client: pdf-gen: fix scale bar calculation
Bernhard Reiter <bernhard@intevation.de>
parents: 1903
diff changeset
609 // >= 10 km
1897
c78efb1ddb02 client: pdf-gen: improve scalebar to show nice values
Bernhard Reiter <bernhard@intevation.de>
parents: 1887
diff changeset
610 unit = "km";
1914
3d2b55d2d8a6 client: pdf-gen: fix scale bar calculation
Bernhard Reiter <bernhard@intevation.de>
parents: 1903
diff changeset
611 unitConversionFactor = 1e6;
3d2b55d2d8a6 client: pdf-gen: fix scale bar calculation
Bernhard Reiter <bernhard@intevation.de>
parents: 1903
diff changeset
612 } else if (maxLength >= 1e4) {
3d2b55d2d8a6 client: pdf-gen: fix scale bar calculation
Bernhard Reiter <bernhard@intevation.de>
parents: 1903
diff changeset
613 // >= 10 m
1897
c78efb1ddb02 client: pdf-gen: improve scalebar to show nice values
Bernhard Reiter <bernhard@intevation.de>
parents: 1887
diff changeset
614 unit = "m";
1914
3d2b55d2d8a6 client: pdf-gen: fix scale bar calculation
Bernhard Reiter <bernhard@intevation.de>
parents: 1903
diff changeset
615 unitConversionFactor = 1e3;
1897
c78efb1ddb02 client: pdf-gen: improve scalebar to show nice values
Bernhard Reiter <bernhard@intevation.de>
parents: 1887
diff changeset
616 }
c78efb1ddb02 client: pdf-gen: improve scalebar to show nice values
Bernhard Reiter <bernhard@intevation.de>
parents: 1887
diff changeset
617
c78efb1ddb02 client: pdf-gen: improve scalebar to show nice values
Bernhard Reiter <bernhard@intevation.de>
parents: 1887
diff changeset
618 maxLength /= unitConversionFactor;
c78efb1ddb02 client: pdf-gen: improve scalebar to show nice values
Bernhard Reiter <bernhard@intevation.de>
parents: 1887
diff changeset
619
c78efb1ddb02 client: pdf-gen: improve scalebar to show nice values
Bernhard Reiter <bernhard@intevation.de>
parents: 1887
diff changeset
620 let unroundedLength = maxLength;
c78efb1ddb02 client: pdf-gen: improve scalebar to show nice values
Bernhard Reiter <bernhard@intevation.de>
parents: 1887
diff changeset
621 let numberOfDigits = Math.floor(log10(unroundedLength));
c78efb1ddb02 client: pdf-gen: improve scalebar to show nice values
Bernhard Reiter <bernhard@intevation.de>
parents: 1887
diff changeset
622 let factor = Math.pow(10, numberOfDigits);
c78efb1ddb02 client: pdf-gen: improve scalebar to show nice values
Bernhard Reiter <bernhard@intevation.de>
parents: 1887
diff changeset
623 let mapped = unroundedLength / factor;
c78efb1ddb02 client: pdf-gen: improve scalebar to show nice values
Bernhard Reiter <bernhard@intevation.de>
parents: 1887
diff changeset
624
c78efb1ddb02 client: pdf-gen: improve scalebar to show nice values
Bernhard Reiter <bernhard@intevation.de>
parents: 1887
diff changeset
625 var length = Math.floor(maxLength); // just to have an upper limit
c78efb1ddb02 client: pdf-gen: improve scalebar to show nice values
Bernhard Reiter <bernhard@intevation.de>
parents: 1887
diff changeset
626
c78efb1ddb02 client: pdf-gen: improve scalebar to show nice values
Bernhard Reiter <bernhard@intevation.de>
parents: 1887
diff changeset
627 // manually only use numbers that are very nice to devide by 4
c78efb1ddb02 client: pdf-gen: improve scalebar to show nice values
Bernhard Reiter <bernhard@intevation.de>
parents: 1887
diff changeset
628 // note that this is taken into account for rounding later
c78efb1ddb02 client: pdf-gen: improve scalebar to show nice values
Bernhard Reiter <bernhard@intevation.de>
parents: 1887
diff changeset
629 if (mapped > 8) {
c78efb1ddb02 client: pdf-gen: improve scalebar to show nice values
Bernhard Reiter <bernhard@intevation.de>
parents: 1887
diff changeset
630 length = 8 * factor;
c78efb1ddb02 client: pdf-gen: improve scalebar to show nice values
Bernhard Reiter <bernhard@intevation.de>
parents: 1887
diff changeset
631 } else if (mapped > 4) {
c78efb1ddb02 client: pdf-gen: improve scalebar to show nice values
Bernhard Reiter <bernhard@intevation.de>
parents: 1887
diff changeset
632 length = 4 * factor;
c78efb1ddb02 client: pdf-gen: improve scalebar to show nice values
Bernhard Reiter <bernhard@intevation.de>
parents: 1887
diff changeset
633 } else if (mapped > 2) {
c78efb1ddb02 client: pdf-gen: improve scalebar to show nice values
Bernhard Reiter <bernhard@intevation.de>
parents: 1887
diff changeset
634 length = 2 * factor;
c78efb1ddb02 client: pdf-gen: improve scalebar to show nice values
Bernhard Reiter <bernhard@intevation.de>
parents: 1887
diff changeset
635 } else {
c78efb1ddb02 client: pdf-gen: improve scalebar to show nice values
Bernhard Reiter <bernhard@intevation.de>
parents: 1887
diff changeset
636 length = factor;
c78efb1ddb02 client: pdf-gen: improve scalebar to show nice values
Bernhard Reiter <bernhard@intevation.de>
parents: 1887
diff changeset
637 }
c78efb1ddb02 client: pdf-gen: improve scalebar to show nice values
Bernhard Reiter <bernhard@intevation.de>
parents: 1887
diff changeset
638
2767
3063f1485ad6 client:fix typo
Fadi Abbud <fadi.abbud@intevation.de>
parents: 2754
diff changeset
639 let size = (length * unitConversionFactor) / scaleDenominator / 4;
2218
631ca0412db9 adjusted positioning of pdf elements
Markus Kottlaender <markus@intevation.de>
parents: 2215
diff changeset
640 let fullSize = size * 4;
1933
1aa2921d8832 client: pdf-gen: make scalebar box size dynamic
Bernhard Reiter <bernhard@intevation.de>
parents: 1931
diff changeset
641
2218
631ca0412db9 adjusted positioning of pdf elements
Markus Kottlaender <markus@intevation.de>
parents: 2215
diff changeset
642 // x/y defaults to offset for topleft corner (normal x/y coordinates)
631ca0412db9 adjusted positioning of pdf elements
Markus Kottlaender <markus@intevation.de>
parents: 2215
diff changeset
643 let x = offset.x;
631ca0412db9 adjusted positioning of pdf elements
Markus Kottlaender <markus@intevation.de>
parents: 2215
diff changeset
644 let y = offset.y;
1933
1aa2921d8832 client: pdf-gen: make scalebar box size dynamic
Bernhard Reiter <bernhard@intevation.de>
parents: 1931
diff changeset
645
2218
631ca0412db9 adjusted positioning of pdf elements
Markus Kottlaender <markus@intevation.de>
parents: 2215
diff changeset
646 // if position is on the right, x needs to be calculate with pdf width and
631ca0412db9 adjusted positioning of pdf elements
Markus Kottlaender <markus@intevation.de>
parents: 2215
diff changeset
647 // the size of the element
631ca0412db9 adjusted positioning of pdf elements
Markus Kottlaender <markus@intevation.de>
parents: 2215
diff changeset
648 if (["topright", "bottomright"].indexOf(position) !== -1) {
631ca0412db9 adjusted positioning of pdf elements
Markus Kottlaender <markus@intevation.de>
parents: 2215
diff changeset
649 x = this.pdf.width - offset.x - fullSize - 8;
631ca0412db9 adjusted positioning of pdf elements
Markus Kottlaender <markus@intevation.de>
parents: 2215
diff changeset
650 }
631ca0412db9 adjusted positioning of pdf elements
Markus Kottlaender <markus@intevation.de>
parents: 2215
diff changeset
651 if (["bottomright", "bottomleft"].indexOf(position) !== -1) {
631ca0412db9 adjusted positioning of pdf elements
Markus Kottlaender <markus@intevation.de>
parents: 2215
diff changeset
652 y = this.pdf.height - offset.y - 10;
631ca0412db9 adjusted positioning of pdf elements
Markus Kottlaender <markus@intevation.de>
parents: 2215
diff changeset
653 }
631ca0412db9 adjusted positioning of pdf elements
Markus Kottlaender <markus@intevation.de>
parents: 2215
diff changeset
654
631ca0412db9 adjusted positioning of pdf elements
Markus Kottlaender <markus@intevation.de>
parents: 2215
diff changeset
655 // to give the outer white box 4mm padding
631ca0412db9 adjusted positioning of pdf elements
Markus Kottlaender <markus@intevation.de>
parents: 2215
diff changeset
656 let scaleBarX = x + 4;
631ca0412db9 adjusted positioning of pdf elements
Markus Kottlaender <markus@intevation.de>
parents: 2215
diff changeset
657 let scaleBarY = y + 5; // 5 because above the scalebar will be the numbers
631ca0412db9 adjusted positioning of pdf elements
Markus Kottlaender <markus@intevation.de>
parents: 2215
diff changeset
658
631ca0412db9 adjusted positioning of pdf elements
Markus Kottlaender <markus@intevation.de>
parents: 2215
diff changeset
659 // draw outer white box
2714
4dd38840d74b client:pdf-gen:imporve some template elements
Fadi Abbud <fadi.abbud@intevation.de>
parents: 2561
diff changeset
660 this.addRoundedBox(x, y, fullSize + 8, 10, "white", rounding, brcolor);
1897
c78efb1ddb02 client: pdf-gen: improve scalebar to show nice values
Bernhard Reiter <bernhard@intevation.de>
parents: 1887
diff changeset
661
2218
631ca0412db9 adjusted positioning of pdf elements
Markus Kottlaender <markus@intevation.de>
parents: 2215
diff changeset
662 // draw first part of scalebar
631ca0412db9 adjusted positioning of pdf elements
Markus Kottlaender <markus@intevation.de>
parents: 2215
diff changeset
663 this.pdf.doc.setDrawColor(0, 0, 0);
631ca0412db9 adjusted positioning of pdf elements
Markus Kottlaender <markus@intevation.de>
parents: 2215
diff changeset
664 this.pdf.doc.setFillColor(0, 0, 0);
631ca0412db9 adjusted positioning of pdf elements
Markus Kottlaender <markus@intevation.de>
parents: 2215
diff changeset
665 this.pdf.doc.rect(scaleBarX, scaleBarY, size, 1, "FD");
631ca0412db9 adjusted positioning of pdf elements
Markus Kottlaender <markus@intevation.de>
parents: 2215
diff changeset
666
631ca0412db9 adjusted positioning of pdf elements
Markus Kottlaender <markus@intevation.de>
parents: 2215
diff changeset
667 // draw second part of scalebar
631ca0412db9 adjusted positioning of pdf elements
Markus Kottlaender <markus@intevation.de>
parents: 2215
diff changeset
668 this.pdf.doc.setDrawColor(0, 0, 0);
631ca0412db9 adjusted positioning of pdf elements
Markus Kottlaender <markus@intevation.de>
parents: 2215
diff changeset
669 this.pdf.doc.setFillColor(255, 255, 255);
631ca0412db9 adjusted positioning of pdf elements
Markus Kottlaender <markus@intevation.de>
parents: 2215
diff changeset
670 this.pdf.doc.rect(scaleBarX + size, scaleBarY, size, 1, "FD");
631ca0412db9 adjusted positioning of pdf elements
Markus Kottlaender <markus@intevation.de>
parents: 2215
diff changeset
671
631ca0412db9 adjusted positioning of pdf elements
Markus Kottlaender <markus@intevation.de>
parents: 2215
diff changeset
672 // draw third part of scalebar
631ca0412db9 adjusted positioning of pdf elements
Markus Kottlaender <markus@intevation.de>
parents: 2215
diff changeset
673 this.pdf.doc.setDrawColor(0, 0, 0);
631ca0412db9 adjusted positioning of pdf elements
Markus Kottlaender <markus@intevation.de>
parents: 2215
diff changeset
674 this.pdf.doc.setFillColor(0, 0, 0);
631ca0412db9 adjusted positioning of pdf elements
Markus Kottlaender <markus@intevation.de>
parents: 2215
diff changeset
675 this.pdf.doc.rect(scaleBarX + size * 2, scaleBarY, size * 2, 1, "FD");
631ca0412db9 adjusted positioning of pdf elements
Markus Kottlaender <markus@intevation.de>
parents: 2215
diff changeset
676
631ca0412db9 adjusted positioning of pdf elements
Markus Kottlaender <markus@intevation.de>
parents: 2215
diff changeset
677 // draw numeric labels above scalebar
2223
85142493096c PDF generation: improved positioning, prepared demo templates
Markus Kottlaender <markus@intevation.de>
parents: 2222
diff changeset
678 this.pdf.doc.setTextColor("black");
2240
c3cc21dee75d client: pdf-gen add multi-language font
Bernhard Reiter <bernhard@intevation.de>
parents: 2227
diff changeset
679 this.pdf.doc.setFontSize(6);
2218
631ca0412db9 adjusted positioning of pdf elements
Markus Kottlaender <markus@intevation.de>
parents: 2215
diff changeset
680 this.pdf.doc.text(scaleBarX, scaleBarY - 1, "0");
1897
c78efb1ddb02 client: pdf-gen: improve scalebar to show nice values
Bernhard Reiter <bernhard@intevation.de>
parents: 1887
diff changeset
681 // /4 and could give 2.5. We still round, because of floating point arith
2218
631ca0412db9 adjusted positioning of pdf elements
Markus Kottlaender <markus@intevation.de>
parents: 2215
diff changeset
682 this.pdf.doc.text(
631ca0412db9 adjusted positioning of pdf elements
Markus Kottlaender <markus@intevation.de>
parents: 2215
diff changeset
683 scaleBarX + size - 1,
631ca0412db9 adjusted positioning of pdf elements
Markus Kottlaender <markus@intevation.de>
parents: 2215
diff changeset
684 scaleBarY - 1,
1897
c78efb1ddb02 client: pdf-gen: improve scalebar to show nice values
Bernhard Reiter <bernhard@intevation.de>
parents: 1887
diff changeset
685 (Math.round((length * 10) / 4) / 10).toString()
1884
59ef76d83de7 client: pdf-gen: make scalebar dynamic
Bernhard Reiter <bernhard@intevation.de>
parents: 1883
diff changeset
686 );
2218
631ca0412db9 adjusted positioning of pdf elements
Markus Kottlaender <markus@intevation.de>
parents: 2215
diff changeset
687 this.pdf.doc.text(
631ca0412db9 adjusted positioning of pdf elements
Markus Kottlaender <markus@intevation.de>
parents: 2215
diff changeset
688 scaleBarX + size * 2 - 2,
631ca0412db9 adjusted positioning of pdf elements
Markus Kottlaender <markus@intevation.de>
parents: 2215
diff changeset
689 scaleBarY - 1,
631ca0412db9 adjusted positioning of pdf elements
Markus Kottlaender <markus@intevation.de>
parents: 2215
diff changeset
690 Math.round(length / 2).toString()
631ca0412db9 adjusted positioning of pdf elements
Markus Kottlaender <markus@intevation.de>
parents: 2215
diff changeset
691 );
631ca0412db9 adjusted positioning of pdf elements
Markus Kottlaender <markus@intevation.de>
parents: 2215
diff changeset
692 this.pdf.doc.text(
631ca0412db9 adjusted positioning of pdf elements
Markus Kottlaender <markus@intevation.de>
parents: 2215
diff changeset
693 scaleBarX + size * 4 - 4,
631ca0412db9 adjusted positioning of pdf elements
Markus Kottlaender <markus@intevation.de>
parents: 2215
diff changeset
694 scaleBarY - 1,
631ca0412db9 adjusted positioning of pdf elements
Markus Kottlaender <markus@intevation.de>
parents: 2215
diff changeset
695 Math.round(length).toString() + " " + unit
631ca0412db9 adjusted positioning of pdf elements
Markus Kottlaender <markus@intevation.de>
parents: 2215
diff changeset
696 );
1876
e53924abb4a2 client: export some elements to pdf
Fadi Abbud <fadi.abbud@intevation.de>
parents: 1874
diff changeset
697 },
2218
631ca0412db9 adjusted positioning of pdf elements
Markus Kottlaender <markus@intevation.de>
parents: 2215
diff changeset
698 addNorthArrow(position, offset, size) {
631ca0412db9 adjusted positioning of pdf elements
Markus Kottlaender <markus@intevation.de>
parents: 2215
diff changeset
699 // TODO: fix positioning
631ca0412db9 adjusted positioning of pdf elements
Markus Kottlaender <markus@intevation.de>
parents: 2215
diff changeset
700 // x/y defaults to offset for topleft corner (normal x/y coordinates)
631ca0412db9 adjusted positioning of pdf elements
Markus Kottlaender <markus@intevation.de>
parents: 2215
diff changeset
701 let x1 = offset.x;
631ca0412db9 adjusted positioning of pdf elements
Markus Kottlaender <markus@intevation.de>
parents: 2215
diff changeset
702 let y1 = offset.y;
1876
e53924abb4a2 client: export some elements to pdf
Fadi Abbud <fadi.abbud@intevation.de>
parents: 1874
diff changeset
703
2218
631ca0412db9 adjusted positioning of pdf elements
Markus Kottlaender <markus@intevation.de>
parents: 2215
diff changeset
704 // if position is on the right, x needs to be calculate with pdf width and
631ca0412db9 adjusted positioning of pdf elements
Markus Kottlaender <markus@intevation.de>
parents: 2215
diff changeset
705 // the size of the element
631ca0412db9 adjusted positioning of pdf elements
Markus Kottlaender <markus@intevation.de>
parents: 2215
diff changeset
706 if (["topright", "bottomright"].indexOf(position) !== -1) {
631ca0412db9 adjusted positioning of pdf elements
Markus Kottlaender <markus@intevation.de>
parents: 2215
diff changeset
707 x1 = this.pdf.width - offset.x - size;
631ca0412db9 adjusted positioning of pdf elements
Markus Kottlaender <markus@intevation.de>
parents: 2215
diff changeset
708 }
631ca0412db9 adjusted positioning of pdf elements
Markus Kottlaender <markus@intevation.de>
parents: 2215
diff changeset
709 if (["bottomright", "bottomleft"].indexOf(position) !== -1) {
631ca0412db9 adjusted positioning of pdf elements
Markus Kottlaender <markus@intevation.de>
parents: 2215
diff changeset
710 y1 = this.pdf.height - offset.y - size;
631ca0412db9 adjusted positioning of pdf elements
Markus Kottlaender <markus@intevation.de>
parents: 2215
diff changeset
711 }
2220
d926292d81b6 PDF generation: changed form labels/option texts
Markus Kottlaender <markus@intevation.de>
parents: 2219
diff changeset
712
1876
e53924abb4a2 client: export some elements to pdf
Fadi Abbud <fadi.abbud@intevation.de>
parents: 1874
diff changeset
713 var y2 = y1 + size * 3;
e53924abb4a2 client: export some elements to pdf
Fadi Abbud <fadi.abbud@intevation.de>
parents: 1874
diff changeset
714 var x3 = x1 - size * 2;
e53924abb4a2 client: export some elements to pdf
Fadi Abbud <fadi.abbud@intevation.de>
parents: 1874
diff changeset
715 var y3 = y1 + size * 5;
e53924abb4a2 client: export some elements to pdf
Fadi Abbud <fadi.abbud@intevation.de>
parents: 1874
diff changeset
716 var x4 = x1 + size * 2;
2218
631ca0412db9 adjusted positioning of pdf elements
Markus Kottlaender <markus@intevation.de>
parents: 2215
diff changeset
717 // white triangle
631ca0412db9 adjusted positioning of pdf elements
Markus Kottlaender <markus@intevation.de>
parents: 2215
diff changeset
718 this.pdf.doc.setFillColor(255, 255, 255);
631ca0412db9 adjusted positioning of pdf elements
Markus Kottlaender <markus@intevation.de>
parents: 2215
diff changeset
719 this.pdf.doc.setDrawColor(255, 255, 255);
631ca0412db9 adjusted positioning of pdf elements
Markus Kottlaender <markus@intevation.de>
parents: 2215
diff changeset
720 this.pdf.doc.triangle(
631ca0412db9 adjusted positioning of pdf elements
Markus Kottlaender <markus@intevation.de>
parents: 2215
diff changeset
721 x3 - 0.8,
631ca0412db9 adjusted positioning of pdf elements
Markus Kottlaender <markus@intevation.de>
parents: 2215
diff changeset
722 y3 + 1.2,
631ca0412db9 adjusted positioning of pdf elements
Markus Kottlaender <markus@intevation.de>
parents: 2215
diff changeset
723 x1,
631ca0412db9 adjusted positioning of pdf elements
Markus Kottlaender <markus@intevation.de>
parents: 2215
diff changeset
724 y1 - 1.2,
631ca0412db9 adjusted positioning of pdf elements
Markus Kottlaender <markus@intevation.de>
parents: 2215
diff changeset
725 x1,
631ca0412db9 adjusted positioning of pdf elements
Markus Kottlaender <markus@intevation.de>
parents: 2215
diff changeset
726 y2 + 0.6,
631ca0412db9 adjusted positioning of pdf elements
Markus Kottlaender <markus@intevation.de>
parents: 2215
diff changeset
727 "F"
631ca0412db9 adjusted positioning of pdf elements
Markus Kottlaender <markus@intevation.de>
parents: 2215
diff changeset
728 );
631ca0412db9 adjusted positioning of pdf elements
Markus Kottlaender <markus@intevation.de>
parents: 2215
diff changeset
729 this.pdf.doc.triangle(
631ca0412db9 adjusted positioning of pdf elements
Markus Kottlaender <markus@intevation.de>
parents: 2215
diff changeset
730 x1,
631ca0412db9 adjusted positioning of pdf elements
Markus Kottlaender <markus@intevation.de>
parents: 2215
diff changeset
731 y1 - 1.2,
631ca0412db9 adjusted positioning of pdf elements
Markus Kottlaender <markus@intevation.de>
parents: 2215
diff changeset
732 x1,
631ca0412db9 adjusted positioning of pdf elements
Markus Kottlaender <markus@intevation.de>
parents: 2215
diff changeset
733 y2 + 0.6,
631ca0412db9 adjusted positioning of pdf elements
Markus Kottlaender <markus@intevation.de>
parents: 2215
diff changeset
734 x4 + 0.8,
631ca0412db9 adjusted positioning of pdf elements
Markus Kottlaender <markus@intevation.de>
parents: 2215
diff changeset
735 y3 + 1.2,
631ca0412db9 adjusted positioning of pdf elements
Markus Kottlaender <markus@intevation.de>
parents: 2215
diff changeset
736 "F"
631ca0412db9 adjusted positioning of pdf elements
Markus Kottlaender <markus@intevation.de>
parents: 2215
diff changeset
737 );
631ca0412db9 adjusted positioning of pdf elements
Markus Kottlaender <markus@intevation.de>
parents: 2215
diff changeset
738
631ca0412db9 adjusted positioning of pdf elements
Markus Kottlaender <markus@intevation.de>
parents: 2215
diff changeset
739 // north arrow
631ca0412db9 adjusted positioning of pdf elements
Markus Kottlaender <markus@intevation.de>
parents: 2215
diff changeset
740 this.pdf.doc.setDrawColor(0, 0, 0);
631ca0412db9 adjusted positioning of pdf elements
Markus Kottlaender <markus@intevation.de>
parents: 2215
diff changeset
741 this.pdf.doc.setFillColor(255, 255, 255);
2539
ad2a1d02ad1c client:pdf-gen: improve north arrow drawing
Fadi Abbud <fadi.abbud@intevation.de>
parents: 2534
diff changeset
742 this.pdf.doc.triangle(x3, y3, x1 - 0.1, y1 + 0.2, x1 - 0.1, y2, "FD");
2218
631ca0412db9 adjusted positioning of pdf elements
Markus Kottlaender <markus@intevation.de>
parents: 2215
diff changeset
743 this.pdf.doc.setFillColor(0, 0, 0);
2539
ad2a1d02ad1c client:pdf-gen: improve north arrow drawing
Fadi Abbud <fadi.abbud@intevation.de>
parents: 2534
diff changeset
744 this.pdf.doc.triangle(x1 + 0.1, y1 + 0.2, x1 + 0.1, y2, x4, y3, "FD");
2218
631ca0412db9 adjusted positioning of pdf elements
Markus Kottlaender <markus@intevation.de>
parents: 2215
diff changeset
745 this.pdf.doc.setFontSize(size * 3.1);
631ca0412db9 adjusted positioning of pdf elements
Markus Kottlaender <markus@intevation.de>
parents: 2215
diff changeset
746 this.pdf.doc.setTextColor(255, 255, 255);
631ca0412db9 adjusted positioning of pdf elements
Markus Kottlaender <markus@intevation.de>
parents: 2215
diff changeset
747 this.pdf.doc.setFontStyle("bold");
631ca0412db9 adjusted positioning of pdf elements
Markus Kottlaender <markus@intevation.de>
parents: 2215
diff changeset
748 this.pdf.doc.text(size < 3 ? x1 - 0.5 : x1 - 1.3, y3 + 1, "N");
631ca0412db9 adjusted positioning of pdf elements
Markus Kottlaender <markus@intevation.de>
parents: 2215
diff changeset
749 this.pdf.doc.setFontSize(size * 3);
631ca0412db9 adjusted positioning of pdf elements
Markus Kottlaender <markus@intevation.de>
parents: 2215
diff changeset
750 this.pdf.doc.setTextColor(0, 0, 0);
631ca0412db9 adjusted positioning of pdf elements
Markus Kottlaender <markus@intevation.de>
parents: 2215
diff changeset
751 this.pdf.doc.setFontStyle("normal");
631ca0412db9 adjusted positioning of pdf elements
Markus Kottlaender <markus@intevation.de>
parents: 2215
diff changeset
752 this.pdf.doc.text(size < 3 ? x1 - 0.5 : x1 - 1.3, y3 + 1, "N");
1876
e53924abb4a2 client: export some elements to pdf
Fadi Abbud <fadi.abbud@intevation.de>
parents: 1874
diff changeset
753 },
5310
660147046ddd Client: Implement handling zpg-exception info in pdf
Fadi Abbud <fadi.abbud@intevation.de>
parents: 5288
diff changeset
754 addLegend(position, offset, rounding, brcolor, hasSounding) {
2220
d926292d81b6 PDF generation: changed form labels/option texts
Markus Kottlaender <markus@intevation.de>
parents: 2219
diff changeset
755 if (
5310
660147046ddd Client: Implement handling zpg-exception info in pdf
Fadi Abbud <fadi.abbud@intevation.de>
parents: 5288
diff changeset
756 hasSounding &&
4488
bff6c5c1db4f client: pdf-gen: improve adding bottleneck info to pdf
Fadi Abbud <fadi.abbud@intevation.de>
parents: 4480
diff changeset
757 this.bottleneckForPrint &&
2259
7e378b38d302 client: pdf-gen: made selectedSurvey mandatory for displaying the bottleneck info box and iso line legend.
Markus Kottlaender <markus@intevation.de>
parents: 2258
diff changeset
758 this.selectedSurvey &&
3127
0374197c384f client: fix openLayersMap getter calls
Markus Kottlaender <markus@intevation.de>
parents: 3044
diff changeset
759 this.openLayersMap()
0374197c384f client: fix openLayersMap getter calls
Markus Kottlaender <markus@intevation.de>
parents: 3044
diff changeset
760 .getLayer("BOTTLENECKISOLINE")
0374197c384f client: fix openLayersMap getter calls
Markus Kottlaender <markus@intevation.de>
parents: 3044
diff changeset
761 .getVisible()
2220
d926292d81b6 PDF generation: changed form labels/option texts
Markus Kottlaender <markus@intevation.de>
parents: 2219
diff changeset
762 ) {
5318
ef07b81d3305 PDFTool: Changed layout rendering of bottleneck infobox.
Thomas Junk <thomas.junk@intevation.de>
parents: 5312
diff changeset
763 const ZPGEXCEPTION =
ef07b81d3305 PDFTool: Changed layout rendering of bottleneck infobox.
Thomas Junk <thomas.junk@intevation.de>
parents: 5312
diff changeset
764 this.soundingInfo &&
ef07b81d3305 PDFTool: Changed layout rendering of bottleneck infobox.
Thomas Junk <thomas.junk@intevation.de>
parents: 5312
diff changeset
765 this.soundingInfo.number > 0 &&
ef07b81d3305 PDFTool: Changed layout rendering of bottleneck infobox.
Thomas Junk <thomas.junk@intevation.de>
parents: 5312
diff changeset
766 this.soundingInfo.feature.properties.zpg_exception;
ef07b81d3305 PDFTool: Changed layout rendering of bottleneck infobox.
Thomas Junk <thomas.junk@intevation.de>
parents: 5312
diff changeset
767 let SPACER = ZPGEXCEPTION ? 10 : 4;
ef07b81d3305 PDFTool: Changed layout rendering of bottleneck infobox.
Thomas Junk <thomas.junk@intevation.de>
parents: 5312
diff changeset
768
2218
631ca0412db9 adjusted positioning of pdf elements
Markus Kottlaender <markus@intevation.de>
parents: 2215
diff changeset
769 // transforming into an HTMLImageElement only to find out
631ca0412db9 adjusted positioning of pdf elements
Markus Kottlaender <markus@intevation.de>
parents: 2215
diff changeset
770 // the width x height of the legend image
631ca0412db9 adjusted positioning of pdf elements
Markus Kottlaender <markus@intevation.de>
parents: 2215
diff changeset
771 // FUTURE: find a better way to get the width and height
631ca0412db9 adjusted positioning of pdf elements
Markus Kottlaender <markus@intevation.de>
parents: 2215
diff changeset
772 let legendImage = new Image();
631ca0412db9 adjusted positioning of pdf elements
Markus Kottlaender <markus@intevation.de>
parents: 2215
diff changeset
773 legendImage.src = this.isolinesLegendImgDataURL;
631ca0412db9 adjusted positioning of pdf elements
Markus Kottlaender <markus@intevation.de>
parents: 2215
diff changeset
774 let aspectRatio = legendImage.width / legendImage.height;
631ca0412db9 adjusted positioning of pdf elements
Markus Kottlaender <markus@intevation.de>
parents: 2215
diff changeset
775 let width = 54;
631ca0412db9 adjusted positioning of pdf elements
Markus Kottlaender <markus@intevation.de>
parents: 2215
diff changeset
776 let height = width / aspectRatio;
631ca0412db9 adjusted positioning of pdf elements
Markus Kottlaender <markus@intevation.de>
parents: 2215
diff changeset
777 let padding = 2;
2220
d926292d81b6 PDF generation: changed form labels/option texts
Markus Kottlaender <markus@intevation.de>
parents: 2219
diff changeset
778
2218
631ca0412db9 adjusted positioning of pdf elements
Markus Kottlaender <markus@intevation.de>
parents: 2215
diff changeset
779 // x/y defaults to offset for topleft corner (normal x/y coordinates)
631ca0412db9 adjusted positioning of pdf elements
Markus Kottlaender <markus@intevation.de>
parents: 2215
diff changeset
780 let x = offset.x;
5318
ef07b81d3305 PDFTool: Changed layout rendering of bottleneck infobox.
Thomas Junk <thomas.junk@intevation.de>
parents: 5312
diff changeset
781 let y = offset.y + SPACER;
1947
4235fa8f59d7 clien: pdf-gen: load logo externally; add prepare step
Bernhard Reiter <bernhard@intevation.de>
parents: 1936
diff changeset
782
2218
631ca0412db9 adjusted positioning of pdf elements
Markus Kottlaender <markus@intevation.de>
parents: 2215
diff changeset
783 // if position is on the right, x needs to be calculate with pdf width and
631ca0412db9 adjusted positioning of pdf elements
Markus Kottlaender <markus@intevation.de>
parents: 2215
diff changeset
784 // the size of the element
631ca0412db9 adjusted positioning of pdf elements
Markus Kottlaender <markus@intevation.de>
parents: 2215
diff changeset
785 if (["topright", "bottomright"].indexOf(position) !== -1) {
631ca0412db9 adjusted positioning of pdf elements
Markus Kottlaender <markus@intevation.de>
parents: 2215
diff changeset
786 x = this.pdf.width - offset.x - width;
631ca0412db9 adjusted positioning of pdf elements
Markus Kottlaender <markus@intevation.de>
parents: 2215
diff changeset
787 }
631ca0412db9 adjusted positioning of pdf elements
Markus Kottlaender <markus@intevation.de>
parents: 2215
diff changeset
788 if (["bottomright", "bottomleft"].indexOf(position) !== -1) {
5318
ef07b81d3305 PDFTool: Changed layout rendering of bottleneck infobox.
Thomas Junk <thomas.junk@intevation.de>
parents: 5312
diff changeset
789 y = this.pdf.height - offset.y - SPACER - height;
2218
631ca0412db9 adjusted positioning of pdf elements
Markus Kottlaender <markus@intevation.de>
parents: 2215
diff changeset
790 }
1947
4235fa8f59d7 clien: pdf-gen: load logo externally; add prepare step
Bernhard Reiter <bernhard@intevation.de>
parents: 1936
diff changeset
791
2714
4dd38840d74b client:pdf-gen:imporve some template elements
Fadi Abbud <fadi.abbud@intevation.de>
parents: 2561
diff changeset
792 this.addRoundedBox(x, y, width, height, "white", rounding, brcolor);
2218
631ca0412db9 adjusted positioning of pdf elements
Markus Kottlaender <markus@intevation.de>
parents: 2215
diff changeset
793 this.pdf.doc.addImage(
631ca0412db9 adjusted positioning of pdf elements
Markus Kottlaender <markus@intevation.de>
parents: 2215
diff changeset
794 legendImage,
631ca0412db9 adjusted positioning of pdf elements
Markus Kottlaender <markus@intevation.de>
parents: 2215
diff changeset
795 x + padding,
631ca0412db9 adjusted positioning of pdf elements
Markus Kottlaender <markus@intevation.de>
parents: 2215
diff changeset
796 y + padding,
631ca0412db9 adjusted positioning of pdf elements
Markus Kottlaender <markus@intevation.de>
parents: 2215
diff changeset
797 width - 2 * padding,
631ca0412db9 adjusted positioning of pdf elements
Markus Kottlaender <markus@intevation.de>
parents: 2215
diff changeset
798 height - 2 * padding
631ca0412db9 adjusted positioning of pdf elements
Markus Kottlaender <markus@intevation.de>
parents: 2215
diff changeset
799 );
631ca0412db9 adjusted positioning of pdf elements
Markus Kottlaender <markus@intevation.de>
parents: 2215
diff changeset
800 }
1931
8fb1b1a8ea85 client: pdf-gen: improve legend behaviour
Bernhard Reiter <bernhard@intevation.de>
parents: 1928
diff changeset
801 },
5310
660147046ddd Client: Implement handling zpg-exception info in pdf
Fadi Abbud <fadi.abbud@intevation.de>
parents: 5288
diff changeset
802 addBottleneckInfo(position, offset, rounding, color, brcolor, hasSounding) {
2220
d926292d81b6 PDF generation: changed form labels/option texts
Markus Kottlaender <markus@intevation.de>
parents: 2219
diff changeset
803 if (
5310
660147046ddd Client: Implement handling zpg-exception info in pdf
Fadi Abbud <fadi.abbud@intevation.de>
parents: 5288
diff changeset
804 hasSounding &&
4488
bff6c5c1db4f client: pdf-gen: improve adding bottleneck info to pdf
Fadi Abbud <fadi.abbud@intevation.de>
parents: 4480
diff changeset
805 this.bottleneckForPrint &&
2259
7e378b38d302 client: pdf-gen: made selectedSurvey mandatory for displaying the bottleneck info box and iso line legend.
Markus Kottlaender <markus@intevation.de>
parents: 2258
diff changeset
806 this.selectedSurvey &&
3127
0374197c384f client: fix openLayersMap getter calls
Markus Kottlaender <markus@intevation.de>
parents: 3044
diff changeset
807 this.openLayersMap()
0374197c384f client: fix openLayersMap getter calls
Markus Kottlaender <markus@intevation.de>
parents: 3044
diff changeset
808 .getLayer("BOTTLENECKISOLINE")
0374197c384f client: fix openLayersMap getter calls
Markus Kottlaender <markus@intevation.de>
parents: 3044
diff changeset
809 .getVisible()
2220
d926292d81b6 PDF generation: changed form labels/option texts
Markus Kottlaender <markus@intevation.de>
parents: 2219
diff changeset
810 ) {
5318
ef07b81d3305 PDFTool: Changed layout rendering of bottleneck infobox.
Thomas Junk <thomas.junk@intevation.de>
parents: 5312
diff changeset
811 const ZPGEXCEPTION =
ef07b81d3305 PDFTool: Changed layout rendering of bottleneck infobox.
Thomas Junk <thomas.junk@intevation.de>
parents: 5312
diff changeset
812 this.soundingInfo &&
ef07b81d3305 PDFTool: Changed layout rendering of bottleneck infobox.
Thomas Junk <thomas.junk@intevation.de>
parents: 5312
diff changeset
813 this.soundingInfo.number > 0 &&
ef07b81d3305 PDFTool: Changed layout rendering of bottleneck infobox.
Thomas Junk <thomas.junk@intevation.de>
parents: 5312
diff changeset
814 this.soundingInfo.feature.properties.zpg_exception;
ef07b81d3305 PDFTool: Changed layout rendering of bottleneck infobox.
Thomas Junk <thomas.junk@intevation.de>
parents: 5312
diff changeset
815
2258
24cafd6b1a55 client: pdf-gen: width of bottleneck info box is calculated based on its content now
Markus Kottlaender <markus@intevation.de>
parents: 2257
diff changeset
816 let survey = this.selectedSurvey;
5435
351d38269e4e Display of the according type of sounding data in legend.
Thomas Junk <thomas.junk@intevation.de>
parents: 5434
diff changeset
817 const SURVEYTYPES = {
351d38269e4e Display of the according type of sounding data in legend.
Thomas Junk <thomas.junk@intevation.de>
parents: 5434
diff changeset
818 marking: "Marking Vessel",
351d38269e4e Display of the according type of sounding data in legend.
Thomas Junk <thomas.junk@intevation.de>
parents: 5434
diff changeset
819 multi: "Multibeam",
351d38269e4e Display of the according type of sounding data in legend.
Thomas Junk <thomas.junk@intevation.de>
parents: 5434
diff changeset
820 single: "Singlebeam"
351d38269e4e Display of the according type of sounding data in legend.
Thomas Junk <thomas.junk@intevation.de>
parents: 5434
diff changeset
821 };
2258
24cafd6b1a55 client: pdf-gen: width of bottleneck info box is calculated based on its content now
Markus Kottlaender <markus@intevation.de>
parents: 2257
diff changeset
822 // determine text dimensions
24cafd6b1a55 client: pdf-gen: width of bottleneck info box is calculated based on its content now
Markus Kottlaender <markus@intevation.de>
parents: 2257
diff changeset
823 // this is a little bit cumbersome but we need to separate width
24cafd6b1a55 client: pdf-gen: width of bottleneck info box is calculated based on its content now
Markus Kottlaender <markus@intevation.de>
parents: 2257
diff changeset
824 // calculations and writing
24cafd6b1a55 client: pdf-gen: width of bottleneck info box is calculated based on its content now
Markus Kottlaender <markus@intevation.de>
parents: 2257
diff changeset
825 this.pdf.doc.setFontSize(10);
24cafd6b1a55 client: pdf-gen: width of bottleneck info box is calculated based on its content now
Markus Kottlaender <markus@intevation.de>
parents: 2257
diff changeset
826 this.pdf.doc.setTextColor(color);
24cafd6b1a55 client: pdf-gen: width of bottleneck info box is calculated based on its content now
Markus Kottlaender <markus@intevation.de>
parents: 2257
diff changeset
827 let textOptions = { baseline: "hanging" };
24cafd6b1a55 client: pdf-gen: width of bottleneck info box is calculated based on its content now
Markus Kottlaender <markus@intevation.de>
parents: 2257
diff changeset
828 let str1_1 = this.$gettext("Bottleneck") + ": ";
5572
3b842e951317 change use from name of bottleneck to its id.
Thomas Junk <thomas.junk@intevation.de>
parents: 5456
diff changeset
829 let str1_2 = this.bottleneckForPrint;
2258
24cafd6b1a55 client: pdf-gen: width of bottleneck info box is calculated based on its content now
Markus Kottlaender <markus@intevation.de>
parents: 2257
diff changeset
830 let str2_1 = this.$gettext("Survey date") + ": ";
5435
351d38269e4e Display of the according type of sounding data in legend.
Thomas Junk <thomas.junk@intevation.de>
parents: 5434
diff changeset
831 let str2_2 =
351d38269e4e Display of the according type of sounding data in legend.
Thomas Junk <thomas.junk@intevation.de>
parents: 5434
diff changeset
832 survey.date_info + " (" + SURVEYTYPES[survey["survey_type"]] + ")";
2258
24cafd6b1a55 client: pdf-gen: width of bottleneck info box is calculated based on its content now
Markus Kottlaender <markus@intevation.de>
parents: 2257
diff changeset
833 let str3_1 = this.$gettext("Ref gauge") + ": ";
24cafd6b1a55 client: pdf-gen: width of bottleneck info box is calculated based on its content now
Markus Kottlaender <markus@intevation.de>
parents: 2257
diff changeset
834 let str3_2 = survey.gauge_objname;
24cafd6b1a55 client: pdf-gen: width of bottleneck info box is calculated based on its content now
Markus Kottlaender <markus@intevation.de>
parents: 2257
diff changeset
835 let str4_1 = this.$gettext("Depth relativ to") + ": ";
5318
ef07b81d3305 PDFTool: Changed layout rendering of bottleneck infobox.
Thomas Junk <thomas.junk@intevation.de>
parents: 5312
diff changeset
836 let str4_2 = survey.depth_reference;
ef07b81d3305 PDFTool: Changed layout rendering of bottleneck infobox.
Thomas Junk <thomas.junk@intevation.de>
parents: 5312
diff changeset
837 if (!ZPGEXCEPTION) {
ef07b81d3305 PDFTool: Changed layout rendering of bottleneck infobox.
Thomas Junk <thomas.junk@intevation.de>
parents: 5312
diff changeset
838 str4_2 +=
ef07b81d3305 PDFTool: Changed layout rendering of bottleneck infobox.
Thomas Junk <thomas.junk@intevation.de>
parents: 5312
diff changeset
839 " = " +
ef07b81d3305 PDFTool: Changed layout rendering of bottleneck infobox.
Thomas Junk <thomas.junk@intevation.de>
parents: 5312
diff changeset
840 (survey.hasOwnProperty("waterlevel_value")
ef07b81d3305 PDFTool: Changed layout rendering of bottleneck infobox.
Thomas Junk <thomas.junk@intevation.de>
parents: 5312
diff changeset
841 ? survey.waterlevel_value + " cm"
ef07b81d3305 PDFTool: Changed layout rendering of bottleneck infobox.
Thomas Junk <thomas.junk@intevation.de>
parents: 5312
diff changeset
842 : "?");
ef07b81d3305 PDFTool: Changed layout rendering of bottleneck infobox.
Thomas Junk <thomas.junk@intevation.de>
parents: 5312
diff changeset
843 }
2258
24cafd6b1a55 client: pdf-gen: width of bottleneck info box is calculated based on its content now
Markus Kottlaender <markus@intevation.de>
parents: 2257
diff changeset
844 this.pdf.doc.setFontStyle("italic");
24cafd6b1a55 client: pdf-gen: width of bottleneck info box is calculated based on its content now
Markus Kottlaender <markus@intevation.de>
parents: 2257
diff changeset
845 let w1_1 = this.pdf.doc.getTextWidth(str1_1);
24cafd6b1a55 client: pdf-gen: width of bottleneck info box is calculated based on its content now
Markus Kottlaender <markus@intevation.de>
parents: 2257
diff changeset
846 this.pdf.doc.setFontStyle("bold");
24cafd6b1a55 client: pdf-gen: width of bottleneck info box is calculated based on its content now
Markus Kottlaender <markus@intevation.de>
parents: 2257
diff changeset
847 let w1_2 = this.pdf.doc.getTextWidth(str1_2);
24cafd6b1a55 client: pdf-gen: width of bottleneck info box is calculated based on its content now
Markus Kottlaender <markus@intevation.de>
parents: 2257
diff changeset
848 this.pdf.doc.setFontStyle("italic");
24cafd6b1a55 client: pdf-gen: width of bottleneck info box is calculated based on its content now
Markus Kottlaender <markus@intevation.de>
parents: 2257
diff changeset
849 let w2_1 = this.pdf.doc.getTextWidth(str2_1);
24cafd6b1a55 client: pdf-gen: width of bottleneck info box is calculated based on its content now
Markus Kottlaender <markus@intevation.de>
parents: 2257
diff changeset
850 this.pdf.doc.setFontStyle("normal");
24cafd6b1a55 client: pdf-gen: width of bottleneck info box is calculated based on its content now
Markus Kottlaender <markus@intevation.de>
parents: 2257
diff changeset
851 let w2_2 = this.pdf.doc.getTextWidth(str2_2);
24cafd6b1a55 client: pdf-gen: width of bottleneck info box is calculated based on its content now
Markus Kottlaender <markus@intevation.de>
parents: 2257
diff changeset
852 this.pdf.doc.setFontStyle("italic");
24cafd6b1a55 client: pdf-gen: width of bottleneck info box is calculated based on its content now
Markus Kottlaender <markus@intevation.de>
parents: 2257
diff changeset
853 let w3_1 = this.pdf.doc.getTextWidth(str3_1);
24cafd6b1a55 client: pdf-gen: width of bottleneck info box is calculated based on its content now
Markus Kottlaender <markus@intevation.de>
parents: 2257
diff changeset
854 this.pdf.doc.setFontStyle("normal");
24cafd6b1a55 client: pdf-gen: width of bottleneck info box is calculated based on its content now
Markus Kottlaender <markus@intevation.de>
parents: 2257
diff changeset
855 let w3_2 = this.pdf.doc.getTextWidth(str3_2);
24cafd6b1a55 client: pdf-gen: width of bottleneck info box is calculated based on its content now
Markus Kottlaender <markus@intevation.de>
parents: 2257
diff changeset
856 this.pdf.doc.setFontStyle("italic");
24cafd6b1a55 client: pdf-gen: width of bottleneck info box is calculated based on its content now
Markus Kottlaender <markus@intevation.de>
parents: 2257
diff changeset
857 let w4_1 = this.pdf.doc.getTextWidth(str4_1);
24cafd6b1a55 client: pdf-gen: width of bottleneck info box is calculated based on its content now
Markus Kottlaender <markus@intevation.de>
parents: 2257
diff changeset
858 this.pdf.doc.setFontStyle("normal");
24cafd6b1a55 client: pdf-gen: width of bottleneck info box is calculated based on its content now
Markus Kottlaender <markus@intevation.de>
parents: 2257
diff changeset
859 let w4_2 = this.pdf.doc.getTextWidth(str4_2);
5318
ef07b81d3305 PDFTool: Changed layout rendering of bottleneck infobox.
Thomas Junk <thomas.junk@intevation.de>
parents: 5312
diff changeset
860 let str5_1 = "";
ef07b81d3305 PDFTool: Changed layout rendering of bottleneck infobox.
Thomas Junk <thomas.junk@intevation.de>
parents: 5312
diff changeset
861 let w5_1 = 0;
ef07b81d3305 PDFTool: Changed layout rendering of bottleneck infobox.
Thomas Junk <thomas.junk@intevation.de>
parents: 5312
diff changeset
862 let SPACER = 6;
ef07b81d3305 PDFTool: Changed layout rendering of bottleneck infobox.
Thomas Junk <thomas.junk@intevation.de>
parents: 5312
diff changeset
863 if (ZPGEXCEPTION) {
ef07b81d3305 PDFTool: Changed layout rendering of bottleneck infobox.
Thomas Junk <thomas.junk@intevation.de>
parents: 5312
diff changeset
864 str5_1 = this.$gettext("Bottleneck with ZPG Exception");
ef07b81d3305 PDFTool: Changed layout rendering of bottleneck infobox.
Thomas Junk <thomas.junk@intevation.de>
parents: 5312
diff changeset
865 this.pdf.doc.setFontStyle("normal");
ef07b81d3305 PDFTool: Changed layout rendering of bottleneck infobox.
Thomas Junk <thomas.junk@intevation.de>
parents: 5312
diff changeset
866 w5_1 = this.pdf.doc.getTextWidth(str5_1);
ef07b81d3305 PDFTool: Changed layout rendering of bottleneck infobox.
Thomas Junk <thomas.junk@intevation.de>
parents: 5312
diff changeset
867 }
2258
24cafd6b1a55 client: pdf-gen: width of bottleneck info box is calculated based on its content now
Markus Kottlaender <markus@intevation.de>
parents: 2257
diff changeset
868
5318
ef07b81d3305 PDFTool: Changed layout rendering of bottleneck infobox.
Thomas Junk <thomas.junk@intevation.de>
parents: 5312
diff changeset
869 let height = ZPGEXCEPTION ? 24 + SPACER : 24;
ef07b81d3305 PDFTool: Changed layout rendering of bottleneck infobox.
Thomas Junk <thomas.junk@intevation.de>
parents: 5312
diff changeset
870 let padding = 2;
ef07b81d3305 PDFTool: Changed layout rendering of bottleneck infobox.
Thomas Junk <thomas.junk@intevation.de>
parents: 5312
diff changeset
871 let width = ZPGEXCEPTION
ef07b81d3305 PDFTool: Changed layout rendering of bottleneck infobox.
Thomas Junk <thomas.junk@intevation.de>
parents: 5312
diff changeset
872 ? Math.max(
ef07b81d3305 PDFTool: Changed layout rendering of bottleneck infobox.
Thomas Junk <thomas.junk@intevation.de>
parents: 5312
diff changeset
873 w1_1 + w1_2,
ef07b81d3305 PDFTool: Changed layout rendering of bottleneck infobox.
Thomas Junk <thomas.junk@intevation.de>
parents: 5312
diff changeset
874 w2_1 + w2_2,
ef07b81d3305 PDFTool: Changed layout rendering of bottleneck infobox.
Thomas Junk <thomas.junk@intevation.de>
parents: 5312
diff changeset
875 w3_1 + w3_2,
ef07b81d3305 PDFTool: Changed layout rendering of bottleneck infobox.
Thomas Junk <thomas.junk@intevation.de>
parents: 5312
diff changeset
876 w4_1 + w4_2 + w5_1
ef07b81d3305 PDFTool: Changed layout rendering of bottleneck infobox.
Thomas Junk <thomas.junk@intevation.de>
parents: 5312
diff changeset
877 ) +
ef07b81d3305 PDFTool: Changed layout rendering of bottleneck infobox.
Thomas Junk <thomas.junk@intevation.de>
parents: 5312
diff changeset
878 2 * padding
ef07b81d3305 PDFTool: Changed layout rendering of bottleneck infobox.
Thomas Junk <thomas.junk@intevation.de>
parents: 5312
diff changeset
879 : Math.max(w1_1 + w1_2, w2_1 + w2_2, w3_1 + w3_2, w4_1 + w4_2) +
ef07b81d3305 PDFTool: Changed layout rendering of bottleneck infobox.
Thomas Junk <thomas.junk@intevation.de>
parents: 5312
diff changeset
880 2 * padding;
2220
d926292d81b6 PDF generation: changed form labels/option texts
Markus Kottlaender <markus@intevation.de>
parents: 2219
diff changeset
881
2218
631ca0412db9 adjusted positioning of pdf elements
Markus Kottlaender <markus@intevation.de>
parents: 2215
diff changeset
882 // x/y defaults to offset for topleft corner (normal x/y coordinates)
631ca0412db9 adjusted positioning of pdf elements
Markus Kottlaender <markus@intevation.de>
parents: 2215
diff changeset
883 let x = offset.x;
631ca0412db9 adjusted positioning of pdf elements
Markus Kottlaender <markus@intevation.de>
parents: 2215
diff changeset
884 let y = offset.y;
1931
8fb1b1a8ea85 client: pdf-gen: improve legend behaviour
Bernhard Reiter <bernhard@intevation.de>
parents: 1928
diff changeset
885
2218
631ca0412db9 adjusted positioning of pdf elements
Markus Kottlaender <markus@intevation.de>
parents: 2215
diff changeset
886 // if position is on the right, x needs to be calculate with pdf width and
631ca0412db9 adjusted positioning of pdf elements
Markus Kottlaender <markus@intevation.de>
parents: 2215
diff changeset
887 // the size of the element
631ca0412db9 adjusted positioning of pdf elements
Markus Kottlaender <markus@intevation.de>
parents: 2215
diff changeset
888 if (["topright", "bottomright"].indexOf(position) !== -1) {
631ca0412db9 adjusted positioning of pdf elements
Markus Kottlaender <markus@intevation.de>
parents: 2215
diff changeset
889 x = this.pdf.width - offset.x - width;
631ca0412db9 adjusted positioning of pdf elements
Markus Kottlaender <markus@intevation.de>
parents: 2215
diff changeset
890 }
631ca0412db9 adjusted positioning of pdf elements
Markus Kottlaender <markus@intevation.de>
parents: 2215
diff changeset
891 if (["bottomright", "bottomleft"].indexOf(position) !== -1) {
631ca0412db9 adjusted positioning of pdf elements
Markus Kottlaender <markus@intevation.de>
parents: 2215
diff changeset
892 y = this.pdf.height - offset.y - height;
631ca0412db9 adjusted positioning of pdf elements
Markus Kottlaender <markus@intevation.de>
parents: 2215
diff changeset
893 }
2137
a31c9fa47ab8 client: pdf-gen: add bottleneck details
Bernhard Reiter <bernhard@intevation.de>
parents: 2124
diff changeset
894
2258
24cafd6b1a55 client: pdf-gen: width of bottleneck info box is calculated based on its content now
Markus Kottlaender <markus@intevation.de>
parents: 2257
diff changeset
895 // white background box
2714
4dd38840d74b client:pdf-gen:imporve some template elements
Fadi Abbud <fadi.abbud@intevation.de>
parents: 2561
diff changeset
896 this.addRoundedBox(x, y, width, height, "white", rounding, brcolor);
2138
4a903d382901 client: pdf-gen: make bottleneck infos more fancy
Bernhard Reiter <bernhard@intevation.de>
parents: 2137
diff changeset
897
2258
24cafd6b1a55 client: pdf-gen: width of bottleneck info box is calculated based on its content now
Markus Kottlaender <markus@intevation.de>
parents: 2257
diff changeset
898 // bottleneck
2218
631ca0412db9 adjusted positioning of pdf elements
Markus Kottlaender <markus@intevation.de>
parents: 2215
diff changeset
899 this.pdf.doc.setFontStyle("italic");
5318
ef07b81d3305 PDFTool: Changed layout rendering of bottleneck infobox.
Thomas Junk <thomas.junk@intevation.de>
parents: 5312
diff changeset
900 this.pdf.doc.text(x + padding, y + padding, str1_1, textOptions);
2218
631ca0412db9 adjusted positioning of pdf elements
Markus Kottlaender <markus@intevation.de>
parents: 2215
diff changeset
901 this.pdf.doc.setFontStyle("bold");
5318
ef07b81d3305 PDFTool: Changed layout rendering of bottleneck infobox.
Thomas Junk <thomas.junk@intevation.de>
parents: 5312
diff changeset
902 this.pdf.doc.text(x + padding + w1_1, y + padding, str1_2, textOptions);
2137
a31c9fa47ab8 client: pdf-gen: add bottleneck details
Bernhard Reiter <bernhard@intevation.de>
parents: 2124
diff changeset
903
2258
24cafd6b1a55 client: pdf-gen: width of bottleneck info box is calculated based on its content now
Markus Kottlaender <markus@intevation.de>
parents: 2257
diff changeset
904 // survey date
2218
631ca0412db9 adjusted positioning of pdf elements
Markus Kottlaender <markus@intevation.de>
parents: 2215
diff changeset
905 this.pdf.doc.setFontStyle("italic");
5318
ef07b81d3305 PDFTool: Changed layout rendering of bottleneck infobox.
Thomas Junk <thomas.junk@intevation.de>
parents: 5312
diff changeset
906 this.pdf.doc.text(x + padding, y + 1 + SPACER, str2_1, textOptions);
2218
631ca0412db9 adjusted positioning of pdf elements
Markus Kottlaender <markus@intevation.de>
parents: 2215
diff changeset
907 this.pdf.doc.setFontStyle("normal");
2258
24cafd6b1a55 client: pdf-gen: width of bottleneck info box is calculated based on its content now
Markus Kottlaender <markus@intevation.de>
parents: 2257
diff changeset
908 this.pdf.doc.text(
24cafd6b1a55 client: pdf-gen: width of bottleneck info box is calculated based on its content now
Markus Kottlaender <markus@intevation.de>
parents: 2257
diff changeset
909 x + padding + w2_1,
5318
ef07b81d3305 PDFTool: Changed layout rendering of bottleneck infobox.
Thomas Junk <thomas.junk@intevation.de>
parents: 5312
diff changeset
910 y + 1 + SPACER,
2258
24cafd6b1a55 client: pdf-gen: width of bottleneck info box is calculated based on its content now
Markus Kottlaender <markus@intevation.de>
parents: 2257
diff changeset
911 str2_2,
24cafd6b1a55 client: pdf-gen: width of bottleneck info box is calculated based on its content now
Markus Kottlaender <markus@intevation.de>
parents: 2257
diff changeset
912 textOptions
24cafd6b1a55 client: pdf-gen: width of bottleneck info box is calculated based on its content now
Markus Kottlaender <markus@intevation.de>
parents: 2257
diff changeset
913 );
2247
e6fba449aa3c merged pdf-export in default
Markus Kottlaender <markus@intevation.de>
parents: 2240
diff changeset
914
2258
24cafd6b1a55 client: pdf-gen: width of bottleneck info box is calculated based on its content now
Markus Kottlaender <markus@intevation.de>
parents: 2257
diff changeset
915 // ref gauge
2247
e6fba449aa3c merged pdf-export in default
Markus Kottlaender <markus@intevation.de>
parents: 2240
diff changeset
916 this.pdf.doc.setFontStyle("italic");
5318
ef07b81d3305 PDFTool: Changed layout rendering of bottleneck infobox.
Thomas Junk <thomas.junk@intevation.de>
parents: 5312
diff changeset
917 this.pdf.doc.text(
ef07b81d3305 PDFTool: Changed layout rendering of bottleneck infobox.
Thomas Junk <thomas.junk@intevation.de>
parents: 5312
diff changeset
918 x + padding,
ef07b81d3305 PDFTool: Changed layout rendering of bottleneck infobox.
Thomas Junk <thomas.junk@intevation.de>
parents: 5312
diff changeset
919 y + 0.5 + 2 * SPACER,
ef07b81d3305 PDFTool: Changed layout rendering of bottleneck infobox.
Thomas Junk <thomas.junk@intevation.de>
parents: 5312
diff changeset
920 str3_1,
ef07b81d3305 PDFTool: Changed layout rendering of bottleneck infobox.
Thomas Junk <thomas.junk@intevation.de>
parents: 5312
diff changeset
921 textOptions
ef07b81d3305 PDFTool: Changed layout rendering of bottleneck infobox.
Thomas Junk <thomas.junk@intevation.de>
parents: 5312
diff changeset
922 );
2247
e6fba449aa3c merged pdf-export in default
Markus Kottlaender <markus@intevation.de>
parents: 2240
diff changeset
923 this.pdf.doc.setFontStyle("normal");
2258
24cafd6b1a55 client: pdf-gen: width of bottleneck info box is calculated based on its content now
Markus Kottlaender <markus@intevation.de>
parents: 2257
diff changeset
924 this.pdf.doc.text(
24cafd6b1a55 client: pdf-gen: width of bottleneck info box is calculated based on its content now
Markus Kottlaender <markus@intevation.de>
parents: 2257
diff changeset
925 x + padding + w3_1,
5318
ef07b81d3305 PDFTool: Changed layout rendering of bottleneck infobox.
Thomas Junk <thomas.junk@intevation.de>
parents: 5312
diff changeset
926 y + 0.5 + 2 * SPACER,
2258
24cafd6b1a55 client: pdf-gen: width of bottleneck info box is calculated based on its content now
Markus Kottlaender <markus@intevation.de>
parents: 2257
diff changeset
927 str3_2,
24cafd6b1a55 client: pdf-gen: width of bottleneck info box is calculated based on its content now
Markus Kottlaender <markus@intevation.de>
parents: 2257
diff changeset
928 textOptions
24cafd6b1a55 client: pdf-gen: width of bottleneck info box is calculated based on its content now
Markus Kottlaender <markus@intevation.de>
parents: 2257
diff changeset
929 );
24cafd6b1a55 client: pdf-gen: width of bottleneck info box is calculated based on its content now
Markus Kottlaender <markus@intevation.de>
parents: 2257
diff changeset
930
24cafd6b1a55 client: pdf-gen: width of bottleneck info box is calculated based on its content now
Markus Kottlaender <markus@intevation.de>
parents: 2257
diff changeset
931 // depth relative to
24cafd6b1a55 client: pdf-gen: width of bottleneck info box is calculated based on its content now
Markus Kottlaender <markus@intevation.de>
parents: 2257
diff changeset
932 this.pdf.doc.setFontStyle("italic");
5318
ef07b81d3305 PDFTool: Changed layout rendering of bottleneck infobox.
Thomas Junk <thomas.junk@intevation.de>
parents: 5312
diff changeset
933 this.pdf.doc.text(
ef07b81d3305 PDFTool: Changed layout rendering of bottleneck infobox.
Thomas Junk <thomas.junk@intevation.de>
parents: 5312
diff changeset
934 x + padding,
ef07b81d3305 PDFTool: Changed layout rendering of bottleneck infobox.
Thomas Junk <thomas.junk@intevation.de>
parents: 5312
diff changeset
935 y + 0.5 + 3 * SPACER,
ef07b81d3305 PDFTool: Changed layout rendering of bottleneck infobox.
Thomas Junk <thomas.junk@intevation.de>
parents: 5312
diff changeset
936 str4_1,
ef07b81d3305 PDFTool: Changed layout rendering of bottleneck infobox.
Thomas Junk <thomas.junk@intevation.de>
parents: 5312
diff changeset
937 textOptions
ef07b81d3305 PDFTool: Changed layout rendering of bottleneck infobox.
Thomas Junk <thomas.junk@intevation.de>
parents: 5312
diff changeset
938 );
2258
24cafd6b1a55 client: pdf-gen: width of bottleneck info box is calculated based on its content now
Markus Kottlaender <markus@intevation.de>
parents: 2257
diff changeset
939 this.pdf.doc.setFontStyle("normal");
24cafd6b1a55 client: pdf-gen: width of bottleneck info box is calculated based on its content now
Markus Kottlaender <markus@intevation.de>
parents: 2257
diff changeset
940 this.pdf.doc.text(
24cafd6b1a55 client: pdf-gen: width of bottleneck info box is calculated based on its content now
Markus Kottlaender <markus@intevation.de>
parents: 2257
diff changeset
941 x + padding + w4_1,
5318
ef07b81d3305 PDFTool: Changed layout rendering of bottleneck infobox.
Thomas Junk <thomas.junk@intevation.de>
parents: 5312
diff changeset
942 y + 0.5 + 3 * SPACER,
2258
24cafd6b1a55 client: pdf-gen: width of bottleneck info box is calculated based on its content now
Markus Kottlaender <markus@intevation.de>
parents: 2257
diff changeset
943 str4_2,
24cafd6b1a55 client: pdf-gen: width of bottleneck info box is calculated based on its content now
Markus Kottlaender <markus@intevation.de>
parents: 2257
diff changeset
944 textOptions
24cafd6b1a55 client: pdf-gen: width of bottleneck info box is calculated based on its content now
Markus Kottlaender <markus@intevation.de>
parents: 2257
diff changeset
945 );
5318
ef07b81d3305 PDFTool: Changed layout rendering of bottleneck infobox.
Thomas Junk <thomas.junk@intevation.de>
parents: 5312
diff changeset
946 if (ZPGEXCEPTION) {
ef07b81d3305 PDFTool: Changed layout rendering of bottleneck infobox.
Thomas Junk <thomas.junk@intevation.de>
parents: 5312
diff changeset
947 this.pdf.doc.setFontStyle("bold");
ef07b81d3305 PDFTool: Changed layout rendering of bottleneck infobox.
Thomas Junk <thomas.junk@intevation.de>
parents: 5312
diff changeset
948 this.pdf.doc.text(x + padding, y + 4 * SPACER, str5_1, textOptions);
ef07b81d3305 PDFTool: Changed layout rendering of bottleneck infobox.
Thomas Junk <thomas.junk@intevation.de>
parents: 5312
diff changeset
949 }
2218
631ca0412db9 adjusted positioning of pdf elements
Markus Kottlaender <markus@intevation.de>
parents: 2215
diff changeset
950 }
5282
12e2422ae57c Show current scale dominator as placeholder in PDF export [ci by swilde]
Fadi Abbud <fadi.abbud@intevation.de>
parents: 5265
diff changeset
951 },
12e2422ae57c Show current scale dominator as placeholder in PDF export [ci by swilde]
Fadi Abbud <fadi.abbud@intevation.de>
parents: 5265
diff changeset
952 calculateScaleDenominator() {
12e2422ae57c Show current scale dominator as placeholder in PDF export [ci by swilde]
Fadi Abbud <fadi.abbud@intevation.de>
parents: 5265
diff changeset
953 const pixelsPerMapMillimeter = this.form.resolution / 25.4;
12e2422ae57c Show current scale dominator as placeholder in PDF export [ci by swilde]
Fadi Abbud <fadi.abbud@intevation.de>
parents: 5265
diff changeset
954 if (!this.form.scale) {
12e2422ae57c Show current scale dominator as placeholder in PDF export [ci by swilde]
Fadi Abbud <fadi.abbud@intevation.de>
parents: 5265
diff changeset
955 this.setPDFDimension();
12e2422ae57c Show current scale dominator as placeholder in PDF export [ci by swilde]
Fadi Abbud <fadi.abbud@intevation.de>
parents: 5265
diff changeset
956 const mapSizeForPrint = this.setMapSizForPrint();
12e2422ae57c Show current scale dominator as placeholder in PDF export [ci by swilde]
Fadi Abbud <fadi.abbud@intevation.de>
parents: 5265
diff changeset
957 const size = this.openLayersMap().getSize();
12e2422ae57c Show current scale dominator as placeholder in PDF export [ci by swilde]
Fadi Abbud <fadi.abbud@intevation.de>
parents: 5265
diff changeset
958 const [width, height] = mapSizeForPrint;
12e2422ae57c Show current scale dominator as placeholder in PDF export [ci by swilde]
Fadi Abbud <fadi.abbud@intevation.de>
parents: 5265
diff changeset
959 const scaling = Math.min(width / size[0], height / size[1]);
12e2422ae57c Show current scale dominator as placeholder in PDF export [ci by swilde]
Fadi Abbud <fadi.abbud@intevation.de>
parents: 5265
diff changeset
960 return Math.round(
12e2422ae57c Show current scale dominator as placeholder in PDF export [ci by swilde]
Fadi Abbud <fadi.abbud@intevation.de>
parents: 5265
diff changeset
961 1000 *
12e2422ae57c Show current scale dominator as placeholder in PDF export [ci by swilde]
Fadi Abbud <fadi.abbud@intevation.de>
parents: 5265
diff changeset
962 pixelsPerMapMillimeter *
12e2422ae57c Show current scale dominator as placeholder in PDF export [ci by swilde]
Fadi Abbud <fadi.abbud@intevation.de>
parents: 5265
diff changeset
963 this.getMeterPerPixel(
12e2422ae57c Show current scale dominator as placeholder in PDF export [ci by swilde]
Fadi Abbud <fadi.abbud@intevation.de>
parents: 5265
diff changeset
964 this.openLayersMap()
12e2422ae57c Show current scale dominator as placeholder in PDF export [ci by swilde]
Fadi Abbud <fadi.abbud@intevation.de>
parents: 5265
diff changeset
965 .getView()
12e2422ae57c Show current scale dominator as placeholder in PDF export [ci by swilde]
Fadi Abbud <fadi.abbud@intevation.de>
parents: 5265
diff changeset
966 .getResolution() / scaling
12e2422ae57c Show current scale dominator as placeholder in PDF export [ci by swilde]
Fadi Abbud <fadi.abbud@intevation.de>
parents: 5265
diff changeset
967 )
12e2422ae57c Show current scale dominator as placeholder in PDF export [ci by swilde]
Fadi Abbud <fadi.abbud@intevation.de>
parents: 5265
diff changeset
968 );
12e2422ae57c Show current scale dominator as placeholder in PDF export [ci by swilde]
Fadi Abbud <fadi.abbud@intevation.de>
parents: 5265
diff changeset
969 }
12e2422ae57c Show current scale dominator as placeholder in PDF export [ci by swilde]
Fadi Abbud <fadi.abbud@intevation.de>
parents: 5265
diff changeset
970 return Math.round(
12e2422ae57c Show current scale dominator as placeholder in PDF export [ci by swilde]
Fadi Abbud <fadi.abbud@intevation.de>
parents: 5265
diff changeset
971 1000 *
12e2422ae57c Show current scale dominator as placeholder in PDF export [ci by swilde]
Fadi Abbud <fadi.abbud@intevation.de>
parents: 5265
diff changeset
972 pixelsPerMapMillimeter *
12e2422ae57c Show current scale dominator as placeholder in PDF export [ci by swilde]
Fadi Abbud <fadi.abbud@intevation.de>
parents: 5265
diff changeset
973 this.getMeterPerPixel(
12e2422ae57c Show current scale dominator as placeholder in PDF export [ci by swilde]
Fadi Abbud <fadi.abbud@intevation.de>
parents: 5265
diff changeset
974 this.openLayersMap()
12e2422ae57c Show current scale dominator as placeholder in PDF export [ci by swilde]
Fadi Abbud <fadi.abbud@intevation.de>
parents: 5265
diff changeset
975 .getView()
12e2422ae57c Show current scale dominator as placeholder in PDF export [ci by swilde]
Fadi Abbud <fadi.abbud@intevation.de>
parents: 5265
diff changeset
976 .getResolution()
12e2422ae57c Show current scale dominator as placeholder in PDF export [ci by swilde]
Fadi Abbud <fadi.abbud@intevation.de>
parents: 5265
diff changeset
977 )
12e2422ae57c Show current scale dominator as placeholder in PDF export [ci by swilde]
Fadi Abbud <fadi.abbud@intevation.de>
parents: 5265
diff changeset
978 );
12e2422ae57c Show current scale dominator as placeholder in PDF export [ci by swilde]
Fadi Abbud <fadi.abbud@intevation.de>
parents: 5265
diff changeset
979 },
12e2422ae57c Show current scale dominator as placeholder in PDF export [ci by swilde]
Fadi Abbud <fadi.abbud@intevation.de>
parents: 5265
diff changeset
980 setPDFDimension() {
12e2422ae57c Show current scale dominator as placeholder in PDF export [ci by swilde]
Fadi Abbud <fadi.abbud@intevation.de>
parents: 5265
diff changeset
981 if (this.form.format !== "portrait") {
12e2422ae57c Show current scale dominator as placeholder in PDF export [ci by swilde]
Fadi Abbud <fadi.abbud@intevation.de>
parents: 5265
diff changeset
982 this.pdf.width = paperSizes[this.form.paperSize][0];
12e2422ae57c Show current scale dominator as placeholder in PDF export [ci by swilde]
Fadi Abbud <fadi.abbud@intevation.de>
parents: 5265
diff changeset
983 this.pdf.height = paperSizes[this.form.paperSize][1];
12e2422ae57c Show current scale dominator as placeholder in PDF export [ci by swilde]
Fadi Abbud <fadi.abbud@intevation.de>
parents: 5265
diff changeset
984 } else {
12e2422ae57c Show current scale dominator as placeholder in PDF export [ci by swilde]
Fadi Abbud <fadi.abbud@intevation.de>
parents: 5265
diff changeset
985 this.pdf.width = paperSizes[this.form.paperSize][1];
12e2422ae57c Show current scale dominator as placeholder in PDF export [ci by swilde]
Fadi Abbud <fadi.abbud@intevation.de>
parents: 5265
diff changeset
986 this.pdf.height = paperSizes[this.form.paperSize][0];
12e2422ae57c Show current scale dominator as placeholder in PDF export [ci by swilde]
Fadi Abbud <fadi.abbud@intevation.de>
parents: 5265
diff changeset
987 }
12e2422ae57c Show current scale dominator as placeholder in PDF export [ci by swilde]
Fadi Abbud <fadi.abbud@intevation.de>
parents: 5265
diff changeset
988 },
12e2422ae57c Show current scale dominator as placeholder in PDF export [ci by swilde]
Fadi Abbud <fadi.abbud@intevation.de>
parents: 5265
diff changeset
989 setMapSizForPrint() {
12e2422ae57c Show current scale dominator as placeholder in PDF export [ci by swilde]
Fadi Abbud <fadi.abbud@intevation.de>
parents: 5265
diff changeset
990 const pixelsPerMapMillimeter = this.form.resolution / 25.4;
12e2422ae57c Show current scale dominator as placeholder in PDF export [ci by swilde]
Fadi Abbud <fadi.abbud@intevation.de>
parents: 5265
diff changeset
991 return [
12e2422ae57c Show current scale dominator as placeholder in PDF export [ci by swilde]
Fadi Abbud <fadi.abbud@intevation.de>
parents: 5265
diff changeset
992 Math.round(this.pdf.width * pixelsPerMapMillimeter),
12e2422ae57c Show current scale dominator as placeholder in PDF export [ci by swilde]
Fadi Abbud <fadi.abbud@intevation.de>
parents: 5265
diff changeset
993 Math.round(this.pdf.height * pixelsPerMapMillimeter)
12e2422ae57c Show current scale dominator as placeholder in PDF export [ci by swilde]
Fadi Abbud <fadi.abbud@intevation.de>
parents: 5265
diff changeset
994 ];
1272
bc55ffaeb639 cleaned up client/src directory
Markus Kottlaender <markus@intevation.de>
parents:
diff changeset
995 }
2212
733cfc3db48a started pdf template administration
Markus Kottlaender <markus@intevation.de>
parents: 2207
diff changeset
996 },
733cfc3db48a started pdf template administration
Markus Kottlaender <markus@intevation.de>
parents: 2207
diff changeset
997 mounted() {
3227
6d4d8e7ef881 client: adjust route for pdftemplate,pdftool and add check type to uploaded templates
Fadi Abbud <fadi.abbud@intevation.de>
parents: 3222
diff changeset
998 HTTP.get("/templates/map", {
2257
ce6fd3d4a3a2 client: pdf-gen: moved template handling from store to components
Markus Kottlaender <markus@intevation.de>
parents: 2247
diff changeset
999 headers: {
ce6fd3d4a3a2 client: pdf-gen: moved template handling from store to components
Markus Kottlaender <markus@intevation.de>
parents: 2247
diff changeset
1000 "X-Gemma-Auth": localStorage.getItem("token"),
ce6fd3d4a3a2 client: pdf-gen: moved template handling from store to components
Markus Kottlaender <markus@intevation.de>
parents: 2247
diff changeset
1001 "Content-type": "text/xml; charset=UTF-8"
ce6fd3d4a3a2 client: pdf-gen: moved template handling from store to components
Markus Kottlaender <markus@intevation.de>
parents: 2247
diff changeset
1002 }
ce6fd3d4a3a2 client: pdf-gen: moved template handling from store to components
Markus Kottlaender <markus@intevation.de>
parents: 2247
diff changeset
1003 })
ce6fd3d4a3a2 client: pdf-gen: moved template handling from store to components
Markus Kottlaender <markus@intevation.de>
parents: 2247
diff changeset
1004 .then(response => {
2265
940ae7c20326 client: pdf-gen: use default template when backend does not provide any
Markus Kottlaender <markus@intevation.de>
parents: 2260
diff changeset
1005 if (response.data.length) {
3840
387f239018c7 pdf_tool: retain default template, when custom template is uploaded
Thomas Junk <thomas.junk@intevation.de>
parents: 3802
diff changeset
1006 this.templates = [...this.templates, ...response.data];
387f239018c7 pdf_tool: retain default template, when custom template is uploaded
Thomas Junk <thomas.junk@intevation.de>
parents: 3802
diff changeset
1007 this.form.template = this.templates[1];
2265
940ae7c20326 client: pdf-gen: use default template when backend does not provide any
Markus Kottlaender <markus@intevation.de>
parents: 2260
diff changeset
1008 this.applyTemplateToForm();
3786
a2da2328bb86 PDFTool: prefetch images of template and convert to dataURI
Thomas Junk <thomas.junk@intevation.de>
parents: 3781
diff changeset
1009 } else {
a2da2328bb86 PDFTool: prefetch images of template and convert to dataURI
Thomas Junk <thomas.junk@intevation.de>
parents: 3781
diff changeset
1010 this.form.template = this.templates[0];
a2da2328bb86 PDFTool: prefetch images of template and convert to dataURI
Thomas Junk <thomas.junk@intevation.de>
parents: 3781
diff changeset
1011 this.templateData = this.form.template;
2265
940ae7c20326 client: pdf-gen: use default template when backend does not provide any
Markus Kottlaender <markus@intevation.de>
parents: 2260
diff changeset
1012 }
2257
ce6fd3d4a3a2 client: pdf-gen: moved template handling from store to components
Markus Kottlaender <markus@intevation.de>
parents: 2247
diff changeset
1013 })
4868
008bc1ae8897 exception handling
Thomas Junk <thomas.junk@intevation.de>
parents: 4735
diff changeset
1014 .catch(error => {
4869
6b054b91d9b2 backend not reachable as error message etd. Login adjusted
Thomas Junk <thomas.junk@intevation.de>
parents: 4868
diff changeset
1015 let message = "Backend not reachable";
4868
008bc1ae8897 exception handling
Thomas Junk <thomas.junk@intevation.de>
parents: 4735
diff changeset
1016 if (error.response) {
008bc1ae8897 exception handling
Thomas Junk <thomas.junk@intevation.de>
parents: 4735
diff changeset
1017 const { status, data } = error.response;
008bc1ae8897 exception handling
Thomas Junk <thomas.junk@intevation.de>
parents: 4735
diff changeset
1018 message = `${status}: ${data.message || data}`;
008bc1ae8897 exception handling
Thomas Junk <thomas.junk@intevation.de>
parents: 4735
diff changeset
1019 }
2257
ce6fd3d4a3a2 client: pdf-gen: moved template handling from store to components
Markus Kottlaender <markus@intevation.de>
parents: 2247
diff changeset
1020 displayError({
2284
9f327f197ddd client: translation: mark some strings for translations
Fadi Abbud <fadi.abbud@intevation.de>
parents: 2275
diff changeset
1021 title: this.$gettext("Backend Error"),
4868
008bc1ae8897 exception handling
Thomas Junk <thomas.junk@intevation.de>
parents: 4735
diff changeset
1022 message: message
2257
ce6fd3d4a3a2 client: pdf-gen: moved template handling from store to components
Markus Kottlaender <markus@intevation.de>
parents: 2247
diff changeset
1023 });
ce6fd3d4a3a2 client: pdf-gen: moved template handling from store to components
Markus Kottlaender <markus@intevation.de>
parents: 2247
diff changeset
1024 });
1272
bc55ffaeb639 cleaned up client/src directory
Markus Kottlaender <markus@intevation.de>
parents:
diff changeset
1025 }
bc55ffaeb639 cleaned up client/src directory
Markus Kottlaender <markus@intevation.de>
parents:
diff changeset
1026 };
bc55ffaeb639 cleaned up client/src directory
Markus Kottlaender <markus@intevation.de>
parents:
diff changeset
1027 </script>