- yet another fix for Shapely 2.0 deprecation warnings

This commit is contained in:
Marius Stanciu
2022-01-31 18:40:22 +02:00
committed by Marius
parent 5cee4109b8
commit b64c11885a
2 changed files with 20 additions and 14 deletions

View File

@@ -19,6 +19,7 @@ CHANGELOG for FlatCAM beta
- added a new script example - added a new script example
- improved the quit application process; now the `quit_flatcam` Tcl command works properly - improved the quit application process; now the `quit_flatcam` Tcl command works properly
- another fix for Shapely 2.0 deprecation warning - another fix for Shapely 2.0 deprecation warning
- yet another fix for Shapely 2.0 deprecation warnings
30.01.2022 30.01.2022

View File

@@ -625,18 +625,19 @@ class GerberObject(FlatCAMObj, Gerber):
not isinstance(geo_obj.solid_geometry, MultiPolygon): not isinstance(geo_obj.solid_geometry, MultiPolygon):
geo_obj.solid_geometry = [geo_obj.solid_geometry] geo_obj.solid_geometry = [geo_obj.solid_geometry]
for g in geo_obj.solid_geometry: w_geo = geo_obj.solid_geometry.geoms \
if isinstance(geo_obj.solid_geometry, (MultiPolygon, MultiLineString)) else geo_obj.solid_geometry
for g in w_geo:
if g: if g:
break break
else: else:
empty_cnt += 1 empty_cnt += 1
if empty_cnt == len(geo_obj.solid_geometry): if empty_cnt == len(w_geo):
raise ValidationError("Empty Geometry", None) raise ValidationError("Empty Geometry", None)
else: elif plot:
if plot: msg = '[success] %s: %s' % (_("Isolation geometry created"), geo_obj.options["name"])
app_obj.inform.emit('[success] %s: %s' % app_obj.inform.emit(msg)
(_("Isolation geometry created"), geo_obj.options["name"]))
# even if combine is checked, one pass is still single-geo # even if combine is checked, one pass is still single-geo
geo_obj.multigeo = True if passes > 1 else False geo_obj.multigeo = True if passes > 1 else False
@@ -712,21 +713,24 @@ class GerberObject(FlatCAMObj, Gerber):
# proceed with object creation, if there are empty and the number of them is the length # proceed with object creation, if there are empty and the number of them is the length
# of the list then we have an empty solid_geometry which should raise a Custom Exception # of the list then we have an empty solid_geometry which should raise a Custom Exception
empty_cnt = 0 empty_cnt = 0
if not isinstance(geo_obj.solid_geometry, list): if not isinstance(geo_obj.solid_geometry, list) and \
not isinstance(geo_obj.solid_geometry, (MultiPolygon, MultiLineString)):
geo_obj.solid_geometry = [geo_obj.solid_geometry] geo_obj.solid_geometry = [geo_obj.solid_geometry]
for g in geo_obj.solid_geometry: w_geo = geo_obj.solid_geometry.geoms \
if isinstance(geo_obj.solid_geometry,
(MultiPolygon, MultiLineString)) else geo_obj.solid_geometry
for g in w_geo:
if g: if g:
break break
else: else:
empty_cnt += 1 empty_cnt += 1
if empty_cnt == len(geo_obj.solid_geometry): if empty_cnt == len(w_geo):
raise ValidationError("Empty Geometry", None) raise ValidationError("Empty Geometry", None)
else: elif plot:
if plot: msg = '[success] %s: %s' % (_("Isolation geometry created"), geo_obj.options["name"])
app_obj.inform.emit('[success] %s: %s' % app_obj.inform.emit(msg)
(_("Isolation geometry created"), geo_obj.options["name"]))
geo_obj.multigeo = False geo_obj.multigeo = False
# ############################################################ # ############################################################
@@ -755,7 +759,8 @@ class GerberObject(FlatCAMObj, Gerber):
if invert: if invert:
try: try:
pl = [] pl = []
for p in geom: w_geo = geom.geoms if isinstance(geom, (MultiPolygon, MultiLineString)) else geom
for p in w_geo:
if p is not None: if p is not None:
if isinstance(p, Polygon): if isinstance(p, Polygon):
pl.append(Polygon(p.exterior.coords[::-1], p.interiors)) pl.append(Polygon(p.exterior.coords[::-1], p.interiors))