|
GRASS 8 Programmer's Manual 8.6.0dev(2026)-ddeab64dbf
|
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.
Macros | |
| #define | NOPG_UNUSED |
Functions | |
| struct dblinks * | Vect_new_dblinks_struct (void) |
| Create and init new dblinks structure. | |
| void | Vect_reset_dblinks (struct dblinks *p) |
| Reset dblinks structure (number of fields) | |
| 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. | |
| void | Vect_copy_map_dblinks (struct Map_info *In, struct Map_info *Out, int first_only) |
| Copy DB links from input vector map to output vector map. | |
| int | Vect_map_check_dblink (struct Map_info *Map, int field, const char *name) |
| Check if DB connection exists in dblinks structure. | |
| int | Vect_check_dblink (const struct dblinks *p, int field, const char *name) |
| 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 (by layer number) | |
| struct field_info * | Vect_get_field_by_name (struct Map_info *Map, const char *field) |
| Get information about link to database (by layer name) | |
| struct field_info * | Vect_get_field2 (struct Map_info *Map, const char *field) |
| Get information about link to database (by layer number or layer name) | |
| int | Vect_get_field_number (struct Map_info *Map, const char *field) |
| Get field number of given field. | |
| void | Vect_destroy_field_info (struct field_info *fi) |
| Free a struct field_info and all memory associated with it. | |
| 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. | |
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, ...) |
Definition at line 280 of file field.c.
References _, dblinks::alloc_fields, dblinks::field, G_debug(), G_free(), G_realloc, G_store(), G_warning(), field_info::key, dblinks::n_fields, AMI_STREAM< T >::name(), name, NULL, field_info::number, field_info::table, and Vect_check_dblink().
Referenced by V1_close_nat(), and Vect_map_add_dblink().
Check if DB connection exists in dblinks structure.
| p | pointer to existing dblinks structure |
| field | layer number |
| name | layer name |
Definition at line 247 of file field.c.
References dblinks::field, G_debug(), dblinks::n_fields, AMI_STREAM< T >::name(), name, and NULL.
Referenced by Vect_add_dblink(), and 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 200 of file field.c.
References _, G_warning(), AMI_STREAM< T >::name(), 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 |
Definition at line 353 of file field.c.
References _, field_info::database, DB_DEFAULT_DRIVER, db_get_connection(), db_set_default_connection(), field_info::driver, G_asprintf(), G_debug(), G_fatal_error(), G_free(), G_important_message(), G_malloc, G_store(), G_zero(), GNAME_MAX, GV_1TABLE, GV_FORMAT_OGR_DIRECT, GV_KEY_COLUMN, field_info::key, AMI_STREAM< T >::name(), field_info::name, NULL, field_info::number, field_info::table, and Vect__get_element_path().
Referenced by Vect_copy_table_by_cats(), and Vect_rename().
| void Vect_destroy_field_info | ( | struct field_info * | fi | ) |
Free a struct field_info and all memory associated with it.
| [in,out] | fi | pointer to field_info structure |
Definition at line 628 of file field.c.
References field_info::database, field_info::driver, G_free(), field_info::key, field_info::name, NULL, and field_info::table.
Referenced by Gp_load_sites_thematic(), NetA_get_node_costs(), NetA_init_timetable_from_db(), Vect_copy_table_by_cats(), Vect_copy_tables(), Vect_get_column_names(), Vect_get_column_names_types(), Vect_get_column_types(), Vect_net_build_graph(), Vect_net_ttb_build_graph(), Vect_set_varray_from_db(), and Vect_write_ascii().
| struct field_info * Vect_get_dblink | ( | 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 470 of file field.c.
References _, field_info::database, field_info::driver, G_debug(), G_malloc, G_store(), G_warning(), field_info::key, AMI_STREAM< T >::name(), field_info::name, NULL, field_info::number, field_info::table, and Vect_subst_var().
Referenced by V1_close_nat(), Vect__delete(), Vect_copy_map_dblinks(), Vect_copy_tables(), Vect_get_field(), Vect_get_field2(), Vect_get_field_by_name(), and Vect_rename().
| struct field_info * Vect_get_field | ( | 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 510 of file field.c.
References G_debug(), NULL, and Vect_get_dblink().
Referenced by Gp_load_sites_thematic(), Gv_load_vect_thematic(), IL_vector_input_data_2d(), NetA_get_node_costs(), NetA_init_timetable_from_db(), Vect_cats_set_constraint(), Vect_copy_table_by_cats(), Vect_get_column_names(), Vect_get_column_names_types(), Vect_get_column_types(), Vect_get_field2(), Vect_net_build_graph(), Vect_net_ttb_build_graph(), Vect_rename(), Vect_set_varray_from_db(), and Vect_write_ascii().
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 566 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().
Get information about link to database (by layer name)
| Map | pointer to Map_info structure |
| field | layer name |
Definition at line 536 of file field.c.
References G_debug(), AMI_STREAM< T >::name(), NULL, and Vect_get_dblink().
Referenced by Vect_get_field2().
Get field number of given field.
| Map | pointer to Map_info structure |
| field | layer name |
Definition at line 603 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 115 of file field.c.
References _, G_warning(), GV_MODE_RW, GV_MODE_WRITE, name, Vect_add_dblink(), and Vect_write_dblinks().
Referenced by Vect_copy_map_dblinks(), Vect_copy_table_by_cats(), and Vect_rename().
Check if DB connection exists in dblinks structure.
| Map | pointer to Map_info structure |
| field | layer number |
| name | layer name |
Definition at line 232 of file field.c.
References name, and Vect_check_dblink().
Delete db connection from Map_info structure.
| Map | pointer to Map_info structure |
| field | layer number (-1 to delete all dblinks) |
Definition at line 155 of file field.c.
References _, dblinks::field, G_debug(), G_warning(), AMI_STREAM< T >::name(), and Vect_write_dblinks().
Referenced by Vect_close(), and Vect_rename().
Create and init new dblinks structure.
Definition at line 47 of file field.c.
References G_malloc, and G_zero().
Referenced by V1_close_nat(), and Vect__open_old().
Read dblinks to existing structure.
Variables are not substituted by values.
| Map | pointer to Map_info structure |
Definition at line 837 of file field.c.
References _, G_debug(), G_fatal_error(), GV_FORMAT_NATIVE, GV_FORMAT_OGR, GV_FORMAT_OGR_DIRECT, GV_FORMAT_POSTGIS, AMI_STREAM< T >::name(), and Vect_reset_dblinks().
Referenced by Vect__open_old().
Reset dblinks structure (number of fields)
| p | pointer to existing dblinks structure |
Definition at line 96 of file field.c.
References dblinks::n_fields.
Referenced by Vect_read_dblinks().
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 982 of file field.c.
References _, G_fatal_error(), G_mapset(), G_strcasecmp(), and Vect_write_dblinks().
Substitute variable in string.
| in | current string |
| Map | pointer to Map_info structure |
Definition at line 923 of file field.c.
References G_debug(), G_free(), G_store(), G_str_replace(), AMI_STREAM< T >::name(), NULL, and strcpy.
Referenced by Vect_copy_table_by_cats(), Vect_get_dblink(), and Vect_rename().
Write dblinks to file.
| Map | pointer to Map_info structure |
Definition at line 869 of file field.c.
References _, dblinks::field, G_debug(), G_fopen_new(), G_warning(), GPATH_MAX, GV_DBLN_ELEMENT, GV_FORMAT_NATIVE, dblinks::n_fields, AMI_STREAM< T >::name(), NULL, Vect__get_path(), and Vect_get_name().
Referenced by V1_close_nat(), Vect_map_add_dblink(), Vect_map_del_dblink(), and Vect_set_db_updated().