GRASS 8 Programmer's Manual 8.6.0dev(2026)-c83afef6d3
Loading...
Searching...
No Matches
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 SPDX-FileCopyrightText: 2001-2009, 2011-2012 GRASS Development Team
9 SPDX-License-Identifier: GPL-2.0-or-later
10
11 \author Original author CERL, probably Dave Gerdes or Mike Higgins.
12 \author Update to GRASS 5.7 Radim Blazek and David D. Gray.
13 \author Level 3 by Martin Landa <landa.martin gmail.com>
14 */
15
16#include <grass/vector.h>
17#include <grass/glocale.h>
18
19static int rew_dummy(struct Map_info *Map G_UNUSED)
20{
21 return -1;
22}
23
24#if !defined HAVE_POSTGRES
25static int format(struct Map_info *Map G_UNUSED)
26{
27 G_fatal_error(_("Requested format is not compiled in this version"));
28 return 0;
29}
30#endif
31
32static int (*Rewind_array[][4])(struct Map_info *) = {
33 {rew_dummy, V1_rewind_nat, V2_rewind_nat, rew_dummy},
34 {rew_dummy, V1_rewind_ogr, V2_rewind_ogr, rew_dummy},
35 {rew_dummy, V1_rewind_ogr, V2_rewind_ogr, rew_dummy}
36#ifdef HAVE_POSTGRES
37 ,
39#else
40 ,
41 {rew_dummy, format, format, rew_dummy}
42#endif
43};
44
45/*!
46 \brief Rewind vector map to cause reads to start at beginning
47
48 \param Map pointer to Map_info structure
49
50 \return 0 on success
51 \return -1 on error
52 */
54{
55 if (!VECT_OPEN(Map))
56 return -1;
57
58 G_debug(1, "Vect_Rewind(): name = %s level = %d", Map->name, Map->level);
59
60 return (*Rewind_array[Map->format][Map->level])(Map);
61}
AMI_err name(char **stream_name)
Definition ami_stream.h:426
void void void void G_fatal_error(const char *,...) __attribute__((format(printf
int G_debug(int, const char *,...) __attribute__((format(printf
int V2_rewind_ogr(struct Map_info *)
Rewind vector map (OGR layer) to cause reads to start at beginning on topological level (level 2)
Definition rewind_ogr.c:52
int V2_rewind_nat(struct Map_info *)
Rewind vector map to cause reads to start at beginning on topological level (level 2) - native format...
Definition rewind_nat.c:38
int V1_rewind_nat(struct Map_info *)
Rewind vector map to cause reads to start at beginning on non-topological level (level 1) - native fo...
Definition rewind_nat.c:25
int V1_rewind_pg(struct Map_info *)
Rewind vector map (PostGIS layer) to cause reads to start at beginning (level 1)
Definition rewind_pg.c:32
int V1_rewind_ogr(struct Map_info *)
Rewind vector map (OGR layer) to cause reads to start at beginning (level 1)
Definition rewind_ogr.c:28
int V2_rewind_pg(struct Map_info *)
Rewind vector map (PostGIS layer) to cause reads to start at beginning on topological level (level 2)
Definition rewind_pg.c:68
#define VECT_OPEN(Map)
Check if vector map is open.
#define G_UNUSED
A macro for an attribute, if attached to a variable, indicating that the variable is not used.
Definition gis.h:43
#define _(str)
Definition glocale.h:10
Vector map info.
int format
Map format (native, ogr, postgis)
int Vect_rewind(struct Map_info *Map)
Rewind vector map to cause reads to start at beginning.