[GRASS-SVN] r39908 - grass/trunk/vector/v.reclass
svn_grass at osgeo.org
svn_grass at osgeo.org
Sun Dec 6 03:45:27 EST 2009
Author: martinl
Date: 2009-12-06 03:45:27 -0500 (Sun, 06 Dec 2009)
New Revision: 39908
Modified:
grass/trunk/vector/v.reclass/main.c
Log:
v.reclass: OGR support (read access)
Modified: grass/trunk/vector/v.reclass/main.c
===================================================================
--- grass/trunk/vector/v.reclass/main.c 2009-12-06 08:44:11 UTC (rev 39907)
+++ grass/trunk/vector/v.reclass/main.c 2009-12-06 08:45:27 UTC (rev 39908)
@@ -6,17 +6,20 @@
* GRASS 6 update: Radim Blazek <radim.blazek gmail.com>
* Glynn Clements <glynn gclements.plus.com>,
* Jachym Cepicky <jachym les-ejk.cz>, Markus Neteler <neteler itc.it>
+ * OGR support by Martin Landa <landa.martin gmail.com>
* PURPOSE:
- * COPYRIGHT: (C) 1999-2007 by the GRASS Development Team
+ * COPYRIGHT: (C) 1999-2009 by the GRASS Development Team
*
- * This program is free software under the GNU General Public
- * License (>=v2). Read the file COPYING that comes with GRASS
- * for details.
+ * This program is free software under the GNU General
+ * Public License (>=v2). Read the file COPYING that
+ * comes with GRASS for details.
*
*****************************************************************************/
+
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
+
#include <grass/gis.h>
#include <grass/vector.h>
#include <grass/dbmi.h>
@@ -70,21 +73,21 @@
in_opt = G_define_standard_option(G_OPT_V_INPUT);
- out_opt = G_define_standard_option(G_OPT_V_OUTPUT);
+ field_opt = G_define_standard_option(G_OPT_V_FIELD);
+ field_opt->guisection = _("Selection");
type_opt = G_define_standard_option(G_OPT_V_TYPE);
type_opt->options = "point,line,boundary,centroid";
type_opt->answer = "point,line,boundary,centroid";
type_opt->guisection = _("Selection");
- field_opt = G_define_standard_option(G_OPT_V_FIELD);
- field_opt->guisection = _("Selection");
-
+ out_opt = G_define_standard_option(G_OPT_V_OUTPUT);
+
col_opt = G_define_standard_option(G_OPT_DB_COLUMN);
col_opt->label =
_("The name of the column whose values are to be used as new categories");
col_opt->description = _("The source for the new key column must be type integer or string");
-
+
rules_opt = G_define_standard_option(G_OPT_F_INPUT);
rules_opt->key = "rules";
rules_opt->required = NO;
@@ -95,18 +98,19 @@
type = Vect_option_to_types(type_opt);
- field = atoi(field_opt->answer);
if ((!(rules_opt->answer) && !(col_opt->answer)) ||
(rules_opt->answer && col_opt->answer)) {
- G_fatal_error(_("Either 'rules' or 'col' must be specified"));
+ G_fatal_error(_("Either '%s' or '%s' must be specified"),
+ rules_opt->key, col_opt->key);
}
Vect_check_input_output_name(in_opt->answer, out_opt->answer,
GV_FATAL_EXIT);
Vect_set_open_level(2);
- Vect_open_old(&In, in_opt->answer, "");
+ Vect_open_old2(&In, in_opt->answer, "", field_opt->answer);
+ field = Vect_get_field_number(&In, field_opt->answer);
Vect_open_new(&Out, out_opt->answer, Vect_is_3d(&In));
Vect_copy_head_data(&In, &Out);
@@ -118,8 +122,8 @@
Fi = Vect_get_field(&In, field);
if (Fi == NULL)
- G_fatal_error(_("Database connection not defined for layer %d"),
- field);
+ G_fatal_error(_("Database connection not defined for layer %s"),
+ field_opt->answer);
Driver = db_start_driver_open_database(Fi->driver, Fi->database);
if (Driver == NULL)
More information about the grass-commit
mailing list