浏览代码

veditlib: bugfix - snapping lines works now

git-svn-id: https://svn.osgeo.org/grass/grass/trunk@32091 15284696-431f-4ddb-bdfa-cd5b030d7da7
Martin Landa 17 年之前
父节点
当前提交
3e944dfe99
共有 2 个文件被更改,包括 8 次插入6 次删除
  1. 1 1
      gui/wxpython/vdigit/line.cpp
  2. 7 5
      lib/vector/vedit/snap.c

+ 1 - 1
gui/wxpython/vdigit/line.cpp

@@ -113,7 +113,7 @@ int Digit::AddLine(int type, std::vector<double> coords, int layer, int cat,
 	}
     }
 
-    if (snap != NO_SNAP) { /* apply snapping (node or vertex) */
+    if (snap != NO_SNAP && (type & GV_LINES)) { /* apply snapping (node or vertex) */
 	Vedit_snap_line(display->mapInfo, BgMap, nbgmaps,
 			-1, Points,
 			threshold, (snap == SNAP) ? 0 : 1); 

+ 7 - 5
lib/vector/vedit/snap.c

@@ -106,7 +106,7 @@ 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)
 {
-    int i, type, npoints, node, rewrite;
+    int i, npoints, node, rewrite;
     double *x, *y, *z;
 
     struct line_cats *Cats;
@@ -146,14 +146,14 @@ int Vedit_snap_line(struct Map_info *Map, struct Map_info **BgMap, int nbgmaps,
     } /* for each line vertex */
     
     /* close boundaries or lines */
-    if (!rewrite && (type & GV_LINES) &&
+    if (!rewrite &&
 	Vect_points_distance(x[0], y[0], z[0],
 			     x[npoints-1], y[npoints-1], z[npoints-1],
 			     WITHOUT_Z) <= thresh) {
 	x[npoints-1] = x[0];
 	y[npoints-1] = y[0];
 	z[npoints-1] = z[0];
-	
+
 	rewrite = 1;
     }
 
@@ -193,9 +193,11 @@ int Vedit_snap_lines(struct Map_info *Map, struct Map_info **BgMap, int nbgmaps,
     for(i = 0; i < List -> n_values; i++) {
 	line = List -> value[i];
 	type = Vect_read_line(Map, Points, Cats, line);
-	if (type < 0) {
-	    return -1;
+
+	if (!(type & GV_LINES)) {
+	    continue;
 	}
+
 	if (Vedit_snap_line(Map, BgMap, nbgmaps,
 			    line, Points, thresh, to_vertex) == 1) {
 	    if (Vect_rewrite_line (Map, line, type, Points, Cats) < 0) {