LCOV - code coverage report
Current view: directory - ogr/ogrsf_frmts/libkml - ogrlibkmlfeature.cpp (source / functions) Found Hit Coverage
Test: gdal_filtered.info Lines: 16 16 100.0 %
Date: 2012-04-28 Functions: 2 2 100.0 %

       1                 : /******************************************************************************
       2                 :  *
       3                 :  * Project:  KML Translator
       4                 :  * Purpose:  Implements OGRLIBKMLDriver
       5                 :  * Author:   Brian Case, rush at winkey dot org
       6                 :  *
       7                 :  ******************************************************************************
       8                 :  * Copyright (c) 2010, Brian Case
       9                 :  *
      10                 :  * Permission is hereby granted, free of charge, to any person obtaining a
      11                 :  * copy of this software and associated documentation files (the "Software"),
      12                 :  * to deal in the Software without restriction, including without limitation
      13                 :  * the rights to use, copy, modify, merge, publish, distribute, sublicense,
      14                 :  * and/or sell copies of the Software, and to permit persons to whom the
      15                 :  * Software is furnished to do so, subject to the following conditions:
      16                 :  *
      17                 :  * The above copyright notice and this permission notice shall be included
      18                 :  * in all copies or substantial portions of the Software.
      19                 :  *
      20                 :  * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
      21                 :  * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
      22                 :  * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
      23                 :  * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
      24                 :  * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
      25                 :  * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
      26                 :  * DEALINGS IN THE SOFTWARE.
      27                 :  *****************************************************************************/
      28                 : 
      29                 : #include <ogrsf_frmts.h>
      30                 : #include <ogr_geometry.h>
      31                 : 
      32                 : #include <kml/dom.h>
      33                 : 
      34                 : using kmldom::KmlFactory;
      35                 : using kmldom::PlacemarkPtr;
      36                 : using kmldom::ElementPtr;
      37                 : using kmldom::GeometryPtr;
      38                 : using kmldom::Geometry;
      39                 : 
      40                 : #include "ogr_libkml.h"
      41                 : 
      42                 : #include "ogrlibkmlgeometry.h"
      43                 : #include "ogrlibkmlfield.h"
      44                 : #include "ogrlibkmlfeaturestyle.h"
      45                 : 
      46              54 : PlacemarkPtr feat2kml (
      47                 :     OGRLIBKMLDataSource * poOgrDS,
      48                 :     OGRLayer * poOgrLayer,
      49                 :     OGRFeature * poOgrFeat,
      50                 :     KmlFactory * poKmlFactory )
      51                 : {
      52                 : 
      53              54 :     PlacemarkPtr poKmlPlacemark = poKmlFactory->CreatePlacemark (  );
      54                 : 
      55                 :     /***** style *****/
      56                 : 
      57                 :     featurestyle2kml ( poOgrDS, poOgrLayer, poOgrFeat, poKmlFactory,
      58              54 :                        poKmlPlacemark );
      59                 : 
      60                 :     /***** geometry *****/
      61                 : 
      62              54 :     OGRGeometry *poOgrGeom = poOgrFeat->GetGeometryRef (  );
      63              54 :     ElementPtr poKmlElement = geom2kml ( poOgrGeom, -1, 0, poKmlFactory );
      64                 : 
      65              54 :     poKmlPlacemark->set_geometry ( AsGeometry ( poKmlElement ) );
      66                 : 
      67                 :     /***** fields *****/
      68                 : 
      69                 :     field2kml ( poOgrFeat, ( OGRLIBKMLLayer * ) poOgrLayer, poKmlFactory,
      70              54 :                 poKmlPlacemark );
      71                 : 
      72                 : 
      73                 : 
      74              54 :     return poKmlPlacemark;
      75                 : }
      76                 : 
      77             552 : OGRFeature *kml2feat (
      78                 :     PlacemarkPtr poKmlPlacemark,
      79                 :     OGRLIBKMLDataSource * poOgrDS,
      80                 :     OGRLayer * poOgrLayer,
      81                 :     OGRFeatureDefn * poOgrFeatDefn,
      82                 :     OGRSpatialReference *poOgrSRS)
      83                 : {
      84                 : 
      85             552 :     OGRFeature *poOgrFeat = new OGRFeature ( poOgrFeatDefn );
      86                 : 
      87                 :     /***** style *****/
      88                 : 
      89            1104 :     kml2featurestyle ( poKmlPlacemark, poOgrDS, poOgrLayer, poOgrFeat );
      90                 : 
      91                 :     /***** geometry *****/
      92                 : 
      93             552 :     if ( poKmlPlacemark->has_geometry (  ) ) {
      94                 :         OGRGeometry *poOgrGeom =
      95             534 :             kml2geom ( poKmlPlacemark->get_geometry (  ), poOgrSRS );
      96             534 :         poOgrFeat->SetGeometryDirectly ( poOgrGeom );
      97                 : 
      98                 :     }
      99                 : 
     100                 :     /***** fields *****/
     101                 : 
     102             552 :     kml2field ( poOgrFeat, poKmlPlacemark );
     103                 : 
     104             552 :     return poOgrFeat;
     105                 : }

Generated by: LCOV version 1.7