open.c File Reference

Vector library - Open vector map. More...

#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 open.c:

Go to the source code of this file.

Defines

#define MAX_OPEN_LEVEL   2

Functions

int Vect_set_open_level (int level)
 Predetermine level at which a map will be opened for reading.
int Vect__open_old (struct Map_info *Map, const char *name, const char *mapset, int update, int head_only)
 Open old vector for reading.
int Vect_open_old (struct Map_info *Map, const char *name, const char *mapset)
 Open existing vector for reading.
int Vect_open_update (struct Map_info *Map, const char *name, const char *mapset)
 Open existing vector for reading/writing.
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.
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).
int Vect_open_new (struct Map_info *Map, const char *name, int with_z)
 Open new vector for reading/writing.
int Vect_coor_info (struct Map_info *Map, struct Coor_info *Info)
 Update Coor_info structure.
const char * Vect_maptype_info (struct Map_info *Map)
 Gets maptype (native, shape, postgis).
int Vect_open_topo (struct Map_info *Map, int head_only)
 Open topo file.
int Vect_open_spatial_index (struct Map_info *Map)
 Open spatial index file.


Detailed Description

Vector library - Open 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 open.c.


Define Documentation

#define MAX_OPEN_LEVEL   2

Definition at line 30 of file 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] Map vector map
[in] name name of vector map to open
[in] mapset mapset name
[in] update open for update
[in] head_only read 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 open.c.

References dig_cidx_free(), dig_free_plus(), dig_init_plus(), dig_read_frmt_ascii(), dig_spidx_free(), Node::level, 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(), and Vect_set_fatal_error().

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] Map vector map
[out] Info Coor_info structure
Returns:
1 on success

0 on error

Definition at line 611 of file open.c.

References dig_fseek(), and dig_ftell().

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] Map vector map
Returns:
maptype string on success

error message on error

Definition at line 659 of file open.c.

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

Open new vector for reading/writing.

Parameters:
[out] Map vector map
[in] name name of vector map
[in] with_z 2D/3D vector map
Returns:
1 on success

-1 on error

Definition at line 517 of file open.c.

References dig_init_plus(), V1_open_new_nat(), Vect__init_head(), Vect_delete(), Vect_get_fatal_error(), Vect_get_full_name(), Vect_legal_filename(), Vect_new_dblinks_struct(), and Vect_set_fatal_error().

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] Map vector map
[in] name name of vector map
[in] mapset mapset name
Returns:
level of openness [1, 2, (3)]

-1 on error

Definition at line 413 of file open.c.

References Vect__open_old().

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] Map vector map
[in] name name of vector map to read
[in] mapset mapset name
Returns:
level of openness [1, 2, (3)]

-1 on error

Definition at line 468 of file 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] Map vector map
Returns:
0 on success

-1 on error

Definition at line 770 of file open.c.

References dig_file_init(), dig_read_spidx(), and dig_spidx_init().

int Vect_open_topo ( struct Map_info *  Map,
int  head_only 
)

Open topo file.

Parameters:
[in,out] Map vector map
[in] head_only open only head
Returns:
0 on success

1 file does not exist

-1 on error

Definition at line 689 of file open.c.

References dig_file_init(), dig_load_plus(), dig_Rd_Plus_head(), 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] Map vector map
[in] name name of vector map to update
[in] mapset mapset name
Returns:
level of openness [1, 2, (3)]

-1 on error

Definition at line 431 of file open.c.

References Vect__open_old(), and Vect_build_sidx_from_topo().

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] Map vector map
[in] name name of vector map to update
[in] mapset mapset name
Returns:
level of openness [1, 2, (3)]

-1 on error

Definition at line 486 of file open.c.

References 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] level vector (topo) level
Returns:
0 on success

1 on error

Definition at line 96 of file open.c.

References MAX_OPEN_LEVEL.

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


Generated on Thu Jul 16 13:21:27 2009 for GRASS Programmer's Manual by  doxygen 1.5.6