######################################################################################## # # # BALISES LLIGA CATALANA DE PARAPENT PASSADES A DXF PER VEURE AMB PROGRAMES DE CAD # # Laboratori d'envol # # Pere Hernandez Casellas 2-7-2006 # # Programat amb llenguatge "bash" de GNU/Linux # # GNU General Public License 2.0 # # Està permesa la còpia, estudi, modificació i lliure distribució d'aquest codi # # perehc AT geocities DOT com # # # ######################################################################################## #!/bin/bash clear # Llegeix arxiu de balises i el simplifica a format llegible txt # Es pot substituir balisescatv7.wpt per altres arxius amb similar format grep "W " balisescatv7.wpt > balises.txt
# Transforma coordenades geografiques a coordenades UTM amb utilitat proj d'UNIX
# Ellipsoide internacional de Hayford (1909) i datum WGS84
cat balises.txt | awk '{print substr($4,1,13) substr($4,15,1) " " substr($5,1,12) substr($5,14,1) " " $9 " " $10 " " $11 " " $12}' > lat-long.txt
proj +proj=utm +ellps=intl +datum=WGS84 -r lat-long.txt > balises-utm.txt
cat balises-utm.txt | awk '{print $1 " " $2 " " $3 " " $4 " " $5 " " $6}' > balises-utm.txt
cat balises-utm.txt
# Crea un fitxer de balises per llegir cat balises.txt | awk '{print substr($2,1,3) " " substr($4,1,13) substr($4,15,1) " " substr($5,1,12) substr($5,14,1) " " substr($8,1,7) " " $9 " " $10 " " $11 " " $12}' > balises-llegir.txt
# Esborra fitxer dxf anterior rm balises.dxf
# Semiamplada (m) de la creu de la balisa i color de la mateixa s=$(echo "scale=10; 100" | bc -l) color=10
# color del text 1 2 i 3 (adaptar a la paleta de colors del programa de CAD) cl1=3
cl2=6
cl3=9
# Funcio linia entre punt A(xa,ya) i B(xb,yb) en .dxf format function line { echo 0 >> balises.dxf
echo LINE >> balises.dxf
echo 8 >> balises.dxf
echo default >> balises.dxf
echo 6 >> balises.dxf
echo CONTINOUS >> balises.dxf
echo 10 >> balises.dxf ; echo $xa >> balises.dxf
echo 20 >> balises.dxf ; echo $ya >> balises.dxf
echo 11 >> balises.dxf ; echo $xb >> balises.dxf
echo 21 >> balises.dxf ; echo $yb >> balises.dxf
echo 39 >> balises.dxf ; echo 0 >> balises.dxf
echo 62 >> balises.dxf ; echo $color >> balises.dxf
} # Funcio text en .dxf function text { echo 0 >> balises.dxf
echo "MTEXT" >> balises.dxf
echo 5 >> balises.dxf; echo 43 >> balises.dxf; echo 100 >> balises.dxf
echo "AcDbEntity" >> balises.dxf; echo 100 >> balises.dxf
echo "AcDbMText" >> balises.dxf; echo 8 >> balises.dxf; echo 0 >> balises.dxf
echo 62 >> balises.dxf; echo $cl1 >> balises.dxf
echo 370 >> balises.dxf; echo -1 >> balises.dxf; echo 6 >> balises.dxf
echo "ByLayer" >> balises.dxf
echo 10 >> balises.dxf
echo $(echo "$x+2*$s" | bc -l) >> balises.dxf
echo 20 >> balises.dxf
echo $(echo "$y+2*$s" | bc -l) >> balises.dxf
echo 30 >> balises.dxf; echo 0.0 >> balises.dxf
echo 40 >> balises.dxf; echo $(echo "$s*4" | bc -l) >> balises.dxf
echo 41 >> balises.dxf
echo 100.0 >> balises.dxf
echo 71 >> balises.dxf; echo 1 >> balises.dxf; echo 72 >> balises.dxf; echo 0 >> balises.dxf
echo 1 >> balises.dxf
echo $nom >> balises.dxf
echo 7 >> balises.dxf
echo normallatin1 >> balises.dxf
echo 100 >> balises.dxf
echo 0.0 >> balises.dxf
echo 73 >> balises.dxf
echo 1 >> balises.dxf
echo 44 >> balises.dxf
echo 1.0 >> balises.dxf
} # Calcula nombre de balises numf=$(wc -l balises-utm.txt | awk '{print $1}') echo "num balises= " $numf contador=1
# Llegeix punts i els dibuixa for i in $(less balises-utm.txt | awk '{print $1}' balises-utm.txt); do less balises-utm.txt | head -$contador | tail -1 > linea-prov
x=$(awk '{print $1}' linea-prov) y=$(awk '{print $2}' linea-prov) nom=$(awk '{print $3 " " $4 " " $5}' linea-prov) text xa=$(echo "scale=10; $x-$s" | bc -l) xb=$(echo "scale=10; $x+$s" | bc -l) ya=$(echo "scale=10; $y" | bc -l) yb=$(echo "scale=10; $y" | bc -l) line xa=$(echo "scale=10; $x" | bc -l) xb=$(echo "scale=10; $x" | bc -l) ya=$(echo "scale=10; $y-$s" | bc -l) yb=$(echo "scale=10; $y+$s" | bc -l) line echo $contador " " $x " " $y " " $nom contador=$(echo "$contador+1" | bc -l) done echo "OK" # Tanca el fitxer dxf echo END >> balises.dxf
# qcad balises.dxf