GRASS Programmer's Manual  6.5.svn(2014)-r66266
 All Data Structures Namespaces Files Functions Variables Typedefs Enumerations Enumerator Macros Pages
vector/Vlib/open.c File Reference
#include <stdlib.h>
#include <stdio.h>
#include <string.h>
#include <unistd.h>
#include <sys/types.h>
#include <sys/stat.h>
#include <grass/glocale.h>
#include <grass/gis.h>
#include <grass/Vect.h>
Include dependency graph for vector/Vlib/open.c:

Go to the source code of this file.

Macros

#define MAX_OPEN_LEVEL   2
 

Functions

int Vect_set_open_level (int level)
 Predetermine level at which a map will be opened for reading. More...
 
int Vect__open_old (struct Map_info *Map, const char *name, const char *mapset, int update, int head_only)
 Open old vector for reading. More...
 
int Vect_open_old (struct Map_info *Map, const char *name, const char *mapset)
 Open existing vector for reading. More...
 
int Vect_open_update (struct Map_info *Map, const char *name, const char *mapset)
 Open existing vector for reading/writing. More...
 
int Vect_open_old_head (struct Map_info *Map, const char *name, const char *mapset)
 Reads only info about vector from headers of 'head', 'dbln', 'topo' and 'cidx' file. More...
 
int Vect_open_update_head (struct Map_info *Map, const char *name, const char *mapset)
 Open old vector head for updating (mostly for database link updates) More...
 
int Vect_open_new (struct Map_info *Map, const char *name, int with_z)
 Open new vector for reading/writing. More...
 
int Vect_coor_info (struct Map_info *Map, struct Coor_info *Info)
 Update Coor_info structure. More...
 
const char * Vect_maptype_info (struct Map_info *Map)
 Gets maptype (native, shape, postgis) More...
 
int Vect_open_topo (struct Map_info *Map, int head_only)
 Open topo file. More...
 
int Vect_open_spatial_index (struct Map_info *Map)
 Open spatial index file. More...
 

Macro Definition Documentation

#define MAX_OPEN_LEVEL   2

Definition at line 30 of file vector/Vlib/open.c.

Referenced by Vect_set_open_level().

Function Documentation

int Vect__open_old ( struct Map_info *  Map,
const char *  name,
const char *  mapset,
int  update,
int  head_only 
)

Open old vector for reading.

In case of error, the functions respect fatal error settings.

Parameters
[out]Mapvector map
[in]namename of vector map to open
[in]mapsetmapset name
[in]updateopen for update
[in]head_onlyread only header info from 'head', 'dbln', 'topo', 'cidx' is not opened. The header may be opened on level 2 only.
Returns
level of openness (1, 2)
-1 in error

Definition at line 125 of file vector/Vlib/open.c.

References buf, buf2, dig_cidx_free(), dig_free_plus(), dig_init_plus(), dig_read_frmt_ascii(), dig_spidx_free(), fclose(), G__file_name(), G__name_is_fully_qualified(), G_debug(), G_fatal_error(), G_find_vector2(), G_fopen_modify(), G_fopen_old(), G_gisdbase(), G_location(), G_mapset(), G_store(), G_warning(), NULL, sprintf(), stat, V2_open_old_ogr(), Vect__init_head(), Vect__read_head(), Vect_cidx_open(), Vect_get_fatal_error(), Vect_get_full_name(), Vect_hist_write(), Vect_new_dblinks_struct(), Vect_open_topo(), Vect_read_dblinks(), Vect_rewind(), Vect_set_fatal_error(), xmapset, and xname.

Referenced by Vect_open_old(), Vect_open_old_head(), Vect_open_update(), and Vect_open_update_head().

int Vect_coor_info ( struct Map_info *  Map,
struct Coor_info *  Info 
)

Update Coor_info structure.

Parameters
[in]Mapvector map
[out]InfoCoor_info structure
Returns
1 on success
0 on error

Definition at line 611 of file vector/Vlib/open.c.

References buf, dig_fseek(), dig_ftell(), G__file_name(), G_debug(), G_warning(), sprintf(), and stat.

Referenced by V1_close_nat(), Vect_close(), and Vect_open_topo().

const char* Vect_maptype_info ( struct Map_info *  Map)

Gets maptype (native, shape, postgis)

Parameters
[in]Mapvector map
Returns
maptype string on success
error message on error

Definition at line 659 of file vector/Vlib/open.c.

References G_store(), manager::maptype, and sprintf().

int Vect_open_new ( struct Map_info *  Map,
const char *  name,
int  with_z 
)

Open new vector for reading/writing.

