Skip to content

Commit

Permalink
Merge pull request #11293 from rouault/OGRWarpedLayer_GetArrowStream
Browse files Browse the repository at this point in the history
OGRWarpedLayer: do not use source layer GetArrowStream() as this would skip reprojection...
  • Loading branch information
rouault authored Nov 20, 2024
2 parents 3cabd19 + c9d1eaf commit 52850a4
Show file tree
Hide file tree
Showing 3 changed files with 42 additions and 0 deletions.
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

0 comments on commit 52850a4

Please sign in to comment.