Statistics
| Revision:

svn-gvsig-desktop / tags / v10_RC2c / libraries / libjni-gdal / include / ogrsf_frmts.h @ 8745

History | View | Annotate | Download (13.5 KB)

1
/******************************************************************************
2
 * $Id: ogrsf_frmts.h 8745 2006-11-14 13:14:23Z  $
3
 *
4
 * Project:  OpenGIS Simple Features Reference Implementation
5
 * Purpose:  Classes related to format registration, and file opening.
6
 * Author:   Frank Warmerdam, warmerda@home.com
7
 *
8
 ******************************************************************************
9
 * Copyright (c) 1999,  Les Technologies SoftMap Inc.
10
 *
11
 * Permission is hereby granted, free of charge, to any person obtaining a
12
 * copy of this software and associated documentation files (the "Software"),
13
 * to deal in the Software without restriction, including without limitation
14
 * the rights to use, copy, modify, merge, publish, distribute, sublicense,
15
 * and/or sell copies of the Software, and to permit persons to whom the
16
 * Software is furnished to do so, subject to the following conditions:
17
 *
18
 * The above copyright notice and this permission notice shall be included
19
 * in all copies or substantial portions of the Software.
20
 *
21
 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
22
 * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
23
 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
24
 * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
25
 * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
26
 * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
27
 * DEALINGS IN THE SOFTWARE.
28
 ******************************************************************************
29
 *
30
 * $Log$
31
 * Revision 1.2.10.1  2006-10-04 06:55:46  nacho
32
 * *** empty log message ***
33
 *
34
 * Revision 1.3  2006/10/03 07:05:18  nacho
35
 * *** empty log message ***
36
 *
37
 * Revision 1.1  2006/07/18 16:21:00  nacho
38
 * *** empty log message ***
39
 *
40
 * Revision 1.1  2006/06/29 16:23:27  nacho
41
 * *** empty log message ***
42
 *
43
 * Revision 1.2  2006/01/09 12:50:13  nacho
44
 * *** empty log message ***
45
 *
46
 * Revision 1.1  2005/07/27 08:22:55  igbrotru
47
 * *** empty log message ***
48
 *
49
 * Revision 1.1  2005/01/11 15:23:01  igbrotru
50
 * *** empty log message ***
51
 *
52
 * Revision 1.44  2004/07/20 19:18:44  warmerda
53
 * added CSV
54
 *
55
 * Revision 1.43  2004/07/10 05:03:24  warmerda
56
 * added SQLite
57
 *
58
 * Revision 1.42  2004/02/11 18:03:15  warmerda
59
 * added RegisterOGRDODS()
60
 *
61
 * Revision 1.41  2003/11/06 18:27:35  warmerda
62
 * Added VRT registration point
63
 *
64
 * Revision 1.40  2003/10/09 15:28:07  warmerda
65
 * added OGRLayer::DeleteFeature() support
66
 *
67
 * Revision 1.39  2003/10/06 19:15:40  warmerda
68
 * added ODBC support
69
 *
70
 * Revision 1.38  2003/05/28 19:17:31  warmerda
71
 * fixup stuff for docs
72
 *
73
 * Revision 1.37  2003/04/22 19:36:04  warmerda
74
 * Added SyncToDisk
75
 *
76
 * Revision 1.36  2003/04/08 21:21:29  warmerda
77
 * added OGRGetDriverByName
78
 *
79
 * Revision 1.35  2003/04/08 19:31:32  warmerda
80
 * added CopyLayer and CopyDataSource entry points
81
 *
82
 * Revision 1.34  2003/03/20 20:21:48  warmerda
83
 * added drop index
84
 *
85
 * Revision 1.33  2003/03/19 20:29:06  warmerda
86
 * added shared access and reference counting
87
 *
88
 * Revision 1.32  2003/03/05 05:09:11  warmerda
89
 * added GetLayerByName() method on OGRDataSource
90
 *
91
 * Revision 1.31  2003/03/04 05:47:23  warmerda
92
 * added indexing support
93
 *
94
 * Revision 1.30  2003/03/03 05:06:08  warmerda
95
 * added support for DeleteDataSource and DeleteLayer
96
 *
97
 * Revision 1.29  2003/02/03 21:16:49  warmerda
98
 * added .rec driver
99
 *
100
 * Revision 1.28  2002/12/28 04:09:18  warmerda
101
 * added Oracle support
102
 *
103
 * Revision 1.27  2002/09/26 18:15:31  warmerda
104
 * moved capabilities macros to ogr_core.h for ogr_api.h
105
 *
106
 * Revision 1.26  2002/06/25 14:45:50  warmerda
107
 * added RegisterOGRFME()
108
 *
109
 * Revision 1.25  2002/04/25 03:42:04  warmerda
110
 * fixed spatial filter support on SQL results
111
 *
112
 * Revision 1.24  2002/04/25 02:24:13  warmerda
113
 * added ExecuteSWQ() method
114
 *
115
 * Revision 1.23  2002/02/18 20:56:24  warmerda
116
 * added AVC registration
117
 *
118
 * Revision 1.22  2002/01/25 20:47:58  warmerda
119
 * added GML registration
120
 *
121
 * Revision 1.21  2001/11/15 21:19:21  warmerda
122
 * added transaction semantics
123
 *
124
 * Revision 1.20  2001/06/19 15:50:23  warmerda
125
 * added feature attribute query support
126
 *
127
 * Revision 1.19  2001/03/15 04:01:43  danmo
128
 * Added OGRLayer::GetExtent()
129
 *
130
 * Revision 1.18  2001/02/06 17:10:28  warmerda
131
 * export entry points from DLL
132
 *
133
 * Revision 1.17  2001/01/19 21:13:50  warmerda
134
 * expanded tabs
135
 *
136
 * Revision 1.16  2000/11/28 19:00:32  warmerda
137
 * added RegisterOGRDGN
138
 *
139
 * Revision 1.15  2000/10/17 17:54:53  warmerda
140
 * added postgresql support
141
 *
142
 * Revision 1.14  2000/08/24 04:44:05  danmo
143
 * Added optional OGDI driver in OGR
144
 *
145
 * Revision 1.13  2000/08/18 21:52:53  svillene
146
 * Add OGR Representation
147
 *
148
 * Revision 1.12  1999/11/14 18:13:08  svillene
149
 * add RegisterOGRTAB RegisterOGRMIF
150
 *
151
 * Revision 1.11  1999/11/04 21:09:40  warmerda
152
 * Made a bunch of changes related to supporting creation of new
153
 * layers and data sources.
154
 *
155
 * Revision 1.10  1999/10/06 19:02:43  warmerda
156
 * Added tiger registration.
157
 *
158
 * Revision 1.9  1999/09/22 03:05:08  warmerda
159
 * added SDTS
160
 *
161
 * Revision 1.8  1999/09/09 21:04:55  warmerda
162
 * added fme support
163
 *
164
 * Revision 1.7  1999/08/28 03:12:43  warmerda
165
 * Added NTF.
166
 *
167
 * Revision 1.6  1999/07/27 00:50:39  warmerda
168
 * added a number of OGRLayer methods
169
 *
170
 * Revision 1.5  1999/07/26 13:59:05  warmerda
171
 * added feature writing api
172
 *
173
 * Revision 1.4  1999/07/21 13:23:27  warmerda
174
 * Fixed multiple inclusion protection.
175
 *
176
 * Revision 1.3  1999/07/08 20:04:58  warmerda
177
 * added GetFeatureCount
178
 *
179
 * Revision 1.2  1999/07/06 20:25:09  warmerda
180
 * added some documentation
181
 *
182
 * Revision 1.1  1999/07/05 18:59:00  warmerda
183
 * new
184
 *
185
 */
