LCOV - code coverage report
Current view: top level - ogr/ogrsf_frmts/kml - ogr_kml.h (source / functions) Hit Total Coverage
Test: gdal_filtered.info Lines: 15 22 68.2 %
Date: 2024-04-27 17:22:41 Functions: 7 10 70.0 %

          Line data    Source code
       1             : /******************************************************************************
       2             :  * $Id$
       3             :  *
       4             :  * Project:  KML Driver
       5             :  * Purpose:  Declarations for OGR wrapper classes for KML, and OGR->KML
       6             :  *           translation of geometry.
       7             :  * Author:   Christopher Condit, condit@sdsc.edu;
       8             :  *           Jens Oberender, j.obi@troja.net
       9             :  *
      10             :  ******************************************************************************
      11             :  * Copyright (c) 2006, Christopher Condit
      12             :  *               2007, Jens Oberender
      13             :  * Copyright (c) 2007-2014, Even Rouault <even dot rouault at spatialys.com>
      14             :  *
      15             :  * Permission is hereby granted, free of charge, to any person obtaining a
      16             :  * copy of this software and associated documentation files (the "Software"),
      17             :  * to deal in the Software without restriction, including without limitation
      18             :  * the rights to use, copy, modify, merge, publish, distribute, sublicense,
      19             :  * and/or sell copies of the Software, and to permit persons to whom the
      20             :  * Software is furnished to do so, subject to the following conditions:
      21             :  *
      22             :  * The above copyright notice and this permission notice shall be included
      23             :  * in all copies or substantial portions of the Software.
      24             :  *
      25             :  * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
      26             :  * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
      27             :  * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
      28             :  * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
      29             :  * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
      30             :  * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
      31             :  * DEALINGS IN THE SOFTWARE.
      32             :  ****************************************************************************/
      33             : #ifndef OGR_KML_H_INCLUDED
      34             : #define OGR_KML_H_INCLUDED
      35             : 
      36             : #include "ogrsf_frmts.h"
      37             : 
      38             : #ifdef HAVE_EXPAT
      39             : #include "kmlvector.h"
      40             : #endif
      41             : 
      42             : class OGRKMLDataSource;
      43             : 
      44             : /************************************************************************/
      45             : /*                            OGRKMLLayer                               */
      46             : /************************************************************************/
      47             : 
      48             : class OGRKMLLayer final : public OGRLayer
      49             : {
      50             :   public:
      51             :     OGRKMLLayer(const char *pszName_, const OGRSpatialReference *poSRS,
      52             :                 bool bWriter, OGRwkbGeometryType eType, OGRKMLDataSource *poDS);
      53             :     ~OGRKMLLayer();
      54             : 
      55             :     //
      56             :     // OGRLayer Interface
      57             :     //
      58             :     OGRFeatureDefn *GetLayerDefn() override;
      59             :     OGRErr ICreateFeature(OGRFeature *poFeature) override;
      60             :     OGRErr CreateField(const OGRFieldDefn *poField,
      61             :                        int bApproxOK = TRUE) override;
      62             :     void ResetReading() override;
      63             :     OGRFeature *GetNextFeature() override;
      64             :     GIntBig GetFeatureCount(int bForce = TRUE) override;
      65             :     int TestCapability(const char *pszCap) override;
      66             : 
      67             :     GDALDataset *GetDataset() override;
      68             : 
      69             :     //
      70             :     // OGRKMLLayer Interface
      71             :     //
      72             :     void SetLayerNumber(int nLayer);
      73             : 
      74          19 :     void SetClosedForWriting()
      75             :     {
      76          19 :         bClosedForWriting = true;
      77          19 :     }
      78             : 
      79             :     CPLString WriteSchema();
      80             : 
      81             :   private:
      82             :     friend class OGRKMLDataSource;
      83             : 
      84             :     OGRKMLDataSource *poDS_;
      85             :     OGRSpatialReference *poSRS_;
      86             :     OGRCoordinateTransformation *poCT_;
      87             : 
      88             :     OGRFeatureDefn *poFeatureDefn_;
      89             : 
      90             :     int iNextKMLId_;
      91             :     bool bWriter_;
      92             :     int nLayerNumber_;
      93             :     int nWroteFeatureCount_;
      94             :     bool bSchemaWritten_;
      95             :     bool bClosedForWriting;
      96             :     char *pszName_;
      97             : 
      98             :     int nLastAsked;
      99             :     int nLastCount;
     100             : };
     101             : 
     102             : /************************************************************************/
     103             : /*                           OGRKMLDataSource                           */
     104             : /************************************************************************/
     105             : 
     106             : class OGRKMLDataSource final : public OGRDataSource
     107             : {
     108             :   public:
     109             :     OGRKMLDataSource();
     110             :     ~OGRKMLDataSource();
     111             : 
     112             :     //
     113             :     // OGRDataSource Interface
     114             :     //
     115             :     int Open(const char *pszName, int bTestOpen);
     116             : 
     117           0 :     const char *GetName() override
     118             :     {
     119           0 :         return pszName_;
     120             :     }
     121             : 
     122        1243 :     int GetLayerCount() override
     123             :     {
     124        1243 :         return nLayers_;
     125             :     }
     126             : 
     127             :     OGRLayer *GetLayer(int nLayer) override;
     128             :     OGRLayer *ICreateLayer(const char *pszName,
     129             :                            const OGRGeomFieldDefn *poGeomFieldDefn,
     130             :                            CSLConstList papszOptions) override;
     131             :     int TestCapability(const char *pszCap) override;
     132             : 
     133             :     //
     134             :     // OGRKMLDataSource Interface
     135             :     //
     136             :     int Create(const char *pszName, char **papszOptions);
     137             : 
     138        1581 :     const char *GetNameField() const
     139             :     {
     140        1581 :         return pszNameField_;
     141             :     }
     142             : 
     143        1497 :     const char *GetDescriptionField() const
     144             :     {
     145        1497 :         return pszDescriptionField_;
     146             :     }
     147             : 
     148          90 :     const char *GetAltitudeMode()
     149             :     {
     150          90 :         return pszAltitudeMode_;
     151             :     }
     152             : 
     153         128 :     VSILFILE *GetOutputFP()
     154             :     {
     155         128 :         return fpOutput_;
     156             :     }
     157             : 
     158             :     void GrowExtents(OGREnvelope *psGeomBounds);
     159             : #ifdef HAVE_EXPAT
     160         810 :     KML *GetKMLFile()
     161             :     {
     162         810 :         return poKMLFile_;
     163             :     }
     164             : #endif
     165             : 
     166           0 :     bool IsFirstCTError() const
     167             :     {
     168           0 :         return !bIssuedCTError_;
     169             :     }
     170             : 
     171           0 :     void IssuedFirstCTError()
     172             :     {
     173           0 :         bIssuedCTError_ = true;
     174           0 :     }
     175             : 
     176             :   private:
     177             : #ifdef HAVE_EXPAT
     178             :     KML *poKMLFile_;
     179             : #endif
     180             : 
     181             :     char *pszName_;
     182             : 
     183             :     OGRKMLLayer **papoLayers_;
     184             :     int nLayers_;
     185             : 
     186             :     // The name of the field to use for the KML name element.
     187             :     char *pszNameField_;
     188             :     char *pszDescriptionField_;
     189             : 
     190             :     // The KML altitude mode to use.
     191             :     char *pszAltitudeMode_;
     192             : 
     193             :     char **papszCreateOptions_;
     194             : 
     195             :     // Output related parameters.
     196             :     VSILFILE *fpOutput_;
     197             : 
     198             :     OGREnvelope oEnvelope_;
     199             : 
     200             :     // Have we issued a coordinate transformation already for this datasource.
     201             :     bool bIssuedCTError_;
     202             : };
     203             : 
     204             : #endif /* OGR_KML_H_INCLUDED */

Generated by: LCOV version 1.14