Parameters
[out]Mapvector map
[in]namename of vector map
[in]with_z2D/3D vector map
Returns
1 on success
-1 on error

Definition at line 517 of file vector/Vlib/open.c.

References buf, dig_init_plus(), G__name_is_fully_qualified(), G_debug(), G_find_file2(), G_fopen_new(), G_gisdbase(), G_location(), G_mapset(), G_store(), G_warning(), NULL, sprintf(), V1_open_new_nat(), Vect__init_head(), Vect_delete(), Vect_get_fatal_error(), Vect_get_full_name(), Vect_legal_filename(), Vect_new_dblinks_struct(), Vect_set_fatal_error(), xmapset, and xname.

Referenced by G_sites_open_new().

int Vect_open_old ( struct Map_info *  Map,
const char *  name,
const char *  mapset 
)

Open existing vector for reading.

In case of error, the functions respect fatal error settings.

Parameters
[out]Mapvector map
[in]namename of vector map
[in]mapsetmapset name
Returns
level of openness [1, 2, (3)]
-1 on error

Definition at line 413 of file vector/Vlib/open.c.

References Vect__open_old().

Referenced by G_sites_open_old(), Gp_load_sites(), Gv_load_vect(), wxdigit.IVDigit::OpenBackgroundMap(), and wxdisplay.DisplayDriver::OpenMap().

int Vect_open_old_head ( struct Map_info *  Map,
const char *  name,
const char *  mapset 
)

Reads only info about vector from headers of 'head', 'dbln', 'topo' and 'cidx' file.

In case of error, the functions respect fatal error settings.

Parameters
[out]Mapvector map
[in]namename of vector map to read
[in]mapsetmapset name
Returns
level of openness [1, 2, (3)]
-1 on error

Definition at line 468 of file vector/Vlib/open.c.

References Vect__open_old().

Referenced by Vect_copy(), and Vect_delete().

int Vect_open_spatial_index ( struct Map_info *  Map)

Open spatial index file.

Parameters
[in,out]Mapvector map
Returns
0 on success
-1 on error

Definition at line 770 of file vector/Vlib/open.c.

References buf, dig_file_init(), dig_read_spidx(), dig_spidx_init(), fclose(), G_debug(), G_fopen_old(), NULL, and sprintf().

int Vect_open_topo ( struct Map_info *  Map,
int  head_only 
)

Open topo file.

Parameters
[in,out]Mapvector map
[in]head_onlyopen only head
Returns
0 on success
1 file does not exist
-1 on error

Definition at line 689 of file vector/Vlib/open.c.

References buf, dig_file_init(), dig_load_plus(), dig_Rd_Plus_head(), err, fclose(), G__file_name(), G_debug(), G_fopen_old(), G_warning(), NULL, sprintf(), stat, and Vect_coor_info().

Referenced by Vect__open_old().

int Vect_open_update ( struct Map_info *  Map,
const char *  name,
const char *  mapset 
)

Open existing vector for reading/writing.

In case of error, the functions respect fatal error settings.

Parameters
[out]Mapvector map
[in]namename of vector map to update
[in]mapsetmapset name
Returns
level of openness [1, 2, (3)]
-1 on error

Definition at line 431 of file vector/Vlib/open.c.

References NULL, Vect__open_old(), and Vect_build_sidx_from_topo().

Referenced by wxdisplay.DisplayDriver::OpenMap().

int Vect_open_update_head ( struct Map_info *  Map,
const char *  name,
const char *  mapset 
)

Open old vector head for updating (mostly for database link updates)

In case of error, the functions respect fatal error settings.

Parameters
[out]Mapvector map
[in]namename of vector map to update
[in]mapsetmapset name
Returns
level of openness [1, 2, (3)]
-1 on error

Definition at line 486 of file vector/Vlib/open.c.

References NULL, and Vect__open_old().

Referenced by Vect_copy(), and Vect_rename().

int Vect_set_open_level ( int  level)

Predetermine level at which a map will be opened for reading.

If it can't open that level, the open will fail. The specified level must be set before any call to open. The default is to try to open the highest level possible, and keep stepping down until success.

NOTE!! This should only be used to set when you wish to force a lower level open. If you require a higher level, then just check the return to verify the level instead of forcing it. This is because future releases will have higher levels which will be downward compatible and which your programs should support by default.

Parameters
[in]levelvector (topo) level
Returns
0 on success
1 on error

Definition at line 96 of file vector/Vlib/open.c.

References G_warning(), and MAX_OPEN_LEVEL.

Referenced by G_sites_open_old(), Gp_load_sites(), Gv_load_vect(), Vect_copy(), Vect_delete(), and Vect_rename().