13#ifndef OGRUNIONLAYER_H_INCLUDED
14#define OGRUNIONLAYER_H_INCLUDED
31 int bGeomTypeSet =
false;
33 OGREnvelope sStaticEnvelope{};
36 explicit OGRUnionLayerGeomFieldDefn(
const OGRGeomFieldDefn *poSrc);
37 explicit OGRUnionLayerGeomFieldDefn(
38 const OGRUnionLayerGeomFieldDefn *poSrc);
39 ~OGRUnionLayerGeomFieldDefn()
override;
48 FIELD_FROM_FIRST_LAYER,
49 FIELD_UNION_ALL_LAYERS,
50 FIELD_INTERSECTION_ALL_LAYERS,
54class CPL_DLL OGRUnionLayer final :
public OGRLayer
61 std::unique_ptr<OGRLayer> poLayerKeeper{};
62 OGRLayer *poLayer =
nullptr;
63 bool bModified =
false;
64 bool bCheckIfAutoWrap =
false;
68 Layer(OGRLayer *poLayerIn,
bool bOwnedIn)
69 : poLayerKeeper(bOwnedIn ? poLayerIn : nullptr),
70 poLayer(bOwnedIn ? poLayerKeeper.get() : poLayerIn)
74 Layer(Layer &&) =
default;
75 Layer &operator=(Layer &&) =
default;
77 OGRLayer *operator->()
82 const OGRLayer *operator->()
const
87 std::pair<OGRLayer *, bool> release()
89 const bool bOwnedBackup = poLayerKeeper !=
nullptr;
90 OGRLayer *poLayerBackup =
91 poLayerKeeper ? poLayerKeeper.release() : poLayer;
92 poLayerKeeper.reset();
93 return std::make_pair(poLayerBackup, bOwnedBackup);
96 void reset(std::unique_ptr<OGRLayer> poLayerIn)
98 poLayerKeeper = std::move(poLayerIn);
99 poLayer = poLayerKeeper.get();
105 std::vector<Layer> m_apoSrcLayers{};
107 mutable OGRFeatureDefn *poFeatureDefn =
nullptr;
109 OGRFieldDefn **papoFields =
nullptr;
111 OGRUnionLayerGeomFieldDefn **papoGeomFields =
nullptr;
112 FieldUnionStrategy eFieldStrategy = FIELD_UNION_ALL_LAYERS;
113 CPLString osSourceLayerFieldName{};
115 int bPreserveSrcFID =
false;
120 bool m_bHasAlreadyIteratedOverFeatures =
false;
121 char *pszAttributeFilter =
nullptr;
123 int *panMap =
nullptr;
124 CPLStringList m_aosIgnoredFields{};
125 mutable int bAttrFilterPassThroughValue = -1;
126 mutable const OGRSpatialReference *poGlobalSRS =
nullptr;
128 std::mutex m_oMutex{};
139 std::vector<FIDRange> m_fidRanges{};
140 bool m_fidRangesInvalid =
false;
141 bool m_fidRangesComplete =
false;
143 void AutoWarpLayerIfNecessary(
int iSubLayer);
144 std::unique_ptr<OGRFeature> TranslateFromSrcLayer(OGRFeature *poSrcFeature,
146 void ApplyAttributeFilterToSrcLayer(
int iSubLayer);
147 int GetAttrFilterPassThroughValue()
const;
148 void ConfigureActiveLayer();
149 void SetSpatialFilterToSourceLayer(OGRLayer *poSrcLayer);
153 const char *pszName,
int nSrcLayers,
157 int bTakeLayerOwnership);
159 ~OGRUnionLayer()
override;
165 FieldUnionStrategy eFieldStrategy,
int nFields,
166 OGRFieldDefn **papoFields,
168 OGRUnionLayerGeomFieldDefn *
170 void SetSourceLayerFieldName(
const char *pszSourceLayerFieldName);
171 void SetPreserveSrcFID(
int bPreserveSrcFID);
172 void SetFeatureCount(
int nFeatureCount);
174 const char *GetName()
const override
176 return osName.c_str();
181 void ResetReading()
override;
182 OGRFeature *GetNextFeature()
override;
184 OGRFeature *GetFeature(
GIntBig nFeatureId)
override;
186 OGRErr ICreateFeature(OGRFeature *poFeature)
override;
188 OGRErr ISetFeature(OGRFeature *poFeature)
override;
190 OGRErr IUpsertFeature(OGRFeature *poFeature)
override;
192 OGRErr IUpdateFeature(OGRFeature *poFeature,
int nUpdatedFieldsCount,
193 const int *panUpdatedFieldsIdx,
194 int nUpdatedGeomFieldsCount,
195 const int *panUpdatedGeomFieldsIdx,
196 bool bUpdateStyleString)
override;
198 const OGRFeatureDefn *GetLayerDefn()
const override;
202 GIntBig GetFeatureCount(
int)
override;
204 OGRErr SetAttributeFilter(
const char *)
override;
206 int TestCapability(
const char *)
const override;
208 OGRErr IGetExtent(
int iGeomField, OGREnvelope *psExtent,
209 bool bForce)
override;
211 virtual OGRErr ISetSpatialFilter(
int iGeomField,
212 const OGRGeometry *)
override;
216 OGRErr SyncToDisk()
override;
Definition of a geometry field of an OGRFeatureDefn.
Definition ogr_feature.h:332
virtual const OGRSpatialReference * GetSpatialRef() const
Fetch spatial reference system of this field.
Definition ogrgeomfielddefn.cpp:496
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:936
char ** CSLConstList
Type of a constant null-terminated list of nul terminated strings.
Definition cpl_port.h:1087
long long GIntBig
Large signed integer type (generally 64-bit integer type).
Definition cpl_port.h:205
OGRwkbGeometryType
List of well known binary geometry types.
Definition ogr_core.h:405
int OGRErr
Type for a OGR error.
Definition ogr_core.h:370
Classes related to registration of format support, and opening datasets.