-
Notifications
You must be signed in to change notification settings - Fork 96
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
5 changed files
with
81 additions
and
53 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Binary file not shown.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,39 @@ | ||
//! Raster ground control point support | ||
use crate::Dataset; | ||
use crate::spatial_ref::SpatialRef; | ||
|
||
impl Dataset { | ||
/// Get output spatial reference system for GCPs. | ||
/// | ||
/// # Notes | ||
/// * This is separate and distinct from [`Dataset::spatial_ref`], and only applies to | ||
/// 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> { | ||
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() | ||
} | ||
} | ||
|
||
#[cfg(test)] | ||
mod tests { | ||
use crate::Dataset; | ||
use crate::test_utils::fixture; | ||
|
||
#[test] | ||
fn test_gcp_spatial_ref() { | ||
let dataset = Dataset::open(fixture("gcp.tif")).unwrap(); | ||
let gcp_srs = dataset.gcp_spatial_ref(); | ||
let auth = gcp_srs.and_then(|s| s.authority().ok()); | ||
assert_eq!(auth.unwrap(), "EPSG:4326"); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters