Skip to content

Commit

Permalink
update styler to only modify LineString
Browse files Browse the repository at this point in the history
  • Loading branch information
smartlixx committed May 19, 2021
1 parent 2cce13d commit 951a720
Showing 1 changed file with 13 additions and 15 deletions.
28 changes: 13 additions & 15 deletions lib/cartopy/mpl/geoaxes.py
Original file line number Diff line number Diff line change
Expand Up @@ -752,21 +752,19 @@ def add_geometries(self, geoms, crs, **kwargs):
"""
styler = kwargs.pop('styler', None)
has_LineString = False
try:
for g in iter(tuple(geoms)):
if isinstance(g, sgeom.LineString):
has_LineString = True
break
except TypeError:
if isinstance(geoms, sgeom.LineString):
has_LineString = True

if has_LineString:
kwargs['facecolor'] = 'none'
if 'edgecolor' not in kwargs or kwargs['edgecolor'] == 'face':
kwargs['edgecolor'] = mpl.rcParams['patch.edgecolor']
styler_kw = kwargs.pop('styler', None)

def styler(geom):
styler_g = styler_kw if styler_kw else dict()
styler_g = styler_g.copy()

if isinstance(geom, sgeom.LineString):
styler_g['facecolor'] = 'none'
if ('edgecolor' not in styler_g) or (styler_g['edgecolor'] ==
'face'):
styler_g['edgecolor'] = mpl.rcParams['patch.edgecolor']
return styler_g

feature = cartopy.feature.ShapelyFeature(geoms, crs, **kwargs)
return self.add_feature(feature, styler=styler)

Expand Down

0 comments on commit 951a720

Please sign in to comment.