1
/******************************************************************************
2
* $Id: ogrgeomediaselectlayer.cpp 21545 2011-01-22 14:26:31Z rouault $
4
* Project: OpenGIS Simple Features Reference Implementation
5
* Purpose: Implements OGRGeomediaSelectLayer class, layer access to the results
6
* of a SELECT statement executed via ExecuteSQL().
7
* Author: Frank Warmerdam, warmerdam@pobox.com
9
******************************************************************************
10
* Copyright (c) 2005, Frank Warmerdam
12
* Permission is hereby granted, free of charge, to any person obtaining a
13
* copy of this software and associated documentation files (the "Software"),
14
* to deal in the Software without restriction, including without limitation
15
* the rights to use, copy, modify, merge, publish, distribute, sublicense,
16
* and/or sell copies of the Software, and to permit persons to whom the
17
* Software is furnished to do so, subject to the following conditions:
19
* The above copyright notice and this permission notice shall be included
20
* in all copies or substantial portions of the Software.
22
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
23
* OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
24
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
25
* THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
26
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
27
* FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
28
* DEALINGS IN THE SOFTWARE.
29
****************************************************************************/
32
#include "ogr_geomedia.h"
34
CPL_CVSID("$Id: ogrgeomediaselectlayer.cpp 21545 2011-01-22 14:26:31Z rouault $");
36
/************************************************************************/
37
/* OGRGeomediaSelectLayer() */
38
/************************************************************************/
40
OGRGeomediaSelectLayer::OGRGeomediaSelectLayer( OGRGeomediaDataSource *poDSIn,
41
CPLODBCStatement * poStmtIn )
51
pszBaseStatement = CPLStrdup( poStmtIn->GetCommand() );
53
BuildFeatureDefn( "SELECT", poStmt );
56
/************************************************************************/
57
/* ~OGRGeomediaSelectLayer() */
58
/************************************************************************/
60
OGRGeomediaSelectLayer::~OGRGeomediaSelectLayer()
64
CPLFree(pszBaseStatement);
67
/************************************************************************/
68
/* ClearStatement() */
69
/************************************************************************/
71
void OGRGeomediaSelectLayer::ClearStatement()
81
/************************************************************************/
83
/************************************************************************/
85
CPLODBCStatement *OGRGeomediaSelectLayer::GetStatement()
94
/************************************************************************/
95
/* ResetStatement() */
96
/************************************************************************/
98
OGRErr OGRGeomediaSelectLayer::ResetStatement()
105
CPLDebug( "ODBC", "Recreating statement." );
106
poStmt = new CPLODBCStatement( poDS->GetSession() );
107
poStmt->Append( pszBaseStatement );
109
if( poStmt->ExecuteSQL() )
115
return OGRERR_FAILURE;
119
/************************************************************************/
121
/************************************************************************/
123
void OGRGeomediaSelectLayer::ResetReading()
126
if( iNextShapeId != 0 )
129
OGRGeomediaLayer::ResetReading();
132
/************************************************************************/
134
/************************************************************************/
136
OGRFeature *OGRGeomediaSelectLayer::GetFeature( long nFeatureId )
139
return OGRGeomediaLayer::GetFeature( nFeatureId );
142
/************************************************************************/
143
/* TestCapability() */
144
/************************************************************************/
146
int OGRGeomediaSelectLayer::TestCapability( const char * pszCap )
149
return OGRGeomediaLayer::TestCapability( pszCap );
152
/************************************************************************/
153
/* GetFeatureCount() */
155
/* If a spatial filter is in effect, we turn control over to */
156
/* the generic counter. Otherwise we return the total count. */
157
/* Eventually we should consider implementing a more efficient */
158
/* way of counting features matching a spatial query. */
159
/************************************************************************/
161
int OGRGeomediaSelectLayer::GetFeatureCount( int bForce )
164
return OGRGeomediaLayer::GetFeatureCount( bForce );