[GRASS-SVN] r42296 - grass/trunk/vector/v.info

svn_grass at osgeo.org svn_grass at osgeo.org
Tue May 18 08:53:45 EDT 2010


Author: mmetz
Date: 2010-05-18 08:53:44 -0400 (Tue, 18 May 2010)
New Revision: 42296

Modified:
   grass/trunk/vector/v.info/level1.c
   grass/trunk/vector/v.info/main.c
Log:
clean up the mess: don't call Vect_get_num_primitives when map is not yet opened; don't override topo_flag for level 1 because there will be some info; don't open map twice; don't close map, then try to read map

Modified: grass/trunk/vector/v.info/level1.c
===================================================================
--- grass/trunk/vector/v.info/level1.c	2010-05-18 12:33:55 UTC (rev 42295)
+++ grass/trunk/vector/v.info/level1.c	2010-05-18 12:53:44 UTC (rev 42296)
@@ -12,13 +12,15 @@
     struct line_cats *Cats;
     struct bound_box box;
 
-    int n_primitives, n_points, n_lines, n_boundaries, n_centroids, n_kernels;
+    int n_primitives, n_points, n_lines, n_boundaries, n_centroids;
+    int n_faces, n_kernels;
 
     G_debug(1, "Count vector objects for level 1");
 
     plus = &(Map->plus);
 
-    n_primitives = n_points = n_lines = n_boundaries = n_centroids = n_kernels = 0;
+    n_primitives = n_points = n_lines = n_boundaries = n_centroids = 0;
+    n_faces = n_kernels = 0;
 
     Points = Vect_new_line_struct();
     Cats = Vect_new_cats_struct();
@@ -52,6 +54,8 @@
 	    n_centroids++;
 	else if (type & GV_KERNEL)
 	    n_kernels++;
+	else if (type & GV_FACE)
+	    n_faces++;
 
 	offset = Map->head.last_offset;
 
@@ -83,6 +87,7 @@
     plus->n_blines = n_boundaries;
     plus->n_clines = n_centroids;
     plus->n_klines = n_kernels;
+    plus->n_flines = n_faces;
 
     return 1;
 }

Modified: grass/trunk/vector/v.info/main.c
===================================================================
--- grass/trunk/vector/v.info/main.c	2010-05-18 12:33:55 UTC (rev 42295)
+++ grass/trunk/vector/v.info/main.c	2010-05-18 12:53:44 UTC (rev 42296)
@@ -44,27 +44,21 @@
 	       &input_opt, &field_opt,
 	       &hist_flag, &col_flag, &reg_flag, &topo_flag, &title_flag, &level1_flag);
 
+    /* force level 1
+     * NOTE: number of points, lines, boundaries, centroids, faces, kernels is still available */
     if (level1_flag) {
 	Vect_set_open_level(1); /* no topology */
-	if (topo_flag && Vect_get_num_primitives(&Map, GV_POINT) == 0){
-	    G_warning(_("Vector map requested on level 1 (flag -t ignored)")); 
-	    topo_flag = 0;
-        }
+	Vect_open_old2(&Map, input_opt, "", field_opt);
     }
     
     if (!level1_flag) {
-	 /* level 2 */
-	if (Vect_open_old_head2(&Map, input_opt, "", field_opt) < 2 &&
-	    Vect_open_old2(&Map, input_opt, "", field_opt) < 2) {
-	    G_warning(_("Unable to open vector map <%s> on level 2"),
+	 /* try to open on level 2 */
+	if (Vect_open_old2(&Map, input_opt, "", field_opt) == 1) {
+	    G_warning(_("Unable to open vector map <%s> on level 2, using level 1"),
 		      Vect_get_full_name(&Map));
-	    Vect_close(&Map);
 	    level1_flag = 1;
 	}
     }
-    else {
-	Vect_open_old2(&Map, input_opt, "", field_opt);
-    }
 
     if (level1_flag) {
 	level_one_info(&Map);



More information about the grass-commit mailing list