31 #ifndef OGR_GENSQL_H_INCLUDED
32 #define OGR_GENSQL_H_INCLUDED
43 #define GEOM_FIELD_INDEX_TO_ALL_FIELD_INDEX(poFDefn, iGeom) \
44 ((poFDefn)->GetFieldCount() + SPECIAL_FIELD_COUNT + (iGeom))
46 #define IS_GEOM_FIELD_INDEX(poFDefn, idx) \
47 (((idx) >= (poFDefn)->GetFieldCount() + SPECIAL_FIELD_COUNT) && \
48 ((idx) < (poFDefn)->GetFieldCount() + SPECIAL_FIELD_COUNT + (poFDefn)->GetGeomFieldCount()))
50 #define ALL_FIELD_INDEX_TO_GEOM_FIELD_INDEX(poFDefn, idx) \
51 ((idx) - ((poFDefn)->GetFieldCount() + SPECIAL_FIELD_COUNT))
57 class CPL_DLL OGRGenSQLResultsLayer :
public OGRLayer
70 int *panGeomFieldToSrcGeomField;
82 GDALDataset **papoExtraDS;
85 std::vector<CPLString> m_oDistinctList;
90 void CreateOrderByIndex();
94 void SortIndexSection(
const OGRField *pasIndexFields,
96 size_t nStart,
size_t nEntries );
97 void FreeIndexFields(
OGRField *pasIndexFields,
99 bool bFreeArray =
true);
103 void ApplyFiltersToSource();
105 void FindAndSetIgnoredFields();
106 void ExploreExprForIgnoredFields(swq_expr_node* expr,
CPLHashSet* hSet);
107 void AddFieldDefnToSet(
int iTable,
int iColumn,
CPLHashSet* hSet);
109 int ContainGeomSpecialField(swq_expr_node* expr);
111 void InvalidateOrderByIndex();
113 int MustEvaluateSpatialFilterOnGenSQL();
116 OGRGenSQLResultsLayer( GDALDataset *poSrcDS,
119 const char *pszWHERE,
120 const char *pszDialect );
121 virtual ~OGRGenSQLResultsLayer();
133 virtual OGRErr GetExtent(OGREnvelope *psExtent,
int bForce = TRUE)
override {
return GetExtent(0, psExtent, bForce); }
134 virtual OGRErr GetExtent(
int iGeomField, OGREnvelope *psExtent,
int bForce = TRUE)
override;
virtual OGRFeatureDefn * GetLayerDefn()=0
Fetch the schema information for this layer.
virtual OGRErr SetAttributeFilter(const char *)
Set a new attribute query.
Definition: ogrlayer.cpp:337
virtual void SetSpatialFilter(OGRGeometry *)
Set a new spatial filter.
Definition: ogrlayer.cpp:1106
virtual OGRErr SetNextByIndex(GIntBig nIndex)
Move read cursor to the nIndex'th feature in the current resultset.
Definition: ogrlayer.cpp:497
virtual OGRGeometry * GetSpatialFilter()
This method returns the current spatial filter for this layer.
Definition: ogrlayer.cpp:1079
Definition: ogr_feature.h:207
Definition: cpl_hash_set.cpp:40
virtual OGRFeature * GetFeature(GIntBig nFID) CPL_WARN_UNUSED_RESULT
Fetch a feature by its identifier.
Definition: ogrlayer.cpp:445
virtual GIntBig GetFeatureCount(int bForce=TRUE)
Fetch the feature count in this layer.
Definition: ogrlayer.cpp:166
Definition: ogr_geometry.h:118
virtual int TestCapability(const char *)=0
Test if this layer supported the named capability.
virtual void ResetReading()=0
Reset feature reading to start on the first feature.
Definition: ogr_core.h:661
Definition: ogrsf_frmts.h:68
virtual OGRErr GetExtent(OGREnvelope *psExtent, int bForce=TRUE) CPL_WARN_UNUSED_RESULT
Fetch the extent of this layer.
Definition: ogrlayer.cpp:207
Definition: ogr_feature.h:279
virtual OGRFeature * GetNextFeature() CPL_WARN_UNUSED_RESULT=0
Fetch the next available feature from this layer.
long long GIntBig
Definition: cpl_port.h:250
int OGRErr
Definition: ogr_core.h:285