|
GRASS GIS 7 Programmer's Manual
7.9.dev(2021)-e5379bbd7
|
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 "pg_local_proto.h"
Go to the source code of this file.
Functions | |
| SF_FeatureType | get_feature (struct Map_info *Map, int fid, int type) |
| Read feature geometry. More... | |
| 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... | |
| SF_FeatureType | Vect__cache_feature_pg (const char *data, int skip_polygon, int force_type, struct Format_info_cache *cache, struct feat_parts *fparts) |
| Read geometry from HEX data. More... | |
| int | Vect__open_cursor_next_line_pg (struct Format_info_pg *pg_info, int fetch_all, int built_level) |
| Create select cursor for sequential access (internal use only) More... | |
| int | Vect__open_cursor_line_pg (struct Format_info_pg *pg_info, int fid, int type) |
| Open select cursor for random access (internal use only) More... | |
| int | Vect__close_cursor_pg (struct Format_info_pg *pg_info) |
| Close select cursor. More... | |
| int | Vect__select_line_pg (struct Format_info_pg *pg_info, int fid, int type) |
| Select feature (internal use only) More... | |
| int | Vect__execute_pg (PGconn *conn, const char *stmt) |
| Execute SQL statement. More... | |
| int | Vect__execute_get_value_pg (PGconn *conn, const char *stmt) |
| Execute SQL statement and get value. More... | |
| void | Vect__reallocate_cache (struct Format_info_cache *cache, int num, int incr) |
| Reallocate lines cache. More... | |
Vector library - reading features (PostGIS format)
Higher level functions for reading/writing/manipulating vectors.
(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.
Definition in file read_pg.c.
| SF_FeatureType get_feature | ( | struct Map_info * | Map, |
| int | fid, | ||
| int | type | ||
| ) |
Read feature geometry.
Geometry is stored in lines cache.
| [in,out] | Map | pointer to Map_info struct |
| fid | feature id to be read (-1 for next) | |
| type | feature type (GV_POINT, GV_LINE, ...) - use only for topological access |
| 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.
| Map | pointer to Map_info structure | |
| [out] | line_p | container used to store line points within (pointer line_pnts struct) |
| [out] | line_c | container used to store line categories within (pointer line_cats struct) |
| offset | given offset |
| 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:
| Map | pointer to Map_info structure | |
| [out] | line_p | container used to store line points within (pointer to line_pnts struct) |
| [out] | line_c | container used to store line categories within (pointer line_cats struct) |
Definition at line 82 of file read_pg.c.
References G_debug().
| 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
| Map | pointer to Map_info structure | |
| [out] | line_p | container used to store line points within (pointer line_pnts struct) |
| [out] | line_c | container used to store line categories within (pointer line_cats struct) |
| line | feature id to read |
| 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.
| Map | pointer to Map_info structure | |
| [out] | line_p | container used to store line points within (pointer to line_pnts struct) |
| [out] | line_c | container used to store line categories within (pointer to line_cats struct) |
| SF_FeatureType Vect__cache_feature_pg | ( | const char * | data, |
| int | skip_polygon, | ||
| int | force_type, | ||
| struct Format_info_cache * | cache, | ||
| struct feat_parts * | fparts | ||
| ) |
Read geometry from HEX data.
This code is inspired by OGRGeometryFactory::createFromWkb() from GDAL/OGR library.
| data | HEX data | |
| skip_polygon | skip polygons (level 1) | |
| force_type | force GV_BOUNDARY or GV_CENTROID (used for PostGIS topology only) | |
| [out] | cache | lines cache |
| [out] | fparts | used for building pseudo-topology (or NULL) |
| int Vect__close_cursor_pg | ( | struct Format_info_pg * | pg_info | ) |
Close select cursor.
| pg_info | pointer to Format_info_pg struct |
Definition at line 1408 of file read_pg.c.
References _, Format_info_pg::conn, Format_info_pg::cursor_name, DB_SQL_MAX, G_free(), G_warning(), NULL, Format_info_pg::res, and Vect__execute_pg().
Referenced by V1_rewind_pg().
| int Vect__execute_get_value_pg | ( | PGconn * | conn, |
| const char * | stmt | ||
| ) |
Execute SQL statement and get value.
| conn | pointer to PGconn |
| stmt | query |
Definition at line 1548 of file read_pg.c.
References _, G_debug(), G_warning(), and NULL.
Referenced by Vect_sfa_get_num_features().
| int Vect__execute_pg | ( | PGconn * | conn, |
| const char * | stmt | ||
| ) |
Execute SQL statement.
See pg_local_proto.h
| conn | pointer to PGconn |
| stmt | query |
Definition at line 1514 of file read_pg.c.
References _, G_debug(), G_warning(), and NULL.
Referenced by V1_close_pg(), V1_delete_line_pg(), Vect__clean_grass_db_topo(), Vect__close_cursor_pg(), Vect__insert_face_pg(), Vect__open_cursor_next_line_pg(), and Vect_build_pg().
| int Vect__open_cursor_line_pg | ( | struct Format_info_pg * | pg_info, |
| int | fid, | ||
| int | type | ||
| ) |
Open select cursor for random access (internal use only)
Fetch number of feature (given by CURSOR_PAGE) starting with fid.
Allocated cursor name should be freed by G_free().
| pg_info | pointer to Format_info_pg struct |
| fid | feature id to get |
| type | feature type |
| int Vect__open_cursor_next_line_pg | ( | struct Format_info_pg * | pg_info, |
| int | fetch_all, | ||
| int | built_level | ||
| ) |
Create select cursor for sequential access (internal use only)
Allocated cursor name should be freed by G_free().
| pg_info | pointer to Format_info_pg struct | |
| fetch_all | TRUE to fetch all records | |
| [out] | cursor | name |
Definition at line 1234 of file read_pg.c.
References _, Format_info_pg::conn, Format_info_pg::cursor_name, DB_SQL_MAX, Format_info_pg::fid_column, G_asprintf(), G_debug(), G_free_tokens(), G_number_of_tokens(), G_tokenize(), G_warning(), Format_info_pg::geom_column, GV_BOUNDARY, GV_BUILD_CENTROIDS, GV_CENTROID, GV_LINE, GV_POINT, Format_info_pg::res, Format_info_pg::schema_name, Format_info_pg::table_name, Format_info_pg::topogeom_column, Format_info_pg::toposchema_name, Vect__execute_pg(), and Format_info_pg::where.
| void Vect__reallocate_cache | ( | struct Format_info_cache * | cache, |
| int | num, | ||
| int | incr | ||
| ) |
Reallocate lines cache.
Definition at line 1575 of file read_pg.c.
References G_realloc, Format_info_cache::lines, Format_info_cache::lines_alloc, Format_info_cache::lines_cats, Format_info_cache::lines_types, and Vect_new_line_struct().
| int Vect__select_line_pg | ( | struct Format_info_pg * | pg_info, |
| int | fid, | ||
| int | type | ||
| ) |
Select feature (internal use only)
| pg_info | pointer to Format_info_pg struct |
| fid | feature id to get |
| type | feature type |