Line data Source code
1 : /******************************************************************************
2 : *
3 : * Project: OpenGIS Simple Features Reference Implementation
4 : * Purpose: Classes related to format registration, and file opening.
5 : * Author: Frank Warmerdam, warmerda@home.com
6 : *
7 : ******************************************************************************
8 : * Copyright (c) 1999, Les Technologies SoftMap Inc.
9 : * Copyright (c) 2007-2014, Even Rouault <even dot rouault at spatialys.com>
10 : *
11 : * SPDX-License-Identifier: MIT
12 : ****************************************************************************/
13 :
14 : #ifndef OGRSF_FRMTS_H_INCLUDED
15 : #define OGRSF_FRMTS_H_INCLUDED
16 :
17 : #include "cpl_progress.h"
18 : #include "ogr_feature.h"
19 : #include "ogr_featurestyle.h"
20 : #include "gdal_priv.h"
21 :
22 : #include <memory>
23 : #include <deque>
24 :
25 : /**
26 : * \file ogrsf_frmts.h
27 : *
28 : * Classes related to registration of format support, and opening datasets.
29 : */
30 :
31 : //! @cond Doxygen_Suppress
32 : #if !defined(GDAL_COMPILATION) && !defined(SUPPRESS_DEPRECATION_WARNINGS)
33 : #define OGR_DEPRECATED(x) CPL_WARN_DEPRECATED(x)
34 : #else
35 : #define OGR_DEPRECATED(x)
36 : #endif
37 :
38 : #ifndef CPPCHECK_STATIC
39 : #define CPPCHECK_STATIC
40 : #endif
41 : //! @endcond
42 :
43 : class OGRLayerAttrIndex;
44 : class OGRSFDriver;
45 :
46 : struct ArrowArrayStream;
47 :
48 : /************************************************************************/
49 : /* OGRLayer */
50 : /************************************************************************/
51 :
52 : /**
53 : * This class represents a layer of simple features, with access methods.
54 : *
55 : */
56 :
57 : /* Note: any virtual method added to this class must also be added in the */
58 : /* OGRLayerDecorator and OGRMutexedLayer classes. */
59 :
60 : class CPL_DLL OGRLayer : public GDALMajorObject
61 : {
62 : private:
63 : struct Private;
64 : std::unique_ptr<Private> m_poPrivate;
65 :
66 : void ConvertGeomsIfNecessary(OGRFeature *poFeature);
67 :
68 : class CPL_DLL FeatureIterator
69 : {
70 : struct Private;
71 : std::unique_ptr<Private> m_poPrivate;
72 :
73 : public:
74 : FeatureIterator(OGRLayer *poLayer, bool bStart);
75 : FeatureIterator(
76 : FeatureIterator &&oOther) noexcept; // declared but not defined.
77 : // Needed for gcc 5.4 at least
78 : ~FeatureIterator();
79 : OGRFeatureUniquePtr &operator*();
80 : FeatureIterator &operator++();
81 : bool operator!=(const FeatureIterator &it) const;
82 : };
83 :
84 : friend inline FeatureIterator begin(OGRLayer *poLayer);
85 : friend inline FeatureIterator end(OGRLayer *poLayer);
86 :
87 : CPL_DISALLOW_COPY_ASSIGN(OGRLayer)
88 :
89 : protected:
90 : //! @cond Doxygen_Suppress
91 : int m_bFilterIsEnvelope;
92 : OGRGeometry *m_poFilterGeom;
93 : OGRPreparedGeometry *m_pPreparedFilterGeom; /* m_poFilterGeom compiled as a
94 : prepared geometry */
95 : OGREnvelope m_sFilterEnvelope;
96 : int m_iGeomFieldFilter; // specify the index on which the spatial
97 : // filter is active.
98 :
99 : int FilterGeometry(const OGRGeometry *);
100 : // int FilterGeometry( OGRGeometry *, OGREnvelope*
101 : // psGeometryEnvelope);
102 : int InstallFilter(const OGRGeometry *);
103 : bool
104 : ValidateGeometryFieldIndexForSetSpatialFilter(int iGeomField,
105 : const OGRGeometry *poGeomIn,
106 : bool bIsSelectLayer = false);
107 : //! @endcond
108 :
109 : virtual OGRErr IGetExtent(int iGeomField, OGREnvelope *psExtent,
110 : bool bForce) CPL_WARN_UNUSED_RESULT;
111 :
112 : virtual OGRErr IGetExtent3D(int iGeomField, OGREnvelope3D *psExtent3D,
113 : bool bForce) CPL_WARN_UNUSED_RESULT;
114 :
115 : virtual OGRErr ISetSpatialFilter(int iGeomField, const OGRGeometry *);
116 :
117 : virtual OGRErr ISetFeature(OGRFeature *poFeature) CPL_WARN_UNUSED_RESULT;
118 : virtual OGRErr ICreateFeature(OGRFeature *poFeature) CPL_WARN_UNUSED_RESULT;
119 : virtual OGRErr IUpsertFeature(OGRFeature *poFeature) CPL_WARN_UNUSED_RESULT;
120 : virtual OGRErr
121 : IUpdateFeature(OGRFeature *poFeature, int nUpdatedFieldsCount,
122 : const int *panUpdatedFieldsIdx, int nUpdatedGeomFieldsCount,
123 : const int *panUpdatedGeomFieldsIdx,
124 : bool bUpdateStyleString) CPL_WARN_UNUSED_RESULT;
125 :
126 : //! @cond Doxygen_Suppress
127 : CPLStringList m_aosArrowArrayStreamOptions{};
128 :
129 : friend struct OGRGenSQLResultsLayerArrowStreamPrivateData;
130 :
131 : struct ArrowArrayStreamPrivateData
132 : {
133 : bool m_bArrowArrayStreamInProgress = false;
134 : bool m_bEOF = false;
135 : OGRLayer *m_poLayer = nullptr;
136 : std::vector<GIntBig> m_anQueriedFIDs{};
137 : size_t m_iQueriedFIDS = 0;
138 : std::deque<std::unique_ptr<OGRFeature>> m_oFeatureQueue{};
139 : };
140 :
141 : std::shared_ptr<ArrowArrayStreamPrivateData>
142 : m_poSharedArrowArrayStreamPrivateData{};
143 :
144 : struct ArrowArrayStreamPrivateDataSharedDataWrapper
145 : {
146 : std::shared_ptr<ArrowArrayStreamPrivateData> poShared{};
147 : };
148 : //! @endcond
149 :
150 : friend class OGRArrowArrayHelper;
151 : friend class OGRGenSQLResultsLayer;
152 : static void ReleaseArray(struct ArrowArray *array);
153 : static void ReleaseSchema(struct ArrowSchema *schema);
154 : static void ReleaseStream(struct ArrowArrayStream *stream);
155 : virtual int GetArrowSchema(struct ArrowArrayStream *,
156 : struct ArrowSchema *out_schema);
157 : virtual int GetNextArrowArray(struct ArrowArrayStream *,
158 : struct ArrowArray *out_array);
159 : static int StaticGetArrowSchema(struct ArrowArrayStream *,
160 : struct ArrowSchema *out_schema);
161 : static int StaticGetNextArrowArray(struct ArrowArrayStream *,
162 : struct ArrowArray *out_array);
163 : static const char *GetLastErrorArrowArrayStream(struct ArrowArrayStream *);
164 :
165 : static struct ArrowSchema *
166 : CreateSchemaForWKBGeometryColumn(const OGRGeomFieldDefn *poFieldDefn,
167 : const char *pszArrowFormat,
168 : const char *pszExtensionName);
169 :
170 : virtual bool
171 : CanPostFilterArrowArray(const struct ArrowSchema *schema) const;
172 : void PostFilterArrowArray(const struct ArrowSchema *schema,
173 : struct ArrowArray *array,
174 : CSLConstList papszOptions) const;
175 :
176 : //! @cond Doxygen_Suppress
177 : bool CreateFieldFromArrowSchemaInternal(const struct ArrowSchema *schema,
178 : const std::string &osFieldPrefix,
179 : CSLConstList papszOptions);
180 : //! @endcond
181 :
182 : public:
183 : OGRLayer();
184 : ~OGRLayer() override;
185 :
186 : /** Return begin of feature iterator.
187 : *
188 : * Using this iterator for standard range-based loops is safe, but
189 : * due to implementation limitations, you shouldn't try to access
190 : * (dereference) more than one iterator step at a time, since the
191 : * OGRFeatureUniquePtr reference is reused.
192 : *
193 : * Only one iterator per layer can be active at a time.
194 : * @since GDAL 2.3
195 : */
196 : FeatureIterator begin();
197 :
198 : /** Return end of feature iterator. */
199 : FeatureIterator end();
200 :
201 : virtual OGRGeometry *GetSpatialFilter();
202 :
203 : OGRErr SetSpatialFilter(const OGRGeometry *);
204 : OGRErr SetSpatialFilterRect(double dfMinX, double dfMinY, double dfMaxX,
205 : double dfMaxY);
206 :
207 : OGRErr SetSpatialFilter(int iGeomField, const OGRGeometry *);
208 : OGRErr SetSpatialFilterRect(int iGeomField, double dfMinX, double dfMinY,
209 : double dfMaxX, double dfMaxY);
210 :
211 : virtual OGRErr SetAttributeFilter(const char *);
212 :
213 : virtual void ResetReading() = 0;
214 : virtual OGRFeature *GetNextFeature() CPL_WARN_UNUSED_RESULT = 0;
215 : virtual OGRErr SetNextByIndex(GIntBig nIndex);
216 : virtual OGRFeature *GetFeature(GIntBig nFID) CPL_WARN_UNUSED_RESULT;
217 :
218 : virtual GDALDataset *GetDataset();
219 : virtual bool GetArrowStream(struct ArrowArrayStream *out_stream,
220 : CSLConstList papszOptions = nullptr);
221 : virtual bool IsArrowSchemaSupported(const struct ArrowSchema *schema,
222 : CSLConstList papszOptions,
223 : std::string &osErrorMsg) const;
224 : virtual bool
225 : CreateFieldFromArrowSchema(const struct ArrowSchema *schema,
226 : CSLConstList papszOptions = nullptr);
227 : virtual bool WriteArrowBatch(const struct ArrowSchema *schema,
228 : struct ArrowArray *array,
229 : CSLConstList papszOptions = nullptr);
230 :
231 : OGRErr SetFeature(OGRFeature *poFeature) CPL_WARN_UNUSED_RESULT;
232 : OGRErr CreateFeature(OGRFeature *poFeature) CPL_WARN_UNUSED_RESULT;
233 : OGRErr UpsertFeature(OGRFeature *poFeature) CPL_WARN_UNUSED_RESULT;
234 : OGRErr UpdateFeature(OGRFeature *poFeature, int nUpdatedFieldsCount,
235 : const int *panUpdatedFieldsIdx,
236 : int nUpdatedGeomFieldsCount,
237 : const int *panUpdatedGeomFieldsIdx,
238 : bool bUpdateStyleString) CPL_WARN_UNUSED_RESULT;
239 :
240 : virtual OGRErr DeleteFeature(GIntBig nFID) CPL_WARN_UNUSED_RESULT;
241 :
242 : virtual const char *GetName() const;
243 : virtual OGRwkbGeometryType GetGeomType() const;
244 : virtual const OGRFeatureDefn *GetLayerDefn() const = 0;
245 :
246 1502891 : OGRFeatureDefn *GetLayerDefn()
247 : {
248 : return const_cast<OGRFeatureDefn *>(
249 1502891 : const_cast<const OGRLayer *>(this)->GetLayerDefn());
250 : }
251 :
252 : virtual int FindFieldIndex(const char *pszFieldName, int bExactMatch);
253 :
254 : virtual const OGRSpatialReference *GetSpatialRef() const;
255 :
256 : /** Return type of OGRLayer::GetSupportedSRSList() */
257 : typedef std::vector<
258 : std::unique_ptr<OGRSpatialReference, OGRSpatialReferenceReleaser>>
259 : GetSupportedSRSListRetType;
260 : virtual const GetSupportedSRSListRetType &
261 : GetSupportedSRSList(int iGeomField);
262 : virtual OGRErr SetActiveSRS(int iGeomField,
263 : const OGRSpatialReference *poSRS);
264 :
265 : virtual GIntBig GetFeatureCount(int bForce = TRUE);
266 :
267 : OGRErr GetExtent(OGREnvelope *psExtent,
268 : bool bForce = true) CPL_WARN_UNUSED_RESULT;
269 : OGRErr GetExtent(int iGeomField, OGREnvelope *psExtent,
270 : bool bForce = true) CPL_WARN_UNUSED_RESULT;
271 :
272 : OGRErr GetExtent3D(int iGeomField, OGREnvelope3D *psExtent,
273 : bool bForce = true) CPL_WARN_UNUSED_RESULT;
274 :
275 : virtual int TestCapability(const char *) const = 0;
276 :
277 : virtual OGRErr Rename(const char *pszNewName) CPL_WARN_UNUSED_RESULT;
278 :
279 : virtual OGRErr CreateField(const OGRFieldDefn *poField,
280 : int bApproxOK = TRUE);
281 : virtual OGRErr DeleteField(int iField);
282 : virtual OGRErr ReorderFields(int *panMap);
283 : virtual OGRErr AlterFieldDefn(int iField, OGRFieldDefn *poNewFieldDefn,
284 : int nFlagsIn);
285 : virtual OGRErr
286 : AlterGeomFieldDefn(int iGeomField,
287 : const OGRGeomFieldDefn *poNewGeomFieldDefn,
288 : int nFlagsIn);
289 :
290 : virtual OGRErr CreateGeomField(const OGRGeomFieldDefn *poField,
291 : int bApproxOK = TRUE);
292 :
293 : virtual OGRErr SyncToDisk();
294 :
295 : virtual OGRStyleTable *GetStyleTable();
296 : virtual void SetStyleTableDirectly(OGRStyleTable *poStyleTable);
297 :
298 : virtual void SetStyleTable(OGRStyleTable *poStyleTable);
299 :
300 : virtual OGRErr StartTransaction() CPL_WARN_UNUSED_RESULT;
301 : virtual OGRErr CommitTransaction() CPL_WARN_UNUSED_RESULT;
302 : virtual OGRErr RollbackTransaction();
303 :
304 : //! @cond Doxygen_Suppress
305 : // Keep field definitions in sync with transactions
306 : virtual void PrepareStartTransaction();
307 : // Rollback TO SAVEPOINT if osSavepointName is not empty, otherwise ROLLBACK
308 : virtual void FinishRollbackTransaction(const std::string &osSavepointName);
309 : //! @endcond
310 :
311 : virtual const char *GetFIDColumn() const;
312 : virtual const char *GetGeometryColumn() const;
313 :
314 : virtual OGRErr SetIgnoredFields(CSLConstList papszFields);
315 :
316 : virtual OGRGeometryTypeCounter *
317 : GetGeometryTypes(int iGeomField, int nFlagsGGT, int &nEntryCountOut,
318 : GDALProgressFunc pfnProgress, void *pProgressData);
319 :
320 : OGRErr Intersection(OGRLayer *pLayerMethod, OGRLayer *pLayerResult,
321 : char **papszOptions = nullptr,
322 : GDALProgressFunc pfnProgress = nullptr,
323 : void *pProgressArg = nullptr);
324 : OGRErr Union(OGRLayer *pLayerMethod, OGRLayer *pLayerResult,
325 : char **papszOptions = nullptr,
326 : GDALProgressFunc pfnProgress = nullptr,
327 : void *pProgressArg = nullptr);
328 : OGRErr SymDifference(OGRLayer *pLayerMethod, OGRLayer *pLayerResult,
329 : char **papszOptions, GDALProgressFunc pfnProgress,
330 : void *pProgressArg);
331 : OGRErr Identity(OGRLayer *pLayerMethod, OGRLayer *pLayerResult,
332 : char **papszOptions = nullptr,
333 : GDALProgressFunc pfnProgress = nullptr,
334 : void *pProgressArg = nullptr);
335 : OGRErr Update(OGRLayer *pLayerMethod, OGRLayer *pLayerResult,
336 : char **papszOptions = nullptr,
337 : GDALProgressFunc pfnProgress = nullptr,
338 : void *pProgressArg = nullptr);
339 : OGRErr Clip(OGRLayer *pLayerMethod, OGRLayer *pLayerResult,
340 : char **papszOptions = nullptr,
341 : GDALProgressFunc pfnProgress = nullptr,
342 : void *pProgressArg = nullptr);
343 : OGRErr Erase(OGRLayer *pLayerMethod, OGRLayer *pLayerResult,
344 : char **papszOptions = nullptr,
345 : GDALProgressFunc pfnProgress = nullptr,
346 : void *pProgressArg = nullptr);
347 :
348 : int Reference();
349 : int Dereference();
350 : int GetRefCount() const;
351 : //! @cond Doxygen_Suppress
352 : GIntBig GetFeaturesRead();
353 : //! @endcond
354 :
355 : /* non virtual : convenience wrapper for ReorderFields() */
356 : OGRErr ReorderField(int iOldFieldPos, int iNewFieldPos);
357 :
358 : //! @cond Doxygen_Suppress
359 : int AttributeFilterEvaluationNeedsGeometry();
360 :
361 : /* consider these private */
362 : OGRErr InitializeIndexSupport(const char *);
363 :
364 5799 : OGRLayerAttrIndex *GetIndex()
365 : {
366 5799 : return m_poAttrIndex;
367 : }
368 :
369 13 : int GetGeomFieldFilter() const
370 : {
371 13 : return m_iGeomFieldFilter;
372 : }
373 :
374 72 : const char *GetAttrQueryString() const
375 : {
376 72 : return m_pszAttrQueryString;
377 : }
378 :
379 : //! @endcond
380 :
381 : /** Convert a OGRLayer* to a OGRLayerH.
382 : * @since GDAL 2.3
383 : */
384 29555 : static inline OGRLayerH ToHandle(OGRLayer *poLayer)
385 : {
386 29555 : return reinterpret_cast<OGRLayerH>(poLayer);
387 : }
388 :
389 : /** Convert a OGRLayerH to a OGRLayer*.
390 : * @since GDAL 2.3
391 : */
392 718373 : static inline OGRLayer *FromHandle(OGRLayerH hLayer)
393 : {
394 718373 : return reinterpret_cast<OGRLayer *>(hLayer);
395 : }
396 :
397 : //! @cond Doxygen_Suppress
398 : bool FilterWKBGeometry(const GByte *pabyWKB, size_t nWKBSize,
399 : bool bEnvelopeAlreadySet,
400 : OGREnvelope &sEnvelope) const;
401 :
402 : static bool FilterWKBGeometry(const GByte *pabyWKB, size_t nWKBSize,
403 : bool bEnvelopeAlreadySet,
404 : OGREnvelope &sEnvelope,
405 : const OGRGeometry *poFilterGeom,
406 : bool bFilterIsEnvelope,
407 : const OGREnvelope &sFilterEnvelope,
408 : OGRPreparedGeometry *&poPreparedFilterGeom);
409 : //! @endcond
410 :
411 : /** Field name used by GetArrowSchema() for a FID column when
412 : * GetFIDColumn() is not set.
413 : */
414 : static constexpr const char *DEFAULT_ARROW_FID_NAME = "OGC_FID";
415 :
416 : /** Field name used by GetArrowSchema() for the name of the (single)
417 : * geometry column (returned by GetGeometryColumn()) is not set.
418 : */
419 : static constexpr const char *DEFAULT_ARROW_GEOMETRY_NAME = "wkb_geometry";
420 :
421 : protected:
422 : //! @cond Doxygen_Suppress
423 :
424 : enum class FieldChangeType : char
425 : {
426 : ADD_FIELD,
427 : ALTER_FIELD,
428 : DELETE_FIELD
429 : };
430 :
431 : // Store changes to the fields that happened inside a transaction
432 : template <typename T> struct FieldDefnChange
433 : {
434 :
435 1329 : FieldDefnChange(std::unique_ptr<T> &&poFieldDefnIn, int iFieldIn,
436 : FieldChangeType eChangeTypeIn,
437 : const std::string &osSavepointNameIn = "")
438 1329 : : poFieldDefn(std::move(poFieldDefnIn)), iField(iFieldIn),
439 1329 : eChangeType(eChangeTypeIn), osSavepointName(osSavepointNameIn)
440 : {
441 1329 : }
442 :
443 : std::unique_ptr<T> poFieldDefn;
444 : int iField;
445 : FieldChangeType eChangeType;
446 : std::string osSavepointName;
447 : };
448 :
449 : std::vector<FieldDefnChange<OGRFieldDefn>> m_apoFieldDefnChanges{};
450 : std::vector<FieldDefnChange<OGRGeomFieldDefn>> m_apoGeomFieldDefnChanges{};
451 :
452 : OGRStyleTable *m_poStyleTable;
453 : OGRFeatureQuery *m_poAttrQuery;
454 : char *m_pszAttrQueryString;
455 : OGRLayerAttrIndex *m_poAttrIndex;
456 :
457 : int m_nRefCount;
458 :
459 : GIntBig m_nFeaturesRead;
460 : //! @endcond
461 : };
462 :
463 : /** Return begin of feature iterator.
464 : *
465 : * Using this iterator for standard range-based loops is safe, but
466 : * due to implementation limitations, you shouldn't try to access
467 : * (dereference) more than one iterator step at a time, since the
468 : * std::unique_ptr<OGRFeature> reference is reused.
469 : *
470 : * Only one iterator per layer can be active at a time.
471 : * @since GDAL 2.3
472 : * @see OGRLayer::begin()
473 : */
474 2771 : inline OGRLayer::FeatureIterator begin(OGRLayer *poLayer)
475 : {
476 2771 : return poLayer->begin();
477 : }
478 :
479 : /** Return end of feature iterator.
480 : * @see OGRLayer::end()
481 : */
482 2771 : inline OGRLayer::FeatureIterator end(OGRLayer *poLayer)
483 : {
484 2771 : return poLayer->end();
485 : }
486 :
487 : /** Unique pointer type for OGRLayer.
488 : * @since GDAL 3.2
489 : */
490 : using OGRLayerUniquePtr = std::unique_ptr<OGRLayer>;
491 :
492 : /************************************************************************/
493 : /* OGRGetNextFeatureThroughRaw */
494 : /************************************************************************/
495 :
496 : /** Template class offering a GetNextFeature() implementation relying on
497 : * GetNextRawFeature()
498 : *
499 : * @since GDAL 3.2
500 : */
501 : template <class BaseLayer> class OGRGetNextFeatureThroughRaw
502 : {
503 : protected:
504 : ~OGRGetNextFeatureThroughRaw() = default;
505 :
506 : public:
507 : /** Implement OGRLayer::GetNextFeature(), relying on
508 : * BaseLayer::GetNextRawFeature() */
509 52099 : OGRFeature *GetNextFeature()
510 : {
511 52099 : const auto poThis = static_cast<BaseLayer *>(this);
512 15987 : while (true)
513 : {
514 68086 : OGRFeature *poFeature = poThis->GetNextRawFeature();
515 68086 : if (poFeature == nullptr)
516 4204 : return nullptr;
517 :
518 13765 : if ((poThis->m_poFilterGeom == nullptr ||
519 127764 : poThis->FilterGeometry(poFeature->GetGeometryRef())) &&
520 69554 : (poThis->m_poAttrQuery == nullptr ||
521 14781 : poThis->m_poAttrQuery->Evaluate(poFeature)))
522 : {
523 47895 : return poFeature;
524 : }
525 : else
526 15987 : delete poFeature;
527 : }
528 : }
529 : };
530 :
531 : /** Utility macro to define GetNextFeature() through GetNextRawFeature() */
532 : #define DEFINE_GET_NEXT_FEATURE_THROUGH_RAW(BaseLayer) \
533 : private: \
534 : friend class OGRGetNextFeatureThroughRaw<BaseLayer>; \
535 : \
536 : public: \
537 : OGRFeature *GetNextFeature() override \
538 : { \
539 : return OGRGetNextFeatureThroughRaw<BaseLayer>::GetNextFeature(); \
540 : }
541 :
542 : /************************************************************************/
543 : /* OGRDataSource */
544 : /************************************************************************/
545 :
546 : /**
547 : * LEGACY class. Use GDALDataset in your new code ! This class may be
548 : * removed in a later release.
549 : *
550 : * This class represents a data source. A data source potentially
551 : * consists of many layers (OGRLayer). A data source normally consists
552 : * of one, or a related set of files, though the name doesn't have to be
553 : * a real item in the file system.
554 : *
555 : * When an OGRDataSource is destroyed, all its associated OGRLayers objects
556 : * are also destroyed.
557 : *
558 : * NOTE: Starting with GDAL 2.0, it is *NOT* safe to cast the handle of
559 : * a C function that returns a OGRDataSourceH to a OGRDataSource*. If a C++
560 : * object is needed, the handle should be cast to GDALDataset*.
561 : *
562 : * @deprecated
563 : */
564 :
565 0 : class CPL_DLL OGRDataSource : public GDALDataset
566 : {
567 : public:
568 : OGRDataSource();
569 : ~OGRDataSource() override;
570 :
571 : //! @cond Doxygen_Suppress
572 : virtual const char *GetName()
573 : OGR_DEPRECATED("Use GDALDataset class instead") = 0;
574 :
575 : static void DestroyDataSource(OGRDataSource *)
576 : OGR_DEPRECATED("Use GDALDataset class instead");
577 : //! @endcond
578 : };
579 :
580 : /************************************************************************/
581 : /* OGRSFDriver */
582 : /************************************************************************/
583 :
584 : /**
585 : * LEGACY class. Use GDALDriver in your new code ! This class may be
586 : * removed in a later release.
587 : *
588 : * Represents an operational format driver.
589 : *
590 : * One OGRSFDriver derived class will normally exist for each file format
591 : * registered for use, regardless of whether a file has or will be opened.
592 : * The list of available drivers is normally managed by the
593 : * OGRSFDriverRegistrar.
594 : *
595 : * NOTE: Starting with GDAL 2.0, it is *NOT* safe to cast the handle of
596 : * a C function that returns a OGRSFDriverH to a OGRSFDriver*. If a C++ object
597 : * is needed, the handle should be cast to GDALDriver*.
598 : *
599 : * @deprecated
600 : */
601 :
602 : class CPL_DLL OGRSFDriver : public GDALDriver
603 : {
604 : public:
605 : //! @cond Doxygen_Suppress
606 : ~OGRSFDriver() override;
607 :
608 : virtual const char *GetName()
609 : OGR_DEPRECATED("Use GDALDriver class instead") = 0;
610 :
611 : virtual OGRDataSource *Open(const char *pszName, int bUpdate = FALSE)
612 : OGR_DEPRECATED("Use GDALDriver class instead") = 0;
613 :
614 : virtual int TestCapability(const char *pszCap)
615 : OGR_DEPRECATED("Use GDALDriver class instead") = 0;
616 :
617 : virtual OGRDataSource *CreateDataSource(const char *pszName,
618 : char ** = nullptr)
619 : OGR_DEPRECATED("Use GDALDriver class instead");
620 : virtual OGRErr DeleteDataSource(const char *pszName)
621 : OGR_DEPRECATED("Use GDALDriver class instead");
622 : //! @endcond
623 : };
624 :
625 : /************************************************************************/
626 : /* OGRSFDriverRegistrar */
627 : /************************************************************************/
628 :
629 : /**
630 : * LEGACY class. Use GDALDriverManager in your new code ! This class may be
631 : * removed in a later release.
632 : *
633 : * Singleton manager for OGRSFDriver instances that will be used to try
634 : * and open datasources. Normally the registrar is populated with
635 : * standard drivers using the OGRRegisterAll() function and does not need
636 : * to be directly accessed. The driver registrar and all registered drivers
637 : * may be cleaned up on shutdown using OGRCleanupAll().
638 : *
639 : * @deprecated
640 : */
641 :
642 : class CPL_DLL OGRSFDriverRegistrar
643 : {
644 :
645 : OGRSFDriverRegistrar();
646 : ~OGRSFDriverRegistrar();
647 :
648 : static GDALDataset *OpenWithDriverArg(GDALDriver *poDriver,
649 : GDALOpenInfo *poOpenInfo);
650 : static GDALDataset *CreateVectorOnly(GDALDriver *poDriver,
651 : const char *pszName,
652 : char **papszOptions);
653 : static CPLErr DeleteDataSource(GDALDriver *poDriver, const char *pszName);
654 :
655 : public:
656 : //! @cond Doxygen_Suppress
657 : static OGRSFDriverRegistrar *GetRegistrar()
658 : OGR_DEPRECATED("Use GDALDriverManager class instead");
659 :
660 : CPPCHECK_STATIC void RegisterDriver(OGRSFDriver *poDriver)
661 : OGR_DEPRECATED("Use GDALDriverManager class instead");
662 :
663 : CPPCHECK_STATIC int GetDriverCount(void)
664 : OGR_DEPRECATED("Use GDALDriverManager class instead");
665 :
666 : CPPCHECK_STATIC GDALDriver *GetDriver(int iDriver)
667 : OGR_DEPRECATED("Use GDALDriverManager class instead");
668 :
669 : CPPCHECK_STATIC GDALDriver *GetDriverByName(const char *)
670 : OGR_DEPRECATED("Use GDALDriverManager class instead");
671 :
672 : CPPCHECK_STATIC int GetOpenDSCount()
673 : OGR_DEPRECATED("Use GDALDriverManager class instead");
674 :
675 : CPPCHECK_STATIC OGRDataSource *GetOpenDS(int)
676 : OGR_DEPRECATED("Use GDALDriverManager class instead");
677 : //! @endcond
678 : };
679 :
680 : /* -------------------------------------------------------------------- */
681 : /* Various available registration methods. */
682 : /* -------------------------------------------------------------------- */
683 : CPL_C_START
684 :
685 : //! @cond Doxygen_Suppress
686 : void OGRRegisterAllInternal();
687 :
688 : void CPL_DLL RegisterOGRFileGDB();
689 : void DeclareDeferredOGRFileGDBPlugin();
690 : void CPL_DLL RegisterOGRShape();
691 : void CPL_DLL RegisterOGRS57();
692 : void CPL_DLL RegisterOGRTAB();
693 : void CPL_DLL RegisterOGRMIF();
694 : void CPL_DLL RegisterOGRODBC();
695 : void DeclareDeferredOGRODBCPlugin();
696 : void CPL_DLL RegisterOGRWAsP();
697 : void CPL_DLL RegisterOGRPG();
698 : void DeclareDeferredOGRPGPlugin();
699 : void CPL_DLL RegisterOGRMSSQLSpatial();
700 : void DeclareDeferredOGRMSSQLSpatialPlugin();
701 : void CPL_DLL RegisterOGRMySQL();
702 : void DeclareDeferredOGRMySQLPlugin();
703 : void CPL_DLL RegisterOGROCI();
704 : void DeclareDeferredOGROCIPlugin();
705 : void CPL_DLL RegisterOGRDGN();
706 : void CPL_DLL RegisterOGRGML();
707 : void CPL_DLL RegisterOGRLIBKML();
708 : void DeclareDeferredOGRLIBKMLPlugin();
709 : void CPL_DLL RegisterOGRKML();
710 : void CPL_DLL RegisterOGRFlatGeobuf();
711 : void CPL_DLL RegisterOGRGeoJSON();
712 : void CPL_DLL RegisterOGRGeoJSONSeq();
713 : void CPL_DLL RegisterOGRESRIJSON();
714 : void CPL_DLL RegisterOGRTopoJSON();
715 : void CPL_DLL RegisterOGRAVCBin();
716 : void CPL_DLL RegisterOGRAVCE00();
717 : void CPL_DLL RegisterOGRVRT();
718 : void CPL_DLL RegisterOGRSQLite();
719 : void CPL_DLL RegisterOGRCSV();
720 : void CPL_DLL RegisterOGRILI1();
721 : void CPL_DLL RegisterOGRILI2();
722 : void CPL_DLL RegisterOGRPGeo();
723 : void CPL_DLL RegisterOGRDXF();
724 : void CPL_DLL RegisterOGRCAD();
725 : void DeclareDeferredOGRCADPlugin();
726 : void CPL_DLL RegisterOGRDWG();
727 : void CPL_DLL RegisterOGRDGNV8();
728 : void DeclareDeferredOGRDWGPlugin();
729 : void DeclareDeferredOGRDGNV8Plugin();
730 : void CPL_DLL RegisterOGRIDB();
731 : void DeclareDeferredOGRIDBPlugin();
732 : void CPL_DLL RegisterOGRGMT();
733 : void CPL_DLL RegisterOGRGPX();
734 : void CPL_DLL RegisterOGRNAS();
735 : void CPL_DLL RegisterOGRGeoRSS();
736 : void CPL_DLL RegisterOGRVFK();
737 : void DeclareDeferredOGRVFKPlugin();
738 : void CPL_DLL RegisterOGRPGDump();
739 : void CPL_DLL RegisterOGROSM();
740 : void CPL_DLL RegisterOGRGPSBabel();
741 : void CPL_DLL RegisterOGRPDS();
742 : void CPL_DLL RegisterOGRWFS();
743 : void CPL_DLL RegisterOGROAPIF();
744 : void CPL_DLL RegisterOGRSOSI();
745 : void DeclareDeferredOGRSOSIPlugin();
746 : void CPL_DLL RegisterOGREDIGEO();
747 : void CPL_DLL RegisterOGRIdrisi();
748 : void CPL_DLL RegisterOGRXLS();
749 : void DeclareDeferredOGRXLSPlugin();
750 : void CPL_DLL RegisterOGRODS();
751 : void CPL_DLL RegisterOGRXLSX();
752 : void CPL_DLL RegisterOGRElastic();
753 : void DeclareDeferredOGRElasticPlugin();
754 : void CPL_DLL RegisterOGRGeoPackage();
755 : void CPL_DLL RegisterOGRCarto();
756 : void DeclareDeferredOGRCartoPlugin();
757 : void CPL_DLL RegisterOGRAmigoCloud();
758 : void CPL_DLL RegisterOGRSXF();
759 : void CPL_DLL RegisterOGROpenFileGDB();
760 : void DeclareDeferredOGROpenFileGDBPlugin();
761 : void CPL_DLL RegisterOGRSelafin();
762 : void CPL_DLL RegisterOGRJML();
763 : void CPL_DLL RegisterOGRPLSCENES();
764 : void DeclareDeferredOGRPLSCENESPlugin();
765 : void CPL_DLL RegisterOGRCSW();
766 : void CPL_DLL RegisterOGRMongoDBv3();
767 : void DeclareDeferredOGRMongoDBv3Plugin();
768 : void CPL_DLL RegisterOGRVDV();
769 : void CPL_DLL RegisterOGRGMLAS();
770 : void DeclareDeferredOGRGMLASPlugin();
771 : void CPL_DLL RegisterOGRMVT();
772 : void CPL_DLL RegisterOGRNGW();
773 : void CPL_DLL RegisterOGRMapML();
774 : void CPL_DLL RegisterOGRLVBAG();
775 : void CPL_DLL RegisterOGRHANA();
776 : void DeclareDeferredOGRHANAPlugin();
777 : void CPL_DLL RegisterOGRParquet();
778 : void DeclareDeferredOGRParquetPlugin();
779 : void CPL_DLL RegisterOGRArrow();
780 : void DeclareDeferredOGRArrowPlugin();
781 : void CPL_DLL RegisterOGRGTFS();
782 : void CPL_DLL RegisterOGRPMTiles();
783 : void CPL_DLL RegisterOGRJSONFG();
784 : void CPL_DLL RegisterOGRMiraMon();
785 : void CPL_DLL RegisterOGRXODR();
786 : void DeclareDeferredOGRXODRPlugin();
787 : void CPL_DLL RegisterOGRADBC();
788 : void DeclareDeferredOGRADBCPlugin();
789 : void CPL_DLL RegisterOGRAIVector();
790 : // @endcond
791 :
792 : CPL_C_END
793 :
794 : #endif /* ndef OGRSF_FRMTS_H_INCLUDED */
|