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

Vector library - write vector feature (PostGIS format) More...

#include <string.h>
#include <grass/vector.h>
#include <grass/glocale.h>
#include "local_proto.h"
Include dependency graph for write_pg.c:

Go to the source code of this file.

Functions

off_t V1_write_line_pg (struct Map_info *Map, int type, const struct line_pnts *points, const struct line_cats *cats)
 Writes feature on level 1 (PostGIS interface) More...
 
off_t V2_write_line_pg (struct Map_info *Map, int type, const struct line_pnts *points, const struct line_cats *cats)
 Writes feature on topological level (PostGIS interface) More...
 
off_t V1_rewrite_line_pg (struct Map_info *Map, off_t offset, int type, const struct line_pnts *points, const struct line_cats *cats)
 Rewrites feature at the given offset (level 1) (PostGIS interface, internal use only) More...
 
off_t V2_rewrite_line_pg (struct Map_info *Map, off_t line, int type, const struct line_pnts *points, const struct line_cats *cats)
 Rewrites feature at topological level (PostGIS interface, internal use only) More...
 
int V1_delete_line_pg (struct Map_info *Map, off_t offset)
 Deletes feature at the given offset (level 1) More...
 
int V2_delete_line_pg (struct Map_info *Map, off_t line)
 Deletes feature on topological level (PostGIS interface) More...
 

Detailed Description

Vector library - write vector feature (PostGIS format)

Higher level functions for reading/writing/manipulating vectors.

Write subroutine inspired by OGR PostgreSQL driver.

Todo:

PostGIS version of V2__delete_area_cats_from_cidx_nat()

function to delete corresponding entry in fidx

PostGIS version of V2__add_area_cats_to_cidx_nat

(C) 2012-2014 by Martin Landa, and 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 write_pg.c.

Function Documentation

int V1_delete_line_pg ( struct Map_info Map,
off_t  offset 
)

Deletes feature at the given offset (level 1)

Only for simple feature access. PostGIS Topology requires level 2.

Parameters
Mappointer Map_info structure
offsetfeature offset
Returns
0 on success
-1 on error

Definition at line 310 of file write_pg.c.

References _, Format_info_offset::array, Format_info_offset::array_num, Format_info_pg::conn, DB_SQL_MAX, Format_info_pg::fid_column, Map_info::fInfo, G_debug(), G_fatal_error(), G_warning(), Format_info_pg::inTransaction, Format_info_pg::offset, Format_info::pg, Format_info_pg::table_name, and TRUE.

Referenced by V1_rewrite_line_pg(), and V2_delete_line_sfa().

off_t V1_rewrite_line_pg ( struct Map_info Map,
off_t  offset,
int  type,
const struct line_pnts points,
const struct line_cats cats 
)

Rewrites feature at the given offset (level 1) (PostGIS interface, internal use only)

Only for simple feature access. PostGIS Topology requires level 2.

Todo:
Use UPDATE statement ?
Parameters
Mappointer to Map_info structure
offsetfeature offset
typefeature type (GV_POINT, GV_LINE, ...)
pointsfeature geometry
catsfeature categories
Returns
feature offset (rewritten feature)
-1 on error

Definition at line 178 of file write_pg.c.

References _, G_debug(), G_fatal_error(), G_warning(), NULL, PRI_OFF_T, V1_delete_line_pg(), V1_read_line_pg(), and V1_write_line_pg().

off_t V1_write_line_pg ( struct Map_info Map,
int  type,
const struct line_pnts points,
const struct line_cats cats 
)

Writes feature on level 1 (PostGIS interface)

Notes for simple feature access:

  • centroids are not supported in PostGIS, pseudotopo holds virtual centroids
  • boundaries are not supported in PostGIS, pseudotopo treats polygons as boundaries

Notes for PostGIS Topology access:

  • centroids are stored as isolated nodes
  • boundaries are stored as edges
Parameters
Mappointer to Map_info structure
typefeature type (GV_POINT, GV_LINE, ...)
pointspointer to line_pnts structure (feature geometry)
catspointer to line_cats structure (feature categories)
Returns
feature offset into file
-1 on error

Definition at line 98 of file write_pg.c.

References _, FALSE, Format_info_pg::feature_type, Map_info::fInfo, G_fatal_error(), Format_info::pg, SF_GEOMETRY, and Format_info_pg::toposchema_name.

Referenced by V1_rewrite_line_pg(), and V2_write_line_sfa().

int V2_delete_line_pg ( struct Map_info Map,
off_t  line 
)
off_t V2_rewrite_line_pg ( struct Map_info Map,
off_t  line,
int  type,
const struct line_pnts points,
const struct line_cats cats 
)

Rewrites feature at topological level (PostGIS interface, internal use only)

Note: Topology must be built at level >= GV_BUILD_BASE

Todo:

Handle also categories

Store original geometry in tmp table for restore

Parameters
Mappointer to Map_info structure
linefeature id
typefeature type (GV_POINT, GV_LINE, ...)
pointsfeature geometry
catsfeature categories
Returns
offset where feature was rewritten
-1 on error

Definition at line 218 of file write_pg.c.

References _, Plus_head::cidx_up_to_date, Format_info_pg::conn, FALSE, Format_info_pg::fid_column, Map_info::fInfo, G_asprintf(), G_debug(), G_fatal_error(), G_free(), G_warning(), GV_POINTS, Map_info::head, Plus_head::Line, Plus_head::n_lines, NULL, P_line::offset, Format_info::pg, Map_info::plus, Format_info_pg::schema_name, Format_info_pg::table_name, Format_info_pg::toposchema_name, Plus_head::update_cidx, V2_read_line_pg(), Vect_new_line_struct(), and dig_head::with_z.

off_t V2_write_line_pg ( struct Map_info Map,
int  type,
const struct line_pnts points,
const struct line_cats cats 
)

Writes feature on topological level (PostGIS interface)

Calls V2_write_line_sfa() for simple features access.

Parameters
Mappointer to Map_info structure
typefeature type (GV_POINT, GV_LINE, ...)
pointspointer to line_pnts structure (feature geometry)
catspointer to line_cats structure (feature categories)
Returns
feature offset into file
-1 on error

Definition at line 141 of file write_pg.c.

References _, FALSE, Map_info::fInfo, G_fatal_error(), Format_info::pg, Format_info_pg::toposchema_name, and V2_write_line_sfa().