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

quad tree with points that have a set of line indices as data #43

Conversation

stijnvermeeren-swisstopo
Copy link
Contributor

@stijnvermeeren-swisstopo stijnvermeeren-swisstopo commented May 13, 2024

Code review proposal for #38

  • Link multiple lines with a single point in the quad tree
  • Remove the need for recursive calls of the "merge lines by quad tree" method
  • Remove the need for the inefficient check for duplicate lines

I think that some unit tests for the LinesQuadTree class could be really useful, but I did not have time to implement any new tests yet. I'll leave that up to you @redur to either add some unit tests, or to accept this PR as-is already and to leave writing unit tests for later.

Copy link

github-actions bot commented May 13, 2024

Coverage

Coverage Report
FileStmtsMissCoverMissing
src/stratigraphy
   __init__.py8188%11
   extract.py1891890%3–460
   get_files.py21210%3–48
   line_detection.py26260%3–76
   main.py85850%3–225
src/stratigraphy/util
   dataclasses.py32391%37–39
   depthcolumn.py2046767%26, 30, 51, 57, 60–61, 85, 88, 95, 102, 110–111, 121, 138–154, 187, 210, 226–234, 244, 249, 256, 263, 268, 286, 296, 299–306, 321–322, 365–407
   depthcolumnentry.py20480%12, 15, 27, 34
   description_block_splitter.py70297%24, 139
   draw.py62620%3–184
   duplicate_detection.py32320%3–81
   find_depth_columns.py82495%57–58, 149–150
   find_description.py39685%27–34, 111–114
   geometric_line_utilities.py87298%83, 133
   interval.py1075251%25–28, 32–35, 40, 45, 48, 100–146, 166, 171–187
   language_detection.py18180%3–43
   line.py492647%25, 42, 51, 65–95, 98
   linesquadtree.py46198%76
   plot_utils.py44440%3–121
   predictions.py1541540%3–322
   textblock.py74889%27, 51, 63, 75, 98, 119, 127, 155
   util.py402245%15–18, 22, 26, 40–47, 61–63, 87–88, 100–105
TOTAL148982944% 

Tests Skipped Failures Errors Time
44 0 💤 0 ❌ 0 🔥 0.502s ⏱️

Copy link
Contributor

@redur redur left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good to me. Thanks.

Performance is also improved on my Mac. Even sligthly faster than the old non-quad tree implementation.

def __init__(self, width: float, height: float):
"""Create a LinesQuadTree instance.

The LinesQuadTree will contain an actual quad tree with the end points of all lines, as well as a hashmap to
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The end points confused me for a second. Maybe it's better to say with all start and end points of all lines.
I think you meant it the right way, a line (segment) has two end points. But since our implementation has line.start and line.end; it can be confusing.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes, good point, I see that it can be confusing.

However, "end point" is a rather standard name for the extremities of a line segment. And our line segments don't really have an inherent direction, so maybe we should reconsider the naming of "line.start" and "line.end", rather than avoid the word "end point" in other contexts such as here...

What do you think? Merge it like this and deal with it later?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Merge it and deal with it later. The implementation is rather explicit. So any confused reader will figure it out quickly.

@stijnvermeeren-swisstopo stijnvermeeren-swisstopo merged commit f6a3bb8 into feat/exact_line_merging May 16, 2024
3 checks passed
@stijnvermeeren-swisstopo stijnvermeeren-swisstopo deleted the feat/exact_line_merging-review_stijn branch May 16, 2024 15:21
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants