summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rwxr-xr-xsrc/makecolumns.sh37
1 files changed, 20 insertions, 17 deletions
diff --git a/src/makecolumns.sh b/src/makecolumns.sh
index 95c9d08..4ed1f86 100755
--- a/src/makecolumns.sh
+++ b/src/makecolumns.sh
@@ -22,6 +22,9 @@ main() {
22 # Compile all the binaries 22 # Compile all the binaries
23 make all 23 make all
24 24
25 printf "Cleaning up old working directory ... "
26 rm -rf ../work_`basename ${1#white_}`
27 printf "done.\n"
25 mkdir -p ../work_`basename ${1#white_}` 28 mkdir -p ../work_`basename ${1#white_}`
26 cd ../work_`basename ${1#white_}` || exit 1 29 cd ../work_`basename ${1#white_}` || exit 1
27 30
@@ -45,14 +48,18 @@ get_dword() {
45 48
46do_decompress_old() { 49do_decompress_old() {
47 printf "Extracting $2 chunks ... " 50 printf "Extracting $2 chunks ... "
48 extractblocks "${1}" | grep -v appropriate 51 extractblocks "${1}"
49 printf "done.\n" 52 printf "done.\n"
50 53
51 printf "Decompressing $2 chunks ... " 54 printf "Decompressing $2 chunks ... "
55 number_of_files=`find . -name \*.lha | wc -l`
56 reported=0; processed=0
52 for archive in *.lha; do 57 for archive in *.lha; do
53 lha x ${archive} > /dev/null 58 lha x ${archive} > /dev/null
54 rm ${archive} 59 rm ${archive}
60 [ 1 -eq $(( ( processed++ * 20 ) / number_of_files > reported )) ] && printf "%d%% " $(( ++reported * 5 ))
55 done 61 done
62 [ $reported -lt 10 ] && printf "100% "
56 printf "done.\n" 63 printf "done.\n"
57} 64}
58 65
@@ -74,24 +81,15 @@ do_processfile_old() {
74} 81}
75 82
76handle_old_format() { 83handle_old_format() {
77 # Clear old files. Be very careful, we could 84 # Extract teiln.dat
78 # have ended up in an unexpected directory, after all. 85 do_decompress_old $1/[Dd][Aa][Tt]/[Tt][Ee][Ii][Ll][Nn].[Dd][Aa][Tt] "teiln.dat"
79 printf "Cleaning up old temporary files ... "
80 find -E . -depth 1 -regex '^\./[0123456789]+' -delete
81 rm -rf ??_* coords strassen
82 printf "done.\n"
83
84 # If street names come in an extra file, extract
85 # street names first
86 streets=$1/[Dd][Aa][Tt]/[Ss][Tt][Rr][Aa][Ss][Ss][Ee][Nn].[Dd][Aa][Tt]
87 [ -f ${streets} ] && do_processfile_old "${streets}" "street name" 99_Strassenname convert_zeros
88
89 # Then extract teiln.dat
90 do_decompress_old $1/[Dd][Aa][Tt]/[Tt][Ee][Ii][Ll][Nn].[Dd][Aa][Tt] "teiln.dat"
91 86
92 # See how long each filename is 87 # See how long each filename is
93 filename_len=$(( `ls | head -n 1 | wc -c` - 1 )) 88 filename_len=$(( `ls | head -n 1 | wc -c` - 1 ))
94 89
90 # Get total amount of files, for reporting progress
91 number_of_files=`find -E . -depth 1 -regex '^\./[0123456789]+' | wc -l`
92
95 # from 2000F on file 0+3*n is table, so make it default 93 # from 2000F on file 0+3*n is table, so make it default
96 table_file=`printf %0${filename_len}d 0` 94 table_file=`printf %0${filename_len}d 0`
97 vname_file=`printf %0${filename_len}d 2` 95 vname_file=`printf %0${filename_len}d 2`
@@ -115,6 +113,7 @@ handle_old_format() {
115 113
116 # Now loop over all files and dump them 114 # Now loop over all files and dump them
117 printf "Splitting decompressed chunks into their columns ... " 115 printf "Splitting decompressed chunks into their columns ... "
116 reported=0
118 while [ -f ${nname_file} ]; do 117 while [ -f ${nname_file} ]; do
119 # Get number of entries in this round 118 # Get number of entries in this round
120 count=`get_dword ${nname_file}` 119 count=`get_dword ${nname_file}`
@@ -146,8 +145,8 @@ handle_old_format() {
146 vname_file=`printf "%s + 3\n" ${vname_file} | bc` 145 vname_file=`printf "%s + 3\n" ${vname_file} | bc`
147 vname_file=`printf %0${filename_len}d ${vname_file}` 146 vname_file=`printf %0${filename_len}d ${vname_file}`
148 table_file=`printf "%s + 3\n" ${table_file} | bc` 147 table_file=`printf "%s + 3\n" ${table_file} | bc`
148 [ 1 -eq $(( ( table_file * 20 ) / number_of_files > reported )) ] && printf "%d%% " $(( ++reported * 5 ))
149 table_file=`printf %0${filename_len}d ${table_file}` 149 table_file=`printf %0${filename_len}d ${table_file}`
150
151 done 150 done
152 printf "done.\n" 151 printf "done.\n"
153 152
@@ -169,6 +168,11 @@ handle_old_format() {
169 [ -f 14_unknown ] && mv 14_unknown 14_Email 168 [ -f 14_unknown ] && mv 14_unknown 14_Email
170 [ -f 15_unknown ] && mv 15_unknown 15_Webadresse 169 [ -f 15_unknown ] && mv 15_unknown 15_Webadresse
171 170
171 # If street names come in an extra file, extract
172 # street names first
173 streets=$1/[Dd][Aa][Tt]/[Ss][Tt][Rr][Aa][Ss][Ss][Ee][Nn].[Dd][Aa][Tt]
174 [ -f ${streets} ] && do_processfile_old "${streets}" "street name" 99_Strassenname convert_zeros
175
172 # extract street names if 07_unknown contains street indexes 176 # extract street names if 07_unknown contains street indexes
173 # instead of street names 177 # instead of street names
174 if [ -f 99_Strassenname ]; then 178 if [ -f 99_Strassenname ]; then
@@ -181,7 +185,6 @@ handle_old_format() {
181 fi 185 fi
182 186
183 karto=$1/[Dd][Aa][Tt]/[Kk][Aa][Rr][Tt][Oo].[Dd][Aa][Tt] 187 karto=$1/[Dd][Aa][Tt]/[Kk][Aa][Rr][Tt][Oo].[Dd][Aa][Tt]
184 printf "%s\n" $karto
185 [ -f ${karto} ] && do_processfile_old ${karto} "geo coordinates" 90_Geokoordinaten_hnr 188 [ -f ${karto} ] && do_processfile_old ${karto} "geo coordinates" 90_Geokoordinaten_hnr
186} 189}
187 190