GRASS 8 Programmer's Manual 8.6.0dev(2026)-1d1e47ad9d
Loading...
Searching...
No Matches
open_pg.c File Reference

Vector library - Open PostGIS layer as vector map layer. More...

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

Go to the source code of this file.

Macros

#define NOPG_UNUSED
 

Functions

int V1_open_old_pg (struct Map_info *Map, int update)
 Open vector map - PostGIS feature table on non-topological level.
 
int V2_open_old_pg (struct Map_info *Map)
 Open vector map - PostGIS feature table on topological level.
 
int V1_open_new_pg (struct Map_info *Map, const char *name, int with_z)
 Prepare PostGIS database for creating new feature table (level 1)
 
int Vect__open_topo_pg (struct Map_info *Map, int head_only, int update)
 Read full-topology for PostGIS links.
 
int Vect__load_plus_head (struct Map_info *Map)
 Read topo from PostGIS topology schema – header info only.
 
int Vect__load_plus_pg (struct Map_info *Map, int head_only)
 Read topo info from PostGIS topology schema.
 
int Vect__load_map_nodes_pg (struct Map_info *Map, int geom_only)
 Read nodes from DB.
 
int Vect__load_map_lines_pg (struct Map_info *Map)
 Read features from DB.
 

Detailed Description

Vector library - Open PostGIS layer as vector map layer.

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.

Author
Martin Landa <landa.martin gmail.com>

Definition in file open_pg.c.

Macro Definition Documentation

◆ NOPG_UNUSED

#define NOPG_UNUSED

Definition at line 58 of file open_pg.c.

Function Documentation

◆ V1_open_new_pg()

int V1_open_new_pg ( struct Map_info Map,
const char name,
int  with_z 
)

Prepare PostGIS database for creating new feature table (level 1)

New PostGIS table is created when writing features by Vect_wrile_line().

Parameters
[out]Mappointer to Map_info structure
namename of PostGIS feature table to create
with_zWITH_Z for 3D vector data otherwise WITHOUT_Z
Returns
0 success
-1 error

Definition at line 226 of file open_pg.c.

References _, DB_SQL_MAX, G_debug(), G_fatal_error(), G_get_overwrite(), G_store(), G_warning(), GV_PG_FID_COLUMN, GV_PG_GEOMETRY_COLUMN, name, Format_info_pg::res, and SF_GEOMETRY.

◆ V1_open_old_pg()

int V1_open_old_pg ( struct Map_info Map,
int  update 
)

Open vector map - PostGIS feature table on non-topological level.

Parameters
[in,out]Mappointer to Map_info structure
updateTRUE for write mode, otherwise read-only
Returns
0 success
-1 error

Definition at line 73 of file open_pg.c.

References _, DB_SQL_MAX, FALSE, G_debug(), G_fatal_error(), G_store(), G_warning(), Format_info_pg::res, and TRUE.

◆ V2_open_old_pg()

int V2_open_old_pg ( struct Map_info Map)

Open vector map - PostGIS feature table on topological level.

Simple feature access:

  • open feature index file PostGIS Topology:
  • check if topological schema exists
Parameters
[in,out]Mappointer to Map_info structure
Returns
0 success
-1 error

Definition at line 166 of file open_pg.c.

References _, DB_SQL_MAX, G_debug(), G_fatal_error(), G_warning(), G_zero(), AMI_STREAM< T >::name(), Format_info_pg::res, Vect_get_full_name(), and Vect_open_fidx().

Referenced by Vect__open_old().

◆ Vect__load_map_lines_pg()

int Vect__load_map_lines_pg ( struct Map_info Map)

Read features from DB.

Parameters
Mappointer to Map_info struct
Returns
number of features

Definition at line 1566 of file open_pg.c.

References _, Plus_head::built, DB_SQL_MAX, dig_alloc_lines(), G_debug(), G_warning(), G_zero(), GV_BUILD_BASE, Plus_head::Line, Plus_head::n_blines, Plus_head::n_clines, Plus_head::n_lines, Plus_head::n_llines, and Plus_head::n_plines.

Referenced by Vect__load_plus_pg().

◆ Vect__load_map_nodes_pg()

int Vect__load_map_nodes_pg ( struct Map_info Map,
int  geom_only 
)

Read nodes from DB.

Parameters
Mappointer to Map_info struct
geom_onlyread only node's geometry
Returns
number of nodes

Definition at line 1492 of file open_pg.c.

References _, Format_info_offset::array, Format_info_offset::array_alloc, Format_info_offset::array_num, DB_SQL_MAX, dig_alloc_nodes(), G_debug(), G_malloc, G_warning(), Plus_head::n_nodes, and NULL.

Referenced by Vect__load_plus_pg().

◆ Vect__load_plus_head()

int Vect__load_plus_head ( struct Map_info Map)

Read topo from PostGIS topology schema – header info only.

Parameters
[in,out]pluspointer to Plus_head struct
Returns
0 on success
-1 on error

Definition at line 1128 of file open_pg.c.

References _, Plus_head::box, DB_SQL_MAX, G_debug(), G_warning(), Plus_head::n_areas, Plus_head::n_blines, Plus_head::n_clines, Plus_head::n_isles, Plus_head::n_lines, Plus_head::n_llines, Plus_head::n_nodes, Plus_head::n_plines, Plus_head::off_t_size, and Vect__execute_get_value_pg().

Referenced by Vect__load_plus_pg().

◆ Vect__load_plus_pg()

◆ Vect__open_topo_pg()

int Vect__open_topo_pg ( struct Map_info Map,
int  head_only,
int  update 
)

Read full-topology for PostGIS links.

Note: Only 2D topological primitives are currently supported

Parameters
[in,out]Mappointer to Map_info structure
head_onlyTRUE to read only header
updateTRUE to clean GRASS topology in update mode
Returns
0 on success
1 topology layer does not exist
-1 on error

Definition at line 327 of file open_pg.c.

References _, Plus_head::cidx_up_to_date, dig_init_plus(), FALSE, G_fatal_error(), Plus_head::Spidx_new, TRUE, Plus_head::update_cidx, Vect__clean_grass_db_topo(), Vect__load_plus_pg(), and VECT_OPEN_CODE.

Referenced by Vect__open_old().