Skip to content

Commit 75c354f

Browse files
committed
WIP Print view
1 parent 903ad25 commit 75c354f

23 files changed

Lines changed: 509 additions & 110 deletions

File tree

packages/geoadmin-coordinates/src/proj/CoordinateSystem.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,8 @@ export type ResolutionStep = {
3434
resolution: number
3535
/** Corresponding zoom level for this resolution step */
3636
zoom: number | undefined
37+
/** Name of the map product shown at this resolution/zoom */
38+
label?: string
3739
}
3840

3941
export interface CoordinateSystemProps {

packages/geoadmin-coordinates/src/proj/SwissCoordinateSystem.ts

Lines changed: 30 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -87,6 +87,24 @@ export const SWISSTOPO_TILEGRID_ZOOM_TO_STANDARD_ZOOM_MATRIX: number[] = [
8787
21, // max: 14
8888
]
8989

90+
const SWISSTOPO_ZOOM_TO_PRODUCT_SCALE: string[] = [
91+
"1:2'500'000", // zoom 0
92+
"1:2'500'000", // 1
93+
"1:1'000'000", // 2
94+
"1:1'000'000", // 3
95+
"1:500'000", // 4
96+
"1:200'000", // 5
97+
"1:100'000", // 6
98+
"1:50'000", // 7
99+
"1:25'000", // 8
100+
"1:25'000", // 9
101+
"1:10'000", // 10
102+
"1:10'000", // 11
103+
"1:10'000", // 12
104+
"1:10'000", // 13
105+
"1:10'000", // max zoom: 14
106+
]
107+
90108
const swisstopoZoomLevels: number[] = SWISSTOPO_TILEGRID_ZOOM_TO_STANDARD_ZOOM_MATRIX.map(
91109
(_, index) => index
92110
)
@@ -103,10 +121,18 @@ const swisstopoZoomLevels: number[] = SWISSTOPO_TILEGRID_ZOOM_TO_STANDARD_ZOOM_M
103121
*/
104122
export default class SwissCoordinateSystem extends CustomCoordinateSystem {
105123
getResolutions(): ResolutionStep[] {
106-
return SWISSTOPO_TILEGRID_RESOLUTIONS.map((resolution) => ({
107-
zoom: LV95_RESOLUTIONS.indexOf(resolution) ?? undefined,
108-
resolution: resolution,
109-
}))
124+
return SWISSTOPO_TILEGRID_RESOLUTIONS.map((resolution) => {
125+
const zoom: number | undefined = LV95_RESOLUTIONS.indexOf(resolution) ?? undefined
126+
let label: string | undefined
127+
if (zoom) {
128+
label = SWISSTOPO_ZOOM_TO_PRODUCT_SCALE[zoom]
129+
}
130+
return {
131+
zoom,
132+
label,
133+
resolution: resolution,
134+
}
135+
})
110136
}
111137

112138
get1_25000ZoomLevel(): number {

packages/mapviewer/src/config/print.config.js

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,3 +5,16 @@ export const PRINT_DPI_COMPENSATION = 144
55
// when the scale is too low, the print backend can't read the exponent.
66
//So when there is a non 0 scale, we set its minimum to 0.0001
77
export const MIN_PRINT_SCALE_SIZE = 0.0001
8+
9+
/** Dimensions in mm of the viewport for each print format */
10+
export const PRINT_DIMENSIONS = {
11+
A0: [1189, 841],
12+
A1: [841, 594],
13+
A2: [594, 420],
14+
A3: [420, 297],
15+
A4: [297, 210],
16+
A5: [210, 148],
17+
A6: [148, 105],
18+
}
19+
20+
export const PRINT_DEFAULT_DPI = 96

packages/mapviewer/src/modules/i18n/locales/de.json

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -498,7 +498,10 @@
498498
"position": "Position",
499499
"print": "Drucken",
500500
"print_action": "Erstelle PDF für Druck",
501+
"print_footer_description": "www.geo.admin.ch ist ein Portal zur Einsicht von geolokalisierten Informationen, Daten und Diensten, die von öffentlichen Einrichtungen zur Verfügung gestellt werden",
502+
"print_footer_disclaimer": "Obwohl die Bundesbehörden mit aller Sorgfalt auf die Richtigkeit der veröffentlichten Informationen achten, kann hinsichtlich der inhaltlichen Richtigkeit, Genauigkeit, Aktualität, Zuverlässigkeit und Vollständigkeit dieser Informationen keine Gewährleistung übernommen werden.Copyright: Bundesbehörden der Schweizerischen Eidgenossenschaft. https://www.admin.ch/gov/de/start/rechtliches.html. Falls Daten Dritter abgebildet werden, wird deren Verfügbarkeit durch den Drittanbieter gewährleistet. Es gelten zusätzlich die Bedingungen der entsprechenden Datenherren.",
501503
"print_layout": "Orientierung",
504+
"print_printed_on": "Gedruckt am",
502505
"print_request_too_large": "Die Datei wird nicht gedruckt: zu gross.",
503506
"print_scale": "Massstab",
504507
"print_underway_message": "Wir bitten Sie um Geduld. Ein mehrseitiger Druck wird erstellt. Dies nimmt einige Zeit in Anspruch.",

packages/mapviewer/src/modules/i18n/locales/en.json

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -498,7 +498,10 @@
498498
"position": "Position",
499499
"print": "Print",
500500
"print_action": "Create PDF for print",
501+
"print_footer_description": "www.geo.admin.ch is a portal provided by the Federal Authorities of the Swiss Confederation to gain insight on publicly accessible geographical information, data and services",
502+
"print_footer_disclaimer": "Although every care has been taken by the Federal Authorities to ensure the accuracy of the information published, no warranty can be given in respect of the accuracy, reliability, up-to-dateness or completeness of this information. Copyright: Swiss federal authorities. https://www.admin.ch/gov/en/start/terms-and-conditions.html. If data from third parties are depicted, their availability is ensured by the third-party provider. Additionally, the conditions of the respective data owners apply.",
501503
"print_layout": "Orientation",
504+
"print_printed_on": "Printed on",
502505
"print_request_too_large": "Printing error: the file to print is too large",
503506
"print_scale": "Scale",
504507
"print_underway_message": "We ask you for your patience. A multi-page print is underway, which can take some time.",

packages/mapviewer/src/modules/i18n/locales/fr.json

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -498,9 +498,12 @@
498498
"position": "Position",
499499
"print": "Imprimer",
500500
"print_action": "Créer PDF pour impression",
501+
"print_footer_description": "www.geo.admin.ch est un portail d'accès aux informations géolocalisées, données et services qui sont mis à disposition par l'administration fédérale",
502+
"print_footer_disclaimer": "Responsabilité: Malgré la grande attention qu'elles portent à la justesse des informations diffusées sur ce site, les autorités fédérales ne peuvent endosser aucune responsabilité quant à la fidélité, à l'exactitude, à l'actualité, à la fiabilité et à l'intégralité de ces informations. Droits d'auteur: autorités de la Confédération suisse. https://www.admin.ch/gov/fr/accueil/conditions-utilisation.html. Si des données de tiers sont représentées, leur disponibilité est garantie par le tiers fournisseur. Les conditions des détenteurs de données correspondants s'appliquent également.",
501503
"print_layout": "Orientation",
504+
"print_printed_on": "Imprimé le",
502505
"print_request_too_large": "Impression impossible : le fichier est trop grand.",
503-
"print_scale": "Echelle",
506+
"print_scale": "Échelle",
504507
"print_underway_message": "Nous vous prions de bien vouloir patienter. Une impression de plusieurs pages est en réalisation. Cela prend un peu de temps.",
505508
"problem_announcement": "Annoncer un problème",
506509
"profile_distance": "Distance à vol d'oiseau",

packages/mapviewer/src/modules/i18n/locales/it.json

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -498,7 +498,10 @@
498498
"position": "Posizione",
499499
"print": "Stampa",
500500
"print_action": "Creare PDF per la stampa",
501+
"print_footer_description": " www.geo.admin.ch è un portale d'accesso ad informazioni, dati e servizi geografici messi a disposizione dall'amministrazione federale.",
502+
"print_footer_disclaimer": "Nonostante si presti grande attenzione all’esattezza delle informazioni pubblicate su questo sito, le autorità federali declinano ogni responsabilità per la fedeltà, l’esattezza, l’attualità, l’affidabilità e la completezza di tali informazioni. Diritti d’autore: autorità della Confederazione Svizzera. https://www.admin.ch/gov/it/pagina-iniziale/basi-legali.html. Se sono rappresentati dati di terze parti, la loro disponibilità è garantita dal fornitore terzo. Si applicano inoltre le condizioni dei rispettivi detentori dei dati.",
501503
"print_layout": "Orientamento",
504+
"print_printed_on": "Stampato il",
502505
"print_request_too_large": "Errore di stampa: file troppo pesante",
503506
"print_scale": "Scala",
504507
"print_underway_message": "Le chiediamo di avere pazienza. È in corso una stampa su più pagine, che può richiedere un po' di tempo.",

packages/mapviewer/src/modules/i18n/locales/rm.json

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -496,7 +496,10 @@
496496
"position": "Posiziun",
497497
"print": "Stampar",
498498
"print_action": "Creais PDF per stampar",
499+
"print_footer_description": "www.geo.admin.ch è in portal d'access ad infurmaziuns geolocalisadas, datas ed a servetschs che vegnan mess a disposiziun da l'administraziun federala.",
500+
"print_footer_disclaimer": "Malgrà che las autoritads fan bain adatg che las infurmaziuns publitgadas sin questa pagina d'internet sajan correctas, na pon ellas surpigliar nagina responsabladad per la correctadad dal cuntegn, per l'exactezza, per l'actualitad, per l'autenticitad e per la cumplettezza da talas infurmaziuns. Dretgs d'autur: autoritads da la Confederaziun svizra. https://www.admin.ch/gov/rm/pagina-iniziala/infurmaziuns-giuridicas.html. Sche datas da terzs vegnan mussadas, è lur disponibilitad garantida dal furnitur da terzs. Ultra da quai valan er las cundiziuns dals possesurs da las datas correspundentas.",
499501
"print_layout": "Orientaziun",
502+
"print_printed_on": "Stampà ils",
500503
"print_request_too_large": "Betg pussaivel da stampar: Datoteca memia gronda.",
501504
"print_scale": "Scala",
502505
"print_underway_message": "Nus As supplitgain d'avair pazienza. In stampat da pliras paginas vegn preparà, quai dovra ses temp.",
6.23 KB
Loading
Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
<script setup>
2+
import { computed, inject, onBeforeUnmount, onMounted, ref } from 'vue'
3+
import { useStore } from 'vuex'
4+
5+
const { resolution } = defineProps({
6+
resolution: {
7+
type: Number,
8+
required: true,
9+
},
10+
})
11+
12+
const olMap = inject('olMap')
13+
14+
const store = useStore()
15+
const mapResolution = computed(() => store.getters.resolution)
16+
17+
const startingResolution = ref(null)
18+
19+
onMounted(() => {
20+
startingResolution.value = mapResolution.value
21+
olMap.getView().setResolution(resolution)
22+
})
23+
24+
onBeforeUnmount(() => {
25+
olMap.getView().setResolution(startingResolution.value)
26+
})
27+
</script>
28+
29+
<template>
30+
<slot />
31+
</template>

0 commit comments

Comments
 (0)