Skip to content

Commit

Permalink
Merge branch 'georust:main' into vector-ops-proposal
Browse files Browse the repository at this point in the history
  • Loading branch information
thehappycheese authored Jul 31, 2023
2 parents 006a48c + 2ab2b27 commit 10b7f08
Show file tree
Hide file tree
Showing 16 changed files with 783 additions and 36 deletions.
36 changes: 18 additions & 18 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -43,12 +43,12 @@ jobs:
matrix:
container_image:
# Use the latest stable version. No need for older versions.
- "georust/geo-ci:rust-1.66"
- "georust/geo-ci:proj-9.2.1-rust-1.70"
container:
image: ${{ matrix.container_image }}
steps:
- name: Checkout repository
uses: actions/checkout@v2
uses: actions/checkout@v3
- run: rustup component add rustfmt clippy
- run: cargo fmt --all -- --check
- run: cargo clippy --all-features --all-targets -- -Dwarnings
Expand All @@ -67,15 +67,15 @@ jobs:
# giving us about 6 months of coverage.
#
# Minimum supported rust version (MSRV)
- "georust/geo-ci:rust-1.63"
- "georust/geo-ci:proj-9.2.1-rust-1.63"
# Two most recent releases - we omit older ones for expedient CI
- "georust/geo-ci:rust-1.65"
- "georust/geo-ci:rust-1.66"
- "georust/geo-ci:proj-9.2.1-rust-1.69"
- "georust/geo-ci:proj-9.2.1-rust-1.70"
container:
image: ${{ matrix.container_image }}
steps:
- name: Checkout repository
uses: actions/checkout@v2
uses: actions/checkout@v3
- run: rustup target add thumbv7em-none-eabihf
- run: cargo check --all-targets --no-default-features
- run: cargo check --lib --target thumbv7em-none-eabihf --no-default-features -F use-rstar_0_9,serde
Expand All @@ -95,15 +95,15 @@ jobs:
# giving us about 6 months of coverage.
#
# Minimum supported rust version (MSRV)
- "georust/geo-ci:rust-1.63"
- "georust/geo-ci:proj-9.2.1-rust-1.63"
# Two most recent releases - we omit older ones for expedient CI
- "georust/geo-ci:rust-1.65"
- "georust/geo-ci:rust-1.66"
- "georust/geo-ci:proj-9.2.1-rust-1.69"
- "georust/geo-ci:proj-9.2.1-rust-1.70"
container:
image: ${{ matrix.container_image }}
steps:
- name: Checkout repository
uses: actions/checkout@v2
uses: actions/checkout@v3
- run: cargo check --all-targets --no-default-features
# we don't want to test `proj-network` because it only enables the `proj` feature
- run: cargo test --features "use-proj use-serde"
Expand All @@ -122,15 +122,15 @@ jobs:
# giving us about 6 months of coverage.
#
# Minimum supported rust version (MSRV)
- "georust/geo-ci:rust-1.63"
- "georust/geo-ci:proj-9.2.1-rust-1.63"
# Two most recent releases - we omit older ones for expedient CI
- "georust/geo-ci:rust-1.65"
- "georust/geo-ci:rust-1.66"
- "georust/geo-ci:proj-9.2.1-rust-1.69"
- "georust/geo-ci:proj-9.2.1-rust-1.70"
container:
image: ${{ matrix.container_image }}
steps:
- name: Checkout repository
uses: actions/checkout@v2
uses: actions/checkout@v3
- run: cargo check --all-targets
- run: cargo test

Expand All @@ -145,21 +145,21 @@ jobs:
matrix:
container_image:
# Fuzz only on latest
- "georust/geo-ci:rust-1.66"
- "georust/geo-ci:proj-9.2.1-rust-1.70"
container:
image: ${{ matrix.container_image }}
steps:
- name: Checkout repository
uses: actions/checkout@v2
uses: actions/checkout@v3
- run: cargo build --bins

