LCOV - code coverage report
Current view: directory - ogr/ogrsf_frmts/georss - ogr_georss.h (source / functions) Found Hit Coverage
Test: gdal_filtered.info Lines: 7 7 100.0 %
Date: 2010-01-09 Functions: 7 7 100.0 %

       1                 : /******************************************************************************
       2                 :  * $Id $
       3                 :  *
       4                 :  * Project:  GeoRSS Translator
       5                 :  * Purpose:  Definition of classes for OGR GeoRSS driver.
       6                 :  * Author:   Even Rouault, even dot rouault at mines dash paris dot org
       7                 :  *
       8                 :  ******************************************************************************
       9                 :  * Copyright (c) 2008, Even Rouault
      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_GEORSS_H_INCLUDED
      31                 : #define _OGR_GEORSS_H_INCLUDED
      32                 : 
      33                 : #include "ogrsf_frmts.h"
      34                 : #include "ogr_p.h"
      35                 : #include "cpl_hash_set.h"
      36                 : 
      37                 : #ifdef HAVE_EXPAT
      38                 : #include "ogr_expat.h"
      39                 : #endif
      40                 : 
      41                 : class OGRGeoRSSDataSource;
      42                 : 
      43                 : typedef enum
      44                 : {
      45                 :     GEORSS_ATOM,
      46                 :     GEORSS_RSS,
      47                 : } OGRGeoRSSFormat;
      48                 : 
      49                 : typedef enum
      50                 : {
      51                 :     GEORSS_GML,
      52                 :     GEORSS_SIMPLE,
      53                 :     GEORSS_W3C_GEO
      54                 : } OGRGeoRSSGeomDialect;
      55                 : 
      56                 : /************************************************************************/
      57                 : /*                             OGRGeoRSSLayer                              */
      58                 : /************************************************************************/
      59                 : 
      60                 : class OGRGeoRSSLayer : public OGRLayer
      61                 : {
      62                 :     OGRFeatureDefn*    poFeatureDefn;
      63                 :     OGRSpatialReference *poSRS;
      64                 :     OGRGeoRSSDataSource*  poDS;
      65                 :     OGRGeoRSSFormat     eFormat;
      66                 : 
      67                 :     int                bWriteMode;
      68                 :     int                nTotalFeatureCount;
      69                 : 
      70                 :     int                eof;
      71                 :     int                nNextFID;
      72                 :     FILE*              fpGeoRSS; /* Large file API */
      73                 :     int                bHasReadSchema;
      74                 : #ifdef HAVE_EXPAT
      75                 :     XML_Parser         oParser;
      76                 :     XML_Parser         oSchemaParser;
      77                 : #endif
      78                 :     OGRGeometry*       poGlobalGeom;
      79                 :     int                bStopParsing;
      80                 :     int                bInFeature;
      81                 :     int                hasFoundLat;
      82                 :     int                hasFoundLon;
      83                 :     double             latVal;
      84                 :     double             lonVal;
      85                 :     char*              pszSubElementName;
      86                 :     char*              pszSubElementValue;
      87                 :     int                nSubElementValueLen;
      88                 :     int                iCurrentField;
      89                 :     int                bInSimpleGeometry;
      90                 :     int                bInGMLGeometry;
      91                 :     int                bInGeoLat;
      92                 :     int                bInGeoLong;
      93                 :     int                bFoundGeom;
      94                 :     OGRwkbGeometryType eGeomType;
      95                 :     int                bSameSRS;
      96                 :     char*              pszGMLSRSName;
      97                 :     int                bInTagWithSubTag;
      98                 :     char*              pszTagWithSubTag;
      99                 :     int                currentDepth;
     100                 :     int                featureDepth;
     101                 :     int                geometryDepth;
     102                 :     OGRFieldDefn*      currentFieldDefn;
     103                 :     int                nWithoutEventCounter;
     104                 :     CPLHashSet*        setOfFoundFields;
     105                 :     int                nDataHandlerCounter;
     106                 : 
     107                 :     OGRFeature*        poFeature;
     108                 :     OGRFeature **      ppoFeatureTab;
     109                 :     int                nFeatureTabLength;
     110                 :     int                nFeatureTabIndex;
     111                 : 
     112                 :   private:
     113                 : #ifdef HAVE_EXPAT
     114                 :     void               AddStrToSubElementValue(const char* pszStr);
     115                 : #endif
     116                 :     int                IsStandardField(const char* pszName);
     117                 :     
     118                 :   public:
     119                 :                         OGRGeoRSSLayer(const char *pszFilename,
     120                 :                                     const char* layerName,
     121                 :                                     OGRGeoRSSDataSource* poDS,
     122                 :                                     OGRSpatialReference *poSRSIn,
     123                 :                                     int bWriteMode = FALSE);
     124                 :                         ~OGRGeoRSSLayer();
     125                 : 
     126                 :     void                ResetReading();
     127                 :     OGRFeature *        GetNextFeature();
     128                 :     
     129                 :     OGRErr              CreateFeature( OGRFeature *poFeature );
     130                 :     OGRErr              CreateField( OGRFieldDefn *poField, int bApproxOK );
     131                 : 
     132                 :     OGRFeatureDefn *    GetLayerDefn();
     133                 :     
     134                 :     int                 TestCapability( const char * );
     135                 :     
     136                 :     OGRSpatialReference *GetSpatialRef();
     137                 :     
     138                 :     int                 GetFeatureCount( int bForce );
     139                 : 
     140                 :     void                LoadSchema();
     141                 : 
     142                 : #ifdef HAVE_EXPAT
     143                 :     void                startElementCbk(const char *pszName, const char **ppszAttr);
     144                 :     void                endElementCbk(const char *pszName);
     145                 :     void                dataHandlerCbk(const char *data, int nLen);
     146                 : 
     147                 :     void                startElementLoadSchemaCbk(const char *pszName, const char **ppszAttr);
     148                 :     void                endElementLoadSchemaCbk(const char *pszName);
     149                 :     void                dataHandlerLoadSchemaCbk(const char *data, int nLen);
     150                 : #endif
     151                 : };
     152                 : 
     153                 : /************************************************************************/
     154                 : /*                           OGRGeoRSSDataSource                           */
     155                 : /************************************************************************/
     156                 : 
     157                 : typedef enum
     158                 : {
     159                 :     GEORSS_VALIDITY_UNKNOWN,
     160                 :     GEORSS_VALIDITY_INVALID,
     161                 :     GEORSS_VALIDITY_VALID
     162                 : } OGRGeoRSSValidity;
     163                 : 
     164                 : class OGRGeoRSSDataSource : public OGRDataSource
     165                 : {
     166                 :     char*               pszName;
     167                 : 
     168                 :     OGRGeoRSSLayer**    papoLayers;
     169                 :     int                 nLayers;
     170                 : 
     171                 :     /*  Export related */
     172                 :     FILE                *fpOutput; /* Standard file API */
     173                 :     
     174                 :     OGRGeoRSSValidity   validity;
     175                 :     OGRGeoRSSFormat     eFormat;
     176                 :     OGRGeoRSSGeomDialect eGeomDialect;
     177                 :     int                 bUseExtensions;
     178                 :     int                 bWriteHeaderAndFooter;
     179                 : #ifdef HAVE_EXPAT
     180                 :     XML_Parser          oCurrentParser;
     181                 :     int                 nDataHandlerCounter;
     182                 : #endif
     183                 : 
     184                 :   public:
     185                 :                         OGRGeoRSSDataSource();
     186                 :                         ~OGRGeoRSSDataSource();
     187                 : 
     188                 :     int                 Open( const char * pszFilename,
     189                 :                               int bUpdate );
     190                 :     
     191                 :     int                 Create( const char *pszFilename, 
     192                 :                               char **papszOptions );
     193                 :     
     194              20 :     const char*         GetName() { return pszName; }
     195                 : 
     196               2 :     int                 GetLayerCount() { return nLayers; }
     197                 :     OGRLayer*           GetLayer( int );
     198                 :     
     199                 :     OGRLayer *          CreateLayer( const char * pszLayerName,
     200                 :                                     OGRSpatialReference *poSRS,
     201                 :                                     OGRwkbGeometryType eType,
     202                 :                                     char ** papszOptions );
     203                 : 
     204                 :     int                 TestCapability( const char * );
     205                 :     
     206              15 :     FILE *              GetOutputFP() { return fpOutput; }
     207              19 :     OGRGeoRSSFormat     GetFormat() { return eFormat; }
     208              15 :     OGRGeoRSSGeomDialect GetGeomDialect() { return eGeomDialect; }
     209               3 :     int                 GetUseExtensions() { return bUseExtensions; }
     210                 :     
     211                 : #ifdef HAVE_EXPAT
     212                 :     void                startElementValidateCbk(const char *pszName, const char **ppszAttr);
     213                 :     void                dataHandlerValidateCbk(const char *data, int nLen);
     214                 : #endif
     215                 : };
     216                 : 
     217                 : /************************************************************************/
     218                 : /*                             OGRGeoRSSDriver                             */
     219                 : /************************************************************************/
     220                 : 
     221                 : class OGRGeoRSSDriver : public OGRSFDriver
     222              64 : {
     223                 :   public:
     224                 :                 ~OGRGeoRSSDriver();
     225                 : 
     226                 :     const char*         GetName();
     227                 :     OGRDataSource*      Open( const char *, int );
     228                 :     OGRDataSource*      CreateDataSource( const char * pszName, char **papszOptions );
     229                 :     int                 DeleteDataSource( const char *pszFilename );
     230                 :     int                 TestCapability( const char * );
     231                 :     
     232                 : };
     233                 : 
     234                 : 
     235                 : #endif /* ndef _OGR_GeoRSS_H_INCLUDED */

Generated by: LCOV version 1.7