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

OGRWarpedLayer: do not use source layer GetArrowStream() as this would skip reprojection... #11293

Merged
merged 1 commit into from
Nov 20, 2024
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
26 changes: 26 additions & 0 deletions autotest/ogr/ogr_vrt.py
Original file line number Diff line number Diff line change
Expand Up @@ -3361,3 +3361,29 @@ def test_ogr_vrt_geom_coordinate_precision():
assert prec.GetXYResolution() == 1e-5
assert prec.GetZResolution() == 1e-3
assert prec.GetMResolution() == 1e-2


###############################################################################
# Test OGRWarpedLayer and GetArrowStream


@pytest.mark.require_driver("GPKG")
def test_ogr_vrt_warped_arrow(tmp_vsimem):

src_ds = ogr.Open(
"""<OGRVRTDataSource>
<OGRVRTWarpedLayer>
<OGRVRTLayer name="foo">
<SrcDataSource>data/gpkg/2d_envelope.gpkg</SrcDataSource>
</OGRVRTLayer>
<TargetSRS>EPSG:32631</TargetSRS>
</OGRVRTWarpedLayer>
</OGRVRTDataSource>"""
)
out_filename = str(tmp_vsimem / "out.gpkg")
with gdal.config_option("OGR2OGR_USE_ARROW_API", "YES"):
gdal.VectorTranslate(out_filename, src_ds)
ds = ogr.Open(out_filename)
assert ds.GetLayer(0).GetExtent() == pytest.approx(
(166021.443080541, 500000, 0.0, 331593.179548329)
)
13 changes: 13 additions & 0 deletions ogr/ogrsf_frmts/generic/ogrwarpedlayer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -543,6 +543,9 @@ int OGRWarpedLayer::TestCapability(const char *pszCapability)

int bVal = m_poDecoratedLayer->TestCapability(pszCapability);

if (EQUAL(pszCapability, OLCFastGetArrowStream))
return false;

if (EQUAL(pszCapability, OLCFastSpatialFilter) ||
EQUAL(pszCapability, OLCRandomWrite) ||
EQUAL(pszCapability, OLCSequentialWrite))
Expand Down Expand Up @@ -572,4 +575,14 @@ void OGRWarpedLayer::SetExtent(double dfXMin, double dfYMin, double dfXMax,
sStaticEnvelope.MaxY = dfYMax;
}

/************************************************************************/
/* GetArrowStream() */
/************************************************************************/

bool OGRWarpedLayer::GetArrowStream(struct ArrowArrayStream *out_stream,
CSLConstList papszOptions)
{
return OGRLayer::GetArrowStream(out_stream, papszOptions);
}

#endif /* #ifndef DOXYGEN_SKIP */
3 changes: 3 additions & 0 deletions ogr/ogrsf_frmts/generic/ogrwarpedlayer.h
Original file line number Diff line number Diff line change
Expand Up @@ -85,6 +85,9 @@ class CPL_DLL OGRWarpedLayer : public OGRLayerDecorator
virtual OGRErr GetExtent(OGREnvelope *psExtent, int bForce = TRUE) override;

virtual int TestCapability(const char *) override;

virtual bool GetArrowStream(struct ArrowArrayStream *out_stream,
CSLConstList papszOptions = nullptr) override;
};

#endif /* #ifndef DOXYGEN_SKIP */
Expand Down
Loading