1
1
/******************************************************************************
2
* $Id: ogrsqliteselectlayer.cpp 10645 2007-01-18 02:22:39Z warmerdam $
2
* $Id: ogrsqliteselectlayer.cpp 19800 2010-06-04 21:38:03Z rouault $
4
4
* Project: OpenGIS Simple Features Reference Implementation
5
5
* Purpose: Implements OGRSQLiteSelectLayer class, layer access to the results
31
31
#include "cpl_conv.h"
32
32
#include "ogr_sqlite.h"
34
CPL_CVSID("$Id: ogrsqliteselectlayer.cpp 10645 2007-01-18 02:22:39Z warmerdam $");
34
CPL_CVSID("$Id: ogrsqliteselectlayer.cpp 19800 2010-06-04 21:38:03Z rouault $");
35
35
/************************************************************************/
36
36
/* OGRSQLiteSelectLayer() */
37
37
/************************************************************************/
39
39
OGRSQLiteSelectLayer::OGRSQLiteSelectLayer( OGRSQLiteDataSource *poDSIn,
40
41
sqlite3_stmt *hStmtIn )
47
48
poFeatureDefn = NULL;
51
BuildFeatureDefn( "SELECT", hStmt );
53
// Reset so the next _step() will get the first record.
54
sqlite3_reset( hStmt );
50
BuildFeatureDefn( "SELECT", hStmtIn );
52
sqlite3_finalize( hStmtIn );
57
57
/************************************************************************/
61
61
OGRSQLiteSelectLayer::~OGRSQLiteSelectLayer()
64
sqlite3_finalize( hStmt );
68
/************************************************************************/
69
/* ClearStatement() */
71
/* Called when GetNextRawFeature() runs out of rows. */
72
/************************************************************************/
74
void OGRSQLiteSelectLayer::ClearStatement()
79
/************************************************************************/
81
/************************************************************************/
83
void OGRSQLiteSelectLayer::ResetReading()
86
sqlite3_reset( hStmt );
87
OGRSQLiteLayer::ResetReading();
90
/************************************************************************/
92
/************************************************************************/
94
OGRFeature *OGRSQLiteSelectLayer::GetFeature( long nFeatureId )
97
return OGRSQLiteLayer::GetFeature( nFeatureId );
100
/************************************************************************/
101
/* TestCapability() */
102
/************************************************************************/
104
int OGRSQLiteSelectLayer::TestCapability( const char * pszCap )
107
return OGRSQLiteLayer::TestCapability( pszCap );
110
/************************************************************************/
111
/* GetFeatureCount() */
113
/* If a spatial filter is in effect, we turn control over to */
114
/* the generic counter. Otherwise we return the total count. */
115
/* Eventually we should consider implementing a more efficient */
116
/* way of counting features matching a spatial query. */
117
/************************************************************************/
119
int OGRSQLiteSelectLayer::GetFeatureCount( int bForce )
122
return OGRSQLiteLayer::GetFeatureCount( bForce );
66
/************************************************************************/
67
/* ResetStatement() */
68
/************************************************************************/
70
OGRErr OGRSQLiteSelectLayer::ResetStatement()
79
rc = sqlite3_prepare( poDS->GetDB(), osSQL, osSQL.size(),
88
CPLError( CE_Failure, CPLE_AppDefined,
89
"In ResetStatement(): sqlite3_prepare(%s):\n %s",
90
osSQL.c_str(), sqlite3_errmsg(poDS->GetDB()) );
92
return OGRERR_FAILURE;