field.c File Reference

Vector library - field(layer) related fns. More...

#include <stdlib.h>
#include <stdio.h>
#include <string.h>
#include <grass/glocale.h>
#include <grass/gis.h>
#include <grass/dbmi.h>
#include <grass/Vect.h>
#include <gdal_version.h>
#include <ogr_api.h>
Include dependency graph for field.c:

Go to the source code of this file.

Functions

struct dblinks * Vect_new_dblinks_struct (void)
 Create and init new dblinks ctructure.
void Vect_reset_dblinks (struct dblinks *p)
 Reset dblinks structure.
int Vect_map_add_dblink (struct Map_info *Map, int number, const char *name, const char *table, const char *key, const char *db, const char *driver)
 Add new db connection to Map_info structure.
int Vect_map_del_dblink (struct Map_info *Map, int field)
 Delete db connection from Map_info structure.
int Vect_map_check_dblink (struct Map_info *Map, int field)
 Check if db connection exists in dblinks structure.
int Vect_check_dblink (struct dblinks *p, int field)
 Check if db connection exists in dblinks structure.
int Vect_add_dblink (struct dblinks *p, int number, const char *name, const char *table, const char *key, const char *db, const char *driver)
 Add new db connection to dblinks structure.
struct field_info * Vect_default_field_info (struct Map_info *Map, int field, const char *field_name, int type)
 Get default information about link to database for new dblink.
struct field_info * Vect_get_dblink (struct Map_info *Map, int link)
 Get information about link to database.
struct field_info * Vect_get_field (struct Map_info *Map, int field)
 Get information about link to database.
int Vect_read_dblinks (struct Map_info *Map)
 Read dblinks to existing structure.
int Vect_write_dblinks (struct Map_info *Map)
 Write dblinks to file.
char * Vect_subst_var (const char *in, struct Map_info *Map)
 Substitute variable in string.
void Vect_set_db_updated (struct Map_info *Map)
 Rewrite 'dbln' file.

Detailed Description

Vector library - field(layer) related fns.

Higher level functions for reading/writing/manipulating vectors.

TODO: see Vect_read_dblinks; activate auto-FID detection once OGR_L_GetFIDColumn() is working or solution found if FID not available

(C) 2001-2008 by the GRASS Development Team

This program is free software under the GNU General Public License (>=v2). Read the file COPYING that comes with GRASS for details.

Author:
Original author CERL, probably Dave Gerdes or Mike Higgins. Update to GRASS 5.7 Radim Blazek and David D. Gray.
Date:
2001-2008

Definition in file field.c.


Function Documentation

int Vect_add_dblink ( struct dblinks *  p,
int  number,
const char *  name,
const char *  table,
const char *  key,
const char *  db,
const char *  driver 
)

Add new db connection to dblinks structure.

Parameters:
p pointer to existing dblinks structure
number layer number
name layer name
key key name
db database name
driver driver name
Returns:
0 OK
-1 error

Definition at line 214 of file field.c.

References Vect_check_dblink().

Referenced by Vect_map_add_dblink(), and Vect_read_dblinks().

int Vect_check_dblink ( struct dblinks *  p,
int  field 
)

Check if db connection exists in dblinks structure.

Parameters:
p pointer to existing dblinks structure
field layer number
Returns:
1 dblink for field exists
0 dblink does not exist for field

Definition at line 185 of file field.c.

Referenced by Vect_add_dblink(), and Vect_map_check_dblink().

struct field_info* Vect_default_field_info ( struct Map_info *  Map,
int  field,
const char *  field_name,
int  type 
) [read]

Get default information about link to database for new dblink.

Parameters:
Map vector map
field layer number
field_name layer name
type how many tables are linked to map: GV_1TABLE / GV_MTABLE
Returns:
pointer to new field_info structure

Definition at line 278 of file field.c.

Referenced by Vect_copy(), Vect_copy_table_by_cats(), Vect_copy_tables(), and Vect_rename().

struct field_info* Vect_get_dblink ( struct Map_info *  Map,
int  link 
) [read]

Get information about link to database.

