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

« back to all changes in this revision

Viewing changes to ogr/ogrsf_frmts/geomedia/ogrgeomediaselectlayer.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
/******************************************************************************
 
2
 * $Id: ogrgeomediaselectlayer.cpp 21545 2011-01-22 14:26:31Z rouault $
 
3
 *
 
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
 
8
 *
 
9
 ******************************************************************************
 
10
 * Copyright (c) 2005, Frank Warmerdam
 
11
 *
 
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:
 
18
 *
 
19
 * The above copyright notice and this permission notice shall be included
 
20
 * in all copies or substantial portions of the Software.
 
21
 *
 
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
 ****************************************************************************/
 
30
 
 
31
#include "cpl_conv.h"
 
32
#include "ogr_geomedia.h"
 
33
 
 
34
CPL_CVSID("$Id: ogrgeomediaselectlayer.cpp 21545 2011-01-22 14:26:31Z rouault $");
 
35
 
 
36
/************************************************************************/
 
37
/*                        OGRGeomediaSelectLayer()                      */
 
38
/************************************************************************/
 
39
 
 
40
OGRGeomediaSelectLayer::OGRGeomediaSelectLayer( OGRGeomediaDataSource *poDSIn,
 
41
                                        CPLODBCStatement * poStmtIn )
 
42
 
 
43
{
 
44
    poDS = poDSIn;
 
45
 
 
46
    iNextShapeId = 0;
 
47
    nSRSId = -1;
 
48
    poFeatureDefn = NULL;
 
49
 
 
50
    poStmt = poStmtIn;
 
51
    pszBaseStatement = CPLStrdup( poStmtIn->GetCommand() );
 
52
 
 
53
    BuildFeatureDefn( "SELECT", poStmt );
 
54
}
 
55
 
 
56
/************************************************************************/
 
57
/*                        ~OGRGeomediaSelectLayer()                     */
 
58
/************************************************************************/
 
59
 
 
60
OGRGeomediaSelectLayer::~OGRGeomediaSelectLayer()
 
61
 
 
62
{
 
63
    ClearStatement();
 
64
    CPLFree(pszBaseStatement);
 
65
}
 
66
 
 
67
/************************************************************************/
 
68
/*                           ClearStatement()                           */
 
69
/************************************************************************/
 
70
 
 
71
void OGRGeomediaSelectLayer::ClearStatement()
 
72
 
 
73
{
 
74
    if( poStmt != NULL )
 
75
    {
 
76
        delete poStmt;
 
77
        poStmt = NULL;
 
78
    }
 
79
}
 
80
 
 
81
/************************************************************************/
 
82
/*                            GetStatement()                            */
 
83
/************************************************************************/
 
84
 
 
85
CPLODBCStatement *OGRGeomediaSelectLayer::GetStatement()
 
86
 
 
87
{
 
88
    if( poStmt == NULL )
 
89
        ResetStatement();
 
90
 
 
91
    return poStmt;
 
92
}
 
93
 
 
94
/************************************************************************/
 
95
/*                           ResetStatement()                           */
 
96
/************************************************************************/
 
97
 
 
98
OGRErr OGRGeomediaSelectLayer::ResetStatement()
 
99
 
 
100
{
 
101
    ClearStatement();
 
102
 
 
103
    iNextShapeId = 0;
 
104
 
 
105
    CPLDebug( "ODBC", "Recreating statement." );
 
106
    poStmt = new CPLODBCStatement( poDS->GetSession() );
 
107
    poStmt->Append( pszBaseStatement );
 
108
 
 
109
    if( poStmt->ExecuteSQL() )
 
110
        return OGRERR_NONE;
 
111
    else
 
112
    {
 
113
        delete poStmt;
 
114
        poStmt = NULL;
 
115
        return OGRERR_FAILURE;
 
116
    }
 
117
}
 
118
 
 
119
/************************************************************************/
 
120
/*                            ResetReading()                            */
 
121
/************************************************************************/
 
122
 
 
123
void OGRGeomediaSelectLayer::ResetReading()
 
124
 
 
125
{
 
126
    if( iNextShapeId != 0 )
 
127
        ClearStatement();
 
128
 
 
129
    OGRGeomediaLayer::ResetReading();
 
130
}
 
131
 
 
132
/************************************************************************/
 
133
/*                             GetFeature()                             */
 
134
/************************************************************************/
 
135
 
 
136
OGRFeature *OGRGeomediaSelectLayer::GetFeature( long nFeatureId )
 
137
 
 
138
{
 
139
    return OGRGeomediaLayer::GetFeature( nFeatureId );
 
140
}
 
141
 
 
142
/************************************************************************/
 
143
/*                           TestCapability()                           */
 
144
/************************************************************************/
 
145
 
 
146
int OGRGeomediaSelectLayer::TestCapability( const char * pszCap )
 
147
 
 
148
{
 
149
    return OGRGeomediaLayer::TestCapability( pszCap );
 
150
}
 
151
 
 
152
/************************************************************************/
 
153
/*                          GetFeatureCount()                           */
 
154
/*                                                                      */
 
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
/************************************************************************/
 
160
 
 
161
int OGRGeomediaSelectLayer::GetFeatureCount( int bForce )
 
162
 
 
163
{
 
164
    return OGRGeomediaLayer::GetFeatureCount( bForce );
 
165
}