[GRASS-dev] Creating location from file problem

Markus Neteler neteler at itc.it
Fri Oct 20 08:36:11 EDT 2006


On Fri, Oct 20, 2006 at 01:02:44PM +0100, Glynn Clements wrote:
> 
> Markus Neteler wrote:
> 
> > together with Helena I tried to create new location from a file,
> > it fails if a datum should be asked:
> > 
> > > 1. Create new location from a file -
> > > I put the file at:
> > > http://skagit.meas.ncsu.edu/~helena/grasswork/grassbookdat/gdc.zip
> > 
> > When selecting the SHAPE file, the procedure in
> > lib/init/file_option.tcl
> > calls g.proj. In this case, it wants to query the user for the
> > datum, but for that it has to be run in the xterm wrapper which
> > isn't the case yet.
> > 
> > I tried
> > diff -u -r1.5 file_option.tcl
> > --- file_option.tcl     19 Oct 2006 12:03:48 -0000      1.5
> > +++ file_option.tcl     20 Oct 2006 08:45:28 -0000
> > @@ -114,8 +114,7 @@
> >                         if {[file exists $filepath]== 1} {
> >                                 if {[file exists $thelocation ]==0} {
> >                                         destroy .fileloc;
> > -                                       exec -- g.proj -c georef=$filepath location=$fileLocation >@stdout 2>@stderr;
> > -                                       destroy .fileloc
> > +                                       exec -- $env(GISBASE)/etc/grass-xterm-wrapper -e g.proj -c georef=$filepath location=$fileLocation;
> >                                         DialogGen .wrnDlg [G_msg "WARNING: restart GRASS please"] warning \
> >                                         [G_msg "WARNING: Please restart GRASS in order find the created location in the list (closing it for you now)"] \
> >                                                 0 OK;
> > 
> > but the xterm window only flashes, then closes.
> > 
> > How to do it right?
> 
> 1. Any GRASS program run in an xterm needs to use grass-run.sh, e.g.:
> 
> exec -- $env(GISBASE)/etc/grass-xterm-wrapper -e $env(GISBASE)/etc/grass-run.sh g.proj ...
> 
> You should probably also use "-T g.proj -n g.proj" to set the title
> back (otherwise it will be "grass-run.sh", which isn't particularly
> informative).
> 
> 2. Those semicolons shouldn't be there; I don't know if they will have
> any adverse effect, but they are unnecessary.
> 
> 3. The xterm will close as soon as the command completes (whether it
> succeeds or fails). You can use the -hold switch to retain the xterm
> window after the command completes, but you should only do that for
> debugging; having to manually close the xterm window each time would
> be annoying in normal use. Alternatively, redirect stdout/stderr to a
> file, to catch any error messages.

Very nice, it now works and is fixed in 6.3 and 6.2-release branch.

Thanks for the quick help!
Markus




More information about the grass-dev mailing list