Skip to content

Commit

Permalink
add axis_mapping_strategy handling
Browse files Browse the repository at this point in the history
  • Loading branch information
jdroenner committed Jun 17, 2020
1 parent 75eb504 commit 9fefb0e
Show file tree
Hide file tree
Showing 2 changed files with 27 additions and 0 deletions.
15 changes: 15 additions & 0 deletions src/spatial_ref/srs.rs
Original file line number Diff line number Diff line change
Expand Up @@ -304,6 +304,21 @@ impl SpatialRef {
}
}

#[cfg(feature = "gdal_3_0")]
pub fn set_axis_mapping_strategy(&self, strategy: gdal_sys::OSRAxisMappingStrategy::Type) {
unsafe {
gdal_sys::OSRSetAxisMappingStrategy(self.0, strategy);
}
}

#[cfg(feature = "gdal_3_0")]
pub fn get_axis_mapping_strategy(&self) -> gdal_sys::OSRAxisMappingStrategy::Type {
unsafe {
gdal_sys::OSRGetAxisMappingStrategy(self.0)
}
}


// TODO: should this take self instead of &self?
pub fn to_c_hsrs(&self) -> OGRSpatialReferenceH {
self.0
Expand Down
12 changes: 12 additions & 0 deletions src/spatial_ref/tests.rs
Original file line number Diff line number Diff line change
Expand Up @@ -167,3 +167,15 @@ fn auto_identify() {
spatial_ref.auto_identify_epsg().unwrap();
assert_eq!(spatial_ref.auth_code().unwrap(), 32632);
}


#[cfg(feature = "gdal_3_0")]
#[test]
fn axis_mapping_strategy() {
use gdal_sys;

let spatial_ref = SpatialRef::from_epsg(4326).unwrap();
assert_eq!(spatial_ref.get_axis_mapping_strategy(), gdal_sys::OSRAxisMappingStrategy::OAMS_AUTHORITY_COMPLIANT);
spatial_ref.set_axis_mapping_strategy(gdal_sys::OSRAxisMappingStrategy::OAMS_TRADITIONAL_GIS_ORDER);
assert_eq!(spatial_ref.get_axis_mapping_strategy(), gdal_sys::OSRAxisMappingStrategy::OAMS_TRADITIONAL_GIS_ORDER);
}

0 comments on commit 9fefb0e

Please sign in to comment.