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

Inplace functions should use mutable refs #93

Merged
merged 1 commit into from
Sep 30, 2020
Merged
Show file tree
Hide file tree
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
2 changes: 1 addition & 1 deletion src/spatial_ref/tests.rs
Original file line number Diff line number Diff line change
Expand Up @@ -92,7 +92,7 @@ fn transform_ogr_geometry() {
//let expected_value = "POLYGON ((5509543.150809700600803 1716062.191619219258428,5467122.000330002978444 1980151.204280239529908,5623571.028492723591626 2010213.310253676958382,5671834.921544363722205 1746968.078280254499987,5509543.150809700600803 1716062.191619219258428))";
//let expected_value = "POLYGON ((5509543.15080969966948 1716062.191619222285226,5467122.000330002047122 1980151.204280242323875,5623571.028492721728981 2010213.31025367998518,5671834.921544362790883 1746968.078280256595463,5509543.15080969966948 1716062.191619222285226))";
let expected_value = "POLYGON ((5509543.1508097 1716062.19161922,5467122.00033 1980151.20428024,5623571.02849272 2010213.31025368,5671834.92154436 1746968.07828026,5509543.1508097 1716062.19161922))";
let geom = Geometry::from_wkt(
let mut geom = Geometry::from_wkt(
"POLYGON((23.43 37.58, 23.43 40.0, 25.29 40.0, 25.29 37.58, 23.43 37.58))",
)
.unwrap();
Expand Down
4 changes: 2 additions & 2 deletions src/vector/geometry.rs
Original file line number Diff line number Diff line change
Expand Up @@ -182,7 +182,7 @@ impl Geometry {
}

// Transform the geometry inplace (when we own the Geometry)
pub fn transform_inplace(&self, htransform: &CoordTransform) -> Result<()> {
pub fn transform_inplace(&mut self, htransform: &CoordTransform) -> Result<()> {
let rv = unsafe { gdal_sys::OGR_G_Transform(self.c_geometry(), htransform.to_c_hct()) };
if rv != OGRErr::OGRERR_NONE {
Err(ErrorKind::OgrError {
Expand All @@ -206,7 +206,7 @@ impl Geometry {
Ok(unsafe { Geometry::with_c_geometry(new_c_geom, true) })
}

pub fn transform_to_inplace(&self, spatial_ref: &SpatialRef) -> Result<()> {
pub fn transform_to_inplace(&mut self, spatial_ref: &SpatialRef) -> Result<()> {
let rv = unsafe { gdal_sys::OGR_G_TransformTo(self.c_geometry(), spatial_ref.to_c_hsrs()) };
if rv != OGRErr::OGRERR_NONE {
Err(ErrorKind::OgrError {
Expand Down