[GRASS-dev] [GRASS GIS] #2289: v.colors not working

#2289: v.colors not working
------------------------+---------------------------------------------------
Reporter: veroandreo | Owner: grass-dev@…
     Type: defect | Status: new
Priority: normal | Milestone: 7.1.0
Component: Default | Version: unspecified
Keywords: v.colors | Platform: Linux
      Cpu: x86-64 |
------------------------+---------------------------------------------------
Hi all,

I guess something is wrong with v.colors. I'm not able to colorize
anything, it does say it sets the corresponding color table, but then...
just grey...

{{{
v.colors map=soils_general@PERMANENT use=cat color=wave
d.mon wx0
d.vect soils_general
}}}
---> no colors, just grey polygons

{{{
v.colors map=firestations use=cat color=random
d.mon wx1
d.vect firestations icon=basic/circle size=12
}}}
---> all grey circles

It doesn't work from the gui either.

I'm using grass7.1.svn (r60164M) under fedora 20.

Best,

Vero

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

#2289: v.colors not working
-------------------------+--------------------------------------------------
  Reporter: veroandreo | Owner: grass-dev@…
      Type: defect | Status: closed
  Priority: normal | Milestone: 7.1.0
Component: Default | Version: unspecified
Resolution: fixed | Keywords: v.colors
  Platform: Linux | Cpu: x86-64
-------------------------+--------------------------------------------------
Changes (by hcho):

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

Comment:

Fixed in r60225.

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

#2289: v.colors not working
-------------------------+--------------------------------------------------
  Reporter: veroandreo | Owner: grass-dev@…
      Type: defect | Status: closed
  Priority: normal | Milestone: 7.0.0
Component: Default | Version: svn-trunk
Resolution: fixed | Keywords: v.colors
  Platform: Linux | Cpu: x86-64
-------------------------+--------------------------------------------------
Changes (by neteler):

  * version: unspecified => svn-trunk
  * milestone: 7.1.0 => 7.0.0

Comment:

Replying to [comment:1 hcho]:
> Fixed in r60225.

Please let's keep it open unless the backport is done

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

#2289: v.colors not working
-------------------------+--------------------------------------------------
  Reporter: veroandreo | Owner: grass-dev@…
      Type: defect | Status: reopened
  Priority: normal | Milestone: 7.0.0
Component: Default | Version: svn-trunk
Resolution: | Keywords: v.colors
  Platform: Linux | Cpu: x86-64
-------------------------+--------------------------------------------------
Changes (by neteler):

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

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

Oh! I got it. Thanks, Markus.

···

On Tue, May 13, 2014 at 10:56 AM, GRASS GIS <trac@osgeo.org> wrote:

#2289: v.colors not working
-------------------------±-------------------------------------------------

Reporter: veroandreo | Owner: grass-dev@…
Type: defect | Status: reopened

Priority: normal | Milestone: 7.0.0
Component: Default | Version: svn-trunk

Resolution: | Keywords: v.colors
Platform: Linux | Cpu: x86-64
-------------------------±-------------------------------------------------
Changes (by neteler):

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


Ticket URL: <https://trac.osgeo.org/grass/ticket/2289#comment:3>
GRASS GIS <http://grass.osgeo.org>

#2289: v.colors not working
-------------------------+--------------------------------------------------
  Reporter: veroandreo | Owner: grass-dev@…
      Type: defect | Status: reopened
  Priority: normal | Milestone: 7.0.0
Component: Default | Version: svn-trunk
Resolution: | Keywords: v.colors
  Platform: Linux | Cpu: x86-64
-------------------------+--------------------------------------------------

Comment(by mlennert):

Replying to [comment:1 hcho]:
> Fixed in r60225.

I can confirm that this fixes the issue, but how come that in
grass70release the same code (as before the change) seems to work, but not
in trunk ?

Moritz

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

In 70release, we had

else if (!mapset || !*mapset)
mapset = G_find_file2(element, name, mapset);

but in trunk, r60149 replaced it with

mapset = G_find_file2(element, name, mapset);

and G_find_file2 hates an empty name.

Huidae

···

On Tue, May 13, 2014 at 12:24 PM, GRASS GIS <trac@osgeo.org> wrote:

#2289: v.colors not working
-------------------------±-------------------------------------------------

Reporter: veroandreo | Owner: grass-dev@…

Type: defect | Status: reopened
Priority: normal | Milestone: 7.0.0
Component: Default | Version: svn-trunk

Resolution: | Keywords: v.colors
Platform: Linux | Cpu: x86-64
-------------------------±-------------------------------------------------

Comment(by mlennert):

Replying to [comment:1 hcho]:

Fixed in r60225.

I can confirm that this fixes the issue, but how come that in
grass70release the same code (as before the change) seems to work, but not
in trunk ?

Moritz


