bin: add osm tools

This commit is contained in:
xeruf 2022-10-13 21:55:59 +02:00
parent 8949048286
commit 80626489e2
2 changed files with 32 additions and 0 deletions

8
.local/bin/scripts/geocode Executable file
View File

@ -0,0 +1,8 @@
#!/bin/sh -e
endpoint='https://photon.komoot.io'
lsof -i :2322 >/dev/null && endpoint='http://localhost:2322'
location=$(echo "$@" | sed 's| |%20|g')
echo "Geocoding $location" >&2
curl "$endpoint/api/?q=$location&lang=de&limit=1" | jq
# Germany: &bbox=5.98865807458,47.3024876979,15.0169958839,54.983104153

24
.local/bin/scripts/osmjson Executable file
View File

@ -0,0 +1,24 @@
#!/bin/sh -ex
filebase="${1%%.*}"
file_orig="$1"
#case "$1" in
# (*.o5m) file_o5m="$1";;
# (*) file_o5m="$filebase.o5m"
# test -f "$file_o5m" || osmconvert --verbose --drop-relations "$1" -o="$file_o5m";;
#esac
shift
if ! expr "$1" : "-" >/dev/null
then filebase="$filebase-$1"
test $# -gt 1 && shift
fi
file_osm="$filebase.osm"
#osmfilter --verbose "$file_o5m" "$@" >"$file_osm"
#osmium tags-filter --verbose --omit-referenced "$file_orig" -o "$file_osm" "$@"
file_json="$filebase.geojson"
#node --max_old_space_size=$(free | awk 'NR == 2 {print $7}' | rev | cut -c4- | rev) "$(which osmtogeojson)" -n -v "$file_osm" >"$file_json"
osmium export --verbose --geometry-types=point "$file_osm" -o "$file_json" --overwrite
echo "Output saved to $file_json!" >&2