GRASS GIS 7 Programmer's Manual  7.5.svn(2017)-r71942
 All Data Structures Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
map.c File Reference

Vector library - Manipulate vector map (copy, rename, delete) 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 <errno.h>
#include <grass/glocale.h>
#include <grass/vector.h>
#include <grass/dbmi.h>
#include "local_proto.h"
Include dependency graph for map.c:

Go to the source code of this file.

Functions

struct Map_infoVect_new_map_struct (void)
 Creates and initializes Map_info structure. More...
 
void Vect_destroy_map_struct (struct Map_info *p)
 Frees all memory associated with a Map_info structure, including the structure itself. More...
 
int Vect_copy (const char *in, const char *mapset, const char *out)
 Copy vector map including attribute tables. More...
 
int Vect_rename (const char *in, const char *out)
 Rename existing vector map (in the current mapset). More...
 
int Vect_delete (const char *map)
 Delete vector map including attribute tables. More...
 
int Vect__delete (const char *map, int is_tmp)
 Delete vector map (internal use only) 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)
 Set category index to be updated when vector is changed. More...
 

Detailed Description

Vector library - Manipulate vector map (copy, rename, delete)

Higher level functions for reading/writing/manipulating vectors.

(C) 2001-2009, 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.

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

Definition in file map.c.

Function Documentation

int Vect__delete ( const char *  map,
int  is_tmp 
)
int Vect_copy ( const char *  in,
const char *  mapset,
const char *  out 
)

Copy vector map including attribute tables.

Note: Output vector map is overwritten if exists!

Parameters
inname if vector map to be copied
mapsetmapset name where the input map is located
outname for output vector map (new map is created in current mapset)
Returns
-1 error
0 success

Definition at line 123 of file map.c.

References _, Map_info::format, G_debug(), G_fatal_error(), G_file_name(), G_find_vector2(), G_make_mapset_element(), G_mapset(), G_name_is_fully_qualified(), G_warning(), GMAPSET_MAX, GNAME_MAX, GPATH_MAX, GV_CIDX_ELEMENT, GV_COOR_ELEMENT, GV_DIRECTORY, GV_FORMAT_NATIVE, GV_FRMT_ELEMENT, GV_HEAD_ELEMENT, GV_HIST_ELEMENT, GV_SIDX_ELEMENT, GV_TOPO_ELEMENT, NULL, Vect_close(), Vect_copy_tables(), Vect_delete(), Vect_legal_filename(), Vect_open_old_head(), Vect_open_update_head(), and Vect_set_open_level().

Referenced by M_do_copy().

int Vect_delete ( const char *  map)

Delete vector map including attribute tables.

Vector map must be located in current mapset.

Parameters
mapname of vector map to be delete
Returns
-1 error
0 success

Definition at line 369 of file map.c.

References FALSE, and Vect__delete().

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

void Vect_destroy_map_struct ( struct Map_info p)

Frees all memory associated with a Map_info structure, including the structure itself.

Parameters
ppointer to Map_info structure

Definition at line 61 of file map.c.

References G_free().

struct Map_info* Vect_new_map_struct ( void  )

Creates and initializes Map_info structure.

To free allocated memory call Vect_destroy_map_struct().

Returns
pointer to Map_info

Definition at line 41 of file map.c.

References _, G_fatal_error(), G_zero(), malloc(), and NULL.

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

Rename existing vector map (in the current mapset).

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

The origial format (native/OGR) is used.

Note: Output vector map is overwritten if exists!

Parameters
inname of vector map to be renamed
outname for output vector map
Returns
-1 error
0 success

Definition at line 233 of file map.c.

References _, field_info::database, db_close_database_shutdown_driver(), db_copy_table(), db_create_index2(), db_delete_table(), DB_FAILED, DB_OK, db_start_driver_open_database(), driver, field_info::driver, Map_info::format, free(), G_debug(), G_fatal_error(), G_find_vector2(), G_mapset(), G_name_is_fully_qualified(), G_rename(), G_warning(), GMAPSET_MAX, GNAME_MAX, GV_1TABLE, GV_DIRECTORY, GV_FORMAT_NATIVE, GV_MTABLE, field_info::key, field_info::name, NULL, field_info::number, field_info::table, Map_info::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().

Referenced by M_do_rename().

void Vect_set_category_index_update ( struct Map_info Map)

Set category index to be updated when vector is changed.

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

Definition at line 559 of file map.c.

References Map_info::plus, TRUE, and Plus_head::update_cidx.

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

Definition at line 543 of file map.c.

References Map_info::plus, Plus_head::release_support, and TRUE.