summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--src/makecolumns.sh35
1 files changed, 26 insertions, 9 deletions
diff --git a/src/makecolumns.sh b/src/makecolumns.sh
index 1d19ada..5ee4f4a 100644
--- a/src/makecolumns.sh
+++ b/src/makecolumns.sh
@@ -162,17 +162,23 @@ handle_old_format() {
162} 162}
163 163
164handle_new_format() { 164handle_new_format() {
165 echo "Working on $1. Detected post-2003 Telefonbuch version."
166 printf "Extracting street names ... "
165 ../bin/decompress $1/streets.tl 167 ../bin/decompress $1/streets.tl
166 168
167 cat file_* > streets 169 cat file_* | tr '\n\0' '\t\n' > 99_Strassenname
168 rm file_* 170 rm file_*
171 printf "done.\n"
169 172
170 ../bin/decompress $1/phonebook.db 173 printf "Extracting phonebook.db ... "
174 ../bin/decompress $1/phonebook.db | grep -v appropriate
171 175
172 numfiles=`find . -name file_\* | wc -l` 176 numfiles=`find . -name file_\* | wc -l`
177 printf "done.\nFound %d entries.\n" $numfiles
173 178
179 printf "Splitting decompressed chunks into their columns ... "
174 for column in `jot - 0 10 1`; do 180 for column in `jot - 0 10 1`; do
175 for file in `jot - ${column} ${numfiles} 11`; do 181 for file in `jot - ${column} $(( numfiles - 1 )) 11`; do
176 acton=`printf file_%05X ${file}` 182 acton=`printf file_%05X ${file}`
177 if [ ${column} = 0 ]; then 183 if [ ${column} = 0 ]; then
178 xxd -ps -c1 ${acton} >> column_0; 184 xxd -ps -c1 ${acton} >> column_0;
@@ -181,7 +187,11 @@ handle_new_format() {
181 fi 187 fi
182 done; 188 done;
183 done 189 done
190 printf "done.\n"
191
192 printf "Cleaning up decompressed chunks ... "
184 find . -name file_\* -delete 193 find . -name file_\* -delete
194 printf "done.\n"
185 195
186 mv column_0 01_Flags 196 mv column_0 01_Flags
187 mv column_1 02_Nachname 197 mv column_1 02_Nachname
@@ -195,23 +205,30 @@ handle_new_format() {
195 mv column_9 13_Rufnummer 205 mv column_9 13_Rufnummer
196 mv column_10 14_15_Email_Webadresse 206 mv column_10 14_15_Email_Webadresse
197 207
198 [ -e streets ] && tr '\n\0' '\t\n' < streets > 99_Strassenname && rm streets 208 printf "Looing up street names from indexes ... "
209 cut -f 1 07_08_Strassenindex_Hausnummer | ${EL} -0 99_Strassenname > 07_Strasse
210 printf "done.\n"
199 211
200 if [ -e 99_Strassenname ]; then 212 printf "Splitting house numbers ... "
201 cut -f 1 07_08_Strassenindex_Hausnummer | ${EL} -0 99_Strassenname > 07_Strasse
202 else
203 echo Could not convert streetindexes
204 fi
205 sed -E $'s:$:\t:' < 07_08_Strassenindex_Hausnummer | cut -f 2 > 08_Hausnummer 213 sed -E $'s:$:\t:' < 07_08_Strassenindex_Hausnummer | cut -f 2 > 08_Hausnummer
214 printf "done.\n"
206 215
207 if [ -f $1/zip-streets-hn-geo.tl ]; then 216 if [ -f $1/zip-streets-hn-geo.tl ]; then
217 printf "Extracting geo coordinates (precision: house number) ... "
208 ../bin/decompress $1/zip-streets-hn-geo.tl 218 ../bin/decompress $1/zip-streets-hn-geo.tl
209 cat file_* > 90_Geokoordinaten_hnr 219 cat file_* > 90_Geokoordinaten_hnr
220 printf "done.\n"
221 printf "Looking up geo coordinates for each phonebook entry ... "
210 lam 10_Postleitzahl -s $'\t' 07_Strasse -s $'\t' 08_Hausnummer | ../bin/mapcoords 90_Geokoordinaten_hnr > 16_Koordinaten 222 lam 10_Postleitzahl -s $'\t' 07_Strasse -s $'\t' 08_Hausnummer | ../bin/mapcoords 90_Geokoordinaten_hnr > 16_Koordinaten
223 printf "done.\n"
211 elif [ -f $1/zip-streets-geo.tl ]; then 224 elif [ -f $1/zip-streets-geo.tl ]; then
225 printf "Extracting geo coordinates (precision: street) ... "
212 ../bin/decompress $1/zip-streets-geo.tl 226 ../bin/decompress $1/zip-streets-geo.tl
213 cat file_* > 91_Geokoordinaten_str 227 cat file_* > 91_Geokoordinaten_str
228 printf "done.\n"
229 printf "Looking up geo coordinates for each phonebook entry ... "
214 lam 10_Postleitzahl -s $'\t' 07_Strasse | ../bin/mapcoords 91_Geokoordinaten_str > 16_Koordinaten 230 lam 10_Postleitzahl -s $'\t' 07_Strasse | ../bin/mapcoords 91_Geokoordinaten_str > 16_Koordinaten
231 printf "done.\n"
215 fi 232 fi
216 rm file_* 233 rm file_*
217} 234}