#! /bin/csh -f # Last edited on 2008-02-04 20:07:08 by stolfi set usage = "$0 NAME > PLOT.jpg" # Reads files in the following formats # # NAME.tplot TRECHO X Y (in pairs w/ blank lines) # NAME.eplot ESQUINA X Y # NAME.pplot SERVICO XK YK (with blank lines between servicos) # # Generates from them an image of the map, suitable for thumbing if ($#argv != 1) then echo "usage: ${usage}"; exit 1 endif set name = "$1"; shift; set tfile = "${name}.tplot" set efile = "${name}.eplot" set pfile = "${name}.pplot" set tmp = "/tmp/$$" set tefile = "${tmp}.eplot" set ttfile = "${tmp}.tplot" set spfile = "${tmp}.pplot" set bmfile = "${tmp}.ppm" set crfile = "${tmp}-crop.ppm" set jpfile = "${tmp}.jpg" set lgfile = "${tmp}.log" cat ${efile} > ${tefile} cat ${tfile} > ${ttfile} cat ${pfile} > ${spfile} if ( $?xlo ) then set xlim = ( $xlo $xhi ) set ylim = ( $ylo $yhi ) else set xlim = ( `cat ${tefile} ${ttfile} ${spfile} | gawk 'BEGIN{a=9999;b=-9999;} /./ {v=$2; if(vb){b=v}} END{print a,b}'` ) set ylim = ( `cat ${tefile} ${ttfile} ${spfile} | gawk 'BEGIN{a=9999;b=-9999;} /./ {v=$3; if(vb){b=v}} END{print a,b}'` ) endif gawk -v bds="${xlim} ${ylim}" \ 'BEGIN{printf "bounds: %s\n", bds > "/dev/stderr";}' gnuplot <& ${lgfile} cat ${bmfile} | pnmcrop > ${crfile} convert -quality 95 ${crfile} ${jpfile} >& ${lgfile} cat ${lgfile} | gawk '/./{print > "/dev/stderr";}' cat ${jpfile} ( display ${jpfile}; /bin/rm -f ${tefile} ${ttfile} ${spfile} ${jpfile} ) & endif /bin/rm -f ${bmfile} ${crfile}