GRASS GIS 8 Programmer's Manual  8.5.0dev(2024)-602118adcc
rewind_ogr.c
Go to the documentation of this file.
1 /*!
2  \file lib/vector/Vlib/rewind_ogr.c
3 
4  \brief Vector library - rewind data (OGR)
5 
6  Higher level functions for reading/writing/manipulating vectors.
7 
8  (C) 2001-2009, 2011 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 Radim Blazek, Piero Cavalieri
14  */
15 
16 #include <grass/vector.h>
17 #include <grass/glocale.h>
18 
19 #ifdef HAVE_OGR
20 #include <ogr_api.h>
21 #endif
22 
23 /*!
24  \brief Rewind vector map (OGR layer) to cause reads to start at
25  beginning (level 1)
26 
27  \param Map pointer to Map_info structure
28 
29  \return 0 on success
30  \return -1 on error
31  */
32 int V1_rewind_ogr(struct Map_info *Map)
33 {
34  G_debug(2, "V1_rewind_ogr(): name = %s", Map->name);
35 #ifdef HAVE_OGR
36  struct Format_info_ogr *ogr_info;
37 
38  ogr_info = &(Map->fInfo.ogr);
39 
40  ogr_info->cache.lines_num = 0;
41  ogr_info->cache.lines_next = 0;
42 
43  OGR_L_ResetReading(ogr_info->layer);
44 
45  return 0;
46 #else
47  G_fatal_error(_("GRASS is not compiled with OGR support"));
48  return -1;
49 #endif
50 }
51 
52 /*!
53  \brief Rewind vector map (OGR layer) to cause reads to start at
54  beginning on topological level (level 2)
55 
56  \param Map pointer to Map_info structure
57 
58  \return 0 on success
59  \return -1 on error
60  */
61 int V2_rewind_ogr(struct Map_info *Map)
62 {
63  G_debug(2, "V2_rewind_ogr(): name = %s", Map->name);
64 #ifdef HAVE_OGR
65  Map->next_line = 1;
66 
67  V1_rewind_ogr(Map);
68 
69  return 0;
70 #else
71  G_fatal_error(_("GRASS is not compiled with OGR support"));
72  return -1;
73 #endif
74 }
void void void void G_fatal_error(const char *,...) __attribute__((format(printf
int G_debug(int, const char *,...) __attribute__((format(printf
#define _(str)
Definition: glocale.h:10
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
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 lines_next
Next line to be read from cache.
Definition: dig_structs.h:482
int lines_num
Number of lines which forms current feature.
Definition: dig_structs.h:478
Non-native format info (OGR)
Definition: dig_structs.h:505
OGRLayerH layer
Pointer to OGRLayer.
Definition: dig_structs.h:534
struct Format_info_cache cache
Lines cache for reading feature.
Definition: dig_structs.h:561
struct Format_info_ogr ogr
OGR info.
Definition: dig_structs.h:708
Vector map info.
Definition: dig_structs.h:1243
char * name
Map name (for 4.0)
Definition: dig_structs.h:1316
plus_t next_line
Feature id for sequential access.
Definition: dig_structs.h:1338
struct Format_info fInfo
Format info for non-native formats.
Definition: dig_structs.h:1400