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