Browse Source

v.info: -r/-m/-t -> shell param (basic,region,topo) + manual updated
pythonlib updated
gislib: cosmetics in standard options


git-svn-id: https://svn.osgeo.org/grass/grass/trunk@45050 15284696-431f-4ddb-bdfa-cd5b030d7da7

Martin Landa 14 years ago
parent
commit
47027ae778

+ 9 - 9
lib/gis/parser_standard_options.c

@@ -289,7 +289,7 @@ struct Option *G_define_standard_option(int opt)
 	Opt->key_desc = "name";
 	Opt->key_desc = "name";
 	Opt->required = YES;
 	Opt->required = YES;
 	Opt->gisprompt = "old,grid3,3d-raster";
 	Opt->gisprompt = "old,grid3,3d-raster";
-	Opt->description = _("Name of input 3D raster map");
+	Opt->description = _("Name of 3D raster map");
 	break;
 	break;
     case G_OPT_R3_MAPS:
     case G_OPT_R3_MAPS:
 	Opt->key = "map";
 	Opt->key = "map";
@@ -298,7 +298,7 @@ struct Option *G_define_standard_option(int opt)
 	Opt->required = YES;
 	Opt->required = YES;
 	Opt->multiple = YES;
 	Opt->multiple = YES;
 	Opt->gisprompt = "old,grid3,3d-raster";
 	Opt->gisprompt = "old,grid3,3d-raster";
-	Opt->description = _("Name of input 3D raster map(s)");
+	Opt->description = _("Name of 3D raster map(s)");
 	break;
 	break;
 
 
 	/*vector maps */
 	/*vector maps */
@@ -309,7 +309,7 @@ struct Option *G_define_standard_option(int opt)
 	Opt->required = YES;
 	Opt->required = YES;
 	Opt->gisprompt = "old,vector,vector";
 	Opt->gisprompt = "old,vector,vector";
 	Opt->label = _("Name of input vector map");
 	Opt->label = _("Name of input vector map");
-	Opt->description = _("Data source for OGR access");
+	Opt->description = _("Data source for direct OGR access");
 	break;
 	break;
     case G_OPT_V_INPUTS:
     case G_OPT_V_INPUTS:
 	Opt->key = "input";
 	Opt->key = "input";
@@ -319,7 +319,7 @@ struct Option *G_define_standard_option(int opt)
 	Opt->multiple = YES;
 	Opt->multiple = YES;
 	Opt->gisprompt = "old,vector,vector";
 	Opt->gisprompt = "old,vector,vector";
 	Opt->label = _("Name of input vector map(s)");
 	Opt->label = _("Name of input vector map(s)");
-	Opt->description = _("Data source(s) for OGR access");
+	Opt->description = _("Data source(s) for direct OGR access");
 	break;
 	break;
     case G_OPT_V_OUTPUT:
     case G_OPT_V_OUTPUT:
 	Opt->key = "output";
 	Opt->key = "output";
@@ -335,8 +335,8 @@ struct Option *G_define_standard_option(int opt)
 	Opt->key_desc = "name";
 	Opt->key_desc = "name";
 	Opt->required = YES;
 	Opt->required = YES;
 	Opt->gisprompt = "old,vector,vector";
 	Opt->gisprompt = "old,vector,vector";
-	Opt->label = _("Name of input vector map");
-	Opt->description = _("Data source for OGR access");
+	Opt->label = _("Name of vector map");
+	Opt->description = _("Data source for direct OGR access");
 	break;
 	break;
     case G_OPT_V_MAPS:
     case G_OPT_V_MAPS:
 	Opt->key = "map";
 	Opt->key = "map";
@@ -345,7 +345,7 @@ struct Option *G_define_standard_option(int opt)
 	Opt->required = YES;
 	Opt->required = YES;
 	Opt->multiple = YES;
 	Opt->multiple = YES;
 	Opt->gisprompt = "old,vector,vector";
 	Opt->gisprompt = "old,vector,vector";
-	Opt->description = _("Name of input vector map(s)");
+	Opt->description = _("Name of vector map(s)");
 	break;
 	break;
     case G_OPT_V_TYPE:
     case G_OPT_V_TYPE:
 	Opt->key = "type";
 	Opt->key = "type";
