[GRASS-dev] Re: [grass-code R][428] Warn about wrong epsg code when creating a location in grass 6.2

Hamish hamish_nospam at yahoo.com
Mon Jun 18 02:18:31 EDT 2007


http://wald.intevation.org/tracker/?func=detail&atid=188&aid=428&group_id=21

> code R item #428, was opened at 2007-06-16 18:39
> Submitted By: Daniel Victoria (dvictori)
> Summary: Warn about wrong epsg code when creating a location in grass
> 6.2
> GRASS component: startup
..
> When creating a location based on a georeferenced files, if the EPSG
> code is wrong there is no clear warning and no location gets created.

in 6.2 lib/init/epsg_option.tcl.in calls this:

exec -- $env(GISBASE)/etc/grass-xterm-wrapper -e \
   $env(GISBASE)/etc/make_location_epsg.sh \
   $epsg_code $epsgLocation $locpath >@stdout 2>@stderr;


make_location_epsg.sh.in then checks if "g.proj -c" worked, and exits
with an error if it didn't, but the xterm closes as soon as the script
is done so you don't see the error message and epsg_option.tcl doesn't
check the return code to make its own error message.

One option is to be like grass-run.sh and do something like:

if [ $EXIT_VAL -ne 0 ] ; then
   echo
   echo "ERROR: $1 exited abnormally. Press <enter> to continue."
   read
fi


but make_location_epsg.sh is not just used by the startup GUI, so
making it interactive might be bad. A compromise might be to do that,
but give the `read` a timeout:

read -t 10 -n 1 -p "Press any key to continue ... (or wait 10 seconds)"

but AFAIK -t and -n are not portable. maybe 

echo "ERROR: ..."
sleep 5
? :-/

We could catch the "exec grass-xterm-wrapper" in epsg_option.tcl.in and
check the exit code (I've no idea how to do that correctly). That
doesn't help show what the g.proj error was though, just that
make_location_epsg.sh.in failed.


> This feature is already present in 6.3. Could it be backported?

No, in 6.3 it is totally different, a Tcl script makes the location.
But maybe we can find another solution.


> Also, if a wrong EPSG code is input a tmp directory sometimes is
> created

6.2's lib/init/make_location_epsg.sh.in goes:
[...]
# create new location:
g.proj -c proj4='+init=epsg:'$EPSG location=$LOCATION

if [ $? -eq 1 ] ; then
  echo "An error occured. Stop."
  exit 1
fi

#restore previous .$GRASSRC
if test -f "$GISDBASE"/"$TEMPDIR"/$GRASSRC ; then
   mv "$GISDBASE"/"$TEMPDIR"/$GRASSRC "$HOME"/.$GRASSRC
fi

#cleanup:
rm -rf $GISDBASE/$TEMPDIR
[...]


so cleanup isn't done if "g.proj -c" had an error.


Hamish




More information about the grass-dev mailing list