diff --git a/geo-types/CHANGES.md b/geo-types/CHANGES.md index e98141461..95375e2e1 100644 --- a/geo-types/CHANGES.md +++ b/geo-types/CHANGES.md @@ -8,6 +8,8 @@ * * Macros `coord!`, `point!`, `line_string!`, and `polygon!` now support trailing commas such as `coord! { x: 181.2, y: 51.79, }` * +* Internal cleanup: Explicitly declare `use-rstar_0_8` and `use-rstar_0_9` features to be explicit which rstar version is being used. For backward compatibility, the `use-rstar` feature will still enable `use-rstar_0_8`. + * * Add missing size_hint() method for point and coordinate iterators on LineString * * Add ExactsizeIterator impl for Points iterator on LineString diff --git a/geo-types/Cargo.toml b/geo-types/Cargo.toml index a847872c5..d05d49030 100644 --- a/geo-types/Cargo.toml +++ b/geo-types/Cargo.toml @@ -11,17 +11,19 @@ description = "Geospatial primitive data types" edition = "2021" [features] -use-rstar = ["rstar", "approx"] +# Prefer `use-rstar` feature rather than enabling rstar directly. +# rstar integration relies on the optional approx crate, but implicit features cannot yet enable other features. +# See: https://doc.rust-lang.org/nightly/cargo/reference/unstable.html#namespaced-features +rstar = ["rstar_0_8"] +use-rstar = ["use-rstar_0_8"] +use-rstar_0_8 = ["rstar_0_8", "approx"] use-rstar_0_9 = ["rstar_0_9", "approx"] [dependencies] approx = { version = "0.4.0", optional = true } arbitrary = { version = "1", optional = true } num-traits = "0.2" -# Prefer `use-rstar` feature rather than enabling rstar directly. -# rstar integration relies on the optional approx crate, but implicit features cannot yet enable other features. -# See: https://doc.rust-lang.org/nightly/cargo/reference/unstable.html#namespaced-features -rstar = { version = "0.8", optional = true } +rstar_0_8 = { package = "rstar", version = "0.8", optional = true } rstar_0_9 = { package = "rstar", version = "0.9", optional = true } serde = { version = "1", optional = true, features = ["derive"] } diff --git a/geo-types/src/coordinate.rs b/geo-types/src/coordinate.rs index f956b07cc..8196c8161 100644 --- a/geo-types/src/coordinate.rs +++ b/geo-types/src/coordinate.rs @@ -285,10 +285,10 @@ where } } -#[cfg(feature = "rstar")] -impl ::rstar::Point for Coordinate +#[cfg(feature = "rstar_0_8")] +impl ::rstar_0_8::Point for Coordinate where - T: ::num_traits::Float + ::rstar::RTreeNum, + T: ::num_traits::Float + ::rstar_0_8::RTreeNum, { type Scalar = T; diff --git a/geo-types/src/lib.rs b/geo-types/src/lib.rs index e9e00da9d..d832600b6 100644 --- a/geo-types/src/lib.rs +++ b/geo-types/src/lib.rs @@ -37,7 +37,7 @@ //! - `approx`: Allows geometry types to be checked for approximate equality with [approx] //! - `arbitrary`: Allows geometry types to be created from unstructured input with [arbitrary] //! - `serde`: Allows geometry types to be serialized and deserialized with [Serde] -//! - `use-rstar`: Allows geometry types to be inserted into [rstar] R*-trees (`rstar v0.8`) +//! - `use-rstar_0_8`: Allows geometry types to be inserted into [rstar] R*-trees (`rstar v0.8`) //! - `use-rstar_0_9`: Allows geometry types to be inserted into [rstar] R*-trees (`rstar v0.9`) //! //! [approx]: https://github.com/brendanzab/approx @@ -57,8 +57,8 @@ use std::fmt::Debug; #[macro_use] extern crate serde; -#[cfg(feature = "rstar")] -extern crate rstar; +#[cfg(feature = "rstar_0_8")] +extern crate rstar_0_8; #[cfg(test)] #[macro_use] @@ -129,7 +129,7 @@ mod macros; #[cfg(feature = "arbitrary")] mod arbitrary; -#[cfg(feature = "rstar")] +#[cfg(feature = "rstar_0_8")] #[doc(hidden)] pub mod private_utils; @@ -209,12 +209,12 @@ mod tests { assert_eq!(p.x(), 1_000_000i64); } - #[cfg(feature = "rstar")] + #[cfg(feature = "rstar_0_8")] #[test] /// ensure Line's SpatialObject impl is correct fn line_test() { - use rstar::primitives::Line as RStarLine; - use rstar::{PointDistance, RTreeObject}; + use rstar_0_8::primitives::Line as RStarLine; + use rstar_0_8::{PointDistance, RTreeObject}; let rl = RStarLine::new(Point::new(0.0, 0.0), Point::new(5.0, 5.0)); let l = Line::new(coord! { x: 0.0, y: 0.0 }, coord! { x: 5., y: 5. }); diff --git a/geo-types/src/line.rs b/geo-types/src/line.rs index e9785f024..be1e8fa94 100644 --- a/geo-types/src/line.rs +++ b/geo-types/src/line.rs @@ -221,6 +221,7 @@ impl + CoordNum> AbsDiffEq for Line { } } +#[cfg(any(feature = "rstar_0_8", feature = "rstar_0_9"))] macro_rules! impl_rstar_line { ($rstar:ident) => { impl ::$rstar::RTreeObject for Line @@ -247,8 +248,8 @@ macro_rules! impl_rstar_line { }; } -#[cfg(feature = "rstar")] -impl_rstar_line!(rstar); +#[cfg(feature = "rstar_0_8")] +impl_rstar_line!(rstar_0_8); #[cfg(feature = "rstar_0_9")] impl_rstar_line!(rstar_0_9); diff --git a/geo-types/src/line_string.rs b/geo-types/src/line_string.rs index 171bdf080..dce624064 100644 --- a/geo-types/src/line_string.rs +++ b/geo-types/src/line_string.rs @@ -473,6 +473,7 @@ impl + CoordNum> AbsDiffEq for LineString { } } +#[cfg(any(feature = "rstar_0_8", feature = "rstar_0_9"))] macro_rules! impl_rstar_line_string { ($rstar:ident) => { impl ::$rstar::RTreeObject for LineString @@ -513,8 +514,8 @@ macro_rules! impl_rstar_line_string { }; } -#[cfg(feature = "rstar")] -impl_rstar_line_string!(rstar); +#[cfg(feature = "rstar_0_8")] +impl_rstar_line_string!(rstar_0_8); #[cfg(feature = "rstar_0_9")] impl_rstar_line_string!(rstar_0_9); diff --git a/geo-types/src/point.rs b/geo-types/src/point.rs index 6caeb354a..5c959d82d 100644 --- a/geo-types/src/point.rs +++ b/geo-types/src/point.rs @@ -547,11 +547,11 @@ where } } -#[cfg(feature = "rstar")] +#[cfg(feature = "rstar_0_8")] // These are required for rstar RTree -impl ::rstar::Point for Point +impl ::rstar_0_8::Point for Point where - T: ::num_traits::Float + ::rstar::RTreeNum, + T: ::num_traits::Float + ::rstar_0_8::RTreeNum, { type Scalar = T; diff --git a/geo/Cargo.toml b/geo/Cargo.toml index 8c3fa987c..929f68c5f 100644 --- a/geo/Cargo.toml +++ b/geo/Cargo.toml @@ -18,17 +18,17 @@ use-serde = ["serde", "geo-types/serde"] [dependencies] geo-types = { version = "0.7.3", features = ["approx", "use-rstar"] } -geographiclib-rs = { version = "0.2" } +geographiclib-rs = "0.2" log = "0.4.11" num-traits = "0.2" proj = { version = "0.25.2", optional = true } -robust = { version = "0.2.2" } -rstar = { version = "0.8" } +robust = "0.2.2" +rstar = "0.8" serde = { version = "1.0", optional = true, features = ["derive"] } [dev-dependencies] approx = "0.4.0" -criterion = { version = "0.3" } +criterion = "0.3" geo-test-fixtures = { path = "../geo-test-fixtures" } # jts-test-runner is an internal crate which exists only to be part of the geo test suite. # As such it's kept unpublished. It's in a separate repo primarily because it's kind of large.