|
GRASS 8 Programmer's Manual 8.6.0dev(2026)-1d1e47ad9d
|
Vector library - reading features (PostGIS format) More...
#include <inttypes.h>#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.
Macros | |
| #define | NOPG_UNUSED |
Functions | |
| SF_FeatureType | get_feature (struct Map_info *Map, int fid, int type) |
| Read feature geometry. | |
| 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. | |
| 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). | |
| 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) | |
| 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. | |
| 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. | |
| 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) | |
| 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) | |
| int | Vect__close_cursor_pg (struct Format_info_pg *pg_info) |
| Close select cursor. | |
| int | Vect__select_line_pg (struct Format_info_pg *pg_info, int fid, int type) |
| Select feature (internal use only) | |
| int | Vect__execute_pg (PGconn *conn, const char *stmt) |
| Execute SQL statement. | |
| int | Vect__execute_get_value_pg (PGconn *conn, const char *stmt) |
| Execute SQL statement and get value. | |
| void | Vect__reallocate_cache (struct Format_info_cache *cache, int num, int incr) |
| Reallocate lines cache. | |
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 |
Definition at line 580 of file read_pg.c.
References _, DB_SQL_MAX, FALSE, G_debug(), G_warning(), GV_BOUNDARY, GV_CENTROID, GV_LINE, GV_POINT, GV_POINTS, NULL, SF_POLYGON, Vect__cache_feature_pg(), Vect__close_cursor_pg(), Vect__open_cursor_line_pg(), Vect__open_cursor_next_line_pg(), and Vect__select_line_pg().
Referenced by V1_read_line_pg(), and V2_read_line_pg().
| 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 |
Definition at line 245 of file read_pg.c.
References _, G_debug(), G_fatal_error(), G_warning(), get_feature(), GV_FORWARD, NULL, Format_info_pg::offset, SF_LINESTRING, SF_NONE, SF_POINT, 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:
| 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 88 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
| 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 |
Definition at line 328 of file read_pg.c.
References _, G_debug(), G_fatal_error(), G_warning(), get_feature(), GV_CENTROID, GV_FORWARD, GV_POINTS, NULL, P_line::offset, SF_NONE, P_line::type, Vect__select_line_pg(), 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.
| 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) |
Definition at line 119 of file read_pg.c.
References _, P_topo_c::area, dig_init_boxlist(), G_debug(), G_fatal_error(), G_warning(), GV_CENTROID, NULL, P_line::offset, P_line::topo, TRUE, P_line::type, 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().
| 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) |
Definition at line 779 of file read_pg.c.
References _, Format_info_pg::cache, ENDIAN_BIG, ENDIAN_LITTLE, FALSE, G_debug(), G_warning(), GV_BOUNDARY, GV_CENTROID, GV_LINE, GV_POINT, SF_GEOMETRY, SF_GEOMETRYCOLLECTION, SF_LINESTRING, SF_MULTILINESTRING, SF_MULTIPOINT, SF_MULTIPOLYGON, SF_NONE, SF_POINT, SF_POLYGON, TRUE, and Vect__reallocate_cache().
Referenced by get_feature(), and Vect__get_area_points_pg().
| 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 1454 of file read_pg.c.
References _, DB_SQL_MAX, G_free(), G_warning(), NULL, and Vect__execute_pg().
Referenced by get_feature(), and V1_rewind_pg().
Execute SQL statement and get value.
| conn | pointer to PGconn |
| stmt | query |
Definition at line 1599 of file read_pg.c.
References _, G_debug(), G_warning(), and NULL.
Referenced by Vect__load_plus_head(), and Vect_sfa_get_num_features().
Execute SQL statement.
See pg_local_proto.h
| conn | pointer to PGconn |
| stmt | query |
Definition at line 1565 of file read_pg.c.
References _, G_debug(), G_warning(), and NULL.
Referenced by V1_close_pg(), V1_delete_line_pg(), V2__update_area_pg(), V2_delete_line_pg(), V2_rewrite_line_pg(), Vect__clean_grass_db_topo(), Vect__close_cursor_pg(), Vect__define_topo_relation(), Vect__insert_face_pg(), Vect__open_cursor_line_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 |
Definition at line 1380 of file read_pg.c.
References _, DB_SQL_MAX, G_asprintf(), G_debug(), G_warning(), GV_LINES, GV_POINTS, and Vect__execute_pg().
Referenced by get_feature().
| 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 1253 of file read_pg.c.
References _, DB_SQL_MAX, G_asprintf(), G_debug(), G_free_tokens(), G_number_of_tokens(), G_tokenize(), G_warning(), GV_BOUNDARY, GV_BUILD_CENTROIDS, GV_CENTROID, GV_LINE, GV_POINT, and Vect__execute_pg().
Referenced by get_feature().
| void Vect__reallocate_cache | ( | struct Format_info_cache * | cache, |
| int | num, | ||
| int | incr | ||
| ) |
Reallocate lines cache.
Definition at line 1626 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().
Referenced by Vect__cache_feature_pg().
| 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 |
Definition at line 1487 of file read_pg.c.
References _, DB_SQL_MAX, G_debug(), G_warning(), GV_LINES, GV_POINT, and GV_POINTS.
Referenced by get_feature(), and V2_read_line_pg().