From 24ea5355992bacb9814986e1f14ccf7fe5ff7e40 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Johannes=20Dr=C3=B6nner?= Date: Fri, 6 Aug 2021 09:18:19 +0200 Subject: [PATCH 1/3] set_attribute_filter shouild take &mut self --- src/vector/layer.rs | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/src/vector/layer.rs b/src/vector/layer.rs index a1de4a00..cf162b5e 100644 --- a/src/vector/layer.rs +++ b/src/vector/layer.rs @@ -339,10 +339,12 @@ impl<'a> Layer<'a> { /// Set a new attribute query that restricts features when using the feature iterator. /// + /// From the GDAL docs: Note that installing a query string will generally result in resetting the current reading position + /// /// Parameters: /// - `query` in restricted SQL WHERE format /// - pub fn set_attribute_filter(&self, query: &str) -> Result<()> { + pub fn set_attribute_filter(&mut self, query: &str) -> Result<()> { let c_str = CString::new(query)?; let rv = unsafe { gdal_sys::OGR_L_SetAttributeFilter(self.c_layer, c_str.as_ptr()) }; @@ -357,7 +359,10 @@ impl<'a> Layer<'a> { } /// Clear the attribute filter set on this layer - pub fn clear_attribute_filter(&self) { + /// + /// From the GDAL docs: Note that installing a query string will generally result in resetting the current reading position + /// + pub fn clear_attribute_filter(&mut self) { unsafe { gdal_sys::OGR_L_SetAttributeFilter(self.c_layer, null_mut()); } From b1b9e0b5119080e82e4dc96ba24fc88683d7e8c2 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Johannes=20Dr=C3=B6nner?= Date: Fri, 6 Aug 2021 14:32:44 +0200 Subject: [PATCH 2/3] add changes --- CHANGES.md | 3 +++ 1 file changed, 3 insertions(+) diff --git a/CHANGES.md b/CHANGES.md index 7694df7b..4912510d 100644 --- a/CHANGES.md +++ b/CHANGES.md @@ -2,6 +2,9 @@ ## Unreleased +- Make `set_attribute_filter` and `clear_attribute_filter` take `&mut self` + - + - **Breaking**: Drop pre-build bindings for GDAL versions < 2.4. The bindgen feature can be used to generate bindings for older versions. - Fix memory leaks reported by Valgrind. This required re-generation of the pre-build bindings. - From 78c88e305f6c80e2db6b6aa1dc8243bf0aa05952 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Johannes=20Dr=C3=B6nner?= Date: Fri, 6 Aug 2021 14:37:42 +0200 Subject: [PATCH 3/3] Update CHANGES.md MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Co-authored-by: Laurențiu Nicola --- CHANGES.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/CHANGES.md b/CHANGES.md index 4912510d..ef07555d 100644 --- a/CHANGES.md +++ b/CHANGES.md @@ -2,7 +2,7 @@ ## Unreleased -- Make `set_attribute_filter` and `clear_attribute_filter` take `&mut self` +- **Breaking**: Make `set_attribute_filter` and `clear_attribute_filter` take `&mut self` - - **Breaking**: Drop pre-build bindings for GDAL versions < 2.4. The bindgen feature can be used to generate bindings for older versions.