[GRASS-CVS] markus: grass6/vector/v.label description.html, 1.12, 1.12.2.1 main.c, 1.30, 1.30.2.1

grass at intevation.de grass at intevation.de
Thu Nov 29 08:27:07 EST 2007


Author: markus

Update of /grassrepository/grass6/vector/v.label
In directory doto:/tmp/cvs-serv18756

Modified Files:
      Tag: releasebranch_6_3
	description.html main.c 
Log Message:
backported fixes from HEAD

Index: description.html
===================================================================
RCS file: /grassrepository/grass6/vector/v.label/description.html,v
retrieving revision 1.12
retrieving revision 1.12.2.1
diff -u -d -r1.12 -r1.12.2.1
--- description.html	26 Sep 2007 07:19:10 -0000	1.12
+++ description.html	29 Nov 2007 13:27:05 -0000	1.12.2.1
@@ -207,6 +207,17 @@
 d.labels lroads
 </pre></div>
 
+Since the label files are simple text files, you can merge them together
+if you like. For example if you set the label colors based on database
+attributes using multiple runs with the <b>where</b> option.
+This example uses the standard UNIX <tt>cat</tt> program.
+
+<div class="code"><pre>
+cd $MAPSET/paint/labels/
+cat file1 file2 file3 file4 > file_all
+</pre></div>
+
+
 
 <H2>SEE ALSO</H2>
 <EM>

Index: main.c
===================================================================
RCS file: /grassrepository/grass6/vector/v.label/main.c,v
retrieving revision 1.30
retrieving revision 1.30.2.1
diff -u -d -r1.30 -r1.30.2.1
--- main.c	19 Oct 2007 15:41:26 -0000	1.30
+++ main.c	29 Nov 2007 13:27:05 -0000	1.30.2.1
@@ -46,7 +46,7 @@
     
     struct Map_info Map;
     struct GModule *module;
-    struct Option *Vectfile, *Typopt, *Fieldopt, *Colopt;
+    struct Option *Vectfile, *Typopt, *Fieldopt, *Colopt, *whereopt;
     struct Option *Labelfile, *Space, *FontSize, *Rotation;
     struct Flag   *Along_flag, *Curl_flag;
 
@@ -82,7 +82,8 @@
     Typopt->options = "point,line,boundary,centroid";
     Typopt->answer  = "point,line,boundary,centroid";
     
-    Fieldopt = G_define_standard_option(G_OPT_V_FIELD) ; 
+    Fieldopt = G_define_standard_option(G_OPT_V_FIELD);
+    whereopt = G_define_standard_option(G_OPT_WHERE);
 
     Along_flag = G_define_flag();
     Along_flag->key            = 'a';
@@ -268,7 +269,9 @@
     /* open database */	
     field = atoi ( Fieldopt->answer );
     fi = Vect_get_field(&Map, field);
-    if ( fi == NULL ) G_fatal_error (_("Unable to get layer info for vector map"));
+    if ( fi == NULL )
+	G_fatal_error (_("Unable to get layer info for vector map"));
+
     driver = db_start_driver_open_database ( fi->driver, fi->database );
     if ( driver == NULL ) 
 	G_fatal_error(_("Unable to open database <%s> by driver <%s>"), 
@@ -294,17 +297,27 @@
 	
 	/* Read label from database */
 
-	sprintf(buf, "select %s from %s where %s = %d", Colopt->answer, 
-	    fi->table, fi->key, cat);
+	if(whereopt->answer) {
+	    sprintf(buf, "select %s from %s where %s = %d and %s",
+		Colopt->answer, fi->table, fi->key, cat, whereopt->answer);
+	}
+	else {
+	    sprintf(buf, "select %s from %s where %s = %d",
+		Colopt->answer, fi->table, fi->key, cat);
+	}
 	G_debug (3, "SQL: %s", buf);
 	db_set_string ( &stmt, buf);
-	
+
         if (db_open_select_cursor(driver, &stmt, &cursor, DB_SEQUENTIAL) != DB_OK)
             G_fatal_error (_("Unable to select attributes"));
 
 	nrows = db_get_num_rows ( &cursor );
 	if ( nrows < 1 ) {
-	    G_warning (_("No record for category %d in table <%s>"), cat, fi->table);
+	    /* not optimal, but the warning isn't /that/ critical. */
+	    if(!whereopt->answer) {
+		G_warning (_("No record for category %d in table <%s>"),
+			cat, fi->table);
+	    }
 	    continue;
 	}
 




More information about the grass-commit mailing list