[GRASS-dev] GRASS 7: d.vect: layer=-1 default conflicts with where option

Hi,

I found that d.vect fails on commandline

d.vect mylakes where="FTYPE IS NULL" type=area col=red
ERROR: Option <layer> must be > 0

d.vect mylakes where="FTYPE IS NULL" type=area col=red layer=1
d.vect complete.

The reason is
layer Layer number or name ('-1' for all layers)

I suppose that the logic in the WHERE part needs to be updated.

Markus

On Sun, Sep 4, 2011 at 10:13 AM, Markus Neteler <neteler@osgeo.org> wrote:

Hi,

I found that d.vect fails on commandline

d.vect mylakes where="FTYPE IS NULL" type=area col=red
ERROR: Option <layer> must be > 0

d.vect mylakes where="FTYPE IS NULL" type=area col=red layer=1
d.vect complete.

The reason is
layer Layer number or name ('-1' for all layers)

The same applies to v.dissolve (and maybe others) on command line:

   layer Layer number or name. If -1, all layers are extracted.
            A single vector map can be connected to multiple database
tables. This number determines which table to use. Layer name for
direct OGR access.
           default: -1

v.dissolve mysoils_general output=mysoils_general_families column=GSL_NAME
ERROR: Database connection not defined for layer <-1>
ERROR: Column <GSL_NAME> not found

Stating layer=1 manually on command line would be very annoying of course...

Markus

Markus Neteler wrote:

I found that d.vect fails on commandline

d.vect mylakes where="FTYPE IS NULL" type=area col=red
ERROR: Option <layer> must be > 0

d.vect mylakes where="FTYPE IS NULL" type=area col=red layer=1
d.vect complete.

The reason is
layer Layer number or name ('-1' for all layers)

I suppose that the logic in the WHERE part needs to be updated.

The error message should be more straightforward, e.g.

  "Option <where> requires a layer"

Making it support where= with all layers would require a substantial
re-write (and requires that you can come up with a single query which
works for all layers).

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

On Mon, Sep 5, 2011 at 4:04 AM, Glynn Clements <glynn@gclements.plus.com> wrote:

Markus Neteler wrote:

I found that d.vect fails on commandline

d.vect mylakes where="FTYPE IS NULL" type=area col=red
ERROR: Option <layer> must be > 0

d.vect mylakes where="FTYPE IS NULL" type=area col=red layer=1
d.vect complete.

The reason is
layer Layer number or name ('-1' for all layers)

I suppose that the logic in the WHERE part needs to be updated.

The error message should be more straightforward, e.g.

   &quot;Option &lt;where&gt; requires a layer&quot;

Making it support where= with all layers would require a substantial
re-write (and requires that you can come up with a single query which
works for all layers).

Sure but what I meant to say:

d.vect mylakes where="FTYPE IS NULL" type=area col=red

... this works in GRASS 6 and fails in GRASS 7 since the default
layer value is unsuitable. IMHO default values should work (as before).

Markus

Markus Neteler wrote:

> Making it support where= with all layers would require a substantial
> re-write (and requires that you can come up with a single query which
> works for all layers).

Sure but what I meant to say:

d.vect mylakes where="FTYPE IS NULL" type=area col=red

... this works in GRASS 6

... even if the map has multiple layers. This should be considered a
bug in 6.x, IMHO.

and fails in GRASS 7 since the default
layer value is unsuitable. IMHO default values should work (as before).

Is layer 1 *genuinely* special? I.e. is there some reason why it
*should* be the default layer?

As it stands, the default behaviour of d.vect in 6.x is to display
*some* data without any indication that it isn't displaying all of it.

I can see an argument for silently selecting layer 1 *if* a map only
has one layer, although this is practically asking for people to write
scripts which can't be used on maps with more than one layer.

If a map has multiple layers, where= is given, and layer= is not
given, then an error seem preferable to silently producing
"incomplete" output.

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

On Tue, Sep 6, 2011 at 7:20 AM, Glynn Clements <glynn@gclements.plus.com> wrote:

Is layer 1 *genuinely* special? I.e. is there some reason why it
*should* be the default layer?

Yes, since most users will have only one layer. This renders it kind of
*genuinely* special.

I believe that a software should address with default values the needs
of the majority of the users. Or remove the default value if it does not
behave like this (i.e. lead to an error message)...

Markus

On Tue, Sep 6, 2011 at 8:51 AM, Markus Neteler <neteler@osgeo.org> wrote:

On Tue, Sep 6, 2011 at 7:20 AM, Glynn Clements <glynn@gclements.plus.com> wrote:

Is layer 1 *genuinely* special? I.e. is there some reason why it
*should* be the default layer?

Yes, since most users will have only one layer. This renders it kind of
*genuinely* special.

Technically speaking, if a grass vector has only one layer, this layer
can have any number, not necessarily 1. Layer 1 is simply the most
common layer, most vectors have this layer.

I believe that a software should address with default values the needs
of the majority of the users. Or remove the default value if it does not
behave like this (i.e. lead to an error message)...

Error message updated in r48126.

Markus M