[GRASS-SVN] r58261 - grass/trunk/vector/v.what.rast

svn_grass at osgeo.org svn_grass at osgeo.org
Thu Nov 21 00:34:40 PST 2013


Author: hamish
Date: 2013-11-21 00:34:40 -0800 (Thu, 21 Nov 2013)
New Revision: 58261

Modified:
   grass/trunk/vector/v.what.rast/main.c
Log:
fixes for print flag: vect map doesn't need to be in current mapset, and doesn't need to have a DB

Modified: grass/trunk/vector/v.what.rast/main.c
===================================================================
--- grass/trunk/vector/v.what.rast/main.c	2013-11-20 20:22:14 UTC (rev 58260)
+++ grass/trunk/vector/v.what.rast/main.c	2013-11-21 08:34:40 UTC (rev 58261)
@@ -124,19 +124,18 @@
 
     field = Vect_get_field_number(&Map, opt.field->answer);
 
-    /* FIXME: if the print flag is used then a database doesn't
-	need to exist and the map doesn't need to be in the
-	current mapset. Topology should be optional too. */
     Fi = Vect_get_field(&Map, field);
-    if (Fi == NULL)
-	G_fatal_error(_("Database connection not defined for layer %d"),
-		      field);
+    if (!print_flag->answer) {
+	if (Fi == NULL)
+	    G_fatal_error(_("Database connection not defined for layer %d"),
+			  field);
 
-    /* Open driver */
-    driver = db_start_driver_open_database(Fi->driver, Fi->database);
-    if (driver == NULL) {
-	G_fatal_error(_("Unable to open database <%s> by driver <%s>"),
-		      Fi->database, Fi->driver);
+	/* Open driver */
+	driver = db_start_driver_open_database(Fi->driver, Fi->database);
+	if (driver == NULL) {
+	    G_fatal_error(_("Unable to open database <%s> by driver <%s>"),
+			  Fi->database, Fi->driver);
+	}
     }
 
     /* Open raster */
@@ -223,9 +222,11 @@
 	point_cnt++;
     }
 
-    Vect_set_db_updated(&Map);
-    Vect_hist_command(&Map);
-    Vect_set_db_updated(&Map);
+    if (!print_flag->answer) {
+	Vect_set_db_updated(&Map);
+	Vect_hist_command(&Map);
+	Vect_set_db_updated(&Map); /* again? */
+    }
     Vect_close(&Map);
 
     G_debug(1, "Read %d vector points", point_cnt);
@@ -516,7 +517,10 @@
     if (print_flag->answer) {
 	dupl_cnt = 0;
 
-	G_message("%s|value", Fi->key);
+	if(Fi)
+	    G_message("%s|value", Fi->key);
+	else
+	    G_message("cat|value");
 
 	for (point = 0; point < point_cnt; point++) {
 	    if (cache[point].count > 1) {



More information about the grass-commit mailing list