浏览代码

d.vect: fix show z-coordinates (display=zcoor) also for vectors open on level 1 (no topology)

git-svn-id: https://svn.osgeo.org/grass/grass/trunk@70308 15284696-431f-4ddb-bdfa-cd5b030d7da7
Martin Landa 8 年之前
父节点
当前提交
0226caf5e1
共有 1 个文件被更改,包括 20 次插入15 次删除
  1. 20 15
      display/d.vect/zcoor.c

+ 20 - 15
display/d.vect/zcoor.c

@@ -31,20 +31,27 @@ int display_zcoor(struct Map_info *Map, int type, LATTR *lattr)
 	D_encoding(lattr->enc);
 
     Vect_rewind(Map);
-
-    num = Vect_get_num_lines(Map);
-    G_debug(1, "n_lines = %d", num);
     /* Points - no nodes registered */
-    for (el = 1; el <= num; el++) {
-	if (!Vect_line_alive(Map, el))
-	    continue;
-	ltype = Vect_read_line(Map, Points, NULL, el);
-	if ((ltype != GV_POINT) && (ltype & type))
-	    continue;
-	G_debug(3, "point = %d", el);
-	
-	sprintf(text, "%.2f", Points->z[0]);
-	show_label(&Points->x[0], &Points->y[0], lattr, text);
+    while (TRUE) {
+        ltype = Vect_read_next_line(Map, Points, NULL);
+        if (ltype == -1) {
+            G_warning(_("Unable to read vector map"));
+            return 1;
+        }
+        else if (ltype == -2) {
+            break;
+        }
+        if ((ltype != GV_POINT) && (ltype & type))
+            continue;
+        
+        sprintf(text, "%.2f", Points->z[0]);
+        show_label(&Points->x[0], &Points->y[0], lattr, text);
+    }
+    Vect_destroy_line_struct(Points);
+    
+    if (Vect_level(Map) < 2) {
+        /* no topology */
+        return 0;
     }
     
     num = Vect_get_num_nodes(Map);
@@ -61,7 +68,5 @@ int display_zcoor(struct Map_info *Map, int type, LATTR *lattr)
 	show_label(&xl, &yl, lattr, text);
     }
 
-    Vect_destroy_line_struct(Points);
-    
     return 0;
 }