forked from poutnikl/Brouter-profiles
-
Notifications
You must be signed in to change notification settings - Fork 0
/
sedbatch
executable file
·683 lines (518 loc) · 31.1 KB
/
sedbatch
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
#!/bin/bash
#
# The script generates Brouter profiles from a reference to a profile template.
# It can by run in a Linux terminal,
# but it's true power comes if run in termux,
# a powerful Linux terminal emulator for Android.
#****** history ****************
# Ver 1.1 Fixed generation for Hiking-wet profiles ( by error identical to dry ones )
# Ver 1.2 Parameter "main" generates only main/major profiles
# Ver 1.2.1 Fixed names of Trekking-Dry/Wet profiles ( Was Poutnik instead of Trekking ])
# Ver 1.3.1 Added Shortest-P profile
# Ver 1.3.2 windows batch ported to Linux Bash
# Ver 1.4 Improved script parameter logic. Action paramaters are bike/car/foot, modifiers are master/develop and all/main
# Implemented termux path specifics and profike copying
# Ver 1.5 Implemented modifiers local/git/remote
# Implemented modifiers copy/nocopy
# Ver 1.6 Implemented support for other than Poutnik's profiles.
# THe script automatically generates a bunch of Brouter profiles
# based on the bike/car/foot profile templates by Poutnik
# additionally also on other profiles on Github
# like zossebart's MTB, Jacobcs streetbike .
#
# When launched,
# 1/ it create a working subfolder in a folder where the script resides
# 2/ it downloads latest profile template from GitHub depository,
# or uses local git repository or the script folder storage.
# 3/ it generates end user profiles by automatic substitution of assign parameters.
# 4/ it packs them into a single ZIP archive and deletes the working subfolder content.
# 5/ it optionally copies profiles to the scriot folder
# or from termux private space to Android storage.
#
# ******************************************************
# P R E R E Q U I S I T I E S
# ******************************************************
# 0 This bash script can be run
# either on a desktop Linux
# either on Android within Linux terminal emulator termux.
#
# Points 1-5 applies only if to be run on an Android device
#
# 1 Install termux ( Linux terminal emulator for Android )
# https://play.google.com/store/apps/details?id=com.termux
# Read links below for more
# https://termux.com
# https://wiki.termux.com/wiki/Main_Page
# https://wiki.termux.com/wiki/Community
# https://github.com/termux
#
# 2 Run termux, what open Linux terminal emulator
# 3 Execute "termux-setup-storage"
# if you want to grant termux permissions to write profile files out of its sandbox
# to be able to copy profiles to Android storage.
# It is recommended not to copy directly to live profiles2 folder.
# Run "apt update && apt upgrade" to make sure that this tool is available.
# See more at https://wiki.termux.com/wiki/Termux-setup-storage
# 4 Check if commands sed, wget, zip, optionally git are available.
# If not, install them by "pkg install command"
# 5 Check and define within the script code
# your desired target folder for copying profiles.
#
# 6 If run on termux with access to Android storage,
# the optional copying of zipped profiles
# is pointed to the provided Android storage folder,
# otherwise the archive remains in the script folder..
#
# 7 Both Linux and termux expects placing the sedbatch script
# into a dedicated folder.
# (subject of later renaming, it remains for historical reasons )
# 8 (optional) if going to use git or pull sourve midifiers,
# you need to install git and clone repositories/branches of interest.
#
# USAGE
# The sedbatch script expects particular command line parameters to do anything.
# "sedbatch" without parameters lists the short info.
# "sedbatch" <action> [<action> ..... ]
# generates the respective set of Brouter profiles, zipped into a ZIP archive.
# <action> ::=
# <scope> ::= all | main | locus
# <branch> ::= master | develop
# <copying> ::= nocopy | copy
# <source location> ::= remote | git | local
# <profile_set> ::= bike | foot | car | mtb | street
# The script can be provided by arbitrary sequence of above mentioned keywords:
# bike car foot mtb street main all master develop copy nocopy remote local git
#
# bike, car, foot, mtb, street are "action" keywords, generating respective profiles from a profile template.
# mtb generates 4 variants of zossebart MTB profiles.
# street generates 2 variants of Jacob's streetbike profikes
# The rest of keywords are modifiers, changing the default values.
# Note that their scope the whole keyword sequence, unless overridden by new value.
# all(default), main
# are modifiers, setting scope of generated profiles ( all or the most important)
# master(default), develop
# are modifiers determining the github repository branch, where the profile template is located
# ( if git modifier is used, they preform switching local git branches )
# nocopy(default), copy
# copy copies zipped profiles to orovidec Android storage
# outside of the orivate termux space ( with jailbroken termux )
# remote(default), git, local determined location of the script template
# local=script folder, git=local git repository, remote=remote github repository
# git and remote stores the template in locsl folder
# and remember what branch it came from.
#
#
# Examples of usage'
# "sedbatch bike" generates all profiles from bike trekking template
# and stores them in BR-Bike-Profiles-master-all.zip
# and generates the all profiles for all car, bike and foot transportation modes
#
# "sedbatch main develop bike" generates only selected major profiles from bike trekking template
# from develop branch
#
# "sedbatch copy main git foot all bike develop main car"
# generates from local git repositories major profiles for hiking, all profiles for bike trekking
# and selected profiles from car template develop branch.
# Additionally, the zipped profiles are copied to selected folder outside of termux
#
# ******************************************************
# L E G E N D
# ******************************************************
function legend {
echo 'The sedbatch script expects an arbitrary sequence of following keywords to do anything:'
echo 'bike car foot mtb street main all master develop copy nocopy local remote git'
echo '.'
echo 'bike, car, foot, mtb, street are "action" keywords, generating respective profiles from a profile template'
echo '.'
echo 'all(default), main set the scope of generated profiles ( all or the most important)'
echo 'master(default), develop are modifiers determining the github repository branch, where the profile template is located'
echo '.'
echo 'If a modifier is used it becomes the new default'
echo 'for the rest of the line, unless overridden again.'
echo '.'
echo 'for examples and more info, see the legend comments withing the script.'
}
# ******************************************************
# M A I N
# ******************************************************
function main {
# *************** V A R I A B L E S ******************
#termux relative path from $HOME
# to Android internal storage (if termux is jailbroken)
STORAGE_PREFIX=~/storage/shared
# Brouter target folder relative paths from termux home.
BRPATH=~/storage/shared/Brouter/myprofiles
# the folder holding your local git repositories
LOCAL_GIT_ROOT=$HOME
#relative working folder for SED based manipulations
SEDWDIR=sedwdir
#https://stackoverflow.com/questions/59895/get-the-source-directory-of-a-bash-script-from-within-the-script-itself
script_folder="$( cd "$( dirname "${BASH_SOURCE[0]}" )" >/dev/null 2>&1 && pwd )"
#Default values of modifiers
github_branch=master #branch master or develop
scope=all #scope all or main
copy_to_brouter=nocopy #copy or nocopy
source=remote #remote or git or local
#Repository and template names
# Essential rewuirement is to keep consistently
# the keyword like "bike" in the vsriable names
GH_PROF_POUTNIK='https://raw.githubusercontent.com/poutnikl'
bikerep='Trekking-Poutnik'
biketemp=$bikerep
bikeprof=$GH_PROF_POUTNIK
legend_prefix_bike="BR-Bike-Profiles"
footrep='Hiking-Poutnik'
foottemp='Hiking'
footprof=$GH_PROF_POUTNIK
legend_prefix_foot="BR-Foot-Profiles"
carrep='Car-Profile'
cartemp='Car-test-Template'
carprof=$GH_PROF_POUTNIK
legend_prefix_car="BR-Car-Profiles"
GH_PROF_ZOSSEBART='https://raw.githubusercontent.com/zossebart'
#https://github.com/zossebart/brouter-mtb
mtbrep='brouter-mtb'
mtbtemp='mtb-zossebart'
mtbprof=$GH_PROF_ZOSSEBART
legend_prefix_mtb="BR-MTBzoss-Profiles"
GH_PROF_UTACK='https://raw.githubusercontent.com/utack'
#https://github.com/utack/utack_brouter_profile
streetrep='utack_brouter_profile'
streettemp='streetbike_touring'
streetprof=$GH_PROF_UTACK
legend_prefix_street="BR-StrBike-Profiles"
# ************* P R E C H E C K S **************
#Is termux jailbreak set ?
if [[ -L $STORAGE_PREFIX ]]; then # termux is jailbroken
# running on jailbroken termux and can access android storage
termux2storage=true
ifcd $STORAGE_PREFIX
brouterpath="$BRPATH"
ifcd $BRPATH
else # No termux or termux is not jailbroken
termux2storage=false
brouterpath="$brouter_linux_path"
profilespath="$brouterpath"
fi
ifcd "$script_folder"
# ********* P A R A M E T E R L O O P *************
if [[ -z "$1" ]]; then
legend;
else
for arg in "$@"; do
case $arg in
car|bike|foot|mtb|street) profgenprep "$arg";;
develop|master) github_branch="$arg";;
main|all|locus) scope="$arg";;
copy) [[ $termux2storage = true ]] && copy_to_brouter=copy || copy_to_brouter=nocopy;;
nocopy) copy_to_brouter=nocopy;;
local|remote|git|pull) source="$arg";;
*) echo "An unknown parameter $arg"; legend;;
esac
done
fi
} # M A I N E N D
# ******************************************************
# ******************************************************
# P R O F I L E S G E N P R E P
# ******************************************************
function profgenprep { #$1=bike/foot/car/mtb/street
if [[ $1 = "bike" || $1 = "foot" || $1 = "car" || $1 = "mtb" || $1 = "street" ]]; then
modus=$1
#If $modus=bike then repos=bikerep, $template=biketemp, $profile=bikeprof
echo "Modus is :$modus"
case "$modus" in
bike) repos="$bikerep" ; template="$biketemp"; profile="$bikeprof"; legend_prefix="$legend_prefix_bike" ;;
foot) repos="$footrep" ; template="$foottemp"; profile="$footprof"; legend_prefix="$legend_prefix_foot" ;;
car) repos="$carrep" ; template="$cartemp" ; profile="$carprof" ; legend_prefix="$legend_prefix_car" ;;
mtb) repos="$mtbrep" ; template="$mtbtemp" ; profile="$mtbprof" ; legend_prefix="$legend_prefix_mtb" ;;
street) repos="$streetrep"; template="$streettemp"; profile="$streetprof"; legend_prefix="$legend_prefix_street" ;;
*) echo "there is no such a mode as the $modus" ; exit ;;
esac
echo repos "$repos"
echo template "$template"
echo profile "$profile"
echo legend_prefix "$legend_prefix"
echo source "$source"
echo branch "$github_branch"
# modifier "local" reads template from the script folder,
# it uses the file from the last used
# either local git, either remote github source
# script breaks if the file is not found.
if [[ $source = "local" ]]; then
ifcd "$script_folder"
sourcefile="$script_folder/$template.brf"
[[ -f "$sourcefile" ]] || { echo "$sourcefile does not exist" ; exit;}
source_branch "$template" "$github_branch" "get"
if [[ $? -eq 0 ]]; then
echo "The requested branch does not match the local one."
exit
fi
# modifier "git" reads template from local git repository and branch.
# and copy it to the script folder.
# script breaks if the repo or branch are not found.
elif [[ $source = "git" || $source = "pull" ]]; then
ifcd "$LOCAL_GIT_ROOT"
ifcd "$repos"
git checkout "$github_branch" || { echo "The branch $github_branch in $LOCAL_GIT_ROOT/$repos does not exist."; exit; }
sourcefile="$LOCAL_GIT_ROOT/$repos/$template.brf"
[[ ! -f "$sourcefile" ]] && { echo "$sourcefile does not exist" ; exit;}
[[ $source = "pull" ]] && { git fetch; git pull; }
cp "$sourcefile" "$script_folder" || { echo "copying $sourcefile to $script_folder is not possible" ; exit; }
ifcd "$script_folder"
sourcefile="$script_folder/$template.brf"
source_branch "$template" "$github_branch" "set"
# modifier "remote" reads template from remote github repository and branch.
# and copy it to the script folder.
# script breaks if the repo or branch are not found.
elif [[ $source = "remote" ]]; then
cd "$script_folder" || { echo "$script_folder does not exist or no access there."; exit; }
sourcefile="$profile/$repos/$github_branch/$template.brf"
wget -N "$sourcefile" || { echo "$sourcefile could not be retrieved."; exit; }
sourcefile="$script_folder/$template.brf"
source_branch "$template" "$github_branch" "set"
fi
echo "local file: $sourcefile"
wdir
archivefile=$legend_prefix-$github_branch-$scope
legfile=$archivefile-Legend.txt
[[ -f $legfile ]] && rm "$legfile"
echo 'Profile name, Profile description ( generated )' >"$legfile"
case $modus in
(bike) bikeexec;;
(foot) footexec;;
(car) carexec;;
(mtb) mtbexec;;
(street) streetexec;;
(*) Echo "No such an execution mode as $modus"
esac
closing
fi
}
# *****************
function source_branch {
#$template $branch $set/get
#creates/get a flag file about the github branch
#the file came from
if [[ $3 = "set" ]]; then
if [[ -f "$script_folder/.$1-*" ]]; then
rm "$script_folder/.$1-*"
fi
echo "" >"$script_folder/.$1-$2"
elif [[ $3 = "get" ]]; then
if [[ -f "$script_folder/.$1-$2" ]]; then
return 1
else
return 0
fi
fi
}
# ******************************************************
# W D I R
# ******************************************************
function wdir {
sedwdir="$script_folder/$SEDWDIR"
if [[ ! -d "$sedwdir" ]]; then
mkdir "$sedwdir" || { echo "$sedwdir could not be created"; exit; }
fi
ifcd "$sedwdir"
[[ -f "$sedwdir/*.brf" ]] && rm "$sedwdir/*.brf"
[[ -f "$sedwdir/*legend.txt" ]] && rm "$sedwdir/*legend.txt"
[[ ! $modus = foot ]] && src="$template" || src="$template-template"
cp "$sourcefile" "$sedwdir/$src.brf" || { echo "$sourcefile $sedwdir/$src.brf could not be done"; exit; }
}
# ******************************************************
# C L O S I N G
# ******************************************************
function closing {
ifcd "$sedwdir"
rm $src.brf || echo "rm $src.brf could not be done."
if [[ -f "$script_folder/$archivefile.zip" ]]; then
rm "$script_folder/$archivefile.zip"
fi
zip "$script_folder/$archivefile.zip" *.brf "$legfile" -x $src.brf
cp "$sedwdir/$legfile" "$script_folder/$legfile" || echo "Copying $sedwdir/$legfile to $script_folder/$legfile is not possible";
ifcd "$script_folder"
if [[ $copy_to_brouter = copy ]]; then
cp "$archivefile.zip" $BRPATH
cp "$legfile" $BRPATH
fi
ifcd "$sedwdir"
rm -f *.brf
rm -f "$legfile"
ifcd "$script_folder"
}
# ************ ifcd ************
function ifcd {
cd "$1" || {
if [[ -d "$1" ]]; then
echo "cd: The script does not have access to the folder $1. - Exit"
else
echo "cd: The folder $1 does not exist. - Exit"
fi
exit; }
}
# ******************************************************
# E X E C U T I V E S U B R O U T I N E S
# ******************************************************
function replaceone {
# parameters 1=keyword 2=oldvalue 3=newvalue 4=oldfile but ext 5=new file but ext 6=optionally Legend
setrgx="s/\(assign\s\+$1\(\s\|=\)\+\)$2/\1$3/gi"
if [ -z "$6" ]
then
sed -b -e "$setrgx" "$4".brf >"$5".brf
else
sed -b -e "$setrgx" "$4".brf | sed -b -e "s/# LEGEND/# $6/" >"$5".brf
echo "$5".brf, "$6" >>"$legfile"
fi
}
function replacetwo {
# parameters 1=keyword1 2=oldvalue1 3=newvalue2 4=keyword2 5=oldvalue2 6=newvalue2 7=oldfile but ext 8=new file but ext 9=optionally legend
setrgx="s/\(assign\s\+$1\(\s\|=\)\+\)$2/\1$3/gi"
setrgx2="s/\(assign\s\+$4\(\s\|=\)\+\)$5/\1$6/gi"
if [[ -z "$9" ]]; then
sed -b -e "$setrgx" "$7".brf | sed -b -e "$setrgx2" >"$8".brf
else
sed -b -e "$setrgx" "$7".brf | sed -b -e "$setrgx2" | sed -b -e "s/# LEGEND/# $9/" >"$8".brf
echo "$8".brf, "$9" >>"$legfile"
fi
}
# ******************************************************
# B I C Y C L E P R O F I L E S E X E C
# ******************************************************
function bikeexec {
replaceone is_wet 0 0 $src Trekking-dry "Standard Trekking profile by Poutnik"
if [[ ! "$scope" = "locus" ]]; then
replaceone is_wet 0 1 $src $src-wet
replaceone iswet 0 1 $src-wet Trekking-wet 'Standard Trekking profile by Poutnik, for wet weather ( partially avoids muddy or slicky surface, but does not forbid them )'
fi
replaceone MTB_factor 0.0 0.5 $src Trekking-MTB-medium "Trekking profile with medium focus on unpaved roads, moderately penalizing mainroads."
replaceone MTB_factor 0.0 -0.5 $src Trekking-Fast "Trekking profile with moderate focus on mainroads, penalizing unpaved roads. Between Trekking and FastBike."
replacetwo MTB_factor 0.0 2.0 smallpaved_factor 0.0 -0.5 $src MTB "MTB profile, based on MTBiker feedback"
replacetwo MTB_factor 0.0 1.0 smallpaved_factor 0.0 -0.3 $src MTB-light "Light MTB profile for tired bikers, based on MTBiker feedback. Preferred to Trekking-MTB-strong"
replacetwo MTB_factor 0.0 -1.7 smallpaved_factor 0.0 2.0 $src Trekking-SmallRoads "Trekking profile more preferring small paved roads and tracks"
if [[ "$scope" = "all" || "$scope" = "locus" ]]; then {
replaceone MTB_factor 0.0 0.2 $src Trekking-MTB-light "Trekking profile with light focus on unpaved roads, slightly penalizing mainroads."
replaceone MTB_factor 0.0 1.0 $src Trekking-MTB-strong "Trekking profile with strong focus on unpaved roads, strongly penalizes mainroads. Similar to MTB light, that is preferred."
replaceone cycleroutes_pref 0.2 0.0 $src Trekking-ICR "Trekking profile ignoring existence of cycleroutes"
replaceone cycleroutes_pref 0.2 0.5 $src Trekking-FCR "Trekking profile more following cycleroutes, expecially long distance ones"
replaceone cycleroutes_pref 0.2 0.8 $src Trekking-LCR "Trekking profile for long distance cycleroutes"
replaceone hills 1 2 Trekking-FCR Trekking-FCR-hills2 "Trekking profile ignoring existence of cycleroutes"
replaceone hills 1 2 Trekking-LCR Trekking-LCR-hills2 "Trekking profile ignoring existence of cycleroutes"
replaceone hills 1 4 $src Trekking-Valley "Trekking in Valley mode, preferred flats as far as possible, even in expense of steep valley escape. On-the-slope based penalizations by Up-down-costfactors."
replaceone hills 1 5 $src Trekking-No-Flat "Trekking in No-Flat mode, giving penalty to flat roads, with zero hillcost."
replacetwo MTB_factor 0.0 1.5 smallpaved_factor 0.0 -0.75 $src $src-tmp
replaceone isbike_for_mainroads true false $src-tmp Trekking-tracks "Trekking in Tracks mode, Strong preference of unpaved tracks and paths"
rm $src-tmp.brf
replacetwo MTB_factor 0.0 2.0 smallpaved_factor 0.0 -1.0 $src $src-tmp
replacetwo isbike_for_mainroads true false path_preference 0.0 20.0 $src-tmp Trekking-hilly-paths "Trekking in Hilly paths mode, Very strong preference of unpaved hilly paths"
replacetwo tandem_mode 0 1 ignore_cycle_barrier 1 0 $src Trek_tandem "Trekking on a tandem bike addressing the tandem manipulation specifics"
rm $src-tmp.brf
}
fi
if [[ "$scope" = "all" ]]; then {
replaceone MTB_factor 0.0 0.2 $src-wet Trekking-MTB-light-wet "Trekking wet weather profile with light focus on unpaved roads, slightly penalizing mainroads."
replaceone MTB_factor 0.0 0.5 $src-wet Trekking-MTB-medium-wet "Trekking wet weather profile with medium focus on unpaved roads, moderately penalizing mainroads."
replaceone MTB_factor 0.0 1.0 $src-wet Trekking-MTB-strong-wet "Trekking wet weather profile with strong focus on unpaved roads, strongly penalizes mainroads. Similar to MTB light, that is preferred."
replaceone MTB_factor 0.0 -0.5 $src-wet Trekking-Fast-wet "Trekking wet weather profile with moderate focus on mainroads, penalizing unpaved roads. Between Trekking and FastBike."
replacetwo MTB_factor 0.0 2.0 smallpaved_factor 0.0 -0.5 $src-wet MTB-wet "MTB wet weather profile, based on MTBiker feedback"
replacetwo MTB_factor 0.0 1.0 smallpaved_factor 0.0 -0.3 $src-wet MTB-light-wet "Light MTB wet weather profile for tired bikers, based on MTBiker feedback. Preferred to Trekking-MTB-strong"
replaceone cycleroutes_pref 0.2 0.0 $src-wet Trekking-ICR-wet "Trekking profile ignoring existence of cycleroutes, wet weather variant"
replaceone cycleroutes_pref 0.2 0.5 $src-wet Trekking-FCR-wet "Trekking profile more following cycleroutes, expecially long distance ones, wet weather variant"
replaceone cycleroutes_pref 0.2 0.8 $src-wet Trekking-LCR-wet "Trekking profile for long distance cycleroutes, wet weather variant"
replaceone hills 1 2 Trekking-FCR-wet Trekking-FCR-wet-hills2 "Trekking profile ignoring existence of cycleroutes, wet weather variant"
replaceone hills 1 2 Trekking-LCR-wet Trekking-LCR-wet-hills2 "Trekking profile ignoring existence of cycleroutes, wet weather variant"
replacetwo MTB_factor 0.0 -1.7 smallpaved_factor 0.0 2.0 $src-wet Trekking-SmallRoads-wet "Trekking profile more preferring small paved roads and tracks, wet weather variant"
}
fi
} # B I C Y C L E P R O F I L E S E X E C
# ******************************************************
# C A R P R O F I L E S E X E C
# ******************************************************
function carexec {
replaceone avoid_toll 0 1 $src $src-TollFree
replaceone avoid_motorways 0 1 $src $src-NoMotorway
replaceone avoid_unpaved 0 1 $src $src-NoUnpaved
replaceone drivestyle 2 3 $src Car-Fast "Car profile going for Speed - possible with booth or vignette tolls"
replaceone drivestyle 2 1 $src Car-Eco "Economic Car profile, fuel saving. Possible with booth or vignette tolls. May be slow."
replaceone drivestyle 2 2 $src Car-FastEco "Car profile balancing Speed and Cost - RECOMMENDED"
replaceone drivestyle 2 0 $src Car-Short "Car profile, shortest route, probably useless unless for technical emergency."
replaceone drivestyle 2 3 $src-TollFree Car-Fast-TollFree "Toll free, Car profile going for Speed"
replaceone drivestyle 2 2 $src-TollFree Car-FastEco-TollFree "Toll free, Car profile balancing Speed and Cost - RECOMMENDED"
replaceone drivestyle 2 1 $src-TollFree Car-Eco-TollFree "Toll free, Car profile going for low cost - May be slow, as low cost speed is 60-80 km per h"
replaceone drivestyle 2 3 $src-NoMotorway Car-Fast-NoMotorway "Car profile going for Speed - Avoiding motorways\/motorroads"
replaceone drivestyle 2 3 $src-NoUnpaved Car-Fast-NoUnpaved "Car profile going for Speed - Avoiding unpaved ways"
if [[ "$scope" = "all" ]]; then {
replaceone drivestyle 2 2 $src-NoMotorway Car-FastEco-NoMotorway "Car profile balancing Speed and Cost - Avoiding motorways\/motorroads, RECOMMENDED"
replaceone drivestyle 2 1 $src-NoMotorway Car-Eco-NoMotorway "Economic Car profile, fuel saving, Avoiding motorways\/motorroads, May be slow."
replaceone drivestyle 2 2 $src-NoUnpaved Car-FastEco-NoUnpaved "Car profile balancing Speed and Cost - Avoiding unpaved ways"
replaceone drivestyle 2 1 $src-NoUnpaved Car-Eco-NoUnpaved "Car profile going for low cost - Avoiding unpaved ways - May be slow."
replacetwo drivestyle 2 3 road_restriction 1 3 $src Car-Fast-NoMinorRoads "Fast profile avoiding unpaved and minor paved roads"
replacetwo drivestyle 2 3 road_restriction 1 3 $src-TollFree Car-Fast-TollFree-NoMinorRoads "Fast tollfree profile avoiding unpaved and minor paved roads"
replacetwo drivestyle 2 3 road_restriction 1 4 $src Car-Fast-TertiaryRoads "Fast long distance profile following tertiary and better roads"
replacetwo drivestyle 2 3 road_restriction 1 4 $src-TollFree Car-Fast-TollFree-TertiaryRoads "Fast tollfree long distance profile following tertiary and better roads"
replacetwo drivestyle 2 3 road_restriction 1 5 $src Car-Fast-SecondaryRoads "Fast long distance profile following secondary and better roads"
replacetwo drivestyle 2 3 road_restriction 1 5 $src-TollFree Car-Fast-TollFree-SecondaryRoads "Fast tollfree long distance profile following secondary and better roads"
replacetwo drivestyle 2 2 road_restriction 1 3 $src Car-FastEco-NoMinorRoads "FastEco profile avoiding unpaved and minor paved roads"
replacetwo drivestyle 2 2 road_restriction 1 3 $src-TollFree Car-FastEco-TollFree-NoMinorRoads "FastEco tollfree profile avoiding unpaved and minor paved roads"
replacetwo drivestyle 2 2 road_restriction 1 4 $src Car-FastEco-TertiaryRoads "FastEco long distance profile following tertiary and better roads"
replacetwo drivestyle 2 2 road_restriction 1 4 $src-TollFree Car-FastEco-TollFree-TertiaryRoads "FastEco tollfree long distance profile following tertiary and better roads"
replacetwo drivestyle 2 2 road_restriction 1 5 $src Car-FastEco-SecondaryRoads "FastEco long distance profile following secondary and better roads"
replacetwo drivestyle 2 2 road_restriction 1 5 $src-TollFree Car-FastEco-TollFree-SecondaryRoads "FastEco tollfree long distance profile following secondary and better roads"
}
fi
} # C A R P R O F I L E S E X E C
# ******************************************************
# H I K I N G P R O F I L E S E X E C
# ******************************************************
function footexec {
replaceone shortest_way 0 1 $src Shortest-P "Shortest way - implemented naviagtion hints."
if [[ ! "$scope" = "locus" ]]; then
replaceone is_wet 0 1 $src $src-wet
replacetwo SAC_scale_limit 3 1 SAC_scale_preferred 1 0 $src-wet Walking-wet "SAC T1 - hiking - Wet variant"
fi
# StrongHikingRoutePreference SHRP
replaceone hiking_routes_preference 0.20 0.60 $src $src-SHRP
# VeryStrongHikingRoutePreference VSHRP
replaceone hiking_routes_preference 0.20 2.00 $src $src-VSHRP
replacetwo SAC_scale_limit 3 1 SAC_scale_preferred 1 0 $src Walking "SAC T1 - hiking - Trail well cleared, Area flat or slightly sloped, no fall hazard"
replacetwo SAC_scale_limit 3 2 SAC_scale_preferred 1 1 $src Hiking-SAC2 "SAC T2 - mountain_hiking - Trail with continuous line and balanced ascent, Terrain partially steep, fall hazard possible, Hiking shoes recommended, Some sure footedness"
replacetwo SAC_scale_limit 3 3 SAC_scale_preferred 1 1 $src Hiking-Mountain-SAC3 "SAC T3 - demanding_mountain_hiking - exposed sites may be secured, possible need of hands for balance, Partly exposed with fall hazard, Well sure-footed, Good hiking shoes, Basic alpine experience "
if [[ "$scope" = "all" || "$scope" = "locus" ]]; then
replacetwo SAC_scale_limit 3 4 SAC_scale_preferred 1 2 $src Hiking-Alpine-SAC4 "SAC T4 - alpine_hiking - sometimes need for hand use, Terrain quite exposed, jagged rocks, Familiarity with exposed terrain, Solid trekking boots, Some ability for terrain assessment, Alpine experience"
replacetwo SAC_scale_limit 3 5 SAC_scale_preferred 1 3 $src Hiking-Alpine-SAC5 "SAC T5 - demanding_alpine_hiking - single plainly climbing up to second grade, Exposed, demanding terrain, jagged rocks, Mountaineering boots, Reliable assessment of terrain, Profound alpine experience, Elementary knowledge of handling with ice axe and rope"
replacetwo SAC_scale_limit 3 6 SAC_scale_preferred 1 4 $src Hiking-Alpine-SAC6 "SAC T6 - difficult_alpine_hiking - climbing up to second grade, Often very exposed, precarious jagged rocks, glacier with danger to slip and fall, Mature alpine experience, Familiarity with the handling of technical alpine equipment"
replacetwo SAC_scale_limit 3 1 SAC_scale_preferred 1 0 $src-SHRP Walking-SAC1-SHRP "SAC T1 - hiking - Trail well cleared, Area flat or slightly sloped, no fall hazard, Strong Hiking Route Preference"
replacetwo SAC_scale_limit 3 2 SAC_scale_preferred 1 1 $src-SHRP Hiking-SAC2-SHRP "SAC T2 - mountain_hiking - Trail with continuous line and balanced ascent, Terrain partially steep, fall hazard possible, Hiking shoes recommended, Some sure footedness, Strong Hiking Route Preference"
replacetwo SAC_scale_limit 3 3 SAC_scale_preferred 1 1 $src-SHRP Hiking-Mountain-SAC3-SHRP "SAC T3 - demanding_mountain_hiking - exposed sites may be secured, possible need of hands for balance, Partly exposed with fall hazard, Well sure-footed, Good hiking shoes, Basic alpine experience, Strong Hiking Route Preference "
replacetwo SAC_scale_limit 3 4 SAC_scale_preferred 1 2 $src-SHRP Hiking-Alpine-SAC4-SHRP "SAC T4 - alpine_hiking - sometimes need for hand use, Terrain quite exposed, jagged rocks, Familiarity with exposed terrain, Solid trekking boots, Some ability for terrain assessment, Alpine experience, Strong Hiking Route Preference"
replacetwo SAC_scale_limit 3 1 SAC_scale_preferred 1 0 $src-VSHRP Walking-SAC1-VSHRP "SAC T1 - hiking - Trail well cleared, Area flat or slightly sloped, no fall hazard, VERY Strong Hiking Route Preference"
replacetwo SAC_scale_limit 3 2 SAC_scale_preferred 1 1 $src-VSHRP Hiking-SAC2-VSHRP "SAC T2 - mountain_hiking - Trail with continuous line and balanced ascent, Terrain partially steep, fall hazard possible, Hiking shoes recommended, Some sure footedness, VERY Strong Hiking Route Preference"
replacetwo SAC_scale_limit 3 3 SAC_scale_preferred 1 1 $src-VSHRP Hiking-Mountain-SAC3-VSHRP "SAC T3 - demanding_mountain_hiking - exposed sites may be secured, possible need of hands for balance, Partly exposed with fall hazard, Well sure-footed, Good hiking shoes, Basic alpine experience, VERY Strong Hiking Route Preference "
fi
if [[ "$scope" = "all" ]]; then
replacetwo SAC_scale_limit 3 1 SAC_scale_preferred 1 0 $src-wet Walking-wet "SAC T1 - hiking - Wet variant"
replacetwo SAC_scale_limit 3 2 SAC_scale_preferred 1 1 $src-wet Hiking-SAC2 "SAC T2 - mountain_hiking - Wet variant"
replacetwo SAC_scale_limit 3 3 SAC_scale_preferred 1 1 $src-wet Hiking-Mountain-SAC3 "SAC T3 - demanding_mountain_hiking - Wet variant"
replacetwo SAC_scale_limit 3 4 SAC_scale_preferred 1 2 $src-wet Hiking-Alpine-SAC4 "SAC T4 - alpine_hiking - Wet variant"
replacetwo SAC_scale_limit 3 5 SAC_scale_preferred 1 3 $src-wet Hiking-Alpine-SAC5 "SAC T5 - demanding_alpine_hiking - Wet variant"
replacetwo SAC_scale_limit 3 6 SAC_scale_preferred 1 4 $src-wet Hiking-Alpine-SAC6 "SAC T6 - difficult_alpine_hiking - Wet variant"
fi
} # H I K I N G P R O F I L E S E X E C
# ******************************************************
# M T B P R O F I L E S E X E C
# ******************************************************
function mtbexec {
replaceone is_wet 0 0 $src mtbzoss
replaceone mtb_hard_factor 0 1 mtbzoss mtbzoss-hard
}
# ******************************************************
# S T R E E T P R O F I L E S E X E C
# ******************************************************
function streetexec {
replaceone iswet false false $src Street-dry
replaceone iswet false true $src Street-wet
}
# ****************************************************
# M A I N E X E C
main "$@"