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 20, 2021
1 parent 2cce13d commit 6eb951b
Showing 1 changed file with 19 additions and 14 deletions.
33 changes: 19 additions & 14 deletions lib/cartopy/mpl/geoaxes.py
Original file line number Diff line number Diff line change
Expand Up @@ -753,20 +753,25 @@ 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']

if (not callable(styler)) and ('facecolor' not in kwargs):
styler_kw = styler

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 kwargs) or (
kwargs['edgecolor'] == 'face'):
styler_g['edgecolor'] = mpl.rcParams['patch.edgecolor']
else:
styler_g['edgecolor'] = kwargs['edgecolor']
return styler_g
else:
return styler_kw

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

Expand Down

0 comments on commit 6eb951b

Please sign in to comment.