浏览代码

vectorlib, network analysis: fix shortcut, prune path (backport from trunk https://trac.osgeo.org/grass/changeset/70677)

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

+ 12 - 1
lib/vector/Vlib/net.c

@@ -1038,6 +1038,11 @@ Vect_net_shortest_path_coor2(struct Map_info *Map,
 	Vect_reset_line(SPoints);
 	if (flen == tlen) {
 	    cur_cst = 0;
+
+	    Vect_append_point(SPoints, fx, fy, fz);
+	    Vect_append_point(SPoints, fcx, fcy, fcz);
+	    Vect_append_point(SPoints, tx, ty, tz);
+
 	    reachable = shortcut = 1;
 	}
 	else if (flen < tlen) {
@@ -1152,6 +1157,7 @@ Vect_net_shortest_path_coor2(struct Map_info *Map,
 			Vect_append_points(Points, APoints, GV_FORWARD);
 		    else
 			Vect_append_points(Points, APoints, GV_BACKWARD);
+		    Points->n_points--;
 		}
                 if (NodesList) {
                     int node, node1, node2;
@@ -1170,8 +1176,11 @@ Vect_net_shortest_path_coor2(struct Map_info *Map,
 		    Vect_list_append(List, line);
 	    }
 
-	    if (Points)
+	    if (Points) {
+		if (LList->n_values)
+		    Points->n_points++;
 		Vect_append_points(Points, tPoints[tn], GV_FORWARD);
+	    }
 
 	    if (TPoints)
 		Vect_append_points(TPoints, tPoints[tn], GV_FORWARD);
@@ -1185,6 +1194,8 @@ Vect_net_shortest_path_coor2(struct Map_info *Map,
 
 	if (costs)
 	    *costs = cur_cst;
+	if (Points)
+	    Vect_line_prune(Points);
     }
 
     return reachable;