186

    
187
#ifndef _OGRSF_FRMTS_H_INCLUDED
188
#define _OGRSF_FRMTS_H_INCLUDED
189

    
190
#include "ogr_feature.h"
191

    
192
/**
193
 * \file ogrsf_frmts.h
194
 *
195
 * Classes related to registration of format support, and opening datasets.
196
 */
197

    
198
class OGRLayerAttrIndex;
199

    
200
/************************************************************************/
201
/*                               OGRLayer                               */
202
/************************************************************************/
203

    
204
/**
205
 * This class represents a layer of simple features, with access methods.
206
 *
207
 */
208

    
209
class CPL_DLL OGRLayer
210
{
211
  public:
212
                OGRLayer();
213
    virtual     ~OGRLayer();
214

    
215
    virtual OGRGeometry *GetSpatialFilter() = 0;
216
    virtual void        SetSpatialFilter( OGRGeometry * ) = 0;
217

    
218
    virtual OGRErr      SetAttributeFilter( const char * );
219

    
220
    virtual void        ResetReading() = 0;
221
    virtual OGRFeature *GetNextFeature() = 0;
222
    virtual OGRFeature *GetFeature( long nFID );
223
    virtual OGRErr      SetFeature( OGRFeature *poFeature );
224
    virtual OGRErr      CreateFeature( OGRFeature *poFeature );
225
    virtual OGRErr      DeleteFeature( long nFID );
226

    
227
    virtual OGRFeatureDefn *GetLayerDefn() = 0;
228

    
229
    virtual OGRSpatialReference *GetSpatialRef() { return NULL; }
230

    
231
    virtual int         GetFeatureCount( int bForce = TRUE );
232
    virtual OGRErr      GetExtent(OGREnvelope *psExtent, int bForce = TRUE);
233

    
234
    virtual int         TestCapability( const char * ) = 0;
235

    
236
    virtual const char *GetInfo( const char * );
237

    
238
    virtual OGRErr      CreateField( OGRFieldDefn *poField,
239
                                     int bApproxOK = TRUE );
240

    
241
    virtual OGRErr      SyncToDisk();
242

    
243
    OGRStyleTable       *GetStyleTable(){return m_poStyleTable;}
244
    void                 SetStyleTable(OGRStyleTable *poStyleTable){m_poStyleTable = poStyleTable;}
245

    
246
    virtual OGRErr       StartTransaction();
247
    virtual OGRErr       CommitTransaction();
248
    virtual OGRErr       RollbackTransaction();
249

    
250
    int                 Reference();
251
    int                 Dereference();
252
    int                 GetRefCount() const;
253
    
254
    /* consider these private */
255
    OGRErr               InitializeIndexSupport( const char * );
256
    OGRLayerAttrIndex   *GetIndex() { return m_poAttrIndex; }
257

    
258
 protected:
259
    OGRStyleTable       *m_poStyleTable;
260
    OGRFeatureQuery     *m_poAttrQuery;
261
    OGRLayerAttrIndex   *m_poAttrIndex;
262

    
263
    int                  m_nRefCount;
264
};
265

    
266

    
267
/************************************************************************/
268
/*                            OGRDataSource                             */
269
/************************************************************************/
270

    
271
/**
272
 * This class represents a data source.  A data source potentially
273
 * consists of many layers (OGRLayer).  A data source normally consists
274
 * of one, or a related set of files, though the name doesn't have to be
275
 * a real item in the file system.
276
 *
277
 * When an OGRDataSource is destroyed, all it's associated OGRLayers objects
278
 * are also destroyed.
279
 */ 
