LCOV - code coverage report
Current view: directory - ogr/ogrsf_frmts/kml - ogrkmldriver.cpp (source / functions) Found Hit Coverage
Test: gdal_filtered.info Lines: 29 23 79.3 %
Date: 2012-04-28 Functions: 11 7 63.6 %

       1                 : /******************************************************************************
       2                 :  * $Id: ogrkmldriver.cpp 23978 2012-02-14 20:42:34Z rouault $
       3                 :  *
       4                 :  * Project:  KML Driver
       5                 :  * Purpose:  Implementation of OGRKMLDriver class.
       6                 :  * Author:   Christopher Condit, condit@sdsc.edu;
       7                 :  *           Jens Oberender, j.obi@troja.net
       8                 :  *
       9                 :  ******************************************************************************
      10                 :  * Copyright (c) 2006, Christopher Condit
      11                 :  *               2007, Jens Oberender
      12                 :  *
      13                 :  * Permission is hereby granted, free of charge, to any person obtaining a
      14                 :  * copy of this software and associated documentation files (the "Software"),
      15                 :  * to deal in the Software without restriction, including without limitation
      16                 :  * the rights to use, copy, modify, merge, publish, distribute, sublicense,
      17                 :  * and/or sell copies of the Software, and to permit persons to whom the
      18                 :  * Software is furnished to do so, subject to the following conditions:
      19                 :  *
      20                 :  * The above copyright notice and this permission notice shall be included
      21                 :  * in all copies or substantial portions of the Software.
      22                 :  *
      23                 :  * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
      24                 :  * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
      25                 :  * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
      26                 :  * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
      27                 :  * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
      28                 :  * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
      29                 :  * DEALINGS IN THE SOFTWARE.
      30                 :  ****************************************************************************/
      31                 : #include "ogr_kml.h"
      32                 : #include "cpl_conv.h"
      33                 : #include "cpl_error.h"
      34                 : 
      35                 : /************************************************************************/
      36                 : /*                          ~OGRKMLDriver()                           */
      37                 : /************************************************************************/
      38                 : 
      39             369 : OGRKMLDriver::~OGRKMLDriver()
      40                 : {
      41             369 : }
      42                 : 
      43                 : /************************************************************************/
      44                 : /*                              GetName()                               */
      45                 : /************************************************************************/
      46                 : 
      47           23531 : const char *OGRKMLDriver::GetName()
      48                 : {
      49           23531 :     return "KML";
      50                 : }
      51                 : 
      52                 : /************************************************************************/
      53                 : /*                                Open()                                */
      54                 : /************************************************************************/
      55                 : 
      56             236 : OGRDataSource *OGRKMLDriver::Open( const char * pszName, int bUpdate )
      57                 : {
      58             236 :     CPLAssert( NULL != pszName );
      59                 : 
      60             236 :     OGRKMLDataSource* poDS = NULL;
      61                 : 
      62                 : #ifdef HAVE_EXPAT
      63             236 :     if( bUpdate )
      64              72 :         return NULL;
      65                 : 
      66             164 :     poDS = new OGRKMLDataSource();
      67                 : 
      68             164 :     if( poDS->Open( pszName, TRUE ) )
      69                 :     {
      70                 :         /*if( poDS->GetLayerCount() == 0 )
      71                 :         {
      72                 :             CPLError( CE_Failure, CPLE_OpenFailed, 
      73                 :                 "No layers in KML file: %s.", pszName );
      74                 : 
      75                 :             delete poDS;
      76                 :             poDS = NULL;
      77                 :         }*/
      78                 :     }
      79                 :     else
      80                 :     {
      81             146 :         delete poDS;
      82             146 :         poDS = NULL;
      83                 :     }
      84                 : #endif
      85                 : 
      86             164 :     return poDS;
      87                 : }
      88                 : 
      89                 : /************************************************************************/
      90                 : /*                          CreateDataSource()                          */
      91                 : /************************************************************************/
      92                 : 
      93               4 : OGRDataSource *OGRKMLDriver::CreateDataSource( const char* pszName,
      94                 :                                                char** papszOptions )
      95                 : {
      96               4 :     CPLAssert( NULL != pszName );
      97               4 :     CPLDebug( "KML", "Attempt to create: %s", pszName );
      98                 :     
      99               4 :     OGRKMLDataSource *poDS = new OGRKMLDataSource();
     100                 : 
     101               4 :     if( !poDS->Create( pszName, papszOptions ) )
     102                 :     {
     103               0 :         delete poDS;
     104               0 :         poDS = NULL;
     105                 :     }
     106                 : 
     107               4 :     return poDS;
     108                 : }
     109                 : 
     110                 : /************************************************************************/
     111                 : /*                           TestCapability()                           */
     112                 : /************************************************************************/
     113                 : 
     114               0 : int OGRKMLDriver::TestCapability( const char* pszCap )
     115                 : {
     116               0 :     if( EQUAL(pszCap, ODrCCreateDataSource) )
     117               0 :         return TRUE;
     118                 :     else
     119               0 :         return FALSE;
     120                 : }
     121                 : 
     122                 : /************************************************************************/
     123                 : /*                           RegisterOGRKML()                           */
     124                 : /************************************************************************/
     125                 : 
     126             389 : void RegisterOGRKML()
     127                 : {
     128             389 :     OGRSFDriverRegistrar::GetRegistrar()->RegisterDriver( new OGRKMLDriver );
     129            4418 : }
     130                 : 
     131                 : 

Generated by: LCOV version 1.7