LTP GCOV extension - code coverage report
Current view: directory - ogr/ogrsf_frmts/pgeo - ogrpgeoselectlayer.cpp
Test: gdal_filtered.info
Date: 2010-07-12 Instrumented lines: 43
Code covered: 0.0 % Executed lines: 0

       1                 : /******************************************************************************
       2                 :  * $Id: ogrpgeoselectlayer.cpp 10645 2007-01-18 02:22:39Z warmerdam $
       3                 :  *
       4                 :  * Project:  OpenGIS Simple Features Reference Implementation
       5                 :  * Purpose:  Implements OGRPGeoSelectLayer 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_pgeo.h"
      33                 : 
      34                 : CPL_CVSID("$Id: ogrpgeoselectlayer.cpp 10645 2007-01-18 02:22:39Z warmerdam $");
      35                 : 
      36                 : /************************************************************************/
      37                 : /*                          OGRPGeoSelectLayer()                        */
      38                 : /************************************************************************/
      39                 : 
      40                 : OGRPGeoSelectLayer::OGRPGeoSelectLayer( OGRPGeoDataSource *poDSIn,
      41               0 :                                         CPLODBCStatement * poStmtIn )
      42                 : 
      43                 : {
      44               0 :     poDS = poDSIn;
      45                 : 
      46               0 :     iNextShapeId = 0;
      47               0 :     nSRSId = -1;
      48               0 :     poFeatureDefn = NULL;
      49                 : 
      50               0 :     poStmt = poStmtIn;
      51               0 :     pszBaseStatement = CPLStrdup( poStmtIn->GetCommand() );
      52                 : 
      53               0 :     BuildFeatureDefn( "SELECT", poStmt );
      54               0 : }
      55                 : 
      56                 : /************************************************************************/
      57                 : /*                          ~OGRPGeoSelectLayer()                       */
      58                 : /************************************************************************/
      59                 : 
      60               0 : OGRPGeoSelectLayer::~OGRPGeoSelectLayer()
      61                 : 
      62                 : {
      63               0 :     ClearStatement();
      64               0 : }
      65                 : 
      66                 : /************************************************************************/
      67                 : /*                           ClearStatement()                           */
      68                 : /************************************************************************/
      69                 : 
      70               0 : void OGRPGeoSelectLayer::ClearStatement()
      71                 : 
      72                 : {
      73               0 :     if( poStmt != NULL )
      74                 :     {
      75               0 :         delete poStmt;
      76               0 :         poStmt = NULL;
      77                 :     }
      78               0 : }
      79                 : 
      80                 : /************************************************************************/
      81                 : /*                            GetStatement()                            */
      82                 : /************************************************************************/
      83                 : 
      84               0 : CPLODBCStatement *OGRPGeoSelectLayer::GetStatement()
      85                 : 
      86                 : {
      87               0 :     if( poStmt == NULL )
      88               0 :         ResetStatement();
      89                 : 
      90               0 :     return poStmt;
      91                 : }
      92                 : 
      93                 : /************************************************************************/
      94                 : /*                           ResetStatement()                           */
      95                 : /************************************************************************/
      96                 : 
      97               0 : OGRErr OGRPGeoSelectLayer::ResetStatement()
      98                 : 
      99                 : {
     100               0 :     ClearStatement();
     101                 : 
     102               0 :     iNextShapeId = 0;
     103                 : 
     104               0 :     CPLDebug( "ODBC", "Recreating statement." );
     105               0 :     poStmt = new CPLODBCStatement( poDS->GetSession() );
     106               0 :     poStmt->Append( pszBaseStatement );
     107                 : 
     108               0 :     if( poStmt->ExecuteSQL() )
     109               0 :         return OGRERR_NONE;
     110                 :     else
     111                 :     {
     112               0 :         delete poStmt;
     113               0 :         poStmt = NULL;
     114               0 :         return OGRERR_FAILURE;
     115                 :     }
     116                 : }
     117                 : 
     118                 : /************************************************************************/
     119                 : /*                            ResetReading()                            */
     120                 : /************************************************************************/
     121                 : 
     122               0 : void OGRPGeoSelectLayer::ResetReading()
     123                 : 
     124                 : {
     125               0 :     if( iNextShapeId != 0 )
     126               0 :         ClearStatement();
     127                 : 
     128               0 :     OGRPGeoLayer::ResetReading();
     129               0 : }
     130                 : 
     131                 : /************************************************************************/
     132                 : /*                             GetFeature()                             */
     133                 : /************************************************************************/
     134                 : 
     135               0 : OGRFeature *OGRPGeoSelectLayer::GetFeature( long nFeatureId )
     136                 : 
     137                 : {
     138               0 :     return OGRPGeoLayer::GetFeature( nFeatureId );
     139                 : }
     140                 : 
     141                 : /************************************************************************/
     142                 : /*                           TestCapability()                           */
     143                 : /************************************************************************/
     144                 : 
     145               0 : int OGRPGeoSelectLayer::TestCapability( const char * pszCap )
     146                 : 
     147                 : {
     148               0 :     return OGRPGeoLayer::TestCapability( pszCap );
     149                 : }
     150                 : 
     151                 : /************************************************************************/
     152                 : /*                          GetFeatureCount()                           */
     153                 : /*                                                                      */
     154                 : /*      If a spatial filter is in effect, we turn control over to       */
     155                 : /*      the generic counter.  Otherwise we return the total count.      */
     156                 : /*      Eventually we should consider implementing a more efficient     */
     157                 : /*      way of counting features matching a spatial query.              */
     158                 : /************************************************************************/
     159                 : 
     160               0 : int OGRPGeoSelectLayer::GetFeatureCount( int bForce )
     161                 : 
     162                 : {
     163               0 :     return OGRPGeoLayer::GetFeatureCount( bForce );
     164                 : }

Generated by: LTP GCOV extension version 1.5