Variables are substituted by values, link is index to array of dblinks

Parameters:
Map vector map
link link id
Returns:
pointer to new field_info structure

Definition at line 364 of file field.c.

References Vect_subst_var().

Referenced by Vect_copy(), Vect_copy_tables(), Vect_delete(), Vect_get_field(), and Vect_rename().

struct field_info* Vect_get_field ( struct Map_info *  Map,
int  field 
) [read]

Get information about link to database.

Variables are substituted by values, field is number of requested field

Parameters:
Map vector map
field layer number
Returns:
pointer to new field_info structure
NULL if not found

Definition at line 404 of file field.c.

References Vect_get_dblink().

Referenced by Vect_copy_table_by_cats(), Vect_get_column_names(), Vect_get_column_names_types(), Vect_get_column_types(), Vect_net_build_graph(), Vect_rename(), and Vect_set_varray_from_db().

int Vect_map_add_dblink ( struct Map_info *  Map,
int  number,
const char *  name,
const char *  table,
const char *  key,
const char *  db,
const char *  driver 
)

Add new db connection to Map_info structure.

Parameters:
Map vector map
number layer number
name layer name
table table name
key key name
db database name
driver driver name
Returns:
0 OK
-1 error

Definition at line 86 of file field.c.

References Vect_add_dblink(), and Vect_write_dblinks().

Referenced by Vect_copy(), Vect_copy_table_by_cats(), Vect_copy_tables(), and Vect_rename().

int Vect_map_check_dblink ( struct Map_info *  Map,
int  field 
)

Check if db connection exists in dblinks structure.

Parameters:
Map vector map
field layer number
Returns:
1 dblink for field exists
0 dblink does not exist for field

Definition at line 171 of file field.c.

References Vect_check_dblink().

int Vect_map_del_dblink ( struct Map_info *  Map,
int  field 
)

Delete db connection from Map_info structure.

Parameters:
Map vector map
field layer number
Returns:
0 deleted
-1 error

Definition at line 125 of file field.c.

References Vect_write_dblinks().

Referenced by Vect_rename().

struct dblinks* Vect_new_dblinks_struct ( void   )  [read]

Create and init new dblinks ctructure.

Parameters:
void 
Returns:
pointer to new dblinks structure

Definition at line 45 of file field.c.

Referenced by Vect__open_old(), and Vect_open_new().

int Vect_read_dblinks ( struct Map_info *  Map  ) 

Read dblinks to existing structure.

Variables are not substituted by values.

Parameters:
Map vector map
Returns:
number of links read
-1 on error

Definition at line 431 of file field.c.

References FALSE, Vect_add_dblink(), and Vect_reset_dblinks().

Referenced by Vect__open_old().

void Vect_reset_dblinks ( struct dblinks *  p  ) 

Reset dblinks structure.

Parameters:
p pointer to existing dblinks structure
Returns:
void

Definition at line 66 of file field.c.

Referenced by Vect_read_dblinks().

void Vect_set_db_updated ( struct Map_info *  Map  ) 

Rewrite 'dbln' file.

Should be used by GRASS modules which update database tables, so that other applications know that tables were changed and can reload data.

Parameters:
Map vector map
Returns:
void

Definition at line 775 of file field.c.

References Vect_write_dblinks().

char* Vect_subst_var ( const char *  in,
struct Map_info *  Map 
)

Substitute variable in string.

Parameters:
in current string
Map vector map
Returns:
pointer to new string

Definition at line 722 of file field.c.

Referenced by Vect_copy(), Vect_copy_table_by_cats(), Vect_copy_tables(), Vect_get_dblink(), and Vect_rename().

int Vect_write_dblinks ( struct Map_info *  Map  ) 

Write dblinks to file.

Parameters:
Map vector map
Returns:
0 OK
-1 on error

Definition at line 671 of file field.c.

Referenced by V1_close_nat(), Vect_map_add_dblink(), Vect_map_del_dblink(), and Vect_set_db_updated().

Generated on Tue Apr 6 13:28:14 2010 for GRASS Programmer's Manual by  doxygen 1.6.3