LCOV - code coverage report
Current view: directory - ogr/ogrsf_frmts/pdf - ogr_pdf.h (source / functions) Found Hit Coverage
Test: gdal_filtered.info Lines: 4 4 100.0 %
Date: 2012-12-26 Functions: 5 4 80.0 %

       1                 : /******************************************************************************
       2                 :  * $Id: ogr_pdf.h 25325 2012-12-16 21:25:25Z rouault $
       3                 :  *
       4                 :  * Project:  PDF Translator
       5                 :  * Purpose:  Definition of classes for OGR .pdf driver.
       6                 :  * Author:   Even Rouault, even dot rouault at mines dash paris dot org
       7                 :  *
       8                 :  ******************************************************************************
       9                 :  * Copyright (c) 2012, Even Rouault <even dot rouault at mines dash paris dot org>
      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                 : #ifndef _OGR_PDF_H_INCLUDED
      31                 : #define _OGR_PDF_H_INCLUDED
      32                 : 
      33                 : #include "ogrsf_frmts.h"
      34                 : 
      35                 : #include "ogr_mem.h"
      36                 : #include "gdal_priv.h"
      37                 : #include "pdfobject.h"
      38                 : 
      39                 : #include <map>
      40                 : #include <stack>
      41                 : 
      42                 : /************************************************************************/
      43                 : /*                             OGRPDFLayer                              */
      44                 : /************************************************************************/
      45                 : 
      46                 : class OGRPDFDataSource;
      47                 : 
      48                 : class OGRPDFLayer : public OGRMemLayer
      49              20 : {
      50                 :     OGRPDFDataSource* poDS;
      51                 :     int               bGeomTypeSet;
      52                 :     int               bGeomTypeMixed;
      53                 : 
      54                 : public:
      55                 :         OGRPDFLayer(OGRPDFDataSource* poDS,
      56                 :                     const char * pszName,
      57                 :                     OGRSpatialReference *poSRS,
      58                 :                     OGRwkbGeometryType eGeomType);
      59                 : 
      60                 :     void                Fill( GDALPDFArray* poArray );
      61                 : 
      62                 :     virtual int                 TestCapability( const char * );
      63                 :     virtual OGRErr              CreateFeature( OGRFeature *poFeature );
      64                 : };
      65                 : 
      66                 : /************************************************************************/
      67                 : /*                           OGRPDFDataSource                           */
      68                 : /************************************************************************/
      69                 : 
      70                 : #define MAX_TOKEN_SIZE 256
      71                 : #define TOKEN_STACK_SIZE 8
      72                 : 
      73                 : class OGRPDFDataSource : public OGRDataSource
      74                 : {
      75                 :     char*               pszName;
      76                 :     char**              papszOptions;
      77                 : 
      78                 :     int                 nLayers;
      79                 :     OGRLayer          **papoLayers;
      80                 : 
      81                 :     int                 bWritable;
      82                 :     int                 bModified;
      83                 : 
      84                 :     GDALDataset        *poGDAL_DS;
      85                 :     GDALPDFObject      *poPageObj;
      86                 :     GDALPDFObject      *poCatalogObj;
      87                 :     int                 nXSize;
      88                 :     int                 nYSize;
      89                 :     double              adfGeoTransform[6];
      90                 :     double              dfPageWidth;
      91                 :     double              dfPageHeight;
      92                 :     void                PDFCoordsToSRSCoords(double x, double y,
      93                 :                                              double& X, double &Y);
      94                 : 
      95                 :     std::map<int,OGRGeometry*> oMapMCID;
      96                 :     void                CleanupIntermediateResources();
      97                 : 
      98                 :     std::map<CPLString, int> oMapOperators;
      99                 :     void                InitMapOperators();
     100                 :     
     101                 :     int                 bSetStyle;
     102                 : 
     103                 :     void                ExploreTree(GDALPDFObject* poObj, int nRecLevel);
     104                 :     void                ExploreContents(GDALPDFObject* poObj, GDALPDFObject* poResources);
     105                 : 
     106                 :     void                ExploreContentsNonStructuredInternal(GDALPDFObject* poContents,
     107                 :                                                              GDALPDFObject* poResources,
     108                 :                                                              std::map<CPLString, OGRPDFLayer*>& oMapPropertyToLayer);
     109                 :     void                ExploreContentsNonStructured(GDALPDFObject* poObj, GDALPDFObject* poResources);
     110                 : 
     111                 :     int                 UnstackTokens(const char* pszToken,
     112                 :                                       int nRequiredArgs,
     113                 :                                       char aszTokenStack[TOKEN_STACK_SIZE][MAX_TOKEN_SIZE],
     114                 :                                       int& nTokenStackSize,
     115                 :                                       double* adfCoords);
     116                 :     OGRGeometry*        ParseContent(const char* pszContent,
     117                 :                                      GDALPDFObject* poResources,
     118                 :                                      int bInitBDCStack,
     119                 :                                      int bMatchQ,
     120                 :                                      std::map<CPLString, OGRPDFLayer*>& oMapPropertyToLayer,
     121                 :                                      OGRPDFLayer* poCurLayer);
     122                 :     OGRGeometry*        BuildGeometry(std::vector<double>& oCoords,
     123                 :                                       int bHasFoundFill,
     124                 :                                       int bHasMultiPart);
     125                 : 
     126                 :   public:
     127                 :                         OGRPDFDataSource();
     128                 :                         ~OGRPDFDataSource();
     129                 : 
     130                 :     int                 Open( const char * pszName );
     131                 :     int                 Create( const char * pszName, char **papszOptions );
     132                 : 
     133               8 :     virtual const char*         GetName() { return pszName; }
     134                 : 
     135                 :     virtual int                 GetLayerCount();
     136                 :     virtual OGRLayer*           GetLayer( int );
     137                 : 
     138                 :     virtual int                 TestCapability( const char * );
     139                 : 
     140                 :     virtual OGRLayer* CreateLayer( const char * pszLayerName,
     141                 :                                 OGRSpatialReference *poSRS,
     142                 :                                 OGRwkbGeometryType eType,
     143                 :                                 char ** papszOptions );
     144                 : 
     145                 :     virtual OGRErr      SyncToDisk();
     146                 : 
     147             451 :     void                SetModified() { bModified = TRUE; }
     148                 :     OGRGeometry        *GetGeometryFromMCID(int nMCID);
     149                 : };
     150                 : 
     151                 : /************************************************************************/
     152                 : /*                             OGRPDFDriver                              */
     153                 : /************************************************************************/
     154                 : 
     155                 : class OGRPDFDriver : public OGRSFDriver
     156             226 : {
     157                 :   public:
     158                 :                 ~OGRPDFDriver();
     159                 : 
     160                 :     virtual const char*         GetName();
     161                 :     virtual OGRDataSource*      Open( const char *, int );
     162                 :     virtual int                 TestCapability( const char * );
     163                 : 
     164                 :     virtual OGRDataSource *CreateDataSource( const char *pszName,
     165                 :                                              char ** = NULL );
     166                 :     virtual OGRErr DeleteDataSource( const char *pszName );
     167                 : };
     168                 : 
     169                 : 
     170                 : #endif /* ndef _OGR_PDF_H_INCLUDED */

Generated by: LCOV version 1.7