bench:
name: bench
runs-on: ubuntu-latest
if: "!contains(github.event.head_commit.message, '[skip ci]')"
container:
image: georust/geo-ci:rust-1.66
image: georust/geo-ci:proj-9.2.1-rust-1.70
steps:
- name: Checkout repository
uses: actions/checkout@v2
uses: actions/checkout@v3
- run: cargo bench --no-run
10 changes: 5 additions & 5 deletions geo-bool-ops-benches/benches/boolean_ops.rs
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ fn run_complex<T: Measurement>(c: &mut Criterion<T>) {
|b, _| {
b.iter_batched(
polys.sampler(),
|&(ref poly, ref poly2, _, _)| poly.intersection(poly2),
|(poly, poly2, _, _)| poly.intersection(poly2),
BatchSize::SmallInput,
);
},
Expand All @@ -55,7 +55,7 @@ fn run_complex<T: Measurement>(c: &mut Criterion<T>) {
group.bench_with_input(BenchmarkId::new("bops::union", steps), &(), |b, _| {
b.iter_batched(
polys.sampler(),
|&(ref poly, ref poly2, _, _)| poly.union(poly2),
|(poly, poly2, _, _)| poly.union(poly2),
BatchSize::SmallInput,
);
});
Expand All @@ -66,7 +66,7 @@ fn run_complex<T: Measurement>(c: &mut Criterion<T>) {
|b, _| {
b.iter_batched(
polys.sampler(),
|&(_, _, ref poly, ref poly2)| OtherBooleanOp::intersection(poly, poly2),
|(_, _, poly, poly2)| OtherBooleanOp::intersection(poly, poly2),
BatchSize::SmallInput,
);
},
Expand All @@ -75,15 +75,15 @@ fn run_complex<T: Measurement>(c: &mut Criterion<T>) {
group.bench_with_input(BenchmarkId::new("rgbops::union", steps), &(), |b, _| {
b.iter_batched(
polys.sampler(),
|&(_, _, ref poly, ref poly2)| OtherBooleanOp::union(poly, poly2),
|(_, _, poly, poly2)| OtherBooleanOp::union(poly, poly2),
BatchSize::SmallInput,
);
});

group.bench_with_input(BenchmarkId::new("geo::relate", steps), &(), |b, _| {
b.iter_batched(
polys.sampler(),
|&(ref poly, ref poly2, _, _)| poly.relate(poly2).is_intersects(),
|(poly, poly2, _, _)| poly.relate(poly2).is_intersects(),
BatchSize::SmallInput,
);
});
Expand Down
6 changes: 5 additions & 1 deletion geo-types/CHANGES.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,10 @@
# Changes

## Unreleased
## 0.7.11
* Bump rstar dependency
<https://github.com/georust/geo/pull/1030>

## 0.7.10

* Implement `From<&Line>` for `LineString`

Expand Down
6 changes: 4 additions & 2 deletions geo-types/Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[package]
name = "geo-types"
version = "0.7.9"
version = "0.7.11"
license = "MIT OR Apache-2.0"
repository = "https://github.com/georust/geo"
documentation = "https://docs.rs/geo-types/"
Expand All @@ -12,7 +12,7 @@ edition = "2021"

[features]
default = ["std"]
std = ["approx/std", "num-traits/std", "serde/std"]
std = ["approx?/std", "num-traits/std", "serde?/std"]
# 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
Expand All @@ -21,6 +21,7 @@ use-rstar = ["use-rstar_0_8"]
use-rstar_0_8 = ["rstar_0_8", "approx"]
use-rstar_0_9 = ["rstar_0_9", "approx"]
use-rstar_0_10 = ["rstar_0_10", "approx"]
use-rstar_0_11 = ["rstar_0_11", "approx"]

[dependencies]
approx = { version = ">= 0.4.0, < 0.6.0", optional = true, default-features = false }
Expand All @@ -29,6 +30,7 @@ num-traits = { version = "0.2", default-features = false, features = ["libm"] }
rstar_0_8 = { package = "rstar", version = "0.8", optional = true }
rstar_0_9 = { package = "rstar", version = "0.9", optional = true }
rstar_0_10 = { package = "rstar", version = "0.10", optional = true }
rstar_0_11 = { package = "rstar", version = "0.11", optional = true }
serde = { version = "1", optional = true, default-features = false, features = ["alloc", "derive"] }

[dev-dependencies]
Expand Down
36 changes: 36 additions & 0 deletions geo-types/src/geometry/coord.rs
Original file line number Diff line number Diff line change
Expand Up @@ -426,3 +426,39 @@ where
}
}
}

#[cfg(feature = "rstar_0_11")]
impl<T> ::rstar_0_11::Point for Coord<T>
where
T: ::num_traits::Float + ::rstar_0_11::RTreeNum,
{
type Scalar = T;

const DIMENSIONS: usize = 2;

#[inline]
fn generate(mut generator: impl FnMut(usize) -> Self::Scalar) -> Self {
coord! {
x: generator(0),
y: generator(1),
}
}

#[inline]
fn nth(&self, index: usize) -> Self::Scalar {
match index {
0 => self.x,
1 => self.y,
_ => unreachable!(),
}
}

#[inline]
fn nth_mut(&mut self, index: usize) -> &mut Self::Scalar {
match index {
0 => &mut self.x,
1 => &mut self.y,
_ => unreachable!(),
}
}
}
10 changes: 9 additions & 1 deletion geo-types/src/geometry/line.rs
Original file line number Diff line number Diff line change
Expand Up @@ -221,7 +221,12 @@ impl<T: AbsDiffEq<Epsilon = T> + CoordNum> AbsDiffEq for Line<T> {
}
}

