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

GeodesicBearing and HaversineBearing return result #1161

Open
wants to merge 5 commits into
base: main
Choose a base branch
from

Conversation

cojmeister
Copy link

@cojmeister cojmeister commented Mar 13, 2024

  • I agree to follow the project's code of conduct.
  • I added an entry to CHANGES.md if knowledge of this change could be valuable to users.

I'm stuck in the comparison, I'm trying to implement the trait but I'm having issues. Any help would be appreciated.

@cojmeister cojmeister changed the title [WIP] GeodesicBearing and HaversineBearing return result GeodesicBearing and HaversineBearing return result Mar 13, 2024
@@ -44,8 +44,8 @@ where
fn cross_track_distance(&self, line_point_a: &Point<T>, line_point_b: &Point<T>) -> T {
let mean_earth_radius = T::from(MEAN_EARTH_RADIUS).unwrap();
let l_delta_13: T = line_point_a.haversine_distance(self) / mean_earth_radius;
let theta_13: T = line_point_a.haversine_bearing(*self).to_radians();
let theta_12: T = line_point_a.haversine_bearing(*line_point_b).to_radians();
let theta_13: T = line_point_a.haversine_bearing(*self).unwrap().to_radians();
Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Would change the signature of this function so that it also returns Result

@@ -102,14 +102,14 @@ where
}

let pi = T::from(std::f64::consts::PI).unwrap();
let crs_ad = p1.haversine_bearing(*from).to_radians();
let crs_ab = p1.haversine_bearing(p2).to_radians();
let crs_ad = p1.haversine_bearing(*from).unwrap().to_radians();
Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Would change signature to return result

@@ -92,7 +92,7 @@ mod test {
let pt2 = Point::new(-170.0, -30.0);

for (start, end) in [(pt1, pt2), (pt2, pt1)] {
let bearing = start.haversine_bearing(end);
let bearing = start.haversine_bearing(end).unwrap();
Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Would change signature to return result

Ok(())
}

fn check_y_in_limits(&self) -> Result<(), String> {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Points can be projected - they might not be lat/lon.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants