GRASS Programmer's Manual  6.5.svn(2014)-r66266
 All Data Structures Namespaces Files Functions Variables Typedefs Enumerations Enumerator Macros Pages
map.c File Reference

Vector library - Manipulate with vector map. More...

#include <stdlib.h>
#include <stdio.h>
#include <dirent.h>
#include <string.h>
#include <unistd.h>
#include <sys/types.h>
#include <sys/stat.h>
#include <fcntl.h>
#include <grass/glocale.h>
#include <grass/gis.h>
#include <grass/Vect.h>
#include <grass/dbmi.h>
Include dependency graph for map.c:

Go to the source code of this file.

Functions

int Vect_copy_map_lines (struct Map_info *In, struct Map_info *Out)
 Copy all alive elements of opened vector map to another opened vector map. More...
 
int Vect_copy (const char *in, const char *mapset, const char *out)
 Copy a map including attribute tables. More...
 
int Vect_rename (const char *in, const char *out)
 Rename a map. More...
 
int Vect_delete (const char *map)
 Delete vector map including attribute tables. More...
 
int Vect_copy_tables (struct Map_info *In, struct Map_info *Out, int field)
 Copy tables linked to vector map. More...
 
int Vect_copy_table (struct Map_info *In, struct Map_info *Out, int field_in, int field_out, const char *field_name, int type)
 Copy table linked to vector map based on type. More...
 
int Vect_copy_table_by_cats (struct Map_info *In, struct Map_info *Out, int field_in, int field_out, const char *field_name, int type, int *cats, int ncats)
 Copy table linked to vector map based on category numbers. More...
 
void Vect_set_release_support (struct Map_info *Map)
 Set spatial index to be realease when vector is closed. More...
 
void Vect_set_category_index_update (struct Map_info *Map)
 By default, category index is not updated if vector is changed, this function sets category index update. More...
 

Detailed Description

Vector library - Manipulate with vector map.

Higher level functions for reading/writing/manipulating vectors.

(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 map.c.

Function Documentation

int Vect_copy ( const char *  in,
const char *  mapset,
const char *  out 
)
int Vect_copy_map_lines ( struct Map_info *  In,
struct Map_info *  Out 
)

Copy all alive elements of opened vector map to another opened vector map.

Parameters
[in]Ininput vector map
[out]Outoutput vector map
Returns
0 on success
1 on error

Definition at line 44 of file map.c.

References G_fatal_error(), G_warning(), dialogs::type, Vect_destroy_cats_struct(), Vect_destroy_line_struct(), Vect_get_full_name(), Vect_get_num_lines(), Vect_level(), Vect_line_alive(), Vect_new_cats_struct(), Vect_new_line_struct(), Vect_read_line(), Vect_read_next_line(), Vect_rewind(), and Vect_write_line().

int Vect_copy_table ( struct Map_info *  In,
struct Map_info *  Out,
int  field_in,
int  field_out,
const char *  field_name,
int  type 
)

Copy table linked to vector map based on type.

Parameters
[in]Ininput vector map
[out]Outoutput vector map
[in]field_ininput layer number
[in]field_outoutput layer number
[in]field_namelayer name
[in]typefeature type
Returns
0 on success
-1 on error

Definition at line 650 of file map.c.

References NULL, and Vect_copy_table_by_cats().

int Vect_copy_table_by_cats ( struct Map_info *  In,
struct Map_info *  Out,
int  field_in,
int  field_out,
const char *  field_name,
int  type,
int cats,
int  ncats 
)

Copy table linked to vector map based on category numbers.

Parameters
[in]Ininput vector map
[out]Outoutput vector map
[in]field_ininput layer number
[in]field_outoutput layer number
[in]field_namelayer name
[in]typefeature type
[in]catspointer to array of cats or NULL
[in]ncatsnumber of cats in 'cats'
Returns
0 on success
-1 on error

Definition at line 673 of file map.c.

References db_copy_table_by_ints(), G_debug(), G_warning(), render::name, NULL, Vect_default_field_info(), Vect_get_field(), Vect_map_add_dblink(), and Vect_subst_var().

Referenced by Vect_copy_table().

int Vect_copy_tables ( struct Map_info *  In,
struct Map_info *  Out,
int  field 
)

Copy tables linked to vector map.

All if field = 0, or table defined by given field if field > 0 Notice, that if input map has no tables defined, it will copy nothing and return 0 (success).

Parameters
[in]Ininput vector map
[out]Outoutput vector map
[in]fieldlayer number
Returns
0 on success
-1 on error

Definition at line 571 of file map.c.

References db_close_database_shutdown_driver(), db_copy_table(), db_create_index2(), db_start_driver_open_database(), driver, G_debug(), G_warning(), n, NULL, dialogs::type, Vect_default_field_info(), Vect_get_dblink(), Vect_get_num_dblinks(), Vect_map_add_dblink(), and Vect_subst_var().

int Vect_delete ( const char *  map)

Delete vector map including attribute tables.

Parameters
[in]mapvector map name
Returns
-1 error
0 success

Definition at line 431 of file map.c.

References db_delete_table(), db_table_exists(), G_debug(), G_gisdbase(), G_location(), G_location_path(), G_mapset(), G_tempfile(), G_warning(), n, NULL, opendir(), readdir(), sprintf(), Vect_close(), Vect_get_dblink(), Vect_get_num_dblinks(), Vect_open_old_head(), and Vect_set_open_level().

Referenced by Vect_copy(), Vect_open_new(), and Vect_rename().

int Vect_rename ( const char *  in,
const char *  out 
)

Rename a map.

Attribute tables are created in the same database where input tables were stored.

The original format (native/OGR) is used. Old map ('out') is deleted!!!

Parameters
[in]ininput vector map name
[in]outoutput vector map name
Returns
-1 error
0 success

Definition at line 303 of file map.c.

References db_close_database_shutdown_driver(), db_copy_table(), db_create_index2(), db_delete_table(), db_start_driver_open_database(), driver, free(), G_debug(), G_fatal_error(), G_find_vector2(), G_mapset(), G_rename(), G_warning(), n, NULL, dialogs::type, Vect_close(), Vect_default_field_info(), Vect_delete(), Vect_get_dblink(), Vect_get_field(), Vect_get_num_dblinks(), Vect_legal_filename(), Vect_map_add_dblink(), Vect_map_del_dblink(), Vect_open_update_head(), Vect_set_open_level(), and Vect_subst_var().

void Vect_set_category_index_update ( struct Map_info *  Map)

By default, category index is not updated if vector is changed, this function sets category index update.

WARNING: currently only category for elements is updated not for areas

Parameters
Mapvector map
Returns

Definition at line 751 of file map.c.

void Vect_set_release_support ( struct Map_info *  Map)

Set spatial index to be realease when vector is closed.

By default, the memory occupied by spatial index is not released.

Parameters
Mapvector map
Returns

Definition at line 736 of file map.c.