2
0
Fork 0

osm-garmin: add Containerfile

This commit is contained in:
Ducky 2023-09-26 02:13:31 +01:00
parent b37cf2742a
commit e52a69735c
5 changed files with 294 additions and 0 deletions

61
osm-garmin/app/utils.sh Normal file
View file

@ -0,0 +1,61 @@
#!/usr/bin/env bash
bounds_dir="/data/build/bounds"
build_dir="/data/build/tmp"
maps_dir="/data/build/osm"
out_dir="/data/maps"
styles_dir="/data/styles"
tiles_dir="/data/build/tiles"
function die() {
echo "Error: $1"
exit 255
}
function check_osm_region_exists() {
region="$1"
exists="true"
curl -ILs --fail "$(get_pbf_url "$region")" 2> /dev/null
[[ $? != 0 ]] && exists="false"
echo $exists
}
function check_osm_update() {
region="$1"
region_path="$maps_dir/$(get_region_shortname "$region").osm.pbf"
update="true"
md5="$(curl -Ls --fail "$(get_pbf_url "$region").md5" | cut -d' ' -f1)"
if [[ $? == 0 ]]; then
if [[ -f "$region_path" ]]; then
if [[ "$(get_md5 "$region_path")" == "$md5" ]]; then
update="false"
fi
fi
fi
echo $update
}
function get_md5() {
file="$1"
echo "$(md5sum "$file" | cut -d' ' -f1)"
}
function get_md5_dir() {
dir="$1"
echo "$(find "$dir" -type f -name "*.*" -exec md5sum {} + | awk '{print $1}' | sort | md5sum)"
}
function get_pbf_url() {
region="$1"
echo "https://download.geofabrik.de/$region-latest.osm.pbf"
}
function get_region_shortname() {
region="$1"
echo "$(echo "$region" | sed "s/\//./g")"
}