[GRASS-dev] Re: [grass-code R] Warn about wrong epsg code when
creating a location in grass 6.2
hamish_nospam at yahoo.com
Mon Jun 18 02:18:31 EDT 2007
> 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
> 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 \
$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 "ERROR: $1 exited abnormally. Press <enter> to continue."
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: ..."
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
> 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
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."
#restore previous .$GRASSRC
if test -f "$GISDBASE"/"$TEMPDIR"/$GRASSRC ; then
mv "$GISDBASE"/"$TEMPDIR"/$GRASSRC "$HOME"/.$GRASSRC
rm -rf $GISDBASE/$TEMPDIR
so cleanup isn't done if "g.proj -c" had an error.
More information about the grass-dev