fabanc / pyvoronoi

Python wrapper for Boost voronoi diagram implementation.
27 stars 7 forks source link

Pyvoronoi construct never completes #23

Closed pnuaxen closed 10 months ago

pnuaxen commented 1 year ago

I have been using this library with success, except for one dataset that results in construct never completing. I've spent quite a bit of time ensuring that the input segments don't overlap -- which with other data sets resulted in a degenerate voronoi diagram but it always completed. The size of the dataset is not bigger (about 350k segments) than others that complete almost instantly.

I can't find any way to turn on enhanced logging or if that is even available in boost. Do you have any pointers on how I could get more information about what is causing this? Have you encountered other data sets that cause construct to go into an infinite loop (guessing here...)

fabanc commented 12 months ago

Yes. In my experience, two things can lead to that:

  1. Your input of arcs intersects but there are no nodes.
  2. Some segments are smaller than the distance allowed by the scale factor.

When a point is added into the Voronoi input, the coordinates are multiplied by the scale factor and then turned into an integer. If you have multiple points that end up having the same coordinates after that transformation, that might be a problem. I would need to run into the test cases I had when I enhanced that library. But I remember before sending any data I would check:

I use that to work with complex road network across big countries in North America. If I don't validate those two things, the library can crash quite easily. However, with those two checks, I have never run into any issues. If you're a GIS user, software like ArcGIS Pro or QGIS can help you troubleshoot that.