ogrsf_frmts.h

Go to the documentation of this file.
00001 /******************************************************************************
00002  * $Id: ogrsf_frmts.h,v 1.50 2005/02/22 12:40:37 fwarmerdam 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.50  2005/02/22 12:40:37  fwarmerdam
00032  * added base OGRLayer spatial filter support
00033  *
00034  * Revision 1.49  2005/02/02 20:00:01  fwarmerdam
00035  * added SetNextByIndex support
00036  *
00037  * Revision 1.48  2005/01/19 20:29:10  fwarmerdam
00038  * added autoloaddrivers on ogrsfdriverregistrar
00039  *
00040  * Revision 1.47  2005/01/03 22:16:44  fwarmerdam
00041  * added OGRLayer::SetSpatialFilterRect()
00042  *
00043  * Revision 1.46  2004/11/21 22:08:49  fwarmerdam
00044  * added Release() and DestroyDataSource() methods on OGRDataSource
00045  *
00046  * Revision 1.45  2004/10/06 19:49:14  fwarmerdam
00047  * Added Mysql registration function.
00048  *
00049  * Revision 1.44  2004/07/20 19:18:44  warmerda
00050  * added CSV
00051  *
00052  * Revision 1.43  2004/07/10 05:03:24  warmerda
00053  * added SQLite
00054  *
00055  * Revision 1.42  2004/02/11 18:03:15  warmerda
00056  * added RegisterOGRDODS()
00057  *
00058  * Revision 1.41  2003/11/06 18:27:35  warmerda
00059  * Added VRT registration point
00060  *
00061  * Revision 1.40  2003/10/09 15:28:07  warmerda
00062  * added OGRLayer::DeleteFeature() support
00063  *
00064  * Revision 1.39  2003/10/06 19:15:40  warmerda
00065  * added ODBC support
00066  *
00067  * Revision 1.38  2003/05/28 19:17:31  warmerda
00068  * fixup stuff for docs
00069  *
00070  * Revision 1.37  2003/04/22 19:36:04  warmerda
00071  * Added SyncToDisk
00072  *
00073  * Revision 1.36  2003/04/08 21:21:29  warmerda
00074  * added OGRGetDriverByName
00075  *
00076  * Revision 1.35  2003/04/08 19:31:32  warmerda
00077  * added CopyLayer and CopyDataSource entry points
00078  *
00079  * Revision 1.34  2003/03/20 20:21:48  warmerda
00080  * added drop index
00081  *
00082  * Revision 1.33  2003/03/19 20:29:06  warmerda
00083  * added shared access and reference counting
00084  *
00085  * Revision 1.32  2003/03/05 05:09:11  warmerda
00086  * added GetLayerByName() method on OGRDataSource
00087  *
00088  * Revision 1.31  2003/03/04 05:47:23  warmerda
00089  * added indexing support
00090  *
00091  * Revision 1.30  2003/03/03 05:06:08  warmerda
00092  * added support for DeleteDataSource and DeleteLayer
00093  *
00094  * Revision 1.29  2003/02/03 21:16:49  warmerda
00095  * added .rec driver
00096  *
00097  * Revision 1.28  2002/12/28 04:09:18  warmerda
00098  * added Oracle support
00099  *
00100  * Revision 1.27  2002/09/26 18:15:31  warmerda
00101  * moved capabilities macros to ogr_core.h for ogr_api.h
00102  *
00103  * Revision 1.26  2002/06/25 14:45:50  warmerda
00104  * added RegisterOGRFME()
00105  *
00106  * Revision 1.25  2002/04/25 03:42:04  warmerda
00107  * fixed spatial filter support on SQL results
00108  *
00109  * Revision 1.24  2002/04/25 02:24:13  warmerda
00110  * added ExecuteSWQ() method
00111  *
00112  * Revision 1.23  2002/02/18 20:56:24  warmerda
00113  * added AVC registration
00114  *
00115  * Revision 1.22  2002/01/25 20:47:58  warmerda
00116  * added GML registration
00117  *
00118  * Revision 1.21  2001/11/15 21:19:21  warmerda
00119  * added transaction semantics
00120  *
00121  * Revision 1.20  2001/06/19 15:50:23  warmerda
00122  * added feature attribute query support
00123  *
00124  * Revision 1.19  2001/03/15 04:01:43  danmo
00125  * Added OGRLayer::GetExtent()
00126  *
00127  * Revision 1.18  2001/02/06 17:10:28  warmerda
00128  * export entry points from DLL
00129  *
00130  * Revision 1.17  2001/01/19 21:13:50  warmerda
00131  * expanded tabs
00132  *
00133  * Revision 1.16  2000/11/28 19:00:32  warmerda
00134  * added RegisterOGRDGN
00135  *
00136  * Revision 1.15  2000/10/17 17:54:53  warmerda
00137  * added postgresql support
00138  *
00139  * Revision 1.14  2000/08/24 04:44:05  danmo
00140  * Added optional OGDI driver in OGR
00141  *
00142  * Revision 1.13  2000/08/18 21:52:53  svillene
00143  * Add OGR Representation
00144  *
00145  * Revision 1.12  1999/11/14 18:13:08  svillene
00146  * add RegisterOGRTAB RegisterOGRMIF
00147  *
00148  * Revision 1.11  1999/11/04 21:09:40  warmerda
00149  * Made a bunch of changes related to supporting creation of new
00150  * layers and data sources.
00151  *
00152  * Revision 1.10  1999/10/06 19:02:43  warmerda
00153  * Added tiger registration.
00154  *
00155  * Revision 1.9  1999/09/22 03:05:08  warmerda
00156  * added SDTS
00157  *
00158  * Revision 1.8  1999/09/09 21:04:55  warmerda
00159  * added fme support
00160  *
00161  * Revision 1.7  1999/08/28 03:12:43  warmerda
00162  * Added NTF.
00163  *
00164  * Revision 1.6  1999/07/27 00:50:39  warmerda
00165  * added a number of OGRLayer methods
00166  *
00167  * Revision 1.5  1999/07/26 13:59:05  warmerda
00168  * added feature writing api
00169  *
00170  * Revision 1.4  1999/07/21 13:23:27  warmerda
00171  * Fixed multiple inclusion protection.
00172  *
00173  * Revision 1.3  1999/07/08 20:04:58  warmerda
00174  * added GetFeatureCount
00175  *
00176  * Revision 1.2  1999/07/06 20:25:09  warmerda
00177  * added some documentation
00178  *
00179  * Revision 1.1  1999/07/05 18:59:00  warmerda
00180  * new
00181  *
00182  */
00183 
00184 #ifndef _OGRSF_FRMTS_H_INCLUDED
00185 #define _OGRSF_FRMTS_H_INCLUDED
00186 
00187 #include "ogr_feature.h"
00188 
00195 class OGRLayerAttrIndex;
00196 
00197 /************************************************************************/
00198 /*                               OGRLayer                               */
00199 /************************************************************************/
00200 
00206 class CPL_DLL OGRLayer
00207 {
00208   protected:
00209     int          m_bFilterIsEnvelope;
00210     OGRGeometry  *m_poFilterGeom;
00211     OGREnvelope  m_sFilterEnvelope;
00212 
00213     int          FilterGeometry( OGRGeometry * );
00214     int          InstallFilter( OGRGeometry * );
00215 
00216   public:
00217     OGRLayer();
00218     virtual     ~OGRLayer();
00219 
00220     virtual OGRGeometry *GetSpatialFilter();
00221     virtual void        SetSpatialFilter( OGRGeometry * );
00222     virtual void        SetSpatialFilterRect( double dfMinX, double dfMinY,
00223                                               double dfMaxX, double dfMaxY );
00224 
00225     virtual OGRErr      SetAttributeFilter( const char * );
00226 
00227     virtual void        ResetReading() = 0;
00228     virtual OGRFeature *GetNextFeature() = 0;
00229     virtual OGRErr      SetNextByIndex( long nIndex );
00230     virtual OGRFeature *GetFeature( long nFID );
00231     virtual OGRErr      SetFeature( OGRFeature *poFeature );
00232     virtual OGRErr      CreateFeature( OGRFeature *poFeature );
00233     virtual OGRErr      DeleteFeature( long nFID );
00234 
00235     virtual OGRFeatureDefn *GetLayerDefn() = 0;
00236 
00237     virtual OGRSpatialReference *GetSpatialRef() { return NULL; }
00238 
00239     virtual int         GetFeatureCount( int bForce = TRUE );
00240     virtual OGRErr      GetExtent(OGREnvelope *psExtent, int bForce = TRUE);
00241 
00242     virtual int         TestCapability( const char * ) = 0;
00243 
00244     virtual const char *GetInfo( const char * );
00245 
00246     virtual OGRErr      CreateField( OGRFieldDefn *poField,
00247                                      int bApproxOK = TRUE );
00248 
00249     virtual OGRErr      SyncToDisk();
00250 
00251     OGRStyleTable       *GetStyleTable(){return m_poStyleTable;}
00252     void                 SetStyleTable(OGRStyleTable *poStyleTable){m_poStyleTable = poStyleTable;}
00253 
00254     virtual OGRErr       StartTransaction();
00255     virtual OGRErr       CommitTransaction();
00256     virtual OGRErr       RollbackTransaction();
00257 
00258     int                 Reference();
00259     int                 Dereference();
00260     int                 GetRefCount() const;
00261 
00262     GIntBig             GetFeaturesRead();
00263     
00264     /* consider these private */
00265     OGRErr               InitializeIndexSupport( const char * );
00266     OGRLayerAttrIndex   *GetIndex() { return m_poAttrIndex; }
00267 
00268  protected:
00269     OGRStyleTable       *m_poStyleTable;
00270     OGRFeatureQuery     *m_poAttrQuery;
00271     OGRLayerAttrIndex   *m_poAttrIndex;
00272 
00273     int                  m_nRefCount;
00274 
00275     GIntBig              m_nFeaturesRead;
00276 };
00277 
00278 
00279 /************************************************************************/
00280 /*                            OGRDataSource                             */
00281 /************************************************************************/
00282 
00293 class CPL_DLL OGRDataSource
00294 {
00295   public:
00296 
00297     OGRDataSource();
00298     virtual     ~OGRDataSource();
00299     static void         DestroyDataSource( OGRDataSource * );
00300 
00301     virtual const char  *GetName() = 0;
00302 
00303     virtual int         GetLayerCount() = 0;
00304     virtual OGRLayer    *GetLayer(int) = 0;
00305     virtual OGRLayer    *GetLayerByName(const char *);
00306     virtual OGRErr      DeleteLayer(int);
00307 
00308     virtual int         TestCapability( const char * ) = 0;
00309 
00310     virtual OGRLayer   *CreateLayer( const char *pszName, 
00311                                      OGRSpatialReference *poSpatialRef = NULL,
00312                                      OGRwkbGeometryType eGType = wkbUnknown,
00313                                      char ** papszOptions = NULL );
00314     virtual OGRLayer   *CopyLayer( OGRLayer *poSrcLayer, 
00315                                    const char *pszNewName, 
00316                                    char **papszOptions = NULL );
00317     OGRStyleTable       *GetStyleTable(){return m_poStyleTable;}
00318 
00319     virtual OGRLayer *  ExecuteSQL( const char *pszStatement,
00320                                     OGRGeometry *poSpatialFilter,
00321                                     const char *pszDialect );
00322     virtual void        ReleaseResultSet( OGRLayer * poResultsSet );
00323 
00324     virtual OGRErr      SyncToDisk();
00325 
00326     int                 Reference();
00327     int                 Dereference();
00328     int                 GetRefCount() const;
00329     int                 GetSummaryRefCount() const;
00330     OGRErr              Release();
00331 
00332   protected:
00333 
00334     OGRErr              ProcessSQLCreateIndex( const char * );
00335     OGRErr              ProcessSQLDropIndex( const char * );
00336 
00337     OGRStyleTable      *m_poStyleTable;
00338     int                 m_nRefCount;
00339 };
00340 
00341 /************************************************************************/
00342 /*                             OGRSFDriver                              */
00343 /************************************************************************/
00344 
00354 class CPL_DLL OGRSFDriver
00355 {
00356   public:
00357     virtual     ~OGRSFDriver();
00358 
00359     virtual const char  *GetName() = 0;
00360 
00361     virtual OGRDataSource *Open( const char *pszName, int bUpdate=FALSE ) = 0;
00362 
00363     virtual int         TestCapability( const char * ) = 0;
00364 
00365     virtual OGRDataSource *CreateDataSource( const char *pszName,
00366                                              char ** = NULL );
00367     virtual OGRErr      DeleteDataSource( const char *pszName );
00368 
00369     virtual OGRDataSource *CopyDataSource( OGRDataSource *poSrcDS, 
00370                                            const char *pszNewName, 
00371                                            char **papszOptions = NULL );
00372 };
00373 
00374 
00375 /************************************************************************/
00376 /*                         OGRSFDriverRegistrar                         */
00377 /************************************************************************/
00378 
00384 class CPL_DLL OGRSFDriverRegistrar
00385 {
00386     int         nDrivers;
00387     OGRSFDriver **papoDrivers;
00388 
00389                 OGRSFDriverRegistrar();
00390 
00391     int         nOpenDSCount;
00392     char        **papszOpenDSRawName;
00393     OGRDataSource **papoOpenDS;
00394     OGRSFDriver **papoOpenDSDriver;
00395 
00396   public:
00397 
00398                 ~OGRSFDriverRegistrar();
00399 
00400     static OGRSFDriverRegistrar *GetRegistrar();
00401     static OGRDataSource *Open( const char *pszName, int bUpdate=FALSE,
00402                                 OGRSFDriver ** ppoDriver = NULL );
00403 
00404     OGRDataSource *OpenShared( const char *pszName, int bUpdate=FALSE,
00405                                OGRSFDriver ** ppoDriver = NULL );
00406     OGRErr      ReleaseDataSource( OGRDataSource * );
00407 
00408     void        RegisterDriver( OGRSFDriver * poDriver );
00409 
00410     int         GetDriverCount( void );
00411     OGRSFDriver *GetDriver( int iDriver );
00412     OGRSFDriver *GetDriverByName( const char * );
00413 
00414     int         GetOpenDSCount() { return nOpenDSCount; } 
00415     OGRDataSource *GetOpenDS( int );
00416 
00417     void        AutoLoadDrivers();
00418 };
00419 
00420 /* -------------------------------------------------------------------- */
00421 /*      Various available registration methods.                         */
00422 /* -------------------------------------------------------------------- */
00423 CPL_C_START
00424 void CPL_DLL OGRRegisterAll();
00425 
00426 void CPL_DLL RegisterOGRShape();
00427 void CPL_DLL RegisterOGRNTF();
00428 void CPL_DLL RegisterOGRFME();
00429 void CPL_DLL RegisterOGRSDTS();
00430 void CPL_DLL RegisterOGRTiger();
00431 void CPL_DLL RegisterOGRS57();
00432 void CPL_DLL RegisterOGRTAB();
00433 void CPL_DLL RegisterOGRMIF();
00434 void CPL_DLL RegisterOGROGDI();
00435 void CPL_DLL RegisterOGRODBC();
00436 void CPL_DLL RegisterOGRPG();
00437 void CPL_DLL RegisterOGRMySQL();
00438 void CPL_DLL RegisterOGROCI();
00439 void CPL_DLL RegisterOGRDGN();
00440 void CPL_DLL RegisterOGRGML();
00441 void CPL_DLL RegisterOGRAVCBin();
00442 void CPL_DLL RegisterOGRAVCE00();
00443 void CPL_DLL RegisterOGRFME();
00444 void CPL_DLL RegisterOGRREC();
00445 void CPL_DLL RegisterOGRMEM();
00446 void CPL_DLL RegisterOGRVRT();
00447 void CPL_DLL RegisterOGRDODS();
00448 void CPL_DLL RegisterOGRSQLite();
00449 void CPL_DLL RegisterOGRCSV();
00450 
00451 CPL_C_END
00452 
00453 
00454 #endif /* ndef _OGRSF_FRMTS_H_INCLUDED */

Generated on Mon Jan 9 18:03:31 2006 for OGR by  doxygen 1.4.6