#!/bin/bash
#
# Wien.sh       12Jun2006/PicoKnirps
#
if test $# -eq 0 ; then
   echo "Kein Input-File angegeben!"
   echo "Beispiel:"
   echo ""
   echo "$0 gc_schweiz_logs.gpx"
   echo ""
   echo "oder optional ein zweiter Filename"
   echo ""
   echo "$0 gc_schweiz_logs.gpx MyFinds.gpx"
   echo ""
   exit 1
fi
#
inpfil1=$1
inpfil2='nix'
if test $# -eq 2 ; then
   inpfil2=$2
fi
cat $inpfil1 | grep \<wpt | cut -d\" -f 2,4 | tr -s '"' ' ' > gc.dat
#
#
pscoast -R16.20/16.5/48.10/48.30 -JM14.0c -Ba0.2f0.1/a0.2f0.1 -Df -A5 -I1/5/50/50/255 -I2/5/50/50/255 -I3/5/50/50/255 -Na/7/0/50/0 -S50/50/255 -K > gc.ps
cat gc.dat | awk '{print $1,$2,0.07}' | psxy -R -JM -O -Sc -L -G255/255/100 -W5/0/0/100 -: -K >> gc.ps
if test "$inpfil2" != "nix" ; then
   cat $inpfil2 | grep \<wpt | cut -d\" -f 2,4 | tr -s '"' ' ' > gc.dat
   cat gc.dat | awk '{print $1,$2,0.07}' | psxy -R -JM -O -Sc -L -G255/50/50 -W5/0/0/100 -: -K >> gc.ps
fi
#
dat=`date`
date=`echo $dat | cut -c-16,20-`
if test "$inpfil2" != "nix" ; then
   echo "16.20 48.33 18 0 4 5 $inpfil1 (gelb) $inpfil2 (rot) - $date" | pstext -R -JM -N -O >> gc.ps
else
   echo "16.20 48.33 18 0 4 5 $inpfil1 - $date" | pstext -R -JM -N -O >> gc.ps
fi
#
convert -rotate 90 gc.ps $inpfil1.png
rm gc.dat
##rm gc.ps
echo "Karte erstellt. Name: $inpfil1.png"
#