Ticket URL: <https://trac.osgeo.org/grass/ticket/2289#comment:4>
GRASS GIS <http://grass.osgeo.org>

Hi,

2014-05-13 20:06 GMT+02:00 Huidae Cho <grass4u@gmail.com>:

but in trunk, r60149 replaced it with

then we should discuss about backporting such change instead of quick
fixing in relbr70 (without explanation)... Martin

I agree. Maybe, Markus M has a better idea why we needed r60149?

···

On Tue, May 13, 2014 at 2:08 PM, Martin Landa <landa.martin@gmail.com> wrote:

Hi,

2014-05-13 20:06 GMT+02:00 Huidae Cho <grass4u@gmail.com>:

but in trunk, r60149 replaced it with

then we should discuss about backporting such change instead of quick
fixing in relbr70 (without explanation)… Martin

Huidae Cho wrote:

I agree. Maybe, Markus M has a better idea why we needed r60149?

AFAICT, the reason for the logic change is so that it doesn't print a
warning if the file simply doesn't exist.

The previous version would only call G_find_file2() if the mapset
couldn't otherwise be determined, i.e. the name was unqualified and no
mapset was given. If the mapset could be determined either from a
qualified name or a non-empty mapset parameter, a non-existent file
wouldn't be detected until the open() call failed.

The new version always calls G_find_file2() first, so open() should
never be called for a non-existent file (or one which is inaccessible
due to the current process lacking execute (search) permission on any
ancestor directory). So a failed open() would indicate something less
mundane than a missing file.

I'm assuming that some code used the functions for a combined "check
whether it exists, and if so, open it" function. If that's the case,
warning about non-existent files would be a nuisance.

I'm still not sure whether this behaviour is a good idea, or whether
we should always generate the warning and require callers to perform
an explicit G_find_* call if the file's existence is merely "useful"
rather than either "required" or at least "expected".

And none of this changes the fact that Vect_read_colors() was broken
prior to r60225, and is still broken now.

If a function has parameters which happen to be used as the various
components of a filename, code shouldn't assume that they're just
going to get glued together and that it doesn't matter about the
individual pieces.

It's still broken now because the first argument to Rast__read_colors
is supposed to be an "element name", not two directory names glued
together. That it happens to work as a coincidence of implementation
details doesn't make it correct (in fact, "happens to work as a
coincidence of implementation details" is pretty much the definition
of a "hack").

Given that the current prototype for Rast__read_colors() doesn't
actually support reading colours for a vector map (because of the
vector code using the <mapset>/vector/<map>/<element> layout rather
than <mapset>/<element>/<map>), the correct solution is to add a new
function which takes a FILE* and let Vlib deal with opening (and
closing) the file.

--
Glynn Clements <glynn@gclements.plus.com>

I think in the long term it would be better to change the raster directory structure such that raster and vector have the same mapset/(raster, vector)/mapname/element path. Then we would be able to move some useful element related functions from librast to libgis.

Huidae

On May 13, 2014 5:11 PM, “Glynn Clements” <glynn@gclements.plus.com> wrote:

Huidae Cho wrote:

I agree. Maybe, Markus M has a better idea why we needed r60149?

AFAICT, the reason for the logic change is so that it doesn’t print a
warning if the file simply doesn’t exist.

The previous version would only call G_find_file2() if the mapset
couldn’t otherwise be determined, i.e. the name was unqualified and no
mapset was given. If the mapset could be determined either from a
qualified name or a non-empty mapset parameter, a non-existent file
wouldn’t be detected until the open() call failed.

The new version always calls G_find_file2() first, so open() should
never be called for a non-existent file (or one which is inaccessible
due to the current process lacking execute (search) permission on any
ancestor directory). So a failed open() would indicate something less
mundane than a missing file.

I’m assuming that some code used the functions for a combined “check
whether it exists, and if so, open it” function. If that’s the case,
warning about non-existent files would be a nuisance.

I’m still not sure whether this behaviour is a good idea, or whether
we should always generate the warning and require callers to perform
an explicit G_find_* call if the file’s existence is merely “useful”
rather than either “required” or at least “expected”.

And none of this changes the fact that Vect_read_colors() was broken
prior to r60225, and is still broken now.

If a function has parameters which happen to be used as the various
components of a filename, code shouldn’t assume that they’re just
going to get glued together and that it doesn’t matter about the
individual pieces.

It’s still broken now because the first argument to Rast__read_colors
is supposed to be an “element name”, not two directory names glued
together. That it happens to work as a coincidence of implementation
details doesn’t make it correct (in fact, “happens to work as a
coincidence of implementation details” is pretty much the definition
of a “hack”).