#[cfg(any(feature = "rstar_0_8", feature = "rstar_0_9", feature = "rstar_0_10"))]
#[cfg(any(
feature = "rstar_0_8",
feature = "rstar_0_9",
feature = "rstar_0_10",
feature = "rstar_0_11"
))]
macro_rules! impl_rstar_line {
($rstar:ident) => {
impl<T> ::$rstar::RTreeObject for Line<T>
Expand Down Expand Up @@ -257,6 +262,9 @@ impl_rstar_line!(rstar_0_9);
#[cfg(feature = "rstar_0_10")]
impl_rstar_line!(rstar_0_10);

#[cfg(feature = "rstar_0_11")]
impl_rstar_line!(rstar_0_11);

#[cfg(test)]
mod test {
use super::*;
Expand Down
10 changes: 9 additions & 1 deletion geo-types/src/geometry/line_string.rs
Original file line number Diff line number Diff line change
Expand Up @@ -486,7 +486,12 @@ impl<T: AbsDiffEq<Epsilon = T> + CoordNum> AbsDiffEq for LineString<T> {
}
}

#[cfg(any(feature = "rstar_0_8", feature = "rstar_0_9", feature = "rstar_0_10"))]
#[cfg(any(
feature = "rstar_0_8",
feature = "rstar_0_9",
feature = "rstar_0_10",
feature = "rstar_0_11"
))]
macro_rules! impl_rstar_line_string {
($rstar:ident) => {
impl<T> ::$rstar::RTreeObject for LineString<T>
Expand Down Expand Up @@ -536,6 +541,9 @@ impl_rstar_line_string!(rstar_0_9);
#[cfg(feature = "rstar_0_10")]
impl_rstar_line_string!(rstar_0_10);

#[cfg(feature = "rstar_0_11")]
impl_rstar_line_string!(rstar_0_11);

#[cfg(test)]
mod test {
use super::*;
Expand Down
29 changes: 29 additions & 0 deletions geo-types/src/geometry/point.rs
Original file line number Diff line number Diff line change
Expand Up @@ -674,6 +674,35 @@ where
}
}

#[cfg(feature = "rstar_0_11")]
impl<T> ::rstar_0_11::Point for Point<T>
where
T: ::num_traits::Float + ::rstar_0_11::RTreeNum,
{
type Scalar = T;

const DIMENSIONS: usize = 2;

fn generate(mut generator: impl FnMut(usize) -> Self::Scalar) -> Self {
Point::new(generator(0), generator(1))
}

fn nth(&self, index: usize) -> Self::Scalar {
match index {
0 => self.0.x,
1 => self.0.y,
_ => unreachable!(),
}
}
fn nth_mut(&mut self, index: usize) -> &mut Self::Scalar {
match index {
0 => &mut self.0.x,
1 => &mut self.0.y,
_ => unreachable!(),
}
}
}

#[cfg(test)]
mod test {
use super::*;
Expand Down
10 changes: 9 additions & 1 deletion geo-types/src/geometry/polygon.rs
Original file line number Diff line number Diff line change
Expand Up @@ -545,7 +545,12 @@ impl<T: AbsDiffEq<Epsilon = T> + CoordNum> AbsDiffEq for Polygon<T> {
}
}

#[cfg(any(feature = "rstar_0_8", feature = "rstar_0_9", feature = "rstar_0_10"))]
#[cfg(any(
feature = "rstar_0_8",
feature = "rstar_0_9",
feature = "rstar_0_10",
feature = "rstar_0_11"
))]
macro_rules! impl_rstar_polygon {
($rstar:ident) => {
impl<T> $rstar::RTreeObject for Polygon<T>
Expand All @@ -569,3 +574,6 @@ impl_rstar_polygon!(rstar_0_9);

#[cfg(feature = "rstar_0_10")]
impl_rstar_polygon!(rstar_0_10);

#[cfg(feature = "rstar_0_11")]
impl_rstar_polygon!(rstar_0_11);
23 changes: 22 additions & 1 deletion geo-types/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,7 @@
//! - `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`)
//! - `use-rstar_0_10`: Allows geometry types to be inserted into [rstar] R*-trees (`rstar v0.10`)
//! - `use-rstar_0_11`: Allows geometry types to be inserted into [rstar] R*-trees (`rstar v0.11`)
//!
//! This library can be used in `#![no_std]` environments if the default `std` feature is disabled. At
//! the moment, the `arbitrary` and `use-rstar_0_8` features require `std`. This may change in a
Expand Down Expand Up @@ -136,7 +137,12 @@ mod macros;
#[cfg(feature = "arbitrary")]
mod arbitrary;

#[cfg(any(feature = "rstar_0_8", feature = "rstar_0_9", feature = "rstar_0_10"))]
#[cfg(any(
feature = "rstar_0_8",
feature = "rstar_0_9",
feature = "rstar_0_10",
feature = "rstar_0_11"
))]
#[doc(hidden)]
pub mod private_utils;

