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

Generated by: LCOV version 1.7