Statistics
| Revision:

root / trunk / libraries / libjni-gdal / include / ogrsf_frmts.h @ 879

History | View | Annotate | Download (13.1 KB)

1
/******************************************************************************
2
 * $Id: ogrsf_frmts.h 879 2005-01-11 15:23:01Z igbrotru $
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.1  2005-01-11 15:23:01  igbrotru
32
 * *** empty log message ***
33
 *
34
 * Revision 1.44  2004/07/20 19:18:44  warmerda
35
 * added CSV
36
 *
37
 * Revision 1.43  2004/07/10 05:03:24  warmerda
38
 * added SQLite
39
 *
40
 * Revision 1.42  2004/02/11 18:03:15  warmerda
41
 * added RegisterOGRDODS()
42
 *
43
 * Revision 1.41  2003/11/06 18:27:35  warmerda
44
 * Added VRT registration point
45
 *
46
 * Revision 1.40  2003/10/09 15:28:07  warmerda
47
 * added OGRLayer::DeleteFeature() support
48
 *
49
 * Revision 1.39  2003/10/06 19:15:40  warmerda
50
 * added ODBC support
51
 *
52
 * Revision 1.38  2003/05/28 19:17:31  warmerda
53
 * fixup stuff for docs
54
 *
55
 * Revision 1.37  2003/04/22 19:36:04  warmerda
56
 * Added SyncToDisk
57
 *
58
 * Revision 1.36  2003/04/08 21:21:29  warmerda
59
 * added OGRGetDriverByName
60
 *
61
 * Revision 1.35  2003/04/08 19:31:32  warmerda
62
 * added CopyLayer and CopyDataSource entry points
63
 *
64
 * Revision 1.34  2003/03/20 20:21:48  warmerda
65
 * added drop index
66
 *
67
 * Revision 1.33  2003/03/19 20:29:06  warmerda
68
 * added shared access and reference counting
69
 *
70
 * Revision 1.32  2003/03/05 05:09:11  warmerda
71
 * added GetLayerByName() method on OGRDataSource
72
 *
73
 * Revision 1.31  2003/03/04 05:47:23  warmerda
74
 * added indexing support
75
 *
76
 * Revision 1.30  2003/03/03 05:06:08  warmerda
77
 * added support for DeleteDataSource and DeleteLayer
78
 *
79
 * Revision 1.29  2003/02/03 21:16:49  warmerda
80
 * added .rec driver
81
 *
82
 * Revision 1.28  2002/12/28 04:09:18  warmerda
83
 * added Oracle support
84
 *
85
 * Revision 1.27  2002/09/26 18:15:31  warmerda
86
 * moved capabilities macros to ogr_core.h for ogr_api.h
87
 *
88
 * Revision 1.26  2002/06/25 14:45:50  warmerda
89
 * added RegisterOGRFME()
90
 *
91
 * Revision 1.25  2002/04/25 03:42:04  warmerda
92
 * fixed spatial filter support on SQL results
93
 *
94
 * Revision 1.24  2002/04/25 02:24:13  warmerda
95
 * added ExecuteSWQ() method
96
 *
97
 * Revision 1.23  2002/02/18 20:56:24  warmerda
98
 * added AVC registration
99
 *
100
 * Revision 1.22  2002/01/25 20:47:58  warmerda
101
 * added GML registration
102
 *
103
 * Revision 1.21  2001/11/15 21:19:21  warmerda
104
 * added transaction semantics
105
 *
106
 * Revision 1.20  2001/06/19 15:50:23  warmerda
107
 * added feature attribute query support
108
 *
109
 * Revision 1.19  2001/03/15 04:01:43  danmo
110
 * Added OGRLayer::GetExtent()
111
 *
112
 * Revision 1.18  2001/02/06 17:10:28  warmerda
113
 * export entry points from DLL
114
 *
115
 * Revision 1.17  2001/01/19 21:13:50  warmerda
116
 * expanded tabs
117
 *
118
 * Revision 1.16  2000/11/28 19:00:32  warmerda
119
 * added RegisterOGRDGN
120
 *
121
 * Revision 1.15  2000/10/17 17:54:53  warmerda
122
 * added postgresql support
123
 *
124
 * Revision 1.14  2000/08/24 04:44:05  danmo
125
 * Added optional OGDI driver in OGR
126
 *
127
 * Revision 1.13  2000/08/18 21:52:53  svillene
128
 * Add OGR Representation
129
 *
130
 * Revision 1.12  1999/11/14 18:13:08  svillene
131
 * add RegisterOGRTAB RegisterOGRMIF
132
 *
133
 * Revision 1.11  1999/11/04 21:09:40  warmerda
134
 * Made a bunch of changes related to supporting creation of new
135
 * layers and data sources.
136
 *
137
 * Revision 1.10  1999/10/06 19:02:43  warmerda
138
 * Added tiger registration.
139
 *
140
 * Revision 1.9  1999/09/22 03:05:08  warmerda
141
 * added SDTS
142
 *
143
 * Revision 1.8  1999/09/09 21:04:55  warmerda
144
 * added fme support
145
 *
146
 * Revision 1.7  1999/08/28 03:12:43  warmerda
147
 * Added NTF.
148
 *
149
 * Revision 1.6  1999/07/27 00:50:39  warmerda
150
 * added a number of OGRLayer methods
151
 *
152
 * Revision 1.5  1999/07/26 13:59:05  warmerda
153
 * added feature writing api
154
 *
155
 * Revision 1.4  1999/07/21 13:23:27  warmerda
156
 * Fixed multiple inclusion protection.
157
 *
158
 * Revision 1.3  1999/07/08 20:04:58  warmerda
159
 * added GetFeatureCount
160
 *
161
 * Revision 1.2  1999/07/06 20:25:09  warmerda
162
 * added some documentation
163
 *
164
 * Revision 1.1  1999/07/05 18:59:00  warmerda
165
 * new
166
 *
167
 */