Expand Down Expand Up @@ -273,6 +279,21 @@ mod tests {
assert_relative_eq!(25.999999999999996, l.distance_2(&Point::new(4.0, 10.0)));
}

#[cfg(feature = "rstar_0_11")]
#[test]
/// ensure Line's SpatialObject impl is correct
fn line_test_0_11() {
use rstar_0_11::primitives::Line as RStarLine;
use rstar_0_11::{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. });
assert_eq!(rl.envelope(), l.envelope());
// difference in 15th decimal place
assert_relative_eq!(26.0, rl.distance_2(&Point::new(4.0, 10.0)));
assert_relative_eq!(25.999999999999996, l.distance_2(&Point::new(4.0, 10.0)));
}

#[test]
fn test_rects() {
let r = Rect::new(coord! { x: -1., y: -1. }, coord! { x: 1., y: 1. });
Expand Down
9 changes: 8 additions & 1 deletion geo/CHANGES.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,13 @@
# Changes

## Unreleased
## 0.26.0

* Implement "Closest Point" from a `Point` on a `Geometry` using spherical geometry. <https://github.com/georust/geo/pull/958>
* Bump CI containers to use libproj 9.2.1
* **BREAKING**: Bump rstar and robust dependencies
<https://github.com/georust/geo/pull/1030>

## 0.25.1

- Add `TriangulateEarcut` algorithm trait to triangulate polygons with the earcut algorithm.
- <https://github.com/georust/geo/pull/1007>
Expand Down
Loading

0 comments on commit 10b7f08

Please sign in to comment.