[GRASS-SVN] r39579 - grass/trunk/vector/v.out.ogr
svn_grass at osgeo.org
svn_grass at osgeo.org
Mon Oct 19 04:44:45 EDT 2009
Author: martinl
Date: 2009-10-19 04:44:44 -0400 (Mon, 19 Oct 2009)
New Revision: 39579
Modified:
grass/trunk/vector/v.out.ogr/attrb.c
grass/trunk/vector/v.out.ogr/main.c
Log:
v.out.ogr: don't write attributes twice (bugfix)
fix intendation
Modified: grass/trunk/vector/v.out.ogr/attrb.c
===================================================================
--- grass/trunk/vector/v.out.ogr/attrb.c 2009-10-19 07:49:42 UTC (rev 39578)
+++ grass/trunk/vector/v.out.ogr/attrb.c 2009-10-19 08:44:44 UTC (rev 39579)
@@ -68,32 +68,34 @@
ogrfieldnum = OGR_F_GetFieldIndex(Ogr_feature,
db_get_column_name(Column));
-
+ G_debug(2, " column = %s -> fieldnum = %d",
+ db_get_column_name(Column), ogrfieldnum);
+
/* Reset */
OGR_F_UnsetField(Ogr_feature, ogrfieldnum);
/* prevent writing NULL values */
if (!db_test_value_isnull(Value)) {
- switch (colctype) {
- case DB_C_TYPE_INT:
- OGR_F_SetFieldInteger(Ogr_feature, ogrfieldnum,
- db_get_value_int(Value));
- break;
- case DB_C_TYPE_DOUBLE:
- OGR_F_SetFieldDouble(Ogr_feature, ogrfieldnum,
- db_get_value_double(Value));
- break;
- case DB_C_TYPE_STRING:
- OGR_F_SetFieldString(Ogr_feature, ogrfieldnum,
- db_get_value_string(Value));
- break;
- case DB_C_TYPE_DATETIME:
- db_convert_column_value_to_string(Column,
- &dbstring);
- OGR_F_SetFieldString(Ogr_feature, ogrfieldnum,
- db_get_string(&dbstring));
- break;
- }
+ switch (colctype) {
+ case DB_C_TYPE_INT:
+ OGR_F_SetFieldInteger(Ogr_feature, ogrfieldnum,
+ db_get_value_int(Value));
+ break;
+ case DB_C_TYPE_DOUBLE:
+ OGR_F_SetFieldDouble(Ogr_feature, ogrfieldnum,
+ db_get_value_double(Value));
+ break;
+ case DB_C_TYPE_STRING:
+ OGR_F_SetFieldString(Ogr_feature, ogrfieldnum,
+ db_get_value_string(Value));
+ break;
+ case DB_C_TYPE_DATETIME:
+ db_convert_column_value_to_string(Column,
+ &dbstring);
+ OGR_F_SetFieldString(Ogr_feature, ogrfieldnum,
+ db_get_string(&dbstring));
+ break;
+ }
}
}
}
Modified: grass/trunk/vector/v.out.ogr/main.c
===================================================================
--- grass/trunk/vector/v.out.ogr/main.c 2009-10-19 07:49:42 UTC (rev 39578)
+++ grass/trunk/vector/v.out.ogr/main.c 2009-10-19 08:44:44 UTC (rev 39579)
@@ -52,7 +52,6 @@
int doatt = 0, ncol = 0, colsqltype, colctype, keycol = -1;
struct field_info *Fi = NULL;
dbDriver *Driver = NULL;
- dbHandle handle;
dbTable *Table;
dbString dbstring;
dbColumn *Column;
@@ -345,16 +344,11 @@
doatt = 0;
}
else {
- Driver = db_start_driver(Fi->driver);
- if (Driver == NULL)
- G_fatal_error(_("Unable to start driver <%s>"), Fi->driver);
-
- db_init_handle(&handle);
- db_set_handle(&handle, Fi->database, NULL);
- if (db_open_database(Driver, &handle) != DB_OK)
+ Driver = db_start_driver_open_database(Fi->driver, Fi->database);
+ if (!Driver)
G_fatal_error(_("Unable to open database <%s> by driver <%s>"),
Fi->database, Fi->driver);
-
+
db_set_string(&dbstring, Fi->table);
if (db_describe_table(Driver, &dbstring, &Table) != DB_OK)
G_fatal_error(_("Unable to describe table <%s>"), Fi->table);
@@ -393,11 +387,7 @@
keycol = i;
G_debug(2, "%s x %s -> %s x %s -> keycol = %d", Fi->key,
db_get_column_name(Column), key1, key2, keycol);
-
- Ogr_field =
- OGR_Fld_Create(db_get_column_name(Column), ogr_ftype);
- OGR_L_CreateField(Ogr_layer, Ogr_field, 0);
- OGR_Fld_Destroy(Ogr_field);
+
if (!flags.nocat->answer) {
Ogr_field =
OGR_Fld_Create(db_get_column_name(Column), ogr_ftype);
@@ -405,16 +395,16 @@
OGR_Fld_Destroy(Ogr_field);
} else {
/* skip export of 'cat' field */
- if (strcmp (Fi->key,db_get_column_name(Column)) != 0) {
+ if (strcmp (Fi->key, db_get_column_name(Column)) != 0) {
Ogr_field =
OGR_Fld_Create(db_get_column_name(Column), ogr_ftype);
OGR_L_CreateField(Ogr_layer, Ogr_field, 0);
OGR_Fld_Destroy(Ogr_field);
}
+ }
}
- }
if (keycol == -1)
- G_fatal_error(_("Key column '%s' not found"), Fi->key);
+ G_fatal_error(_("Key column <%s> not found"), Fi->key);
}
}
@@ -552,8 +542,7 @@
nocatskip++;
continue;
}
-
-
+
/* Geometry */
if (type == GV_LINE && flags.poly->answer) {
OGRGeometryH ring;
More information about the grass-commit
mailing list