13#ifndef OGRUNIONLAYER_H_INCLUDED
14#define OGRUNIONLAYER_H_INCLUDED
31 int bGeomTypeSet =
false;
33 OGREnvelope sStaticEnvelope{};
36 explicit OGRUnionLayerGeomFieldDefn(
const OGRGeomFieldDefn &oSrc);
37 OGRUnionLayerGeomFieldDefn(
const OGRUnionLayerGeomFieldDefn &oSrc);
38 OGRUnionLayerGeomFieldDefn(OGRUnionLayerGeomFieldDefn &&) =
default;
39 ~OGRUnionLayerGeomFieldDefn()
override;
41 OGRUnionLayerGeomFieldDefn &
42 operator=(
const OGRUnionLayerGeomFieldDefn &) =
delete;
43 OGRUnionLayerGeomFieldDefn &
44 operator=(OGRUnionLayerGeomFieldDefn &&) =
delete;
53 FIELD_FROM_FIRST_LAYER,
54 FIELD_UNION_ALL_LAYERS,
55 FIELD_INTERSECTION_ALL_LAYERS,
59class CPL_DLL OGRUnionLayer final :
public OGRLayer
66 std::unique_ptr<OGRLayer> poLayerKeeper{};
67 OGRLayer *poLayer =
nullptr;
68 bool bModified =
false;
69 bool bCheckIfAutoWrap =
false;
73 Layer(OGRLayer *poLayerIn,
bool bOwnedIn)
74 : poLayerKeeper(bOwnedIn ? poLayerIn : nullptr),
75 poLayer(bOwnedIn ? poLayerKeeper.get() : poLayerIn)
79 Layer(Layer &&) =
default;
80 Layer &operator=(Layer &&) =
default;
82 OGRLayer *operator->()
87 const OGRLayer *operator->()
const
92 std::pair<OGRLayer *, bool> release()
94 const bool bOwnedBackup = poLayerKeeper !=
nullptr;
95 OGRLayer *poLayerBackup =
96 poLayerKeeper ? poLayerKeeper.release() : poLayer;
97 poLayerKeeper.reset();
98 return std::make_pair(poLayerBackup, bOwnedBackup);
101 void reset(std::unique_ptr<OGRLayer> poLayerIn)
103 poLayerKeeper = std::move(poLayerIn);
104 poLayer = poLayerKeeper.get();
110 std::vector<Layer> m_apoSrcLayers{};
112 mutable OGRFeatureDefn *poFeatureDefn =
nullptr;
113 std::vector<std::unique_ptr<OGRFieldDefn>> apoFields{};
114 std::vector<std::unique_ptr<OGRUnionLayerGeomFieldDefn>> apoGeomFields{};
115 bool bUseGeomFields =
true;
116 FieldUnionStrategy eFieldStrategy = FIELD_UNION_ALL_LAYERS;
117 CPLString osSourceLayerFieldName{};
119 int bPreserveSrcFID =
false;
124 bool m_bHasAlreadyIteratedOverFeatures =
false;
125 char *pszAttributeFilter =
nullptr;
127 int *panMap =
nullptr;
128 CPLStringList m_aosIgnoredFields{};
129 mutable int bAttrFilterPassThroughValue = -1;
130 mutable const OGRSpatialReference *poGlobalSRS =
nullptr;
132 std::mutex m_oMutex{};
143 std::vector<FIDRange> m_fidRanges{};
144 bool m_fidRangesInvalid =
false;
145 bool m_fidRangesComplete =
false;
147 void AutoWarpLayerIfNecessary(
int iSubLayer);
148 std::unique_ptr<OGRFeature> TranslateFromSrcLayer(OGRFeature *poSrcFeature,
150 void ApplyAttributeFilterToSrcLayer(
int iSubLayer);
151 int GetAttrFilterPassThroughValue()
const;
152 void ConfigureActiveLayer();
153 void SetSpatialFilterToSourceLayer(OGRLayer *poSrcLayer);
157 const char *pszName,
int nSrcLayers,
161 int bTakeLayerOwnership);
163 ~OGRUnionLayer()
override;
169 FieldUnionStrategy eFieldStrategy,
int nFields,
170 const OGRFieldDefn *paoFields,
172 const OGRUnionLayerGeomFieldDefn
174 void SetFields(FieldUnionStrategy eFieldStrategy,
175 const OGRFeatureDefn *poFeatureDefnIn);
177 void SetSourceLayerFieldName(
const char *pszSourceLayerFieldName);
178 void SetPreserveSrcFID(
int bPreserveSrcFID);
179 void SetFeatureCount(
int nFeatureCount);
181 const char *GetName()
const override
183 return osName.c_str();
188 void ResetReading()
override;
189 OGRFeature *GetNextFeature()
override;
191 OGRFeature *GetFeature(
GIntBig nFeatureId)
override;
193 OGRErr ICreateFeature(OGRFeature *poFeature)
override;
195 OGRErr ISetFeature(OGRFeature *poFeature)
override;
197 OGRErr IUpsertFeature(OGRFeature *poFeature)
override;
199 OGRErr IUpdateFeature(OGRFeature *poFeature,
int nUpdatedFieldsCount,
200 const int *panUpdatedFieldsIdx,
201 int nUpdatedGeomFieldsCount,
202 const int *panUpdatedGeomFieldsIdx,
203 bool bUpdateStyleString)
override;
205 const OGRFeatureDefn *GetLayerDefn()
const override;
209 GIntBig GetFeatureCount(
int)
override;
211 OGRErr SetAttributeFilter(
const char *)
override;
213 int TestCapability(
const char *)
const override;
215 OGRErr IGetExtent(
int iGeomField, OGREnvelope *psExtent,
216 bool bForce)
override;
218 virtual OGRErr ISetSpatialFilter(
int iGeomField,
219 const OGRGeometry *)
override;
223 OGRErr SyncToDisk()
override;
Definition of a geometry field of an OGRFeatureDefn.
Definition ogr_feature.h:335
OGRGeomFieldDefn & operator=(const OGRGeomFieldDefn &oOther)
Copy assignment operator.
Definition ogrgeomfielddefn.cpp:156
virtual const OGRSpatialReference * GetSpatialRef() const
Fetch spatial reference system of this field.
Definition ogrgeomfielddefn.cpp:520
This class represents a layer of simple features, with access methods.
Definition ogrsf_frmts.h:61
#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:1101
char ** CSLConstList
Type of a constant null-terminated list of nul terminated strings.
Definition cpl_port.h:1252
long long GIntBig
Large signed integer type (generally 64-bit integer type).
Definition cpl_port.h:195
OGRwkbGeometryType
List of well known binary geometry types.
Definition ogr_core.h:423
int OGRErr
Type for a OGR error.
Definition ogr_core.h:388
Classes related to registration of format support, and opening datasets.