168

    
169
#ifndef _OGRSF_FRMTS_H_INCLUDED
170
#define _OGRSF_FRMTS_H_INCLUDED
171

    
172
#include "ogr_feature.h"
173

    
174
/**
175
 * \file ogrsf_frmts.h
176
 *
177
 * Classes related to registration of format support, and opening datasets.
178
 */
179

    
180
class OGRLayerAttrIndex;
181

    
182
/************************************************************************/
183
/*                               OGRLayer                               */
184
/************************************************************************/
185

    
186
/**
187
 * This class represents a layer of simple features, with access methods.
188
 *
189
 */
190

    
191
class CPL_DLL OGRLayer
192
{
193
  public:
194
                OGRLayer();
195
    virtual     ~OGRLayer();
196

    
197
    virtual OGRGeometry *GetSpatialFilter() = 0;
198
    virtual void        SetSpatialFilter( OGRGeometry * ) = 0;
199

    
200
    virtual OGRErr      SetAttributeFilter( const char * );
201

    
202
    virtual void        ResetReading() = 0;
203
    virtual OGRFeature *GetNextFeature() = 0;
204
    virtual OGRFeature *GetFeature( long nFID );
205
    virtual OGRErr      SetFeature( OGRFeature *poFeature );
206
    virtual OGRErr      CreateFeature( OGRFeature *poFeature );
207
    virtual OGRErr      DeleteFeature( long nFID );
208

    
209
    virtual OGRFeatureDefn *GetLayerDefn() = 0;
210

    
211
    virtual OGRSpatialReference *GetSpatialRef() { return NULL; }
212

    
213
    virtual int         GetFeatureCount( int bForce = TRUE );
214
    virtual OGRErr      GetExtent(OGREnvelope *psExtent, int bForce = TRUE);
215

    
216
    virtual int         TestCapability( const char * ) = 0;
217

    
218
    virtual const char *GetInfo( const char * );
219

    
220
    virtual OGRErr      CreateField( OGRFieldDefn *poField,
221
                                     int bApproxOK = TRUE );
222

    
223
    virtual OGRErr      SyncToDisk();
224

    
225
    OGRStyleTable       *GetStyleTable(){return m_poStyleTable;}
226
    void                 SetStyleTable(OGRStyleTable *poStyleTable){m_poStyleTable = poStyleTable;}
227

    
228
    virtual OGRErr       StartTransaction();
229
    virtual OGRErr       CommitTransaction();
230
    virtual OGRErr       RollbackTransaction();
231

    
232
    int                 Reference();
233
    int                 Dereference();
234
    int                 GetRefCount() const;
235
    
236
    /* consider these private */
237
    OGRErr               InitializeIndexSupport( const char * );
238
    OGRLayerAttrIndex   *GetIndex() { return m_poAttrIndex; }
239

    
240
 protected:
241
    OGRStyleTable       *m_poStyleTable;
242
    OGRFeatureQuery     *m_poAttrQuery;
243
    OGRLayerAttrIndex   *m_poAttrIndex;
244

    
245
    int                  m_nRefCount;
246
};
247

    
248

    
249
/************************************************************************/
250
/*                            OGRDataSource                             */
251
/************************************************************************/
252

    
253
/**
254
 * This class represents a data source.  A data source potentially
255
 * consists of many layers (OGRLayer).  A data source normally consists
256
 * of one, or a related set of files, though the name doesn't have to be
257
 * a real item in the file system.
258
 *
259
 * When an OGRDataSource is destroyed, all it's associated OGRLayers objects
260
 * are also destroyed.
261
 */ 
