LCOV - code coverage report
Current view: directory - ogr/ogrsf_frmts/sqlite - ogrsqliteselectlayer.cpp (source / functions) Found Hit Coverage
Test: gdal_filtered.info Lines: 26 24 92.3 %
Date: 2010-01-09 Functions: 8 7 87.5 %

       1                 : /******************************************************************************
       2                 :  * $Id: ogrsqliteselectlayer.cpp 10645 2007-01-18 02:22:39Z warmerdam $
       3                 :  *
       4                 :  * Project:  OpenGIS Simple Features Reference Implementation
       5                 :  * Purpose:  Implements OGRSQLiteSelectLayer 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) 2004, 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_sqlite.h"
      33                 : 
      34                 : CPL_CVSID("$Id: ogrsqliteselectlayer.cpp 10645 2007-01-18 02:22:39Z warmerdam $");
      35                 : /************************************************************************/
      36                 : /*                        OGRSQLiteSelectLayer()                        */
      37                 : /************************************************************************/
      38                 : 
      39              20 : OGRSQLiteSelectLayer::OGRSQLiteSelectLayer( OGRSQLiteDataSource *poDSIn,
      40              20 :                                             sqlite3_stmt *hStmtIn )
      41                 : 
      42                 : {
      43              20 :     poDS = poDSIn;
      44                 : 
      45              20 :     iNextShapeId = 0;
      46              20 :     nSRSId = -1;
      47              20 :     poFeatureDefn = NULL;
      48                 : 
      49              20 :     hStmt = hStmtIn;
      50                 : 
      51              20 :     BuildFeatureDefn( "SELECT", hStmt );
      52                 :     
      53                 :     // Reset so the next _step() will get the first record.
      54              20 :     sqlite3_reset( hStmt );
      55              20 : }
      56                 : 
      57                 : /************************************************************************/
      58                 : /*                       ~OGRSQLiteSelectLayer()                        */
      59                 : /************************************************************************/
      60                 : 
      61              40 : OGRSQLiteSelectLayer::~OGRSQLiteSelectLayer()
      62                 : 
      63                 : {
      64              20 :     sqlite3_finalize( hStmt );
      65              20 :     hStmt = NULL;
      66              40 : }
      67                 : 
      68                 : /************************************************************************/
      69                 : /*                           ClearStatement()                           */
      70                 : /*                                                                      */
      71                 : /*      Called when GetNextRawFeature() runs out of rows.               */
      72                 : /************************************************************************/
      73                 : 
      74              16 : void OGRSQLiteSelectLayer::ClearStatement()
      75                 : 
      76                 : {
      77              16 : }
      78                 : 
      79                 : /************************************************************************/
      80                 : /*                            ResetReading()                            */
      81                 : /************************************************************************/
      82                 : 
      83              13 : void OGRSQLiteSelectLayer::ResetReading()
      84                 : 
      85                 : {
      86              13 :     sqlite3_reset( hStmt );
      87              13 :     OGRSQLiteLayer::ResetReading();
      88              13 : }
      89                 : 
      90                 : /************************************************************************/
      91                 : /*                             GetFeature()                             */
      92                 : /************************************************************************/
      93                 : 
      94               2 : OGRFeature *OGRSQLiteSelectLayer::GetFeature( long nFeatureId )
      95                 : 
      96                 : {
      97               2 :     return OGRSQLiteLayer::GetFeature( nFeatureId );
      98                 : }
      99                 : 
     100                 : /************************************************************************/
     101                 : /*                           TestCapability()                           */
     102                 : /************************************************************************/
     103                 : 
     104               0 : int OGRSQLiteSelectLayer::TestCapability( const char * pszCap )
     105                 : 
     106                 : {
     107               0 :     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               5 : int OGRSQLiteSelectLayer::GetFeatureCount( int bForce )
     120                 : 
     121                 : {
     122               5 :     return OGRSQLiteLayer::GetFeatureCount( bForce );
     123                 : }

Generated by: LCOV version 1.7