GDAL
ogrsf_frmts.h
Go to the documentation of this file.
1 /******************************************************************************
2  * $Id: ogrsf_frmts.h 4db9ec884a59751d80c7482f9f3d621ef3c640f6 2018-12-13 11:54:36 +0300 Dmitry Baryshnikov $
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  * Copyright (c) 2007-2014, Even Rouault <even dot rouault at mines-paris dot org>
11  *
12  * Permission is hereby granted, free of charge, to any person obtaining a
13  * copy of this software and associated documentation files (the "Software"),
14  * to deal in the Software without restriction, including without limitation
15  * the rights to use, copy, modify, merge, publish, distribute, sublicense,
16  * and/or sell copies of the Software, and to permit persons to whom the
17  * Software is furnished to do so, subject to the following conditions:
18  *
19  * The above copyright notice and this permission notice shall be included
20  * in all copies or substantial portions of the Software.
21  *
22  * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
23  * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
24  * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
25  * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
26  * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
27  * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
28  * DEALINGS IN THE SOFTWARE.
29  ****************************************************************************/
30 
31 #ifndef OGRSF_FRMTS_H_INCLUDED
32 #define OGRSF_FRMTS_H_INCLUDED
33 
34 #include "cpl_progress.h"
35 #include "ogr_feature.h"
36 #include "ogr_featurestyle.h"
37 #include "gdal_priv.h"
38 
39 #include <memory>
40 
47 #if !defined(GDAL_COMPILATION) && !defined(SUPPRESS_DEPRECATION_WARNINGS)
49 #define OGR_DEPRECATED(x) CPL_WARN_DEPRECATED(x)
50 #else
51 #define OGR_DEPRECATED(x)
52 #endif
53 
55 class OGRLayerAttrIndex;
56 class OGRSFDriver;
57 
58 /************************************************************************/
59 /* OGRLayer */
60 /************************************************************************/
61 
67 /* Note: any virtual method added to this class must also be added in the */
68 /* OGRLayerDecorator and OGRMutexedLayer classes. */
69 
70 class CPL_DLL OGRLayer : public GDALMajorObject
71 {
72  private:
73  struct Private;
74  std::unique_ptr<Private> m_poPrivate;
75 
76  void ConvertGeomsIfNecessary( OGRFeature *poFeature );
77 
78  class CPL_DLL FeatureIterator
79  {
80  struct Private;
81  std::unique_ptr<Private> m_poPrivate;
82  public:
83  FeatureIterator(OGRLayer* poLayer, bool bStart);
84  FeatureIterator(FeatureIterator&& oOther) noexcept; // declared but not defined. Needed for gcc 5.4 at least
85  ~FeatureIterator();
86  OGRFeatureUniquePtr& operator*();
87  FeatureIterator& operator++();
88  bool operator!=(const FeatureIterator& it) const;
89  };
90 
91  friend inline FeatureIterator begin(OGRLayer* poLayer);
92  friend inline FeatureIterator end(OGRLayer* poLayer);
93 
95 
96  protected:
98  int m_bFilterIsEnvelope;
99  OGRGeometry *m_poFilterGeom;
100  OGRPreparedGeometry *m_pPreparedFilterGeom; /* m_poFilterGeom compiled as a prepared geometry */
101  OGREnvelope m_sFilterEnvelope;
102  int m_iGeomFieldFilter; // specify the index on which the spatial
103  // filter is active.
104 
105  int FilterGeometry( OGRGeometry * );
106  //int FilterGeometry( OGRGeometry *, OGREnvelope* psGeometryEnvelope);
107  int InstallFilter( OGRGeometry * );
108 
109  OGRErr GetExtentInternal(int iGeomField, OGREnvelope *psExtent, int bForce );
111 
112  virtual OGRErr ISetFeature( OGRFeature *poFeature ) CPL_WARN_UNUSED_RESULT;
113  virtual OGRErr ICreateFeature( OGRFeature *poFeature ) CPL_WARN_UNUSED_RESULT;
114 
115  public:
116  OGRLayer();
117  virtual ~OGRLayer();
118 
129  FeatureIterator begin();
130 
132  FeatureIterator end();
133 
134  virtual OGRGeometry *GetSpatialFilter();
135  virtual void SetSpatialFilter( OGRGeometry * );
136  virtual void SetSpatialFilterRect( double dfMinX, double dfMinY,
137  double dfMaxX, double dfMaxY );
138 
139  virtual void SetSpatialFilter( int iGeomField, OGRGeometry * );
140  virtual void SetSpatialFilterRect( int iGeomField,
141  double dfMinX, double dfMinY,
142  double dfMaxX, double dfMaxY );
143 
144  virtual OGRErr SetAttributeFilter( const char * );
145 
146  virtual void ResetReading() = 0;
147  virtual OGRFeature *GetNextFeature() CPL_WARN_UNUSED_RESULT = 0;
148  virtual OGRErr SetNextByIndex( GIntBig nIndex );
149  virtual OGRFeature *GetFeature( GIntBig nFID ) CPL_WARN_UNUSED_RESULT;
150 
151  OGRErr SetFeature( OGRFeature *poFeature ) CPL_WARN_UNUSED_RESULT;
152  OGRErr CreateFeature( OGRFeature *poFeature ) CPL_WARN_UNUSED_RESULT;
153 
154  virtual OGRErr DeleteFeature( GIntBig nFID ) CPL_WARN_UNUSED_RESULT;
155 
156  virtual const char *GetName();
157  virtual OGRwkbGeometryType GetGeomType();
158  virtual OGRFeatureDefn *GetLayerDefn() = 0;
159  virtual int FindFieldIndex( const char *pszFieldName, int bExactMatch );
160 
161  virtual OGRSpatialReference *GetSpatialRef();
162 
163  virtual GIntBig GetFeatureCount( int bForce = TRUE );
164  virtual OGRErr GetExtent(OGREnvelope *psExtent, int bForce = TRUE) CPL_WARN_UNUSED_RESULT;
165  virtual OGRErr GetExtent(int iGeomField, OGREnvelope *psExtent,
166  int bForce = TRUE) CPL_WARN_UNUSED_RESULT;
167 
168  virtual int TestCapability( const char * ) = 0;
169 
170  virtual OGRErr CreateField( OGRFieldDefn *poField,
171  int bApproxOK = TRUE );
172  virtual OGRErr DeleteField( int iField );
173  virtual OGRErr ReorderFields( int* panMap );
174  virtual OGRErr AlterFieldDefn( int iField, OGRFieldDefn* poNewFieldDefn, int nFlagsIn );
175 
176  virtual OGRErr CreateGeomField( OGRGeomFieldDefn *poField,
177  int bApproxOK = TRUE );
178 
179  virtual OGRErr SyncToDisk();
180 
181  virtual OGRStyleTable *GetStyleTable();
182  virtual void SetStyleTableDirectly( OGRStyleTable *poStyleTable );
183 
184  virtual void SetStyleTable(OGRStyleTable *poStyleTable);
185 
186  virtual OGRErr StartTransaction() CPL_WARN_UNUSED_RESULT;
187  virtual OGRErr CommitTransaction() CPL_WARN_UNUSED_RESULT;
188  virtual OGRErr RollbackTransaction();
189 
190  virtual const char *GetFIDColumn();
191  virtual const char *GetGeometryColumn();
192 
193  virtual OGRErr SetIgnoredFields( const char **papszFields );
194 
195  OGRErr Intersection( OGRLayer *pLayerMethod,
196  OGRLayer *pLayerResult,
197  char** papszOptions = nullptr,
198  GDALProgressFunc pfnProgress = nullptr,
199  void * pProgressArg = nullptr );
200  OGRErr Union( OGRLayer *pLayerMethod,
201  OGRLayer *pLayerResult,
202  char** papszOptions = nullptr,
203  GDALProgressFunc pfnProgress = nullptr,
204  void * pProgressArg = nullptr );
205  OGRErr SymDifference( OGRLayer *pLayerMethod,
206  OGRLayer *pLayerResult,
207  char** papszOptions,
208  GDALProgressFunc pfnProgress,
209  void * pProgressArg );
210  OGRErr Identity( OGRLayer *pLayerMethod,
211  OGRLayer *pLayerResult,
212  char** papszOptions = nullptr,
213  GDALProgressFunc pfnProgress = nullptr,
214  void * pProgressArg = nullptr );
215  OGRErr Update( OGRLayer *pLayerMethod,
216  OGRLayer *pLayerResult,
217  char** papszOptions = nullptr,
218  GDALProgressFunc pfnProgress = nullptr,
219  void * pProgressArg = nullptr );
220  OGRErr Clip( OGRLayer *pLayerMethod,
221  OGRLayer *pLayerResult,
222  char** papszOptions = nullptr,
223  GDALProgressFunc pfnProgress = nullptr,
224  void * pProgressArg = nullptr );
225  OGRErr Erase( OGRLayer *pLayerMethod,
226  OGRLayer *pLayerResult,
227  char** papszOptions = nullptr,
228  GDALProgressFunc pfnProgress = nullptr,
229  void * pProgressArg = nullptr );
230 
231  int Reference();
232  int Dereference();
233  int GetRefCount() const;
235  GIntBig GetFeaturesRead();
237 
238  /* non virtual : convenience wrapper for ReorderFields() */
239  OGRErr ReorderField( int iOldFieldPos, int iNewFieldPos );
240 
242  int AttributeFilterEvaluationNeedsGeometry();
243 
244  /* consider these private */
245  OGRErr InitializeIndexSupport( const char * );
246  OGRLayerAttrIndex *GetIndex() { return m_poAttrIndex; }
247  int GetGeomFieldFilter() const { return m_iGeomFieldFilter; }
248  const char *GetAttrQueryString() const { return m_pszAttrQueryString; }
250 
254  static inline OGRLayerH ToHandle(OGRLayer* poLayer)
255  { return reinterpret_cast<OGRLayerH>(poLayer); }
256 
260  static inline OGRLayer* FromHandle(OGRLayerH hLayer)
261  { return reinterpret_cast<OGRLayer*>(hLayer); }
262 
263  protected:
265  OGRStyleTable *m_poStyleTable;
266  OGRFeatureQuery *m_poAttrQuery;
267  char *m_pszAttrQueryString;
268  OGRLayerAttrIndex *m_poAttrIndex;
269 
270  int m_nRefCount;
271 
272  GIntBig m_nFeaturesRead;
274 };
275 
287 inline OGRLayer::FeatureIterator begin(OGRLayer* poLayer) { return poLayer->begin(); }
288 
292 inline OGRLayer::FeatureIterator end(OGRLayer* poLayer) { return poLayer->end(); }
293 
294 /************************************************************************/
295 /* OGRDataSource */
296 /************************************************************************/
297 
317 class CPL_DLL OGRDataSource : public GDALDataset
318 {
319 public:
320  OGRDataSource();
322  virtual const char *GetName() OGR_DEPRECATED("Use GDALDataset class instead") = 0;
323 
324  static void DestroyDataSource( OGRDataSource * ) OGR_DEPRECATED("Use GDALDataset class instead");
326 };
327 
328 /************************************************************************/
329 /* OGRSFDriver */
330 /************************************************************************/
331 
350 class CPL_DLL OGRSFDriver : public GDALDriver
351 {
352  public:
354  virtual ~OGRSFDriver();
355 
356  virtual const char *GetName() OGR_DEPRECATED("Use GDALDriver class instead") = 0;
357 
358  virtual OGRDataSource *Open( const char *pszName, int bUpdate=FALSE ) OGR_DEPRECATED("Use GDALDriver class instead") = 0;
359 
360  virtual int TestCapability( const char *pszCap ) OGR_DEPRECATED("Use GDALDriver class instead") = 0;
361 
362  virtual OGRDataSource *CreateDataSource( const char *pszName,
363  char ** = nullptr ) OGR_DEPRECATED("Use GDALDriver class instead");
364  virtual OGRErr DeleteDataSource( const char *pszName ) OGR_DEPRECATED("Use GDALDriver class instead");
366 };
367 
368 /************************************************************************/
369 /* OGRSFDriverRegistrar */
370 /************************************************************************/
371 
385 class CPL_DLL OGRSFDriverRegistrar
386 {
387 
389  ~OGRSFDriverRegistrar();
390 
391  static GDALDataset* OpenWithDriverArg(GDALDriver* poDriver,
392  GDALOpenInfo* poOpenInfo);
393  static GDALDataset* CreateVectorOnly( GDALDriver* poDriver,
394  const char * pszName,
395  char ** papszOptions );
396  static CPLErr DeleteDataSource( GDALDriver* poDriver,
397  const char * pszName );
398 
399  public:
401  static OGRSFDriverRegistrar *GetRegistrar() OGR_DEPRECATED("Use GDALDriverManager class instead");
402 
403  // cppcheck-suppress functionStatic
404  void RegisterDriver( OGRSFDriver * poDriver ) OGR_DEPRECATED("Use GDALDriverManager class instead");
405 
406  // cppcheck-suppress functionStatic
407  int GetDriverCount( void ) OGR_DEPRECATED("Use GDALDriverManager class instead");
408  // cppcheck-suppress functionStatic
409  GDALDriver *GetDriver( int iDriver ) OGR_DEPRECATED("Use GDALDriverManager class instead");
410  // cppcheck-suppress functionStatic
411  GDALDriver *GetDriverByName( const char * ) OGR_DEPRECATED("Use GDALDriverManager class instead");
412 
413  // cppcheck-suppress functionStatic
414  int GetOpenDSCount() OGR_DEPRECATED("Use GDALDriverManager class instead");
415  // cppcheck-suppress functionStatic
416  OGRDataSource *GetOpenDS( int ) OGR_DEPRECATED("Use GDALDriverManager class instead");
418 };
419 
420 /* -------------------------------------------------------------------- */
421 /* Various available registration methods. */
422 /* -------------------------------------------------------------------- */
424 
426 void OGRRegisterAllInternal();
427 
428 void CPL_DLL RegisterOGRFileGDB();
429 void CPL_DLL RegisterOGRShape();
430 void CPL_DLL RegisterOGRDB2();
431 void CPL_DLL RegisterOGRNTF();
432 void CPL_DLL RegisterOGRFME();
433 void CPL_DLL RegisterOGRSDTS();
434 void CPL_DLL RegisterOGRTiger();
435 void CPL_DLL RegisterOGRS57();
436 void CPL_DLL RegisterOGRTAB();
437 void CPL_DLL RegisterOGRMIF();
438 void CPL_DLL RegisterOGROGDI();
439 void CPL_DLL RegisterOGRODBC();
440 void CPL_DLL RegisterOGRWAsP();
441 void CPL_DLL RegisterOGRPG();
442 void CPL_DLL RegisterOGRMSSQLSpatial();
443 void CPL_DLL RegisterOGRMySQL();
444 void CPL_DLL RegisterOGROCI();
445 void CPL_DLL RegisterOGRDGN();
446 void CPL_DLL RegisterOGRGML();
447 void CPL_DLL RegisterOGRLIBKML();
448 void CPL_DLL RegisterOGRKML();
449 void CPL_DLL RegisterOGRGeoJSON();
450 void CPL_DLL RegisterOGRGeoJSONSeq();
451 void CPL_DLL RegisterOGRESRIJSON();
452 void CPL_DLL RegisterOGRTopoJSON();
453 void CPL_DLL RegisterOGRAVCBin();
454 void CPL_DLL RegisterOGRAVCE00();
455 void CPL_DLL RegisterOGRREC();
456 void CPL_DLL RegisterOGRMEM();
457 void CPL_DLL RegisterOGRVRT();
458 void CPL_DLL RegisterOGRDODS();
459 void CPL_DLL RegisterOGRSQLite();
460 void CPL_DLL RegisterOGRCSV();
461 void CPL_DLL RegisterOGRILI1();
462 void CPL_DLL RegisterOGRILI2();
463 void CPL_DLL RegisterOGRGRASS();
464 void CPL_DLL RegisterOGRPGeo();
465 void CPL_DLL RegisterOGRDXF();
466 void CPL_DLL RegisterOGRCAD();
467 void CPL_DLL RegisterOGRDWG();
468 void CPL_DLL RegisterOGRDGNV8();
469 void CPL_DLL RegisterOGRSDE();
470 void CPL_DLL RegisterOGRIDB();
471 void CPL_DLL RegisterOGRGMT();
472 void CPL_DLL RegisterOGRBNA();
473 void CPL_DLL RegisterOGRGPX();
474 void CPL_DLL RegisterOGRGeoconcept();
475 void CPL_DLL RegisterOGRIngres();
476 void CPL_DLL RegisterOGRXPlane();
477 void CPL_DLL RegisterOGRNAS();
478 void CPL_DLL RegisterOGRGeoRSS();
479 void CPL_DLL RegisterOGRGTM();
480 void CPL_DLL RegisterOGRVFK();
481 void CPL_DLL RegisterOGRPGDump();
482 void CPL_DLL RegisterOGROSM();
483 void CPL_DLL RegisterOGRGPSBabel();
484 void CPL_DLL RegisterOGRSUA();
485 void CPL_DLL RegisterOGROpenAir();
486 void CPL_DLL RegisterOGRPDS();
487 void CPL_DLL RegisterOGRWFS();
488 void CPL_DLL RegisterOGRWFS3();
489 void CPL_DLL RegisterOGRSOSI();
490 void CPL_DLL RegisterOGRHTF();
491 void CPL_DLL RegisterOGRAeronavFAA();
492 void CPL_DLL RegisterOGRGeomedia();
493 void CPL_DLL RegisterOGRMDB();
494 void CPL_DLL RegisterOGREDIGEO();
495 void CPL_DLL RegisterOGRGFT();
496 void CPL_DLL RegisterOGRSVG();
497 void CPL_DLL RegisterOGRCouchDB();
498 void CPL_DLL RegisterOGRCloudant();
499 void CPL_DLL RegisterOGRIdrisi();
500 void CPL_DLL RegisterOGRARCGEN();
501 void CPL_DLL RegisterOGRSEGUKOOA();
502 void CPL_DLL RegisterOGRSEGY();
503 void CPL_DLL RegisterOGRXLS();
504 void CPL_DLL RegisterOGRODS();
505 void CPL_DLL RegisterOGRXLSX();
506 void CPL_DLL RegisterOGRElastic();
507 void CPL_DLL RegisterOGRGeoPackage();
508 void CPL_DLL RegisterOGRWalk();
509 void CPL_DLL RegisterOGRCarto();
510 void CPL_DLL RegisterOGRAmigoCloud();
511 void CPL_DLL RegisterOGRSXF();
512 void CPL_DLL RegisterOGROpenFileGDB();
513 void CPL_DLL RegisterOGRSelafin();
514 void CPL_DLL RegisterOGRJML();
515 void CPL_DLL RegisterOGRPLSCENES();
516 void CPL_DLL RegisterOGRCSW();
517 void CPL_DLL RegisterOGRMongoDB();
518 void CPL_DLL RegisterOGRVDV();
519 void CPL_DLL RegisterOGRGMLAS();
520 void CPL_DLL RegisterOGRMVT();
521 void CPL_DLL RegisterOGRNGW();
522 // @endcond
523 
524 CPL_C_END
525 
526 #endif /* ndef OGRSF_FRMTS_H_INCLUDED */
LEGACY class.
Definition: ogrsf_frmts.h:317
void * OGRLayerH
Opaque type for a layer (OGRLayer)
Definition: ogr_api.h:508
std::unique_ptr< OGRFeature, OGRFeatureUniquePtrDeleter > OGRFeatureUniquePtr
Unique pointer type for OGRFeature.
Definition: ogr_feature.h:780
#define CPL_C_START
Macro to start a block of C symbols.
Definition: cpl_port.h:337
C++ GDAL entry points.
Definition of a geometry field of an OGRFeatureDefn.
Definition: ogr_feature.h:182
static OGRLayer * FromHandle(OGRLayerH hLayer)
Convert a OGRLayerH to a OGRLayer*.
Definition: ogrsf_frmts.h:260
static OGRLayerH ToHandle(OGRLayer *poLayer)
Convert a OGRLayer* to a OGRLayerH.
Definition: ogrsf_frmts.h:254
Definition of a feature class or feature layer.
Definition: ogr_feature.h:259
Simple feature style classes.
Definition of an attribute of an OGRFeatureDefn.
Definition: ogr_feature.h:92
OGRwkbGeometryType
List of well known binary geometry types.
Definition: ogr_core.h:317
Abstract base class for all geometry classes.
Definition: ogr_geometry.h:286
Class for dataset open functions.
Definition: gdal_priv.h:265
This class represents an OpenGIS Spatial Reference System, and contains methods for converting betwee...
Definition: ogr_spatialref.h:147
struct _OGRPreparedGeometry OGRPreparedGeometry
Prepared geometry API (needs GEOS >= 3.1.0)
Definition: ogr_geometry.h:2910
Object with metadata.
Definition: gdal_priv.h:132
LEGACY class.
Definition: ogrsf_frmts.h:385
This class represents a layer of simple features, with access methods.
Definition: ogrsf_frmts.h:70
Simple feature classes.
A simple feature, including geometry and attributes.
Definition: ogr_feature.h:354
This class represents a style table.
Definition: ogr_featurestyle.h:84
A set of associated raster bands, usually from one file.
Definition: gdal_priv.h:335
#define CPL_C_END
Macro to end a block of C symbols.
Definition: cpl_port.h:339
long long GIntBig
Large signed integer type (generally 64-bit integer type).
Definition: cpl_port.h:248
OGRLayer::FeatureIterator begin(OGRLayer *poLayer)
Return begin of feature iterator.
Definition: ogrsf_frmts.h:287
int OGRErr
Simple container for a bounding region.
Definition: ogr_core.h:290
friend FeatureIterator begin(OGRLayer *poLayer)
Return begin of feature iterator.
Definition: ogrsf_frmts.h:287
OGRLayer::FeatureIterator end(OGRLayer *poLayer)
Return end of feature iterator.
Definition: ogrsf_frmts.h:292
friend FeatureIterator end(OGRLayer *poLayer)
Return end of feature iterator.
Definition: ogrsf_frmts.h:292
Format specific driver.
Definition: gdal_priv.h:1386
CPLErr
Error category.
Definition: cpl_error.h:52
LEGACY class.
Definition: ogrsf_frmts.h:350
#define CPL_DISALLOW_COPY_ASSIGN(ClassName)
Helper to remove the copy and assignment constructors so that the compiler will not generate the defa...
Definition: cpl_port.h:989
#define CPL_WARN_UNUSED_RESULT
Qualifier to warn when the return value of a function is not used.
Definition: cpl_port.h:931

Generated for GDAL by doxygen 1.8.13.