LTP GCOV extension - code coverage report
Current view: directory - ogr/ogrsf_frmts/pcidsk - ogrpcidskdatasource.cpp
Test: gdal_filtered.info
Date: 2010-07-12 Instrumented lines: 29
Code covered: 31.0 % Executed lines: 9

       1                 : /******************************************************************************
       2                 :  * $Id: ogrcsvdatasource.cpp 17806 2009-10-13 17:27:54Z rouault $
       3                 :  *
       4                 :  * Project:  PCIDSK Translator
       5                 :  * Purpose:  Implements OGRPCIDSKDataSource class
       6                 :  * Author:   Frank Warmerdam, warmerdam@pobox.com
       7                 :  *
       8                 :  ******************************************************************************
       9                 :  * Copyright (c) 2009, Frank Warmerdam <warmerdam@pobox.com>
      10                 :  *
      11                 :  * Permission is hereby granted, free of charge, to any person obtaining a
      12                 :  * copy of this software and associated documentation files (the "Software"),
      13                 :  * to deal in the Software without restriction, including without limitation
      14                 :  * the rights to use, copy, modify, merge, publish, distribute, sublicense,
      15                 :  * and/or sell copies of the Software, and to permit persons to whom the
      16                 :  * Software is furnished to do so, subject to the following conditions:
      17                 :  *
      18                 :  * The above copyright notice and this permission notice shall be included
      19                 :  * in all copies or substantial portions of the Software.
      20                 :  *
      21                 :  * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
      22                 :  * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
      23                 :  * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
      24                 :  * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
      25                 :  * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
      26                 :  * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
      27                 :  * DEALINGS IN THE SOFTWARE.
      28                 :  ****************************************************************************/
      29                 : 
      30                 : #include "ogr_pcidsk.h"
      31                 : #include "cpl_conv.h"
      32                 : #include "cpl_string.h"
      33                 : #include "cpl_csv.h"
      34                 : 
      35                 : CPL_CVSID("$Id: ogrcsvdatasource.cpp 17806 2009-10-13 17:27:54Z rouault $");
      36                 : 
      37                 : /************************************************************************/
      38                 : /*                        OGRPCIDSKDataSource()                         */
      39                 : /************************************************************************/
      40                 : 
      41              50 : OGRPCIDSKDataSource::OGRPCIDSKDataSource()
      42                 : 
      43                 : {
      44              50 :     bUpdate = FALSE;
      45              50 : }
      46                 : 
      47                 : /************************************************************************/
      48                 : /*                        ~OGRPCIDSKDataSource()                        */
      49                 : /************************************************************************/
      50                 : 
      51              50 : OGRPCIDSKDataSource::~OGRPCIDSKDataSource()
      52                 : 
      53                 : {
      54             100 :     while( apoLayers.size() > 0 )
      55                 :     {
      56               0 :         delete apoLayers.back();
      57               0 :         apoLayers.pop_back();
      58                 :     }
      59              50 : }
      60                 : 
      61                 : /************************************************************************/
      62                 : /*                           TestCapability()                           */
      63                 : /************************************************************************/
      64                 : 
      65               0 : int OGRPCIDSKDataSource::TestCapability( const char * pszCap )
      66                 : 
      67                 : {
      68               0 :     return FALSE;
      69                 : }
      70                 : 
      71                 : /************************************************************************/
      72                 : /*                              GetLayer()                              */
      73                 : /************************************************************************/
      74                 : 
      75               0 : OGRLayer *OGRPCIDSKDataSource::GetLayer( int iLayer )
      76                 : 
      77                 : {
      78               0 :     if( iLayer < 0 || iLayer >= (int) apoLayers.size() )
      79               0 :         return NULL;
      80                 :     else
      81               0 :         return apoLayers[iLayer];
      82                 : }
      83                 : 
      84                 : /************************************************************************/
      85                 : /*                                Open()                                */
      86                 : /************************************************************************/
      87                 : 
      88              50 : int OGRPCIDSKDataSource::Open( const char * pszFilename, int bUpdateIn )
      89                 : 
      90                 : {
      91              50 :     if( !EQUAL(CPLGetExtension(pszFilename),"pix") )
      92              50 :         return FALSE;
      93                 : 
      94               0 :     osName = pszFilename;
      95               0 :     bUpdate = bUpdateIn;
      96                 : 
      97                 : /* -------------------------------------------------------------------- */
      98                 : /*      Open the file, and create layer for each vector segment.        */
      99                 : /* -------------------------------------------------------------------- */
     100                 :     try 
     101                 :     {
     102                 :         PCIDSK::PCIDSKSegment *segobj;
     103                 : 
     104               0 :         poFile = PCIDSK::Open( pszFilename, "r", NULL );
     105                 : 
     106               0 :         for( segobj = poFile->GetSegment( PCIDSK::SEG_VEC, "" );
     107                 :              segobj != NULL;
     108                 :              segobj = poFile->GetSegment( PCIDSK::SEG_VEC, "",
     109                 :                                           segobj->GetSegmentNumber() ) )
     110                 :         {
     111               0 :             apoLayers.push_back( new OGRPCIDSKLayer( segobj ) );
     112                 :         }
     113                 :     }
     114                 : 
     115                 : /* -------------------------------------------------------------------- */
     116                 : /*      Trap exceptions and report as CPL errors.                       */
     117                 : /* -------------------------------------------------------------------- */
     118               0 :     catch( PCIDSK::PCIDSKException ex )
     119                 :     {
     120                 :         CPLError( CE_Failure, CPLE_AppDefined, 
     121               0 :                   "%s", ex.what() );
     122               0 :         return FALSE;
     123                 :     }
     124               0 :     catch(...)
     125                 :     {
     126                 :         CPLError( CE_Failure, CPLE_AppDefined, 
     127               0 :                   "Non-PCIDSK exception trapped." );
     128               0 :         return FALSE;
     129                 :     }
     130                 : 
     131                 : /* -------------------------------------------------------------------- */
     132                 : /*      We presume that this is indeed intended to be a PCIDSK             */
     133                 : /*      datasource if over half the files were .csv files.              */
     134                 : /* -------------------------------------------------------------------- */
     135               0 :     return TRUE;
     136                 : }
     137                 : 

Generated by: LTP GCOV extension version 1.5