fitodic / centerline

Calculate the polygon's centerline
https://centerline.readthedocs.io
MIT License
266 stars 55 forks source link

Convert linestrings within to strtree for 100x speed up #44

Closed Lash-L closed 7 months ago

Lash-L commented 7 months ago

Hello!

Using centerline for larger more complex polygons took a while, conveting to STRTree causes a massive speed up. I've used STRTree a few other times and I have never had an issue with different data being outputted. Testing on my current system for centerline, I get the same amount of lines outputted. In my example, it provides an over 100x speed up. In smaller, simple polygons, there is a chance STRTree takes longer than the old system, but it would be extremely minimal. I would say anything over 4-5 within checks and I would expect STRTree to be faster.

Before: image After: image

fitodic commented 7 months ago

@Lash-L Thanks for the contribution, it looks great! Could you please just reformat the following line: ./src/centerline/geometry.py:89:80: E501 line too long (106 > 79 characters)

Once complete, I can merge it and release it :)

codecov[bot] commented 7 months ago

Codecov Report

All modified and coverable lines are covered by tests :white_check_mark:

Comparison is base (c0c0bf7) 100.00% compared to head (cdd7776) 99.33%.

:exclamation: Current head cdd7776 differs from pull request most recent head 1f98149. Consider uploading reports for the commit 1f98149 to get more accurate results

Additional details and impacted files ```diff @@ Coverage Diff @@ ## master #44 +/- ## =========================================== - Coverage 100.00% 99.33% -0.67% =========================================== Files 4 4 Lines 148 151 +3 Branches 20 20 =========================================== + Hits 148 150 +2 - Misses 0 1 +1 ```

:umbrella: View full report in Codecov by Sentry.
:loudspeaker: Have feedback on the report? Share it here.

Lash-L commented 7 months ago

@fitodic good for another workflow run!

fitodic commented 7 months ago

@Lash-L Thanks for the quick responses! The build has completed and your changes are available on PyPI. Thanks again for your contribution and I hope it speeds up your project :)