# annotlk.awk - (c) Heinz Spiess, EMME/2 Support Center # 1.4 2004/06/22 16:59:35 # # This AWK script takes an EMME/2 network file (d211.in) that contains # link labels to be displayed in field 12 and transforms them into an EMME/2 # annotation file. # # usage: awk -f annotlk.awk [SIZE=sz] [OFFSET=of] [SLANT=sl] d211.in >annotx # # Note: # 1) The SIZE and OFFSET parameters are defined in user coordinates. # SIZE is the size of one character, OFFSET is the link offset. # 2) Only field number 12 is taken as label # 3) The annotation file may be modified manually to include color commands # BEGIN {if(!SIZE)SIZE=.005;if(!OFFSET)OFFSET=2*SIZE} NR==1 {printf("u 1 1\ns %f %f\n",SIZE,SLANT)} $1 == "t" {table++} table==1 {x[$2]=$3;y[$2]=$4} table==2 && NF>=12{ off=OFFSET xi=x[$2] xj=x[$3] yi=y[$2] yj=y[$3] if(xi>xj){ t=xi;xi=xj;xj=t t=yi;yi=yj;yj=t off= -off+SIZE } dx=xj-xi dy=yj-yi d=sqrt(dx*dx+dy*dy) if(d-0==0)break printf("a %6f %6f\n",dx,dy) x0=xi+dx/2-(length($12)*SIZE/2*dx-off*dy)/d y0=yi+dy/2-(length($12)*SIZE/2*dy+off*dx)/d printf("t %6f %6f %s\n",x0,y0,$12) }