[GRASS-dev] [GRASS GIS] #965: Location wizard: doesn't create MYNAME

#965: Location wizard: doesn't create MYNAME
-----------------------------+----------------------------------------------
Reporter: hamish | Owner: grass-dev@lists.osgeo.org
     Type: defect | Status: new
Priority: normal | Milestone: 6.4.0
Component: wxGUI | Version: svn-releasebranch64
Keywords: location wizard | Platform: All
      Cpu: All |
-----------------------------+----------------------------------------------
Hi,

the wx new location wizard doesn't prompt the user to
{{{
Please enter a one line description for this location:
}}}

like the old lib/init/mke_loc.c does. So the PERMANENT/MYNAME file is
never created and so e.g. ps.map gets (gracefully) upset that it's
missing.

(G_myname() in lib/gis/myname.c)

Hamish

--
Ticket URL: <https://trac.osgeo.org/grass/ticket/965&gt;
GRASS GIS <http://grass.osgeo.org>

#965: Location wizard: doesn't create MYNAME
-----------------------------+----------------------------------------------
Reporter: hamish | Owner: martinl
     Type: defect | Status: assigned
Priority: normal | Milestone: 6.4.1
Component: wxGUI | Version: svn-releasebranch64
Keywords: location wizard | Platform: All
      Cpu: All |
-----------------------------+----------------------------------------------
Changes (by martinl):

* cc: grass-dev@… (added)
  * owner: grass-dev@… => martinl
  * status: new => assigned
  * milestone: 6.4.0 => 6.4.1

Comment:

Please try out r44616

--
Ticket URL: <http://trac.osgeo.org/grass/ticket/965#comment:1&gt;
GRASS GIS <http://grass.osgeo.org>

#965: Location wizard: doesn't create MYNAME
---------------------+------------------------------------------------------
  Reporter: hamish | Owner: martinl
      Type: defect | Status: closed
  Priority: normal | Milestone: 6.4.1
Component: wxGUI | Version: svn-releasebranch64
Resolution: fixed | Keywords: location wizard
  Platform: All | Cpu: All
---------------------+------------------------------------------------------
Changes (by martinl):

  * status: assigned => closed
  * resolution: => fixed

Comment:

Please reopen the ticket if needed.

--
Ticket URL: <http://trac.osgeo.org/grass/ticket/965#comment:2&gt;
GRASS GIS <http://grass.osgeo.org>

#965: Location wizard: doesn't create MYNAME
---------------------+------------------------------------------------------
  Reporter: hamish | Owner: martinl
      Type: defect | Status: reopened
  Priority: normal | Milestone: 6.4.1
Component: wxGUI | Version: svn-releasebranch64
Resolution: | Keywords: location wizard
  Platform: All | Cpu: All
---------------------+------------------------------------------------------
Changes (by hamish):

  * status: closed => reopened
  * resolution: fixed =>

Comment:

thanks, placement in the location wizard looks nice.

Trying it out in 6.5svn I get the following error when I click on
'Finish':
{{{
$ grass65 -gui
Cleaning up temporary files ...
Starting GRASS ...
Traceback (most recent call last):
   File "/usr/local/src/grass/grass65/dist.i686-pc-linux-
gnu/etc/wxpython/gis_set.py", line 411, in OnWizard
     grassdatabase = self.tgisdbase.GetValue())
   File "/usr/local/src/grass/grass65/dist.i686-pc-linux-
gnu/etc/wxpython/gui_modules/location_wizard.py", line 1794, in __init__
     msg = self.OnWizFinished()
   File "/usr/local/src/grass/grass65/dist.i686-pc-linux-
gnu/etc/wxpython/gui_modules/location_wizard.py", line 1986, in
OnWizFinished
     desc = self.startpage.description)
TypeError: create_location() got an unexpected keyword argument 'desc'
}}}

? and the location is not created.

also, the MYNAME description should be limited to a single line, so any \n
in the desc text should be replaced by a space. (if that's not already
being done)
[G_myname() reads & returns a single G_getl()]

cheers,
Hamish

--
Ticket URL: <https://trac.osgeo.org/grass/ticket/965#comment:3&gt;
GRASS GIS <http://grass.osgeo.org>

#965: Location wizard: doesn't create MYNAME
---------------------+------------------------------------------------------
  Reporter: hamish | Owner: martinl
      Type: defect | Status: reopened
  Priority: normal | Milestone: 6.4.1
Component: wxGUI | Version: svn-releasebranch64
Resolution: | Keywords: location wizard
  Platform: All | Cpu: All
