GRASS GIS 7 Programmer's Manual  7.5.svn(2017)-r71759
 All Data Structures Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
vector/Vlib/rewind.c
Go to the documentation of this file.
1 /*!
2  \file lib/vector/Vlib/rewind.c
3 
4  \brief Vector library - rewind data
5 
6  Higher level functions for reading/writing/manipulating vectors.
7 
8  (C) 2001-2009, 2011-2012 by the GRASS Development Team
9 
10  This program is free software under the GNU General Public License
11  (>=v2). Read the file COPYING that comes with GRASS for details.
12 
13  \author Original author CERL, probably Dave Gerdes or Mike Higgins.
14  \author Update to GRASS 5.7 Radim Blazek and David D. Gray.
15  \author Level 3 by Martin Landa <landa.martin gmail.com>
16 */
17 
18 #include <grass/vector.h>
19 #include <grass/glocale.h>
20 
21 static int rew_dummy()
22 {
23  return -1;
24 }
25 
26 #if !defined HAVE_OGR || !defined HAVE_POSTGRES
27 static int format()
28 {
29  G_fatal_error(_("Requested format is not compiled in this version"));
30  return 0;
31 }
32 #endif
33 
34 
35 static int (*Rewind_array[][4]) () = {
36  {
37  rew_dummy, V1_rewind_nat, V2_rewind_nat, rew_dummy}
38 #ifdef HAVE_OGR
39  , {
40  rew_dummy, V1_rewind_ogr, V2_rewind_ogr, rew_dummy}
41  , {
42  rew_dummy, V1_rewind_ogr, V2_rewind_ogr, rew_dummy}
43 #else
44  , {
45  rew_dummy, format, format, rew_dummy}
46  , {
47  rew_dummy, format, format, rew_dummy}
48 #endif
49 #ifdef HAVE_POSTGRES
50  , {
51  rew_dummy, V1_rewind_pg, V2_rewind_pg, V2_rewind_pg}
52 #else
53  , {
54  rew_dummy, format, format, rew_dummy}
55 #endif
56 };
57 
58 /*!
59  \brief Rewind vector map to cause reads to start at beginning
60 
61  \param Map pointer to Map_info structure
62 
63  \return 0 on success
64  \return -1 on error
65  */
66 int Vect_rewind(struct Map_info *Map)
67 {
68  if (!VECT_OPEN(Map))
69  return -1;
70 
71  G_debug(1, "Vect_Rewind(): name = %s level = %d", Map->name, Map->level);
72 
73  return (*Rewind_array[Map->format][Map->level]) (Map);
74 }
int V1_rewind_nat(struct Map_info *Map)
Rewind vector map to cause reads to start at beginning on non-topological level (level 1) - native fo...
Definition: rewind_nat.c:27
char * name
Map name (for 4.0)
Definition: dig_structs.h:1332
int V1_rewind_pg(struct Map_info *Map)
Rewind vector map (PostGIS layer) to cause reads to start at beginning (level 1)
Definition: rewind_pg.c:34
int V2_rewind_ogr(struct Map_info *Map)
Rewind vector map (OGR layer) to cause reads to start at beginning on topological level (level 2) ...
Definition: rewind_ogr.c:61
int level
Topology level.
Definition: dig_structs.h:1313
void G_fatal_error(const char *msg,...)
Print a fatal error message to stderr.
Definition: gis/error.c:159
int V1_rewind_ogr(struct Map_info *Map)
Rewind vector map (OGR layer) to cause reads to start at beginning (level 1)
Definition: rewind_ogr.c:32
#define VECT_OPEN(Map)
Check if vector map is open.
Definition: dig_defines.h:136
int G_debug(int level, const char *msg,...)
Print debugging message.
Definition: debug.c:65
int V2_rewind_pg(struct Map_info *Map)
Rewind vector map (PostGIS layer) to cause reads to start at beginning on topological level (level 2)...
Definition: rewind_pg.c:70
int V2_rewind_nat(struct Map_info *Map)
Rewind vector map to cause reads to start at beginning on topological level (level 2) - native format...
Definition: rewind_nat.c:40
Vector map info.
Definition: dig_structs.h:1259
#define _(str)
Definition: glocale.h:13
int format
Map format (native, ogr, postgis)
Definition: dig_structs.h:1271
int
Reads the categories file for map name in mapset and stores the categories in the pcats structure...
int Vect_rewind(struct Map_info *Map)
Rewind vector map to cause reads to start at beginning.