Browse Source

vectorlib, network analysis: initialize output, fix shortcut, prune path

git-svn-id: https://svn.osgeo.org/grass/grass/trunk@70677 15284696-431f-4ddb-bdfa-cd5b030d7da7
Markus Metz 8 years ago
parent
commit
0efc558ddc
1 changed files with 15 additions and 1 deletions
  1. 15 1
      lib/vector/Vlib/net_analyze.c

+ 15 - 1
lib/vector/Vlib/net_analyze.c

@@ -150,6 +150,9 @@ static int find_shortest_path(struct Map_info *Map, int from, int to,
     /* Note : if from == to dgl goes to nearest node and returns back (dgl feature) => 
      *         check here for from == to */
 
+    if (List != NULL)
+	Vect_reset_list(List);
+
     /* Check if from and to are identical, otherwise dglib returns path to neares node and back! */
     if (from == to) {
 	if (cost != NULL)
@@ -822,6 +825,11 @@ find_shortest_path_coor(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) {
@@ -948,6 +956,7 @@ find_shortest_path_coor(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;
@@ -966,8 +975,11 @@ find_shortest_path_coor(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);
@@ -981,6 +993,8 @@ find_shortest_path_coor(struct Map_info *Map,
 
 	if (costs)
 	    *costs = cur_cst;
+	if (Points)
+	    Vect_line_prune(Points);
     }
 
     return reachable;