13#ifndef GDALALG_VECTOR_GEOM_INCLUDED
14#define GDALALG_VECTOR_GEOM_INCLUDED
16#include "gdalalg_vector_pipeline.h"
25class GDALVectorGeomAbstractAlgorithm
26 :
public GDALVectorPipelineStepAlgorithm
31 std::string m_activeLayer{};
32 std::string m_geomField{};
35 virtual std::unique_ptr<OGRLayerWithTranslateFeature>
36 CreateAlgLayer(
OGRLayer &srcLayer) = 0;
38 GDALVectorGeomAbstractAlgorithm(
const std::string &name,
39 const std::string &description,
40 const std::string &helpURL,
41 bool standaloneStep, OptionsBase &opts);
43 bool RunStep(GDALPipelineStepRunContext &ctxt)
override;
46 std::string &m_activeLayer;
54class GDALVectorGeomOneToOneAlgorithmLayer
55 :
public GDALVectorPipelineOutputLayer
60 return m_srcLayer.GetLayerDefn();
63 GIntBig GetFeatureCount(
int bForce)
override
65 if (!m_poAttrQuery && !m_poFilterGeom)
66 return m_srcLayer.GetFeatureCount(bForce);
73 return m_srcLayer.GetExtent(iGeomField, psExtent, bForce);
79 std::unique_ptr<OGRFeature>(m_srcLayer.GetFeature(nFID));
82 return TranslateFeature(std::move(poSrcFeature)).release();
85 int TestCapability(
const char *pszCap)
const override
94 return m_srcLayer.TestCapability(pszCap);
100 const typename T::Options m_opts;
102 GDALVectorGeomOneToOneAlgorithmLayer(
OGRLayer &oSrcLayer,
103 const typename T::Options &opts)
104 : GDALVectorPipelineOutputLayer(oSrcLayer), m_opts(opts)
108 if (!m_opts.m_geomField.empty())
111 m_opts.m_geomField.c_str());
115 m_iGeomIdx = INT_MAX;
119 bool IsSelectedGeomField(
int idx)
const
121 return m_iGeomIdx < 0 || idx == m_iGeomIdx;
124 virtual std::unique_ptr<OGRFeature>
125 TranslateFeature(std::unique_ptr<OGRFeature> poSrcFeature)
const = 0;
127 void TranslateFeature(
128 std::unique_ptr<OGRFeature> poSrcFeature,
129 std::vector<std::unique_ptr<OGRFeature>> &apoOutFeatures)
override
131 auto poDstFeature = TranslateFeature(std::move(poSrcFeature));
133 apoOutFeatures.push_back(std::move(poDstFeature));
152class GDALGeosNonStreamingAlgorithmLayer
153 :
public GDALVectorNonStreamingAlgorithmLayer
156 GDALGeosNonStreamingAlgorithmLayer(
OGRLayer &srcLayer,
int geomFieldIndex);
158 ~GDALGeosNonStreamingAlgorithmLayer()
override;
160 void ResetReading()
override;
164 bool Process(GDALProgressFunc pfnProgress,
void *pProgressData)
override;
166 std::unique_ptr<OGRFeature> GetNextProcessedFeature()
override;
168 virtual bool ProcessGeos() = 0;
171 virtual bool PolygonsOnly()
const = 0;
174 virtual bool SkipEmpty()
const = 0;
178 std::vector<GEOSGeometry *> m_apoGeosInputs{};
179 GEOSGeometry *m_poGeosResultAsCollection{
nullptr};
180 GEOSGeometry **m_papoGeosResults{
nullptr};
183 bool ConvertInputsToGeos(
OGRLayer &srcLayer,
int geomFieldIndex,
184 GDALProgressFunc pfnProgress,
void *pProgressData);
188 std::vector<std::unique_ptr<OGRFeature>> m_apoFeatures{};
189 unsigned int m_nGeosResultSize{0};
190 unsigned int m_readPos{0};
virtual CSLConstList GetMetadata(const char *pszDomain="")
Fetch metadata.
Definition gdalmajorobject.cpp:228
virtual const char * GetDescription() const
Fetch object description.
Definition gdalmajorobject.cpp:61
Simple container for a bounding region (rectangle)
Definition ogr_core.h:44
Definition of a feature class or feature layer.
Definition ogr_feature.h:521
virtual int GetGeomFieldIndex(const char *) const
Find geometry field by name.
Definition ogrfeaturedefn.cpp:957
A simple feature, including geometry and attributes.
Definition ogr_feature.h:1041
This class represents a layer of simple features, with access methods.
Definition ogrsf_frmts.h:61
virtual GIntBig GetFeatureCount(int bForce=TRUE)
Fetch the feature count in this layer.
Definition ogrlayer.cpp:204
virtual const OGRFeatureDefn * GetLayerDefn() const =0
Fetch the schema information for this layer.
#define EQUAL(a, b)
Alias for strcasecmp() == 0.
Definition cpl_port.h:532
#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
long long GIntBig
Large signed integer type (generally 64-bit integer type).
Definition cpl_port.h:195
#define OLCStringsAsUTF8
Layer capability for strings returned with UTF-8 \ encoding.
Definition ogr_core.h:1016
#define OLCFastFeatureCount
Layer capability for fast feature count retrieval .
Definition ogr_core.h:983
#define OLCZGeometries
Layer capability for geometry with Z dimension support.
Definition ogr_core.h:1028
#define OLCRandomRead
Layer capability for random read.
Definition ogr_core.h:977
#define OLCFastGetExtent
Layer capability for fast extent retrieval.
Definition ogr_core.h:986
#define OLCMeasuredGeometries
Layer capability for measured geometries support .
Definition ogr_core.h:1025
int OGRErr
Type for a OGR error.
Definition ogr_core.h:388
#define OLCCurveGeometries
Layer capability for curve geometries support.
Definition ogr_core.h:1023
struct GEOSContextHandle_HS * GEOSContextHandle_t
GEOS context handle type.
Definition ogr_geometry.h:110