262

    
263
class CPL_DLL OGRDataSource
264
{
265
  public:
266

    
267
    OGRDataSource();
268
    virtual     ~OGRDataSource();
269

    
270
    virtual const char  *GetName() = 0;
271

    
272
    virtual int         GetLayerCount() = 0;
273
    virtual OGRLayer    *GetLayer(int) = 0;
274
    virtual OGRLayer    *GetLayerByName(const char *);
275
    virtual OGRErr      DeleteLayer(int);
276

    
277
    virtual int         TestCapability( const char * ) = 0;
278

    
279
    virtual OGRLayer   *CreateLayer( const char *pszName, 
280
                                     OGRSpatialReference *poSpatialRef = NULL,
281
                                     OGRwkbGeometryType eGType = wkbUnknown,
282
                                     char ** papszOptions = NULL );
283
    virtual OGRLayer   *CopyLayer( OGRLayer *poSrcLayer, 
284
                                   const char *pszNewName, 
285
                                   char **papszOptions = NULL );
286
    OGRStyleTable       *GetStyleTable(){return m_poStyleTable;}
287

    
288
    virtual OGRLayer *  ExecuteSQL( const char *pszStatement,
289
                                    OGRGeometry *poSpatialFilter,
290
                                    const char *pszDialect );
291
    virtual void        ReleaseResultSet( OGRLayer * poResultsSet );
292

    
293
    virtual OGRErr      SyncToDisk();
294

    
295
    int                 Reference();
296
    int                 Dereference();
297
    int                 GetRefCount() const;
298
    int                 GetSummaryRefCount() const;
299

    
300
  protected:
301

    
302
    OGRErr              ProcessSQLCreateIndex( const char * );
303
    OGRErr              ProcessSQLDropIndex( const char * );
304

    
305
    OGRStyleTable      *m_poStyleTable;
306
    int                 m_nRefCount;
307
};
308

    
309
/************************************************************************/
310
/*                             OGRSFDriver                              */
311
/************************************************************************/
312

    
313
/**
314
 * Represents an operational format driver.
315
 *
316
 * One OGRSFDriver derived class will normally exist for each file format
317
 * registered for use, regardless of whether a file has or will be opened.
318
 * The list of available drivers is normally managed by the
319
 * OGRSFDriverRegistrar.
320
 */