---------------------+------------------------------------------------------

Comment(by hamish):

perhaps wrongly applied, but G_myname() is using GNAME_MAX for the max
length (256 chars in gis.h) of the description. So besides having the
newlines removed it should be cut at char 255-1 for the null
terminator(?). (or better: can python access the #defined values in the C
include files directly as swig could?)

Hamish

--
Ticket URL: <https://trac.osgeo.org/grass/ticket/965#comment:4&gt;
GRASS GIS <http://grass.osgeo.org>

#965: Location wizard: doesn't create MYNAME
---------------------+------------------------------------------------------
  Reporter: hamish | Owner: martinl
      Type: defect | Status: reopened
  Priority: normal | Milestone: 6.4.1
Component: wxGUI | Version: svn-releasebranch64
Resolution: | Keywords: location wizard
  Platform: All | Cpu: All
---------------------+------------------------------------------------------

Comment(by martinl):

Replying to [comment:3 hamish]:
{{{
> $ grass65 -gui
> Cleaning up temporary files ...
> Starting GRASS ...
> Traceback (most recent call last):
> File "/usr/local/src/grass/grass65/dist.i686-pc-linux-
gnu/etc/wxpython/gis_set.py", line 411, in OnWizard
> grassdatabase = self.tgisdbase.GetValue())
> File "/usr/local/src/grass/grass65/dist.i686-pc-linux-
gnu/etc/wxpython/gui_modules/location_wizard.py", line 1794, in __init__
> msg = self.OnWizFinished()
> File "/usr/local/src/grass/grass65/dist.i686-pc-linux-
gnu/etc/wxpython/gui_modules/location_wizard.py", line 1986, in
OnWizFinished
> desc = self.startpage.description)
> TypeError: create_location() got an unexpected keyword argument 'desc'
}}}
>
> ? and the location is not created.

your pythonlib is probably out-dated. Please run `svn up & make` in
{{{lib/python}}}.

--
Ticket URL: <https://trac.osgeo.org/grass/ticket/965#comment:5&gt;
GRASS GIS <http://grass.osgeo.org>

#965: Location wizard: doesn't create MYNAME
---------------------+------------------------------------------------------
  Reporter: hamish | Owner: martinl
      Type: defect | Status: reopened
  Priority: normal | Milestone: 6.4.1
Component: wxGUI | Version: svn-releasebranch64
Resolution: | Keywords: location wizard
  Platform: All | Cpu: All
---------------------+------------------------------------------------------

Comment(by martinl):

Replying to [comment:4 hamish]:
> perhaps wrongly applied, but G_myname() is using GNAME_MAX for the max
length (256 chars in gis.h) of the description. So besides having the
newlines removed it should be cut at char 255-1 for the null
terminator(?). (or better: can python access the #defined values in the C
include files directly as swig could?)

question: why need to be description of the location only one-line text
and moreover limited to the given number of chars. I guess that this
limitation broken in GRASS7.

--
Ticket URL: <https://trac.osgeo.org/grass/ticket/965#comment:6&gt;
GRASS GIS <http://grass.osgeo.org>

#965: Location wizard: doesn't create MYNAME
---------------------+------------------------------------------------------
  Reporter: hamish | Owner: martinl
      Type: defect | Status: reopened
  Priority: normal | Milestone: 6.4.1
Component: wxGUI | Version: svn-releasebranch64
Resolution: | Keywords: location wizard
  Platform: All | Cpu: All
---------------------+------------------------------------------------------

Comment(by martinl):

Replying to [comment:4 hamish]:
> perhaps wrongly applied, but G_myname() is using GNAME_MAX for the max
length (256 chars in gis.h) of the description.

yes, GNAME_MAX could be replaced by GPATH_MAX (or new GTITLE_MAX) to
enlarge the buffer.

> So besides having the newlines removed it should be cut at char 255-1
for the null terminator(?).

see changes in location wizard r44754

> Or better: can python access the #defined values in the C include files
directly as swig could?

Could be accessed using ctypes. Currently wxGUI is not using ctypes
(except of 3D view mode).

--
Ticket URL: <https://trac.osgeo.org/grass/ticket/965#comment:7&gt;
GRASS GIS <http://grass.osgeo.org>

#965: Location wizard: doesn't create MYNAME
---------------------+------------------------------------------------------
  Reporter: hamish | Owner: martinl
      Type: defect | Status: reopened
  Priority: normal | Milestone: 6.4.1
Component: wxGUI | Version: svn-releasebranch64
Resolution: | Keywords: location wizard
  Platform: All | Cpu: All
