29 double *z,
double thresh,
int vertex)
34 int line2snap, mindist_idx;
53 for (i = 0; i < Points->
n_points; i++) {
54 if (i > 0 && i < Points->
n_points - 1)
60 if (mindist >= dist) {
66 if (mindist_idx > -1) {
67 *
x = Points->
x[mindist_idx];
68 *
y = Points->
y[mindist_idx];
69 *
z = Points->
z[mindist_idx];
74 G_debug(3,
"Vedit_snap_point(): map=%s, line2snap=%d, snapped=%d",
75 Map->
name, line2snap, snapped);
98 int line,
struct line_pnts *Points,
double thresh,
101 int i, npoints, node, rewrite;
106 G_debug(3,
"Vedit_snap_line(): thresh=%g, to_vertex=%d", thresh, to_vertex);
119 for (node = 0; node < npoints; node++) {
120 if ((node > 0 && node < npoints - 1) && !to_vertex)
129 for (i = 0; i < nbgmaps; i++) {
131 thresh, to_vertex)) {
143 x[npoints - 1] =
x[0];
144 y[npoints - 1] = y[0];
145 z[npoints - 1] = z[0];
150 G_debug(3,
"Vedit_snap_line(): line=%d, snapped=%d", line, rewrite);
171 struct ilist *List,
double thresh,
int to_vertex)
174 int nlines_modified = 0;
182 for (i = 0; i < List->
n_values; i++) {
183 line = List->
value[i];
193 nlines_modified = -1;
205 return nlines_modified;
int G_debug(int, const char *,...) __attribute__((format(printf
void Vect_destroy_line_struct(struct line_pnts *)
Frees all memory associated with a line_pnts structure, including the structure itself.
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)
void Vect_destroy_cats_struct(struct line_cats *)
Frees all memory associated with line_cats structure, including the struct itself.
int Vect_read_line(struct Map_info *, struct line_pnts *, struct line_cats *, int)
Read vector feature (topological level required)
int Vect_find_line(struct Map_info *, double, double, double, int, double, int, int)
Find the nearest line.
double Vect_points_distance(double, double, double, double, double, double, int)
Calculate distance of 2 points.
int Vect_line_alive(struct Map_info *, int)
Check if feature is alive or dead (topological level required)
struct line_pnts * Vect_new_line_struct(void)
Creates and initializes a line_pnts structure.
struct line_cats * Vect_new_cats_struct(void)
Creates and initializes line_cats structure.
#define GV_POINT
Feature types used in memory on run time (may change)
#define WITHOUT_Z
2D/3D vector data
char * name
Map name (for 4.0)
int n_values
Number of values in the list.
int * value
Array of values.
Feature geometry info - coordinates.
double * y
Array of Y coordinates.
double * x
Array of X coordinates.
int n_points
Number of points.
double * z
Array of Z 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.
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.
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.