@@ -374,7 +374,7 @@ struct Option *G_define_standard_option(int opt)
 	Opt->description =
 	Opt->description =
 	    _("A single vector map can be connected to multiple database "
 	    _("A single vector map can be connected to multiple database "
 	      "tables. This number determines which table to use. "
 	      "tables. This number determines which table to use. "
-	      "Layer name for OGR access.");
+	      "Layer name for direct OGR access.");
 	Opt->gisprompt = "old,layer,layer";
 	Opt->gisprompt = "old,layer,layer";
 	break;
 	break;
     case G_OPT_V_FIELD_ALL:
     case G_OPT_V_FIELD_ALL:
@@ -386,7 +386,7 @@ struct Option *G_define_standard_option(int opt)
 	Opt->description =
 	Opt->description =
 	    _("A single vector map can be connected to multiple database "
 	    _("A single vector map can be connected to multiple database "
 	      "tables. This number determines which table to use. "
 	      "tables. This number determines which table to use. "
-	      "Layer name for OGR access.");
+	      "Layer name for direct OGR access.");
 	Opt->gisprompt = "old,layer,layer_all";
 	Opt->gisprompt = "old,layer,layer_all";
 	break;
 	break;
     case G_OPT_V_CAT:
     case G_OPT_V_CAT:

+ 54 - 60
lib/python/pythonlib.dox

@@ -15,6 +15,7 @@ See code in:
 - db.py
 - db.py
 - raster.py
 - raster.py
 - vector.py
 - vector.py
+- setup.py
 
 
 <b>Table of content</b>
 <b>Table of content</b>
 
 
@@ -24,6 +25,7 @@ See code in:
  - \subpage pythonDb
  - \subpage pythonDb
  - \subpage pythonRaster
  - \subpage pythonRaster
  - \subpage pythonVector
  - \subpage pythonVector
+ - \subpage pythonSetup
 
 
 \section pythonScripting GRASS scripting tasks for Python provided by "grass.script"
 \section pythonScripting GRASS scripting tasks for Python provided by "grass.script"
 
 
@@ -82,42 +84,42 @@ if __name__ == "__main__":
 
 
 <b>GRASS-oriented interface to subprocess module</b>
 <b>GRASS-oriented interface to subprocess module</b>
 
 
- - exec_command()
+ - python::core::exec_command()
 
 
- - feed_command()
+ - python::core::feed_command()
 
 
- - make_command()
+ - python::core::make_command()
 
 
- - parse_command()
+ - python::core::parse_command()
 
 
- - pipe_command()
+ - python::core::pipe_command()
 
 
- - read_command()
+ - python::core::read_command()
 
 
- - run_command()
+ - python::core::run_command()
 
 
- - start_command()
+ - python::core::start_command()
 
 
- - write_command()
+ - python::core::write_command()
 
 
 <b>Interface to g.message</b>
 <b>Interface to g.message</b>
 
 
 These all run g.message, differing only in which flag (if any) is
 These all run g.message, differing only in which flag (if any) is
 used. fatal() is error(), but also calls sys.exit(1).
 used. fatal() is error(), but also calls sys.exit(1).
 
 
- - debug()
+ - python::core::debug()
 
 
- - error()
+ - python::core::error()
 
 
- - fatal()
+ - python::core::fatal()
 
 
- - info()
+ - python::core::info()
 
 
- - message()
+ - python::core::message()
 
 
- - verbose()
+ - python::core::verbose()
 
 
- - warning()
+ - python::core::warning()
 
 
 <b>Interface to g.parser</b>
 <b>Interface to g.parser</b>
 
 
@@ -129,117 +131,109 @@ Interface to g.parser, intended to be run from the top-level, e.g.
 	    main()
 	    main()
 \endcode
 \endcode
 
 
- - parser()
+ - python::core::parser()
 
 
 <b>Interface to g.tempfile</b>
 <b>Interface to g.tempfile</b>
 
 
 Returns the name of a temporary file, created with g.tempfile.
 Returns the name of a temporary file, created with g.tempfile.
 
 
- - tempfile()
+ - python::core::tempfile()
 
 
 <b>Key-value parsers</b>
 <b>Key-value parsers</b>
 
 
- - parse_key_val()
+ - python::core::parse_key_val()
 
 
 <b>Interface to g.gisenv</b>
 <b>Interface to g.gisenv</b>
 
 
- - gisenv()
+ - python::core::gisenv()
 
 
 <b>Interface to g.region</b>
 <b>Interface to g.region</b>
 
 
