[GRASS-SVN] r48060 - in grass/trunk/vector: v.net.alloc v.net.allpairs v.net.bridge v.net.centrality v.net.components v.net.connectivity v.net.distance v.net.flow v.net.iso v.net.path v.net.salesman v.net.spanningtree v.net.steiner v.net.timetable

svn_grass at osgeo.org svn_grass at osgeo.org
Fri Sep 2 06:46:41 EDT 2011


Author: mmetz
Date: 2011-09-02 03:46:41 -0700 (Fri, 02 Sep 2011)
New Revision: 48060

Modified:
   grass/trunk/vector/v.net.alloc/main.c
   grass/trunk/vector/v.net.allpairs/main.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.iso/main.c
   grass/trunk/vector/v.net.path/path.c
   grass/trunk/vector/v.net.salesman/main.c
   grass/trunk/vector/v.net.spanningtree/main.c
   grass/trunk/vector/v.net.steiner/main.c
   grass/trunk/vector/v.net.timetable/main.c
Log:
vector network module maintenance, solve#1361

Modified: grass/trunk/vector/v.net.alloc/main.c
===================================================================
--- grass/trunk/vector/v.net.alloc/main.c	2011-09-02 09:11:23 UTC (rev 48059)
+++ grass/trunk/vector/v.net.alloc/main.c	2011-09-02 10:46:41 UTC (rev 48060)
@@ -37,9 +37,9 @@
 
 int main(int argc, char **argv)
 {
-    int i, j, ret, center, line, center1, center2;
+    int i, ret, center, line, center1, center2;
     int nlines, nnodes, type, ltype, afield, nfield, geo, cat;
-    int node, node1, node2;
+    int node1, node2;
     double cost, e1cost, e2cost, n1cost, n2cost, s1cost, s2cost, l, l1, l2;
     struct Option *map, *output;
     struct Option *afield_opt, *nfield_opt, *afcol, *abcol, *ncol, *type_opt,
@@ -127,8 +127,6 @@
     SPoints = Vect_new_line_struct();
 
     type = Vect_option_to_types(type_opt);
-    afield = atoi(afield_opt->answer);
-    nfield = atoi(nfield_opt->answer);
 
     catlist = Vect_new_cat_list();
     Vect_str_to_cat_list(term_opt->answer, catlist);
@@ -141,6 +139,9 @@
     Vect_set_open_level(2);
     Vect_open_old(&Map, map->answer, "");
 
+    afield = Vect_get_field_number(&Map, afield_opt->answer);
+    nfield = Vect_get_field_number(&Map, nfield_opt->answer);
+
     /* Build graph */
     Vect_net_build_graph(&Map, type, afield, nfield, afcol->answer,
 			 abcol->answer, ncol->answer, geo, 0);
@@ -185,39 +186,6 @@
 	}
     }
 
-#if 0
-    for (node = 1; node <= nnodes; node++) {
-	nlines = Vect_get_node_n_lines(&Map, node);
-	for (j = 0; j < nlines; j++) {
-	    line = abs(Vect_get_node_line(&Map, node, j));
-	    ltype = Vect_read_line(&Map, NULL, Cats, line);
-	    if (!(ltype & GV_POINT))
-		continue;
-	    if (!(Vect_cat_get(Cats, nfield, &cat)))
-		continue;
-	    if (Vect_cat_in_cat_list(cat, catlist)) {
-		Vect_net_get_node_cost(&Map, node, &n1cost);
-		if (n1cost == -1) {	/* closed */
-		    G_warning("center at closed node (costs = -1) ignored");
-		}
-		else {
-		    if (acenters == ncenters) {
-			acenters += 1;
-			Centers =
-			    (CENTER *) G_realloc(Centers,
-						 acenters * sizeof(CENTER));
-		    }
-		    Centers[ncenters].cat = cat;
-		    Centers[ncenters].node = node;
-		    G_debug(2, "center = %d node = %d cat = %d", ncenters,
-			    node, cat);
-		    ncenters++;
-		}
-	    }
-	}
-    }
-#endif
-
     G_message(_("Number of centers: [%d] (nlayer: [%d])"), ncenters, nfield);
 
     if (ncenters == 0)

Modified: grass/trunk/vector/v.net.allpairs/main.c
===================================================================
--- grass/trunk/vector/v.net.allpairs/main.c	2011-09-02 09:11:23 UTC (rev 48059)
+++ grass/trunk/vector/v.net.allpairs/main.c	2011-09-02 10:46:41 UTC (rev 48060)
@@ -31,10 +31,12 @@
     struct line_cats *Cats;
     struct GModule *module;	/* GRASS module for parsing arguments */
     struct Option *map_in, *map_out;
-    struct Option *cat_opt, *field_opt, *where_opt, *abcol, *afcol;
+    struct Option *cat_opt, *afield_opt, *nfield_opt, *where_opt, *abcol,
+                  *afcol, *ncol;
     struct Flag *geo_f, *newpoints_f;
+    int afield, nfield;
     int chcat, with_z;
-    int layer, mask_type;
+    int mask_type;
     struct varray *varray;
     dglGraph_s *graph;
     int i, j, geo, nnodes, nlines, max_cat, *cats;
@@ -61,8 +63,18 @@
     map_in = G_define_standard_option(G_OPT_V_INPUT);
     map_out = G_define_standard_option(G_OPT_V_OUTPUT);
 
-    field_opt = G_define_standard_option(G_OPT_V_FIELD);
-    field_opt->guisection = _("Selection");
+    afield_opt = G_define_standard_option(G_OPT_V_FIELD);
+    afield_opt->key = "alayer";
+    afield_opt->answer = "1";
+    afield_opt->description = _("Arc layer");
+    afield_opt->guisection = _("Selection");
+
+    nfield_opt = G_define_standard_option(G_OPT_V_FIELD);
+    nfield_opt->key = "nlayer";
+    nfield_opt->answer = "2";
+    nfield_opt->description = _("Node layer");
+    nfield_opt->guisection = _("Selection");
+
     cat_opt = G_define_standard_option(G_OPT_V_CATS);
     cat_opt->guisection = _("Selection");
     where_opt = G_define_standard_option(G_OPT_DB_WHERE);
@@ -72,15 +84,22 @@
     afcol->key = "afcolumn";
     afcol->required = NO;
     afcol->description =
-	_("Name of arc forward/both direction(s) cost column");
+	_("Arc forward/both direction(s) cost column (number)");
     afcol->guisection = _("Cost");
 
     abcol = G_define_standard_option(G_OPT_DB_COLUMN);
     abcol->key = "abcolumn";
     abcol->required = NO;
-    abcol->description = _("Name of arc backward direction cost column");
+    abcol->description = _("Arc backward direction cost column (number)");
     abcol->guisection = _("Cost");
 
+    ncol = G_define_option();
+    ncol->key = "ncolumn";
+    ncol->type = TYPE_STRING;
+    ncol->required = NO;
+    ncol->description = _("Node cost column (number)");
+    ncol->guisection = _("Cost");
+
     geo_f = G_define_flag();
     geo_f->key = 'g';
     geo_f->description =
@@ -123,10 +142,12 @@
 	geo = 0;
 
     /* parse filter option and select appropriate lines */
