GRASS GIS 8 Programmer's Manual
8.2.2dev(2023)-3d2c704037
|
Vector library - field (layer) related fns. More...
#include <stdlib.h>
#include <stdio.h>
#include <string.h>
#include <grass/gis.h>
#include <grass/glocale.h>
#include <grass/dbmi.h>
#include <grass/vector.h>
#include "local_proto.h"
#include <gdal_version.h>
#include <ogr_api.h>
Go to the source code of this file.
Functions | |
struct dblinks * | Vect_new_dblinks_struct (void) |
Create and init new dblinks structure. More... | |
void | Vect_reset_dblinks (struct dblinks *p) |
Reset dblinks structure (number of fields) More... | |
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. More... | |
int | Vect_map_del_dblink (struct Map_info *Map, int field) |
Delete db connection from Map_info structure. More... | |
void | Vect_copy_map_dblinks (const struct Map_info *In, struct Map_info *Out, int first_only) |
Copy DB links from input vector map to output vector map. More... | |
int | Vect_map_check_dblink (const struct Map_info *Map, int field, const char *name) |
Check if DB connection exists in dblinks structure. More... | |
int | Vect_check_dblink (const struct dblinks *p, int field, const char *name) |
Check if DB connection exists in dblinks structure. More... | |
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. More... | |
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. More... | |
struct field_info * | Vect_get_dblink (const struct Map_info *Map, int link) |
Get information about link to database. More... | |
struct field_info * | Vect_get_field (const struct Map_info *Map, int field) |
Get information about link to database (by layer number) More... | |
struct field_info * | Vect_get_field_by_name (const struct Map_info *Map, const char *field) |
Get information about link to database (by layer name) More... | |
struct field_info * | Vect_get_field2 (const struct Map_info *Map, const char *field) |
Get information about link to database (by layer number or layer name) More... | |
int | Vect_get_field_number (const struct Map_info *Map, const char *field) |
Get field number of given field. More... | |
int | Vect_read_dblinks (struct Map_info *Map) |
Read dblinks to existing structure. More... | |
int | Vect_write_dblinks (struct Map_info *Map) |
Write dblinks to file. More... | |
char * | Vect_subst_var (const char *in, const struct Map_info *Map) |
Substitute variable in string. More... | |
void | Vect_set_db_updated (struct Map_info *Map) |
Rewrite 'dbln' file. More... | |
Vector library - field (layer) related fns.
Higher level functions for reading/writing/manipulating vectors.
(C) 2001-2009, 2011-2012 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.
Definition in file field.c.
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.
[in,out] | p | pointer to existing dblinks structure |
number | layer number (1 for OGR) | |
name | layer name (layer for OGR) - if not given use table name | |
table | table name (layer for OGR) | |
key | key name | |
db | database name (datasource for OGR) | |
driver | driver name (dbf, postgresql, ogr, ...) |
int Vect_check_dblink | ( | const struct dblinks * | p, |
int | field, | ||
const char * | name | ||
) |
Check if DB connection exists in dblinks structure.
p | pointer to existing dblinks structure |
field | layer number |
name | layer name |
Definition at line 244 of file field.c.
References dblinks::field, G_debug(), dblinks::n_fields, field_info::name, NULL, and field_info::number.
Referenced by Vect_map_check_dblink().
Copy DB links from input vector map to output vector map.
In | pointer to Map_info structure (input) |
Out | pointer to Map_info structure (output) |
first_only | TRUE to copy only first link otherwise all DB links are copied |
Definition at line 197 of file field.c.
References _, field_info::database, field_info::driver, G_warning(), field_info::key, field_info::name, field_info::number, field_info::table, Vect_get_dblink(), Vect_get_num_dblinks(), and Vect_map_add_dblink().
Referenced by Vect_close().
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.
Map | pointer to Map_info structure |
field | layer number |
field_name | layer name |
type | how many tables are linked to map: GV_1TABLE / GV_MTABLE |
struct field_info* Vect_get_dblink | ( | const struct Map_info * | Map, |
int | link | ||
) |
Get information about link to database.
Variables are substituted by values, link is index to array of dblinks.
Map | pointer to Map_info structure |
link | link id |
Definition at line 467 of file field.c.
References _, field_info::database, Map_info::dblnk, field_info::driver, dblinks::field, G_debug(), G_malloc, G_store(), G_warning(), field_info::key, dblinks::n_fields, field_info::name, NULL, field_info::number, field_info::table, and Vect_subst_var().
Referenced by Vect_copy_map_dblinks(), Vect_get_field(), Vect_get_field2(), and Vect_get_field_by_name().
struct field_info* Vect_get_field | ( | const struct Map_info * | Map, |
int | field | ||
) |
Get information about link to database (by layer number)
Variables are substituted by values, field is number of requested field.
Map | pointer to Map_info structure |
field | layer number |
Definition at line 507 of file field.c.
References Map_info::dblnk, dblinks::field, G_debug(), dblinks::n_fields, NULL, field_info::number, and Vect_get_dblink().
Referenced by Vect_cats_set_constraint(), and Vect_get_field2().
struct field_info* Vect_get_field2 | ( | const struct Map_info * | Map, |
const char * | field | ||
) |
Get information about link to database (by layer number or layer name)
Note: if field is -1 then the function returns the first dblink or NULL
Map | pointer to Map_info structure |
field | layer number or name |
Definition at line 562 of file field.c.
References G_debug(), NULL, Vect_get_dblink(), Vect_get_field(), Vect_get_field_by_name(), and Vect_get_num_dblinks().
Referenced by Vect_get_field_number().
struct field_info* Vect_get_field_by_name | ( | const struct Map_info * | Map, |
const char * | field | ||
) |
Get information about link to database (by layer name)
Map | pointer to Map_info structure |
field | layer name |
Definition at line 533 of file field.c.
References Map_info::dblnk, dblinks::field, G_debug(), dblinks::n_fields, field_info::name, NULL, and Vect_get_dblink().
Referenced by Vect_get_field2().
int Vect_get_field_number | ( | const struct Map_info * | Map, |
const char * | field | ||
) |
Get field number of given field.
Map | pointer to Map_info structure |
field | layer name |
Definition at line 599 of file field.c.
References G_debug(), field_info::number, Vect_get_field2(), and Vect_get_num_dblinks().
Referenced by vector2perimeters().
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.
Map | pointer to Map_info structure |
number | layer number |
name | layer name (if not given use table name) |
table | table name |
key | key name |
db | database name |
driver | driver name |
Definition at line 113 of file field.c.
Referenced by Vect_copy_map_dblinks().
int Vect_map_check_dblink | ( | const struct Map_info * | Map, |
int | field, | ||
const char * | name | ||
) |
Check if DB connection exists in dblinks structure.
Map | pointer to Map_info structure |
field | layer number |
name | layer name |
Definition at line 229 of file field.c.
References Map_info::dblnk, and Vect_check_dblink().
int Vect_map_del_dblink | ( | struct Map_info * | Map, |
int | field | ||
) |
Delete db connection from Map_info structure.
Map | pointer to Map_info structure |
field | layer number (-1 to delete all dblinks) |
Definition at line 153 of file field.c.
References _, field_info::database, Map_info::dblnk, field_info::driver, dblinks::field, G_debug(), G_warning(), field_info::key, dblinks::n_fields, field_info::name, field_info::number, field_info::table, and Vect_write_dblinks().
Referenced by Vect_close().
struct dblinks* Vect_new_dblinks_struct | ( | void | ) |
int Vect_read_dblinks | ( | struct Map_info * | Map | ) |
Read dblinks to existing structure.
Variables are not substituted by values.
Map | pointer to Map_info structure |
Definition at line 921 of file field.c.
References Map_info::dblnk, Map_info::format, G_debug(), GV_FORMAT_NATIVE, Map_info::mapset, Map_info::name, and Vect_reset_dblinks().
void Vect_reset_dblinks | ( | struct dblinks * | p | ) |
Reset dblinks structure (number of fields)
p | pointer to existing dblinks structure |
Definition at line 94 of file field.c.
References dblinks::n_fields.
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.
Map | pointer to Map_info structure |
Definition at line 1062 of file field.c.
References _, G_fatal_error(), G_mapset(), G_strcasecmp(), Map_info::mapset, and Vect_write_dblinks().
char* Vect_subst_var | ( | const char * | in, |
const struct Map_info * | Map | ||
) |
Substitute variable in string.
in | current string |
Map | pointer to Map_info structure |
Definition at line 1004 of file field.c.
Referenced by Vect_get_dblink().
int Vect_write_dblinks | ( | struct Map_info * | Map | ) |
Write dblinks to file.
Map | pointer to Map_info structure |
Definition at line 952 of file field.c.
References _, field_info::database, Map_info::dblnk, field_info::driver, dblinks::field, Map_info::format, G_debug(), G_fopen_new(), G_warning(), GPATH_MAX, GV_DBLN_ELEMENT, GV_FORMAT_NATIVE, field_info::key, Map_info::mapset, dblinks::n_fields, field_info::name, Map_info::name, NULL, field_info::number, field_info::table, Vect__get_path(), and Vect_get_name().
Referenced by V1_close_nat(), Vect_map_del_dblink(), and Vect_set_db_updated().