~ubuntu-branches/debian/sid/gdal/sid

« back to all changes in this revision

Viewing changes to ogr/ogrsf_frmts/sqlite/ogrsqliteselectlayer.cpp

  • Committer: Package Import Robot
  • Author(s): Francesco Paolo Lovergine
  • Date: 2012-05-07 15:04:42 UTC
  • mfrom: (5.5.16 experimental)
  • Revision ID: package-import@ubuntu.com-20120507150442-2eks97loeh6rq005
Tags: 1.9.0-1
* Ready for sid, starting transition.
* All symfiles updated to latest builds.
* Added dh_numpy call in debian/rules to depend on numpy ABI.
* Policy bumped to 3.9.3, no changes required.

Show diffs side-by-side

added added

removed removed

Lines of Context:
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 $
3
3
 *
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"
33
33
 
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
/************************************************************************/
38
38
 
39
39
OGRSQLiteSelectLayer::OGRSQLiteSelectLayer( OGRSQLiteDataSource *poDSIn,
 
40
                                            CPLString osSQL,
40
41
                                            sqlite3_stmt *hStmtIn )
41
42
 
42
43
{
46
47
    nSRSId = -1;
47
48
    poFeatureDefn = NULL;
48
49
 
49
 
    hStmt = hStmtIn;
50
 
 
51
 
    BuildFeatureDefn( "SELECT", hStmt );
52
 
    
53
 
    // Reset so the next _step() will get the first record.
54
 
    sqlite3_reset( hStmt );
 
50
    BuildFeatureDefn( "SELECT", hStmtIn );
 
51
 
 
52
    sqlite3_finalize( hStmtIn );
 
53
 
 
54
    this->osSQL = osSQL;
55
55
}
56
56
 
57
57
/************************************************************************/
61
61
OGRSQLiteSelectLayer::~OGRSQLiteSelectLayer()
62
62
 
63
63
{
64
 
    sqlite3_finalize( hStmt );
65
 
    hStmt = NULL;
66
 
}
67
 
 
68
 
/************************************************************************/
69
 
/*                           ClearStatement()                           */
70
 
/*                                                                      */
71
 
/*      Called when GetNextRawFeature() runs out of rows.               */
72
 
/************************************************************************/
73
 
 
74
 
void OGRSQLiteSelectLayer::ClearStatement()
75
 
 
76
 
{
77
 
}
78
 
 
79
 
/************************************************************************/
80
 
/*                            ResetReading()                            */
81
 
/************************************************************************/
82
 
 
83
 
void OGRSQLiteSelectLayer::ResetReading()
84
 
 
85
 
{
86
 
    sqlite3_reset( hStmt );
87
 
    OGRSQLiteLayer::ResetReading();
88
 
}
89
 
 
90
 
/************************************************************************/
91
 
/*                             GetFeature()                             */
92
 
/************************************************************************/
93
 
 
94
 
OGRFeature *OGRSQLiteSelectLayer::GetFeature( long nFeatureId )
95
 
 
96
 
{
97
 
    return OGRSQLiteLayer::GetFeature( nFeatureId );
98
 
}
99
 
 
100
 
/************************************************************************/
101
 
/*                           TestCapability()                           */
102
 
/************************************************************************/
103
 
 
104
 
int OGRSQLiteSelectLayer::TestCapability( const char * pszCap )
105
 
 
106
 
{
107
 
    return OGRSQLiteLayer::TestCapability( pszCap );
108
 
}
109
 
 
110
 
/************************************************************************/
111
 
/*                          GetFeatureCount()                           */
112
 
/*                                                                      */
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
 
/************************************************************************/
118
 
 
119
 
int OGRSQLiteSelectLayer::GetFeatureCount( int bForce )
120
 
 
121
 
{
122
 
    return OGRSQLiteLayer::GetFeatureCount( bForce );
 
64
}
 
65
 
 
66
/************************************************************************/
 
67
/*                           ResetStatement()                           */
 
68
/************************************************************************/
 
69
 
 
70
OGRErr OGRSQLiteSelectLayer::ResetStatement()
 
71
 
 
72
{
 
73
    int rc;
 
74
 
 
75
    ClearStatement();
 
76
 
 
77
    iNextShapeId = 0;
 
78
 
 
79
    rc = sqlite3_prepare( poDS->GetDB(), osSQL, osSQL.size(),
 
80
                          &hStmt, NULL );
 
81
 
 
82
    if( rc == SQLITE_OK )
 
83
    {
 
84
        return OGRERR_NONE;
 
85
    }
 
86
    else
 
87
    {
 
88
        CPLError( CE_Failure, CPLE_AppDefined, 
 
89
                  "In ResetStatement(): sqlite3_prepare(%s):\n  %s", 
 
90
                  osSQL.c_str(), sqlite3_errmsg(poDS->GetDB()) );
 
91
        hStmt = NULL;
 
92
        return OGRERR_FAILURE;
 
93
    }
123
94
}