From 2fef3521c505a68e79dc1fda8ff95da643892c8c Mon Sep 17 00:00:00 2001 From: Ulli Goschler Date: Tue, 8 Oct 2024 13:56:54 +0200 Subject: [PATCH] Default elevation profile (#23) * set default elevation profile based on activity type * decrease tic clutter on hikes --- pkg/activity/templates/mtb/elevation.plt | 76 ------------------ pkg/activity/templates/wandern/elevation.plt | 77 +------------------ pkg/activity/templates/wandern/header.yaml | 2 +- pkg/migrate/splitelevation.go | 18 ++++- .../elevationprofile/activity-settings.plt | 2 +- 5 files changed, 20 insertions(+), 155 deletions(-) diff --git a/pkg/activity/templates/mtb/elevation.plt b/pkg/activity/templates/mtb/elevation.plt index 9c7e2f1..00f3164 100644 --- a/pkg/activity/templates/mtb/elevation.plt +++ b/pkg/activity/templates/mtb/elevation.plt @@ -1,77 +1 @@ -# vim: set ft=gnuplot: -# MTB VERSION -# -- [ Colors ] -- -# MTB Maroon #AF3235 -# Alternat. Olivegreen #3C8031 -mtb = "#AF3235" -olivegreen = "#3C8031" - -mycolor = mtb -altcolor = olivegreen - -# -- [ Scaling ] -- -YTICS = 200 - -# MTB -mtbKM = 20 -mtbHM = 0.235 - -myscaleKM = mtbKM -myscaleHM = mtbHM -# --- - -file = 'gpxdata.txt' - -reset -unset key -stats file u 3:2 nooutput -set xrange [STATS_min_x:STATS_max_x] -# floor to lowest elevation, to always display minimum elevation; -set yrange [floor(STATS_min_y/YTICS) * YTICS:STATS_max_y] -set y2range [floor(STATS_min_y/YTICS) * YTICS:STATS_max_y] - -# Max Km mit Skalierungsfaktor. Den (fiktiven) Pixelwert von 300dpi auf cm umrechnen und den gesamten Skalierungsfaktor darauf mulitiplizieren. -# vielleicht nicht so ideal -w = floor(STATS_max_x * myscaleKM) * 2.54 / 300 * 2 -# h = floor((STATS_max_y - STATS_min_y) * myscaleHM) * 2.54 / 300 * 2 -# switch from 300 to 250 as small tours are getting dense 07.2016 -h = floor((STATS_max_y - STATS_min_y) * myscaleHM) * 2.54 / 250 * 2 - -# -- [ Labels ] -- set label 1 '\textcolor{mtb}{TOP}' at STATS_pos_max_y,STATS_max_y point pointtype 7 ps 0.6 offset 0.3,0.3 front -#set label 2 '\textcolor{mtb}{foo}' at xxx,yyy point pointtype 7 ps 0.6 offset 0.3,0.3 front - -# -- [ Terminal ] -- -# epslates does not support transparency -# for mac xquartz is required to install epslatex https://xquartz.macosforge.org/landing/ -# brew install gnuplot --cairo -set terminal cairolatex size w cm,h cm color -set output "elevation.tex" - -# -- [ Grid and Tics ] -- -set xtic 5 -set xtic nomirror -unset border -set grid lt 0 dashtype 2 lw 3 lc rgb "black" -set format x "%g\\tiny\\,\\color{darkgray}{km}" - -# ELEVATION SCALE ON THE RIGHT: -#set y2tics border 200 -#set format y2 "%g\\tiny\\,\\color{darkgray}{m}" -# OR ON THE LEFT: -set ytics border YTICS nomirror -set format y "%h\\tiny\\,\\color{darkgray}{m}" -# cut right margin -set rmargin at screen 1 - -# --- -# plot border: 1 bottom; 2 left -set border 3 lt 3 lw 3 lc rgb "#708090" - -# correct the margin calculations which are based -# on the length of the format string, to a fixed value -set lmargin 4.8 - -set style fill transparent solid 0.45 noborder -plot file u 3:2 w filledcurve x1 lc rgb "black" , \ - file u 3:2 w lines lt 1 lw 5 lc rgb mycolor diff --git a/pkg/activity/templates/wandern/elevation.plt b/pkg/activity/templates/wandern/elevation.plt index 66690c8..0a7bbf3 100644 --- a/pkg/activity/templates/wandern/elevation.plt +++ b/pkg/activity/templates/wandern/elevation.plt @@ -1,77 +1,2 @@ # vim: set ft=gnuplot: -# WANDERN VERSION -# -- [ Colors ] -- -# Wandern ForestGreen #009B55 -# Alternat. Olivegreen #3C8031 -wandern = "#009B55" -olivegreen = "#3C8031" - -mycolor = wandern -altcolor = olivegreen - -# -- [ Scaling ] -- -YTICS = 100 - -# WANDERN -wandernKM = 44.97 # 17.99cm / 40km -wandernHM = 0.300 - -myscaleKM = wandernKM -myscaleHM = wandernHM -# --- - -file = 'gpxdata.txt' - -reset -unset key -stats file u 3:2 nooutput -set xrange [STATS_min_x:STATS_max_x] -# floor to lowest elevation, to always display minimum elevation; -set yrange [floor(STATS_min_y/YTICS) * YTICS:STATS_max_y] -set y2range [floor(STATS_min_y/YTICS) * YTICS:STATS_max_y] - -# Max Km mit Skalierungsfaktor. Den (fiktiven) Pixelwert von 300dpi auf cm umrechnen und den gesamten Skalierungsfaktor darauf mulitiplizieren. -# vielleicht nicht so ideal -w = floor(STATS_max_x * myscaleKM) * 2.54 / 300 * 2 -# h = floor((STATS_max_y - STATS_min_y) * myscaleHM) * 2.54 / 300 * 2 -# switch from 300 to 250 as small tours are getting dense 07.2016 -h = floor((STATS_max_y - STATS_min_y) * myscaleHM) * 2.54 / 250 * 2 - -# -- [ Labels ] -- -set label 1 '\textcolor{wandern}{TOP}' at STATS_pos_max_y,STATS_max_y point pointtype 7 ps 0.6 offset 0.3,0.3 front -#set label 2 '\textcolor{wandern}{NNN}' at XXX,YYY point pointtype 7 ps 0.6 offset 0.3,0.3 front - -# -- [ Terminal ] -- -# epslates does not support transparency -# for mac xquartz is required to install epslatex https://xquartz.macosforge.org/landing/ -# brew install gnuplot --cairo -set terminal cairolatex size w cm,h cm color -set output "elevation.tex" - -# -- [ Grid and Tics ] -- -set xtic 5 -set xtic nomirror -unset border -set grid lt 0 dashtype 2 lw 3 lc rgb "black" -set format x "%g\\tiny\\,\\color{darkgray}{km}" - -# ELEVATION SCALE ON THE RIGHT: -#set y2tics border 200 -#set format y2 "%g\\tiny\\,\\color{darkgray}{m}" -# OR ON THE LEFT: -set ytics border YTICS nomirror -set format y "%h\\tiny\\,\\color{darkgray}{m}" -# cut right margin -set rmargin at screen 1 - -# --- -# plot border: 1 bottom; 2 left -set border 3 lt 3 lw 3 lc rgb "#708090" - -# correct the margin calculations which are based -# on the length of the format string, to a fixed value -set lmargin 4.8 - -set style fill transparent solid 0.45 noborder -plot file u 3:2 w filledcurve x1 lc rgb "black" , \ - file u 3:2 w lines lt 1 lw 5 lc rgb mycolor +set label 1 sprintf("\\textcolor\{wandern\}\{%s \\tiny %sm\}", title, maxElevation) at STATS_pos_max_y,STATS_max_y point pointtype 7 ps 0.6 offset 0.3,0.3 front diff --git a/pkg/activity/templates/wandern/header.yaml b/pkg/activity/templates/wandern/header.yaml index 42e5c55..04095b5 100644 --- a/pkg/activity/templates/wandern/header.yaml +++ b/pkg/activity/templates/wandern/header.yaml @@ -26,7 +26,7 @@ stats: layout: headElevationProfile: false - elevationProfileType: left-axis-layout + elevationProfileType: right-axis-filtered-layout elevationProfileRightMargin: 0 tableSize: 0.45 mapSize: 0.59 diff --git a/pkg/migrate/splitelevation.go b/pkg/migrate/splitelevation.go index 8f123da..a7028d1 100644 --- a/pkg/migrate/splitelevation.go +++ b/pkg/migrate/splitelevation.go @@ -53,10 +53,26 @@ func insertElevationProfileType(textDir string) (bool, error) { return false, fmt.Errorf("error unmarshalling YAML: %w", err) } + var layout string + + activityType, err := activity.GetFromHeader[string](textDir, "Activity.Type") + if err != nil { + return false, fmt.Errorf("error getting activity type: %w", err) + } + + switch activityType { + case "skitour": + layout = "right-axis-filtered-layout" + case "wandern": + layout = "right-axis-filtered-layout" + case "mtb": + layout = "left-axis-layout" + } + // Check if elevationProfile key exists under layout if header.Layout.ElevationProfileType == "" { // If elevationProfile key does not exist, add it - header.Layout.ElevationProfileType = "left-axis-layout" + header.Layout.ElevationProfileType = layout } // Marshal the updated data back to YAML var enc bytes.Buffer diff --git a/pkg/render/templates/elevationprofile/activity-settings.plt b/pkg/render/templates/elevationprofile/activity-settings.plt index 3764535..adece44 100644 --- a/pkg/render/templates/elevationprofile/activity-settings.plt +++ b/pkg/render/templates/elevationprofile/activity-settings.plt @@ -17,7 +17,7 @@ mtbTics = 200 mtbKM = 20 mtbHM = 0.235 -wandernTics = 100 +wandernTics = 200 wandernKM = 44.97 # 17.99cm / 40km wandernHM = 0.255