280

    
281
class CPL_DLL OGRDataSource
282
{
283
  public:
284

    
285
    OGRDataSource();
286
    virtual     ~OGRDataSource();
287

    
288
    virtual const char  *GetName() = 0;
289

    
290
    virtual int         GetLayerCount() = 0;
291
    virtual OGRLayer    *GetLayer(int) = 0;
292
    virtual OGRLayer    *GetLayerByName(const char *);
293
    virtual OGRErr      DeleteLayer(int);
294

    
295
    virtual int         TestCapability( const char * ) = 0;
296

    
297
    virtual OGRLayer   *CreateLayer( const char *pszName, 
298
                                     OGRSpatialReference *poSpatialRef = NULL,
299
                                     OGRwkbGeometryType eGType = wkbUnknown,
300
                                     char ** papszOptions = NULL );
301
    virtual OGRLayer   *CopyLayer( OGRLayer *poSrcLayer, 
302
                                   const char *pszNewName, 
303
                                   char **papszOptions = NULL );
304
    OGRStyleTable       *GetStyleTable(){return m_poStyleTable;}
305

    
306
    virtual OGRLayer *  ExecuteSQL( const char *pszStatement,
307
                                    OGRGeometry *poSpatialFilter,
308
                                    const char *pszDialect );
309
    virtual void        ReleaseResultSet( OGRLayer * poResultsSet );
310

    
311
    virtual OGRErr      SyncToDisk();
312

    
313
    int                 Reference();
314
    int                 Dereference();
315
    int                 GetRefCount() const;
316
    int                 GetSummaryRefCount() const;
317

    
318
  protected:
319

    
320
    OGRErr              ProcessSQLCreateIndex( const char * );
321
    OGRErr              ProcessSQLDropIndex( const char * );
322

    
323
    OGRStyleTable      *m_poStyleTable;
324
    int                 m_nRefCount;
325
};
326

    
327
/************************************************************************/
328
/*                             OGRSFDriver                              */
329
/************************************************************************/
330

    
331
/**
332
 * Represents an operational format driver.
333
 *
334
 * One OGRSFDriver derived class will normally exist for each file format
335
 * registered for use, regardless of whether a file has or will be opened.
336
 * The list of available drivers is normally managed by the
337
 * OGRSFDriverRegistrar.
338
 */
