-
Notifications
You must be signed in to change notification settings - Fork 241
Speed up Relate for PreparedGeometry #1317
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
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -5,7 +5,7 @@ use relate_operation::RelateOperation; | |
| use crate::geometry::*; | ||
| pub use crate::relate::geomgraph::index::PreparedGeometry; | ||
| pub use crate::relate::geomgraph::GeometryGraph; | ||
| use crate::{GeoFloat, GeometryCow}; | ||
| use crate::{BoundingRect, GeoFloat, GeometryCow, HasDimensions}; | ||
|
|
||
| mod edge_end_builder; | ||
| mod geomgraph; | ||
|
|
@@ -54,13 +54,20 @@ mod relate_operation; | |
| /// ``` | ||
| /// | ||
| /// Note: `Relate` must not be called on geometries containing `NaN` coordinates. | ||
| pub trait Relate<F: GeoFloat> { | ||
| /// Construct a [`GeometryGraph`] | ||
| fn geometry_graph(&self, arg_index: usize) -> GeometryGraph<F>; | ||
| pub trait Relate<F: GeoFloat>: BoundingRect<F> + HasDimensions { | ||
| /// Returns a noded topology graph for the geometry. | ||
| /// | ||
| /// # Params | ||
| /// | ||
| /// `idx`: 0 or 1, designating A or B (respectively) in the role this geometry plays | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Guessing it's overkill to make this more typesafe with an enum?
Member
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Basically this is a reflection of the reference implementation — a named enum would definitely be less cryptic. I think we could do it, but it would be kind of a broad change - ultimately it's used throughout the geometry graph code as an index of various Since it doesn't represent new complexity in this PR (I've only added documentation here), I'd prefer not to do that refactor in this PR.
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Yeah, not suggesting a change. Thanks for the explanation |
||
| /// in the relation. e.g. in `a.relate(b)` | ||
| fn geometry_graph(&self, idx: usize) -> GeometryGraph<F>; | ||
|
|
||
| fn relate(&self, other: &impl Relate<F>) -> IntersectionMatrix { | ||
| RelateOperation::new(self.geometry_graph(0), other.geometry_graph(1)) | ||
| .compute_intersection_matrix() | ||
| fn relate(&self, other: &impl Relate<F>) -> IntersectionMatrix | ||
| where | ||
| Self: Sized, | ||
| { | ||
| RelateOperation::new(self, other).compute_intersection_matrix() | ||
|
Member
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This is the crux of the change - rather than passing in the |
||
| } | ||
| } | ||
|
|
||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
What's going on here? I thought leading underscore was convention for "allow this unused variable", but it gets used below. Is this just because the debug assertion gets compiled out sometimes and you get an error otherwise?
Uh oh!
There was an error while loading. Please reload this page.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
That's right. Specifically it's only used in a debug assert, which gets compiled out in release builds, thus producing an "unused" warning.