s.to.labels

M.R. Lassche lasm at geo.vu.nl
Tue May 24 05:45:10 EDT 1994


Hello grasshoppers,

the following message contains a script wich can be used for transforming a sites file into a label file wich can be used wich the commands like d.paint.label and d.labels

__________________cut here_______________________

#program made by Ronnie Lassche on the may 24
#user can transform a sites file into a label file
#for comment mail to lasm at geo.vu.nl

:

echo "Option:    Name of sites file"
echo "     key:  file"
echo "required:  YES"
g.ask type=old element=site_lists desc="sites" unixfile=/tmp/$$ 
eval `cat /tmp/$$`
sitelist="${name}"
rm -f /tmp/$$
  if [ ! "$file" ]
   then
     exit 0
  fi

echo ""
echo "Option:    Name of resulting label file"
echo "     key:  file"
echo "required:  YES"
g.ask type=any element=paint/labels desc="label file" unixfile=/tmp/$$
eval `cat /tmp/$$`
labelfile="${name}"
rm -f /tmp/$$
  if [ ! "$file" ]
   then 
    exit 0
  fi

gotit=0
while test $gotit -eq 0
do
 echo ""
 echo "Option:    Relative position"
 echo "     key:  ref"
 echo " Default:  center"
 echo "required:  NO"
 echo -n "enter option > "
 read refpos
  if test "$refpos"
   then
    if test "$refpos" != "lower left"   -a "$refpos" != "lower right"   -a                  "$refpos" != "lower center" -a "$refpos" != "upper left"    -a                  "$refpos" != "upper right"  -a "$refpos" != "upper center"  -a                  "$refpos" != "center"
     then 
      echo ""
      echo "sorry <$refpos> is not valid input"
      echo ""
      echo "options : lower left,lower right,lower center"
      echo "          upper left,upper right,upper center,center"
     else 
      gotit=1
    fi
   else
    refpos=center
    gotit=1
  fi
done

gotit=0
while test $gotit -eq 0
 do
  echo ""
  echo "Option:    Text color "
  echo "     key:  color"
  echo " Default:  black"
  echo "required:  NO"
  echo -n "enter option > "
  read color
   if test "$color"
    then
     if test "$color" != "aqua"    -a "$color" != "black"    -a                              "$color" != "blue"    -a "$color" != "brown"    -a                              "$color" != "cyan"    -a "$color" != "gray"     -a                              "$color" != "green"   -a "$color" != "grey"     -a                              "$color" != "indigo"  -a "$color" != "magenta"  -a                              "$color" != "orange"  -a "$color" != "purple"   -a                              "$color" != "red"     -a "$color" != "violet"   -a                              "$color" != "white"   -a "$color" != "yellow"
      then 
       echo ""
       echo "sorry <$color> is not valid input"
       echo ""
       echo "Options : aqua,black,blue,brown,cyan,gray,green,grey,indigo,"
       echo "          magenta,orange,purple,red.violet,white,yellow"
      else
       gotit=1
     fi
    else
     color=black
     gotit=1
   fi
  done

gotit=0
while test $gotit -eq 0
 do
  echo ""
  echo "Option:    Size of text (pixels) "
  echo "     key:  size"
  echo " Default:  10"
  echo "required:  NO"
  echo -n "enter option > "
  read size
   if test "$size"
    then
     if test $size -le 0
      then 
        echo ""
        echo "sorry <$size> is not valid input"
        echo ""
        echo "size must be greater then 0"
      else
       gotit=1
     fi
    else
     size=10
     gotit=1
  fi
 done

gotit=0
while test $gotit -eq 0
 do
  echo ""
  echo "Option:    Width of text (pixels) "
  echo "     key:  size"
  echo " Default:  1"
  echo "required:  NO"
  echo -n "enter option > "
  read width
   if test "$width"
    then
     if test $width -le 0
      then 
        echo ""
        echo "sorry <$width> is not valid input"
        echo ""
        echo "width must be greater then 0"
      else
       gotit=1
     fi
    else
     width=1
     gotit=1
  fi
 done

gotit=0
while test $gotit -eq 0
 do
  echo ""
  echo "Option:    Background color "
  echo "     key:  background"
  echo " Default:  none"
  echo "required:  NO"
  echo -n "enter option > "
  read back
   if test "$back"
    then
     if test "$back" != "aqua"    -a "$back" != "black"    -a                                "$back" != "blue"    -a "$back" != "brown"    -a                                "$back" != "cyan"    -a "$back" != "gray"     -a                                "$back" != "green"   -a "$back" != "grey"     -a                                "$back" != "indigo"  -a "$back" != "magenta"  -a                                "$back" != "orange"  -a "$back" != "purple"   -a                                "$back" != "red"     -a "$back" != "violet"   -a                                "$back" != "white"   -a "$back" != "yellow"   -a                                "$back" != "none"
      then 
       echo ""
       echo "sorry <$back> is not valid input"
       echo ""
       echo "Options : aqua,black,blue,brown,cyan,gray,green,grey,indigo,"
       echo "          magenta,orange,purple,red.violet,white,yellow,none"
      else
       gotit=1
     fi
    else
     color=none
     gotit=1
   fi
  done