- - del_temp_region()
+ - python::core::del_temp_region()
 
 
- - region()
+ - python::core::region()
 
 
- - use_temp_region()
+ - python::core::use_temp_region()
 
 
 <b>Interface to g.findfile</b>
 <b>Interface to g.findfile</b>
 
 
- - find_file()
+ - python::core::find_file()
 
 
 <b>Interface to g.list</b>
 <b>Interface to g.list</b>
 
 
- - list_grouped()
+ - python::core::list_grouped()
 
 
- - list_pairs()
+ - python::core::list_pairs()
 
 
- - list_strings()
+ - python::core::list_strings()
 
 
- - mlist_grouped()
+ - python::core::mlist_grouped()
 
 
 <b>Interface to g.mapsets</b>
 <b>Interface to g.mapsets</b>
 
 
- - mapsets()
+ - python::core::mapsets()
 
 
 <b>Color parsing</b>
 <b>Color parsing</b>
 
 
- - parse_color()
+ - python::core::parse_color()
 
 
 <b>Check GRASS environment variables</b>
 <b>Check GRASS environment variables</b>
 
 
- - overwrite()
+ - python::core::overwrite()
 
 
- - verbosity()
+ - python::core::verbosity()
 
 
 <b>Various utilities, not specific to GRASS</b>
 <b>Various utilities, not specific to GRASS</b>
  
  
- - basename()
+ - python::core::basename()
 
 
- - find_program()
+ - python::core::find_program()
 
 
- - try_remove()
+ - python::core::try_remove()
 
 
- - try_rmdir()
+ - python::core::try_rmdir()
 
 
- - float_or_dms()
+ - python::core::float_or_dms()
 
 
 \section pythonDb Database
 \section pythonDb Database
 
 
 Interface for <tt>db.*</tt> modules.
 Interface for <tt>db.*</tt> modules.
 
 
-\code
-from grass.script import db as grass
-\endcode
-
- - db_connection()
+ - python::db::db_connection()
 
 
- - db_describe()
+ - python::db::db_describe()
 
 
- - db_select()
+ - python::db::db_select()
 
 
 \section pythonRaster Raster
 \section pythonRaster Raster
 
 
 Interface for <tt>r.*</tt> modules.
 Interface for <tt>r.*</tt> modules.
 
 
-\code
-from grass.script import raster as grass
-\endcode
+ - python::raster::raster_history()
 
 
- - raster_history()
+ - python::raster::raster_info()
 
 
- - raster_info()
-
- - mapcalc()
+ - python::raster::mapcalc()
 
 
 \section pythonVector Vector
 \section pythonVector Vector
 
 
 Interface for <tt>v.*</tt> modules.
 Interface for <tt>v.*</tt> modules.
 
 
-\code
-from grass.script import vector as grass
-\endcode
+ - python::vector::vector_columns()
+
+ - python::vector::vector_db()
 
 
- - vector_columns()
+ - python::vector::vector_db_select()
 
 
- - vector_db()
+ - python::vector::vector_history()
 
 
- - vector_db_select()
+ - python::vector::vector_info_topo()
 
 
- - vector_history()
+ - python::vector::vector_layer_db()
 
 
- - vector_info_topo()
+\section pythonSetup Setup
 
 
- - vector_layer_db()
+ - python::setup::init()
 
 
 \section pythonAuthors Authors
 \section pythonAuthors Authors
 
 

+ 8 - 4
lib/python/vector.py

@@ -143,7 +143,7 @@ def vector_history(map):
     """
     """
     run_command('v.support', map = map, cmdhist = os.environ['CMDLINE'])
     run_command('v.support', map = map, cmdhist = os.environ['CMDLINE'])
 
 