321

    
322
class CPL_DLL OGRSFDriver
323
{
324
  public:
325
    virtual     ~OGRSFDriver();
326

    
327
    virtual const char  *GetName() = 0;
328

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

    
331
    virtual int         TestCapability( const char * ) = 0;
332

    
333
    virtual OGRDataSource *CreateDataSource( const char *pszName,
334
                                             char ** = NULL );
335
    virtual OGRErr      DeleteDataSource( const char *pszName );
336

    
337
    virtual OGRDataSource *CopyDataSource( OGRDataSource *poSrcDS, 
338
                                           const char *pszNewName, 
339
                                           char **papszOptions = NULL );
340
};
341

    
342

    
343
/************************************************************************/
344
/*                         OGRSFDriverRegistrar                         */
345
/************************************************************************/
346

    
347
/**
348
 * Singleton manager for drivers.
349
 *
350
 */
351

    
352
class CPL_DLL OGRSFDriverRegistrar
353
{
354
    int         nDrivers;
355
    OGRSFDriver **papoDrivers;
356

    
357
                OGRSFDriverRegistrar();
358

    
359
    int         nOpenDSCount;
360
    char        **papszOpenDSRawName;
361
    OGRDataSource **papoOpenDS;
362
    OGRSFDriver **papoOpenDSDriver;
363

    
364
  public:
365

    
366
                ~OGRSFDriverRegistrar();
367

    
368
    static OGRSFDriverRegistrar *GetRegistrar();
369
    static OGRDataSource *Open( const char *pszName, int bUpdate=FALSE,
370
                                OGRSFDriver ** ppoDriver = NULL );
371

    
372
    OGRDataSource *OpenShared( const char *pszName, int bUpdate=FALSE,
373
                               OGRSFDriver ** ppoDriver = NULL );
374
    OGRErr      ReleaseDataSource( OGRDataSource * );
375

    
376
    void        RegisterDriver( OGRSFDriver * poDriver );
377

    
378
    int         GetDriverCount( void );
379
    OGRSFDriver *GetDriver( int iDriver );
380
    OGRSFDriver *GetDriverByName( const char * );
381

    
382
    int         GetOpenDSCount() { return nOpenDSCount; } 
383
    OGRDataSource *GetOpenDS( int );
384
};
385

    
386
/* -------------------------------------------------------------------- */
387
/*      Various available registration methods.                         */
388
/* -------------------------------------------------------------------- */
389
CPL_C_START
390
void CPL_DLL OGRRegisterAll();
391

    
392
void CPL_DLL RegisterOGRShape();
393
void CPL_DLL RegisterOGRNTF();
394
void CPL_DLL RegisterOGRFME();
395
void CPL_DLL RegisterOGRSDTS();
396
void CPL_DLL RegisterOGRTiger();
397
void CPL_DLL RegisterOGRS57();
398
void CPL_DLL RegisterOGRTAB();
399
void CPL_DLL RegisterOGRMIF();
400
void CPL_DLL RegisterOGROGDI();
401
void CPL_DLL RegisterOGRODBC();
402
void CPL_DLL RegisterOGRPG();
403
void CPL_DLL RegisterOGROCI();
404
void CPL_DLL RegisterOGRDGN();
405
void CPL_DLL RegisterOGRGML();
406
void CPL_DLL RegisterOGRAVCBin();
407
void CPL_DLL RegisterOGRAVCE00();
408
void CPL_DLL RegisterOGRFME();
409
void CPL_DLL RegisterOGRREC();
410
void CPL_DLL RegisterOGRMEM();
411
void CPL_DLL RegisterOGRVRT();
412
void CPL_DLL RegisterOGRDODS();
413
void CPL_DLL RegisterOGRSQLite();
414
void CPL_DLL RegisterOGRCSV();
415

    
416
CPL_C_END
417

    
418

    
419
#endif /* ndef _OGRSF_FRMTS_H_INCLUDED */