21 #include <grass/gis.h>
22 #include <grass/Vect.h>
23 #include <grass/glocale.h>
44 struct line_pnts *Points;
45 struct line_cats *SCats, *LCats, *OCats;
53 for (node = 1; node <= nnodes; node++) {
67 G_debug(3,
"nlines = %d", nlines);
69 for (i = 0; i < nlines; i++) {
75 Line = Map->plus.Line[abs(line2)];
78 G_debug(4,
" type = %d", Line->type);
79 if (!(Line->type & (otype &
GV_LINES)))
86 G_debug(4,
" line1 = %d angle1 = %e line2 = %d angle2 = %e",
87 line1, angle1, line2, angle2);
89 if (angle2 == angle1) {
91 double length1, length2;
94 int new_short_line = 0;
95 int short_type, long_type,
type;
96 double x,
y, z, nx, ny, nz;
98 G_debug(4,
" identical angles -> clean");
106 Points->y[1], 0.0, 0);
111 np = Points->n_points;
114 Points->y[np - 1], 0.0,
116 Points->y[np - 2], 0.0, 0);
124 Points->y[1], 0.0, 0);
129 np = Points->n_points;
132 Points->y[np - 1], 0.0,
134 Points->y[np - 2], 0.0, 0);
137 G_debug(4,
" length1 = %f length2 = %f", length1,
140 if (length1 < length2) {
153 if (short_line > 0) {
160 x = Points->x[Points->n_points - 2];
161 y = Points->y[Points->n_points - 2];
162 z = Points->z[Points->n_points - 2];
170 if (Points->n_points > 1) {
173 short_type, Points, SCats);
181 if (abs(line1) == abs(line2)) {
183 long_line = new_short_line;
185 long_line = -new_short_line;
193 for (j = 0; j < SCats->n_cats; j++) {
196 for (j = 0; j < LCats->n_cats; j++) {
200 if (long_type == GV_BOUNDARY || short_type == GV_BOUNDARY) {
225 Points->x[Points->n_points - 1] = x;
226 Points->y[Points->n_points - 1] =
y;
227 Points->z[Points->n_points - 1] = z;
230 if (Points->n_points > 1) {
int Vect_get_node_line(struct Map_info *Map, int node, int line)
Get line id for node line index.
struct line_pnts * Vect_new_line_struct()
Creates and initializes a struct line_pnts.
int Vect_node_alive(struct Map_info *Map, int node)
Check if node is alive or dead.
int Vect_clean_small_angles_at_nodes(struct Map_info *Map, int otype, struct Map_info *Err)
Clean small angles at nodes.
int Vect_reset_line(struct line_pnts *Points)
Reset line.
int Vect_reset_cats(struct line_cats *Cats)
Reset category structure to make sure cats structure is clean to be re-used.
int Vect_append_point(struct line_pnts *Points, double x, double y, double z)
Appends one point to the end of a line.
int Vect_cat_set(struct line_cats *Cats, int field, int cat)
Add new field/cat to category structure if doesn't exist yet.
int G_percent(long n, long d, int s)
Print percent complete messages.
int Vect_rewrite_line(struct Map_info *Map, int line, int type, struct line_pnts *points, struct line_cats *cats)
Rewrites feature info at the given offset.
struct line_cats * Vect_new_cats_struct()
Creates and initializes line_cats structure.
int Vect_line_prune(struct line_pnts *Points)
Remove duplicate points, i.e. zero length segments.
int G_debug(int level, const char *msg,...)
Print debugging message.
int Vect_delete_line(struct Map_info *Map, int line)
Delete feature.
float Vect_get_node_line_angle(struct Map_info *Map, int node, int line)
Angle of segment of the line connected to the node.
double Vect_points_distance(double x1, double y1, double z1, double x2, double y2, double z2, int with_z)
Calculate distance of 2 points.
int Vect_line_delete_point(struct line_pnts *Points, int index)
Delete point at given index and move all points above down.
long Vect_write_line(struct Map_info *Map, int type, struct line_pnts *points, struct line_cats *cats)
Writes new feature to the end of file (table)
int Vect_get_node_coor(struct Map_info *map, int num, double *x, double *y, double *z)
Get node coordinates.
int Vect_get_num_nodes(struct Map_info *map)
Get number of nodes in vector map.
int Vect_read_line(struct Map_info *Map, struct line_pnts *line_p, struct line_cats *line_c, int line)
Read vector feature.
int Vect_get_node_n_lines(struct Map_info *Map, int node)
Get number of lines for node.