[GRASS-SVN] r70677 - grass/trunk/lib/vector/Vlib

svn_grass at osgeo.org svn_grass at osgeo.org
Sun Feb 26 05:24:05 PST 2017


Author: mmetz
Date: 2017-02-26 05:24:05 -0800 (Sun, 26 Feb 2017)
New Revision: 70677

Modified:
   grass/trunk/lib/vector/Vlib/net_analyze.c
Log:
vectorlib, network analysis: initialize output, fix shortcut, prune path

Modified: grass/trunk/lib/vector/Vlib/net_analyze.c
===================================================================
--- grass/trunk/lib/vector/Vlib/net_analyze.c	2017-02-26 10:14:27 UTC (rev 70676)
+++ grass/trunk/lib/vector/Vlib/net_analyze.c	2017-02-26 13:24:05 UTC (rev 70677)
@@ -150,6 +150,9 @@
     /* 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 @@
 	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 @@
 			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 @@
 		    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 @@
 
 	if (costs)
 	    *costs = cur_cst;
+	if (Points)
+	    Vect_line_prune(Points);
     }
 
     return reachable;



More information about the grass-commit mailing list