-    layer = atoi(field_opt->answer);
+    afield = Vect_get_field_number(&In, afield_opt->answer);
+    nfield = Vect_get_field_number(&In, nfield_opt->answer);
+
     chcat =
 	(NetA_initialise_varray
-	 (&In, layer, GV_POINT, where_opt->answer, cat_opt->answer,
+	 (&In, afield, GV_POINT, where_opt->answer, cat_opt->answer,
 	  &varray) == 1);
 
     /* Create table */
@@ -161,8 +182,8 @@
     db_begin_transaction(driver);
 
 
-    Vect_net_build_graph(&In, mask_type, atoi(field_opt->answer), 0,
-			 afcol->answer, abcol->answer, NULL, geo, 0);
+    Vect_net_build_graph(&In, mask_type, afield, nfield,
+			 afcol->answer, abcol->answer, ncol->answer, geo, 0);
     graph = &(In.graph);
     nnodes = dglGet_NodeCount(graph);
     dist = (dglInt32_t **) G_calloc(nnodes + 1, sizeof(dglInt32_t *));
@@ -196,7 +217,7 @@
 
 	    /* Vect_get_line_nodes(&In, i, &node, NULL); */
 	    node = Vect_find_node(&In, Points->x[0], Points->y[0], Points->z[0], 0, 0);
-	    Vect_cat_get(Cats, layer, &cats[node]);
+	    Vect_cat_get(Cats, afield, &cats[node]);
 	    if (cats[node] != -1) {
 		Vect_write_line(&Out, GV_POINT, Points, Cats);
 		if (!chcat || varray->c[i])

Modified: grass/trunk/vector/v.net.bridge/main.c
===================================================================
--- grass/trunk/vector/v.net.bridge/main.c	2011-09-02 09:11:23 UTC (rev 48059)
+++ grass/trunk/vector/v.net.bridge/main.c	2011-09-02 10:46:41 UTC (rev 48060)
@@ -30,9 +30,10 @@
     struct line_cats *Cats;
     struct GModule *module;	/* GRASS module for parsing arguments */
     struct Option *map_in, *map_out;
-    struct Option *field_opt, *method_opt;
+    struct Option *afield_opt, *nfield_opt, *abcol, *afcol, *ncol,
+                  *method_opt;
     int with_z;
-    int layer, mask_type;
+    int afield, nfield, mask_type;
     dglGraph_s *graph;
     int i, bridges, articulations;
     struct ilist *bridge_list, *articulation_list;
@@ -52,8 +53,38 @@
     map_in = G_define_standard_option(G_OPT_V_INPUT);
     map_out = G_define_standard_option(G_OPT_V_OUTPUT);
 
-    field_opt = G_define_standard_option(G_OPT_V_FIELD);
+    afield_opt = G_define_standard_option(G_OPT_V_FIELD);
+    afield_opt->key = "alayer";
+    afield_opt->answer = "1";
+    afield_opt->description = _("Arc layer");
+    afield_opt->guisection = _("Cost");
 
+    nfield_opt = G_define_standard_option(G_OPT_V_FIELD);
+    nfield_opt->key = "nlayer";
+    nfield_opt->answer = "2";
+    nfield_opt->description = _("Node layer");
+    nfield_opt->guisection = _("Cost");
+
+    afcol = G_define_standard_option(G_OPT_DB_COLUMN);
+    afcol->key = "afcolumn";
+    afcol->required = NO;
+    afcol->description =
+	_("Arc forward/both direction(s) cost column (number)");
+    afcol->guisection = _("Cost");
+
+    abcol = G_define_standard_option(G_OPT_DB_COLUMN);
+    abcol->key = "abcolumn";
+    abcol->required = NO;
+    abcol->description = _("Arc backward direction cost column (number)");
+    abcol->guisection = _("Cost");
+
+    ncol = G_define_option();
+    ncol->key = "ncolumn";
+    ncol->type = TYPE_STRING;
+    ncol->required = NO;
+    ncol->description = _("Node cost column (number)");
+    ncol->guisection = _("Cost");
+
     method_opt = G_define_option();
     method_opt->key = "method";
     method_opt->type = TYPE_STRING;
@@ -90,9 +121,11 @@
 
 
     /* parse filter option and select appropriate lines */
-    layer = atoi(field_opt->answer);
+    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, 0, 0, NULL, NULL, NULL, 0, 0);
+    Vect_net_build_graph(&In, mask_type, afield, nfield, afcol->answer,
+                         abcol->answer, ncol->answer, 0, 0);
     graph = &(In.graph);
 
     Vect_copy_head_data(&In, &Out);

Modified: grass/trunk/vector/v.net.centrality/main.c
===================================================================
--- grass/trunk/vector/v.net.centrality/main.c	2011-09-02 09:11:23 UTC (rev 48059)
+++ grass/trunk/vector/v.net.centrality/main.c	2011-09-02 10:46:41 UTC (rev 48060)
@@ -77,11 +77,12 @@
     struct line_cats *Cats;
     struct GModule *module;	/* GRASS module for parsing arguments */
     struct Option *map_in, *map_out;
-    struct Option *cat_opt, *field_opt, *where_opt, *abcol, *afcol;
+    struct Option *cat_opt, *where_opt, *afield_opt, *nfield_opt, *abcol,
+                  *afcol, *ncol;
     struct Option *iter_opt, *error_opt;
     struct Flag *geo_f, *add_f;
     int chcat, with_z;
-    int layer, mask_type;
+    int afield, nfield, mask_type;
     struct varray *varray;
     dglGraph_s *graph;
     int i, geo, nnodes, nlines, j, max_cat;
@@ -101,8 +102,19 @@
 
     /* Define the different options as defined in gis.h */
     map_in = G_define_standard_option(G_OPT_V_INPUT);
-    field_opt = G_define_standard_option(G_OPT_V_FIELD);
 
+    afield_opt = G_define_standard_option(G_OPT_V_FIELD);
+    afield_opt->key = "alayer";
+    afield_opt->answer = "1";
+    afield_opt->description = _("Arc layer");
+    afield_opt->guisection = _("Cost");
+
+    nfield_opt = G_define_standard_option(G_OPT_V_FIELD);
+    nfield_opt->key = "nlayer";
+    nfield_opt->answer = "2";
+    nfield_opt->description = _("Node layer");
+    nfield_opt->guisection = _("Cost");
+
     map_out = G_define_standard_option(G_OPT_V_OUTPUT);
 
     cat_opt = G_define_standard_option(G_OPT_V_CATS);
@@ -114,15 +126,22 @@
     afcol->key = "afcolumn";
     afcol->required = NO;
     afcol->description =
-	_("Name of arc forward/both direction(s) cost column");
+	_("Arc forward/both direction(s) cost column (number)");
     afcol->guisection = _("Cost");
 
     abcol = G_define_standard_option(G_OPT_DB_COLUMN);
     abcol->key = "abcolumn";
     abcol->required = NO;
-    abcol->description = _("Name of arc backward direction cost column");
+    abcol->description = _("Arc backward direction cost column (number)");
     abcol->guisection = _("Cost");
 
+    ncol = G_define_option();
+    ncol->key = "ncolumn";
+    ncol->type = TYPE_STRING;
+    ncol->required = NO;
+    ncol->description = _("Node cost column (number)");
+    ncol->guisection = _("Cost");
+
     deg_opt = G_define_standard_option(G_OPT_DB_COLUMN);
     deg_opt->key = "degree";
     deg_opt->required = NO;
@@ -206,10 +225,12 @@
 	geo = 0;
 
     /* parse filter option and select appropriate lines */
-    layer = atoi(field_opt->answer);
+    afield = Vect_get_field_number(&In, afield_opt->answer);
+    nfield = Vect_get_field_number(&In, nfield_opt->answer);
+
     chcat =
 	(NetA_initialise_varray
-	 (&In, layer, mask_type, where_opt->answer, cat_opt->answer,
+	 (&In, afield, mask_type, where_opt->answer, cat_opt->answer,
 	  &varray) == 1);
 
     /* Create table */
@@ -255,8 +276,8 @@
     Vect_hist_copy(&In, &Out);
     Vect_hist_command(&Out);
 
-    Vect_net_build_graph(&In, mask_type, atoi(field_opt->answer), 0,
-			 afcol->answer, abcol->answer, NULL, geo, 0);
+    Vect_net_build_graph(&In, mask_type, afield, nfield, afcol->answer,
+			 abcol->answer, ncol->answer, geo, 0);
     graph = &(In.graph);
     nnodes = dglGet_NodeCount(graph);
 
@@ -319,7 +340,7 @@
 	if (type == GV_POINT && (!chcat || varray->c[i])) {
 	    int cat, node;
 
-	    if (!Vect_cat_get(Cats, layer, &cat))
+	    if (!Vect_cat_get(Cats, afield, &cat))
 		continue;
 	    Vect_write_line(&Out, type, Points, Cats);
 	    node = Vect_find_node(&In, Points->x[0], Points->y[0], Points->z[0], 0, 0);

Modified: grass/trunk/vector/v.net.components/main.c
===================================================================
--- grass/trunk/vector/v.net.components/main.c	2011-09-02 09:11:23 UTC (rev 48059)
+++ grass/trunk/vector/v.net.components/main.c	2011-09-02 10:46:41 UTC (rev 48060)
@@ -48,10 +48,11 @@
     struct line_cats *Cats;
     struct GModule *module;	/* GRASS module for parsing arguments */
     struct Option *map_in, *map_out;
-    struct Option *field_opt, *method_opt;
+    struct Option *method_opt, *afield_opt, *nfield_opt, *abcol,
+                  *afcol, *ncol;
     struct Flag *add_f;
     int with_z;
-    int layer, mask_type;
+    int afield, nfield, mask_type;
     dglGraph_s *graph;
     int *component, nnodes, type, i, nlines, components, j, max_cat;
     char buf[2000], *covered;
@@ -74,8 +75,39 @@
 
     /* Define the different options as defined in gis.h */
     map_in = G_define_standard_option(G_OPT_V_INPUT);
-    field_opt = G_define_standard_option(G_OPT_V_FIELD);
 
+    afield_opt = G_define_standard_option(G_OPT_V_FIELD);
+    afield_opt->key = "alayer";
+    afield_opt->answer = "1";
+    afield_opt->description = _("Arc layer");
+    afield_opt->guisection = _("Cost");
+
+    nfield_opt = G_define_standard_option(G_OPT_V_FIELD);
+    nfield_opt->key = "nlayer";
+    nfield_opt->answer = "2";
+    nfield_opt->description = _("Node layer");
+    nfield_opt->guisection = _("Cost");
+
+    afcol = G_define_standard_option(G_OPT_DB_COLUMN);
+    afcol->key = "afcolumn";
+    afcol->required = NO;
+    afcol->description =
+	_("Arc forward/both direction(s) cost column (number)");
+    afcol->guisection = _("Cost");
+
+    abcol = G_define_standard_option(G_OPT_DB_COLUMN);
+    abcol->key = "abcolumn";
+    abcol->required = NO;
+    abcol->description = _("Arc backward direction cost column (number)");
+    abcol->guisection = _("Cost");
+
+    ncol = G_define_option();
+    ncol->key = "ncolumn";
+    ncol->type = TYPE_STRING;
+    ncol->required = NO;
+    ncol->description = _("Node cost column (number)");
+    ncol->guisection = _("Cost");
+
     map_out = G_define_standard_option(G_OPT_V_OUTPUT);
 
     method_opt = G_define_option();
@@ -116,11 +148,13 @@
 	G_fatal_error(_("Unable to create vector map <%s>"), map_out->answer);
     }
 
-
     /* parse filter option and select appropriate lines */
-    layer = atoi(field_opt->answer);
+    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, 0, 0, NULL, NULL, NULL, 0, 0);
+    Vect_net_build_graph(&In, mask_type, afield, nfield, afcol->answer,
+                         abcol->answer, ncol->answer, 0, 0);
+
     graph = &(In.graph);
     nnodes = Vect_get_num_nodes(&In);
     component = (int *)G_calloc(nnodes + 1, sizeof(int));
@@ -130,8 +164,8 @@
 	exit(EXIT_FAILURE);
     }
     /* Create table */
