Skip to content
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

Back BooleanOps with i_overlay to avoid crashes from floating point collapse #1234

Merged
merged 1 commit into from
Oct 28, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions geo-bool-ops-benches/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,10 @@ edition = "2021"

# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html

[features]
# If you want to bench against the `geo-booleanop` crate as a comparison, enable this feature.
bench-foreign-booleanop = []

[dependencies]
geo = { path = "../geo" }
geo-types = { path = "../geo-types" }
Expand Down
56 changes: 29 additions & 27 deletions geo-bool-ops-benches/benches/boolean_ops.rs
Original file line number Diff line number Diff line change
@@ -1,12 +1,8 @@
use std::f64::consts::PI;

use criterion::{measurement::Measurement, *};
use geo::{
algorithm::{BooleanOps, Rotate},
Relate,
};
use geo::algorithm::{BooleanOps, Rotate};

use geo_booleanop::boolean::BooleanOp as OtherBooleanOp;
use rand::{thread_rng, Rng};
use rand_distr::Standard;

Expand Down Expand Up @@ -60,33 +56,39 @@ fn run_complex<T: Measurement>(c: &mut Criterion<T>) {
);
});

group.bench_with_input(
BenchmarkId::new("rgbops::intersection", steps),
&(),
|b, _| {
#[cfg(feature = "bench-foreign-booleanop")]
{
use geo::algorithm::Relate;
use geo_booleanop::boolean::BooleanOp as OtherBooleanOp;

group.bench_with_input(
BenchmarkId::new("rgbops::intersection", steps),
&(),
|b, _| {
b.iter_batched(
polys.sampler(),
|(_, _, poly, poly2)| OtherBooleanOp::intersection(poly, poly2),
BatchSize::SmallInput,
);
},
);

group.bench_with_input(BenchmarkId::new("rgbops::union", steps), &(), |b, _| {
b.iter_batched(
polys.sampler(),
|(_, _, poly, poly2)| OtherBooleanOp::intersection(poly, poly2),
|(_, _, poly, poly2)| OtherBooleanOp::union(poly, poly2),
BatchSize::SmallInput,
);
},
);
});

group.bench_with_input(BenchmarkId::new("rgbops::union", steps), &(), |b, _| {
b.iter_batched(
polys.sampler(),
|(_, _, poly, poly2)| OtherBooleanOp::union(poly, poly2),
BatchSize::SmallInput,
);
});

group.bench_with_input(BenchmarkId::new("geo::relate", steps), &(), |b, _| {
b.iter_batched(
polys.sampler(),
|(poly, poly2, _, _)| poly.relate(poly2).is_intersects(),
BatchSize::SmallInput,
);
});
group.bench_with_input(BenchmarkId::new("geo::relate", steps), &(), |b, _| {
b.iter_batched(
polys.sampler(),
|(poly, poly2, _, _)| poly.relate(poly2).is_intersects(),
BatchSize::SmallInput,
);
});
}
});
}

Expand Down
2 changes: 2 additions & 0 deletions geo/CHANGES.md
Original file line number Diff line number Diff line change
Expand Up @@ -127,6 +127,8 @@
* <https://github.com/georust/geo/pull/1148>
* Point in `Triangle` and `Rect` performance improvemnets
* <https://github.com/georust/geo/pull/1057>
* Fix crashes in `BooleanOps`
* <https://github.com/georust/geo/pull/1234>

## 0.27.0

Expand Down
1 change: 1 addition & 0 deletions geo/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@ proj = { version = "0.27.0", optional = true }
robust = "1.1.0"
rstar = "0.12.0"
serde = { version = "1.0", optional = true, features = ["derive"] }
i_overlay = "1.7.2"

[dev-dependencies]
approx = ">= 0.4.0, < 0.6.0"
Expand Down
Loading
Loading