LCOV - code coverage report
Current view: directory - ogr/ogrsf_frmts/pcidsk - ogrpcidskdriver.cpp (source / functions) Found Hit Coverage
Test: gdal_filtered.info Lines: 27 17 63.0 %
Date: 2012-04-28 Functions: 8 5 62.5 %

       1                 : /******************************************************************************
       2                 :  * $Id: ogrcsvdriver.cpp 10645 2007-01-18 02:22:39Z warmerdam $
       3                 :  *
       4                 :  * Project:  PCIDSK Translator
       5                 :  * Purpose:  Implements OGRPCIDSKDriver.
       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                 : 
      33                 : CPL_CVSID("$Id: ogrcsvdriver.cpp 10645 2007-01-18 02:22:39Z warmerdam $");
      34                 : 
      35                 : const PCIDSK::PCIDSKInterfaces *PCIDSK2GetInterfaces(void);
      36                 : 
      37                 : /************************************************************************/
      38                 : /*                          ~OGRPCIDSKDriver()                          */
      39                 : /************************************************************************/
      40                 : 
      41             369 : OGRPCIDSKDriver::~OGRPCIDSKDriver()
      42                 : 
      43                 : {
      44             369 : }
      45                 : 
      46                 : /************************************************************************/
      47                 : /*                              GetName()                               */
      48                 : /************************************************************************/
      49                 : 
      50           23521 : const char *OGRPCIDSKDriver::GetName()
      51                 : 
      52                 : {
      53           23521 :     return "PCIDSK";
      54                 : }
      55                 : 
      56                 : /************************************************************************/
      57                 : /*                                Open()                                */
      58                 : /************************************************************************/
      59                 : 
      60             358 : OGRDataSource *OGRPCIDSKDriver::Open( const char * pszFilename, int bUpdate )
      61                 : 
      62                 : {
      63             358 :     OGRPCIDSKDataSource   *poDS = new OGRPCIDSKDataSource();
      64                 : 
      65             358 :     if( !poDS->Open( pszFilename, bUpdate ) )
      66                 :     {
      67             342 :         delete poDS;
      68             342 :         poDS = NULL;
      69                 :     }
      70                 : 
      71             358 :     return poDS;
      72                 : }
      73                 : 
      74                 : /************************************************************************/
      75                 : /*                          CreateDataSource()                          */
      76                 : /************************************************************************/
      77                 : 
      78               4 : OGRDataSource *OGRPCIDSKDriver::CreateDataSource( const char * pszName,
      79                 :                                                   char **papszOptions )
      80                 : 
      81                 : {
      82                 : /* -------------------------------------------------------------------- */
      83                 : /*      Try creation.                                                   */
      84                 : /* -------------------------------------------------------------------- */
      85                 :     try {
      86                 :         PCIDSK::PCIDSKFile *poFile;
      87                 : 
      88                 :         // at some point we should use gdal/frmts/pcidsk io interface.
      89                 :         poFile = PCIDSK::Create( pszName, 512, 512, 0, NULL, "BAND", 
      90               4 :                                  PCIDSK2GetInterfaces() );
      91               8 :         delete poFile;
      92                 : 
      93                 :         // TODO: should we ensure this driver gets used?
      94                 : 
      95               4 :         return Open( pszName, TRUE );
      96                 :     }
      97                 : /* -------------------------------------------------------------------- */
      98                 : /*      Trap exceptions.                                                */
      99                 : /* -------------------------------------------------------------------- */
     100               0 :     catch( PCIDSK::PCIDSKException ex )
     101                 :     {
     102                 :         CPLError( CE_Failure, CPLE_AppDefined,
     103               0 :                   "%s", ex.what() );
     104               0 :         return NULL;
     105                 :     }
     106               0 :     catch( ... )
     107                 :     {
     108                 :         CPLError( CE_Failure, CPLE_AppDefined,
     109               0 :                   "PCIDSK::Create() failed, unexpected exception." );
     110               0 :         return NULL;
     111                 :     }
     112                 : }
     113                 : 
     114                 : /************************************************************************/
     115                 : /*                           TestCapability()                           */
     116                 : /************************************************************************/
     117                 : 
     118               0 : int OGRPCIDSKDriver::TestCapability( const char * pszCap )
     119                 : 
     120                 : {
     121               0 :     if( EQUAL(pszCap,ODrCCreateDataSource) )
     122               0 :         return TRUE;
     123                 :     else
     124               0 :         return FALSE;
     125                 : }
     126                 : 
     127                 : /************************************************************************/
     128                 : /*                         RegisterOGRPCIDSK()                          */
     129                 : /************************************************************************/
     130                 : 
     131             389 : void RegisterOGRPCIDSK()
     132                 : 
     133                 : {
     134             389 :     OGRSFDriverRegistrar::GetRegistrar()->RegisterDriver( new OGRPCIDSKDriver );
     135             389 : }
     136                 : 

Generated by: LCOV version 1.7