[GRASS-dev] grass.py: vector_db

Martin Landa landa.martin at gmail.com
Sat Dec 20 08:01:13 EST 2008


Hi,

2008/12/20 Glynn Clements <glynn at gclements.plus.com>:
[...]
> Seems reasonable, although I would suggest:
>
> 1. Remove the layer parameter from the function; you may as well use:
>
>        fields = grass.vector_db(...)[layer]
>
> if you want a specific layer.
>
> Having the function return different types of data depending upon the
> arguments probably wasn't a great design choice. IIRC, I assumed that
> 'v.connect -g ... layer=...' would work, then realised that it
> doesn't, and fixed it inside the function rather than changing the
> interface.
>
> 2. Keep the layer in the per-layer dictionaries, as well as using the
> value as the key for the top-level dictionary, i.e.
>
> { 1 : { 'layer' : 1, 'table' : 'ar_1', 'key': 'cat', 'database': 'grass', 'driver' : 'pg' },
>  2 : { 'layer' : 2, 'table' : 'ar_2', 'key': 'cat', 'database': 'grass', 'driver' : 'pg' } }
>
> If nothing uses it, it's harmless, and it might make life simpler if
> you need to use the dictionary outside of the loop (i.e. if you save
> the dictionary for later, or pass it to a separate function, you don't
> have to record the layer number separately).

done in r34952. I also added vector_layer_db() for common usage of
vector_db() which calls fatal() with standardized error message.

Martin

-- 
Martin Landa <landa.martin gmail.com> * http://gama.fsv.cvut.cz/~landa *


More information about the grass-dev mailing list