Skip to content

Commit d8ded79

Browse files
committed
WIP Print view
1 parent 33aac2f commit d8ded79

File tree

16 files changed

+250
-106
lines changed

16 files changed

+250
-106
lines changed

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: 9 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -8,10 +8,13 @@ export const MIN_PRINT_SCALE_SIZE = 0.0001
88

99
/** Dimensions in pixel of the viewport for each print format */
1010
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],
11+
A0: [3179, 4494],
12+
A1: [2245, 3179],
13+
A2: [1587, 2245],
14+
A3: [1123, 1587],
15+
A4: [794, 1123],
16+
A5: [559, 794],
17+
A6: [397, 559],
1718
}
19+
20+
export const PRINT_DEFAULT_DPI = 96

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

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -500,6 +500,7 @@
500500
"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",
501501
"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.",
502502
"print_layout": "Orientierung",
503+
"print_printed_on": "Gedruckt am",
503504
"print_request_too_large": "Die Datei wird nicht gedruckt: zu gross.",
504505
"print_scale": "Massstab",
505506
"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: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -500,6 +500,7 @@
500500
"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",
501501
"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.",
502502
"print_layout": "Orientation",
503+
"print_printed_on": "Printed on",
503504
"print_request_too_large": "Printing error: the file to print is too large",
504505
"print_scale": "Scale",
505506
"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: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -500,8 +500,9 @@
500500
"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",
501501
"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.",
502502
"print_layout": "Orientation",
503+
"print_printed_on": "Imprimé le",
503504
"print_request_too_large": "Impression impossible : le fichier est trop grand.",
504-
"print_scale": "Echelle",
505+
"print_scale": "Échelle",
505506
"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.",
506507
"problem_announcement": "Annoncer un problème",
507508
"profile_distance": "Distance à vol d'oiseau",

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

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -500,6 +500,7 @@
500500
"print_footer_description": " www.geo.admin.ch è un portale d'accesso ad informazioni, dati e servizi geografici messi a disposizione dall'amministrazione federale.",
501501
"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.",
502502
"print_layout": "Orientamento",
503+
"print_printed_on": "Stampato il",
503504
"print_request_too_large": "Errore di stampa: file troppo pesante",
504505
"print_scale": "Scala",
505506
"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: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -498,6 +498,7 @@
498498
"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.",
499499
"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.",
500500
"print_layout": "Orientaziun",
501+
"print_printed_on": "Stampà ils",
501502
"print_request_too_large": "Betg pussaivel da stampar: Datoteca memia gronda.",
502503
"print_scale": "Scala",
503504
"print_underway_message": "Nus As supplitgain d'avair pazienza. In stampat da pliras paginas vegn preparà, quai dovra ses temp.",

packages/mapviewer/src/modules/map/components/openlayers/OpenLayersMap.vue

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -66,8 +66,6 @@ function triggerReadyFlagIfAllRendered() {
6666
}
6767
map.once('rendercomplete', triggerReadyFlagIfAllRendered)
6868
69-
map.once('rendercomplete', triggerReadyFlagIfAllRendered)
70-
7169
onMounted(() => {
7270
map.setTarget(mapElement.value)
7371
useMapInteractions(map)

packages/mapviewer/src/modules/map/components/openlayers/OpenLayersScale.vue

Lines changed: 66 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,17 @@ import ScaleLine from 'ol/control/ScaleLine'
44
import { computed, inject, onBeforeUnmount, onMounted, useTemplateRef } from 'vue'
55
import { useStore } from 'vuex'
66
7+
const { scaleType, minWidth } = defineProps({
8+
scaleType: {
9+
type: String,
10+
default: 'line',
11+
},
12+
minWidth: {
13+
type: Number,
14+
default: 100,
15+
}
16+
})
17+
718
const scaleLineElement = useTemplateRef('scaleLineElement')
819
920
const store = useStore()
@@ -13,7 +24,9 @@ const projection = computed(() => store.state.position.projection)
1324
const showScaleLine = computed(() => projection.value.epsg === LV95.epsg || zoom.value >= 9)
1425
1526
const scaleLine = new ScaleLine({
16-
className: 'scale-line',
27+
className: `scale-${scaleType}`,
28+
bar: scaleType === 'bar',
29+
minWidth: minWidth,
1730
})
1831
1932
const olMap = inject('olMap')
@@ -50,4 +63,56 @@ onBeforeUnmount(() => olMap.removeControl(scaleLine))
5063
background-color: rgba($white, 0.7);
5164
}
5265
}
66+
67+
.scale-bar {
68+
$scaleBarBorderColor: $black;
69+
$scaleBarPrimary: $gray-800;
70+
$scaleBarSecondary: $gray-300;
71+
72+
position: relative;
73+
74+
.scale-bar-inner {
75+
display: flex;
76+
}
77+
78+
.ol-scale-step-marker {
79+
width: 1px;
80+
height: 15px;
81+
background-color: $scaleBarBorderColor;
82+
float: right;
83+
z-index: 10;
84+
}
85+
86+
.ol-scale-step-text {
87+
position: absolute;
88+
bottom: -7px;
89+
font-size: 11px;
90+
z-index: 11;
91+
color: $scaleBarBorderColor;
92+
}
93+
94+
.ol-scale-text {
95+
position: absolute;
96+
font-size: 12px;
97+
text-align: center;
98+
bottom: 25px;
99+
color: $scaleBarBorderColor;
100+
}
101+
102+
.ol-scale-singlebar {
103+
position: relative;
104+
height: 10px;
105+
z-index: 9;
106+
box-sizing: border-box;
107+
border: 1px solid $scaleBarBorderColor;
108+
}
109+
110+
.ol-scale-singlebar-even {
111+
background-color: $scaleBarSecondary;
112+
}
113+
114+
.ol-scale-singlebar-odd {
115+
background-color: $scaleBarPrimary;
116+
}
117+
}
53118
</style>

0 commit comments

Comments
 (0)