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

Changed return type of Layer::spatial_ref from Result to Option. #355

Merged
merged 1 commit into from
Dec 31, 2022
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
6 changes: 6 additions & 0 deletions CHANGES.md
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,12 @@

- Added prebuilt bindings for GDAL 3.6 (released 6 November 2022).

- <https://github.com/georust/gdal/pull/352>

- **Breaking**: `Layer::spatial_ref` returns `Option` instead of `Result`, thereby better reflecting the semantics documented in the [C++ API](https://gdal.org/doxygen/classOGRLayer.html#a75c06b4993f8eb76b569f37365cd19ab)

- <https://github.com/georust/gdal/pull/355>

## 0.14

- Added new content to `README.md` and the root docs.
Expand Down
9 changes: 6 additions & 3 deletions src/vector/layer.rs
Original file line number Diff line number Diff line change
Expand Up @@ -418,13 +418,16 @@ pub trait LayerAccess: Sized {

/// Fetch the spatial reference system for this layer.
///
/// Returns `Some(SpatialRef)`, or `None` if one isn't defined.
///
/// Refer [OGR_L_GetSpatialRef](https://gdal.org/doxygen/classOGRLayer.html#a75c06b4993f8eb76b569f37365cd19ab)
fn spatial_ref(&self) -> Result<SpatialRef> {
fn spatial_ref(&self) -> Option<SpatialRef> {
let c_obj = unsafe { gdal_sys::OGR_L_GetSpatialRef(self.c_layer()) };
if c_obj.is_null() {
return Err(_last_null_pointer_err("OGR_L_GetSpatialRef"));
None
} else {
unsafe { SpatialRef::from_c_obj(c_obj) }.ok()
}
unsafe { SpatialRef::from_c_obj(c_obj) }
}

fn reset_feature_reading(&mut self) {
Expand Down