From d6b54d55ab4ae368e68dc3c45dac3f88bd854203 Mon Sep 17 00:00:00 2001 From: prokopparuzek Date: Mon, 1 Sep 2025 19:05:52 +0200 Subject: [PATCH] simpler adress parsing --- adressToGPS.sh | 7 ++----- 1 file changed, 2 insertions(+), 5 deletions(-) diff --git a/adressToGPS.sh b/adressToGPS.sh index df4e862..7fe7e8f 100755 --- a/adressToGPS.sh +++ b/adressToGPS.sh @@ -12,11 +12,8 @@ else exit 1 fi -while IFS= read -r LINE; do - NAME=${LINE%%,+([^,]),+([^,]),+([^,])} - ADDRESS=${LINE##+([^,]),} - # filter out PSČ - ADDRESS=${ADDRESS%%,+([^,])} +while IFS=, read -r NAME A1 A2 _; do + ADDRESS="${A1}, ${A2}" GPS=$(curl --get --data-urlencode "query=${ADDRESS}" "https://api.mapy.cz/v1/geocode?lang=cs&limit=1&type=coordinate&apikey=${KEY}" -H 'accept: application/json' \ | jq -cM .items[0].position | sed -E 's/^.*:([[:digit:].]+).+:([[:digit:].]+).*$/\1,\2/' )