mapgen how to!

Stephan,

the mapgen4.1 script should be under the src.related/mapgen/SCS/misc
directory. Copy this file to $GISBASE/scripts directory.
(the script is attached at the bottom of the message)

Be sure to be in a valid GRASS mapset before starting MAPGEN.

I'm not sure about your reference to the 7_15 release binaries. These
changes were compiled for sunos 4.1.3. Most of the programs are shell
scripts, but there are a few c programs that need compiling.

glad you like the citation! my management did not appreciate it.

Jill

mapgen4.1 script___________________________________________________

:
NAME=$1

##### setup mapgen variables ##################
CPATH="`echo $PATH | tr ':' ' '`"
GRAPH=$GISBASE/mapgen
####### This change for new proj REL 4.1
PROJ_LIB=$GISBASE/etc
########
GRAPHB=$GRAPH/bin/plotter:$GRAPH/gfonts/:sr:
PATH=/usr/ucb:/bin:.:$GRAPH/bin:$GRAPH/interface:$PATH
##### END setup####################
SHELL=${SHELL:-sh}
########### check to see if I'm running GRASS #######################
#if test ! -f $HOME/.gislock; then
if test "$GIS_LOCK" = "";then
  echo You MUST be Running GRASS to Run the MAPGEN Interface
  exit
fi

export GRAPHB PATH GRAPH PS1 PROJ_LIB
export MNAME
########## check for correct version of 4.13 plotter and make_leg command
#Check for the instaliation of the NRI mapgen software.
#If present the make.legend program and the plotter program will not
#function correctly.

if test `uname` = SunOS; then
SUM=/usr/5bin/sum
else
SUM=sum
fi

NRIp=`$SUM $GISBASE/mapgen/bin/plotter|cut -d" " -f1`
NRIl=`$SUM $GISBASE/mapgen/interface/make_leg|cut -d" " -f1`

if test $NRIp = 29485 ; then
echo
echo "Your current MAPGEN plotter program is NOT VALID for the 4.13 MAPGEN Software."
echo "Please refer to your 4.13 SCS software release notes."
echo "See page 15 of \"Whats New.... SCS GRASS/MAPGEN 4.13 Release\"."
echo "The 4.13 software incorporates all necessary files for NRIDAS."
echo "DO NOT RE-INSTALL the NRI DAS SOFTWARE!!!!!!!"
exit
fi

if test $NRIl = 63305 ; then
echo
echo "Your current MAPGEN make_leg program is not valid for the 4.13 MAPGEN Software."
echo "Please refer to your 4.13 SCS software release notes."
echo "The 4.13 software incorporates all necessary files for NRIDAS."
echo "See page 15 of \"Whats New.... SCS GRASS/MAPGEN 4.13 Release\"."
echo "DO NOT RE-INSTALL the NRI DAS SOFTWARE!!!!!!!"
exit
fi

##### Put in the proper directory
while test "$answ" != "n"
do
cd $LOCATION
##### check for mapgen directory #########################
if test ! -d mapgen
  then
  mkdir mapgen
  answ=n
else
  answ=y
fi
######## Check for supporting directories #####################
if test ! -d $LOCATION/dig_geo
  then
  mkdir $LOCATION/dig_geo
fi
if test ! -d $LOCATION/sites_geo
  then
  mkdir $LOCATION/sites_geo
fi

