Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add compatibility with GDAL 3.11 RFC 107 #57

Merged
merged 2 commits into from
Feb 13, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 14 additions & 0 deletions ogrgrass.h
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@
#ifndef OGRGRASS_H_INCLUDED
#define OGRGRASS_H_INCLUDED

#include "gdal_version.h"
#include "ogrsf_frmts.h"

extern "C"
Expand Down Expand Up @@ -44,12 +45,19 @@ class OGRGRASSLayer final : public OGRLayer
return poFeatureDefn;
}
auto GetFeatureCount(int) -> GIntBig override;

#if GDAL_VERSION_NUM >= GDAL_COMPUTE_VERSION(3, 11, 0)
auto IGetExtent(int iGeomField, OGREnvelope *psExtent, bool bForce)
-> OGRErr override;
#else
auto GetExtent(OGREnvelope *psExtent, int bForce) -> OGRErr override;
virtual auto GetExtent(int iGeomField, OGREnvelope *psExtent, int bForce)
-> OGRErr override
{
return OGRLayer::GetExtent(iGeomField, psExtent, bForce);
}
#endif

virtual auto GetSpatialRef() -> OGRSpatialReference * override;
auto TestCapability(const char *) -> int override;

Expand All @@ -61,11 +69,17 @@ class OGRGRASSLayer final : public OGRLayer

// Filters
virtual auto SetAttributeFilter(const char *query) -> OGRErr override;

#if GDAL_VERSION_NUM >= GDAL_COMPUTE_VERSION(3, 11, 0)
virtual OGRErr ISetSpatialFilter(int iGeomField,
const OGRGeometry *poGeom) override;
#else
virtual void SetSpatialFilter(OGRGeometry *poGeomIn) override;
virtual void SetSpatialFilter(int iGeomField, OGRGeometry *poGeom) override
{
OGRLayer::SetSpatialFilter(iGeomField, poGeom);
}
#endif

private:
std::string osName;
Expand Down
24 changes: 22 additions & 2 deletions ogrgrasslayer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -618,11 +618,20 @@ auto OGRGRASSLayer::ResetSequentialCursor() -> bool
/************************************************************************/
/* SetSpatialFilter */
/************************************************************************/
#if GDAL_VERSION_NUM >= GDAL_COMPUTE_VERSION(3, 11, 0)
OGRErr OGRGRASSLayer::ISetSpatialFilter(int iGeomField,
const OGRGeometry *poGeomIn)
#else
void OGRGRASSLayer::SetSpatialFilter(OGRGeometry *poGeomIn)
#endif
{
CPLDebug("GRASS", "SetSpatialFilter");

#if GDAL_VERSION_NUM >= GDAL_COMPUTE_VERSION(3, 11, 0)
OGRLayer::ISetSpatialFilter(iGeomField, poGeomIn);
#else
OGRLayer::SetSpatialFilter(poGeomIn);
#endif

if (poGeomIn == nullptr)
{
Expand All @@ -632,10 +641,15 @@ void OGRGRASSLayer::SetSpatialFilter(OGRGeometry *poGeomIn)
CPLFree(paSpatialMatch);
paSpatialMatch = nullptr;
}
return;
}
else
{
SetSpatialMatch();
}

SetSpatialMatch();
#if GDAL_VERSION_NUM >= GDAL_COMPUTE_VERSION(3, 11, 0)
return OGRERR_NONE;
#endif
}

/************************************************************************/
Expand Down Expand Up @@ -1049,7 +1063,13 @@ auto OGRGRASSLayer::GetFeatureCount(int bForce) -> GIntBig
/* */
/* Returns OGRERR_NONE/OGRRERR_FAILURE. */
/************************************************************************/

#if GDAL_VERSION_NUM >= GDAL_COMPUTE_VERSION(3, 11, 0)
auto OGRGRASSLayer::IGetExtent(int /*iGeomField */, OGREnvelope *psExtent,
bool /*bForce*/) -> OGRErr
#else
auto OGRGRASSLayer::GetExtent(OGREnvelope *psExtent, int /*bForce*/) -> OGRErr
#endif
{
struct bound_box box
{
Expand Down