-# run "v.info -t" and parse output
+# run "v.info shell=topo" and parse output
 
 
 def vector_info_topo(map):
 def vector_info_topo(map):
     """!Return information about a vector map (interface to `v.info
     """!Return information about a vector map (interface to `v.info
@@ -153,15 +153,19 @@ def vector_info_topo(map):
     >>> grass.vector_info_topo('lakes')
     >>> grass.vector_info_topo('lakes')
     {'kernels': 0, 'lines': 0, 'centroids': 15279,
     {'kernels': 0, 'lines': 0, 'centroids': 15279,
     'boundaries': 27764, 'points': 0, 'faces': 0,
     'boundaries': 27764, 'points': 0, 'faces': 0,
-    'primitives': 43043, 'islands': 7470, 'nodes': 35234, 'map3d': 0, 'areas': 15279}
+    'primitives': 43043, 'islands': 7470, 'nodes': 35234, 'map3d': False, 'areas': 15279}
     \endcode
     \endcode
     
     
     @param map map name
     @param map map name
 
 
     @return parsed output
     @return parsed output
     """
     """
-    s = read_command('v.info', flags = 't', map = map)
-    return parse_key_val(s, val_type = int)
+    s = read_command('v.info', map = map, shell = 'topo')
+    ret = parse_key_val(s, val_type = int)
+    if ret.has_key('map3d'):
+        ret['map3d'] = bool(ret['map3d'])
+    
+    return ret
 
 
 # interface for v.db.select
 # interface for v.db.select
 
 

+ 7 - 1
vector/v.info/local_proto.h

@@ -1,12 +1,17 @@
 #include <grass/vector.h>
 #include <grass/vector.h>
 
 
+#define NO_INFO     0x00
+#define BASIC_INFO  0x02
+#define REGION_INFO 0x04
+#define TOPO_INFO   0x08
+
 /* level1.c */
 /* level1.c */
 int level_one_info(struct Map_info *);
 int level_one_info(struct Map_info *);
 
 
 /* parse.c */
 /* parse.c */
 void parse_args(int, char**,
 void parse_args(int, char**,
 		char **, char**,
 		char **, char**,
-		int *, int *, int *, int *, int *);
+		int *, int *, int *);
 
 
 /* print.c */
 /* print.c */
 void format_double(double, char *);
 void format_double(double, char *);
@@ -14,3 +19,4 @@ void print_region(const struct Map_info *);
 void print_topo(const struct Map_info *);
 void print_topo(const struct Map_info *);
 void print_columns(const struct Map_info *, const char *, const char *);
 void print_columns(const struct Map_info *, const char *, const char *);
 void print_info(const struct Map_info *);
 void print_info(const struct Map_info *);
+void print_shell(const struct Map_info *);

+ 31 - 27
vector/v.info/main.c

@@ -8,7 +8,7 @@
  *               
  *               
  * PURPOSE:      Print vector map info
  * PURPOSE:      Print vector map info
  *               
  *               
- * COPYRIGHT:    (C) 2002-2009 by the GRASS Development Team
+ * COPYRIGHT:    (C) 2002-2009, 2011 by the GRASS Development Team
  *
  *
  *               This program is free software under the GNU General
  *               This program is free software under the GNU General
  *               Public License (>=v2).  Read the file COPYING that
  *               Public License (>=v2).  Read the file COPYING that
@@ -28,7 +28,7 @@ int main(int argc, char *argv[])
     struct GModule *module;
     struct GModule *module;
 
 
     char *input_opt, *field_opt;
     char *input_opt, *field_opt;
-    int hist_flag, col_flag, reg_flag, topo_flag, title_flag;
+    int hist_flag, col_flag, shell_flag;
     
     
     struct Map_info Map;
     struct Map_info Map;
     
     
@@ -38,14 +38,16 @@ int main(int argc, char *argv[])
     G_add_keyword(_("vector"));
     G_add_keyword(_("vector"));
     G_add_keyword(_("metadata"));
     G_add_keyword(_("metadata"));
     G_add_keyword(_("history"));
     G_add_keyword(_("history"));
+    G_add_keyword(_("attribute columns"));
+    
     module->description =
     module->description =
 	_("Outputs basic information about a vector map.");
 	_("Outputs basic information about a vector map.");
 
 
-    G_debug(1,"LFS is %s", sizeof(off_t) == 8 ? "available" : "not available");
+    G_debug(1, "LFS is %s", sizeof(off_t) == 8 ? "available" : "not available");
     
     
     parse_args(argc, argv,
     parse_args(argc, argv,
 	       &input_opt, &field_opt,
 	       &input_opt, &field_opt,
-	       &hist_flag, &col_flag, &reg_flag, &topo_flag, &title_flag);
+	       &hist_flag, &col_flag, &shell_flag);
 
 
      /* try to open head-only on level 2 */
      /* try to open head-only on level 2 */
     if (Vect_open_old_head2(&Map, input_opt, "", field_opt) < 2) {
     if (Vect_open_old_head2(&Map, input_opt, "", field_opt) < 2) {
@@ -57,36 +59,38 @@ int main(int argc, char *argv[])
 	    G_fatal_error(_("Unable to open vector map <%s>"), Vect_get_full_name(&Map));
 	    G_fatal_error(_("Unable to open vector map <%s>"), Vect_get_full_name(&Map));
 
 
 	/* level one info not needed for history, title, columns */
 	/* level one info not needed for history, title, columns */
-	if (!hist_flag && !title_flag && !col_flag)
+	if (!hist_flag && !col_flag)
 	    level_one_info(&Map);
 	    level_one_info(&Map);
     }
     }
 
 
-    if (hist_flag) {
-	char buf[1001];
-	
-	Vect_hist_rewind(&Map);
-	while (Vect_hist_read(buf, 1000, &Map) != NULL) {
-	    fprintf(stdout, "%s\n", buf);
+    if (hist_flag || col_flag) {
+	if (hist_flag) {
+	    char buf[1001];
+	    
+	    Vect_hist_rewind(&Map);
+	    while (Vect_hist_read(buf, 1000, &Map) != NULL) {
+		fprintf(stdout, "%s\n", buf);
+	    }
+	}
+	else if (col_flag) {
+	    print_columns(&Map, input_opt, field_opt);
 	}
 	}
+	Vect_close(&Map);
+	
+	return (EXIT_SUCCESS);
     }
     }
-    else if (title_flag) {
-	fprintf(stdout, "%s\n", Vect_get_map_name(&Map));
+    
+    if (shell_flag & BASIC_INFO) {
+	print_shell(&Map);
     }
     }
-    else if (reg_flag || topo_flag) {
-	if (reg_flag) {
-	    print_region(&Map);
-	}
-	if (topo_flag) {
-	    print_topo(&Map);
-	}
+    if (shell_flag & REGION_INFO) {
+	print_region(&Map);
     }
     }
-    else {
-	if (col_flag) {
-	    print_columns(&Map, input_opt, field_opt);
-	}
-	else {
-	    print_info(&Map);
-	}
+    if (shell_flag & TOPO_INFO) {
+	print_topo(&Map);
+    }
+    if (shell_flag == 0) {
+	print_info(&Map);
     }
     }
 
 
     Vect_close(&Map);
     Vect_close(&Map);

+ 35 - 27
vector/v.info/parse.c

@@ -5,50 +5,58 @@
 
 
 void parse_args(int argc, char** argv,
 void parse_args(int argc, char** argv,
 		char** input, char** field,
 		char** input, char** field,
-		int* history, int* columns, int* region, int* topo, int* title)
+		int* history, int* columns, int *shell)
 {
 {
-    struct Option *input_opt, *field_opt;
-    struct Flag *hist_flag, *col_flag, *region_flag, *topo_flag, *title_flag;
-
+    int i;
+    const char *answer;
+    
+    struct Option *input_opt, *field_opt, *print_opt;
+    struct Flag *hist_flag, *col_flag;
+    
     input_opt = G_define_standard_option(G_OPT_V_MAP);
     input_opt = G_define_standard_option(G_OPT_V_MAP);
 
 
     field_opt = G_define_standard_option(G_OPT_V_FIELD);
     field_opt = G_define_standard_option(G_OPT_V_FIELD);
 
 
+    print_opt = G_define_option();
+    print_opt->key = "shell";
+    print_opt->multiple = YES;
+    print_opt->options = "basic,region,topo";
+    print_opt->label = _("Print info in shell script style");
+    print_opt->description = _("Ignored if -h or -c flags are given");
+    print_opt->descriptions = _("basic;basic info only;"
+				"region;map region;"
+				"topo;topology information");
+    print_opt->guisection = _("Print");
+    
     hist_flag = G_define_flag();
     hist_flag = G_define_flag();
     hist_flag->key = 'h';
     hist_flag->key = 'h';
-    hist_flag->description = _("Print vector history instead of info");
+    hist_flag->description = _("Print history instead of info and exit");
     hist_flag->guisection = _("Print");
     hist_flag->guisection = _("Print");
 
 
     col_flag = G_define_flag();
     col_flag = G_define_flag();
     col_flag->key = 'c';
     col_flag->key = 'c';
     col_flag->description =
     col_flag->description =
-	_("Print types/names of table columns for specified layer instead of info");
+	_("Print types/names of table columns for specified layer instead of info and exit");
     col_flag->guisection = _("Print");
     col_flag->guisection = _("Print");
 
 
-    region_flag = G_define_flag();
-    region_flag->key = 'g';
-    region_flag->description = _("Print map region only");
-    region_flag->guisection = _("Print");
-
-    title_flag = G_define_flag();
-    title_flag->key = 'm';
-    title_flag->description = _("Print map title only");
-    title_flag->guisection = _("Print");
-
-    topo_flag = G_define_flag();
-    topo_flag->key = 't';
-    topo_flag->description = _("Print topology information only");
-    topo_flag->guisection = _("Print");
-
     if (G_parser(argc, argv))
     if (G_parser(argc, argv))
 	exit(EXIT_FAILURE);
 	exit(EXIT_FAILURE);
 
 
     *input = G_store(input_opt->answer);
     *input = G_store(input_opt->answer);
     *field = G_store(field_opt->answer);
     *field = G_store(field_opt->answer);
-
-    *history = hist_flag-> answer ? 1 : 0;
-    *columns = col_flag-> answer ? 1 : 0;
-    *region  = region_flag-> answer ? 1 : 0;
-    *title   = title_flag-> answer ? 1 : 0;
-    *topo    = topo_flag-> answer ? 1 : 0;
+    *history = hist_flag->answer ? TRUE : FALSE;
+    *columns = col_flag->answer  ? TRUE : FALSE;
+    i = 0;
+    *shell = NO_INFO;
+    if (print_opt->answer) {
+	while(print_opt->answers[i]) {
+	    answer = print_opt->answers[i++];
+	    if (strcmp(answer, "basic") == 0)
+		*shell |= BASIC_INFO;
+	    else if (strcmp(answer, "region") == 0)
+		*shell |= REGION_INFO;
+	    else if (strcmp(answer, "topo") == 0)
+		*shell |= TOPO_INFO;
+	}
+    }
 }
 }

+ 69 - 5
vector/v.info/print.c

@@ -107,8 +107,9 @@ void print_topo(const struct Map_info *Map)
 
 
     fprintf(stdout, "primitives=%ld\n", nprimitives);
     fprintf(stdout, "primitives=%ld\n", nprimitives);
     fflush(stdout);
     fflush(stdout);
-    
-    fprintf(stdout, "map3d=%d\n", Vect_is_3d(Map));
+
+    fprintf(stdout, "map3d=%d\n",
+	    Vect_is_3d(Map) ? 1 : 0);
     fflush(stdout);
     fflush(stdout);
 }
 }
 
 
@@ -163,6 +164,65 @@ void print_columns(const struct Map_info *Map, const char *input_opt, const char
     db_shutdown_driver(driver);
     db_shutdown_driver(driver);
 }
 }
 
 
+void print_shell(const struct Map_info *Map)
+{
+    if (Vect_maptype(Map) & (GV_FORMAT_OGR | GV_FORMAT_OGR_DIRECT)) {
+	fprintf(stdout, "ogr_layer=%s\n",
+		Vect_get_ogr_layer_name(Map));
+	fprintf(stdout, "ogr_dsn=%s\n",
+		Vect_get_ogr_dsn_name(Map));
+    }
+    else {
+	fprintf(stdout, "name=%s\n",
+		Vect_get_name(Map));
+	fprintf(stdout, "mapset=%s\n",
+		Vect_get_mapset(Map));
+    }
+    
+    fprintf(stdout, "location=%s\n",
+	    G_location());
+    fprintf(stdout, "database=%s\n",
+	    G_gisdbase());
+    fprintf(stdout, "title=%s\n",
+	    Vect_get_map_name(Map));
+    fprintf(stdout, "scale=1:%d\n",
+	    Vect_get_scale(Map));
+    
+    if (Vect_maptype(Map) & (GV_FORMAT_OGR | GV_FORMAT_OGR_DIRECT)) {	
+	fprintf(stdout, "format=%s,%s\n",
+		Vect_maptype_info(Map), Vect_get_ogr_format_info(Map));
+    }
+    else {
+	fprintf(stdout, "format=%s\n",
+		Vect_maptype_info(Map));
+    }
+
+    fprintf(stdout, "creator=%s\n",
+	    Vect_get_person(Map));
+    fprintf(stdout, "organization=%s\n",
+	    Vect_get_organization(Map));
+    fprintf(stdout, "source_date=%s\n",
+	    Vect_get_map_date(Map));
+    fprintf(stdout, "level=%d\n", 
+	    Vect_level(Map));
+    
+    if (Vect_level(Map) > 0) {
+	fprintf(stdout, "num_dblinks=%d\n",
+		Vect_get_num_dblinks(Map));
+    }
+
+    fprintf(stdout, "projection=%s\n",
+	    Vect_get_proj_name(Map));
+    if (G_projection() == PROJECTION_UTM) {
+	fprintf(stdout, "zone=%d\n",
+		Vect_get_zone(Map));
+    }
+    fprintf(stdout, "digitization_threshold=%f\n",
+	    Vect_get_thresh(Map));
+    fprintf(stdout, "comment=%s\n",
+	    Vect_get_comment(Map));
+}
+
 void print_info(const struct Map_info *Map)
 void print_info(const struct Map_info *Map)
 {
 {
     int i;
     int i;
@@ -189,6 +249,7 @@ void print_info(const struct Map_info *Map)
 		Vect_get_mapset(Map));
 		Vect_get_mapset(Map));
 	printline(line);
 	printline(line);
     }
     }
+
     sprintf(line, "%-17s%s", _("Location:"),
     sprintf(line, "%-17s%s", _("Location:"),
 	    G_location());
 	    G_location());
     printline(line);
     printline(line);
@@ -201,6 +262,7 @@ void print_info(const struct Map_info *Map)
     sprintf(line, "%-17s1:%d", _("Map scale:"),
     sprintf(line, "%-17s1:%d", _("Map scale:"),
 	    Vect_get_scale(Map));
 	    Vect_get_scale(Map));
     printline(line);
     printline(line);
+    
     if (Vect_maptype(Map) & (GV_FORMAT_OGR | GV_FORMAT_OGR_DIRECT)) {
     if (Vect_maptype(Map) & (GV_FORMAT_OGR | GV_FORMAT_OGR_DIRECT)) {
 	sprintf(line, "%-17s%s (%s)", _("Map format:"),
 	sprintf(line, "%-17s%s (%s)", _("Map format:"),
 		Vect_maptype_info(Map), Vect_get_ogr_format_info(Map));
 		Vect_maptype_info(Map), Vect_get_ogr_format_info(Map));
@@ -209,6 +271,7 @@ void print_info(const struct Map_info *Map)
 	sprintf(line, "%-17s%s", _("Map format:"),
 	sprintf(line, "%-17s%s", _("Map format:"),
 		Vect_maptype_info(Map));
 		Vect_maptype_info(Map));
     }
     }
+    
     printline(line);
     printline(line);
     sprintf(line, "%-17s%s", _("Name of creator:"),
     sprintf(line, "%-17s%s", _("Name of creator:"),
 	    Vect_get_person(Map));
 	    Vect_get_person(Map));
@@ -267,6 +330,7 @@ void print_info(const struct Map_info *Map)
 	    printline(line);
 	    printline(line);
 	}
 	}
 	printline("");
 	printline("");
+	
 	sprintf(line, "  %-24s%s",
 	sprintf(line, "  %-24s%s",
 		_("Map is 3D:"),
 		_("Map is 3D:"),
 		Vect_is_3d(Map) ? _("Yes") : _("No"));
 		Vect_is_3d(Map) ? _("Yes") : _("No"));
@@ -289,10 +353,10 @@ void print_info(const struct Map_info *Map)
 	sprintf(line, "  %s: %s",
 	sprintf(line, "  %s: %s",
 		_("Projection"),
 		_("Projection"),
 		Vect_get_proj_name(Map));
 		Vect_get_proj_name(Map));
-
+    
     printline(line);
     printline(line);
     printline("");
     printline("");
-
+    
     Vect_get_map_box(Map, &box);
     Vect_get_map_box(Map, &box);
     
     
     G_format_northing(box.N, tmp1, G_projection());
     G_format_northing(box.N, tmp1, G_projection());
@@ -315,7 +379,7 @@ void print_info(const struct Map_info *Map)
 	printline(line);
 	printline(line);
     }
     }
     printline("");
     printline("");
-    
+
     format_double(Vect_get_thresh(Map), tmp1);
     format_double(Vect_get_thresh(Map), tmp1);
     sprintf(line, "  %s: %s", _("Digitization threshold"), tmp1);
     sprintf(line, "  %s: %s", _("Digitization threshold"), tmp1);
     printline(line);
     printline(line);

+ 104 - 4
vector/v.info/v.info.html

@@ -4,13 +4,14 @@
 user-specified vector map and its topology status.
 user-specified vector map and its topology status.
 
 
 <p>
 <p>
-Vector map is opened without topology (i.e., on level 1) when
-the <b>-l</b> flag is used. With the <b>-l</b> flag set, vector map
-extends and number of features need to be counted on the fly which may
-take some time.
+If topology info is not available (i.e., vector map cannot be open on
+level 2), vector map extends and number of features need to be counted
+on the fly which may take some time.
 
 
 <h2>EXAMPLE</h2>
 <h2>EXAMPLE</h2>
 
 
+<h3>Basic info</h3>
+
 <div class="code"><pre>
 <div class="code"><pre>
 v.info map=geology
 v.info map=geology
 
 
@@ -46,6 +47,105 @@ v.info map=geology
  +----------------------------------------------------------------------------+
  +----------------------------------------------------------------------------+
 </pre></div>
 </pre></div>
 
 
+<h3>History</h3>
+
+<div class="code"><pre>
+v.info -h map=geology
+
+COMMAND: v.in.ogr dsn="geol.shp" output="geology" min_area=0.0001 snap=-1
+GISDBASE: /bigdata/grassdata05
+LOCATION: ncfromfile MAPSET: PERMANENT USER: helena DATE: Mon Nov  6 15:48:53 2006
+---------------------------------------------------------------------------------
+1832 input polygons
+total area: 1.276093e+11 (1832 areas)
+overlapping area: 0.000000e+00 (0 areas)
+area without category: 0.000000e+00 (0 areas)
+---------------------------------------------------------------------------------
+</pre></div>
+
+<h3>Attribute columns for given layer</h3>
+
+<div class="code"><pre>
+v.info -c map=geology
+
+Displaying column types/names for database connection of layer <1>:
+INTEGER|cat
+DOUBLE PRECISION|onemap_pro
+DOUBLE PRECISION|PERIMETER
+INTEGER|GEOL250_
+INTEGER|GEOL250_ID
+CHARACTER|GEO_NAME
+DOUBLE PRECISION|SHAPE_area
+DOUBLE PRECISION|SHAPE_len
+</pre></div>
+
+<h3>Basic info in shell script style</h3>
+
+<div class="code"><pre>
+v.info map=geology shell=basic,region,topo
+
+name=geology
+mapset=PERMANENT
+location=nc_spm_08
+database=/home/martin/grassdata
+title=North Carolina geology map (polygon map)
+scale=1:1
+format=native
+creator=helena
+organization=NC OneMap
+source_date=Mon Nov  6 15:48:53 2006
+level=2
+map3d=0
+num_dblinks=1
+projection=Lambert Conformal Conic
+digitization_threshold=0.000000
+comment=
+north=318117.43741634
+south=10875.82723209
+east=930172.31282271
+west=123971.19498978
+top=0.000000
+bottom=0.000000
+nodes=4556
+points=0
+lines=0
+boundaries=3649
+centroids=1832
+areas=1832
+islands=907
+primitives=5481
+</pre></div>
+
+<div class="code"><pre>
+v.info map=geology shell=region
+
+north=318117.43741634
+south=10875.82723209
+east=930172.31282271
+west=123971.19498978
+top=0.000000
+bottom=0.000000
+</pre></div>
+
+<h2>PYTHON</h2>
+
+See <em><a href="http://grass.osgeo.org/programming7/pythonlib.html">Python
+Script Library</a></em> for more info.
+
+<div class="code"><pre>
+import grass.script as grass
+    
+grass.vector_columns('geology')   # for `v.info -c`
+grass.vector_info_topo('geology') # for `v.info shell=topo`
+</pre></div>
+
+<h2>SEE ALSO</h2>
+
+<em>
+  <a href="r.info.html">r.info</a>,
+  <a href="r3.info.html">r3.info</a>
+</em>
+
 <h2>AUTHOR</h2>
 <h2>AUTHOR</h2>
 
 
 Original author CERL<br>
 Original author CERL<br>