Skip to content

Commit

Permalink
cargo fmt
Browse files Browse the repository at this point in the history
  • Loading branch information
phayes committed Mar 6, 2023
1 parent 1d1089a commit 390333d
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 10 deletions.
11 changes: 6 additions & 5 deletions geo/src/algorithm/geodesic_bearing.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
use crate::{Point};
use geographiclib_rs::{Geodesic, InverseGeodesic};
use crate::Point;
use geo_types::CoordNum;
use geographiclib_rs::{Geodesic, InverseGeodesic};

/// Returns the bearing to another Point in degrees on a geodesic.
///
Expand All @@ -26,7 +26,7 @@ pub trait GeodesicBearing<T: CoordNum> {
fn geodesic_bearing(&self, point: Point<T>) -> T;

/// Returns the bearing and distance to another Point in a (bearing, distance) tuple.
///
///
/// # Units
///
/// - `bearing`: degrees, zero degrees is north. East is 90°.
Expand Down Expand Up @@ -56,7 +56,8 @@ impl GeodesicBearing<f64> for Point<f64> {
}

fn geodesic_bearing_distance(&self, rhs: Point<f64>) -> (f64, f64) {
let (distance, azi1, _, _) = Geodesic::wgs84().inverse(self.y(), self.x(), rhs.y(), rhs.x());
let (distance, azi1, _, _) =
Geodesic::wgs84().inverse(self.y(), self.x(), rhs.y(), rhs.x());
(azi1, distance)
}
}
Expand All @@ -72,7 +73,7 @@ mod test {
let p_1 = point!(x: 9.177789688110352f64, y: 48.776781529534965);
let p_2 = p_1.geodesic_destination(45., 10000.);
let (b_1, d_1) = p_1.geodesic_bearing_distance(p_2);
assert_relative_eq!(b_1, 45., epsilon =1.0e-6);
assert_relative_eq!(b_1, 45., epsilon = 1.0e-6);
assert_relative_eq!(d_1, 10000.0, epsilon = 1.0e-6);

let p_3 = point!(x: 9., y: 47.);
Expand Down
10 changes: 5 additions & 5 deletions geo/src/algorithm/geodesic_destination.rs
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
use crate::Point;
use geographiclib_rs::{Geodesic, DirectGeodesic};
use geo_types::CoordNum;
use geographiclib_rs::{DirectGeodesic, Geodesic};

/// Returns a new Point using the distance to the existing Point and a bearing for the direction on a geodesic.
///
/// This uses the geodesic methods given by [Karney (2013)].
///
///
/// [Karney (2013)]: https://arxiv.org/pdf/1109.4448.pdf
pub trait GeodesicDestination<T: CoordNum> {
/// Returns a new Point using distance to the existing Point and a bearing for the direction.
Expand All @@ -20,12 +20,12 @@ pub trait GeodesicDestination<T: CoordNum> {
/// ```rust
/// use geo::GeodesicDestination;
/// use geo::Point;
///
///
/// // Determine the point 10000 km NE of JFK.
/// let jfk = Point::new(-73.78, 40.64);
/// let northeast_bearing = 45.0;
/// let distance = 10e6;
///
///
/// let p_1 = jfk.geodesic_destination(northeast_bearing, distance);
/// use approx::assert_relative_eq;
/// assert_relative_eq!(p_1.x(), 49.052487092959836);
Expand All @@ -50,7 +50,7 @@ mod test {
fn returns_a_new_point() {
let p_1 = Point::new(9.177789688110352, 48.776781529534965);
let p_2 = p_1.geodesic_destination(45., 10000.);
assert_eq!(p_2, Point::new(9.27411867078536, 48.8403266058781));
assert_eq!(p_2, Point::new(9.27411867078536, 48.8403266058781));
let distance = p_1.geodesic_distance(&p_2);
assert_relative_eq!(distance, 10000., epsilon = 1.0e-6)
}
Expand Down

0 comments on commit 390333d

Please sign in to comment.