From a62a0a5a509cfaea35740a79dc473da9d0f69c8d Mon Sep 17 00:00:00 2001 From: Dirk Engling Date: Fri, 7 Feb 2014 20:29:31 +0100 Subject: Report progress Remove debug output Wipe whole working directory clean --- src/makecolumns.sh | 37 ++++++++++++++++++++----------------- 1 file 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() { # Compile all the binaries make all + printf "Cleaning up old working directory ... " + rm -rf ../work_`basename ${1#white_}` + printf "done.\n" mkdir -p ../work_`basename ${1#white_}` cd ../work_`basename ${1#white_}` || exit 1 @@ -45,14 +48,18 @@ get_dword() { do_decompress_old() { printf "Extracting $2 chunks ... " - extractblocks "${1}" | grep -v appropriate + extractblocks "${1}" printf "done.\n" printf "Decompressing $2 chunks ... " + number_of_files=`find . -name \*.lha | wc -l` + reported=0; processed=0 for archive in *.lha; do lha x ${archive} > /dev/null rm ${archive} + [ 1 -eq $(( ( processed++ * 20 ) / number_of_files > reported )) ] && printf "%d%% " $(( ++reported * 5 )) done + [ $reported -lt 10 ] && printf "100% " printf "done.\n" } @@ -74,24 +81,15 @@ do_processfile_old() { } handle_old_format() { - # Clear old files. Be very careful, we could - # have ended up in an unexpected directory, after all. - printf "Cleaning up old temporary files ... " - find -E . -depth 1 -regex '^\./[0123456789]+' -delete - rm -rf ??_* coords strassen - printf "done.\n" - - # If street names come in an extra file, extract - # street names first - streets=$1/[Dd][Aa][Tt]/[Ss][Tt][Rr][Aa][Ss][Ss][Ee][Nn].[Dd][Aa][Tt] - [ -f ${streets} ] && do_processfile_old "${streets}" "street name" 99_Strassenname convert_zeros - - # Then extract teiln.dat - do_decompress_old $1/[Dd][Aa][Tt]/[Tt][Ee][Ii][Ll][Nn].[Dd][Aa][Tt] "teiln.dat" + # Extract teiln.dat + do_decompress_old $1/[Dd][Aa][Tt]/[Tt][Ee][Ii][Ll][Nn].[Dd][Aa][Tt] "teiln.dat" # See how long each filename is filename_len=$(( `ls | head -n 1 | wc -c` - 1 )) + # Get total amount of files, for reporting progress + number_of_files=`find -E . -depth 1 -regex '^\./[0123456789]+' | wc -l` + # from 2000F on file 0+3*n is table, so make it default table_file=`printf %0${filename_len}d 0` vname_file=`printf %0${filename_len}d 2` @@ -115,6 +113,7 @@ handle_old_format() { # Now loop over all files and dump them printf "Splitting decompressed chunks into their columns ... " + reported=0 while [ -f ${nname_file} ]; do # Get number of entries in this round count=`get_dword ${nname_file}` @@ -146,8 +145,8 @@ handle_old_format() { vname_file=`printf "%s + 3\n" ${vname_file} | bc` vname_file=`printf %0${filename_len}d ${vname_file}` table_file=`printf "%s + 3\n" ${table_file} | bc` + [ 1 -eq $(( ( table_file * 20 ) / number_of_files > reported )) ] && printf "%d%% " $(( ++reported * 5 )) table_file=`printf %0${filename_len}d ${table_file}` - done printf "done.\n" @@ -169,6 +168,11 @@ handle_old_format() { [ -f 14_unknown ] && mv 14_unknown 14_Email [ -f 15_unknown ] && mv 15_unknown 15_Webadresse + # If street names come in an extra file, extract + # street names first + streets=$1/[Dd][Aa][Tt]/[Ss][Tt][Rr][Aa][Ss][Ss][Ee][Nn].[Dd][Aa][Tt] + [ -f ${streets} ] && do_processfile_old "${streets}" "street name" 99_Strassenname convert_zeros + # extract street names if 07_unknown contains street indexes # instead of street names if [ -f 99_Strassenname ]; then @@ -181,7 +185,6 @@ handle_old_format() { fi karto=$1/[Dd][Aa][Tt]/[Kk][Aa][Rr][Tt][Oo].[Dd][Aa][Tt] - printf "%s\n" $karto [ -f ${karto} ] && do_processfile_old ${karto} "geo coordinates" 90_Geokoordinaten_hnr } -- cgit v1.2.3