[GRASS-SVN] r52124 - grass/trunk/vector/v.net.distance

svn_grass at osgeo.org svn_grass at osgeo.org
Mon Jun 18 06:50:55 PDT 2012


Author: mmetz
Date: 2012-06-18 06:50:55 -0700 (Mon, 18 Jun 2012)
New Revision: 52124

Modified:
   grass/trunk/vector/v.net.distance/main.c
Log:
v.net.distance fix for unreachable features

Modified: grass/trunk/vector/v.net.distance/main.c
===================================================================
--- grass/trunk/vector/v.net.distance/main.c	2012-06-18 13:13:43 UTC (rev 52123)
+++ grass/trunk/vector/v.net.distance/main.c	2012-06-18 13:50:55 UTC (rev 52124)
@@ -30,7 +30,7 @@
 {
     struct Map_info In, Out;
     static struct line_pnts *Points;
-    struct line_cats *Cats;
+    struct line_cats *Cats, *TCats;
     struct GModule *module;	/* GRASS module for parsing arguments */
     struct Option *map_in, *map_out;
     struct Option *catf_opt, *fieldf_opt, *wheref_opt;
@@ -164,6 +164,7 @@
 
     Points = Vect_new_line_struct();
     Cats = Vect_new_cats_struct();
+    TCats = Vect_new_cats_struct();
 
     Vect_check_input_output_name(map_in->answer, map_out->answer,
 				 G_FATAL_EXIT);
@@ -279,7 +280,8 @@
 	    }
 	    if (node < 1)
 		continue;
-	    Vect_write_line(&Out, type, Points, Cats);
+	    if (dst[node] < 0)
+		continue; /* unreachable */
 	    cost = dst[node] / (double)In.cost_multip;
 	    vertex = dglGetNode(graph, node);
 	    vertex_id = node;
@@ -290,9 +292,12 @@
 		vertex = dglEdgeGet_Head(graph, prev[vertex_id]);
 		vertex_id = dglNodeGet_Id(graph, vertex);
 	    }
-	    Vect_read_line(&In, NULL, Cats, nodes_to_features[vertex_id]);
-	    if (!Vect_cat_get(Cats, tlayer, &tcat))
+	    G_debug(3, "read line %d, vertex id %d", nodes_to_features[vertex_id], (int)vertex_id);
+	    Vect_read_line(&In, NULL, TCats, nodes_to_features[vertex_id]);
+	    if (!Vect_cat_get(TCats, tlayer, &tcat))
 		continue;
+
+	    Vect_write_line(&Out, type, Points, Cats);
 	    sprintf(buf, "insert into %s values (%d, %d, %f)", Fi->table, cat,
 		    tcat, cost);
 



More information about the grass-commit mailing list