- minor change
This commit is contained in:
parent
f610739390
commit
35cdf4e4cb
|
@ -22,7 +22,7 @@ from matplotlib.backend_bases import KeyEvent as mpl_key_event
|
|||
from camlib import CNCjob
|
||||
|
||||
from shapely.ops import unary_union
|
||||
from shapely.geometry import Point
|
||||
from shapely.geometry import Point, MultiPoint
|
||||
try:
|
||||
from shapely.ops import voronoi_diagram
|
||||
except Exception:
|
||||
|
@ -728,8 +728,9 @@ class CNCJobObject(FlatCAMObj, CNCjob):
|
|||
pass
|
||||
|
||||
def calculate_voronoi_diagram(self, pts):
|
||||
pts_union = unary_union(pts)
|
||||
pts_union = MultiPoint(pts)
|
||||
env = self.solid_geo.envelope
|
||||
print(pts_union.wkt)
|
||||
try:
|
||||
voronoi_union = voronoi_diagram(geom=pts_union, envelope=env)
|
||||
print(voronoi_union)
|
||||
|
|
|
@ -0,0 +1,26 @@
|
|||
"""
|
||||
Test cases for Voronoi Diagram creation.
|
||||
Overall, I'm trying less to test the correctness of the result
|
||||
and more to cover input cases and behavior, making sure
|
||||
that we return a sane result without error or raise a useful one.
|
||||
"""
|
||||
|
||||
import pytest
|
||||
|
||||
from shapely.geos import geos_version
|
||||
from shapely.wkt import loads as load_wkt
|
||||
|
||||
from shapely.ops import voronoi_diagram
|
||||
|
||||
requires_geos_35 = pytest.mark.skipif(geos_version < (3, 5, 0), reason='GEOS >= 3.5.0 is required.')
|
||||
|
||||
@requires_geos_35
|
||||
def test_from_multipoint_without_tolerace_with_floating_point_coordinates():
|
||||
"""But it's fine without it."""
|
||||
mp = load_wkt('MULTIPOINT (20.1273 18.7303, 26.5107 18.7303, 20.1273 23.8437, 26.5107 23.8437)')
|
||||
|
||||
regions = voronoi_diagram(mp)
|
||||
print("Len: %d -> Regions: %s" % (len(regions), str(regions)))
|
||||
|
||||
print(geos_version)
|
||||
test_from_multipoint_without_tolerace_with_floating_point_coordinates()
|
Loading…
Reference in New Issue