[GRASS-SVN] r56090 - in grass/trunk/vector: v.generalize v.net.bridge v.net.centrality v.net.components v.net.connectivity v.net.distance v.net.flow v.net.spanningtree v.net.timetable

svn_grass at osgeo.org svn_grass at osgeo.org
Thu May 2 14:37:44 PDT 2013


Author: martinl
Date: 2013-05-02 14:37:44 -0700 (Thu, 02 May 2013)
New Revision: 56090

Modified:
   grass/trunk/vector/v.generalize/network.c
   grass/trunk/vector/v.net.bridge/main.c
   grass/trunk/vector/v.net.centrality/main.c
   grass/trunk/vector/v.net.components/main.c
   grass/trunk/vector/v.net.connectivity/main.c
   grass/trunk/vector/v.net.distance/main.c
   grass/trunk/vector/v.net.flow/main.c
   grass/trunk/vector/v.net.spanningtree/main.c
   grass/trunk/vector/v.net.timetable/main.c
Log:
update v.net modules to use Vect_net_get_graph()
       remove unused variables


Modified: grass/trunk/vector/v.generalize/network.c
===================================================================
--- grass/trunk/vector/v.generalize/network.c	2013-05-02 21:36:24 UTC (rev 56089)
+++ grass/trunk/vector/v.generalize/network.c	2013-05-02 21:37:44 UTC (rev 56090)
@@ -85,9 +85,11 @@
     double *betw, *betweeness;
     struct ilist **prev;
 