old=n
######## Check for old supporting directories and copy to location################
if test -d $LOCATION/mapgen/dig_geo; then
  old=y
  echo "PREPARING EXISTING MAPGEN GEO FILES FOR 4.1 VERSION"
  echo "Moving Contents of \$LOCATION/mapgen/dig_geo to \$LOCATION/dig_geo"
  cp $LOCATION/mapgen/dig_geo/* $LOCATION/dig_geo
  rm -r $LOCATION/mapgen/dig_geo
fi
if test -d $LOCATION/mapgen/sites_geo; then
  old=y
  echo "PREPARING EXISTING MAPGEN GEO FILES FOR 4.1 VERSION"
  echo "Moving Contents of \$LOCATION/mapgen/sites_geo to \$LOCATION/sites_geo"
        cp $LOCATION/mapgen/sites_geo/* $LOCATION/sites_geo
        rm -r $LOCATION/mapgen/sites_geo
fi

if test "$answ" != "n" -o "$answ" != "N"
then
clear

if test $# = 1; then
answ=e
fmat41=y
else
answ=l
fi

while test "$answ" = "l" -o "$answ" = "L"
do
echo -n 'Do you want to edit an EXISTING MAP? [e]xisting, (n)ew or (l)ist? '
read answ
answ=${answ:-e}
if test "$answ" = "l" -o "$answ" = "L"
  then
  echo
  ls -C mapgen | sed -e "s/dig_geo//;s/sites_geo//"
  echo
fi
done
fi

if test "$answ" = "n" -o "$answ" = "N"
##### CREATE new map ##########################################
  then
  while test "$MNAME" = ""
  do
  echo -n 'Enter the name of the NEW map: '
  read MNAME
  done
  if test ! -d mapgen/$MNAME
    then
    mkdir mapgen/$MNAME
  fi
  if test ! -d mapgen/$MNAME/ovm
    then
    mkdir mapgen/$MNAME/ovm
  fi

##### END CREATE map
else
  while test "$MNAME" = "";
  do
  echo -n 'Enter the name of the EXISTING base map: '
  read MNAME
  if test ! -d mapgen/$MNAME -o "$MNAME" = ""
    then
    echo Error that map does not exist
    exit
  fi
  done
fi
clear
cd mapgen/$MNAME

###############Checking map structure for 4.1 ###############
if test $old = y ; then
fmat41=n
fi

while test "$fmat41" = ""
do
echo
echo "The MAPGEN Interface parameter file structure has changed in version 4.1x."
echo "The following directory files must be modified for compatability:
  misc parameter files
  map definition files
  legend/cmd files"

if test $answ != n; then
echo
echo -n "Is your current map in the correct format for 4.1x? ([y]es or (n)o): "
read fmat41
fmat41=${fmat41:-y}
else
fmat41=y
fi
done

if [ $fmat41 = n -o $fmat41 = N ]; then
############### checking misc directory file structure
echo
echo "Checking MISC File Structure For Correct 4.1 Format"
for i in `ls $LOCATION/mapgen/$MNAME/misc/*`
do

if test -s $i; then
doit=`head -1 $i |awk '{ FS = " "; print ($2);}'`
if [ "$doit" != "-m" ]; then
mdef=`head -1 $i |awk '{ FS = " "; print ($2);}'`
sed -e "s/legend $mdef/legend -m $mdef/" $i >tmp
mv tmp $i
chmod +x $i
echo "Adding -m for 4.1 version of legend command."
fi
else
echo
echo "File $i is an empty file. Skipping.........."
fi
done
############ end misc check

############# Checking mapdef files for correct structure ######
echo
echo "Checking map definition File Structure For Correct 4.1 Format"
def.2.4.1 $MNAME
##### END check

############# Checking barscale files for correct structure ######
echo
echo "Checking barscale File Structure For Correct 4.1 Format"
bar.2.4.1 $MNAME
##### END check

############# Checking legend/cmd files for correct structure #####
echo
echo "Checking legend/cmd File Structure For Correct 4.1 Format"
run.update.cmd $MNAME
##### END check

fi

PS1="
Mapset <$MAPSET> in Location <$LOCATION_NAME> in MAP <$MNAME>
GRASS-MAPGEN 4.13 > "
clear
echo " Welcome to the SCS-GRASS/MAPGEN Interface version 4.13"
echo " Default options are enclosed in brackets ."
echo " To accept the default type the return."
echo
if [ $fmat41 = n -o $fmat41 = N ] ; then
echo " Warning! Warning!"
echo " Existing MAPGEN file structure has changed. When in doubt
  run the command <redo all> to update your files."
echo
fi
echo " You are editing map $MNAME"
echo " Your current directory is `pwd`"
echo
echo " When ready to quit, type exit."
echo
if test `basename $SHELL` = csh; then
  cshrc=$LOCATION/mapgen/$MNAME/.cshrc
  cp $LOCATION/.cshrc $cshrc
  echo "set path = (/usr/ucb /bin . $GRAPH/bin $GRAPH/interface $CPATH)" >> $cshrc
  echo "set prompt='\\" >> $cshrc
  echo " Mapset <$MAPSET> in Location <$LOCATION_NAME> in MAP <$MNAME>\\" >> $cshrc
  echo " GRASS-MAPGEN 4.13 > '" >> $cshrc
  echo "setenv GRAPHB $GRAPH/bin/plotter:$GRAPH/gfonts/:sr:" >> $cshrc
  HOME=$LOCATION/mapgen/$MNAME;export HOME
  home=$HOME
  $GISBASE/etc/run ${SHELL}
else
  $GISBASE/etc/run ${SHELL}
fi
MNAME=""
echo -n "Do you want to work on another map (y)es or [n]o: "
read answ
answ=${answ:-n}
done
##### Put in the proper directory
cd $LOCATION

Jill,

thanks for your help, but I have still some problems. I have copied the
script mapgen4.1 to $GIS/scripts. I started GRASS, entered my MAPSET,
started mapgen4.1, was prompted if I want [e]xisting, (n)ew ..., entered
"n", entered the name of the desired map ("Topographie") and got:

  Welcome to the SCS-GRASS/MAPGEN Interface version 4.13
        Default options are enclosed in brackets .
        To accept the default type the return.

  You are editing map Topographie
  Your current directory is
/scratch/eicksch/grass-data/Ekstroemisen/Synoptic/mapgen/Topographie

        When ready to quit, type exit.

earth:/scratch/eicksch/grass-data/Ekstroemisen/Synoptic/mapgen/Topographie >

I couldn´t start _any_ of the scripts in $GIS/mapgen/interface, because
for
some reason - which I don´t understand - the PATH variable didn´t
change. All
the other setup succeded, as you might see from my excerpt from using
env
right at the mapgen-prompt (s. attachment).

Do you have any suggestions?

Regards,

  Stephan

P.S.:

PATH=/usr/ucb:/bin:.:$GRAPH/bin:$GRAPH/interface:$PATH

       ~~~~~~~~
  This path doesn´t exist on our machine; is it necessary?

(attachments)

env.txt (2.37 KB)

Hi Jill-

I have fixed some of the problems: I am running tcsh, so in mapgen4.1,
l245 "csh" hat to be replaced by "tcsh". After that, the search path
and the prompt was as expected. But there is still a problem with the
executables in $GIS/mapgen/interface - as you´ve mentioned, they are
compiled for sunos 4.1.3, but not for IRIX5.3 ...
Is there a possibility to get the source code??? I couldn´t find it at
ftp://ftp.nrcs.usda.gov/centers/itc/applications/mapgen/, and - as far
as I know - they do not belong to the USGS release, do they???

Regards,

  Stephan