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

return empty slice when there are no gcps #542

Merged
Merged
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
4 changes: 4 additions & 0 deletions src/gcp.rs
Original file line number Diff line number Diff line change
Expand Up @@ -144,6 +144,10 @@ impl Dataset {
/// See: [`GDALDataset::GetGCPs`](https://gdal.org/api/gdaldataset_cpp.html#_CPPv4N11GDALDataset7GetGCPsEv)
pub fn gcps(&self) -> &[GcpRef] {
let len = unsafe { gdal_sys::GDALGetGCPCount(self.c_dataset()) };
if len == 0 {
return &[];
}

let data = unsafe { gdal_sys::GDALGetGCPs(self.c_dataset()) };
unsafe { std::slice::from_raw_parts(data as *const GcpRef, len as usize) }
}
Expand Down
Loading