Main Page | Class Hierarchy | Class List | Directories | File List | Class Members | File Members | Related Pages

ogrsf_frmts.h

Go to the documentation of this file.
00001 /******************************************************************************
00002  * $Id: ogrsf_frmts.h,v 1.61 2006/12/13 18:24:45 dron Exp $
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  * $Log: ogrsf_frmts.h,v $
00031  * Revision 1.61  2006/12/13 18:24:45  dron
00032  * Added OGRLayer::SetStyleTableDirectly(), OGRDataSource::SetStyleTable()
00033  * and OGRDataSource::SetStyleTablDirectly() methods.
00034  *
00035  * Revision 1.60  2006/12/10 04:59:19  fwarmerdam
00036  * Removed extra OGRFME register function.
00037  *
00038  * Revision 1.59  2006/11/28 15:34:41  osemykin
00039  * Added new Informix DataBlade driver (IDB)
00040  *
00041  * Revision 1.58  2006/06/07 14:39:09  mloskot
00042  * Added new KML (Beta) driver to OGR. Thanks to Christopher Condit - the
00043  * author of KML drvier.
00044  *
00045  * Revision 1.57  2006/01/27 00:09:07  fwarmerdam
00046  * added Get{FID,Geometry}Column() support
00047  *
00048  * Revision 1.56  2005/11/22 17:01:09  fwarmerdam
00049  * added SDE support
00050  *
00051  * Revision 1.55  2005/11/10 21:37:28  fwarmerdam
00052  * added DXF/DWG support
00053  *
00054  * Revision 1.54  2005/10/25 19:58:53  fwarmerdam
00055  * added driver tracking on datasource
00056  *
00057  * Revision 1.53  2005/09/05 19:31:45  fwarmerdam
00058  * Added PGeo driver.
00059  *
00060  * Revision 1.52  2005/08/05 15:34:34  fwarmerdam
00061  * added grass
00062  *
00063  * Revision 1.51  2005/07/08 22:10:56  pka
00064  * Initial import of OGR Interlis driver
00065  *
00066  * Revision 1.50  2005/02/22 12:40:37  fwarmerdam
00067  * added base OGRLayer spatial filter support
00068  *
00069  * Revision 1.49  2005/02/02 20:00:01  fwarmerdam
00070  * added SetNextByIndex support
00071  *
00072  * Revision 1.48  2005/01/19 20:29:10  fwarmerdam
00073  * added autoloaddrivers on ogrsfdriverregistrar
00074  *
00075  * Revision 1.47  2005/01/03 22:16:44  fwarmerdam
00076  * added OGRLayer::SetSpatialFilterRect()
00077  *
00078  * Revision 1.46  2004/11/21 22:08:49  fwarmerdam
00079  * added Release() and DestroyDataSource() methods on OGRDataSource
00080  *
00081  * Revision 1.45  2004/10/06 19:49:14  fwarmerdam
00082  * Added Mysql registration function.
00083  *
00084  * Revision 1.44  2004/07/20 19:18:44  warmerda
00085  * added CSV
00086  *
00087  * Revision 1.43  2004/07/10 05:03:24  warmerda
00088  * added SQLite
00089  *
00090  * Revision 1.42  2004/02/11 18:03:15  warmerda
00091  * added RegisterOGRDODS()
00092  */
00093 
00094 #ifndef _OGRSF_FRMTS_H_INCLUDED
00095 #define _OGRSF_FRMTS_H_INCLUDED
00096 
00097 #include "ogr_feature.h"
00098 #include "ogr_featurestyle.h"
00099 
00106 class OGRLayerAttrIndex;
00107 class OGRSFDriver;
00108 
00109 /************************************************************************/
00110 /*                               OGRLayer                               */
00111 /************************************************************************/
00112 
00118 class CPL_DLL OGRLayer
00119 {
00120   protected:
00121     int          m_bFilterIsEnvelope;
00122     OGRGeometry  *m_poFilterGeom;
00123     OGREnvelope  m_sFilterEnvelope;
00124 
00125     int          FilterGeometry( OGRGeometry * );
00126     int          InstallFilter( OGRGeometry * );
00127 
00128   public:
00129     OGRLayer();
00130     virtual     ~OGRLayer();
00131 
00132     virtual OGRGeometry *GetSpatialFilter();
00133     virtual void        SetSpatialFilter( OGRGeometry * );
00134     virtual void        SetSpatialFilterRect( double dfMinX, double dfMinY,
00135                                               double dfMaxX, double dfMaxY );
00136 
00137     virtual OGRErr      SetAttributeFilter( const char * );
00138 
00139     virtual void        ResetReading() = 0;
00140     virtual OGRFeature *GetNextFeature() = 0;
00141     virtual OGRErr      SetNextByIndex( long nIndex );
00142     virtual OGRFeature *GetFeature( long nFID );
00143     virtual OGRErr      SetFeature( OGRFeature *poFeature );
00144     virtual OGRErr      CreateFeature( OGRFeature *poFeature );
00145     virtual OGRErr      DeleteFeature( long nFID );
00146 
00147     virtual OGRFeatureDefn *GetLayerDefn() = 0;
00148 
00149     virtual OGRSpatialReference *GetSpatialRef() { return NULL; }
00150 
00151     virtual int         GetFeatureCount( int bForce = TRUE );
00152     virtual OGRErr      GetExtent(OGREnvelope *psExtent, int bForce = TRUE);
00153 
00154     virtual int         TestCapability( const char * ) = 0;
00155 
00156     virtual const char *GetInfo( const char * );
00157 
00158     virtual OGRErr      CreateField( OGRFieldDefn *poField,
00159                                      int bApproxOK = TRUE );
00160 
00161     virtual OGRErr      SyncToDisk();
00162 
00163     OGRStyleTable       *GetStyleTable(){ return m_poStyleTable; }
00164     void                SetStyleTableDirectly( OGRStyleTable *poStyleTable )
00165                             { if ( m_poStyleTable ) delete m_poStyleTable;
00166                               m_poStyleTable = poStyleTable; }
00167     void                SetStyleTable(OGRStyleTable *poStyleTable)
00168                             {
00169                                 if ( m_poStyleTable ) delete m_poStyleTable;
00170                                 if ( poStyleTable )
00171                                     m_poStyleTable = poStyleTable->Clone();
00172                             }
00173 
00174     virtual OGRErr      StartTransaction();
00175     virtual OGRErr      CommitTransaction();
00176     virtual OGRErr      RollbackTransaction();
00177 
00178     virtual const char *GetFIDColumn();
00179     virtual const char *GetGeometryColumn();
00180 
00181     int                 Reference();
00182     int                 Dereference();
00183     int                 GetRefCount() const;
00184 
00185     GIntBig             GetFeaturesRead();
00186     
00187     /* consider these private */
00188     OGRErr               InitializeIndexSupport( const char * );
00189     OGRLayerAttrIndex   *GetIndex() { return m_poAttrIndex; }
00190 
00191  protected:
00192     OGRStyleTable       *m_poStyleTable;
00193     OGRFeatureQuery     *m_poAttrQuery;
00194     OGRLayerAttrIndex   *m_poAttrIndex;
00195 
00196     int                  m_nRefCount;
00197 
00198     GIntBig              m_nFeaturesRead;
00199 };
00200 
00201 
00202 /************************************************************************/
00203 /*                            OGRDataSource                             */
00204 /************************************************************************/
00205 
00216 class CPL_DLL OGRDataSource
00217 {
00218     friend class OGRSFDriverRegistrar;
00219 
00220   public:
00221 
00222     OGRDataSource();
00223     virtual     ~OGRDataSource();
00224     static void         DestroyDataSource( OGRDataSource * );
00225 
00226     virtual const char  *GetName() = 0;
00227 
00228     virtual int         GetLayerCount() = 0;
00229     virtual OGRLayer    *GetLayer(int) = 0;
00230     virtual OGRLayer    *GetLayerByName(const char *);
00231     virtual OGRErr      DeleteLayer(int);
00232 
00233     virtual int         TestCapability( const char * ) = 0;
00234 
00235     virtual OGRLayer   *CreateLayer( const char *pszName, 
00236                                      OGRSpatialReference *poSpatialRef = NULL,
00237                                      OGRwkbGeometryType eGType = wkbUnknown,
00238                                      char ** papszOptions = NULL );
00239     virtual OGRLayer   *CopyLayer( OGRLayer *poSrcLayer, 
00240                                    const char *pszNewName, 
00241                                    char **papszOptions = NULL );
00242 
00243     OGRStyleTable       *GetStyleTable(){ return m_poStyleTable; }
00244     void                SetStyleTableDirectly( OGRStyleTable *poStyleTable )
00245                             { if ( m_poStyleTable ) delete m_poStyleTable;
00246                               m_poStyleTable = poStyleTable; }
00247     void                SetStyleTable(OGRStyleTable *poStyleTable)
00248                             {
00249                                 if ( m_poStyleTable ) delete m_poStyleTable;
00250                                 if ( poStyleTable )
00251                                     m_poStyleTable = poStyleTable->Clone();
00252                             }
00253 
00254     virtual OGRLayer *  ExecuteSQL( const char *pszStatement,
00255                                     OGRGeometry *poSpatialFilter,
00256                                     const char *pszDialect );
00257     virtual void        ReleaseResultSet( OGRLayer * poResultsSet );
00258 
00259     virtual OGRErr      SyncToDisk();
00260 
00261     int                 Reference();
00262     int                 Dereference();
00263     int                 GetRefCount() const;
00264     int                 GetSummaryRefCount() const;
00265     OGRErr              Release();
00266 
00267     OGRSFDriver        *GetDriver() const;
00268 
00269   protected:
00270 
00271     OGRErr              ProcessSQLCreateIndex( const char * );
00272     OGRErr              ProcessSQLDropIndex( const char * );
00273 
00274     OGRStyleTable      *m_poStyleTable;
00275     int                 m_nRefCount;
00276     OGRSFDriver        *m_poDriver;
00277 };
00278 
00279 /************************************************************************/
00280 /*                             OGRSFDriver                              */
00281 /************************************************************************/
00282 
00292 class CPL_DLL OGRSFDriver
00293 {
00294   public:
00295     virtual     ~OGRSFDriver();
00296 
00297     virtual const char  *GetName() = 0;
00298 
00299     virtual OGRDataSource *Open( const char *pszName, int bUpdate=FALSE ) = 0;
00300 
00301     virtual int         TestCapability( const char * ) = 0;
00302 
00303     virtual OGRDataSource *CreateDataSource( const char *pszName,
00304                                              char ** = NULL );
00305     virtual OGRErr      DeleteDataSource( const char *pszName );
00306 
00307     virtual OGRDataSource *CopyDataSource( OGRDataSource *poSrcDS, 
00308                                            const char *pszNewName, 
00309                                            char **papszOptions = NULL );
00310 };
00311 
00312 
00313 /************************************************************************/
00314 /*                         OGRSFDriverRegistrar                         */
00315 /************************************************************************/
00316 
00322 class CPL_DLL OGRSFDriverRegistrar
00323 {
00324     int         nDrivers;
00325     OGRSFDriver **papoDrivers;
00326 
00327                 OGRSFDriverRegistrar();
00328 
00329     int         nOpenDSCount;
00330     char        **papszOpenDSRawName;
00331     OGRDataSource **papoOpenDS;
00332     OGRSFDriver **papoOpenDSDriver;
00333 
00334   public:
00335 
00336                 ~OGRSFDriverRegistrar();
00337 
00338     static OGRSFDriverRegistrar *GetRegistrar();
00339     static OGRDataSource *Open( const char *pszName, int bUpdate=FALSE,
00340                                 OGRSFDriver ** ppoDriver = NULL );
00341 
00342     OGRDataSource *OpenShared( const char *pszName, int bUpdate=FALSE,
00343                                OGRSFDriver ** ppoDriver = NULL );
00344     OGRErr      ReleaseDataSource( OGRDataSource * );
00345 
00346     void        RegisterDriver( OGRSFDriver * poDriver );
00347 
00348     int         GetDriverCount( void );
00349     OGRSFDriver *GetDriver( int iDriver );
00350     OGRSFDriver *GetDriverByName( const char * );
00351 
00352     int         GetOpenDSCount() { return nOpenDSCount; } 
00353     OGRDataSource *GetOpenDS( int );
00354 
00355     void        AutoLoadDrivers();
00356 };
00357 
00358 /* -------------------------------------------------------------------- */
00359 /*      Various available registration methods.                         */
00360 /* -------------------------------------------------------------------- */
00361 CPL_C_START
00362 void CPL_DLL OGRRegisterAll();
00363 
00364 void CPL_DLL RegisterOGRShape();
00365 void CPL_DLL RegisterOGRNTF();
00366 void CPL_DLL RegisterOGRFME();
00367 void CPL_DLL RegisterOGRSDTS();
00368 void CPL_DLL RegisterOGRTiger();
00369 void CPL_DLL RegisterOGRS57();
00370 void CPL_DLL RegisterOGRTAB();
00371 void CPL_DLL RegisterOGRMIF();
00372 void CPL_DLL RegisterOGROGDI();
00373 void CPL_DLL RegisterOGRODBC();
00374 void CPL_DLL RegisterOGRPG();
00375 void CPL_DLL RegisterOGRMySQL();
00376 void CPL_DLL RegisterOGROCI();
00377 void CPL_DLL RegisterOGRDGN();
00378 void CPL_DLL RegisterOGRGML();
00379 void CPL_DLL RegisterOGRKML();
00380 void CPL_DLL RegisterOGRAVCBin();
00381 void CPL_DLL RegisterOGRAVCE00();
00382 void CPL_DLL RegisterOGRREC();
00383 void CPL_DLL RegisterOGRMEM();
00384 void CPL_DLL RegisterOGRVRT();
00385 void CPL_DLL RegisterOGRDODS();
00386 void CPL_DLL RegisterOGRSQLite();
00387 void CPL_DLL RegisterOGRCSV();
00388 void CPL_DLL RegisterOGRILI1();
00389 void CPL_DLL RegisterOGRILI2();
00390 void CPL_DLL RegisterOGRGRASS();
00391 void CPL_DLL RegisterOGRPGeo();
00392 void CPL_DLL RegisterOGRDXFDWG();
00393 void CPL_DLL RegisterOGRSDE();
00394 void CPL_DLL RegisterOGRIDB();
00395 
00396 CPL_C_END
00397 
00398 
00399 #endif /* ndef _OGRSF_FRMTS_H_INCLUDED */

Generated for GDAL by doxygen 1.4.4.