Skip to content

Commit

Permalink
Merge branch 'release/geo-0.25.0'
Browse files Browse the repository at this point in the history
  • Loading branch information
michaelkirk committed May 17, 2023
2 parents c9fa18f + 72b2727 commit deb76f7
Show file tree
Hide file tree
Showing 4 changed files with 11 additions and 10 deletions.
4 changes: 3 additions & 1 deletion geo/CHANGES.md
Original file line number Diff line number Diff line change
@@ -1,10 +1,12 @@
# Changes

## UNRELEASED
## 0.25.0

- Added `CrossTrackDistance` trait to calculate the distance from a point
to the nearest point on a line
- <https://github.com/georust/geo/pull/961>
- Performance improvements for CoordinatePosition
- <https://github.com/georust/geo/pull/1004>
- BREAKING: Remove deprecated methods
- <https://github.com/georust/geo/pull/1012>
- Instead of `map_coords_inplace` use `map_coords_in_place`
Expand Down
2 changes: 1 addition & 1 deletion geo/Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
[package]
name = "geo"
description = "Geospatial primitives and algorithms"
version = "0.24.1"
version = "0.25.0"
license = "MIT OR Apache-2.0"
repository = "https://github.com/georust/geo"
documentation = "https://docs.rs/geo/"
Expand Down
14 changes: 7 additions & 7 deletions geo/src/algorithm/cross_track_distance.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
use num_traits::FromPrimitive;
use crate::{HaversineBearing, HaversineDistance, MEAN_EARTH_RADIUS};
use geo_types::{CoordFloat, Point};
use crate::{Bearing, HaversineDistance, MEAN_EARTH_RADIUS};
use num_traits::FromPrimitive;

/// Determine the cross track distance (also known as the cross track error) which is the shortest
/// distance between a point and a continuous line.
Expand Down Expand Up @@ -38,14 +38,14 @@ pub trait CrossTrackDistance<T, Rhs = Self> {
}

impl<T> CrossTrackDistance<T, Point<T>> for Point<T>
where
T: CoordFloat + FromPrimitive,
where
T: CoordFloat + FromPrimitive,
{
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.bearing(*self).to_radians();
let theta_12: T = line_point_a.bearing(*line_point_b).to_radians();
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 l_delta_xt: T = (l_delta_13.sin() * (theta_12 - theta_13).sin()).asin();
mean_earth_radius * l_delta_xt.abs()
}
Expand Down Expand Up @@ -113,4 +113,4 @@ mod test {
epsilon = 1.0
);
}
}
}
1 change: 0 additions & 1 deletion geo/src/algorithm/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -248,5 +248,4 @@ pub mod sweep;
/// Detect outliers in a group of points using [LOF](https://en.wikipedia.org/wiki/Local_outlier_factor)
pub mod outlier_detection;


pub use outlier_detection::OutlierDetection;

0 comments on commit deb76f7

Please sign in to comment.