-
Notifications
You must be signed in to change notification settings - Fork 199
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
base: main
Are you sure you want to change the base?
Changes from 4 commits
5ae8bd9
d5af2a7
d8e54a0
1aa617a
305b13c
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -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(); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Would change the signature of this function so that it also returns |
||
let theta_12: T = line_point_a.haversine_bearing(*line_point_b).unwrap().to_radians(); | ||
let l_delta_xt: T = (l_delta_13.sin() * (theta_12 - theta_13).sin()).asin(); | ||
mean_earth_radius * l_delta_xt.abs() | ||
} | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -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(); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Would change signature to return result |
||
let crs_ab = p1.haversine_bearing(p2).unwrap().to_radians(); | ||
let crs_ba = if crs_ab > T::zero() { | ||
crs_ab - pi | ||
} else { | ||
crs_ab + pi | ||
}; | ||
let crs_bd = p2.haversine_bearing(*from).to_radians(); | ||
let crs_bd = p2.haversine_bearing(*from).unwrap().to_radians(); | ||
let d_crs1 = crs_ad - crs_ab; | ||
let d_crs2 = crs_bd - crs_ba; | ||
|
||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -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(); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Would change signature to return result |
||
let results: Vec<_> = (0..8) | ||
.map(|n| start.haversine_destination(bearing, n as f64 * 250_000.)) | ||
.collect(); | ||
|
There was a problem hiding this comment.
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.