-    Vect_net_build_graph(In, mask_type, 0, 0, NULL, NULL, NULL, 0,
-			 0);
-    gr = &(In->graph);
+    if (0 != Vect_net_build_graph(In, mask_type, 0, 0, NULL, NULL, NULL, 0, 0))
+        G_fatal_error(_("Unable to build graph for vector map <%s>"), Vect_get_full_name(In));
+    
+    gr = Vect_net_get_graph(In);
+    
     /* build own graph by edge<->vertex */
     /* each vertex represents undirected edge */
     if (!graph_init(&g, dglGet_EdgeCount(gr) / 2 + 1)) {

Modified: grass/trunk/vector/v.net.bridge/main.c
===================================================================
--- grass/trunk/vector/v.net.bridge/main.c	2013-05-02 21:36:24 UTC (rev 56089)
+++ grass/trunk/vector/v.net.bridge/main.c	2013-05-02 21:37:44 UTC (rev 56090)
@@ -129,9 +129,11 @@
     afield = Vect_get_field_number(&In, afield_opt->answer);
     nfield = Vect_get_field_number(&In, nfield_opt->answer);
 
-    Vect_net_build_graph(&In, mask_type, afield, nfield, afcol->answer,
-                         abcol->answer, ncol->answer, 0, 0);
-    graph = &(In.graph);
+    if (0 != Vect_net_build_graph(&In, mask_type, afield, nfield, afcol->answer,
+                                  abcol->answer, ncol->answer, 0, 0))
+        G_fatal_error(_("Unable to build graph for vector map <%s>"), Vect_get_full_name(&In));
+    
+    graph = Vect_net_get_graph(&In);
 
     Vect_copy_head_data(&In, &Out);
     Vect_hist_copy(&In, &Out);

Modified: grass/trunk/vector/v.net.centrality/main.c
===================================================================
--- grass/trunk/vector/v.net.centrality/main.c	2013-05-02 21:36:24 UTC (rev 56089)
+++ grass/trunk/vector/v.net.centrality/main.c	2013-05-02 21:37:44 UTC (rev 56090)
@@ -279,9 +279,11 @@
     Vect_hist_copy(&In, &Out);
     Vect_hist_command(&Out);
 
-    Vect_net_build_graph(&In, mask_type, afield, nfield, afcol->answer,
-			 abcol->answer, ncol->answer, geo, 0);
-    graph = &(In.graph);
+    if (0 != Vect_net_build_graph(&In, mask_type, afield, nfield, afcol->answer,
+                                  abcol->answer, ncol->answer, geo, 0))
+        G_fatal_error(_("Unable to build graph for vector map <%s>"), Vect_get_full_name(&In));
+    
+    graph = Vect_net_get_graph(&In);
     nnodes = dglGet_NodeCount(graph);
 
     deg = closeness = betw = eigen = NULL;
@@ -324,7 +326,7 @@
 	NetA_betweenness_closeness(graph, betw, closeness);
 	if (closeness)
 	    for (i = 1; i <= nnodes; i++)
-		closeness[i] /= (double)In.cost_multip;
+		closeness[i] /= (double)In.dgraph.cost_multip;
     }
     if (eigen_opt->answer) {
 	G_message(_("Computing eigenvector centrality measure"));

Modified: grass/trunk/vector/v.net.components/main.c
===================================================================
--- grass/trunk/vector/v.net.components/main.c	2013-05-02 21:36:24 UTC (rev 56089)
+++ grass/trunk/vector/v.net.components/main.c	2013-05-02 21:37:44 UTC (rev 56090)
@@ -157,10 +157,11 @@
     afield = Vect_get_field_number(&In, afield_opt->answer);
     nfield = Vect_get_field_number(&In, nfield_opt->answer);
 
-    Vect_net_build_graph(&In, mask_type, afield, nfield, afcol->answer,
-                         abcol->answer, ncol->answer, 0, 0);
+    if (0 != Vect_net_build_graph(&In, mask_type, afield, nfield, afcol->answer,
+                                  abcol->answer, ncol->answer, 0, 0))
+        G_fatal_error(_("Unable to build graph for vector map <%s>"), Vect_get_full_name(&In));
 
-    graph = &(In.graph);
+    graph = Vect_net_get_graph(&In);
     nnodes = Vect_get_num_nodes(&In);
     component = (int *)G_calloc(nnodes + 1, sizeof(int));
     covered = (char *)G_calloc(nnodes + 1, sizeof(char));

Modified: grass/trunk/vector/v.net.connectivity/main.c
===================================================================
--- grass/trunk/vector/v.net.connectivity/main.c	2013-05-02 21:36:24 UTC (rev 56089)
+++ grass/trunk/vector/v.net.connectivity/main.c	2013-05-02 21:37:44 UTC (rev 56090)
@@ -28,7 +28,6 @@
 int main(int argc, char *argv[])
 {
     struct Map_info In, Out;
-    static struct line_pnts *Points;
     struct line_cats *Cats;
     struct GModule *module;	/* GRASS module for parsing arguments */
     struct Option *map_in, *map_out;
@@ -39,7 +38,7 @@
     int afield, nfield, mask_type;
     struct varray *varray_set1, *varray_set2;
     dglGraph_s *graph;
-    int i, nnodes, nlines, *flow, total_flow, nedges;
+    int i, nnodes, *flow, total_flow, nedges;
     struct ilist *set1_list, *set2_list, *cut;
     int *node_costs;
 
@@ -120,7 +119,6 @@
     /* TODO: make an option for this */
     mask_type = GV_LINE | GV_BOUNDARY;
 
-    Points = Vect_new_line_struct();
     Cats = Vect_new_cats_struct();
 
     Vect_check_input_output_name(map_in->answer, map_out->answer,
@@ -163,7 +161,6 @@
     NetA_varray_to_nodes(&In, varray_set1, set1_list, NULL);
     NetA_varray_to_nodes(&In, varray_set2, set2_list, NULL);
 
-    nlines = Vect_get_num_lines(&In);
     nnodes = Vect_get_num_nodes(&In);
 
     if (set1_list->n_values == 0)
@@ -176,10 +173,11 @@
     Vect_hist_copy(&In, &Out);
     Vect_hist_command(&Out);
 
-    Vect_net_build_graph(&In, mask_type, afield, nfield, afcol->answer,
-                         abcol->answer, ncol->answer, 0, 0);
+    if (0 != Vect_net_build_graph(&In, mask_type, afield, nfield, afcol->answer,
+                                  abcol->answer, ncol->answer, 0, 0))
+        G_fatal_error(_("Unable to build graph for vector map <%s>"), Vect_get_full_name(&In));
 
-    graph = &(In.graph);
+    graph = Vect_net_get_graph(&In);
 
     /*build new graph */
     if (ncol->answer) {

Modified: grass/trunk/vector/v.net.distance/main.c
===================================================================
--- grass/trunk/vector/v.net.distance/main.c	2013-05-02 21:36:24 UTC (rev 56089)
+++ grass/trunk/vector/v.net.distance/main.c	2013-05-02 21:37:44 UTC (rev 56090)
@@ -229,14 +229,15 @@
 
     nodest = Vect_new_list();
     NetA_varray_to_nodes(&In, varrayt, nodest, nodes_to_features);
-
+    
     if (nodest->n_values == 0)
 	G_fatal_error(_("No 'to' features"));
+    
+    if (0 != Vect_net_build_graph(&In, atype, afield, nfield, afcol->answer, abcol->answer,
+                                   ncol->answer, geo, 0))
+        G_fatal_error(_("Unable to build graph for vector map <%s>"), Vect_get_full_name(&In));
 
-    Vect_net_build_graph(&In, atype, afield, nfield, afcol->answer, abcol->answer,
-			 ncol->answer, geo, 0);
-
-    graph = &(In.graph);
+    graph = Vect_net_get_graph(&In);
     NetA_distance_from_points(graph, nodest, dst, prev);
 
     /* Create table */
@@ -298,7 +299,7 @@
 		from_nr++;
  		continue;
 	    }
-	    cost = dst[node] / (double)In.cost_multip;
+	    cost = dst[node] / (double)In.dgraph.cost_multip;
 	    vertex = dglGetNode(graph, node);
 	    vertex_id = node;
 	    while (prev[vertex_id] != NULL) {

Modified: grass/trunk/vector/v.net.flow/main.c
===================================================================
--- grass/trunk/vector/v.net.flow/main.c	2013-05-02 21:36:24 UTC (rev 56089)
+++ grass/trunk/vector/v.net.flow/main.c	2013-05-02 21:37:44 UTC (rev 56090)
@@ -220,10 +220,11 @@
     Vect_hist_copy(&In, &Out);
     Vect_hist_command(&Out);
 
-    Vect_net_build_graph(&In, mask_type, afield, nfield, afcol->answer, abcol->answer,
-			 ncol->answer, 0, 0);
-
-    graph = &(In.graph);
+    if (0 != Vect_net_build_graph(&In, mask_type, afield, nfield, afcol->answer, abcol->answer,
+                                  ncol->answer, 0, 0))
+        G_fatal_error(_("Unable to build graph for vector map <%s>"), Vect_get_full_name(&In));
+    
+    graph = Vect_net_get_graph(&In);
     nlines = Vect_get_num_lines(&In);
     flow = (int *)G_calloc(nlines + 1, sizeof(int));
     if (!flow)
@@ -251,7 +252,7 @@
 	    if (cat == -1)
 		continue;	/*TODO: warning? */
 	    sprintf(buf, "insert into %s values (%d, %f)", Fi->table, cat,
-		    flow[i] / (double)In.cost_multip);
+		    flow[i] / (double)In.dgraph.cost_multip);
 	    db_set_string(&sql, buf);
 	    G_debug(3, db_get_string(&sql));
 

Modified: grass/trunk/vector/v.net.spanningtree/main.c
===================================================================
--- grass/trunk/vector/v.net.spanningtree/main.c	2013-05-02 21:36:24 UTC (rev 56089)
+++ grass/trunk/vector/v.net.spanningtree/main.c	2013-05-02 21:37:44 UTC (rev 56090)
@@ -119,10 +119,11 @@
     afield = Vect_get_field_number(&In, afield_opt->answer);
     nfield = Vect_get_field_number(&In, nfield_opt->answer);
 
-    Vect_net_build_graph(&In, mask_type, afield, nfield, afcol->answer, NULL,
-			 ncol->answer, geo, 0);
+    if (0 != Vect_net_build_graph(&In, mask_type, afield, nfield, afcol->answer, NULL,
+                                  ncol->answer, geo, 0))
+        G_fatal_error(_("Unable to build graph for vector map <%s>"), Vect_get_full_name(&In));
 
-    graph = &(In.graph);
+    graph = Vect_net_get_graph(&In);
 
     Vect_copy_head_data(&In, &Out);
     Vect_hist_copy(&In, &Out);

Modified: grass/trunk/vector/v.net.timetable/main.c
===================================================================
--- grass/trunk/vector/v.net.timetable/main.c	2013-05-02 21:36:24 UTC (rev 56089)
+++ grass/trunk/vector/v.net.timetable/main.c	2013-05-02 21:37:44 UTC (rev 56090)
@@ -228,7 +228,7 @@
 int main(int argc, char *argv[])
 {
     static struct line_pnts *Points, *Cur, *Prev;
-    struct line_cats *Counter_Cats, *Cats;
+    struct line_cats *Cats;
     struct GModule *module;	/* GRASS module for parsing arguments */
     struct Option *map_in, *map_out;
     struct Option *tfield_opt,		  /* Input map: layer with existing timetable */
@@ -341,7 +341,6 @@
 
     Points = Vect_new_line_struct();
     Cats = Vect_new_cats_struct();
-    Counter_Cats = Vect_new_cats_struct();
     Cur = Vect_new_line_struct();
     Prev = Vect_new_line_struct();
 
@@ -401,9 +400,11 @@
 	for (i = 0; i < timetable.routes; i++)
 	    lines[i] = Vect_new_list();
 
-	Vect_net_build_graph(&In, mask_type, afield, nfield, afcol->answer,
-			     abcol->answer, ncol->answer, 0, 0);
-	graph = &(In.graph);
+	if (0 != Vect_net_build_graph(&In, mask_type, afield, nfield, afcol->answer,
+                                      abcol->answer, ncol->answer, 0, 0))
+            G_fatal_error(_("Unable to build graph for vector map <%s>"), Vect_get_full_name(&In));
+        
+	graph = Vect_net_get_graph(&In);
     }
 
 



More information about the grass-commit mailing list