~ubuntu-branches/ubuntu/precise/grass/precise

« back to all changes in this revision

Viewing changes to vector/v.in.ascii/in.c

  • Committer: Bazaar Package Importer
  • Author(s): Francesco Paolo Lovergine
  • Date: 2011-04-13 17:08:41 UTC
  • mfrom: (8.1.7 sid)
  • Revision ID: james.westby@ubuntu.com-20110413170841-ss1t9bic0d0uq0gz
Tags: 6.4.1-1
* New upstream version.
* Now build-dep on libjpeg-dev and current libreadline6-dev.
* Removed patch swig: obsolete.
* Policy bumped to 3.9.2, without changes.

Show diffs side-by-side

added added

removed removed

Lines of Context:
8
8
 * PURPOSE:      Converts a vector map in ASCII format to a vector map
9
9
 *               in binary format
10
10
 *
11
 
 * COPYRIGHT:    (C) 2000-2007 by the GRASS Development Team
 
11
 * COPYRIGHT:    (C) 2000-2009 by the GRASS Development Team
12
12
 *
13
13
 *               This program is free software under the GNU General Public
14
14
 *               License (>=v2). Read the file COPYING that comes with GRASS
65
65
    format_opt->multiple = NO;
66
66
    format_opt->options = "point,standard";
67
67
    format_opt->descriptions = _("point;simple x,y[,z] list;"
68
 
                                 "standard;GRASS's vector ASCII format");
 
68
                                 "standard;GRASS vector ASCII format");
69
69
    format_opt->answer = "point";
70
70
    format_opt->description = _("Input file format");
 
71
    format_opt->guisection = _("Input format");
71
72
 
72
73
    delim_opt = G_define_standard_option(G_OPT_F_SEP);
73
 
 
 
74
    delim_opt->guisection = _("Input format");
 
75
    
74
76
    skip_opt = G_define_option();
75
77
    skip_opt->key = "skip";
76
78
    skip_opt->type = TYPE_INTEGER;
79
81
    skip_opt->answer = "0";
80
82
    skip_opt->description =
81
83
        _("Number of header lines to skip at top of input file (points mode)");
 
84
    skip_opt->guisection = _("Points");
82
85
 
83
86
    columns_opt = G_define_option();
84
87
    columns_opt->key = "columns";
85
88
    columns_opt->type = TYPE_STRING;
86
89
    columns_opt->required = NO;
87
90
    columns_opt->multiple = NO;
88
 
    columns_opt->guisection = _("Columns");
 
91
    columns_opt->guisection = _("Points");
89
92
    columns_opt->label = _("Column definition in SQL style (points mode)");
90
93
    columns_opt->description = _("For example: "
91
94
                                 "'x double precision, y double precision, cat int, "
92
95
                                 "name varchar(10)'");
93
 
 
 
96
    
94
97
    xcol_opt = G_define_option();
95
98
    xcol_opt->key = "x";
96
99
    xcol_opt->type = TYPE_INTEGER;
97
100
    xcol_opt->required = NO;
98
101
    xcol_opt->multiple = NO;
99
102
    xcol_opt->answer = "1";
100
 
    xcol_opt->guisection = _("Columns");
101
 
    xcol_opt->description =
102
 
        _("Number of column used as x coordinate (first column is 1) for points mode");
 
103
    xcol_opt->guisection = _("Points");
 
104
    xcol_opt->label = ("Number of column used as x coordinate (points mode)");
 
105
    xcol_opt->description = _("First column is 1");
103
106
 
104
107
    ycol_opt = G_define_option();
105
108
    ycol_opt->key = "y";
107
110
    ycol_opt->required = NO;
108
111
    ycol_opt->multiple = NO;
109
112
    ycol_opt->answer = "2";
110
 
    ycol_opt->guisection = _("Columns");
111
 
    ycol_opt->description =
112
 
        _("Number of column used as y coordinate (first column is 1) for points mode");
 
113
    ycol_opt->guisection = _("Points");
 
114
    ycol_opt->label = _("Number of column used as y coordinate (points mode)");
 
115
    ycol_opt->description = _("First column is 1");
113
116
 
114
117
    zcol_opt = G_define_option();
115
118
    zcol_opt->key = "z";
117
120
    zcol_opt->required = NO;
118
121
    zcol_opt->multiple = NO;
119
122
    zcol_opt->answer = "0";
120
 
    zcol_opt->guisection = _("Columns");
