14 #include <grass/vedit.h>
29 int line,
double *x,
double *y,
double *z,
double thresh,
32 struct line_pnts *Points;
35 int line2snap, mindist_idx;
44 line2snap =
Vect_find_line(Map, *x, *y, *z, -1, thresh, WITHOUT_Z, line);
54 for (i = 0; i < Points->n_points; i++) {
55 if (i > 0 && i < Points->n_points - 1)
59 Points->x[i], Points->y[i],
60 Points->z[i], WITHOUT_Z);
62 if (mindist >= dist) {
68 if (mindist_idx > -1) {
69 *x = Points->x[mindist_idx];
70 *y = Points->y[mindist_idx];
71 *z = Points->z[mindist_idx];
76 G_debug(3,
"Vedit_snap_point(): map=%s, line2snap=%d, snapped=%d",
77 Map->name, line2snap, snapped);
100 int nbgmaps,
int line,
struct line_pnts *Points,
101 double thresh,
int to_vertex)
103 int i, npoints, node, rewrite;
106 struct line_cats *Cats;
110 G_debug(3,
"Vedit_snap_line(): thresh=%g, to_vertex=%d", thresh,
116 npoints = Points->n_points;
122 for (node = 0; node < npoints; node++) {
123 if ((node > 0 && node < npoints - 1) && !to_vertex)
132 for (i = 0; i < nbgmaps; i++) {
134 (BgMap[i], -1, &x[node], &y[node], &z[node], thresh,
146 x[npoints - 1], y[npoints - 1], z[npoints - 1],
147 WITHOUT_Z) <= thresh) {
148 x[npoints - 1] = x[0];
149 y[npoints - 1] = y[0];
150 z[npoints - 1] = z[0];
155 G_debug(3,
"Vedit_snap_line(): line=%d, snapped=%d", line, rewrite);
176 int nbgmaps,
struct ilist *List,
double thresh,
180 int nlines_modified = 0;
182 struct line_pnts *Points;
183 struct line_cats *Cats;
188 for (i = 0; i < List->n_values; i++) {
189 line = List->value[i];
192 if (!(type & (GV_POINT |
GV_LINES))) {
197 line, Points, thresh, to_vertex) == 1) {
209 return nlines_modified;