GRASS GIS 7 Programmer's Manual  7.5.svn(2017)-r71933
 All Data Structures Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
read_pg.c File Reference

Vector library - reading features (PostGIS format) More...

#include <stdlib.h>
#include <string.h>
#include <limits.h>
#include <grass/vector.h>
#include <grass/dbmi.h>
#include <grass/glocale.h>
#include "local_proto.h"
Include dependency graph for read_pg.c:

Go to the source code of this file.

Functions

int V1_read_next_line_pg (struct Map_info *Map, struct line_pnts *line_p, struct line_cats *line_c)
 Read next feature from PostGIS layer. Skip empty features (level 1 without topology). t This function implements sequential access. More...
 
int V2_read_next_line_pg (struct Map_info *Map, struct line_pnts *line_p, struct line_cats *line_c)
 Read next feature from PostGIS layer on topological level (simple feature access). More...
 
int V1_read_line_pg (struct Map_info *Map, struct line_pnts *line_p, struct line_cats *line_c, off_t offset)
 Read feature from PostGIS layer at given offset (level 1 without topology) More...
 
int V2_read_line_pg (struct Map_info *Map, struct line_pnts *line_p, struct line_cats *line_c, int line)
 Read feature from PostGIS layer on topological level. More...
 

Detailed Description

Vector library - reading features (PostGIS format)

Higher level functions for reading/writing/manipulating vectors.

Todo:
Currently only points, linestrings and polygons are supported, implement also other types
Todo:
Support multigeometries
Todo:
PostGIS Topology - fix category handling (read categories from feature table)

(C) 2011-2013 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
Martin Landa <landa.martin gmail.com>

Definition in file read_pg.c.

Function Documentation

int V1_read_line_pg ( struct Map_info Map,
struct line_pnts line_p,
struct line_cats line_c,
off_t  offset 
)

Read feature from PostGIS layer at given offset (level 1 without topology)

This function implements random access on level 1.

Parameters
Mappointer to Map_info structure
[out]line_pcontainer used to store line points within (pointer line_pnts struct)
[out]line_ccontainer used to store line categories within (pointer line_cats struct)
offsetgiven offset
Returns
line type
0 dead line
-2 no more features
-1 out of memory

Definition at line 237 of file read_pg.c.

References _, Format_info_offset::array, Format_info_offset::array_num, Format_info_pg::cache, Format_info_cache::fid, Map_info::fInfo, G_debug(), G_fatal_error(), G_warning(), GV_FORWARD, if(), int, Format_info_cache::lines, Format_info_cache::lines_types, NULL, Format_info_pg::offset, Format_info::pg, SF_LINESTRING, SF_NONE, SF_POINT, Format_info_cache::sf_type, Format_info_pg::table_name, Vect_append_points(), Vect_cat_set(), Vect_reset_cats(), and Vect_reset_line().

Referenced by V1_rewrite_line_pg(), and V2_read_line_sfa().

int V1_read_next_line_pg ( struct Map_info Map,
struct line_pnts line_p,
struct line_cats line_c 
)

Read next feature from PostGIS layer. Skip empty features (level 1 without topology). t This function implements sequential access.

The action of this routine can be modified by:

Parameters
Mappointer to Map_info structure
[out]line_pcontainer used to store line points within (pointer to line_pnts struct)
[out]line_ccontainer used to store line categories within (pointer line_cats struct)
Returns
feature type
-2 no more features (EOF)
-1 out of memory

Definition at line 82 of file read_pg.c.

References _, FALSE, G_debug(), and G_fatal_error().

int V2_read_line_pg ( struct Map_info Map,
struct line_pnts line_p,
struct line_cats line_c,
int  line 
)

Read feature from PostGIS layer on topological level.

This function implements random access on level 2.

Note: Topology must be built at level >= GV_BUILD_BASE

Parameters
Mappointer to Map_info structure
[out]line_pcontainer used to store line points within (pointer line_pnts struct)
[out]line_ccontainer used to store line categories within (pointer line_cats struct)
linefeature id to read
Returns
feature type
0 dead feature
-1 on error

Definition at line 319 of file read_pg.c.

References _, Format_info_offset::array, Format_info_pg::cache, cat, Format_info_cache::ctype, Map_info::fInfo, G_debug(), G_fatal_error(), G_warning(), GV_CENTROID, GV_FORWARD, GV_POINTS, Plus_head::Line, Format_info_cache::lines, Format_info_cache::lines_cats, Format_info_cache::lines_num, Format_info_cache::lines_types, Plus_head::n_lines, NULL, Format_info_pg::offset, P_line::offset, Format_info::pg, Map_info::plus, PRI_OFF_T, Format_info_pg::res, SF_NONE, Format_info_cache::sf_type, Format_info_pg::toposchema_name, P_line::type, Vect_append_points(), Vect_cat_set(), Vect_reset_cats(), and Vect_reset_line().

Referenced by V2_delete_line_pg(), and V2_rewrite_line_pg().

int V2_read_next_line_pg ( struct Map_info Map,
struct line_pnts line_p,
struct line_cats line_c 
)

Read next feature from PostGIS layer on topological level (simple feature access).

This function implements sequential access.

Parameters
Mappointer to Map_info structure
[out]line_pcontainer used to store line points within (pointer to line_pnts struct)
[out]line_ccontainer used to store line categories within (pointer to line_cats struct)
Returns
feature type
-2 no more features (EOF)
-1 on failure

Definition at line 112 of file read_pg.c.

References _, P_topo_c::area, boxlist::box, Map_info::constraint, dig_init_boxlist(), bound_box::E, Map_info::fInfo, G_debug(), G_fatal_error(), G_warning(), GV_CENTROID, boxlist::id, Plus_head::Line, bound_box::N, Plus_head::n_lines, boxlist::n_values, Map_info::next_line, NULL, P_line::offset, Format_info::pg, Map_info::plus, Map_info::region_flag, P_line::topo, Format_info_pg::toposchema_name, TRUE, Map_info::type, P_line::type, Map_info::type_flag, Vect_append_point(), Vect_box_overlap(), Vect_cat_set(), Vect_get_area_box(), Vect_get_constraint_box(), Vect_line_box(), Vect_reset_cats(), Vect_reset_line(), and Vect_select_lines_by_box().