[GRASS-SVN] r52169 - in grass/branches/develbranch_6/vector: v.net.allpairs v.net.centrality v.net.connectivity v.net.distance v.net.flow

svn_grass at osgeo.org svn_grass at osgeo.org
Wed Jun 20 09:34:48 PDT 2012


Author: mmetz
Date: 2012-06-20 09:34:48 -0700 (Wed, 20 Jun 2012)
New Revision: 52169

Modified:
   grass/branches/develbranch_6/vector/v.net.allpairs/main.c
   grass/branches/develbranch_6/vector/v.net.centrality/main.c
   grass/branches/develbranch_6/vector/v.net.connectivity/main.c
   grass/branches/develbranch_6/vector/v.net.distance/main.c
   grass/branches/develbranch_6/vector/v.net.flow/main.c
Log:
v.net modules: partial backport from trunk

Modified: grass/branches/develbranch_6/vector/v.net.allpairs/main.c
===================================================================
--- grass/branches/develbranch_6/vector/v.net.allpairs/main.c	2012-06-20 14:47:15 UTC (rev 52168)
+++ grass/branches/develbranch_6/vector/v.net.allpairs/main.c	2012-06-20 16:34:48 UTC (rev 52169)
@@ -126,11 +126,16 @@
 
     /* parse filter option and select appropriate lines */
     layer = atoi(field_opt->answer);
-    chcat =
-	(NetA_initialise_varray
-	 (&In, layer, GV_POINT, where_opt->answer, cat_opt->answer,
-	  &varray) == 1);
 
+    if (where_opt->answer || cat_opt->answer) {
+	chcat = (NetA_initialise_varray(&In, layer, GV_POINT,
+	                                where_opt->answer,
+					cat_opt->answer, &varray) > 0);
+    }
+    else
+	chcat = 0;
+
+
     /* Create table */
     Fi = Vect_default_field_info(&Out, 1, NULL, GV_1TABLE);
     Vect_map_add_dblink(&Out, 1, NULL, Fi->table, "cat", Fi->database,

Modified: grass/branches/develbranch_6/vector/v.net.centrality/main.c
===================================================================
--- grass/branches/develbranch_6/vector/v.net.centrality/main.c	2012-06-20 14:47:15 UTC (rev 52168)
+++ grass/branches/develbranch_6/vector/v.net.centrality/main.c	2012-06-20 16:34:48 UTC (rev 52169)
@@ -205,10 +205,13 @@
 
     /* parse filter option and select appropriate lines */
     layer = atoi(field_opt->answer);
-    chcat =
-	(NetA_initialise_varray
-	 (&In, layer, mask_type, where_opt->answer, cat_opt->answer,
-	  &varray) == 1);
+    if (where_opt->answer || cat_opt->answer) {
+	chcat = (NetA_initialise_varray(&In, layer, GV_POINT,
+	                                where_opt->answer,
+					cat_opt->answer, &varray) > 0);
+    }
+    else
+	chcat = 0;
 
     /* Create table */
     Fi = Vect_default_field_info(&Out, 1, NULL, GV_1TABLE);

Modified: grass/branches/develbranch_6/vector/v.net.connectivity/main.c
===================================================================
--- grass/branches/develbranch_6/vector/v.net.connectivity/main.c	2012-06-20 14:47:15 UTC (rev 52168)
+++ grass/branches/develbranch_6/vector/v.net.connectivity/main.c	2012-06-20 16:34:48 UTC (rev 52169)
@@ -126,14 +126,18 @@
 
     if (NetA_initialise_varray
 	(&In, atoi(fieldset1_opt->answer), 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);
+	 catset1_opt->answer, &varray_set1) <= 0) {
+	G_fatal_error(_("No features for %s selected. "
+			"Please check options '%s', '%s'."),
+			"set1", catset1_opt->key, whereset1_opt->key);
+    }
     if (NetA_initialise_varray
 	(&In, atoi(fieldset2_opt->answer), 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);
+	 catset2_opt->answer, &varray_set2) <= 0) {
+	G_fatal_error(_("No features for %s selected. "
+			"Please check options '%s', '%s'."),
+			"set2", catset2_opt->key, whereset2_opt->key);
+    }
 
     set1_list = Vect_new_list();
     set2_list = Vect_new_list();

Modified: grass/branches/develbranch_6/vector/v.net.distance/main.c
===================================================================
--- grass/branches/develbranch_6/vector/v.net.distance/main.c	2012-06-20 14:47:15 UTC (rev 52168)
+++ grass/branches/develbranch_6/vector/v.net.distance/main.c	2012-06-20 16:34:48 UTC (rev 52169)
@@ -193,6 +193,9 @@
     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"));
+
     Vect_net_build_graph(&In, GV_LINES, 1, 0, afcol->answer, abcol->answer,
 			 NULL, geo, 0);
     graph = &(In.graph);

Modified: grass/branches/develbranch_6/vector/v.net.flow/main.c
===================================================================
--- grass/branches/develbranch_6/vector/v.net.flow/main.c	2012-06-20 14:47:15 UTC (rev 52168)
+++ grass/branches/develbranch_6/vector/v.net.flow/main.c	2012-06-20 16:34:48 UTC (rev 52169)
@@ -148,7 +148,7 @@
     layer = atoi(field_opt->answer);
 
     /* Create table */
-    Fi = Vect_default_field_info(&Out, 1, NULL, GV_1TABLE);
+    Fi = Vect_default_field_info(&Out, layer, NULL, GV_1TABLE);
     Vect_map_add_dblink(&Out, 1, NULL, Fi->table, "cat", Fi->database,
 			Fi->driver);
     db_init_string(&sql);
@@ -182,16 +182,19 @@
 
     if (NetA_initialise_varray
 	(&In, atoi(fieldsource_opt->answer), 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);
+	 wheresource_opt->answer, catsource_opt->answer, &varray_source) <= 0) {
+	G_fatal_error(_("No source features selected. "
+			"Please check options '%s', '%s'."),
+			catsource_opt->key, wheresource_opt->key);
+    }
     if (NetA_initialise_varray
 	(&In, atoi(fieldsink_opt->answer), 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);
+	 catsink_opt->answer, &varray_sink) <= 0) {
+	G_fatal_error(_("No sink features selected. "
+			"Please check options '%s', '%s'."),
+			catsink_opt->key, wheresink_opt->key);
+    }
 
-
     NetA_varray_to_nodes(&In, varray_source, source_list, NULL);
     NetA_varray_to_nodes(&In, varray_sink, sink_list, NULL);
 
@@ -228,7 +231,7 @@
 	int type = Vect_read_line(&In, Points, Cats, i);
 
 	Vect_write_line(&Out, type, Points, Cats);
-	if (type == GV_LINE) {
+	if (type & mask_type) {
 	    int cat;
 
 	    Vect_cat_get(Cats, layer, &cat);



More information about the grass-commit mailing list