LCOV - code coverage report
Current view: directory - ogr/ogrsf_frmts/libkml - ogrlibkmlfeature.cpp (source / functions) Found Hit Coverage
Test: gdal_filtered.info Lines: 26 23 88.5 %
Date: 2012-12-26 Functions: 3 3 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                 : using kmldom::GroundOverlayPtr;
      40                 : 
      41                 : #include "ogr_libkml.h"
      42                 : 
      43                 : #include "ogrlibkmlgeometry.h"
      44                 : #include "ogrlibkmlfield.h"
      45                 : #include "ogrlibkmlfeaturestyle.h"
      46                 : 
      47              27 : PlacemarkPtr feat2kml (
      48                 :     OGRLIBKMLDataSource * poOgrDS,
      49                 :     OGRLayer * poOgrLayer,
      50                 :     OGRFeature * poOgrFeat,
      51                 :     KmlFactory * poKmlFactory )
      52                 : {
      53                 : 
      54              27 :     PlacemarkPtr poKmlPlacemark = poKmlFactory->CreatePlacemark (  );
      55                 : 
      56                 :     /***** style *****/
      57                 : 
      58                 :     featurestyle2kml ( poOgrDS, poOgrLayer, poOgrFeat, poKmlFactory,
      59              27 :                        poKmlPlacemark );
      60                 : 
      61                 :     /***** geometry *****/
      62                 : 
      63              27 :     OGRGeometry *poOgrGeom = poOgrFeat->GetGeometryRef (  );
      64              27 :     ElementPtr poKmlElement = geom2kml ( poOgrGeom, -1, 0, poKmlFactory );
      65                 : 
      66              27 :     poKmlPlacemark->set_geometry ( AsGeometry ( poKmlElement ) );
      67                 : 
      68                 :     /***** fields *****/
      69                 : 
      70                 :     field2kml ( poOgrFeat, ( OGRLIBKMLLayer * ) poOgrLayer, poKmlFactory,
      71              27 :                 poKmlPlacemark );
      72                 : 
      73                 : 
      74                 : 
      75              27 :     return poKmlPlacemark;
      76                 : }
      77                 : 
      78             358 : OGRFeature *kml2feat (
      79                 :     PlacemarkPtr poKmlPlacemark,
      80                 :     OGRLIBKMLDataSource * poOgrDS,
      81                 :     OGRLayer * poOgrLayer,
      82                 :     OGRFeatureDefn * poOgrFeatDefn,
      83                 :     OGRSpatialReference *poOgrSRS)
      84                 : {
      85                 : 
      86             358 :     OGRFeature *poOgrFeat = new OGRFeature ( poOgrFeatDefn );
      87                 : 
      88                 :     /***** style *****/
      89                 : 
      90             716 :     kml2featurestyle ( poKmlPlacemark, poOgrDS, poOgrLayer, poOgrFeat );
      91                 : 
      92                 :     /***** geometry *****/
      93                 : 
      94             358 :     if ( poKmlPlacemark->has_geometry (  ) ) {
      95                 :         OGRGeometry *poOgrGeom =
      96             343 :             kml2geom ( poKmlPlacemark->get_geometry (  ), poOgrSRS );
      97             343 :         poOgrFeat->SetGeometryDirectly ( poOgrGeom );
      98                 : 
      99                 :     }
     100                 : 
     101                 :     /***** fields *****/
     102                 : 
     103             358 :     kml2field ( poOgrFeat, AsFeature ( poKmlPlacemark ) );
     104                 : 
     105             358 :     return poOgrFeat;
     106                 : }
     107                 : 
     108              18 : OGRFeature *kmlgroundoverlay2feat (
     109                 :     GroundOverlayPtr poKmlOverlay,
     110                 :     OGRLIBKMLDataSource * poOgrDS,
     111                 :     OGRLayer * poOgrLayer,
     112                 :     OGRFeatureDefn * poOgrFeatDefn,
     113                 :     OGRSpatialReference *poOgrSRS)
     114                 : {
     115                 : 
     116              18 :     OGRFeature *poOgrFeat = new OGRFeature ( poOgrFeatDefn );
     117                 : 
     118                 :     /***** style *****/
     119                 : 
     120                 :     //kml2featurestyle ( poKmlPlacemark, poOgrDS, poOgrLayer, poOgrFeat );
     121                 : 
     122                 :     /***** geometry *****/
     123                 : 
     124              18 :     if ( poKmlOverlay->has_latlonbox (  ) ) {
     125                 :         OGRGeometry *poOgrGeom =
     126              18 :             kml2geom_latlonbox ( poKmlOverlay->get_latlonbox (  ), poOgrSRS );
     127              18 :         poOgrFeat->SetGeometryDirectly ( poOgrGeom );
     128                 : 
     129                 :     }
     130               0 :     else if ( poKmlOverlay->has_gx_latlonquad (  ) ) {
     131                 :         OGRGeometry *poOgrGeom =
     132               0 :             kml2geom_latlonquad ( poKmlOverlay->get_gx_latlonquad (  ), poOgrSRS );
     133               0 :         poOgrFeat->SetGeometryDirectly ( poOgrGeom );
     134                 : 
     135                 :     }
     136                 : 
     137                 :     /***** fields *****/
     138                 : 
     139              18 :     kml2field ( poOgrFeat, AsFeature ( poKmlOverlay ) );
     140                 : 
     141              18 :     return poOgrFeat;
     142                 : }

Generated by: LCOV version 1.7