GRASS GIS 7 Programmer's Manual  7.9.dev(2021)-e5379bbd7
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

◆ Vect__delete()

int Vect__delete ( const char *  map,
int  is_tmp 
)

Delete vector map (internal use only)

Parameters
mapname of vector map to be delete
is_tmpTRUE for temporary maps
Returns
-1 error
0 success

Definition at line 384 of file map.c.

References GMAPSET_MAX, GNAME_MAX, and GPATH_MAX.

Referenced by Vect_delete().

◆ Vect_copy()

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 124 of file map.c.

References _, 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_FRMT_ELEMENT, GV_HEAD_ELEMENT, GV_HIST_ELEMENT, GV_SIDX_ELEMENT, GV_TOPO_ELEMENT, NULL, Vect_delete(), and Vect_legal_filename().

Referenced by M_do_copy().

◆ Vect_delete()

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 370 of file map.c.

References FALSE, and Vect__delete().

Referenced by M_do_remove(), and Vect_copy().

◆ Vect_destroy_map_struct()

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().

◆ Vect_new_map_struct()

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.

◆ Vect_rename()

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 234 of file map.c.

Referenced by M_do_rename().

◆ Vect_set_category_index_update()

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 560 of file map.c.

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

◆ Vect_set_release_support()

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 544 of file map.c.

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