34 struct ilist *List_updated)
37 int type, line, seg, newline;
39 double px, py, spdist, lpdist, dist;
51 for (i = 0; i < List->
n_values; i++) {
52 line = List->
value[i];
66 for (j = 0; j < coord->
n_points; j++) {
69 &dist, &spdist, &lpdist);
76 "Vedit_split_lines(): line=%d, x=%f, y=%f, px=%f, py=%f, "
78 "dist=%f, spdist=%f, lpdist=%f",
79 line, coord->
x[j], coord->
y[j], px, py, seg, dist, spdist,
85 G_debug(3,
"Vedit_split_lines(): line=%d", line);
89 for (
l = 0;
l < seg;
l++) {
102 nlines_modified = -1;
120 nlines_modified = -1;
135 return nlines_modified;
160 int nlines_modified, connected;
161 int i, j, node[2], n_nodes;
165 struct ilist *List_exclude, *List_found;
175 for (i = 0; i < List->
n_values; i++) {
176 line = List->
value[i];
184 node[0] = node[1] = -1;
186 if (node[0] < 0 || node[1] < 0)
192 for (j = 0; j < n_nodes && !connected; j++) {
204 G_debug(3,
"Vedit_connect_lines(): lines=%d,%d", line,
209 "Vedit_connect_lines(): lines=%d,%d -> connected",
211 nlines_modified += 2;
217 }
while (List_found->
n_values > 0 && !connected);
224 return nlines_modified;
231 int type_from, type_to;
232 int n_points, seg, is;
233 double x, y, px, py, x1, y1;
234 double dist, spdist, lpdist, length, dist_p;
235 double angle_t, angle_f, angle;
237 struct line_pnts *Points_from, *Points_to, *Points_final;
246 type_from =
Vect_read_line(Map, Points_from, Cats_from, line_from);
254 n_points = Points_from->
n_points - 1;
257 x = Points_from->
x[0];
258 y = Points_from->
y[0];
261 x = Points_from->
x[n_points];
262 y = Points_from->
y[n_points];
265 NULL, &dist, &spdist, &lpdist);
267 if (seg > 0 && dist > 0.0 && (thresh < 0. || dist <= thresh)) {
275 &angle_f,
NULL) > 0) {
277 &angle_t,
NULL) > 0) {
278 angle = angle_t - angle_f;
279 dist_p = fabs(dist / sin(angle));
288 x1 =
x + dist_p * cos(angle_f);
289 y1 = y + dist_p * sin(angle_f);
298 Points_from->
x[0] = x1;
299 Points_from->
y[0] = y1;
302 Points_from->
x[n_points] = x1;
303 Points_from->
y[n_points] = y1;
307 Points_from, Cats_from);
312 for (is = 0; is < seg; is++) {
319 Points_final, Cats_to);
325 for (is = seg; is < Points_to->
n_points; is++) {
347 return line_new > 0 ? 1 : 0;
int Vedit_connect_lines(struct Map_info *Map, struct ilist *List, double thresh)
Connect lines in given threshold.
int connect_lines(struct Map_info *Map, int first, int line_from, int line_to, double thresh, struct ilist *List UNUSED)
int Vedit_split_lines(struct Map_info *Map, struct ilist *List, struct line_pnts *coord, double thresh, struct ilist *List_updated)
Split selected lines on given position.
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)
int Vect_get_line_nodes(struct Map_info *, int, int *, int *)
Get line nodes.
int Vect_get_node_coor(struct Map_info *, int, double *, double *, double *)
Get node coordinates.
double Vect_line_length(const struct line_pnts *)
Calculate line length, 3D-length in case of 3D vector line.
int Vect_point_on_line(const struct line_pnts *, double, double *, double *, double *, double *, double *)
Find point on line in the specified distance.
int Vect_get_line_type(struct Map_info *, int)
Get line type.
int Vect_find_line_list(struct Map_info *, double, double, double, int, double, int, const struct ilist *, struct ilist *)
Find the nearest line(s).
void Vect_destroy_list(struct ilist *)
Frees all memory associated with a struct ilist, including the struct itself.
void Vect_destroy_cats_struct(struct line_cats *)
Frees all memory associated with line_cats structure, including the struct itself.
int Vect_list_append(struct ilist *, int)
Append new item to the end of list if not yet present.
int Vect_read_line(struct Map_info *, struct line_pnts *, struct line_cats *, int)
Read vector feature (topological level required)
int Vect_line_distance(const struct line_pnts *, double, double, double, int, double *, double *, double *, double *, double *, double *)
Calculate distance of point to line.
struct ilist * Vect_new_list(void)
Creates and initializes a struct ilist.
int Vect_line_alive(struct Map_info *, int)
Check if feature is alive or dead (topological level required)
int Vect_line_insert_point(struct line_pnts *, int, double, double, double)
Insert new point at index position and move all old points at that position and above up.
off_t Vect_write_line(struct Map_info *, int, const struct line_pnts *, const struct line_cats *)
Writes a new feature.
struct line_pnts * Vect_new_line_struct(void)
Creates and initializes a line_pnts structure.
void Vect_reset_line(struct line_pnts *)
Reset line.
struct line_cats * Vect_new_cats_struct(void)
Creates and initializes line_cats structure.
int Vect_reset_list(struct ilist *)
Reset ilist structure.
int Vect_append_point(struct line_pnts *, double, double, double)
Appends one point to the end of a line.
#define WITHOUT_Z
2D/3D vector data
#define UNUSED
A macro for an attribute, if attached to a variable, indicating that the variable is not used.
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.