[GRASS-SVN] r39619 - grass/trunk/db/drivers/ogr
svn_grass at osgeo.org
svn_grass at osgeo.org
Fri Oct 23 10:40:33 EDT 2009
Author: martinl
Date: 2009-10-23 10:40:32 -0400 (Fri, 23 Oct 2009)
New Revision: 39619
Modified:
grass/trunk/db/drivers/ogr/describe.c
grass/trunk/db/drivers/ogr/select.c
Log:
db ogr driver: fix reporting fid id
Modified: grass/trunk/db/drivers/ogr/describe.c
===================================================================
--- grass/trunk/db/drivers/ogr/describe.c 2009-10-23 13:41:28 UTC (rev 39618)
+++ grass/trunk/db/drivers/ogr/describe.c 2009-10-23 14:40:32 UTC (rev 39619)
@@ -84,7 +84,7 @@
*/
int describe_table(OGRLayerH hLayer, dbTable **table, cursor *c)
{
- int i, ifield, ncols, kcols;
+ int i, ncols, kcols, col;
dbColumn *column;
OGRFeatureDefnH hFeatureDefn;
OGRFieldDefnH hFieldDefn;
@@ -146,22 +146,31 @@
db_set_table_insert_priv_not_granted (*table);
*/
- for (i = 0, ifield = 0; ifield < ncols; i++) {
+ if (*fidcol) {
+ column = db_get_table_column(*table, 0);
+ db_set_column_host_type(column, OFTInteger);
+ db_set_column_sqltype(column, DB_SQL_TYPE_INTEGER);
+ db_set_column_name(column, fidcol);
+ db_set_column_length(column, 11); /* ??? */
+ db_set_column_precision(column, 0);
+
+ col = 1;
+ }
+ else {
+ col = 0;
+ }
+
+ for (i = 0; i < ncols; i++, col++) {
int sqlType;
int size, precision, scale;
- if (*fidcol && i == 0) {
- ogrType = OFTInteger; /* ??? */
- fieldName = fidcol;
+ hFieldDefn = OGR_FD_GetFieldDefn(hFeatureDefn, i);
+ ogrType = OGR_Fld_GetType(hFieldDefn);
+ fieldName = OGR_Fld_GetNameRef(hFieldDefn);
+
+ if (!(cols[i])) {
+ continue; /* unknown type */
}
- else {
- hFieldDefn = OGR_FD_GetFieldDefn(hFeatureDefn, ifield);
- ogrType = OGR_Fld_GetType(hFieldDefn);
- fieldName = OGR_Fld_GetNameRef(hFieldDefn);
-
- if (!(cols[ifield++]))
- continue; /* unknown type */
- }
switch (ogrType) {
case OFTInteger:
@@ -193,9 +202,9 @@
}
G_debug(3, " %d: field %d : ogrType = %d, name = %s, size=%d precision=%d",
- i, ifield, ogrType, fieldName, size, precision);
+ i, col, ogrType, fieldName, size, precision);
- column = db_get_table_column(*table, i);
+ column = db_get_table_column(*table, col);
db_set_column_host_type(column, ogrType);
db_set_column_sqltype(column, sqlType);
Modified: grass/trunk/db/drivers/ogr/select.c
===================================================================
--- grass/trunk/db/drivers/ogr/select.c 2009-10-23 13:41:28 UTC (rev 39618)
+++ grass/trunk/db/drivers/ogr/select.c 2009-10-23 14:40:32 UTC (rev 39619)
@@ -49,6 +49,7 @@
db_set_cursor_mode(dbc, mode);
db_set_cursor_type_readonly(dbc);
+ G_debug(3, "SQL: '%s'", db_get_string(sel));
c->hLayer = OGR_DS_ExecuteSQL(hDs, db_get_string(sel), NULL, NULL);
if (c->hLayer == NULL) {
More information about the grass-commit
mailing list