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