ogrsf_frmts.h

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

Generated on Sun Jul 2 22:18:21 2006 for OGR by  doxygen 1.4.6