Skip to content

Commit

Permalink
fix(config): Adjust the conversion script (#1660)
Browse files Browse the repository at this point in the history
  • Loading branch information
MichaelsJP authored Jan 30, 2024
2 parents 0d32a10 + 88ffd34 commit 1598346
Show file tree
Hide file tree
Showing 2 changed files with 28 additions and 12 deletions.
38 changes: 27 additions & 11 deletions .github/utils/config_conversion.sh
Original file line number Diff line number Diff line change
Expand Up @@ -7,21 +7,37 @@ fi

input_file=$1
output_file=$2
ors_file="ors-api/src/test/files/heidelberg.osm.gz"

###########################
### Validate input file ###
###########################
# Fail if ors: can't be found
echo "Checking for ors section"
awk '/^ors:/{print "Found ors section"}' "$input_file" || exit 1

# For engine and source file section, make sure they are in place
echo "Checking for engine and source_file section"
awk '/ engine:/{getline; if ($0 ~ /source_file:/) {print "Found engine and source_file section"} else { exit 1 }}' "$input_file" || exit 1

# For profiles section for car wit enabled
echo "Checking for profiles section"
awk '/ profiles:/{getline; if ($0 ~ / car:/) {getline; if ($0 ~ / enabled:/) {print "Found profiles section"} else { exit 1 }}}' "$input_file" || exit 1

###########################
### Convert input file ####
###########################
# Add # to the beginning of each line that is not empty or a comment
awk '!/^[[:space:]]*#/ && !/^[[:space:]]*$/ {print "#" $0; next} {print}' "$input_file" > "$output_file"

# Replace '#ors:' with 'ors:'
sed -i 's/#ors:/ors:/g' "$output_file"
# Replace '# engine:' with ' engine:'
sed -i 's/# engine:/ engine:/g' "$output_file"
# Replace '# source_file:' with ' source_file: ors-api/src/test/files/heidelberg.osm.gz'
sed -i 's/# source_file:/ source_file: ors-api\/src\/test\/files\/heidelberg.osm.gz/g' "$output_file"
# Replace '# profiles:' with ' profiles:'
sed -i 's/# profiles:/ profiles:/g' "$output_file"

# Replace the individual profiles. Ignore the value of enabled and always set to false.
for profile in car ; do
awk -i inplace "/# $profile:/{getline; if (\$0 ~ /# enabled:/) {print \" $profile:\"; print \" enabled: true\"; next}} {print}" "$output_file"
done


# Remove the comments for the engine and source_file section
awk -i inplace "/engine:/{getline; if (\$0 ~ /source_file:/) {print \" engine:\"; print \" source_file: '$ors_file'\"; next} else { exit1 }} {print}" "$output_file"

# Remove the comments for the profiles section for car
awk -i inplace "/# profiles:/{getline; if (\$0 ~ /# car:/) {getline; if (\$0 ~ /# enabled:/) {print \" profiles:\"; print \" car:\"; print \" enabled: true\"; next}}}{print}" "$output_file"

echo "Parsing complete. Result saved to $output_file"
2 changes: 1 addition & 1 deletion ors-api/src/main/resources/application.yml
Original file line number Diff line number Diff line change
Expand Up @@ -101,9 +101,9 @@ ors:

##### ORS engine settings #####
engine:
source_file:
init_threads: 1
preparation_mode: false
source_file:
graphs_root_path: ./graphs
graphs_data_access: RAM_STORE
elevation:
Expand Down

0 comments on commit 1598346

Please sign in to comment.