georust / geo

Geospatial primitives and algorithms for Rust
https://crates.io/crates/geo
Other
1.47k stars 190 forks source link

Implement getter methods on AffineTransform to access internal elements #1159

Closed weiji14 closed 1 month ago

weiji14 commented 3 months ago

Enable internal elements of the affine transform matrix to be retrieved using getter methods. Included some short documentation and a unit test.

Example usage:

use geo::AffineTransform;

let transform = AffineTransform::new(10.0, 0.0, 400_000.0, 0.0, -10.0, 500_000.0);

let a: f64 = transform.a();
let b: f64 = transform.b();
let xoff: f64 = transform.xoff();
let d: f64 = transform.d();
let e: f64 = transform.e();
let yoff: f64 = transform.yoff();

assert_eq!(transform, AffineTransform::new(a, b, xoff, d, e, yoff))

Fixes #1158

lnicola commented 3 months ago

I personally prefer methods (getters) instead of Index.

weiji14 commented 1 month ago

Anything else I can do to move this PR along?