GDAL

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