***
(sorry for cross-posting - I sent this to grassusers by mistake)
***
Hello list!
I started to write a vector module for GRASS GIS.
It reads an existing vector set (lines) and writes a new one.
The output set should contain the attributes of the input set plus 2 new attributes which are calculated by my module.
How do I append these new attribute columns to my output data?
When I use
Vect_copy_tables ( &In, &Out, 0 ); can I, afterwards, add colums to the table of &Out?
Or do I have to add another table like this:
==code==
Fi = Vect_default_field_info ( &Out, 1, NULL, GV_1TABLE );
Vect_map_add_dblink ( &Out, 1, NULL, Fi->table, "cat", Fi->database, Fi->driver);
driver = db_start_driver_open_database ( Fi->driver, Fi->database );
if ( driver == NULL )
G_fatal_error ( "Cannot open database %s by driver %s", Fi->database, Fi->driver );
sprintf ( buf, "create table %s ( cat integer, bsnid integer, sorder integer )", Fi->table );
db_set_string ( &sql, buf );
G_debug ( 2, db_get_string ( &sql ) );
if (db_execute_immediate (driver, &sql) != DB_OK ) {
db_close_database_shutdown_driver ( driver );
G_fatal_error ( "Cannot create table: %s", db_get_string ( &sql ) );
}
==/code==
(these lines work if there is no table yet - it fails if one already exists)
And finally, can someone explain the concept of dblink,tables,fields, layers concisely? I don't get it yet from the documents on the GRASS 6 vector architecture...
Thanks for your help,
Flo.
--
Florian Kindl
Institute ofr Geograpy
University of Innsbruck