Skip to content

Commit

Permalink
return empty slice when there are no gcps
Browse files Browse the repository at this point in the history
  • Loading branch information
bavardage committed Jun 12, 2024
1 parent 835c0e0 commit 26ca1b1
Showing 1 changed file with 4 additions and 0 deletions.
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

0 comments on commit 26ca1b1

Please sign in to comment.