[GRASS-SVN] r48280 - grass/trunk/display/d.vect

svn_grass at osgeo.org svn_grass at osgeo.org
Tue Sep 13 17:07:59 EDT 2011


Author: martinl
Date: 2011-09-13 14:07:59 -0700 (Tue, 13 Sep 2011)
New Revision: 48280

Modified:
   grass/trunk/display/d.vect/lines.c
   grass/trunk/display/d.vect/main.c
Log:
d.vect: fix -i flag (requires random access)


Modified: grass/trunk/display/d.vect/lines.c
===================================================================
--- grass/trunk/display/d.vect/lines.c	2011-09-13 20:15:31 UTC (rev 48279)
+++ grass/trunk/display/d.vect/lines.c	2011-09-13 21:07:59 UTC (rev 48280)
@@ -62,7 +62,7 @@
 		  dbCatValArray *cvarr_rot, int nrec_rot)
 
 {
-    int ltype, line;
+    int ltype, line, nlines;
     struct line_pnts *Points;
     struct line_cats *Cats;
 
@@ -73,12 +73,6 @@
     
     Symb = NULL;
     
-    if (id_flag && Vect_level(Map) < 2) {
-	G_warning(_("Unable to display lines by id, topology not available. "
-		    "Please try to rebuild topology using "
-		    "v.build or v.build.all."));
-    }
-  
     line_color = G_malloc(sizeof(RGBA_Color));
     fill_color = G_malloc(sizeof(RGBA_Color));
     primary_color = G_malloc(sizeof(RGBA_Color));
@@ -121,6 +115,15 @@
     if (color && !cvarr_rgb && !cats_color_flag)
 	D_RGB_color(color->r, color->g, color->b);
     
+    nlines = -1;
+    if (id_flag) {
+	if (Vect_level(Map) < 2)
+	    G_fatal_error(_("Unable to display features by id, topology not available. "
+			    "Please try to rebuild topology using "
+			    "v.build or v.build.all."));
+	nlines = Vect_get_num_lines(Map);
+    }
+
     line = 0;
     n_points = n_lines = 0;
     n_centroids = n_boundaries = 0;
@@ -128,15 +131,22 @@
     while (TRUE) {
 	line++;
 	
-	ltype = Vect_read_next_line(Map, Points, Cats);
+	if (nlines > -1) {
+	    if (line > nlines)
+		break;
+	    ltype = Vect_read_line(Map, Points, Cats, line);
+	}
+	else {
+	    ltype = Vect_read_next_line(Map, Points, Cats);
 
-	if (ltype == -1) {
-	    G_fatal_error(_("Unable to read vector map"));
+	    if (ltype == -1) {
+		G_fatal_error(_("Unable to read vector map"));
+	    }
+	    else if (ltype == -2) { /* EOF */
+		break;
+	    }
 	}
-	else if (ltype == -2) { /* EOF */
-	    break;
-	}
-
+	
 	draw_line(type, ltype, line,
 		  Points, Cats,
 		  color, fcolor, chcat,

Modified: grass/trunk/display/d.vect/main.c
===================================================================
--- grass/trunk/display/d.vect/main.c	2011-09-13 20:15:31 UTC (rev 48279)
+++ grass/trunk/display/d.vect/main.c	2011-09-13 21:07:59 UTC (rev 48280)
@@ -424,12 +424,12 @@
     chcat = 0;
     if (where_opt->answer) {
 	if (Clist->field < 1)
-	    G_fatal_error(_("Option <%s> requires option <%s> > 0"), where_opt->key, field_opt->key);
+	    G_fatal_error(_("Option <%s> must be > 0"), field_opt->key);
 	chcat = 1;
 	option_to_where(&Map, Clist, where_opt->answer);
     }
     else if (cat_opt->answer) {
-	if (Clist->field < 1)
+	if (Clist->field < 1 && !id_flag->answer)
 	    G_fatal_error(_("Option <%s> must be > 0"), field_opt->key);
 	chcat = 1;
 	ret = Vect_str_to_cat_list(cat_opt->answer, Clist);



More information about the grass-commit mailing list