[GRASS-dev] [GRASS GIS] #338: d.vect / v.univar does not work for layer > 1 ; v.db.join has bugs (corrected here)

#338: d.vect / v.univar does not work for layer > 1 ; v.db.join has bugs
(corrected here)
------------------------+---------------------------------------------------
Reporter: aprasad | Owner: grass-dev@lists.osgeo.org
     Type: defect | Status: new
Priority: major | Milestone: 6.4.0
Component: Vector | Version: 6.3.0
Keywords: layers > 1 | Platform: MSWindows XP
      Cpu: x86-32 |
------------------------+---------------------------------------------------
Two bugs:
1) d.vect does not work for layer > 1 (blank display) - hence
d.vect.thematic does not work.
d.vect.thematic has a bug i.e., does not include the layer option in
v.univar it uses - However, including this option does NOT help ...
BECAUSE v.univar does not work for layers > 1 (gives no values) - so used
v.univar.sh which works (since it uses database, driver and table options
- DON'T DEPRECATE IT YET)....BUT THEN, d.vect does not work for layers > 1
(blank display) - which is used by d.vect.thematic.
I was playing with sqlite database commands with multiple layers.

2) v.db.join: The layer option was missing in v.db.addcol and, in
db.execute, 'driver' and 'database' options were missing thus breaking it
for layer > 1
I have corrected the errors and attaching the corrected version
here...tested OK.

NOTE: I have a feeling that the v.* commands involving layer= is very
buggy and insufficiently tested for layer > 1

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

#338: d.vect / v.univar does not work for layer > 1 ; v.db.join has bugs
(corrected here)
---------------------------+------------------------------------------------
  Reporter: aprasad | Owner: grass-dev@lists.osgeo.org
      Type: defect | Status: closed
  Priority: major | Milestone: 6.4.0
Component: Vector | Version: 6.3.0
Resolution: fixed | Keywords: layers > 1
  Platform: MSWindows XP | Cpu: x86-32
---------------------------+------------------------------------------------
Changes (by mlennert):

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

Comment:

Replying to [ticket:338 aprasad]:
> Two bugs:
> 1) d.vect does not work for layer > 1 (blank display)

I cannot confirm this. Can you be more precise, including output of
'v.category [...] option=report' on your map ?

> d.vect.thematic has a bug i.e., does not include the layer option in
v.univar it uses - However, including this option does NOT help ...
BECAUSE v.univar does not work for layers > 1 (gives no values)

Again, I cannot confirm. Same remark as above.

>- so used v.univar.sh which works (since it uses database, driver and
table options - DON'T DEPRECATE IT YET)....BUT THEN, d.vect does not work
for layers > 1 (blank display) - which is used by d.vect.thematic.

v.univar.sh is different in that it is not linked to a specific vector map
(its man page is misleading in that sense), you can use it to interrogate
any column of any table in any database supported by grass, but no need
for any link to specific maps.

> 2) v.db.join: The layer option was missing in v.db.addcol and, in
db.execute, 'driver' and 'database' options were missing thus breaking it
for layer > 1

Fixed in Revision 33971.

> NOTE: I have a feeling that the v.* commands involving layer= is very
buggy and insufficiently tested for layer > 1

I rather strongly suspect that you are not using layers properly.

Closing the bug.
Moritz

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

Moritz Lennert wrote:

> > 2) v.db.join: The layer option was missing in v.db.addcol and, in
> db.execute, 'driver' and 'database' options were missing thus breaking it
> for layer > 1
>
> Fixed in Revision 33971.

I would like to port this to grass7. Does attached diff look correct
(seems straightforward, but no experience with python scripting, yet, so
just making sure) ?

- if grass.run_command('v.db.addcol', map = map, columns = colspec) != 0:
+ if grass.run_command('v.db.addcol', map = map, columns = colspec, layer = layer) != 0:

This looks okay.

   stmt = template.substitute(table = maptable, column = column,
            otable = otable, ocolumn = ocolumn,
- colname = colname)
+ colname = colname, database = database, driver = driver)

This won't do anything, as the template doesn't contain substitutions
for $database and $driver. Nor can they be added, as the template is
just the SQL statement. The database and driver would need to be
passed to db.execute, e.g.:

- if grass.write_command('db.execute', stdin = stmt) != 0:
+ if grass.write_command('db.execute', stdin = stmt, database = database, driver = driver) != 0:

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

On 22/10/08 17:45, Glynn Clements wrote:

Moritz Lennert wrote:

> 2) v.db.join: The layer option was missing in v.db.addcol and, in
db.execute, 'driver' and 'database' options were missing thus breaking it
for layer > 1

Fixed in Revision 33971.

I would like to port this to grass7. Does attached diff look correct (seems straightforward, but no experience with python scripting, yet, so just making sure) ?

- if grass.run_command('v.db.addcol', map = map, columns = colspec) != 0:
+ if grass.run_command('v.db.addcol', map = map, columns = colspec, layer = layer) != 0:

This looks okay.

   stmt = template.substitute(table = maptable, column = column,
            otable = otable, ocolumn = ocolumn,
- colname = colname)
+ colname = colname, database = database, driver = driver)

This won't do anything, as the template doesn't contain substitutions
for $database and $driver. Nor can they be added, as the template is
just the SQL statement. The database and driver would need to be
passed to db.execute, e.g.:

- if grass.write_command('db.execute', stdin = stmt) != 0:
+ if grass.write_command('db.execute', stdin = stmt, database = database, driver = driver) != 0:

Duh, should have seen this if I had looked more carefully ! Thanks. Committed.

Moritz