GDAL

ogreditablelayer.h
1/******************************************************************************
2 *
3 * Project: OpenGIS Simple Features Reference Implementation
4 * Purpose: Defines OGREditableLayer class
5 * Author: Even Rouault <even.rouault at spatialys.com>
6 *
7 ******************************************************************************
8 * Copyright (c) 2015, Even Rouault <even.rouault at spatialys.com>
9 *
10 * SPDX-License-Identifier: MIT
11 ****************************************************************************/
12
13#ifndef OGREDITABLELAYER_H_INCLUDED
14#define OGREDITABLELAYER_H_INCLUDED
15
17#include "ogrlayerdecorator.h"
18#include <set>
19#include <map>
20
21 class CPL_DLL IOGREditableLayerSynchronizer /* non final */
22{
23 public:
24 virtual ~IOGREditableLayerSynchronizer();
25
26 virtual OGRErr EditableSyncToDisk(OGRLayer *poEditableLayer,
27 OGRLayer **ppoDecoratedLayer) = 0;
28};
29
30 class CPL_DLL OGREditableLayer /* non final */ : public OGRLayerDecorator
31{
32 CPL_DISALLOW_COPY_ASSIGN(OGREditableLayer)
33
34 protected:
35 IOGREditableLayerSynchronizer *m_poSynchronizer;
36 bool m_bTakeOwnershipSynchronizer;
37 OGRFeatureDefn *m_poEditableFeatureDefn;
38 GIntBig m_nNextFID;
39 std::set<GIntBig> m_oSetCreated{};
40 std::set<GIntBig> m_oSetEdited{};
41 std::set<GIntBig> m_oSetDeleted{};
42 std::set<GIntBig>::iterator m_oIter{};
43 std::set<CPLString> m_oSetDeletedFields{};
44 OGRLayer *m_poMemLayer;
45 bool m_bStructureModified;
46 bool m_bSupportsCreateGeomField;
47 bool m_bSupportsCurveGeometries;
48 std::map<CPLString, int> m_oMapEditableFDefnFieldNameToIdx{};
49
50 OGRFeature *Translate(OGRFeatureDefn *poTargetDefn,
51 OGRFeature *poSrcFeature, bool bCanStealSrcFeature,
52 bool bHideDeletedFields);
53 void DetectNextFID();
54 int GetSrcGeomFieldIndex(int iGeomField);
55
56 public:
57 OGREditableLayer(OGRLayer *poDecoratedLayer,
58 bool bTakeOwnershipDecoratedLayer,
59 IOGREditableLayerSynchronizer *poSynchronizer,
60 bool bTakeOwnershipSynchronizer);
61 ~OGREditableLayer() override;
62
63 void SetNextFID(GIntBig nNextFID);
64 void SetSupportsCreateGeomField(bool SupportsCreateGeomField);
65 void SetSupportsCurveGeometries(bool bSupportsCurveGeometries);
66
67 OGRGeometry *GetSpatialFilter() override;
68 virtual OGRErr ISetSpatialFilter(int iGeomField,
69 const OGRGeometry *) override;
70
71 OGRErr SetAttributeFilter(const char *) override;
72 virtual bool GetArrowStream(struct ArrowArrayStream *out_stream,
73 CSLConstList papszOptions = nullptr) override;
74
75 void ResetReading() override;
76 OGRFeature *GetNextFeature() override;
77 OGRErr SetNextByIndex(GIntBig nIndex) override;
78 OGRFeature *GetFeature(GIntBig nFID) override;
79 OGRErr ISetFeature(OGRFeature *poFeature) override;
80 OGRErr ICreateFeature(OGRFeature *poFeature) override;
81 OGRErr IUpsertFeature(OGRFeature *poFeature) override;
82 OGRErr IUpdateFeature(OGRFeature *poFeature, int nUpdatedFieldsCount,
83 const int *panUpdatedFieldsIdx,
84 int nUpdatedGeomFieldsCount,
85 const int *panUpdatedGeomFieldsIdx,
86 bool bUpdateStyleString) override;
87 OGRErr DeleteFeature(GIntBig nFID) override;
88
89 OGRwkbGeometryType GetGeomType() const override;
90 using OGRLayerDecorator::GetLayerDefn;
91 const OGRFeatureDefn *GetLayerDefn() const override;
92
93 const OGRSpatialReference *GetSpatialRef() const override;
94
95 GIntBig GetFeatureCount(int bForce = TRUE) override;
96 OGRErr IGetExtent(int iGeomField, OGREnvelope *psExtent,
97 bool bForce) override;
98
99 int TestCapability(const char *) const override;
100
101 virtual OGRErr CreateField(const OGRFieldDefn *poField,
102 int bApproxOK = TRUE) override;
103 OGRErr DeleteField(int iField) override;
104 OGRErr ReorderFields(int *panMap) override;
105 virtual OGRErr AlterFieldDefn(int iField, OGRFieldDefn *poNewFieldDefn,
106 int nFlags) override;
107 virtual OGRErr
108 AlterGeomFieldDefn(int iGeomField,
109 const OGRGeomFieldDefn *poNewGeomFieldDefn,
110 int nFlags) override;
111
112 virtual OGRErr CreateGeomField(const OGRGeomFieldDefn *poField,
113 int bApproxOK = TRUE) override;
114
115 OGRErr SyncToDisk() override;
116
117 OGRErr StartTransaction() override;
118 OGRErr CommitTransaction() override;
119 OGRErr RollbackTransaction() override;
120
121 const char *GetGeometryColumn() const override;
122};
123
125
126#endif // OGREDITABLELAYER_H_INCLUDED
OGREnvelope
Simple container for a bounding region (rectangle)
Definition ogr_core.h:44
OGRFeatureDefn
Definition of a feature class or feature layer.
Definition ogr_feature.h:504
OGRFeature
A simple feature, including geometry and attributes.
Definition ogr_feature.h:934
OGRFieldDefn
Definition of an attribute of an OGRFeatureDefn.
Definition ogr_feature.h:69
OGRGeomFieldDefn
Definition of a geometry field of an OGRFeatureDefn.
Definition ogr_feature.h:332
OGRGeometry
Abstract base class for all geometry classes.
Definition ogr_geometry.h:357
OGRLayer
This class represents a layer of simple features, with access methods.
Definition ogrsf_frmts.h:61
OGRSpatialReference
This class represents an OpenGIS Spatial Reference System, and contains methods for converting betwee...
Definition ogr_spatialref.h:152
CPL_DISALLOW_COPY_ASSIGN
#define CPL_DISALLOW_COPY_ASSIGN(ClassName)
Helper to remove the copy and assignment constructors so that the compiler will not generate the defa...
Definition cpl_port.h:936
CSLConstList
char ** CSLConstList
Type of a constant null-terminated list of nul terminated strings.
Definition cpl_port.h:1087
GIntBig
long long GIntBig
Large signed integer type (generally 64-bit integer type).
Definition cpl_port.h:205
OGRwkbGeometryType
OGRwkbGeometryType
List of well known binary geometry types.
Definition ogr_core.h:405
OGRErr
int OGRErr
Type for a OGR error.
Definition ogr_core.h:370