-
Notifications
You must be signed in to change notification settings - Fork 0
/
runde
executable file
·193 lines (169 loc) · 5.48 KB
/
runde
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
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
#!/bin/bash
if [ ! $# -eq 1 ]; then
echo Usage: ./runde option
echo ""
echo Options:
echo " 1: run for BB, NI, BY, RP, TH, HH"
echo " 2: run for HB, SL, MV, SH, ST, SN, BW"
echo " 3: run for NW, HE"
echo " c: combine all results"
echo " d: delete pbf and osm files"
exit -1;
fi
function run {
echo ------------------
echo run for $1
echo ------------------
ai="" # assume city
if [ $# -eq 2 ]; then
ai="-ai="$2
fi
mkdir $1
cd $1
mv index.html index.html~
wget http://download.geofabrik.de/openstreetmap/europe/germany/ -O index.html
d=`cat index.html | grep $1.osm.pbf | sed -e "s/\`date +%Y\`.*//g" | sed -e "s/.*>//g" | grep -v \`date +%d\` | wc -l`
cdate=`stat -c %y dupes.txt | awk '{ printf $1 "\n"}'`
if [ $cdate == `date +%Y-%m-%d` ]; then
echo $(tput setaf 3)\!\!\!\!\!\!\!\!\!\!\!\!\!\!\!\!\!\!
echo Already run? Aborting $1...
echo \!\!\!\!\!\!\!\!\!\!\!\!\!\!\!\!\!\!$(tput sgr0)
elif [ ! $d == 0 ]; then
echo $(tput setaf 1)\!\!\!\!\!\!\!\!\!\!\!\!\!\!\!\!\!\!
echo $1.osm.pbf seems to be too old. Aborting $1...
echo \!\!\!\!\!\!\!\!\!\!\!\!\!\!\!\!\!\!$(tput sgr0)
else
rm $1.*
cp ../filter .
cp ../housenumbervalidator .
wget http://download.geofabrik.de/openstreetmap/europe/germany/$1.osm.pbf
if [ ! $? -eq 0 ]; then
echo $(tput bold)$(tput setaf 1)download problem$(tput sgr0)
exit 1;
fi
nice -n 19 ./filter $1.osm.pbf
if [ ! $? -eq 0 ]; then
echo $(tput bold)$(tput setaf 1)filter problem$(tput sgr0)
exit 3;
fi
nice -n 19 ./housenumbervalidator $1.osm.pbf.hnr.osm -l -l=`wc -l $1.osm.pbf.hnr.osm | awk '{ printf $1 "\n"}'` -ac=DE -cpn -css -cpc=5 $ai
if [ ! $? -eq 0 ]; then
echo $(tput bold)$(tput setaf 1)housenumbervalidator problem $1 $(tput sgr0)
exit 4;
fi
# grep incomplete.txt -v --file=html/reports.txt | grep -v "missing 1" | grep -v "missing 2" | grep -v "missing 3" | head -n 2001 | sed "s/pin.png/pin_circle.png/g" > incompl.txt
# mv incomplete.txt incomplete.txt~
# mv incompl.txt incomplete.txt
# cat incomplete.txt | wc -l
echo $(tput setaf 2)------------------
echo Finished $1!
echo ------------------$(tput sgr0)
fi
cd ..
}
function getreports {
mv html/reports.txt html/reports.txt~
wget http://gulp21.bplaced.net/osm/housenumbervalidator/reports.txt
mv reports.txt html/reports.txt
cp html/reports.txt de/
echo `cat html/reports.txt | wc -l` exceptions [$((`cat html/reports.txt | wc -l`-`cat html/reports.txt~ | wc -l`))]
}
function lands1 {
d1=`date`
run brandenburg && run niedersachsen && run bayern && run rheinland-pfalz && run thueringen && echo finished lands1 $d1 - `date`
}
function lands2 {
d2=`date`
run bremen Bremen && run saarland && run berlin Berlin && run mecklenburg-vorpommern && run schleswig-holstein && run sachsen-anhalt && run sachsen && run baden-wuerttemberg && echo finished lands2 $d2 - `date`
}
function lands3 {
d3=`date`
run nordrhein-westfalen && run hessen && run hamburg Hamburg && echo finished lands3 $d3 - `date`
}
function combine {
mkdir de
cd de
rm dupes.txt
rm broken.txt
rm log.txt
path=`echo ~/Dokumente/GitHub/housenumbervalidator`
for land in "baden-wuerttemberg" "bayern" "berlin" "brandenburg" "bremen" "hamburg" "hessen" "nordrhein-westfalen" "mecklenburg-vorpommern" "niedersachsen" "rheinland-pfalz" "saarland" "sachsen" "sachsen-anhalt" "schleswig-holstein" "thueringen" "austria"
do
echo $land...
if [ ! $land == "austria" ]; then
tail $path/$land/dupes.txt -n +2 >> dupes.txt
tail $path/$land/broken.txt -n +2 >> broken.txt
fi
echo $land >> log.txt
cat $path/$land/log.txt >> log.txt
echo "" >> log.txt
done
grep -v -P "\tBE\t|\tDK\t|\tFR\t|\tLU\t|\tNL\t|\tCH\t|\tAT\t|\tPL\t|\tCZ\t" broken.txt | grep -v --file=$path/html/reports.txt > brok
echo $((`cat broken.txt | wc -l`-`cat brok | wc -l`)) foreign lines removed
mv brok broken.txt
grep dupes.txt -v --file=$path/html/reports.txt > dupes
mv dupes dupes.txt
echo Dupes:
wc -l dupes.txt
echo Broken:
wc -l broken.txt
echo Merging with austria...
tail $path/austria/dupes.txt -n +2 >> dupes.txt
tail $path/austria/broken.txt -n +2 >> broken.txt
cat dupes.txt | sort | uniq > d~
mv d~ dupes.txt
cat broken.txt | sort | uniq > b~
mv b~ broken.txt
}
function delete {
for land in "baden-wuerttemberg" "bayern" "berlin" "brandenburg" "bremen" "hamburg" "hessen" "nordrhein-westfalen" "mecklenburg-vorpommern" "niedersachsen" "rheinland-pfalz" "saarland" "sachsen" "sachsen-anhalt" "schleswig-holstein" "thueringen" "austria"
do
echo rm $land/$land.osm.pbf
rm $land/$land.osm.pbf
echo rm $land/$land.osm.pbf.hnr.osm
rm $land/$land.osm.pbf.hnr.osm
# echo rm $land/dupes.txt
# rm $land/dupes.txt
done
}
function delete_dupes {
echo Sure? [y]
read SURE
if [ "$SURE"=="y" ]; then
for land in "baden-wuerttemberg" "bayern" "berlin" "brandenburg" "bremen" "hamburg" "hessen" "nordrhein-westfalen" "mecklenburg-vorpommern" "niedersachsen" "rheinland-pfalz" "saarland" "sachsen" "sachsen-anhalt" "schleswig-holstein" "thueringen" "austria"
do
echo rm $land/dupes.txt
rm $land/dupes.txt
done
fi
}
if [ $1 == "c" ]; then
getreports
combine
elif [ $1 == "d" ]; then
delete
elif [ $1 == "dd" ]; then
delete_dupes
elif [ $1 == "convenience1" ]; then
./runaustria
./runde 1
./runde 2
./runde 3
elif [ $1 == "convenience2" ]; then
gnumeric stat.gnumeric &
./runde d
./runde c
cd de
cat log.txt
git diff | kompare -
git commit -a
cd ..
elif [ $1 -eq 1 ]; then
lands1
elif [ $1 -eq 2 ]; then
lands2
elif [ $1 -eq 3 ]; then
lands3
else
run $1
fi