|
@@ -4,10 +4,11 @@
|
|
|
* MODULE: OGR driver
|
|
|
*
|
|
|
* AUTHOR(S): Radim Blazek
|
|
|
+* Some updates by Martin Landa <landa.martin gmail.com>
|
|
|
*
|
|
|
* PURPOSE: DB driver for OGR sources
|
|
|
*
|
|
|
-* COPYRIGHT: (C) 2004 by the GRASS Development Team
|
|
|
+* COPYRIGHT: (C) 2004-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
|
|
@@ -16,20 +17,32 @@
|
|
|
*****************************************************************************/
|
|
|
#include <stdlib.h>
|
|
|
#include <string.h>
|
|
|
+
|
|
|
#include <grass/gis.h>
|
|
|
#include <grass/dbmi.h>
|
|
|
+#include <grass/glocale.h>
|
|
|
+
|
|
|
#include "ogr_api.h"
|
|
|
#include "globals.h"
|
|
|
#include "proto.h"
|
|
|
-#include <grass/glocale.h>
|
|
|
|
|
|
+/*!
|
|
|
+ \brief Fetch record
|
|
|
+
|
|
|
+ \param cn pointer to dbCursor
|
|
|
+ \param position position indicator (DB_NEXT, DB_FIRST, DB_LAST, etc)
|
|
|
+ \param[out] more 0 for no record fetched otherwise 1
|
|
|
+
|
|
|
+ \return DB_OK on success
|
|
|
+ \return DB_FAILED on error
|
|
|
+*/
|
|
|
int db__driver_fetch(dbCursor * cn, int position, int *more)
|
|
|
{
|
|
|
cursor *c;
|
|
|
dbToken token;
|
|
|
dbTable *table;
|
|
|
int i, col;
|
|
|
-
|
|
|
+
|
|
|
G_debug(3, "db_driver_fetch()");
|
|
|
|
|
|
/* get cursor token */
|
|
@@ -37,7 +50,7 @@ int db__driver_fetch(dbCursor * cn, int position, int *more)
|
|
|
|
|
|
/* get the cursor by its token */
|
|
|
if (!(c = (cursor *) db_find_token(token))) {
|
|
|
- append_error("Cursor not found");
|
|
|
+ append_error(_("Cursor not found"));
|
|
|
report_error();
|
|
|
return DB_FAILED;
|
|
|
}
|
|
@@ -53,7 +66,7 @@ int db__driver_fetch(dbCursor * cn, int position, int *more)
|
|
|
case DB_CURRENT:
|
|
|
break;
|
|
|
case DB_PREVIOUS:
|
|
|
- append_error("DB_PREVIOUS not supported");
|
|
|
+ append_error(_("DB_PREVIOUS not supported"));
|
|
|
report_error();
|
|
|
return DB_FAILED;
|
|
|
break;
|
|
@@ -64,7 +77,7 @@ int db__driver_fetch(dbCursor * cn, int position, int *more)
|
|
|
c->hFeature = OGR_L_GetNextFeature(c->hLayer);
|
|
|
break;
|
|
|
case DB_LAST:
|
|
|
- append_error("DB_LAST not supported");
|
|
|
+ append_error(_("DB_LAST not supported"));
|
|
|
report_error();
|
|
|
return DB_FAILED;
|
|
|
break;
|
|
@@ -79,13 +92,12 @@ int db__driver_fetch(dbCursor * cn, int position, int *more)
|
|
|
|
|
|
/* get the data out of the descriptor into the table */
|
|
|
table = db_get_cursor_table(cn);
|
|
|
-
|
|
|
col = -1;
|
|
|
for (i = 0; i < c->ncols; i++) {
|
|
|
int ogrType, sqlType;
|
|
|
dbColumn *column;
|
|
|
dbValue *value;
|
|
|
-
|
|
|
+
|
|
|
if (!(c->cols[i])) {
|
|
|
continue;
|
|
|
} /* unknown type */
|
|
@@ -134,6 +146,14 @@ int db__driver_fetch(dbCursor * cn, int position, int *more)
|
|
|
return DB_OK;
|
|
|
}
|
|
|
|
|
|
+/*
|
|
|
+ \brief Get number of rows (i.e. features) in open cursor
|
|
|
+
|
|
|
+ \param cn pointer to dbCursor
|
|
|
+
|
|
|
+ \return number of rows
|
|
|
+ \return DB_FAILED on error
|
|
|
+*/
|
|
|
int db__driver_get_num_rows(dbCursor * cn)
|
|
|
{
|
|
|
cursor *c;
|
|
@@ -146,7 +166,7 @@ int db__driver_get_num_rows(dbCursor * cn)
|
|
|
|
|
|
/* get the cursor by its token */
|
|
|
if (!(c = (cursor *) db_find_token(token))) {
|
|
|
- append_error("Cursor not found");
|
|
|
+ append_error(_("Cursor not found"));
|
|
|
report_error();
|
|
|
return DB_FAILED;
|
|
|
}
|