GRASS GIS 8 Programmer's Manual
8.5.0dev(2024)-bea8435a9e
|
Vector library - Clean vector map (snap lines) More...
#include <stdlib.h>
#include <sys/stat.h>
#include <fcntl.h>
#include <unistd.h>
#include <math.h>
#include <grass/vector.h>
#include <grass/glocale.h>
#include <grass/kdtree.h>
Go to the source code of this file.
Macros | |
#define | X1W 0x01 /* x1 is West, x2 East */ |
#define | Y1S 0x02 /* y1 is South, y2 North */ |
#define | Z1B 0x04 /* z1 is Bottom, z2 Top */ |
Functions | |
void | Vect_snap_lines_list (struct Map_info *Map, const 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 with_z, int *nsnapped, int *ncreated) |
Snap a line to reference lines in Map with threshold. More... | |
Vector library - Clean vector map (snap lines)
Higher level functions for reading/writing/manipulating vectors.
(C) 2001-2009 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.
Definition in file Vlib/snap.c.
#define X1W 0x01 /* x1 is West, x2 East */ |
Definition at line 27 of file Vlib/snap.c.
#define Y1S 0x02 /* y1 is South, y2 North */ |
Definition at line 28 of file Vlib/snap.c.
#define Z1B 0x04 /* z1 is Bottom, z2 Top */ |
Definition at line 29 of file Vlib/snap.c.
int Vect_snap_line | ( | struct Map_info * | Map, |
struct ilist * | reflist, | ||
struct line_pnts * | Points, | ||
double | thresh, | ||
int | with_z, | ||
int * | nsnapped, | ||
int * | ncreated | ||
) |
Snap a line to reference lines in Map with threshold.
3D snapping is supported. 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()
[in] | Map | input map with reference lines |
[in] | reflist | list of reference lines |
[in,out] | Points | line points to snap |
[in] | thresh | threshold in which to snap vertices |
[in] | with_z | 2D or 3D snapping |
[in,out] | nsnapped | number of snapped vertices |
[in,out] | ncreated | number of new vertices (on segments) |
Definition at line 949 of file Vlib/snap.c.
Snap lines in vector map to existing vertex in threshold.
For details see Vect_snap_lines_list()
[in] | Map | input map where vertices will be snapped |
[in] | type | type of lines to snap |
[in] | thresh | threshold in which snap vertices |
[out] | Err | vector map where lines representing snap are written or NULL |
Definition at line 896 of file Vlib/snap.c.
void Vect_snap_lines_list | ( | struct Map_info * | Map, |
const struct ilist * | List_lines, | ||
double | thresh, | ||
struct Map_info * | Err | ||
) |
Snap selected lines to existing vertex in threshold.
Snap selected lines to existing vertices of other selected lines. 3D snapping is not supported.
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.
As mentioned above, lines are not necessarily snapped to nearest vertex! For example:
| | 1 line 3 is snapped to line 1, | then line 2 is not snapped to common node at lines 1 and 3, because it is already outside of threshold ----------- 3 | | 2 |
The algorithm selects anchor vertices and snaps non-anchor vertices to these anchors. The distance between anchor vertices is always > threshold. If there is more than one anchor vertex within threshold around a non-anchor vertex, this vertex is snapped to the nearest anchor vertex within threshold.
Map | input map where vertices will be snapped | |
List_lines | list of lines to snap | |
thresh | threshold in which snap vertices | |
[out] | Err | vector map where lines representing snap are written or NULL |
Definition at line 169 of file Vlib/snap.c.