[GRASS-SVN] r39881 - grass/trunk/vector/v.out.ascii
svn_grass at osgeo.org
svn_grass at osgeo.org
Thu Dec 3 13:50:42 EST 2009
Author: martinl
Date: 2009-12-03 13:50:41 -0500 (Thu, 03 Dec 2009)
New Revision: 39881
Modified:
grass/trunk/vector/v.out.ascii/args.c
grass/trunk/vector/v.out.ascii/local_proto.h
grass/trunk/vector/v.out.ascii/main.c
Log:
v.out.ascii: OGR support (read access)
Modified: grass/trunk/vector/v.out.ascii/args.c
===================================================================
--- grass/trunk/vector/v.out.ascii/args.c 2009-12-03 17:37:46 UTC (rev 39880)
+++ grass/trunk/vector/v.out.ascii/args.c 2009-12-03 18:50:41 UTC (rev 39881)
@@ -9,7 +9,7 @@
void parse_args(int argc, char **argv,
char **input, char**output, int *format, int *dp, char **delim,
- int *field, char ***columns, char **where, int *region, int *old_format)
+ char **field, char ***columns, char **where, int *region, int *old_format)
{
struct Option *input_opt, *output_opt, *format_opt, *dp_opt, *delim_opt,
*field_opt, *column_opt, *where_opt;
@@ -17,12 +17,22 @@
input_opt = G_define_standard_option(G_OPT_V_INPUT);
+ field_opt = G_define_standard_option(G_OPT_V_FIELD);
+ field_opt->guisection = _("Selection");
+
output_opt = G_define_standard_option(G_OPT_F_OUTPUT);
output_opt->description =
_("Path to resulting ASCII file ('-' for standard output) "
"or ASCII vector name if '-o' is defined");
output_opt->answer = "-";
+
+ column_opt = G_define_standard_option(G_OPT_DB_COLUMNS);
+ column_opt->description = _("Name of attribute column(s) to be exported (point mode)");
+ column_opt->guisection = _("Points");
+ where_opt = G_define_standard_option(G_OPT_DB_WHERE);
+ where_opt->guisection = _("Selection");
+
format_opt = G_define_option();
format_opt->key = "format";
format_opt->type = TYPE_STRING;
@@ -46,16 +56,6 @@
_("Number of significant digits (floating point only)");
dp_opt->guisection = _("Points");
- field_opt = G_define_standard_option(G_OPT_V_FIELD);
- field_opt->guisection = _("Selection");
-
- column_opt = G_define_standard_option(G_OPT_DB_COLUMNS);
- column_opt->description = _("Name of attribute column(s) to be exported (point mode)");
- column_opt->guisection = _("Points");
-
- where_opt = G_define_standard_option(G_OPT_DB_WHERE);
- where_opt->guisection = _("Selection");
-
old_flag = G_define_flag();
old_flag->key = 'o';
old_flag->description = _("Create old (version 4) ASCII file");
@@ -91,7 +91,7 @@
else
*delim = G_store(delim_opt->answer);
- *field = atoi(field_opt->answer);
+ *field = G_store(field_opt->answer);
*columns = NULL;
if (column_opt->answer) {
int i, nopt;
Modified: grass/trunk/vector/v.out.ascii/local_proto.h
===================================================================
--- grass/trunk/vector/v.out.ascii/local_proto.h 2009-12-03 17:37:46 UTC (rev 39880)
+++ grass/trunk/vector/v.out.ascii/local_proto.h 2009-12-03 18:50:41 UTC (rev 39881)
@@ -1,4 +1,4 @@
/* args.c */
void parse_args(int, char **,
char **, char**, int *, int *, char **,
- int *, char ***, char **, int *, int *);
+ char **, char ***, char **, int *, int *);
Modified: grass/trunk/vector/v.out.ascii/main.c
===================================================================
--- grass/trunk/vector/v.out.ascii/main.c 2009-12-03 17:37:46 UTC (rev 39880)
+++ grass/trunk/vector/v.out.ascii/main.c 2009-12-03 18:50:41 UTC (rev 39881)
@@ -5,7 +5,7 @@
* AUTHOR(S): Michael Higgins, U.S. Army Construction Engineering Research Laboratory
* James Westervelt, U.S. Army Construction Engineering Research Laboratory
* Radim Blazek, ITC-Irst, Trento, Italy
- * Martin Landa, CTU in Prague, Czech Republic (v.out.ascii.db merged & update for GRASS7)
+ * Martin Landa, CTU in Prague, Czech Republic (v.out.ascii.db merged & update (OGR) for GRASS7)
*
* PURPOSE: Writes GRASS vector data as ASCII files
* COPYRIGHT: (C) 2000-2009 by the GRASS Development Team
@@ -33,7 +33,7 @@
struct Map_info Map;
FILE *ascii, *att;
- char *input, *output, *delim, **columns, *where;
+ char *input, *output, *delim, **columns, *where, *field_name;
int format, dp, field, ret, region, old_format;
int ver, pnt;
@@ -44,11 +44,11 @@
G_add_keyword(_("export"));
G_add_keyword(_("ascii"));
module->description =
- _("Converts a GRASS binary vector map to a GRASS ASCII vector map.");
+ _("Exports a vector map to a GRASS ASCII vector representation.");
parse_args(argc, argv, &input, &output, &format, &dp, &delim,
- &field, &columns, &where, ®ion, &old_format);
-
+ &field_name, &columns, &where, ®ion, &old_format);
+
if (format == GV_ASCII_FORMAT_STD && columns) {
G_warning(_("Parameter 'column' ignored in standard mode"));
}
@@ -68,17 +68,19 @@
if (format != GV_ASCII_FORMAT_WKT) {
Vect_set_open_level(1); /* topology not needed */
- if (Vect_open_old(&Map, input, "") < 0)
+ if (Vect_open_old2(&Map, input, "", field_name) < 0)
G_fatal_error(_("Unable to open vector map <%s>"),
input);
}
else {
- if (Vect_open_old(&Map, input, "") < 2) /* topology required for polygons */
+ if (Vect_open_old2(&Map, input, "", field_name) < 2) /* topology required for polygons */
G_warning(_("Unable to open vector map <%s> at topology level. "
"Only points, lines can be processed."),
input);
}
+ field = Vect_get_field_number(&Map, field_name);
+
if (strcmp(output, "-") != 0) {
if (ver == 4) {
ascii = G_fopen_new("dig_ascii", output);
More information about the grass-commit
mailing list