# ---------------------------------------------------------------------- # FormatHeaderRecursively proc FormatHeaderRecursively {filePath filePath1} { upvar var var upvar headerLines headerLines1 upvar 2 contentType contentType # upvar 2 filePath1 filePath1 # set filePath1 [file rootname $filePath](formatted_header)[file extension $filePath] if [file exists $filePath1] { Store var $filePath1 auto 1 a } else { set headerLines2 {} lappend contentType {} lappend contentType {Original header:} lappend contentType [join $headerLines1 \n] foreach line $headerLines1 { foreach {name value} $line {break} if [string equal -nocase xllcorner $name] {lappend headerLines2 [regsub -- $value $line [format %.6f $value]]; continue} if [string equal -nocase yllcorner $name] {lappend headerLines2 [regsub -- $value $line [format %.6f $value]]; continue} if [string equal -nocase dx $name] {lappend headerLines2 [regsub $value $line [format %.6f $value]]; continue} if [string equal -nocase dy $name] {lappend headerLines2 [regsub $value $line [format %.6f $value]]; continue} # if [string equal -nocase dx $name] { # lappend header2 [list cellsize [format %.6f $value]] # continue # } # if [string equal -nocase dy $name] {continue} if [string equal -nocase cellsize $name] {lappend headerLines2 [regsub $value $line [format %.6f $value]]; continue} lappend headerLines2 $line } if [string equal $headerLines1 $headerLines2] {return 1} ;# nothing done set header [join $headerLines2 \n] lappend contentType {} lappend contentType {New header:} lappend contentType $header Store header $filePath1 auto 1 Store var $filePath1 auto 1 a } return 0 } # FormatHeaderRecursively - end # ---------------------------------------------------------------------- # FormatHeader proc FormatHeader {filePath resultRepository} { set argv 0 set initial [clock milliseconds] set filePath0 ../../../../../$resultRepository/doc/[file rootname [file tail $filePath]](header).txt file delete $filePath0 set filePath1 ../../../../../$resultRepository/doc/[file rootname [file tail $filePath]](formatted_header).txt file delete $filePath1 set contentType {} lappend contentType "date = [clock format [clock seconds] -format %Y-%m-%d]" lappend contentType "localtime = [clock format [clock seconds] -format %H:%M:%S]" lappend contentType "file path = $filePath" lappend contentType "action = FormatHeaderRecursively" source ../../../../../urlib.net/www/2021/07.02.22.22/doc/GetSizeRecursively.tcl set action "FormatHeaderRecursively $filePath $filePath1" ProcessRecursively $filePath $action set final [clock milliseconds] lappend contentType {} lappend contentType [DisplayProcessingTime [expr $final - $initial]] if ![file exists $filePath1] { lappend contentType "$filePath has the correct header" } set contentType [join $contentType \n] puts $contentType Store contentType $filePath0 } # FormatHeader - end # ---------------------------------------------------------------------- if $argv { # usage examples console show source ../../../../../dpi.inpe.br/banon/1998/08.02.08.56/doc/utilities1.tcl ;# Store and StoreArray set imageDirectory ../../../../../urlib.net/www/2021/07.14.21.56/doc set resultRepository urlib.net/www/2021/07.14.21.56 set switchNumber 9 switch $switchNumber 1 { set filePath $imageDirectory/arquivo_masc-Teste_.txt ;# data } 2 { set filePath $imageDirectory/_masc_distCanaArAbertaAgua_MB2016F5x5_GRR.txt } 3 { set filePath $imageDirectory/MCP_masc-dist-agua-aberta-cana_GRR.txt ;# 14 s } 4 { set filePath $imageDirectory/SP_masc-dist-agua-aberta-cana_GRR.txt ;# 1 mn and 59 s - 731581396 } 5 { set filePath $imageDirectory/MCP_mascara-distancia-presenca-agua-area-aberta-cana-F5x5_32723.asc } 6 { set filePath $imageDirectory/MPO_mascara-distancia-presenca-agua-area-aberta-cana-F5x5_32723.asc } 7 { set filePath $imageDirectory/MPO_mascara25-uniao-hidrografia-area-aberta-MapBiomas_32723.asc ;# processing time = 15 s; image size = 90600705 } 8 { set filePath $imageDirectory/MCP_mascara-porcentagem-formacao-florestal-F7x7_32723.asc } 9 { set filePath $imageDirectory/MPO_mascara25-uniao-hidrografia-area-aberta-MapBiomas_32723(cell_turned_square).asc } FormatHeader $filePath $resultRepository } # Previous textual results if 0 { }