Skip to content

Commit

Permalink
Python: Allow a FeatureSource to be used multiple times
Browse files Browse the repository at this point in the history
  • Loading branch information
dbaston committed May 1, 2024
1 parent 0b924f9 commit ad54abf
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 0 deletions.
1 change: 1 addition & 0 deletions python/src/pybindings/feature_source_bindings.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@ class PyFeatureSourceBase : public FeatureSource

auto iter = py::iter(m_it);
if (iter == py::iterator::sentinel()) {
m_initialized = false;
return false;
}
m_feature = py::cast<py::object>(*iter);
Expand Down
2 changes: 2 additions & 0 deletions python/tests/test_feature_source.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ def test_gdal_feature_source():
fs = GDALFeatureSource(lyr)

assert fs.count() == 5
assert fs.count() == 5 # make sure we can iterate twice


def test_python_feature_source():
Expand All @@ -39,3 +40,4 @@ def test_python_feature_source():
fs = JSONFeatureSource(features)

assert fs.count() == 5
assert fs.count() == 5

0 comments on commit ad54abf

Please sign in to comment.