-    Fi = Vect_default_field_info(&Out, layer, NULL, GV_1TABLE);
-    Vect_map_add_dblink(&Out, layer, NULL, Fi->table, GV_KEY_COLUMN, Fi->database,
+    Fi = Vect_default_field_info(&Out, 1, NULL, GV_1TABLE);
+    Vect_map_add_dblink(&Out, 1, NULL, Fi->table, GV_KEY_COLUMN, Fi->database,
 			Fi->driver);
     db_init_string(&sql);
     driver = db_start_driver_open_database(Fi->driver, Fi->database);
@@ -174,7 +208,7 @@
 	int comp, cat;
 
 	type = Vect_read_line(&In, Points, Cats, i);
-	if (!Vect_cat_get(Cats, layer, &cat))
+	if (!Vect_cat_get(Cats, afield, &cat))
 	    continue;
 	if (type == GV_LINE || type == GV_BOUNDARY) {
 	    int node1, node2;
@@ -218,7 +252,7 @@
 	for (i = 1; i <= nnodes; i++)
 	    if (!covered[i]) {
 		Vect_reset_cats(Cats);
-		Vect_cat_set(Cats, layer, max_cat);
+		Vect_cat_set(Cats, 1, max_cat);
 		NetA_add_point_on_node(&In, &Out, i, Cats);
 		insert_new_record(driver, Fi, &sql, max_cat++, component[i]);
 	    }

Modified: grass/trunk/vector/v.net.connectivity/main.c
===================================================================
--- grass/trunk/vector/v.net.connectivity/main.c	2011-09-02 09:11:23 UTC (rev 48059)
+++ grass/trunk/vector/v.net.connectivity/main.c	2011-09-02 10:46:41 UTC (rev 48060)
@@ -32,11 +32,11 @@
     struct line_cats *Cats;
     struct GModule *module;	/* GRASS module for parsing arguments */
     struct Option *map_in, *map_out;
-    struct Option *field_opt, *ncol;
-    struct Option *catset1_opt, *fieldset1_opt, *whereset1_opt;
-    struct Option *catset2_opt, *fieldset2_opt, *whereset2_opt;
+    struct Option *afield_opt, *nfield_opt, *abcol, *afcol, *ncol;
+    struct Option *catset1_opt, *whereset1_opt;
+    struct Option *catset2_opt, *whereset2_opt;
     int with_z;
-    int layer, mask_type;
+    int afield, nfield, mask_type;
     struct varray *varray_set1, *varray_set2;
     dglGraph_s *graph;
     int i, nnodes, nlines, *flow, total_flow, nedges;
@@ -58,20 +58,40 @@
 
     /* Define the different options as defined in gis.h */
     map_in = G_define_standard_option(G_OPT_V_INPUT);
-    field_opt = G_define_standard_option(G_OPT_V_FIELD);
 
+    afield_opt = G_define_standard_option(G_OPT_V_FIELD);
+    afield_opt->key = "alayer";
+    afield_opt->answer = "1";
+    afield_opt->description = _("Arc layer");
+    afield_opt->guisection = _("Cost");
+
+    nfield_opt = G_define_standard_option(G_OPT_V_FIELD);
+    nfield_opt->key = "nlayer";
+    nfield_opt->answer = "2";
+    nfield_opt->description = _("Node layer");
+    nfield_opt->guisection = _("Cost");
+
+    afcol = G_define_standard_option(G_OPT_DB_COLUMN);
+    afcol->key = "afcolumn";
+    afcol->required = NO;
+    afcol->description =
+	_("Arc forward/both direction(s) cost column (number)");
+    afcol->guisection = _("Cost");
+
+    abcol = G_define_standard_option(G_OPT_DB_COLUMN);
+    abcol->key = "abcolumn";
+    abcol->required = NO;
+    abcol->description = _("Arc backward direction cost column (number)");
+    abcol->guisection = _("Cost");
+
     map_out = G_define_standard_option(G_OPT_V_OUTPUT);
 
     ncol = G_define_standard_option(G_OPT_DB_COLUMN);
     ncol->key = "ncolumn";
     ncol->required = NO;
-    ncol->description = _("Name of node capacity column");
+    ncol->description = _("Node cost column (number)");
+    ncol->guisection = _("Cost");
 
-    fieldset1_opt = G_define_standard_option(G_OPT_V_FIELD);
-    fieldset1_opt->key = "set1_layer";
-    fieldset1_opt->label = _("Set1 layer number or name");
-    fieldset1_opt->guisection = _("Set1");
-
     catset1_opt = G_define_standard_option(G_OPT_V_CATS);
     catset1_opt->key = "set1_cats";
     catset1_opt->label = _("Set1 category values");
@@ -83,11 +103,6 @@
 	_("Set1 WHERE conditions of SQL statement without 'where' keyword");
     whereset1_opt->guisection = _("Set1");
 
-    fieldset2_opt = G_define_standard_option(G_OPT_V_FIELD);
-    fieldset2_opt->key = "set2_layer";
-    fieldset2_opt->description = _("Set2 layer number or name");
-    fieldset2_opt->guisection = _("Set2");
-
     catset2_opt = G_define_standard_option(G_OPT_V_CATS);
     catset2_opt->key = "set2_cats";
     catset2_opt->description = _("Set2 category values");
@@ -124,15 +139,16 @@
     }
 
     /* parse filter option and select appropriate lines */
-    layer = atoi(field_opt->answer);
+    afield = Vect_get_field_number(&In, afield_opt->answer);
+    nfield = Vect_get_field_number(&In, nfield_opt->answer);
 
     if (NetA_initialise_varray
-	(&In, atoi(fieldset1_opt->answer), GV_POINT, whereset1_opt->answer,
+	(&In, nfield, GV_POINT, whereset1_opt->answer,
 	 catset1_opt->answer, &varray_set1) == 2)
 	G_fatal_error(_("Neither %s nor %s was given"), catset1_opt->key,
 		      whereset1_opt->key);
     if (NetA_initialise_varray
-	(&In, atoi(fieldset2_opt->answer), GV_POINT, whereset2_opt->answer,
+	(&In, nfield, GV_POINT, whereset2_opt->answer,
 	 catset2_opt->answer, &varray_set2) == 2)
 	G_fatal_error(_("Neither %s nor %s was given"), catset2_opt->key,
 		      whereset2_opt->key);
@@ -156,8 +172,9 @@
     Vect_hist_copy(&In, &Out);
     Vect_hist_command(&Out);
 
-    Vect_net_build_graph(&In, mask_type, 0, atoi(field_opt->answer),
-			 NULL, NULL, NULL, 0, 0);
+    Vect_net_build_graph(&In, mask_type, afield, nfield, afcol->answer,
+                         abcol->answer, ncol->answer, 0, 0);
+
     graph = &(In.graph);
 
     /*build new graph */
@@ -165,7 +182,7 @@
 	node_costs = (int *)G_calloc(nnodes + 1, sizeof(int));
 	if (!node_costs)
 	    G_fatal_error(_("Out of memory"));
-	NetA_get_node_costs(&In, layer, ncol->answer, node_costs);
+	NetA_get_node_costs(&In, nfield, ncol->answer, node_costs);
 	nedges = NetA_split_vertices(graph, &vg, node_costs);
 	G_free(node_costs);
     }

Modified: grass/trunk/vector/v.net.distance/main.c
===================================================================
--- grass/trunk/vector/v.net.distance/main.c	2011-09-02 09:11:23 UTC (rev 48059)
+++ grass/trunk/vector/v.net.distance/main.c	2011-09-02 10:46:41 UTC (rev 48060)
@@ -31,14 +31,15 @@
     static struct line_pnts *Points;
     struct line_cats *Cats;
     struct GModule *module;	/* GRASS module for parsing arguments */
-    struct Option *map_in, *map_out, *abcol, *afcol;
-    struct Option *catf_opt, *fieldf_opt, *wheref_opt;
-    struct Option *catt_opt, *fieldt_opt, *wheret_opt, *to_type_opt;
+    struct Option *map_in, *map_out;
+    struct Option *catf_opt, *wheref_opt;
+    struct Option *catt_opt, *wheret_opt, *to_type_opt;
+    struct Option *afield_opt, *nfield_opt, *abcol, *afcol, *ncol;
     struct Flag *geo_f;
     int with_z, geo;
     int mask_type;
     struct varray *varrayf, *varrayt;
-    int flayer, tlayer;
+    int afield, nfield;
     dglGraph_s *graph;
     struct ilist *nodest;
     int i, nnodes, nlines;
@@ -70,11 +71,18 @@
     map_in = G_define_standard_option(G_OPT_V_INPUT);
     map_out = G_define_standard_option(G_OPT_V_OUTPUT);
 
-    fieldf_opt = G_define_standard_option(G_OPT_V_FIELD);
-    fieldf_opt->key = "from_layer";
-    fieldf_opt->label = _("From layer number or name");
-    fieldf_opt->guisection = _("From");
+    afield_opt = G_define_standard_option(G_OPT_V_FIELD);
+    afield_opt->key = "alayer";
+    afield_opt->answer = "1";
+    afield_opt->description = _("Arc layer");
+    afield_opt->guisection = _("Cost");
 
+    nfield_opt = G_define_standard_option(G_OPT_V_FIELD);
+    nfield_opt->key = "nlayer";
+    nfield_opt->answer = "2";
+    nfield_opt->description = _("Node layer");
+    nfield_opt->guisection = _("Cost");
+
     catf_opt = G_define_standard_option(G_OPT_V_CATS);
     catf_opt->key = "from_cats";
     catf_opt->label = _("From category values");
@@ -86,11 +94,6 @@
 	_("From WHERE conditions of SQL statement without 'where' keyword");
     wheref_opt->guisection = _("From");
 
-    fieldt_opt = G_define_standard_option(G_OPT_V_FIELD);
-    fieldt_opt->key = "to_layer";
-    fieldt_opt->description = _("To layer number or name");
-    fieldt_opt->guisection = _("To");
-
     catt_opt = G_define_standard_option(G_OPT_V_CATS);
     catt_opt->key = "to_cats";
     catt_opt->label = _("To category values");
@@ -111,14 +114,25 @@
 
     afcol = G_define_standard_option(G_OPT_DB_COLUMN);
     afcol->key = "afcolumn";
-    afcol->required = YES;
-    afcol->description = _("Arc forward/both direction(s) cost column");
+    afcol->required = NO;
+    afcol->description =
+	_("Arc forward/both direction(s) cost column (number)");
+    afcol->guisection = _("Cost");
 
     abcol = G_define_standard_option(G_OPT_DB_COLUMN);
     abcol->key = "abcolumn";
     abcol->required = NO;
-    abcol->description = _("Arc backward direction cost column");
+    abcol->description = _("Arc backward direction cost column (number)");
+    abcol->guisection = _("Cost");
 
+    ncol = G_define_standard_option(G_OPT_DB_COLUMN);
+    ncol->key = "ncolumn";
+    ncol->required = NO;
+    ncol->description = _("Node cost column (number)");
+    ncol->guisection = _("Cost");
+
+    map_out = G_define_standard_option(G_OPT_V_OUTPUT);
+
     geo_f = G_define_flag();
     geo_f->key = 'g';
     geo_f->description =
@@ -173,18 +187,19 @@
 	on_path[i] = Vect_new_cats_struct();
 
     /*initialise varrays and nodes list appropriatelly */
-    flayer = atoi(fieldf_opt->answer);
-    tlayer = atoi(fieldt_opt->answer);
-    NetA_initialise_varray(&In, flayer, GV_POINT, wheref_opt->answer,
+    afield = Vect_get_field_number(&In, afield_opt->answer);
+    nfield = Vect_get_field_number(&In, nfield_opt->answer);
+
+    NetA_initialise_varray(&In, nfield, GV_POINT, wheref_opt->answer,
 			   catf_opt->answer, &varrayf);
-    NetA_initialise_varray(&In, tlayer, mask_type, wheret_opt->answer,
+    NetA_initialise_varray(&In, nfield, mask_type, wheret_opt->answer,
 			   catt_opt->answer, &varrayt);
 
     nodest = Vect_new_list();
     NetA_varray_to_nodes(&In, varrayt, nodest, nodes_to_features);
 
     Vect_net_build_graph(&In, mask_type, 1, 0, afcol->answer, abcol->answer,
-			 NULL, geo, 0);
+			 ncol->answer, geo, 0);
     graph = &(In.graph);
     NetA_distance_from_points(graph, nodest, dst, prev);
 
@@ -223,7 +238,6 @@
     Vect_hist_copy(&In, &Out);
     Vect_hist_command(&Out);
 
-
     for (i = 1; i <= nlines; i++)
 	if (varrayf->c[i]) {
 	    int type = Vect_read_line(&In, Points, Cats, i);
@@ -231,7 +245,7 @@
 	    double cost;
 	    dglInt32_t *vertex, vertex_id;
 
-	    if (!Vect_cat_get(Cats, flayer, &cat))
+	    if (!Vect_cat_get(Cats, nfield, &cat))
 		continue;
 		
 	    if (type & GV_POINTS) {
@@ -254,7 +268,7 @@
 		vertex_id = dglNodeGet_Id(graph, vertex);
 	    }
 	    Vect_read_line(&In, NULL, Cats, nodes_to_features[vertex_id]);
-	    if (!Vect_cat_get(Cats, tlayer, &tcat))
+	    if (!Vect_cat_get(Cats, nfield, &tcat))
 		continue;
 	    sprintf(buf, "insert into %s values (%d, %d, %f)", Fi->table, cat,
 		    tcat, cost);

Modified: grass/trunk/vector/v.net.flow/main.c
===================================================================
--- grass/trunk/vector/v.net.flow/main.c	2011-09-02 09:11:23 UTC (rev 48059)
+++ grass/trunk/vector/v.net.flow/main.c	2011-09-02 10:46:41 UTC (rev 48060)
@@ -32,11 +32,11 @@
     struct line_cats *Cats;
     struct GModule *module;	/* GRASS module for parsing arguments */
     struct Option *map_in, *map_out, *cut_out;
-    struct Option *field_opt, *abcol, *afcol;
-    struct Option *catsource_opt, *fieldsource_opt, *wheresource_opt;
-    struct Option *catsink_opt, *fieldsink_opt, *wheresink_opt;
+    struct Option *afield_opt, *nfield_opt, *abcol, *afcol, *ncol;
+    struct Option *catsource_opt, *wheresource_opt;
+    struct Option *catsink_opt, *wheresink_opt;
     int with_z;
-    int layer, mask_type;
+    int afield, nfield, mask_type;
     struct varray *varray_source, *varray_sink;
     dglGraph_s *graph;
     int i, nlines, *flow, total_flow;
@@ -63,8 +63,19 @@
 
     /* Define the different options as defined in gis.h */
     map_in = G_define_standard_option(G_OPT_V_INPUT);
-    field_opt = G_define_standard_option(G_OPT_V_FIELD);
 
+    afield_opt = G_define_standard_option(G_OPT_V_FIELD);
+    afield_opt->key = "alayer";
+    afield_opt->answer = "1";
+    afield_opt->description = _("Arc layer");
+    afield_opt->guisection = _("Cost");
+
+    nfield_opt = G_define_standard_option(G_OPT_V_FIELD);
+    nfield_opt->key = "nlayer";
+    nfield_opt->answer = "2";
+    nfield_opt->description = _("Node layer");
+    nfield_opt->guisection = _("Cost");
+
     map_out = G_define_standard_option(G_OPT_V_OUTPUT);
 
     cut_out = G_define_standard_option(G_OPT_V_OUTPUT);
@@ -76,17 +87,20 @@
     afcol->key = "afcolumn";
     afcol->required = NO;
     afcol->description =
-	_("Name of arc forward/both direction(s) capacity column");
+	_("Arc forward/both direction(s) cost column (number)");
+    afcol->guisection = _("Cost");
 
     abcol = G_define_standard_option(G_OPT_DB_COLUMN);
     abcol->key = "abcolumn";
     abcol->required = NO;
-    abcol->description = _("Name of arc backward direction capacity column");
+    abcol->description = _("Arc backward direction cost column (number)");
+    abcol->guisection = _("Cost");
 
-    fieldsource_opt = G_define_standard_option(G_OPT_V_FIELD);
-    fieldsource_opt->key = "source_layer";
-    fieldsource_opt->label = _("Source layer number or name");
-    fieldsource_opt->guisection = _("Source");
+    ncol = G_define_standard_option(G_OPT_DB_COLUMN);
+    ncol->key = "ncolumn";
+    ncol->required = NO;
+    ncol->description = _("Node cost column (number)");
+    ncol->guisection = _("Cost");
 
     catsource_opt = G_define_standard_option(G_OPT_V_CATS);
     catsource_opt->key = "source_cats";
@@ -99,11 +113,6 @@
 	_("Source WHERE conditions of SQL statement without 'where' keyword");
     wheresource_opt->guisection = _("Source");
 
-    fieldsink_opt = G_define_standard_option(G_OPT_V_FIELD);
-    fieldsink_opt->key = "sink_layer";
-    fieldsink_opt->label = _("Sink layer number or name");
-    fieldsink_opt->guisection = _("Sink");
-
     catsink_opt = G_define_standard_option(G_OPT_V_CATS);
     catsink_opt->key = "sink_cats";
     catsink_opt->label = _("Sink category values");
@@ -147,7 +156,8 @@
     }
 
     /* parse filter option and select appropriate lines */
-    layer = atoi(field_opt->answer);
+    afield = Vect_get_field_number(&In, afield_opt->answer);
+    nfield = Vect_get_field_number(&In, nfield_opt->answer);
 
     /* Create table */
     Fi = Vect_default_field_info(&Out, 1, NULL, GV_1TABLE);
@@ -183,12 +193,12 @@
     sink_list = Vect_new_list();
 
     if (NetA_initialise_varray
-	(&In, atoi(fieldsource_opt->answer), GV_POINT,
+	(&In, nfield, GV_POINT,
 	 wheresource_opt->answer, catsource_opt->answer, &varray_source) == 2)
 	G_fatal_error(_("Neither %s nor %s was given"), catsource_opt->key,
 		      wheresource_opt->key);
     if (NetA_initialise_varray
-	(&In, atoi(fieldsink_opt->answer), GV_POINT, wheresink_opt->answer,
+	(&In, nfield, GV_POINT, wheresink_opt->answer,
 	 catsink_opt->answer, &varray_sink) == 2)
 	G_fatal_error(_("Neither %s nor %s was given"), catsink_opt->key,
 		      wheresink_opt->key);
@@ -207,8 +217,9 @@
     Vect_hist_copy(&In, &Out);
     Vect_hist_command(&Out);
 
-    Vect_net_build_graph(&In, mask_type, atoi(field_opt->answer), 0,
-			 afcol->answer, abcol->answer, NULL, 0, 0);
+    Vect_net_build_graph(&In, mask_type, afield, nfield, afcol->answer, abcol->answer,
+			 ncol->answer, 0, 0);
+
     graph = &(In.graph);
     nlines = Vect_get_num_lines(&In);
     flow = (int *)G_calloc(nlines + 1, sizeof(int));
@@ -233,7 +244,7 @@
 	if (type == GV_LINE) {
 	    int cat;
 
-	    Vect_cat_get(Cats, layer, &cat);
+	    Vect_cat_get(Cats, afield, &cat);
 	    if (cat == -1)
 		continue;	/*TODO: warning? */
 	    sprintf(buf, "insert into %s values (%d, %f)", Fi->table, cat,

Modified: grass/trunk/vector/v.net.iso/main.c
===================================================================
--- grass/trunk/vector/v.net.iso/main.c	2011-09-02 09:11:23 UTC (rev 48059)
+++ grass/trunk/vector/v.net.iso/main.c	2011-09-02 10:46:41 UTC (rev 48060)
@@ -43,7 +43,7 @@
 
 int main(int argc, char **argv)
 {
-    int i, j, ret, centre, line, centre1, centre2;
+    int i, ret, centre, line, centre1, centre2;
     int nlines, nnodes, type, ltype, afield, nfield, geo, cat;
     int node, node1, node2;
     double cost, e1cost, e2cost, n1cost, n2cost, s1cost, s2cost, l, l1;
@@ -221,39 +221,6 @@
 	}
     }
 
-#if 0
-    for (node = 1; node <= nnodes; node++) {
-	nlines = Vect_get_node_n_lines(&Map, node);
-	for (j = 0; j < nlines; j++) {
-	    line = abs(Vect_get_node_line(&Map, node, j));
-	    ltype = Vect_read_line(&Map, NULL, Cats, line);
-	    if (!(ltype & GV_POINT))
-		continue;
-	    if (!(Vect_cat_get(Cats, nfield, &cat)))
-		continue;
-	    if (Vect_cat_in_cat_list(cat, catlist)) {
-		Vect_net_get_node_cost(&Map, node, &n1cost);
-		if (n1cost == -1) {	/* closed */
-		    G_warning(_("Centre at closed node (costs = -1) ignored"));
-		}
-		else {
-		    if (acentres == ncentres) {
-			acentres += 1;
-			Centers =
-			    (CENTER *) G_realloc(Centers,
-						 acentres * sizeof(CENTER));
-		    }
-		    Centers[ncentres].cat = cat;
-		    Centers[ncentres].node = node;
-		    G_debug(2, "centre = %d node = %d cat = %d", ncentres,
-			    node, cat);
-		    ncentres++;
-		}
-	    }
-	}
-    }
-#endif
-
     G_message(_("Number of centres: %d (nlayer %d)"), ncentres, nfield);
 
     if (ncentres == 0)

Modified: grass/trunk/vector/v.net.path/path.c
===================================================================
--- grass/trunk/vector/v.net.path/path.c	2011-09-02 09:11:23 UTC (rev 48059)
+++ grass/trunk/vector/v.net.path/path.c	2011-09-02 10:46:41 UTC (rev 48060)
@@ -26,7 +26,7 @@
 int path(struct Map_info *In, struct Map_info *Out, char *filename,
 	 int nfield, double maxdist, int segments)
 {
-    FILE *in_file;
+    FILE *in_file = NULL;
     int i, nlines, line, npoints, type, cat, id, fcat, tcat, fline, tline,
 	fnode, tnode, count;
     int ret, sp, input_mode, unreachable, nopoint, formaterr;
@@ -173,8 +173,8 @@
 	    }
 	    else {
 		fline = Citem->line;
-		type = Vect_read_line(&In, Points, NULL, fline);
-		fnode = Vect_find_node(&In, Points->x[0], Points->y[0], Points->z[0], 0, 0);
+		type = Vect_read_line(In, Points, NULL, fline);
+		fnode = Vect_find_node(In, Points->x[0], Points->y[0], Points->z[0], 0, 0);
 		/* Vect_get_line_nodes(In, fline, &fnode, NULL); */
 	    }
 	    G_debug(3, "from: cat = %5d point(line) = %5d node = %5d", fcat,
@@ -193,8 +193,8 @@
 	    }
 	    else {
 		tline = Citem->line;
-		type = Vect_read_line(&In, Points, NULL, tline);
-		tnode = Vect_find_node(&In, Points->x[0], Points->y[0], Points->z[0], 0, 0);
+		type = Vect_read_line(In, Points, NULL, tline);
+		tnode = Vect_find_node(In, Points->x[0], Points->y[0], Points->z[0], 0, 0);
 		/* Vect_get_line_nodes(In, tline, &tnode, NULL); */
 	    }
 	    G_debug(3, "to  : cat = %5d point(line) = %5d node = %5d", tcat,

Modified: grass/trunk/vector/v.net.salesman/main.c
===================================================================
--- grass/trunk/vector/v.net.salesman/main.c	2011-09-02 09:11:23 UTC (rev 48059)
+++ grass/trunk/vector/v.net.salesman/main.c	2011-09-02 10:46:41 UTC (rev 48060)
@@ -216,24 +216,6 @@
 	
     }
 
-
-#if 0
-    for (i = 1; i <= nnodes; i++) {
-	nlines = Vect_get_node_n_lines(&Map, i);
-	for (j = 0; j < nlines; j++) {
-	    line = abs(Vect_get_node_line(&Map, i, j));
-	    ltype = Vect_read_line(&Map, NULL, Cats, line);
-	    if (!(ltype & GV_POINT))
-		continue;
-	    if (!(Vect_cat_get(Cats, tfield, &cat)))
-		continue;
-	    if (Vect_cat_in_cat_list(cat, Clist)) {
-		Vect_list_append(TList, i);
-	    }
-	}
-    }
-#endif
-
     ncities = TList->n_values;
     G_message(_("Number of cities: [%d]"), ncities);
     if (ncities < 2)
@@ -343,6 +325,7 @@
      *  into cycle between 2 nearest nodes */
     /* for a large number of cities this will become very slow, can be fixed */
     for (i = 0; i < ncities - 2; i++) {
+	G_percent(i, ncities - 3, 1);
 	cost = -1;
 	G_debug(2, "---- city %d ----", i);
 	for (j = 0; j < ncities; j++) {

Modified: grass/trunk/vector/v.net.spanningtree/main.c
===================================================================
--- grass/trunk/vector/v.net.spanningtree/main.c	2011-09-02 09:11:23 UTC (rev 48059)
+++ grass/trunk/vector/v.net.spanningtree/main.c	2011-09-02 10:46:41 UTC (rev 48060)
@@ -30,10 +30,10 @@
     struct line_cats *Cats;
     struct GModule *module;	/* GRASS module for parsing arguments */
     struct Option *map_in, *map_out;
-    struct Option *field_opt, *accol;
+    struct Option *afield_opt, *nfield_opt, *afcol, *ncol;
     struct Flag *geo_f;
     int with_z;
-    int layer, mask_type;
+    int afield, nfield, mask_type;
     dglGraph_s *graph;
     int i, edges, geo;
     struct ilist *tree_list;
@@ -53,13 +53,31 @@
     map_in = G_define_standard_option(G_OPT_V_INPUT);
     map_out = G_define_standard_option(G_OPT_V_OUTPUT);
 
-    field_opt = G_define_standard_option(G_OPT_V_FIELD);
+    afield_opt = G_define_standard_option(G_OPT_V_FIELD);
+    afield_opt->key = "alayer";
+    afield_opt->answer = "1";
+    afield_opt->description = _("Arc layer");
+    afield_opt->guisection = _("Cost");
 
-    accol = G_define_standard_option(G_OPT_DB_COLUMN);
-    accol->key = "accol";
-    accol->required = NO;
-    accol->description = _("Name of Arc cost column");
+    nfield_opt = G_define_standard_option(G_OPT_V_FIELD);
+    nfield_opt->key = "nlayer";
+    nfield_opt->answer = "2";
+    nfield_opt->description = _("Node layer");
+    nfield_opt->guisection = _("Cost");
 
+    afcol = G_define_standard_option(G_OPT_DB_COLUMN);
+    afcol->key = "afcolumn";
+    afcol->required = NO;
+    afcol->description =
+	_("Arc forward/both direction(s) cost column (number)");
+    afcol->guisection = _("Cost");
+
+    ncol = G_define_standard_option(G_OPT_DB_COLUMN);
+    ncol->key = "ncolumn";
+    ncol->required = NO;
+    ncol->description = _("Node cost column (number)");
+    ncol->guisection = _("Cost");
+
     geo_f = G_define_flag();
     geo_f->key = 'g';
     geo_f->description =
@@ -98,10 +116,12 @@
 	geo = 0;
 
     /* parse filter option and select appropriate lines */
-    layer = atoi(field_opt->answer);
+    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, layer, 0,
-			 accol->answer, NULL, NULL, geo, 0);
+    Vect_net_build_graph(&In, mask_type, afield, nfield, afcol->answer, NULL,
+			 ncol->answer, geo, 0);
+
     graph = &(In.graph);
 
     Vect_copy_head_data(&In, &Out);

Modified: grass/trunk/vector/v.net.steiner/main.c
===================================================================
--- grass/trunk/vector/v.net.steiner/main.c	2011-09-02 09:11:23 UTC (rev 48059)
+++ grass/trunk/vector/v.net.steiner/main.c	2011-09-02 10:46:41 UTC (rev 48060)
@@ -441,29 +441,13 @@
 	    G_warning(_("Point is not connected to the network"));
 	    continue;
 	}
-	    if (!(Vect_cat_get(Cats, tfield, &cat)))
-		continue;
-	    if (Vect_cat_in_cat_list(cat, Clist)) {
-		Vect_list_append(TList, i);
-	    }
-    }
-
-#if 0
-    for (i = 1; i <= nnodes; i++) {
-	nlines = Vect_get_node_n_lines(&Map, i);
-	for (j = 0; j < nlines; j++) {
-	    line = abs(Vect_get_node_line(&Map, i, j));
-	    ltype = Vect_read_line(&Map, NULL, Cats, line);
-	    if (!(ltype & GV_POINT))
-		continue;
-	    if (!(Vect_cat_get(Cats, tfield, &cat)))
-		continue;
-	    if (Vect_cat_in_cat_list(cat, Clist)) {
-		Vect_list_append(TList, i);
-	    }
+	if (!(Vect_cat_get(Cats, tfield, &cat)))
+	    continue;
+	if (Vect_cat_in_cat_list(cat, Clist)) {
+	    Vect_list_append(TList, i);
 	}
     }
-#endif
+
     nterms = TList->n_values;
     fprintf(stdout, "Number of terminals: %d\n", nterms);
 

Modified: grass/trunk/vector/v.net.timetable/main.c
===================================================================
--- grass/trunk/vector/v.net.timetable/main.c	2011-09-02 09:11:23 UTC (rev 48059)
+++ grass/trunk/vector/v.net.timetable/main.c	2011-09-02 10:46:41 UTC (rev 48060)
@@ -162,7 +162,7 @@
 int get_nearest_stop(double x, double y, double z, int with_z)
 {
     int i, mini = -1;
-    double mind, d;
+    double mind = -1., d;
 
     for (i = 0; i < timetable.stops; i++) {
 	if (!found[i])
@@ -231,10 +231,16 @@
     struct line_cats *Counter_Cats, *Cats;
     struct GModule *module;	/* GRASS module for parsing arguments */
     struct Option *map_in, *map_out;
-    struct Option *field_opt, *walk_layer_opt, *path_layer_opt, *route_id_opt,
-	*stop_time_opt, *to_stop_opt, *walk_length_opt;
+    struct Option *tfield_opt,		  /* Input map: layer with existing timetable */
+                  *walk_layer_opt;	  /* Input map: layer with existing walking routes between stops */
+
+    struct Option *afield_opt,		  /* Input map: layer with arc costs */
+                  *nfield_opt,		  /* Input map: layer with node costs */
+		  *afcol, *abcol, *ncol;  /* Input map: cost columns */
+	          	
+    struct Option *route_id_opt, *stop_time_opt, *to_stop_opt, *walk_length_opt;
     int with_z;
-    int layer, mask_type, path_layer;
+    int tfield, mask_type, afield, nfield;
     int from_stop, to_stop, start_time, min_change, max_changes,
 	walking_change, ret;
     int *stop_pnt, i, nlines, point_counter, *route_pnt;
@@ -258,45 +264,74 @@
 
     /* Define the different options as defined in gis.h */
     map_in = G_define_standard_option(G_OPT_V_INPUT);
-    field_opt = G_define_standard_option(G_OPT_V_FIELD);
+    tfield_opt = G_define_standard_option(G_OPT_V_FIELD);
 
     map_out = G_define_standard_option(G_OPT_V_OUTPUT);
 
+    afield_opt = G_define_standard_option(G_OPT_V_FIELD);
+    afield_opt->key = "alayer";
+    afield_opt->answer = "1";
+    afield_opt->description = _("Arc layer");
+    afield_opt->guisection = _("Cost");
+
+    nfield_opt = G_define_standard_option(G_OPT_V_FIELD);
+    nfield_opt->key = "nlayer";
+    nfield_opt->answer = "2";
+    nfield_opt->description = _("Node layer");
+    nfield_opt->guisection = _("Cost");
+
+    afcol = G_define_option();
+    afcol->key = "afcolumn";
+    afcol->type = TYPE_STRING;
+    afcol->required = NO;
+    afcol->description =
+	_("Arc forward/both direction(s) cost column (number)");
+    afcol->guisection = _("Cost");
+
+    abcol = G_define_option();
+    abcol->key = "abcolumn";
+    abcol->type = TYPE_STRING;
+    abcol->required = NO;
+    abcol->description = _("Arc backward direction cost column (number)");
+    abcol->guisection = _("Cost");
+
+    ncol = G_define_option();
+    ncol->key = "ncolumn";
+    ncol->type = TYPE_STRING;
+    ncol->required = NO;
+    ncol->description = _("Node cost column (number)");
+    ncol->guisection = _("Cost");
+
     walk_layer_opt = G_define_standard_option(G_OPT_V_FIELD_ALL);
     walk_layer_opt->key = "walk_layer";
     walk_layer_opt->answer = "-1";
     walk_layer_opt->label =
 	_("Layer number or name with walking connections or -1");
 
-    path_layer_opt = G_define_standard_option(G_OPT_V_FIELD_ALL);
-    path_layer_opt->key = "path_layer";
-    path_layer_opt->answer = "-1";
-    path_layer_opt->label = _("Layer number or name with route paths or -1");
-
     route_id_opt = G_define_standard_option(G_OPT_DB_COLUMN);
     route_id_opt->key = "route_id";
     route_id_opt->required = YES;
     route_id_opt->answer = "route_id";
-    route_id_opt->description = _("Name of column name with route ids");
+    route_id_opt->description = _("Name of column with route ids");
 
     stop_time_opt = G_define_standard_option(G_OPT_DB_COLUMN);
     stop_time_opt->key = "stop_time";
     stop_time_opt->required = YES;
     stop_time_opt->answer = "stop_time";
     stop_time_opt->description =
-	_("Name of column name with stop timestamps");
+	_("Name of column with stop timestamps");
 
     to_stop_opt = G_define_standard_option(G_OPT_DB_COLUMN);
     to_stop_opt->key = "to_stop";
     to_stop_opt->required = YES;
     to_stop_opt->answer = "to_stop";
-    to_stop_opt->description = _("Name of column name with stop ids");
+    to_stop_opt->description = _("Name of column with stop ids");
 
     walk_length_opt = G_define_standard_option(G_OPT_DB_COLUMN);
     walk_length_opt->key = "walk_length";
     walk_length_opt->required = YES;
     walk_length_opt->answer = "length";
-    walk_length_opt->description = _("Name of column name with walk lengths");
+    walk_length_opt->description = _("Name of column with walk lengths");
 
     /* options and flags parser */
     if (G_parser(argc, argv))
@@ -327,10 +362,10 @@
 
 
     /* parse filter option and select appropriate lines */
-    layer = atoi(field_opt->answer);
-    path_layer = atoi(path_layer_opt->answer);
+    tfield = atoi(tfield_opt->answer);
+    afield = atoi(afield_opt->answer);
+    nfield = atoi(nfield_opt->answer);
 
-
     init_database(&Out, &point_driver, &point_Fi, 1,
 		  "cat integer, path_id integer, stop_id integer, index integer, arr_time integer, dep_time integer");
     init_database(&Out, &line_driver, &line_Fi, 2,
@@ -341,7 +376,7 @@
     Vect_hist_command(&Out);
 
     if (NetA_init_timetable_from_db
-	(&In, layer, atoi(walk_layer_opt->answer), route_id_opt->answer,
+	(&In, tfield, atoi(walk_layer_opt->answer), route_id_opt->answer,
 	 stop_time_opt->answer, to_stop_opt->answer, walk_length_opt->answer,
 	 &timetable, &route_ids, &stop_ids) != 0)
 	G_fatal_error(_("Could not initialize the timetables"));
@@ -354,7 +389,7 @@
     if (!stop_x || !stop_y || !stop_z || !found)
 	G_fatal_error(_("Out of memory"));
 
-    if (path_layer > 0) {
+    if (afield > 0) {
 	nnodes = Vect_get_num_nodes(&In);
 	stop_node = (int *)G_calloc(timetable.stops, sizeof(int));
 	lines =
@@ -366,8 +401,8 @@
 	for (i = 0; i < timetable.routes; i++)
 	    lines[i] = Vect_new_list();
 
-	Vect_net_build_graph(&In, mask_type, path_layer, 0, NULL, NULL, NULL,
-			     0, 0);
+	Vect_net_build_graph(&In, mask_type, afield, nfield, afcol->answer,
+			     abcol->answer, ncol->answer, 0, 0);
 	graph = &(In.graph);
     }
 
@@ -380,7 +415,7 @@
 	    int cat, stop, node;
 
 	    for (j = 0; j < Cats->n_cats; j++) {
-		if (Cats->field[j] != layer)
+		if (Cats->field[j] != tfield)
 		    continue;
 		cat = Cats->cat[j];
 		stop_pnt =
@@ -393,19 +428,19 @@
 		stop_x[stop] = Points->x[0];
 		stop_y[stop] = Points->y[0];
 		stop_z[stop] = Points->z[0];
-		if (path_layer > 0) {
-		    Vect_get_line_nodes(&In, i, &node, NULL);
-		    if (!stop_node[stop])
+		if (afield > 0) {
+		    node = Vect_find_node(&In, Points->x[0], Points->y[0], Points->z[0], 0, 0);
+		    if (!stop_node[stop] && node > 0)
 			stop_node[stop] = node;
 		}
 		found[stop] = 1;
 	    }
 	}
-	else if (type == GV_LINE && path_layer > 0) {
+	else if (type == GV_LINE && afield > 0) {
 	    int cat;
 
 	    for (j = 0; j < Cats->n_cats; j++) {
-		if (Cats->field[j] != path_layer)
+		if (Cats->field[j] != afield)
 		    continue;
 		cat = Cats->cat[j];
 		route_pnt =
@@ -533,7 +568,7 @@
 	    Vect_append_points(Points, Cur, GV_FORWARD);
 	    Vect_reset_cats(Cats);
 	    Vect_cat_set(Cats, 2, line_counter);
-	    if (path_layer <= 0)
+	    if (afield <= 0)
 		Vect_write_line(&Out, GV_LINE, Points, Cats);
 	    else
 		write_subroute(cur, Points, line_counter);



More information about the grass-commit mailing list