---------------------+------------------------------------------------------

Comment(by hamish):

Hamish:
> > TypeError: create_location() got an unexpected keyword argument 'desc'
Martin:
> your pythonlib is probably out-dated. Please run svn up & make in
lib/python.

yes, that was it. works now.

I suggest to add a tooltip to the "Location title:" in the loc wiz to
clarify that the title is descriptive text and another to the "Project
location:" to clarify that that one is the real name that it will go by.
It seems like it could get confused.

> question: why need to be description of the location only one-line text

for grass 6 this is part of the specification for LOCATION file tree and
should not be changed. at the low level G_myname() only reads 1 line of
text for the location title.

> and moreover limited to the given number of chars.

simply a function of the buffer size used in G_myname()

> I guess that this limitation broken in GRASS7.

yes, but anything that uses G_myname() would have to be changed too.
Currently it is the 1 line ''title'' of the location, not full metadata
story about it. So it is used for example as the long map title in ps.map
if you ask for an automatic header.

moreover the entire metadata system for grass7 needs to be overhauled, and
this is one part of that.

> > perhaps wrongly applied, but G_myname() is using GNAME_MAX for the
> > max length (256 chars in gis.h) of the description.
>
> yes, GNAME_MAX could be replaced by GPATH_MAX (or new GTITLE_MAX) to
enlarge the
> buffer.

what I meant was that GNAME_MAX is meant for map names, not arbitrary
strings of text. If random things are using it which shouldn't be, we get
afraid to change it later even if the change is safe for the intended map
names. GPATH_MAX is abusing it even more, the loc title has nothing to do
with filesystem limits. For a single line description I think 256 chars is
appropriate, just not to hijack defined constants meant for another
purpose. RECORD_LEN would actually be more appropriate, but for grass 6
that's stuck at 80 chars. meh, so I guess just leave this as-is.

thanks,
Hamish

--
Ticket URL: <https://trac.osgeo.org/grass/ticket/965#comment:8&gt;
GRASS GIS <http://grass.osgeo.org>

#965: Location wizard: doesn't create MYNAME
---------------------+------------------------------------------------------
  Reporter: hamish | Owner: martinl
      Type: defect | Status: reopened
  Priority: normal | Milestone: 6.4.1
Component: wxGUI | Version: svn-releasebranch64
Resolution: | Keywords: location wizard
  Platform: All | Cpu: All
---------------------+------------------------------------------------------

Comment(by glynn):

Replying to [comment:7 martinl]:

> > Or better: can python access the #defined values in the C include
files directly as swig could?
>
> Could be accessed using ctypes. Currently wxGUI is not using ctypes
(except of 3D view mode).

They don't exist in the library, so you can't access them directly via
ctypes in the same way as variables (i.e.
ctypes.CDLL("libgrass_gis.so").GNAME_MAX won't work). However, ctypesgen
includes preprocessor macros in the generated files, so they are present
in the grass.lib.*.py modules.

Even so, simply importing grass.lib.* will load the corresponding dynamic
library, which may kill the importing process if there are any problems
(e.g. architecture or version mismatches), so I wouldn't recommend it.

--
Ticket URL: <https://trac.osgeo.org/grass/ticket/965#comment:9&gt;
GRASS GIS <http://grass.osgeo.org>

#965: Location wizard: doesn't create MYNAME
---------------------+------------------------------------------------------
  Reporter: hamish | Owner: martinl
      Type: defect | Status: reopened
  Priority: normal | Milestone: 7.0.0
Component: wxGUI | Version: svn-releasebranch64
Resolution: | Keywords: location wizard
  Platform: All | Cpu: All
---------------------+------------------------------------------------------
Changes (by martinl):

  * milestone: 6.4.1 => 7.0.0

--
Ticket URL: <http://trac.osgeo.org/grass/ticket/965#comment:10&gt;
GRASS GIS <http://grass.osgeo.org>

#965: Location wizard: doesn't create MYNAME
---------------------+------------------------------------------------------
  Reporter: hamish | Owner: martinl
      Type: defect | Status: reopened
  Priority: normal | Milestone: 7.0.0
Component: wxGUI | Version: svn-releasebranch64
Resolution: | Keywords: location wizard
  Platform: All | Cpu: All
---------------------+------------------------------------------------------

Comment(by cmbarton):

Shouldn't this be happening in g.proj? This is what is making the
location. The location wizard is only a wrapper around g.proj.

Michael

--
Ticket URL: <http://trac.osgeo.org/grass/ticket/965#comment:11&gt;
GRASS GIS <http://grass.osgeo.org>