15 #include <grass/vedit.h>
34 int nbgmaps,
struct ilist *List,
35 struct line_pnts *coord,
double thresh_coords,
36 double thresh_snap,
double move_x,
double move_y,
37 double move_z,
int move_first,
int snap)
39 int nvertices_moved, nlines_modified, nvertices_snapped;
42 int line,
type, rewrite;
44 double east, north, dist;
48 struct line_pnts *Points, *Points_snap;
49 struct line_cats *Cats;
52 nvertices_moved = nvertices_snapped = 0;
59 for (i = 0; i < List->n_values; i++) {
60 line = List->value[i];
70 npoints = Points->n_points;
81 (
char *)G_realloc((
void *)moved, Points->n_points *
sizeof(char));
82 G_zero((
void *)moved, Points->n_points *
sizeof(
char));
85 for (j = 0; j < coord->n_points; j++) {
90 for (k = 0; k < Points->n_points; k++) {
93 x[k], y[k], z[k], WITHOUT_Z);
94 if (dist <= thresh_coords) {
96 "Vedit_move_vertex(): line=%d; x=%f, y=%f -> x=%f, y=%f",
97 line, x[k], y[k], x[k] + move_x,
106 G_debug(3,
"Vedit_move_vertex(): line=%d, point=%d",
109 if (snap != NO_SNAP) {
111 (Map, line, &x[k], &y[k], &z[k], thresh_snap,
112 (snap == SNAPVERTEX) ? 1 : 0) == 0) {
116 for (bgi = 0; bgi < nbgmaps; bgi++) {
118 (BgMap[bgi], line, &x[k], &y[k],
120 (snap == SNAPVERTEX) ? 1 : 0))
140 if ((type & GV_LINES) &&
142 x[npoints - 1], y[npoints - 1],
144 WITHOUT_Z) <= thresh_snap) {
147 x[0] = x[npoints - 1];
148 y[0] = y[npoints - 1];
150 z[0] = z[npoints - 1];
152 else if (moved[npoints - 1] == 1) {
153 x[npoints - 1] = x[0];
154 y[npoints - 1] = y[0];
156 z[npoints - 1] = z[0];
176 return nvertices_moved;
195 struct line_pnts *coord,
double thresh)
199 int nlines_modified, nvertices_added, rewrite;
200 double east, north, dist;
204 struct line_pnts *Points;
205 struct line_cats *Cats;
212 for (i = 0; i < List->n_values; i++) {
213 line = List->value[i];
227 for (j = 0; j < coord->n_points; j++) {
232 WITHOUT_Z, &px, &py,
NULL,
236 if (dist <= thresh &&
240 z[seg - 1], WITHOUT_Z) > 0) {
244 "Vedit_add_vertex(): line=%d; x=%f, y=%f, index=%d",
266 return nvertices_added;
283 struct line_pnts *coord,
double thresh)
287 int nvertices_removed, rewrite, nlines_modified;
292 struct line_pnts *Points;
293 struct line_cats *Cats;
295 nvertices_removed = nlines_modified = 0;
300 for (i = 0; i < List->n_values; i++) {
301 line = List->value[i];
315 for (j = 0; j < coord->n_points; j++) {
319 for (k = 0; k < Points->n_points; k++) {
321 x[k], y[k], z[k], WITHOUT_Z);
322 if (dist <= thresh) {
326 "Vedit_remove_vertex(): line=%d; x=%f, y=%f, index=%d",
327 line, x[k], y[k], k);
349 return nvertices_removed;