浏览代码

v.net.salesman: fix https://trac.osgeo.org/grass/ticket/1659, should be applied to all other v.net.* modules

git-svn-id: https://svn.osgeo.org/grass/grass/trunk@52830 15284696-431f-4ddb-bdfa-cd5b030d7da7
Markus Metz 12 年之前
父节点
当前提交
2ad02e0ff3
共有 1 个文件被更改,包括 27 次插入3 次删除
  1. 27 3
      vector/v.net.salesman/main.c

+ 27 - 3
vector/v.net.salesman/main.c

@@ -296,9 +296,33 @@ int main(int argc, char **argv)
 		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;