GRASS Programmer's Manual  6.5.svn(2014)-r66266
 All Data Structures Namespaces Files Functions Variables Typedefs Enumerations Enumerator Macros Pages
Vlib/snap.c File Reference
#include <math.h>
#include <stdlib.h>
#include <grass/gis.h>
#include <grass/Vect.h>
#include <grass/glocale.h>
Include dependency graph for Vlib/snap.c:

Go to the source code of this file.

Data Structures

struct  XPNT
 
struct  XSEG
 
struct  NEW
 
struct  NEW2
 

Functions

void Vect_snap_lines_list (struct Map_info *Map, struct ilist *List_lines, double thresh, struct Map_info *Err)
 Snap selected lines to existing vertex in threshold. More...
 
void Vect_snap_lines (struct Map_info *Map, int type, double thresh, struct Map_info *Err)
 Snap lines in vector map to existing vertex in threshold. More...
 
int Vect_snap_line (struct Map_info *Map, struct ilist *reflist, struct line_pnts *Points, double thresh, int *nsnapped, int *ncreated)
 Snap a line to reference lines in Map with threshold. More...
 

Function Documentation

int Vect_snap_line ( struct Map_info *  Map,
struct ilist *  reflist,
struct line_pnts *  Points,
double  thresh,
int nsnapped,
int ncreated 
)

Snap a line to reference lines in Map with threshold.

The line to snap and the reference lines can but do not need to be in different vector maps.

Vect_snap_line() uses less memory, but is slower than Vect_snap_lines_list()

For details on snapping, see Vect_snap_lines_list()

Parameters
[in]Mapinput map with reference lines
[in]reflistlist of reference lines
[in,out]Pointsline points to snap
[in]threshthreshold in which to snap vertices
[in,out]nsnappednumber of snapped verices
[in,out]ncreatednumber of new vertices (on segments)
Returns
1 if line was changed, otherwise 0

Definition at line 535 of file Vlib/snap.c.

References NEW2::along, XPNT::anchor, Rect::boundary, dig_distance2_point_to_line(), find_item(), G_debug(), G_free(), NULL, point, RTreeDestroyNode(), RTreeInsertRect(), RTreeNewIndex(), RTreeSearch(), Vect_append_point(), Vect_append_points(), Vect_destroy_cats_struct(), Vect_destroy_line_struct(), Vect_destroy_list(), Vect_line_alive(), Vect_line_prune(), Vect_new_cats_struct(), Vect_new_line_struct(), Vect_new_list(), Vect_read_line(), Vect_reset_line(), Vect_reset_list(), NEW2::x, XPNT::x, XSEG::x1, XSEG::x2, xmax, xmin, y, NEW2::y, XPNT::y, XSEG::y1, XSEG::y2, ymax, and ymin.

void Vect_snap_lines ( struct Map_info *  Map,
int  type,
double  thresh,
struct Map_info *  Err 
)

Snap lines in vector map to existing vertex in threshold.

For details see Vect_snap_lines_list()

Parameters
[in]Mapinput map where vertices will be snapped
[in]typetype of lines to snap
[in]threshthreshold in which snap vertices
[out]Errvector map where lines representing snap are written or NULL
Returns
void

Definition at line 481 of file Vlib/snap.c.

References dig_list_add(), G_debug(), NULL, Vect_destroy_list(), Vect_get_num_lines(), Vect_line_alive(), Vect_new_list(), Vect_read_line(), and Vect_snap_lines_list().

void Vect_snap_lines_list ( struct Map_info *  Map,
struct ilist *  List_lines,
double  thresh,
struct Map_info *  Err 
)

Snap selected lines to existing vertex in threshold.

Snap selected lines to existing vertices.

Warning
Lines are not necessarily snapped to nearest vertex, but to vertex in threshold!

Lines showing how vertices were snapped may be optionally written to error map. Input map must be opened on level 2 for update at least on GV_BUILD_BASE.

Parameters
[in]Mapinput map where vertices will be snapped
[in]List_lineslist of lines to snap
[in]threshthreshold in which snap vertices
[out]Errvector map where lines representing snap are written or NULL
Returns
void

Definition at line 110 of file Vlib/snap.c.

References NEW::along, XPNT::anchor, NEW::anchor, Rect::boundary, dig_distance2_point_to_line(), G_debug(), G_free(), G_percent(), G_verbose_message(), main::GV_LINES, NULL, point, RTreeDestroyNode(), RTreeInsertRect(), RTreeNewIndex(), RTreeSearch(), Vect_append_point(), Vect_delete_line(), Vect_destroy_cats_struct(), Vect_destroy_line_struct(), Vect_line_alive(), Vect_line_prune(), Vect_new_cats_struct(), Vect_new_line_struct(), Vect_new_list(), Vect_read_line(), Vect_reset_line(), Vect_reset_list(), Vect_rewrite_line(), Vect_write_line(), XPNT::x, xmax, xmin, y, XPNT::y, ymax, and ymin.

Referenced by wxdigit.IVDigit::SnapLine(), and Vect_snap_lines().