Fix Relate for Point/MultiPoint (broken just yesterday)#1322
Merged
michaelkirk merged 2 commits intomainfrom Mar 5, 2025
Merged
Fix Relate for Point/MultiPoint (broken just yesterday)#1322michaelkirk merged 2 commits intomainfrom
michaelkirk merged 2 commits intomainfrom
Conversation
I recently broke this (in 44816eb, merged yesterday, not released) by attempting to reuse the bbox from the geometry graph's RTree. The problem was that the RTree only contains the Geometry's _segments_, but Point and MultiPoint have no segments - they're zero-dimensional geometries. I don't often use `Relate` with zero dimensional geometries, so it's only luck that an unrelated example I was writing triggered an assert! == PERF There was only a small loss from this change, indicating it was probably a bad idea from the start. build prepared polygons time: [4.5677 ms 4.5717 ms 4.5764 ms] change: [+1.1094% +1.2751% +1.4241%] (p = 0.00 < 0.05) Performance has regressed. relate already prepared polygons time: [18.889 ms 18.912 ms 18.942 ms] change: [+0.5218% +0.6533% +0.8127%] (p = 0.00 < 0.05) Change within noise threshold. build and relate prepared polygons time: [23.598 ms 23.632 ms 23.671 ms] change: [+0.4791% +0.6917% +0.9029%] (p = 0.00 < 0.05) Change within noise threshold. unprepared polygons/relate unprepared polygons time: [744.51 ms 749.08 ms 754.49 ms] change: [-1.2051% -0.1460% +0.8681%] (p = 0.80 > 0.05) No change in performance detected.
michaelkirk
commented
Mar 4, 2025
| debug_assert_eq!(bounding_rect, geometry_graph.geometry().bounding_rect()); | ||
|
|
||
| geometry_graph.set_tree(Rc::new(r_tree)); | ||
| let bounding_rect = geometry_graph.geometry().bounding_rect(); |
Member
Author
There was a problem hiding this comment.
We compute the bounding_rect from scratch, and cache that for use in Relate, rather than try to reuse it from the RTree.
| }; | ||
| // They should be equal - but we can save the computation in the `--release` case | ||
| // by using the bounding_rect from the RTree | ||
| debug_assert_eq!(bounding_rect, geometry_graph.geometry().bounding_rect()); |
Member
Author
There was a problem hiding this comment.
This is why I love asserts - they protect me from myself.
dabreegster
approved these changes
Mar 5, 2025
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
CHANGES.mdif knowledge of this change could be valuable to users.I broke this in 44816eb (merged yesterday, not yet released) by attempting to reuse the bbox from the geometry graph's RTree.
The problem was that the RTree only contains the Geometry's segments, but Point and MultiPoint have no segments - they're zero-dimensional geometries.
I don't often use
Relatewith zero dimensional geometries, so it's only luck that an unrelated example I was writing triggered an assert!To be clear, we're still getting most of the perf benefit from #1317 - we're still caching the bbox. Now we have to compute it 1 time. Previously we were trying to compute it zero times by re-using the one from the RTree.
== PERF
There was only a small loss from this change, indicating it was probably a bad
idea from the start.