Skip to content

Commit

Permalink
Convert Feature to use foreign_types.
Browse files Browse the repository at this point in the history
  • Loading branch information
metasim committed May 23, 2023
1 parent e0b240d commit 10a1310
Show file tree
Hide file tree
Showing 4 changed files with 80 additions and 111 deletions.
7 changes: 4 additions & 3 deletions src/raster/gcp.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
//! Raster ground control point support

use crate::spatial_ref::SpatialRef;
use foreign_types::ForeignTypeRef;
use crate::spatial_ref::SpatialRefRef;
use crate::Dataset;

impl Dataset {
Expand All @@ -11,14 +12,14 @@ impl Dataset {
/// the representation of ground control points, when embedded.
///
/// See: [`GDALGetGCPSpatialRef`](https://gdal.org/api/raster_c_api.html#_CPPv420GDALGetGCPSpatialRef12GDALDatasetH)
pub fn gcp_spatial_ref(&self) -> Option<SpatialRef> {
pub fn gcp_spatial_ref(&self) -> Option<&SpatialRefRef> {
let c_ptr = unsafe { gdal_sys::GDALGetGCPSpatialRef(self.c_dataset()) };

if c_ptr.is_null() {
return None;
}

unsafe { SpatialRef::from_c_obj(c_ptr) }.ok()
Some(unsafe { SpatialRefRef::from_ptr(c_ptr) })
}
}

Expand Down
4 changes: 3 additions & 1 deletion src/spatial_ref/srs.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ use gdal_sys::{self, OGRErr};
use std::ffi::{CStr, CString};
use std::ptr::{self};
use std::str::FromStr;
use foreign_types::{foreign_type, ForeignType};
use foreign_types::{foreign_type, ForeignType, ForeignTypeRef};

use crate::errors::*;

Expand Down Expand Up @@ -115,7 +115,9 @@ impl SpatialRef {
Ok(unsafe { Self::from_ptr(c_obj) })
}
}
}

impl SpatialRefRef {
pub fn to_wkt(&self) -> Result<String> {
let mut c_wkt = ptr::null_mut();
let rv = unsafe { gdal_sys::OSRExportToWkt(self.as_ptr(), &mut c_wkt) };
Expand Down
Loading

0 comments on commit 10a1310

Please sign in to comment.