121
 
    zcol_opt->label =
122
 
        _("Number of column used as z coordinate (first column is 1) for "
123
 
          "points mode");
124
 
    zcol_opt->description = _("If 0, z coordinate is not used");
 
123
    zcol_opt->guisection = _("Points");
 
124
    zcol_opt->label = _("Number of column used as z coordinate (points mode)");
 
125
    zcol_opt->description = _("First column is 1. If 0, z coordinate is not used");
125
126
 
126
127
    catcol_opt = G_define_option();
127
128
    catcol_opt->key = "cat";
129
130
    catcol_opt->required = NO;
130
131
    catcol_opt->multiple = NO;
131
132
    catcol_opt->answer = "0";
132
 
    catcol_opt->guisection = _("Columns");
 
133
    catcol_opt->guisection = _("Points");
133
134
    catcol_opt->label =
134
 
        _("Number of column used as category (first column is 1) for points mode");
 
135
        _("Number of column used as category (points mode)");
135
136
    catcol_opt->description =
136
 
        _("If 0, unique category is assigned to each row and written to new column 'cat'");
137
 
 
 
137
        _("First column is 1. If 0, unique category is assigned to each row and written to new column 'cat'");
 
138
    
138
139
    zcoorf = G_define_flag();
139
140
    zcoorf->key = 'z';
140
141
    zcoorf->description = _("Create 3D vector map");
142
143
    e_flag = G_define_flag();
143
144
    e_flag->key = 'e';
144
145
    e_flag->description =
145
 
        _("Create a new empty vector map and exit. Nothing is read from input");
 
146
        _("Create a new empty vector map and exit. Nothing is read from input.");
146
147
 
147
148
    noheader_flag = G_define_flag();
148
149
    noheader_flag->key = 'n';
149
150
    noheader_flag->description =
150
151
        _("Don't expect a header when reading in standard format");
 
152
    noheader_flag->guisection = _("Input format");
151
153
 
152
154
    t_flag = G_define_flag();
153
155
    t_flag->key = 't';
154
156
    t_flag->description = _("Do not create table in points mode");
155
 
    t_flag->guisection = _("Columns");
 
157
    t_flag->guisection = _("Points");
156
158
 
157
159
    notopol_flag = G_define_flag();
158
160
    notopol_flag->key = 'b';
159
161
    notopol_flag->description = _("Do not build topology in points mode");
 
162
    notopol_flag->guisection = _("Points");
160
163
 
161
164
    region_flag = G_define_flag();
162
165
    region_flag->key = 'r';
163
166
    region_flag->description =
164
167
        _("Only import points falling within current region (points mode)");
165
 
 
 
168
    region_flag->guisection = _("Points");
166
169
 
167
170
    if (G_parser(argc, argv))
168
171
        exit(EXIT_FAILURE);
186
189
 
187
190
    /* specifying zcol= implies that a 3D map is needed */
188
191
    if (zcol >= 0 && !zcoorf->answer)
189
 
        zcoorf->answer = 1;
 
192
        zcoorf->answer = TRUE;
190
193
 
191
194
    if (zcoorf->answer && format == FORMAT_POINT && zcol < 0)
192
195
        G_fatal_error(_("Please specify reasonable z column"));
196
199
    if (xcol+1 < 1 || ycol+1 < 1 || zcol+1 < 0 || catcol+1 < 0)
197
200
        G_fatal_error(_("Column numbers must not be negative"));
198
201
 
199
 
    if (old->answer != NULL) {
 
202
    if ( (old->answer != NULL) && (strcmp(old->answer, "-") != 0) ) {
200
203
        if ((ascii = fopen(old->answer, "r")) == NULL) {
201
204
            G_fatal_error(_("Unable to open ASCII file <%s>"), old->answer);
202
205
        }
519
522
        if (driver) {
520
523
            G_message(_("Populating table..."));
521
524
            db_commit_transaction(driver);
 
525
 
522
526
            if(db_close_database_shutdown_driver(driver) == DB_FAILED)
 
527
#ifdef __MINGW32__
 
528
                G_debug(1, "FIXME: db_close_database_shutdown_driver() fails on WinGrass. Ignoring...");
 
529
#else
523
530
                G_fatal_error(_("Could not close attribute table. The DBMI driver did not accept all attributes"));
 
531
#endif
524
532
        }
525
533
        fclose(tmpascii);
526
534
    }