소스 검색

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

git-svn-id: https://svn.osgeo.org/grass/grass/trunk@42296 15284696-431f-4ddb-bdfa-cd5b030d7da7
Markus Metz 15 년 전
부모
커밋
a4f4f701c7
2개의 변경된 파일13개의 추가작업 그리고 14개의 파일을 삭제
  1. 7 2
      vector/v.info/level1.c
  2. 6 12
      vector/v.info/main.c

+ 7 - 2
vector/v.info/level1.c

@@ -12,13 +12,15 @@ int level_one_info(struct Map_info *Map)
     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 @@ int level_one_info(struct Map_info *Map)
 	    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 @@ int level_one_info(struct Map_info *Map)
     plus->n_blines = n_boundaries;
     plus->n_clines = n_centroids;
     plus->n_klines = n_kernels;
+    plus->n_flines = n_faces;
 
     return 1;
 }

+ 6 - 12
vector/v.info/main.c

@@ -44,27 +44,21 @@ int main(int argc, char *argv[])
 	       &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);