-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathgeocode-single.sh
executable file
·27 lines (22 loc) · 1.07 KB
/
geocode-single.sh
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
#! /bin/bash
LINE=$1
NAME=$(echo $LINE | csvcut -c 1)
ADDR1=$(echo $LINE | csvcut -c 1)
ADDR2=$(echo $LINE | csvcut -c 2)
ADDR3=$(echo $LINE | csvcut -c 3)
ADDR4=$(echo $LINE | csvcut -c 4)
RESULT=$(curl -s "http://nominatim.openstreetmap.ie/search/?q=$(urlencode $NAME $ADDR1 $ADDR2 $ADDR3 $ADDR4)&format=json&limit=1")
if [[ "${RESULT}" == "[]" ]] ; then
RESULT=$(curl -s "http://nominatim.openstreetmap.ie/search/?q=$(urlencode $ADDR1 $ADDR2 $ADDR3 $ADDR4)&format=json&limit=1")
fi
if [[ "${RESULT}" == "[]" ]] ; then
RESULT=$(curl -s "http://nominatim.openstreetmap.ie/search/?q=$(urlencode $ADDR2 $ADDR3 $ADDR4)&format=json&limit=1")
fi
if [[ "${RESULT}" == "[]" ]] ; then
RESULT=$(curl -s "http://nominatim.openstreetmap.ie/search/?q=$(urlencode $ADDR3 $ADDR4)&format=json&limit=1")
fi
if [[ "${RESULT}" == "[]" ]] ; then
RESULT=$(curl -s "http://nominatim.openstreetmap.ie/search/?q=$(urlencode $ADDR4)&format=json&limit=1")
fi
RESULT=$(echo $RESULT | jq -r '[.[0].boundingbox | .[] | tonumber] | @csv')
echo "${NAME},${ADDR1},${ADDR2},${ADDR3},${ADDR4},${RESULT}"