~ubuntu-branches/ubuntu/wily/grass/wily

« back to all changes in this revision

Viewing changes to lib/vector/Vlib/rewind_pg.c

Tags: 7.0.0~rc1+ds1-1~exp1
* New upstream release candidate.
* Repack upstream tarball, remove precompiled Python objects.
* Add upstream metadata.
* Update gbp.conf and Vcs-Git URL to use the experimental branch.
* Update watch file for GRASS 7.0.
* Drop build dependencies for Tcl/Tk, add build dependencies:
  python-numpy, libnetcdf-dev, netcdf-bin, libblas-dev, liblapack-dev
* Update Vcs-Browser URL to use cgit instead of gitweb.
* Update paths to use grass70.
* Add configure options: --with-netcdf, --with-blas, --with-lapack,
  remove --with-tcltk-includes.
* Update patches for GRASS 7.
* Update copyright file, changes:
  - Update copyright years
  - Group files by license
  - Remove unused license sections
* Add patches for various typos.
* Fix desktop file with patch instead of d/rules.
* Use minimal dh rules.
* Bump Standards-Version to 3.9.6, no changes.
* Use dpkg-maintscript-helper to replace directories with symlinks.
  (closes: #776349)
* Update my email to use @debian.org address.

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
/*!
 
2
   \file lib/vector/Vlib/rewind_pg.c
 
3
 
 
4
   \brief Vector library - rewind data (PostGIS layers)
 
5
 
 
6
   Higher level functions for reading/writing/manipulating vectors.
 
7
 
 
8
   (C) 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 Martin Landa <landa.martin gmail.com>
 
14
 */
 
15
 
 
16
#include <grass/vector.h>
 
17
#include <grass/glocale.h>
 
18
 
 
19
#include "local_proto.h"
 
20
 
 
21
#ifdef HAVE_POSTGRES
 
22
#include "pg_local_proto.h"
 
23
#endif
 
24
 
 
25
/*! 
 
26
   \brief Rewind vector map (PostGIS layer) to cause reads to start
 
27
   at beginning (level 1)
 
28
 
 
29
   \param Map pointer to Map_info structure
 
30
 
 
31
   \return 0 on success
 
32
   \return -1 on error
 
33
 */
 
34
int V1_rewind_pg(struct Map_info *Map)
 
35
{
 
36
    G_debug(2, "V1_rewind_pg(): name = %s", Map->name);
 
37
 
 
38
#ifdef HAVE_POSTGRES
 
39
    struct Format_info_pg *pg_info;
 
40
 
 
41
    pg_info = &(Map->fInfo.pg);
 
42
 
 
43
    /* reset reading */
 
44
    pg_info->next_line = 0;
 
45
 
 
46
    /* reset cache */
 
47
    if (pg_info->cache.ctype != CACHE_MAP) {
 
48
        pg_info->cache.lines_num = 0;
 
49
        pg_info->cache.fid = -1;
 
50
    }
 
51
    pg_info->cache.lines_next = 0;
 
52
 
 
53
    /* close DB cursor if necessary */
 
54
    return Vect__close_cursor_pg(pg_info);
 
55
#else
 
56
    G_fatal_error(_("GRASS is not compiled with PostgreSQL support"));
 
57
    return -1;
 
58
#endif
 
59
}
 
60
 
 
61
/*!
 
62
   \brief Rewind vector map (PostGIS layer) to cause reads to start
 
63
   at beginning on topological level (level 2)
 
64
 
 
65
   \param Map pointer to Map_info structure
 
66
 
 
67
   \return 0 on success
 
68
   \return -1 on error
 
69
 */
 
70
int V2_rewind_pg(struct Map_info *Map)
 
71
{
 
72
    G_debug(2, "V2_rewind_pg(): name = %s", Map->name);
 
73
#ifdef HAVE_POSTGRES
 
74
    /* reset reading */
 
75
    Map->next_line = 1;
 
76
    
 
77
    V1_rewind_pg(Map);
 
78
 
 
79
    return 0;
 
80
#else
 
81
    G_fatal_error(_("GRASS is not compiled with PostgreSQL support"));
 
82
    return -1;
 
83
#endif
 
84
}