GRASS GIS 8 Programmer's Manual  8.5.0dev(2024)-36359e2344
constraint.c File Reference

Vector library - constraints for reading features. More...

#include <grass/vector.h>
#include <grass/glocale.h>
Include dependency graph for constraint.c:

Go to the source code of this file.

Functions

int Vect_set_constraint_region (struct Map_info *Map, double n, double s, double e, double w, double t, double b)
 Set constraint region. More...
 
int Vect_get_constraint_box (struct Map_info *Map, struct bound_box *Box)
 Get constraint box. More...
 
int Vect_set_constraint_type (struct Map_info *Map, int type)
 Set constraint type. More...
 
void Vect_remove_constraints (struct Map_info *Map)
 Remove all constraints. More...
 
int Vect_set_constraint_field (struct Map_info *Map, int field)
 Set constraint field. More...
 

Detailed Description

Vector library - constraints for reading features.

Higher level functions for reading/writing/manipulating vectors.

These routines can affect the Vect_read_next_line() functions by restricting what they return. They are applied on a per map basis.

These do not affect the lower level direct read functions.

Normally, all 'Alive' lines will be returned unless overridden by this function. You can specified all the types you are interested in (by oring their types together). You can use this to say exclude 'boundary' type features.

By default all DEAD lines are ignored by the Vect_read_next_line() functions. This too can be overridden by including their types.

(C) 2001-2009, 2011-2012 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.

Definition in file constraint.c.

Function Documentation

◆ Vect_get_constraint_box()

int Vect_get_constraint_box ( struct Map_info Map,
struct bound_box Box 
)

Get constraint box.

Constraint box can be defined by Vect_set_constraint_region().

Parameters
Mapvector map
[out]Boxbounding box
Returns
0 on success
-1 no region constraint defined

Definition at line 79 of file constraint.c.

References bound_box::B, Map_info::box, Box, Map_info::constraint, bound_box::E, bound_box::N, Map_info::region_flag, bound_box::S, bound_box::T, and bound_box::W.

Referenced by V1_read_next_line_nat().

◆ Vect_remove_constraints()

void Vect_remove_constraints ( struct Map_info Map)

Remove all constraints.

Parameters
Mappointer to Map_info struct

Definition at line 122 of file constraint.c.

References Map_info::constraint, FALSE, Map_info::field_flag, Map_info::region_flag, and Map_info::type_flag.

◆ Vect_set_constraint_field()

int Vect_set_constraint_field ( struct Map_info Map,
int  field 
)

Set constraint field.

Vect_read_next_line() will read only features of given type. Note that categories must be read otherwise this constraint is ignored. Constraint is ignored for random access - Vect_read_line().

Ignored for non-native vector formats.

Note: Field is called layer on user level.

Parameters
Mappointer to Map_info struct
fieldfield number (-1 for all fields)
Returns
0 on success
-1 invalid field

Definition at line 147 of file constraint.c.

References _, Map_info::constraint, FALSE, Map_info::field, Map_info::field_flag, Map_info::format, G_warning(), GV_FORMAT_NATIVE, and TRUE.

◆ Vect_set_constraint_region()

int Vect_set_constraint_region ( struct Map_info Map,
double  n,
double  s,
double  e,
double  w,
double  t,
double  b 
)

Set constraint region.

Vect_read_next_line() will read only features inside of given region or features with overlapping bounding box.

Note
Constraint is ignored for random access - Vect_read_line().
Parameters
Mappointer to Map_info struct
n,s,e,w,t,bbbox definition (north, south, east, west, top, and bottom coordinates)
Returns
0 on success
-1 on error (invalid region)

Definition at line 48 of file constraint.c.

◆ Vect_set_constraint_type()

int Vect_set_constraint_type ( struct Map_info Map,
int  type 
)

Set constraint type.

Vect_read_next_line() will read only features of given type. Constraint is ignored for random access - Vect_read_line().

Parameters
Mappointer to Map_info struct
typeconstraint feature type (GV_POINT, GV_LINE, ...)
Returns
0 on success
-1 invalid feature type

Definition at line 106 of file constraint.c.