[GRASS-SVN] r70598 - grass/trunk/lib/vector/vedit
svn_grass at osgeo.org
svn_grass at osgeo.org
Wed Feb 15 23:08:51 PST 2017
Author: hcho
Date: 2017-02-15 23:08:51 -0800 (Wed, 15 Feb 2017)
New Revision: 70598
Modified:
grass/trunk/lib/vector/vedit/extend.c
Log:
vedit: Don't write empty lines
Modified: grass/trunk/lib/vector/vedit/extend.c
===================================================================
--- grass/trunk/lib/vector/vedit/extend.c 2017-02-16 06:49:21 UTC (rev 70597)
+++ grass/trunk/lib/vector/vedit/extend.c 2017-02-16 07:08:51 UTC (rev 70598)
@@ -281,45 +281,55 @@
/* Vect_list_append(List, line_new); */
Vect_reset_line(Points_final);
- switch (line_to_extended) {
- case 1:
- /* extend line_to start node */
- Vect_append_point(Points_final, x1, y1, 0.0);
- for (is = 0; is < Points_to->n_points; is++)
- Vect_append_point(Points_final, Points_to->x[is],
- Points_to->y[is], Points_to->z[is]);
+ if (line_to_extended == 1) {
+ /* extend line_to start node */
+ Vect_append_point(Points_final, x1, y1, 0.0);
+ for (is = 0; is < Points_to->n_points; is++)
+ Vect_append_point(Points_final, Points_to->x[is],
+ Points_to->y[is], Points_to->z[is]);
+ line_new = Vect_rewrite_line(Map, line_to, type_to, Points_final,
+ Cats_to);
+ } else if (line_to_extended == 2) {
+ /* extend line_to end node */
+ for (is = 0; is < Points_to->n_points; is++)
+ Vect_append_point(Points_final, Points_to->x[is],
+ Points_to->y[is], Points_to->z[is]);
+ Vect_append_point(Points_final, x1, y1, 0.0);
+ line_new = Vect_rewrite_line(Map, line_to, type_to, Points_final,
+ Cats_to);
+ } else {
+ int n_parts = 0;
+
+ /* break line_to */
+ /* update line_to -- first part */
+ for (is = 0; is < seg; is++)
+ Vect_append_point(Points_final, Points_to->x[is],
+ Points_to->y[is], Points_to->z[is]);
+ Vect_append_point(Points_final, x1, y1, 0.0);
+
+ if (Vect_line_length(Points_final) > 0) {
+ n_parts++;
line_new = Vect_rewrite_line(Map, line_to, type_to,
Points_final, Cats_to);
- break;
- case 2:
- /* extend line_to end node */
- for (is = 0; is < Points_to->n_points; is++)
- Vect_append_point(Points_final, Points_to->x[is],
- Points_to->y[is], Points_to->z[is]);
- Vect_append_point(Points_final, x1, y1, 0.0);
- line_new = Vect_rewrite_line(Map, line_to, type_to,
- Points_final, Cats_to);
- break;
- default:
- /* break line_to */
- /* update line_to -- first part */
- for (is = 0; is < seg; is++)
- Vect_append_point(Points_final, Points_to->x[is],
- Points_to->y[is], Points_to->z[is]);
- Vect_append_point(Points_final, x1, y1, 0.0);
- line_new = Vect_rewrite_line(Map, line_to, type_to,
- Points_final, Cats_to);
/* Vect_list_append(List, line_new); */
+ }
- /* write second part */
- Vect_reset_line(Points_final);
- Vect_append_point(Points_final, x1, y1, 0.0);
- for (is = seg; is < Points_to->n_points; is++)
- Vect_append_point(Points_final, Points_to->x[is],
- Points_to->y[is], Points_to->z[is]);
- line_new = Vect_write_line(Map, type_to, Points_final, Cats_to);
+ /* write second part */
+ Vect_reset_line(Points_final);
+ Vect_append_point(Points_final, x1, y1, 0.0);
+ for (is = seg; is < Points_to->n_points; is++)
+ Vect_append_point(Points_final, Points_to->x[is],
+ Points_to->y[is], Points_to->z[is]);
+
+ if (Vect_line_length(Points_final) > 0) {
+ if (n_parts > 0)
+ line_new = Vect_write_line(Map, type_to, Points_final,
+ Cats_to);
+ else
+ line_new = Vect_rewrite_line(Map, line_to, type_to,
+ Points_final, Cats_to);
/* Vect_list_append(List, line_new); */
- break;
+ }
}
} while(0);
More information about the grass-commit
mailing list