Given that the current prototype for Rast__read_colors() doesn’t
actually support reading colours for a vector map (because of the
vector code using the /vector// layout rather
than //), the correct solution is to add a new
function which takes a FILE* and let Vlib deal with opening (and
closing) the file.


Glynn Clements <glynn@gclements.plus.com>

Huidae Cho wrote:

I think in the long term it would be better to change the raster directory
structure such that raster and vector have the same mapset/(raster,
vector)/mapname/element path. Then we would be able to move some useful
element related functions from librast to libgis.

The main downsides are:

1. You lose the ability to access the data with older versions of
GRASS.

2. You're more likely to run into limits on the number of maps within
a mapset. IIRC, ext2/ext3 doesn't allow a directory to have more than
32000 subdirectories, whereas there's no practical limit to the number
of files. OTOH, given that raster maps invariably have a non-empty
cell_misc subdirectory, this is probably a moot point.

--
Glynn Clements <glynn@gclements.plus.com>

  1. We may need to break backward compatibility at some point to improve the data structure. As long as we keep the same file format, we could provide a tool to build old databases out of new ones.

  2. Good point and right, even now, cell_misc has subdirectories, not files. If we really want to have no limits on the number of maps, we could make the folder structure flat and have a fixed number of element directories and files inside them. I personally don’t like such a limitation like max 32,000 maps. Maybe, moving/renaming vector/cell_misc element files to the mapset directory is a better option. mapset/element/mapname

···

On Wed, May 14, 2014 at 5:18 PM, Glynn Clements <glynn@gclements.plus.com> wrote:

Huidae Cho wrote:

I think in the long term it would be better to change the raster directory
structure such that raster and vector have the same mapset/(raster,
vector)/mapname/element path. Then we would be able to move some useful
element related functions from librast to libgis.

The main downsides are:

  1. You lose the ability to access the data with older versions of
    GRASS.

  2. You’re more likely to run into limits on the number of maps within
    a mapset. IIRC, ext2/ext3 doesn’t allow a directory to have more than
    32000 subdirectories, whereas there’s no practical limit to the number
    of files. OTOH, given that raster maps invariably have a non-empty
    cell_misc subdirectory, this is probably a moot point.


Glynn Clements <glynn@gclements.plus.com>

#2289: v.colors not working
-------------------------+--------------------------------------------------
  Reporter: veroandreo | Owner: grass-dev@…
      Type: defect | Status: reopened
  Priority: normal | Milestone: 7.0.0
Component: Default | Version: svn-trunk
Resolution: | Keywords: v.colors
  Platform: Linux | Cpu: x86-64
-------------------------+--------------------------------------------------

Comment(by neteler):

Replying to [comment:4 mlennert]:
> Replying to [comment:1 hcho]:
> > Fixed in r60225.
>
> I can confirm that this fixes the issue, but how come that in
grass70release the same code (as before the change) seems to work, but not
in trunk ?

Indeed - is a backport needed? Seems to work without in relbranch7.

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

#2289: v.colors not working
-------------------------+--------------------------------------------------
  Reporter: veroandreo | Owner: grass-dev@…
      Type: defect | Status: reopened
  Priority: normal | Milestone: 7.0.0
Component: Default | Version: svn-trunk
Resolution: | Keywords: v.colors
  Platform: Linux | Cpu: x86-64
-------------------------+--------------------------------------------------

Comment(by hcho):

You should backport both r60149 and r60225, or none of them. At this
point, if we don't already have r60149 in relbranch7, I wouldn't backport
r60225 until we come up with a better solution.

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

#2289: v.colors not working
-------------------------+--------------------------------------------------
  Reporter: veroandreo | Owner: grass-dev@…
      Type: defect | Status: reopened
  Priority: normal | Milestone: 7.0.0
Component: Default | Version: svn-trunk
Resolution: | Keywords: v.colors
  Platform: Linux | Cpu: x86-64
-------------------------+--------------------------------------------------

Comment(by neteler):

Replying to [comment:6 hcho]:
> You should backport both r60149 and r60225, or none of them. At this
point, if we don't already have r60149 in relbranch7,

By chance I backported that earlier today in r61437.

> I wouldn't backport r60225 until we come up with a better solution.

I'll leave that decision to you.

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

#2289: v.colors not working
-------------------------+--------------------------------------------------
  Reporter: veroandreo | Owner: grass-dev@…
      Type: defect | Status: reopened
  Priority: normal | Milestone: 7.0.0
Component: Default | Version: svn-trunk
Resolution: | Keywords: v.colors
  Platform: Linux | Cpu: x86-64
-------------------------+--------------------------------------------------

Comment(by hcho):

Backported in r61449.

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

#2289: v.colors not working
-------------------------+--------------------------------------------------
  Reporter: veroandreo | Owner: grass-dev@…
      Type: defect | Status: closed
  Priority: normal | Milestone: 7.0.0
Component: Default | Version: svn-trunk
Resolution: fixed | Keywords: v.colors
  Platform: Linux | Cpu: x86-64
-------------------------+--------------------------------------------------
Changes (by neteler):

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

Comment:

Works fine now, closing.

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