ogrsf_frmts.h

Go to the documentation of this file.
00001 /******************************************************************************
00002  * $Id: ogrsf_frmts.h 27044 2014-03-16 23:41:27Z 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  * Copyright (c) 2007-2014, Even Rouault <even dot rouault at mines-paris dot org>
00011  *
00012  * Permission is hereby granted, free of charge, to any person obtaining a
00013  * copy of this software and associated documentation files (the "Software"),
00014  * to deal in the Software without restriction, including without limitation
00015  * the rights to use, copy, modify, merge, publish, distribute, sublicense,
00016  * and/or sell copies of the Software, and to permit persons to whom the
00017  * Software is furnished to do so, subject to the following conditions:
00018  *
00019  * The above copyright notice and this permission notice shall be included
00020  * in all copies or substantial portions of the Software.
00021  *
00022  * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
00023  * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
00024  * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
00025  * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
00026  * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
00027  * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
00028  * DEALINGS IN THE SOFTWARE.
00029  ****************************************************************************/
00030 
00031 #ifndef _OGRSF_FRMTS_H_INCLUDED
00032 #define _OGRSF_FRMTS_H_INCLUDED
00033 
00034 #include "cpl_progress.h"
00035 #include "ogr_feature.h"
00036 #include "ogr_featurestyle.h"
00037 
00044 class OGRLayerAttrIndex;
00045 class OGRSFDriver;
00046 
00047 /************************************************************************/
00048 /*                               OGRLayer                               */
00049 /************************************************************************/
00050 
00056 /* Note: any virtual method added to this class must also be added in the */
00057 /* OGRLayerDecorator and OGRMutexedLayer classes. */
00058 
00059 class CPL_DLL OGRLayer
00060 {
00061   protected:
00062     int          m_bFilterIsEnvelope;
00063     OGRGeometry *m_poFilterGeom;
00064     OGRPreparedGeometry *m_pPreparedFilterGeom; /* m_poFilterGeom compiled as a prepared geometry */
00065     OGREnvelope  m_sFilterEnvelope;
00066     int          m_iGeomFieldFilter; // specify the index on which the spatial
00067                                      // filter is active.
00068     
00069     int          FilterGeometry( OGRGeometry * );
00070     //int          FilterGeometry( OGRGeometry *, OGREnvelope* psGeometryEnvelope);
00071     int          InstallFilter( OGRGeometry * );
00072     
00073     OGRErr       GetExtentInternal(int iGeomField, OGREnvelope *psExtent, int bForce );
00074 
00075   public:
00076     OGRLayer();
00077     virtual     ~OGRLayer();
00078 
00079     virtual OGRGeometry *GetSpatialFilter();
00080     virtual void        SetSpatialFilter( OGRGeometry * );
00081     virtual void        SetSpatialFilterRect( double dfMinX, double dfMinY,
00082                                               double dfMaxX, double dfMaxY );
00083 
00084     virtual void        SetSpatialFilter( int iGeomField, OGRGeometry * );
00085     virtual void        SetSpatialFilterRect( int iGeomField,
00086                                             double dfMinX, double dfMinY,
00087                                             double dfMaxX, double dfMaxY );
00088 
00089     virtual OGRErr      SetAttributeFilter( const char * );
00090 
00091     virtual void        ResetReading() = 0;
00092     virtual OGRFeature *GetNextFeature() = 0;
00093     virtual OGRErr      SetNextByIndex( long nIndex );
00094     virtual OGRFeature *GetFeature( long nFID );
00095     virtual OGRErr      SetFeature( OGRFeature *poFeature );
00096     virtual OGRErr      CreateFeature( OGRFeature *poFeature );
00097     virtual OGRErr      DeleteFeature( long nFID );
00098 
00099     virtual const char *GetName();
00100     virtual OGRwkbGeometryType GetGeomType();
00101     virtual OGRFeatureDefn *GetLayerDefn() = 0;
00102     virtual int         FindFieldIndex( const char *pszFieldName, int bExactMatch );
00103 
00104     virtual OGRSpatialReference *GetSpatialRef();
00105 
00106     virtual int         GetFeatureCount( int bForce = TRUE );
00107     virtual OGRErr      GetExtent(OGREnvelope *psExtent, int bForce = TRUE);
00108     virtual OGRErr      GetExtent(int iGeomField, OGREnvelope *psExtent,
00109                                   int bForce = TRUE);
00110 
00111     virtual int         TestCapability( const char * ) = 0;
00112 
00113     virtual const char *GetInfo( const char * );
00114 
00115     virtual OGRErr      CreateField( OGRFieldDefn *poField,
00116                                      int bApproxOK = TRUE );
00117     virtual OGRErr      DeleteField( int iField );
00118     virtual OGRErr      ReorderFields( int* panMap );
00119     virtual OGRErr      AlterFieldDefn( int iField, OGRFieldDefn* poNewFieldDefn, int nFlags );
00120 
00121     virtual OGRErr      CreateGeomField( OGRGeomFieldDefn *poField,
00122                                      int bApproxOK = TRUE );
00123 
00124     virtual OGRErr      SyncToDisk();
00125 
00126     virtual OGRStyleTable *GetStyleTable();
00127     virtual void        SetStyleTableDirectly( OGRStyleTable *poStyleTable );
00128                             
00129     virtual void        SetStyleTable(OGRStyleTable *poStyleTable);
00130 
00131     virtual OGRErr      StartTransaction();
00132     virtual OGRErr      CommitTransaction();
00133     virtual OGRErr      RollbackTransaction();
00134 
00135     virtual const char *GetFIDColumn();
00136     virtual const char *GetGeometryColumn();
00137 
00138     virtual OGRErr      SetIgnoredFields( const char **papszFields );
00139 
00140     OGRErr              Intersection( OGRLayer *pLayerMethod, 
00141                                       OGRLayer *pLayerResult, 
00142                                       char** papszOptions = NULL, 
00143                                       GDALProgressFunc pfnProgress = NULL, 
00144                                       void * pProgressArg = NULL );
00145     OGRErr              Union( OGRLayer *pLayerMethod, 
00146                                OGRLayer *pLayerResult, 
00147                                char** papszOptions = NULL, 
00148                                GDALProgressFunc pfnProgress = NULL, 
00149                                void * pProgressArg = NULL );
00150     OGRErr              SymDifference( OGRLayer *pLayerMethod, 
00151                                        OGRLayer *pLayerResult, 
00152                                        char** papszOptions, 
00153                                        GDALProgressFunc pfnProgress, 
00154                                        void * pProgressArg );
00155     OGRErr              Identity( OGRLayer *pLayerMethod, 
00156                                   OGRLayer *pLayerResult, 
00157                                   char** papszOptions = NULL, 
00158                                   GDALProgressFunc pfnProgress = NULL, 
00159                                   void * pProgressArg = NULL );
00160     OGRErr              Update( OGRLayer *pLayerMethod, 
00161                                 OGRLayer *pLayerResult, 
00162                                 char** papszOptions = NULL, 
00163                                 GDALProgressFunc pfnProgress = NULL, 
00164                                 void * pProgressArg = NULL );
00165     OGRErr              Clip( OGRLayer *pLayerMethod, 
00166                               OGRLayer *pLayerResult, 
00167                               char** papszOptions = NULL, 
00168                               GDALProgressFunc pfnProgress = NULL, 
00169                               void * pProgressArg = NULL );
00170     OGRErr              Erase( OGRLayer *pLayerMethod, 
00171                                OGRLayer *pLayerResult, 
00172                                char** papszOptions = NULL, 
00173                                GDALProgressFunc pfnProgress = NULL, 
00174                                void * pProgressArg = NULL );
00175     
00176     int                 Reference();
00177     int                 Dereference();
00178     int                 GetRefCount() const;
00179 
00180     GIntBig             GetFeaturesRead();
00181 
00182     /* non virtual : conveniency wrapper for ReorderFields() */
00183     OGRErr              ReorderField( int iOldFieldPos, int iNewFieldPos );
00184 
00185     int                 AttributeFilterEvaluationNeedsGeometry();
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     char                *m_pszAttrQueryString;
00195     OGRLayerAttrIndex   *m_poAttrIndex;
00196 
00197     int                  m_nRefCount;
00198 
00199     GIntBig              m_nFeaturesRead;
00200 };
00201 
00202 
00203 /************************************************************************/
00204 /*                            OGRDataSource                             */
00205 /************************************************************************/
00206 
00217 class CPL_DLL OGRDataSource
00218 {
00219     friend class OGRSFDriverRegistrar;
00220 
00221     void        *m_hMutex;
00222 
00223     OGRLayer*       BuildLayerFromSelectInfo(void* psSelectInfo,
00224                                              OGRGeometry *poSpatialFilter,
00225                                              const char *pszDialect);
00226 
00227   public:
00228 
00229     OGRDataSource();
00230     virtual     ~OGRDataSource();
00231     static void         DestroyDataSource( OGRDataSource * );
00232 
00233     virtual const char  *GetName() = 0;
00234 
00235     virtual int         GetLayerCount() = 0;
00236     virtual OGRLayer    *GetLayer(int) = 0;
00237     virtual OGRLayer    *GetLayerByName(const char *);
00238     virtual OGRErr      DeleteLayer(int);
00239 
00240     virtual int         TestCapability( const char * ) = 0;
00241 
00242     virtual OGRLayer   *CreateLayer( const char *pszName, 
00243                                      OGRSpatialReference *poSpatialRef = NULL,
00244                                      OGRwkbGeometryType eGType = wkbUnknown,
00245                                      char ** papszOptions = NULL );
00246     virtual OGRLayer   *CopyLayer( OGRLayer *poSrcLayer, 
00247                                    const char *pszNewName, 
00248                                    char **papszOptions = NULL );
00249 
00250     virtual OGRStyleTable *GetStyleTable();
00251     virtual void        SetStyleTableDirectly( OGRStyleTable *poStyleTable );
00252                             
00253     virtual void        SetStyleTable(OGRStyleTable *poStyleTable);
00254 
00255     virtual OGRLayer *  ExecuteSQL( const char *pszStatement,
00256                                     OGRGeometry *poSpatialFilter,
00257                                     const char *pszDialect );
00258     virtual void        ReleaseResultSet( OGRLayer * poResultsSet );
00259 
00260     virtual OGRErr      SyncToDisk();
00261 
00262     int                 Reference();
00263     int                 Dereference();
00264     int                 GetRefCount() const;
00265     int                 GetSummaryRefCount() const;
00266     OGRErr              Release();
00267 
00268     OGRSFDriver        *GetDriver() const;
00269     void                SetDriver( OGRSFDriver *poDriver );
00270     
00271     static int          IsGenericSQLDialect(const char* pszDialect);
00272 
00273   protected:
00274 
00275     OGRErr              ProcessSQLCreateIndex( const char * );
00276     OGRErr              ProcessSQLDropIndex( const char * );
00277     OGRErr              ProcessSQLDropTable( const char * );
00278     OGRErr              ProcessSQLAlterTableAddColumn( const char * );
00279     OGRErr              ProcessSQLAlterTableDropColumn( const char * );
00280     OGRErr              ProcessSQLAlterTableAlterColumn( const char * );
00281     OGRErr              ProcessSQLAlterTableRenameColumn( const char * );
00282 
00283     OGRStyleTable      *m_poStyleTable;
00284     int                 m_nRefCount;
00285     OGRSFDriver        *m_poDriver;
00286 };
00287 
00288 /************************************************************************/
00289 /*                             OGRSFDriver                              */
00290 /************************************************************************/
00291 
00301 class CPL_DLL OGRSFDriver
00302 {
00303   public:
00304     virtual     ~OGRSFDriver();
00305 
00306     virtual const char  *GetName() = 0;
00307 
00308     virtual OGRDataSource *Open( const char *pszName, int bUpdate=FALSE ) = 0;
00309 
00310     virtual int         TestCapability( const char * ) = 0;
00311 
00312     virtual OGRDataSource *CreateDataSource( const char *pszName,
00313                                              char ** = NULL );
00314     virtual OGRErr      DeleteDataSource( const char *pszName );
00315 
00316     virtual OGRDataSource *CopyDataSource( OGRDataSource *poSrcDS, 
00317                                            const char *pszNewName, 
00318                                            char **papszOptions = NULL );
00319 };
00320 
00321 
00322 /************************************************************************/
00323 /*                         OGRSFDriverRegistrar                         */
00324 /************************************************************************/
00325 
00334 class CPL_DLL OGRSFDriverRegistrar
00335 {
00336     int         nDrivers;
00337     OGRSFDriver **papoDrivers;
00338 
00339                 OGRSFDriverRegistrar();
00340 
00341     int         nOpenDSCount;
00342     char        **papszOpenDSRawName;
00343     OGRDataSource **papoOpenDS;
00344     OGRSFDriver **papoOpenDSDriver;
00345     GIntBig     *panOpenDSPID;
00346 
00347   public:
00348 
00349                 ~OGRSFDriverRegistrar();
00350 
00351     static OGRSFDriverRegistrar *GetRegistrar();
00352     static OGRDataSource *Open( const char *pszName, int bUpdate=FALSE,
00353                                 OGRSFDriver ** ppoDriver = NULL );
00354 
00355     OGRDataSource *OpenShared( const char *pszName, int bUpdate=FALSE,
00356                                OGRSFDriver ** ppoDriver = NULL );
00357     OGRErr      ReleaseDataSource( OGRDataSource * );
00358 
00359     void        RegisterDriver( OGRSFDriver * poDriver );
00360     void        DeregisterDriver( OGRSFDriver * poDriver );
00361 
00362     int         GetDriverCount( void );
00363     OGRSFDriver *GetDriver( int iDriver );
00364     OGRSFDriver *GetDriverByName( const char * );
00365 
00366     int         GetOpenDSCount() { return nOpenDSCount; } 
00367     OGRDataSource *GetOpenDS( int );
00368 
00369     void        AutoLoadDrivers();
00370 };
00371 
00372 /* -------------------------------------------------------------------- */
00373 /*      Various available registration methods.                         */
00374 /* -------------------------------------------------------------------- */
00375 CPL_C_START
00376 void CPL_DLL OGRRegisterAll();
00377 
00378 void CPL_DLL RegisterOGRFileGDB();
00379 void CPL_DLL RegisterOGRShape();
00380 void CPL_DLL RegisterOGRNTF();
00381 void CPL_DLL RegisterOGRFME();
00382 void CPL_DLL RegisterOGRSDTS();
00383 void CPL_DLL RegisterOGRTiger();
00384 void CPL_DLL RegisterOGRS57();
00385 void CPL_DLL RegisterOGRTAB();
00386 void CPL_DLL RegisterOGRMIF();
00387 void CPL_DLL RegisterOGROGDI();
00388 void CPL_DLL RegisterOGRODBC();
00389 void CPL_DLL RegisterOGRWAsP();
00390 void CPL_DLL RegisterOGRPG();
00391 void CPL_DLL RegisterOGRMSSQLSpatial();
00392 void CPL_DLL RegisterOGRMySQL();
00393 void CPL_DLL RegisterOGROCI();
00394 void CPL_DLL RegisterOGRDGN();
00395 void CPL_DLL RegisterOGRGML();
00396 void CPL_DLL RegisterOGRLIBKML();
00397 void CPL_DLL RegisterOGRKML();
00398 void CPL_DLL RegisterOGRGeoJSON();
00399 void CPL_DLL RegisterOGRAVCBin();
00400 void CPL_DLL RegisterOGRAVCE00();
00401 void CPL_DLL RegisterOGRREC();
00402 void CPL_DLL RegisterOGRMEM();
00403 void CPL_DLL RegisterOGRVRT();
00404 void CPL_DLL RegisterOGRDODS();
00405 void CPL_DLL RegisterOGRSQLite();
00406 void CPL_DLL RegisterOGRCSV();
00407 void CPL_DLL RegisterOGRILI1();
00408 void CPL_DLL RegisterOGRILI2();
00409 void CPL_DLL RegisterOGRGRASS();
00410 void CPL_DLL RegisterOGRPGeo();
00411 void CPL_DLL RegisterOGRDXFDWG();
00412 void CPL_DLL RegisterOGRDXF();
00413 void CPL_DLL RegisterOGRDWG();
00414 void CPL_DLL RegisterOGRSDE();
00415 void CPL_DLL RegisterOGRIDB();
00416 void CPL_DLL RegisterOGRGMT();
00417 void CPL_DLL RegisterOGRBNA();
00418 void CPL_DLL RegisterOGRGPX();
00419 void CPL_DLL RegisterOGRGeoconcept();
00420 void CPL_DLL RegisterOGRIngres();
00421 void CPL_DLL RegisterOGRPCIDSK();
00422 void CPL_DLL RegisterOGRXPlane();
00423 void CPL_DLL RegisterOGRNAS();
00424 void CPL_DLL RegisterOGRGeoRSS();
00425 void CPL_DLL RegisterOGRGTM();
00426 void CPL_DLL RegisterOGRVFK();
00427 void CPL_DLL RegisterOGRPGDump();
00428 void CPL_DLL RegisterOGROSM();
00429 void CPL_DLL RegisterOGRGPSBabel();
00430 void CPL_DLL RegisterOGRSUA();
00431 void CPL_DLL RegisterOGROpenAir();
00432 void CPL_DLL RegisterOGRPDS();
00433 void CPL_DLL RegisterOGRWFS();
00434 void CPL_DLL RegisterOGRSOSI();
00435 void CPL_DLL RegisterOGRHTF();
00436 void CPL_DLL RegisterOGRAeronavFAA();
00437 void CPL_DLL RegisterOGRGeomedia();
00438 void CPL_DLL RegisterOGRMDB();
00439 void CPL_DLL RegisterOGREDIGEO();
00440 void CPL_DLL RegisterOGRGFT();
00441 void CPL_DLL RegisterOGRGME();
00442 void CPL_DLL RegisterOGRSVG();
00443 void CPL_DLL RegisterOGRCouchDB();
00444 void CPL_DLL RegisterOGRIdrisi();
00445 void CPL_DLL RegisterOGRARCGEN();
00446 void CPL_DLL RegisterOGRSEGUKOOA();
00447 void CPL_DLL RegisterOGRSEGY();
00448 void CPL_DLL RegisterOGRXLS();
00449 void CPL_DLL RegisterOGRODS();
00450 void CPL_DLL RegisterOGRXLSX();
00451 void CPL_DLL RegisterOGRElastic();
00452 void CPL_DLL RegisterOGRGeoPackage();
00453 void CPL_DLL RegisterOGRPDF();
00454 void CPL_DLL RegisterOGRWalk();
00455 void CPL_DLL RegisterOGRCartoDB();
00456 void CPL_DLL RegisterOGRSXF();
00457 void CPL_DLL RegisterOGROpenFileGDB();
00458 CPL_C_END
00459 
00460 
00461 #endif /* ndef _OGRSF_FRMTS_H_INCLUDED */

Generated for GDAL by doxygen 1.7.1.