forked from foursquare/twofishes
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathdownload-country.sh
executable file
·47 lines (38 loc) · 1 KB
/
download-country.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
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
#!/bin/bash
if [ "$1" = "" ]; then
echo "usage: $0 <2-letter-country-code>"
echo "ex: $0 US"
echo "ex: $0 JP"
exit 1
fi
unzip -v >/dev/null 2>&1 || { echo >&2 "I require 'unzip' but it's not installed. Aborting."; exit 1; }
curl -h >/dev/null 2>&1 || { echo >&2 "I require 'curl' but it's not installed. Aborting."; exit 1; }
COUNTRY=$1
set -x
mkdir -p data/downloaded/
mkdir -p data/downloaded/zip/
FILE=data/downloaded/$COUNTRY.txt
if [ -f $FILE ];
then
echo "File $FILE exists."
else
curl -o $FILE.zip http://download.geonames.org/export/dump/$COUNTRY.zip
unzip $FILE.zip
mv $COUNTRY.txt $FILE
rm readme.txt
rm $FILE.zip
fi
FILE=data/downloaded/zip/$COUNTRY.txt
if [ -f $FILE ];
then
echo "File $FILE exists."
else
curl -o $FILE.zip http://download.geonames.org/export/zip/$COUNTRY.zip
unzip $FILE.zip
mv $COUNTRY.txt $FILE
rm readme.txt
rm $FILE.zip
fi
source scripts/download-common.sh
./scripts/extract-wiki-buildings.py $COUNTRY
./scripts/extract-adm.py $COUNTRY