LCOV - code coverage report
Current view: directory - ogr/ogrsf_frmts/geojson - ogr_geojson.h (source / functions) Found Hit Coverage
Test: gdal_filtered.info Lines: 3 3 100.0 %
Date: 2011-12-18 Functions: 3 3 100.0 %

       1                 : /******************************************************************************
       2                 :  * $Id: ogr_geojson.h 23367 2011-11-12 22:46:13Z rouault $
       3                 :  *
       4                 :  * Project:  OpenGIS Simple Features Reference Implementation
       5                 :  * Purpose:  Definitions of OGR OGRGeoJSON driver types.
       6                 :  * Author:   Mateusz Loskot, mateusz@loskot.net
       7                 :  *
       8                 :  ******************************************************************************
       9                 :  * Copyright (c) 2007, Mateusz Loskot
      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                 : #ifndef OGR_GEOJSON_H_INCLUDED
      30                 : #define OGR_GEOJSON_H_INCLUDED
      31                 : 
      32                 : #include <ogrsf_frmts.h>
      33                 : #include <cstdio>
      34                 : #include <vector> // used by OGRGeoJSONLayer
      35                 : 
      36                 : #define SPACE_FOR_BBOX  80
      37                 : 
      38                 : class OGRGeoJSONDataSource;
      39                 : 
      40                 : /************************************************************************/
      41                 : /*                           OGRGeoJSONLayer                            */
      42                 : /************************************************************************/
      43                 : 
      44                 : class OGRGeoJSONLayer : public OGRLayer
      45                 : {
      46                 : public:
      47                 : 
      48                 :     static const char* const DefaultName;
      49                 :     static const char* const DefaultFIDColumn;
      50                 :     static const OGRwkbGeometryType DefaultGeometryType;
      51                 :  
      52                 :     OGRGeoJSONLayer( const char* pszName,
      53                 :                      OGRSpatialReference* poSRS,
      54                 :                      OGRwkbGeometryType eGType,
      55                 :                      char** papszOptions,
      56                 :                      OGRGeoJSONDataSource* poDS );
      57                 :     ~OGRGeoJSONLayer();
      58                 : 
      59                 :     //
      60                 :     // OGRLayer Interface
      61                 :     //
      62                 :     OGRFeatureDefn* GetLayerDefn();
      63                 :     OGRSpatialReference* GetSpatialRef();
      64                 :     
      65                 :     int GetFeatureCount( int bForce = TRUE );
      66                 :     void ResetReading();
      67                 :     OGRFeature* GetNextFeature();
      68                 :     OGRFeature* GetFeature( long nFID );
      69                 :     OGRErr CreateFeature( OGRFeature* poFeature );
      70                 :     OGRErr CreateField(OGRFieldDefn* poField, int bApproxOK);
      71                 :     int TestCapability( const char* pszCap );
      72                 :     const char* GetFIDColumn();
      73                 :     void SetFIDColumn( const char* pszFIDColumn );
      74                 :     
      75                 :     //
      76                 :     // OGRGeoJSONLayer Interface
      77                 :     //
      78                 :     void AddFeature( OGRFeature* poFeature );
      79                 :     void SetSpatialRef( OGRSpatialReference* poSRS );
      80                 :     void DetectGeometryType();
      81                 : 
      82                 : private:
      83                 : 
      84                 :     typedef std::vector<OGRFeature*> FeaturesSeq;
      85                 :     FeaturesSeq seqFeatures_;
      86                 :     FeaturesSeq::iterator iterCurrent_;
      87                 : 
      88                 :     OGRGeoJSONDataSource* poDS_;
      89                 :     OGRFeatureDefn* poFeatureDefn_;
      90                 :     OGRSpatialReference* poSRS_;
      91                 :     CPLString sFIDColumn_;
      92                 :     int nOutCounter_;
      93                 : 
      94                 :     int bWriteBBOX;
      95                 :     int bBBOX3D;
      96                 :     OGREnvelope3D sEnvelopeLayer;
      97                 : 
      98                 :     int nCoordPrecision;
      99                 : };
     100                 : 
     101                 : /************************************************************************/
     102                 : /*                           OGRGeoJSONDataSource                       */
     103                 : /************************************************************************/
     104                 : 
     105                 : class OGRGeoJSONDataSource : public OGRDataSource
     106                 : {
     107                 : public:
     108                 : 
     109                 :     OGRGeoJSONDataSource();
     110                 :     ~OGRGeoJSONDataSource();
     111                 : 
     112                 :     //
     113                 :     // OGRDataSource Interface
     114                 :     //
     115                 :     int Open( const char* pszSource );
     116                 :     const char* GetName();
     117                 :     int GetLayerCount();
     118                 :     OGRLayer* GetLayer( int nLayer );
     119                 :     OGRLayer* CreateLayer( const char* pszName,
     120                 :                            OGRSpatialReference* poSRS = NULL,
     121                 :                            OGRwkbGeometryType eGType = wkbUnknown,
     122                 :                            char** papszOptions = NULL );
     123                 :     int TestCapability( const char* pszCap );
     124                 : 
     125                 :     //
     126                 :     // OGRGeoJSONDataSource Interface
     127                 :     //
     128                 :     int Create( const char* pszName, char** papszOptions );
     129              84 :     VSILFILE* GetOutputFile() const { return fpOut_; }
     130                 : 
     131                 :     enum GeometryTranslation
     132                 :     {
     133                 :         eGeometryPreserve,
     134                 :         eGeometryAsCollection,
     135                 :     };
     136                 :     
     137                 :     void SetGeometryTranslation( GeometryTranslation type );
     138                 : 
     139                 :     enum AttributesTranslation
     140                 :     {
     141                 :         eAtributesPreserve,
     142                 :         eAtributesSkip
     143                 :     };
     144                 : 
     145                 :     void SetAttributesTranslation( AttributesTranslation type );
     146                 : 
     147               1 :     int  GetFpOutputIsSeekable() const { return bFpOutputIsSeekable_; }
     148               1 :     int  GetBBOXInsertLocation() const { return nBBOXInsertLocation_; }
     149                 : 
     150                 : private:
     151                 : 
     152                 :     //
     153                 :     // Private data members
     154                 :     //
     155                 :     char* pszName_;
     156                 :     char* pszGeoData_;
     157                 :     OGRGeoJSONLayer** papoLayers_;
     158                 :     int nLayers_;
     159                 :     VSILFILE* fpOut_;
     160                 :     
     161                 :     //
     162                 :     // Translation/Creation control flags
     163                 :     // 
     164                 :     GeometryTranslation flTransGeom_;
     165                 :     AttributesTranslation flTransAttrs_;
     166                 : 
     167                 :     int bFpOutputIsSeekable_;
     168                 :     int nBBOXInsertLocation_;
     169                 : 
     170                 :     //
     171                 :     // Priavte utility functions
     172                 :     //
     173                 :     void Clear();
     174                 :     int ReadFromFile( const char* pszSource );
     175                 :     int ReadFromService( const char* pszSource );
     176                 :     OGRGeoJSONLayer* LoadLayer();
     177                 : };
     178                 : 
     179                 : 
     180                 : /************************************************************************/
     181                 : /*                           OGRGeoJSONDriver                           */
     182                 : /************************************************************************/
     183                 : 
     184                 : class OGRGeoJSONDriver : public OGRSFDriver
     185                 : {
     186                 : public:
     187                 : 
     188                 :     OGRGeoJSONDriver();
     189                 :     ~OGRGeoJSONDriver();
     190                 : 
     191                 :     //
     192                 :     // OGRSFDriver Interface
     193                 :     //
     194                 :     const char* GetName();
     195                 :     OGRDataSource* Open( const char* pszName, int bUpdate );
     196                 :     OGRDataSource* CreateDataSource( const char* pszName, char** papszOptions );
     197                 :     OGRErr DeleteDataSource( const char* pszName );
     198                 :     int TestCapability( const char* pszCap );
     199                 : 
     200                 :     //
     201                 :     // OGRGeoJSONDriver Interface
     202                 :     //
     203                 :     // NOTE: New version of Open() based on Andrey's RFC 10.
     204                 :     OGRDataSource* Open( const char* pszName, int bUpdate,
     205                 :                          char** papszOptions );
     206                 : 
     207                 : };
     208                 : 
     209                 : #endif /* OGR_GEOJSON_H_INCLUDED */
     210                 : 

Generated by: LCOV version 1.7