# ogrsf_frmts.h

Go to the documentation of this file.

    00001 /******************************************************************************
    00002  * $Id: ogrsf_frmts.h 21372 2011-01-01 23:53:54Z rouault $
    00003  *
    00004  * Project:  OpenGIS Simple Features Reference Implementation
    00005  * Purpose:  Classes related to format registration, and file opening.
    00006  * Author:   Frank Warmerdam, warmerda@home.com
    00007  *
    00008  ******************************************************************************
    00009  * Copyright (c) 1999,  Les Technologies SoftMap Inc.
    00010  *
    00011  * Permission is hereby granted, free of charge, to any person obtaining a
    00012  * copy of this software and associated documentation files (the "Software"),
    00013  * to deal in the Software without restriction, including without limitation
    00014  * the rights to use, copy, modify, merge, publish, distribute, sublicense,
    00015  * and/or sell copies of the Software, and to permit persons to whom the
    00016  * Software is furnished to do so, subject to the following conditions:
    00017  *
    00018  * The above copyright notice and this permission notice shall be included
    00019  * in all copies or substantial portions of the Software.
    00020  *
    00021  * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
    00022  * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
    00023  * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
    00024  * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
    00025  * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
    00026  * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
    00027  * DEALINGS IN THE SOFTWARE.
    00028  ****************************************************************************/
    00029
    00030 #ifndef _OGRSF_FRMTS_H_INCLUDED
    00031 #define _OGRSF_FRMTS_H_INCLUDED
    00032
    00033 #include "ogr_feature.h"
    00034 #include "ogr_featurestyle.h"
    00035
    00042 class OGRLayerAttrIndex;
    00043 class OGRSFDriver;
    00044
    00045 /************************************************************************/
    00046 /*                               OGRLayer                               */
    00047 /************************************************************************/
    00048
    00054 class CPL_DLL OGRLayer
    00055 {
    00056   protected:
    00057     int          m_bFilterIsEnvelope;
    00058     OGRGeometry *m_poFilterGeom;
    00059     OGREnvelope  m_sFilterEnvelope;
    00060
    00061     int          FilterGeometry( OGRGeometry * );
    00062     int          InstallFilter( OGRGeometry * );
    00063
    00064   public:
    00065     OGRLayer();
    00066     virtual     ~OGRLayer();
    00067
    00068     virtual OGRGeometry *GetSpatialFilter();
    00069     virtual void        SetSpatialFilter( OGRGeometry * );
    00070     virtual void        SetSpatialFilterRect( double dfMinX, double dfMinY,
    00071                                               double dfMaxX, double dfMaxY );
    00072
    00073     virtual OGRErr      SetAttributeFilter( const char * );
    00074
    00075     virtual void        ResetReading() = 0;
    00076     virtual OGRFeature *GetNextFeature() = 0;
    00077     virtual OGRErr      SetNextByIndex( long nIndex );
    00078     virtual OGRFeature *GetFeature( long nFID );
    00079     virtual OGRErr      SetFeature( OGRFeature *poFeature );
    00080     virtual OGRErr      CreateFeature( OGRFeature *poFeature );
    00081     virtual OGRErr      DeleteFeature( long nFID );
    00082
    00083     virtual const char *GetName();
    00084     virtual OGRwkbGeometryType GetGeomType();
    00085     virtual OGRFeatureDefn *GetLayerDefn() = 0;
    00086
    00087     virtual OGRSpatialReference *GetSpatialRef() { return NULL; }
    00088
    00089     virtual int         GetFeatureCount( int bForce = TRUE );
    00090     virtual OGRErr      GetExtent(OGREnvelope *psExtent, int bForce = TRUE);
    00091
    00092     virtual int         TestCapability( const char * ) = 0;
    00093
    00094     virtual const char *GetInfo( const char * );
    00095
    00096     virtual OGRErr      CreateField( OGRFieldDefn *poField,
    00097                                      int bApproxOK = TRUE );
    00098
    00099     virtual OGRErr      SyncToDisk();
    00100
    00101     virtual OGRStyleTable *GetStyleTable();
    00102     virtual void        SetStyleTableDirectly( OGRStyleTable *poStyleTable );
    00103
    00104     virtual void        SetStyleTable(OGRStyleTable *poStyleTable);
    00105
    00106     virtual OGRErr      StartTransaction();
    00107     virtual OGRErr      CommitTransaction();
    00108     virtual OGRErr      RollbackTransaction();
    00109
    00110     virtual const char *GetFIDColumn();
    00111     virtual const char *GetGeometryColumn();
    00112
    00113     virtual OGRErr      SetIgnoredFields( const char **papszFields );
    00114
    00115     int                 Reference();
    00116     int                 Dereference();
    00117     int                 GetRefCount() const;
    00118
    00119     GIntBig             GetFeaturesRead();
    00120
    00121     /* consider these private */
    00122     OGRErr               InitializeIndexSupport( const char * );
    00123     OGRLayerAttrIndex   *GetIndex() { return m_poAttrIndex; }
    00124
    00125  protected:
    00126     OGRStyleTable       *m_poStyleTable;
    00127     OGRFeatureQuery     *m_poAttrQuery;
    00128     OGRLayerAttrIndex   *m_poAttrIndex;
    00129
    00130     int                  m_nRefCount;
    00131
    00132     GIntBig              m_nFeaturesRead;
    00133 };
    00134
    00135
    00136 /************************************************************************/
    00137 /*                            OGRDataSource                             */
    00138 /************************************************************************/
    00139
    00150 class CPL_DLL OGRDataSource
    00151 {
    00152     friend class OGRSFDriverRegistrar;
    00153
    00154     void        *m_hMutex;
    00155
    00156   public:
    00157
    00158     OGRDataSource();
    00159     virtual     ~OGRDataSource();
    00160     static void         DestroyDataSource( OGRDataSource * );
    00161
    00162     virtual const char  *GetName() = 0;
    00163
    00164     virtual int         GetLayerCount() = 0;
    00165     virtual OGRLayer    *GetLayer(int) = 0;
    00166     virtual OGRLayer    *GetLayerByName(const char *);
    00167     virtual OGRErr      DeleteLayer(int);
    00168
    00169     virtual int         TestCapability( const char * ) = 0;
    00170
    00171     virtual OGRLayer   *CreateLayer( const char *pszName,
    00172                                      OGRSpatialReference *poSpatialRef = NULL,
    00173                                      OGRwkbGeometryType eGType = wkbUnknown,
    00174                                      char ** papszOptions = NULL );
    00175     virtual OGRLayer   *CopyLayer( OGRLayer *poSrcLayer,
    00176                                    const char *pszNewName,
    00177                                    char **papszOptions = NULL );
    00178
    00179     virtual OGRStyleTable *GetStyleTable();
    00180     virtual void        SetStyleTableDirectly( OGRStyleTable *poStyleTable );
    00181
    00182     virtual void        SetStyleTable(OGRStyleTable *poStyleTable);
    00183
    00184     virtual OGRLayer *  ExecuteSQL( const char *pszStatement,
    00185                                     OGRGeometry *poSpatialFilter,
    00186                                     const char *pszDialect );
    00187     virtual void        ReleaseResultSet( OGRLayer * poResultsSet );
    00188
    00189     virtual OGRErr      SyncToDisk();
    00190
    00191     int                 Reference();
    00192     int                 Dereference();
    00193     int                 GetRefCount() const;
    00194     int                 GetSummaryRefCount() const;
    00195     OGRErr              Release();
    00196
    00197     OGRSFDriver        *GetDriver() const;
    00198     void                SetDriver( OGRSFDriver *poDriver );
    00199
    00200   protected:
    00201
    00202     OGRErr              ProcessSQLCreateIndex( const char * );
    00203     OGRErr              ProcessSQLDropIndex( const char * );
    00204
    00205     OGRStyleTable      *m_poStyleTable;
    00206     int                 m_nRefCount;
    00207     OGRSFDriver        *m_poDriver;
    00208 };
    00209
    00210 /************************************************************************/
    00211 /*                             OGRSFDriver                              */
    00212 /************************************************************************/
    00213
    00223 class CPL_DLL OGRSFDriver
    00224 {
    00225   public:
    00226     virtual     ~OGRSFDriver();
    00227
    00228     virtual const char  *GetName() = 0;
    00229
    00230     virtual OGRDataSource *Open( const char *pszName, int bUpdate=FALSE ) = 0;
    00231
    00232     virtual int         TestCapability( const char * ) = 0;
    00233
    00234     virtual OGRDataSource *CreateDataSource( const char *pszName,
    00235                                              char ** = NULL );
    00236     virtual OGRErr      DeleteDataSource( const char *pszName );
    00237
    00238     virtual OGRDataSource *CopyDataSource( OGRDataSource *poSrcDS,
    00239                                            const char *pszNewName,
    00240                                            char **papszOptions = NULL );
    00241 };
    00242
    00243
    00244 /************************************************************************/
    00245 /*                         OGRSFDriverRegistrar                         */
    00246 /************************************************************************/
    00247
    00256 class CPL_DLL OGRSFDriverRegistrar
    00257 {
    00258     int         nDrivers;
    00259     OGRSFDriver **papoDrivers;
    00260
    00261                 OGRSFDriverRegistrar();
    00262
    00263     int         nOpenDSCount;
    00264     char        **papszOpenDSRawName;
    00265     OGRDataSource **papoOpenDS;
    00266     OGRSFDriver **papoOpenDSDriver;
    00267     GIntBig     *panOpenDSPID;
    00268
    00269   public:
    00270
    00271                 ~OGRSFDriverRegistrar();
    00272
    00273     static OGRSFDriverRegistrar *GetRegistrar();
    00274     static OGRDataSource *Open( const char *pszName, int bUpdate=FALSE,
    00275                                 OGRSFDriver ** ppoDriver = NULL );
    00276
    00277     OGRDataSource *OpenShared( const char *pszName, int bUpdate=FALSE,
    00278                                OGRSFDriver ** ppoDriver = NULL );
    00279     OGRErr      ReleaseDataSource( OGRDataSource * );
    00280
    00281     void        RegisterDriver( OGRSFDriver * poDriver );
    00282     void        DeregisterDriver( OGRSFDriver * poDriver );
    00283
    00284     int         GetDriverCount( void );
    00285     OGRSFDriver *GetDriver( int iDriver );
    00286     OGRSFDriver *GetDriverByName( const char * );
    00287
    00288     int         GetOpenDSCount() { return nOpenDSCount; }
    00289     OGRDataSource *GetOpenDS( int );
    00290
    00291     void        AutoLoadDrivers();
    00292 };
    00293
    00294 /* -------------------------------------------------------------------- */
    00295 /*      Various available registration methods.                         */
    00296 /* -------------------------------------------------------------------- */
    00297 CPL_C_START
    00298 void CPL_DLL OGRRegisterAll();
    00299
    00300 void CPL_DLL RegisterOGRShape();
    00301 void CPL_DLL RegisterOGRNTF();
    00302 void CPL_DLL RegisterOGRFME();
    00303 void CPL_DLL RegisterOGRSDTS();
    00304 void CPL_DLL RegisterOGRTiger();
    00305 void CPL_DLL RegisterOGRS57();
    00306 void CPL_DLL RegisterOGRTAB();
    00307 void CPL_DLL RegisterOGRMIF();
    00308 void CPL_DLL RegisterOGROGDI();
    00309 void CPL_DLL RegisterOGRODBC();
    00310 void CPL_DLL RegisterOGRPG();
    00311 void CPL_DLL RegisterOGRMSSQLSpatial();
    00312 void CPL_DLL RegisterOGRMySQL();
    00313 void CPL_DLL RegisterOGROCI();
    00314 void CPL_DLL RegisterOGRDGN();
    00315 void CPL_DLL RegisterOGRGML();
    00316 void CPL_DLL RegisterOGRLIBKML();
    00317 void CPL_DLL RegisterOGRKML();
    00318 void CPL_DLL RegisterOGRGeoJSON();
    00319 void CPL_DLL RegisterOGRAVCBin();
    00320 void CPL_DLL RegisterOGRAVCE00();
    00321 void CPL_DLL RegisterOGRREC();
    00322 void CPL_DLL RegisterOGRMEM();
    00323 void CPL_DLL RegisterOGRVRT();
    00324 void CPL_DLL RegisterOGRDODS();
    00325 void CPL_DLL RegisterOGRSQLite();
    00326 void CPL_DLL RegisterOGRCSV();
    00327 void CPL_DLL RegisterOGRILI1();
    00328 void CPL_DLL RegisterOGRILI2();
    00329 void CPL_DLL RegisterOGRGRASS();
    00330 void CPL_DLL RegisterOGRPGeo();
    00331 void CPL_DLL RegisterOGRDXFDWG();
    00332 void CPL_DLL RegisterOGRDXF();
    00333 void CPL_DLL RegisterOGRSDE();
    00334 void CPL_DLL RegisterOGRIDB();
    00335 void CPL_DLL RegisterOGRGMT();
    00336 void CPL_DLL RegisterOGRBNA();
    00337 void CPL_DLL RegisterOGRGPX();
    00338 void CPL_DLL RegisterOGRGeoconcept();
    00339 void CPL_DLL RegisterOGRIngres();
    00340 void CPL_DLL RegisterOGRPCIDSK();
    00341 void CPL_DLL RegisterOGRXPlane();
    00342 void CPL_DLL RegisterOGRNAS();
    00343 void CPL_DLL RegisterOGRGeoRSS();
    00344 void CPL_DLL RegisterOGRGTM();
    00345 void CPL_DLL RegisterOGRVFK();
    00346 void CPL_DLL RegisterOGRPGDump();
    00347 void CPL_DLL RegisterOGRGPSBabel();
    00348 void CPL_DLL RegisterOGRSUA();
    00349 void CPL_DLL RegisterOGROpenAir();
    00350 void CPL_DLL RegisterOGRPDS();
    00351 void CPL_DLL RegisterOGRWFS();
    00352 void CPL_DLL RegisterOGRSOSI();
    00353 void CPL_DLL RegisterOGRHTF();
    00354 void CPL_DLL RegisterOGRAeronavFAA();
    00355 CPL_C_END
    00356
    00357
    00358 #endif /* ndef _OGRSF_FRMTS_H_INCLUDED */

Generated for GDAL by 1.5.6.