29 int line,
double *
x,
double *y,
double *z,
double thresh,
35 int line2snap, mindist_idx;
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],
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;
110 G_debug(3,
"Vedit_snap_line(): thresh=%g, to_vertex=%d", thresh,
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],
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;
188 for (i = 0; i < List->
n_values; i++) {
189 line = List->
value[i];
197 line, Points, thresh, to_vertex) == 1) {
209 return nlines_modified;
char * name
Map name (for 4.0)
int Vedit_snap_lines(struct Map_info *Map, struct Map_info **BgMap, int nbgmaps, struct ilist *List, double thresh, int to_vertex)
Snap lines/boundaries.
off_t Vect_rewrite_line(struct Map_info *, off_t, int, const struct line_pnts *, const struct line_cats *)
Rewrites existing feature (topological level required)
int n_points
Number of points.
int n_values
Number of values in the list.
double Vect_points_distance(double, double, double, double, double, double, int)
Calculate distance of 2 points.
#define GV_POINT
Feature types used in memory on run time (may change)
int Vect_find_line(struct Map_info *, double, double, double, int, double, int, int)
Find the nearest line.
double * x
Array of X coordinates.
int Vedit_snap_line(struct Map_info *Map, struct Map_info **BgMap, int nbgmaps, int line, struct line_pnts *Points, double thresh, int to_vertex)
Snap selected primitive to its nearest primitive.
Feature geometry info - coordinates.
int Vedit_snap_point(struct Map_info *Map, int line, double *x, double *y, double *z, double thresh, int vertex)
Snap given point to the nearest primitive.
struct line_pnts * Vect_new_line_struct(void)
Creates and initializes a line_pnts structure.
void Vect_destroy_cats_struct(struct line_cats *)
Frees all memory associated with line_cats structure, including the struct itself.
#define WITHOUT_Z
2D/3D vector data
double * y
Array of Y coordinates.
struct line_cats * Vect_new_cats_struct(void)
Creates and initializes line_cats structure.
int Vect_line_alive(const struct Map_info *, int)
Check if feature is alive or dead (topological level required)
double * z
Array of Z coordinates.
int * value
Array of values.
void Vect_destroy_line_struct(struct line_pnts *)
Frees all memory associated with a line_pnts structure, including the structure itself.
int Vect_read_line(const struct Map_info *, struct line_pnts *, struct line_cats *, int)
Read vector feature (topological level required)
int G_debug(int, const char *,...) __attribute__((format(printf