# ---------------------------------------------------------------------- # ShortenLine (5) proc ShortenLine {newLineSize filePath1} { upvar currentLine currentLine # upvar lineSize lineSize upvar lineCounter lineCounter set processedLine [lrange $currentLine 0 [expr $newLineSize - 1]] # Store currentLine $filePath1 auto 0 a Store processedLine $filePath1 auto 0 a incr lineCounter } # ShortenLine - end # ---------------------------------------------------------------------- # TakeUpperLeftCornerRecursively (3) proc TakeUpperLeftCornerRecursively {filePath1 nCols nRows} { upvar var var upvar savedVar savedVar upvar headerLines headerLines1 upvar lineCounter lineCounter upvar 2 contentType contentType # headerArray array set headerArray [join $headerLines1] catch {set lineSize $headerArray(ncols)} catch {set lineSize $headerArray(NCOLS)} # catch {set columnSize $headerArray(nrows)} # catch {set columnSize $headerArray(NROWS)} set lineAction "ShortenLine $nCols $filePath1" if [file exists $filePath1] { if [ProcessLines $lineAction] {return 1} } 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 ncols $name] {lappend headerLines2 [regsub -- $value $line $nCols]; continue} if [string equal -nocase nrows $name] {lappend headerLines2 [regsub -- $value $line $nRows]; continue} 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} lappend headerLines2 $line } set header [join $headerLines2 \n] lappend contentType {} lappend contentType {New header:} lappend contentType $header Store header $filePath1 auto # set savedVar {} if [ProcessLines $lineAction] {return 1} } return 0 } # TakeUpperLeftCornerRecursively - end # ---------------------------------------------------------------------- # TakeUpperLeftCorner (1) proc TakeUpperLeftCorner {filePath resultRepository nCols nRows} { set argv 0 set initial [clock milliseconds] set filePath0 ../../../../../$resultRepository/doc/[file rootname [file tail $filePath]](corner)($nCols,$nRows).txt file delete $filePath0 set filePath1 ../../../../../$resultRepository/doc/[file rootname [file tail $filePath]](taken_corner)($nCols,$nRows)[file extension $filePath] 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 = TakeUpperLeftCornerRecursively" source ../../../../../urlib.net/www/2021/07.02.22.22/doc/GetSizeRecursively.tcl source ../../../../../urlib.net/www/2021/07.02.22.22/doc/TurnCellSquareRecursively.tcl set action "TakeUpperLeftCornerRecursively $filePath1 $nCols $nRows" ProcessRecursively $filePath $action set final [clock milliseconds] lappend contentType {} lappend contentType [DisplayProcessingTime [expr $final - $initial]] set contentType [join $contentType \n] puts $contentType Store contentType $filePath0 } # TakeUpperLeftCorner - 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 7 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 ;# processing time = 15 s; image size = 90600705 } 6 { set filePath $imageDirectory/MPO_mascara25-uniao-hidrografia-area-aberta-MapBiomas_32723.asc ;# processing time = 15 s; image size = 90600705 } 7 { set filePath $imageDirectory/MCP_mascara-porcentagem-formacao-florestal-F7x7_32723.asc } set nCols 160 set nRows 549 TakeUpperLeftCorner $filePath $resultRepository $nCols $nRows } # Previous textual results if 0 { }