339

    
340
class CPL_DLL OGRSFDriver
341
{
342
  public:
343
    virtual     ~OGRSFDriver();
344

    
345
    virtual const char  *GetName() = 0;
346

    
347
    virtual OGRDataSource *Open( const char *pszName, int bUpdate=FALSE ) = 0;
348

    
349
    virtual int         TestCapability( const char * ) = 0;
350

    
351
    virtual OGRDataSource *CreateDataSource( const char *pszName,
352
                                             char ** = NULL );
353
    virtual OGRErr      DeleteDataSource( const char *pszName );
354

    
355
    virtual OGRDataSource *CopyDataSource( OGRDataSource *poSrcDS, 
356
                                           const char *pszNewName, 
357
                                           char **papszOptions = NULL );
358
};
359

    
360

    
361
/************************************************************************/
362
/*                         OGRSFDriverRegistrar                         */
363
/************************************************************************/
364

    
365
/**
366
 * Singleton manager for drivers.
367
 *
368
 */
369

    
370
class CPL_DLL OGRSFDriverRegistrar
371
{
372
    int         nDrivers;
373
    OGRSFDriver **papoDrivers;
374

    
375
                OGRSFDriverRegistrar();
376

    
377
    int         nOpenDSCount;
378
    char        **papszOpenDSRawName;
379
    OGRDataSource **papoOpenDS;
380
    OGRSFDriver **papoOpenDSDriver;
381

    
382
  public:
383

    
384
                ~OGRSFDriverRegistrar();
385

    
386
    static OGRSFDriverRegistrar *GetRegistrar();
387
    static OGRDataSource *Open( const char *pszName, int bUpdate=FALSE,
388
                                OGRSFDriver ** ppoDriver = NULL );
389

    
390
    OGRDataSource *OpenShared( const char *pszName, int bUpdate=FALSE,
391
                               OGRSFDriver ** ppoDriver = NULL );
392
    OGRErr      ReleaseDataSource( OGRDataSource * );
393

    
394
    void        RegisterDriver( OGRSFDriver * poDriver );
395

    
396
    int         GetDriverCount( void );
397
    OGRSFDriver *GetDriver( int iDriver );
398
    OGRSFDriver *GetDriverByName( const char * );
399

    
400
    int         GetOpenDSCount() { return nOpenDSCount; } 
401
    OGRDataSource *GetOpenDS( int );
402
};
403

    
404
/* -------------------------------------------------------------------- */
405
/*      Various available registration methods.                         */
406
/* -------------------------------------------------------------------- */
407
CPL_C_START
408
void CPL_DLL OGRRegisterAll();
409

    
410
void CPL_DLL RegisterOGRShape();
411
void CPL_DLL RegisterOGRNTF();
412
void CPL_DLL RegisterOGRFME();
413
void CPL_DLL RegisterOGRSDTS();
414
void CPL_DLL RegisterOGRTiger();
415
void CPL_DLL RegisterOGRS57();
416
void CPL_DLL RegisterOGRTAB();
417
void CPL_DLL RegisterOGRMIF();
418
void CPL_DLL RegisterOGROGDI();
419
void CPL_DLL RegisterOGRODBC();
420
void CPL_DLL RegisterOGRPG();
421
void CPL_DLL RegisterOGROCI();
422
void CPL_DLL RegisterOGRDGN();
423
void CPL_DLL RegisterOGRGML();
424
void CPL_DLL RegisterOGRAVCBin();
425
void CPL_DLL RegisterOGRAVCE00();
426
void CPL_DLL RegisterOGRFME();
427
void CPL_DLL RegisterOGRREC();
428
void CPL_DLL RegisterOGRMEM();
429
void CPL_DLL RegisterOGRVRT();
430
void CPL_DLL RegisterOGRDODS();
431
void CPL_DLL RegisterOGRSQLite();
432
void CPL_DLL RegisterOGRCSV();
433

    
434
CPL_C_END
435

    
436

    
437
#endif /* ndef _OGRSF_FRMTS_H_INCLUDED */