]> git.openstreetmap.org Git - nominatim.git/blob - data-sources/us-tiger/convert.sh
Merge pull request #1813 from lonvia/revert-concurrent-indexing
[nominatim.git] / data-sources / us-tiger / convert.sh
1 #!/bin/bash
2
3 INPATH=$1
4 OUTPATH=$2
5
6 if [[ ! -d "$INPATH" ]]; then
7     echo "input path does not exist"
8     exit 1
9 fi
10
11 if [[ ! -d "$OUTPATH" ]]; then
12     echo "output path does not exist"
13     exit 1
14 fi
15
16 INREGEX='_([0-9]{5})_edges.zip'
17 WORKPATH="$OUTPATH/tmp-workdir/"
18 mkdir -p "$WORKPATH"
19
20
21
22 INFILES=($INPATH/*.zip)
23 echo "Found ${#INFILES[*]} files."
24
25 for F in ${INFILES[*]}; do
26     # echo $F
27
28     if [[ "$F" =~ $INREGEX ]]; then
29         COUNTYID=${BASH_REMATCH[1]}
30         SHAPEFILE="$WORKPATH/$(basename $F '.zip').shp"
31         SQLFILE="$OUTPATH/$COUNTYID.sql"
32
33         unzip -o -q -d "$WORKPATH" "$F"
34         if [[ ! -e "$SHAPEFILE" ]]; then
35             echo "Unzip failed. $SHAPEFILE not found."
36             exit 1
37         fi
38
39         ./tiger_address_convert.py "$SHAPEFILE" "$SQLFILE"
40
41         rm $WORKPATH/*
42     fi
43 done
44
45 OUTFILES=($OUTPATH/*.sql)
46 echo "Wrote ${#OUTFILES[*]} files."
47
48 rmdir $WORKPATH