浏览代码

v.edit tool=merge: skip zero length lines; a single point is not a polygon (backport trunk https://trac.osgeo.org/grass/changeset/69556)

git-svn-id: https://svn.osgeo.org/grass/grass/branches/releasebranch_7_0@69558 15284696-431f-4ddb-bdfa-cd5b030d7da7
Markus Metz 8 年之前
父节点
当前提交
5df9bc47c4
共有 1 个文件被更改,包括 13 次插入2 次删除
  1. 13 2
      lib/vector/vedit/merge.c

+ 13 - 2
lib/vector/vedit/merge.c

@@ -64,6 +64,8 @@ int Vedit_merge_lines(struct Map_info *Map, struct ilist *List)
 	return 0;
     }
 
+    G_debug(1, "Vedit_merge_lines(): merging %d lines", List->n_values);
+
     Points1 = Vect_new_line_struct();
     Cats1 = Vect_new_cats_struct();
     Points2 = Vect_new_line_struct();
@@ -86,6 +88,14 @@ int Vedit_merge_lines(struct Map_info *Map, struct ilist *List)
 	if (!(type1 & GV_LINES))
 	    continue;
 
+	/* remove duplicate points */
+	Vect_line_prune(Points1);
+
+	if (Points1->n_points == 1) {
+	    G_debug(3, "Vedit_merge_lines(): skipping zero length line");
+	    continue;
+	}
+
 	Vect_reset_line(Points);
 
 	for (i = 0; i < Points1->n_points; i += Points1->n_points - 1) {
@@ -110,8 +120,9 @@ int Vedit_merge_lines(struct Map_info *Map, struct ilist *List)
 	     * merge lines only if two lines found in the region
 	     * i.e. the current line and an adjacent line
 	     */
-	    if (1 < Vect_select_lines_by_polygon(Map, Points2, 0, NULL,
-						 GV_LINES, List_in_box)) {
+	    if (0 < Vect_find_line_list(Map, Points1->x[i], Points1->y[i],
+	                                Points1->z[i], GV_LINES, 0, 0,
+					NULL, List_in_box)) {
 		do_merge = 1;
 		line2 = -1;
 		for (j = 0; do_merge && j < List->n_values; j++) {