diff --git a/geo-types/src/coordinate.rs b/geo-types/src/coordinate.rs index aa20cc656..450e3961c 100644 --- a/geo-types/src/coordinate.rs +++ b/geo-types/src/coordinate.rs @@ -1,6 +1,6 @@ use crate::{CoordinateType, Point}; -#[cfg(any(test, feature = "relative_eq"))] +#[cfg(any(feature = "relative_eq", test))] use approx::{AbsDiffEq, RelativeEq}; #[cfg(test)] @@ -243,7 +243,7 @@ impl Zero for Coordinate { } } -#[cfg(any(test, feature = "relative_eq"))] +#[cfg(feature = "relative_eq")] impl AbsDiffEq for Coordinate where T::Epsilon: Copy, @@ -261,7 +261,7 @@ where } } -#[cfg(any(test, feature = "relative_eq"))] +#[cfg(feature = "relative_eq")] impl RelativeEq for Coordinate where T::Epsilon: Copy, diff --git a/geo-types/src/line.rs b/geo-types/src/line.rs index 90a49a02c..a0a6f3a59 100644 --- a/geo-types/src/line.rs +++ b/geo-types/src/line.rs @@ -1,7 +1,7 @@ use crate::{Coordinate, CoordinateType, Point}; -#[cfg(any(feature = "relative_eq", test))] +#[cfg(feature = "relative_eq")] use approx::AbsDiffEq; -#[cfg(any(feature = "relative_eq", test))] +#[cfg(feature = "relative_eq")] use approx::RelativeEq; /// A line segment made up of exactly two diff --git a/geo-types/src/line_string.rs b/geo-types/src/line_string.rs index 38f6647e7..f24541cdb 100644 --- a/geo-types/src/line_string.rs +++ b/geo-types/src/line_string.rs @@ -405,7 +405,7 @@ where } } -#[cfg(all(test, feature = "relative_eq"))] +#[cfg(test)] mod test { use super::*; diff --git a/geo-types/src/multi_point.rs b/geo-types/src/multi_point.rs index ca2df25b3..1a3a978fe 100644 --- a/geo-types/src/multi_point.rs +++ b/geo-types/src/multi_point.rs @@ -1,5 +1,5 @@ use crate::{CoordinateType, Point}; -#[cfg(any(feature = "relative_eq"))] +#[cfg(feature = "relative_eq")] use approx::AbsDiffEq; #[cfg(feature = "relative_eq")] use approx::RelativeEq; diff --git a/geo/Cargo.toml b/geo/Cargo.toml index 96a5c5862..12097a746 100644 --- a/geo/Cargo.toml +++ b/geo/Cargo.toml @@ -22,20 +22,20 @@ geographiclib-rs = { version = "0.2" } proj = { version = "0.20.3", optional = true } -geo-types = { version = "0.6.2", path = "../geo-types", features = ["relative_eq", "rstar"] } -approx= { version = "0.4.0", optional = true } +geo-types = { version = "0.6.2", optional = true, path = "../geo-types", features = ["rstar"] } + robust = { version = "0.2.2" } [features] -default = [] +default = ["geo-types"] use-proj = ["proj"] proj-network = ["use-proj", "proj/network"] use-serde = ["serde", "geo-types/serde"] -relative_eq = ["approx"] [dev-dependencies] approx = "0.4.0" criterion = { version = "0.3" } +geo-types = { version = "0.6.2", path = "../geo-types", features = ["relative_eq", "rstar"] } rand = "0.8.0" [[bench]] diff --git a/geo/src/algorithm/rotate.rs b/geo/src/algorithm/rotate.rs index 9fccef44c..97013234a 100644 --- a/geo/src/algorithm/rotate.rs +++ b/geo/src/algorithm/rotate.rs @@ -221,6 +221,7 @@ where mod test { use super::*; use crate::{line_string, point, polygon, Coordinate, Point}; + use approx::assert_relative_eq; #[test] fn test_rotate_around_point() { @@ -334,16 +335,13 @@ mod test { #[test] fn test_rotate_line() { let line0 = Line::from([(0., 0.), (0., 2.)]); - let line1 = Line::from([(1., 0.9999999999999999), (-1., 1.)]); - assert_eq!(line0.rotate(90.), line1); + let line1 = Line::from([(1., 1.), (-1., 1.)]); + assert_relative_eq!(line0.rotate(90.0), line1); } #[test] fn test_rotate_line_around_point() { let line0 = Line::new(Point::new(0., 0.), Point::new(0., 2.)); - let line1 = Line::new( - Point::new(0., 0.), - Point::new(-2., 0.00000000000000012246467991473532), - ); - assert_eq!(line0.rotate_around_point(90., Point::new(0., 0.)), line1); + let line1 = Line::new(Point::new(0., 0.), Point::new(-2., 0.)); + assert_relative_eq!(line0.rotate_around_point(90., Point::new(0., 0.)), line1); } }