[GRASS-SVN] r52830 - grass/trunk/vector/v.net.salesman

svn_grass at osgeo.org svn_grass at osgeo.org
Tue Aug 21 13:30:11 PDT 2012


Author: mmetz
Date: 2012-08-21 13:30:10 -0700 (Tue, 21 Aug 2012)
New Revision: 52830

Modified:
   grass/trunk/vector/v.net.salesman/main.c
Log:
v.net.salesman: fix #1659, should be applied to all other v.net.* modules

Modified: grass/trunk/vector/v.net.salesman/main.c
===================================================================
--- grass/trunk/vector/v.net.salesman/main.c	2012-08-21 19:48:48 UTC (rev 52829)
+++ grass/trunk/vector/v.net.salesman/main.c	2012-08-21 20:30:10 UTC (rev 52830)
@@ -296,10 +296,34 @@
 		Vect_net_shortest_path(&Map, cities[i], cities[j], NULL,
 				       &cost);
 
-	    if (ret == -1)
-		G_fatal_error(_("Destination node [%d] is unreachable "
-				"from node [%d]"), cities[i], cities[j]);
+	    if (ret == -1) {
+		double coor_x, coor_y, coor_z;
+		int cat1, cat2;
+		
+		Vect_get_node_coor(&Map, cities[i], &coor_x, &coor_y, &coor_z);
+		line = Vect_find_line(&Map, coor_x, coor_y, coor_z, GV_POINT, 0, 0, 0);
+		
+		if (!line)
+		    G_fatal_error(_("No point at node %d"), cities[i]);
 
+		Vect_read_line(&Map, Points, Cats, line);
+		if (!(Vect_cat_get(Cats, tfield, &cat1)))
+		    G_fatal_error(_("No category for point at node %d"), cities[i]);
+
+		Vect_get_node_coor(&Map, cities[j], &coor_x, &coor_y, &coor_z);
+		line = Vect_find_line(&Map, coor_x, coor_y, coor_z, GV_POINT, 0, 0, 0);
+		
+		if (!line)
+		    G_fatal_error(_("No point at node %d"), cities[j]);
+
+		Vect_read_line(&Map, Points, Cats, line);
+		if (!(Vect_cat_get(Cats, tfield, &cat2)))
+		    G_fatal_error(_("No category for point at node %d"), cities[j]);
+
+		G_fatal_error(_("Destination node [cat %d] is unreachable "
+				"from node [cat %d]"), cat1, cat2);
+	    }
+
 	    /* add to directional cost cache: from, to, cost */
 	    costs[i][k].city = j;
 	    costs[i][k].cost = cost;



More information about the grass-commit mailing list