GRASS GIS 8 Programmer's Manual  8.4.0dev(2024)-c17eaff561
vector/Vlib/copy.c File Reference

Vector library - Copy vector features and attribute tables linked to the map. More...

#include <grass/vector.h>
#include <grass/glocale.h>
#include "local_proto.h"
#include "pg_local_proto.h"
Include dependency graph for vector/Vlib/copy.c:

Go to the source code of this file.

Macros

#define TOPO_NONE   -1
 Copy topological elements. More...
 
#define TOPO_NATIVE   1
 
#define TOPO_POSTGIS   2
 
#define NOPG_UNUSED
 

Functions

int Vect_copy_map_lines (struct Map_info *In, struct Map_info *Out)
 Copy all alive vector features from input vector map to output vector map. More...
 
int Vect_copy_map_lines_field (struct Map_info *In, int field, struct Map_info *Out)
 Copy all alive vector features from given layer from input vector map to output vector map. More...
 
int copy_line_nodes (struct Map_info *In, int node, int with_z, struct line_pnts *Points, struct Map_info *Out NOPG_UNUSED)
 
int Vect__copy_areas (struct Map_info *In, int field, struct Map_info *Out)
 Copy areas as polygons (OGR/PostGIS simple features access only) More...
 
int Vect_copy_tables (struct Map_info *In, struct Map_info *Out, int field)
 Copy attribute tables linked to vector map. More...
 
int Vect_copy_table (struct Map_info *In, struct Map_info *Out, int field_in, int field_out, const char *field_name, int type)
 Copy attribute table linked to vector map based on type. More...
 
int Vect_copy_table_by_cat_list (struct Map_info *In, struct Map_info *Out, int field_in, int field_out, const char *field_name, int type, const struct cat_list *cat_list)
 Copy attribute table linked to vector map based on category list. More...
 
int Vect_copy_table_by_cats (struct Map_info *In, struct Map_info *Out, int field_in, int field_out, const char *field_name, int type, int *cats, int ncats)
 Copy attribute table linked to vector map based on category numbers. More...
 

Detailed Description

Vector library - Copy vector features and attribute tables linked to the map.

Higher level functions for reading/writing/manipulating vectors.

(C) 2001-2009, 2012-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
Original author CERL, probably Dave Gerdes or Mike Higgins.
Update to GRASS 5.7 Radim Blazek and David D. Gray.
Update to GRASS 7 by Martin Landa <landa.martin gmail.com> (OGR/PostGIS topology support)

Definition in file vector/Vlib/copy.c.

Macro Definition Documentation

◆ NOPG_UNUSED

#define NOPG_UNUSED

Definition at line 38 of file vector/Vlib/copy.c.

◆ TOPO_NATIVE

#define TOPO_NATIVE   1

Definition at line 33 of file vector/Vlib/copy.c.

◆ TOPO_NONE

#define TOPO_NONE   -1

Copy topological elements.

  • simple features (None)
  • native topo (GRASS)
  • PostGIS Topo

Definition at line 32 of file vector/Vlib/copy.c.

◆ TOPO_POSTGIS

#define TOPO_POSTGIS   2

Definition at line 34 of file vector/Vlib/copy.c.

Function Documentation

◆ copy_line_nodes()

int copy_line_nodes ( struct Map_info In,
int  node,
int  with_z,
struct line_pnts Points,
struct Map_info *Out  NOPG_UNUSED 
)

Definition at line 421 of file vector/Vlib/copy.c.

◆ Vect__copy_areas()

int Vect__copy_areas ( struct Map_info In,
int  field,
struct Map_info Out 
)

Copy areas as polygons (OGR/PostGIS simple features access only)

Parameters
Ininput vector map
fieldlayer number (-1 for all layers)
Outoutput vector map
Returns
0 on success
1 on error

Definition at line 496 of file vector/Vlib/copy.c.

◆ Vect_copy_map_lines()

int Vect_copy_map_lines ( struct Map_info In,
struct Map_info Out 
)

Copy all alive vector features from input vector map to output vector map.

Parameters
Ininput vector map
[out]Outoutput vector map
Returns
0 on success
1 on error

Definition at line 63 of file vector/Vlib/copy.c.

References Vect_copy_map_lines_field().

◆ Vect_copy_map_lines_field()

int Vect_copy_map_lines_field ( struct Map_info In,
int  field,
struct Map_info Out 
)

Copy all alive vector features from given layer from input vector map to output vector map.

Note: Try to copy on level 2 otherwise level 1 is used.

Parameters
Ininput vector map
fieldlayer number (-1 for all layers)
[out]Outoutput vector map
Returns
0 on success
1 on error

Definition at line 81 of file vector/Vlib/copy.c.

Referenced by Vect_close(), and Vect_copy_map_lines().

◆ Vect_copy_table()

int Vect_copy_table ( struct Map_info In,
struct Map_info Out,
int  field_in,
int  field_out,
const char *  field_name,
int  type 
)

Copy attribute table linked to vector map based on type.

Parameters
Ininput vector map
[out]Outoutput vector map
field_ininput layer number
field_outoutput layer number
field_namelayer name (can be NULL)
typehow many tables are linked to map: GV_1TABLE / GV_MTABLE
Returns
0 on success
-1 on error

Definition at line 664 of file vector/Vlib/copy.c.

◆ Vect_copy_table_by_cat_list()

int Vect_copy_table_by_cat_list ( struct Map_info In,
struct Map_info Out,
int  field_in,
int  field_out,
const char *  field_name,
int  type,
const struct cat_list cat_list 
)

Copy attribute table linked to vector map based on category list.

If cat_list is NULL, then Vect_copy_table() is called.

Parameters
Ininput vector map
[out]Outoutput vector map
field_ininput layer number
field_outoutput layer number
field_namelayer name (can be NULL)
typehow many tables are linked to map: GV_1TABLE / GV_MTABLE
cat_listpointer to cat_list struct (can be NULL)
Returns
0 on success
-1 on error

Definition at line 688 of file vector/Vlib/copy.c.

◆ Vect_copy_table_by_cats()

int Vect_copy_table_by_cats ( struct Map_info In,
struct Map_info Out,
int  field_in,
int  field_out,
const char *  field_name,
int  type,
int *  cats,
int  ncats 
)

Copy attribute table linked to vector map based on category numbers.

Parameters
Ininput vector map
[out]Outoutput vector map
field_ininput layer number
field_outoutput layer number
field_namelayer name (can be NULL)
typehow many tables are linked to map: GV_1TABLE / GV_MTABLE
catspointer to array of cats or NULL
ncatsnumber of cats in 'cats'
Returns
0 on success
-1 on error

Definition at line 728 of file vector/Vlib/copy.c.

◆ Vect_copy_tables()

int Vect_copy_tables ( struct Map_info In,
struct Map_info Out,
int  field 
)

Copy attribute tables linked to vector map.

Copy all attribute tables linked to the vector map if field is 0, or selected attribute table defined by given field if field > 0.

Notice, that if input vector map has no tables defined, it will copy nothing and return 0 (success).

Parameters
Ininput vector map
[out]Outoutput vector map
fieldlayer number (0 for all tables linked to the vector map)
Returns
0 on success
-1 on error

Definition at line 614 of file vector/Vlib/copy.c.