gotit=0
while test $gotit -eq 0
 do
  echo ""
  echo "Option:    Border color "
  echo "     key:  border"
  echo " Default:  none"
  echo "required:  NO"
  echo -n "enter option > "
  read border
   if test "$border"
    then
     if test "$border" != "aqua"    -a "$border" != "black"    -a                            "$border" != "blue"    -a "$border" != "brown"    -a                            "$border" != "cyan"    -a "$border" != "gray"     -a                            "$border" != "green"   -a "$border" != "grey"     -a                            "$border" != "indigo"  -a "$border" != "magenta"  -a                            "$border" != "orange"  -a "$border" != "purple"   -a                            "$border" != "red"     -a "$border" != "violet"   -a                            "$border" != "white"   -a "$border" != "yellow"   -a                            "$border" != "none"
      then 
       echo ""
       echo "sorry <$border> is not valid input"
       echo ""
       echo "Options : aqua,black,blue,brown,cyan,gray,green,grey,indigo,"
       echo "          magenta,orange,purple,red.violet,white,yellow,none"
      else
       gotit=1
     fi
    else
     border=none
     gotit=1
   fi
  done

gotit=0
while test $gotit -eq 0
 do
  echo ""
  echo "Option:    opaque (yes/no)"
  echo "     key:  opaque"
  echo " Default:  no"
  echo "required:  NO"
  echo -n "enter option > "
  read opaque
   if test "$opaque"
    then
     if test "$opaque" != "yes"    -a "$opaque" != "no" 
      then 
       echo ""
       echo "sorry <$opaque> is not valid input"
       echo ""
       echo "Options : yes,no"
      else
       gotit=1
     fi
    else
     opaque=no
     gotit=1
   fi
  done

gotit=0
while test $gotit -eq 0
 do
  echo ""
  echo "Option:    Fontname "
  echo "     key:  font"
  echo " Default:  romans"
  echo "required:  NO"
  echo -n "enter option > "
  read font
   if test "$font"
    then
     if test "$font" != "romans"    -a "$font" != "romanc"    -a                             "$font" != "romancs"   -a "$font" != "romand"    -a                             "$font" != "romanp"    -a "$font" != "romant"    -a                             "$font" != "italicc"   -a "$font" != "italiccs"  -a                             "$font" != "italict"   -a "$font" != "gothitt"   -a                             "$font" != "gothgrt"   -a "$font" != "gothgbt"   -a                             "$font" != "scriptc"   -a "$font" != "scripts"   -a                             "$font" != "greekc"    -a "$font" != "greekcs"   -a                             "$font" != "greekp"    -a "$font" != "greeks"    -a                             "$font" != "cyrilc"  
      then 
       echo ""
       echo "sorry <$font> is not valid input"
       echo ""
       echo "Options : cyrilc,gothgbt,gothgrt,gothitt,greekc,greekcs,"
       echo "          greekp,greeks,italicc,italiccs,italict,romanc,"
       echo "          romancs,romand,romanp,romans,romant,scriptc,scripts"
      else
       gotit=1
     fi
    else
     font=romans
     gotit=1
   fi
done

gotit=0
while test $gotit -eq 0
 do
  echo ""
  echo "Option:    xoffset (pixels) "
  echo "     key:  pixels"
  echo " Default:  0"
  echo "required:  NO"
  echo -n "enter option > "
  read xoff
   if test "$xoff"
    then
       gotit=1
    else
     xoff=""
     gotit=1
  fi
done

gotit=0
while test $gotit -eq 0
 do
  echo ""
  echo "Option:    yoffset (pixels) "
  echo "     key:  pixels"
  echo " Default:  0"
  echo "required:  NO"
  echo -n "enter option > "
  read yoff
   if test "$yoff"
    then
       gotit=1
    else
     yoff=""
     gotit=1
  fi
done

echo "#!/bin/sh" > /tmp/$$
echo "cat $LOCATION/site_lists/$sitelist | sed 's/#//g' | awk '" >> /tmp/$$
echo "{" >> /tmp/$$
echo "{FS = \"|\"}" >> /tmp/$$
echo "{print  \"east:             \"\$1}"      >> /tmp/$$
echo "{print  \"north:            \"\$2}"      >> /tmp/$$
echo "{print  \"xoffset:          $xoff\"}"    >> /tmp/$$ 
echo "{print  \"yoffset:          $yoff\"}"    >> /tmp/$$ 
echo "{print  \"ref:              $refpos\"}"  >> /tmp/$$ 
echo "{print  \"font:             $font\"}"    >> /tmp/$$ 
echo "{print  \"color:            $color\"}"   >> /tmp/$$ 
echo "{print  \"size:             $size\"}"    >> /tmp/$$ 
echo "{print  \"width:            $width\"}"   >> /tmp/$$ 
echo "{print  \"background:       $back\"}"    >> /tmp/$$ 
echo "{print  \"border:           $border\"}"  >> /tmp/$$ 
echo "{print  \"opaque:           $opaque\"}"  >> /tmp/$$ 
echo "{print  \"                  \"}"         >> /tmp/$$ 
echo "{print  \"text:\" \$3}"                  >> /tmp/$$ 
echo "{print  \"                  \"}"         >> /tmp/$$ 
echo "'} > $LOCATION/paint/labels/$labelfile"  >> /tmp/$$

chmod u+x /tmp/$$
/tmp/$$
rm /tmp/$$
________________cut here________________
***********************************************
*             Ronnie Lassche                  *
*       Department of earth sciences          *
*              Free University                *
*                 Amsterdam                   *
*               lasm at geo.vu.nl                *
***********************************************



More information about the grass-user mailing list