Skip to content

Commit 42edcbb

Browse files
author
Jeff Whitaker
committed
Merge pull request #21 from jswhit/master
fix imports, don't draw map boundary if patch already attached to axes instance
2 parents 7e55b37 + b4163a8 commit 42edcbb

File tree

3 files changed

+21
-17
lines changed

3 files changed

+21
-17
lines changed

lib/mpl_toolkits/basemap/__init__.py

Lines changed: 16 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1330,6 +1330,7 @@ def drawmapboundary(self,color='k',linewidth=1.0,fill_color=None,\
13301330
ax.set_frame_on(False)
13311331
# elliptical region.
13321332
ax.add_patch(limb)
1333+
self._mapboundarydrawn = limb
13331334
if fill_color is None:
13341335
limb.set_fill(False)
13351336
else:
@@ -1365,6 +1366,7 @@ def drawmapboundary(self,color='k',linewidth=1.0,fill_color=None,\
13651366
xy = list(zip(x,y))
13661367
limb = Polygon(xy,edgecolor=color,linewidth=linewidth)
13671368
ax.add_patch(limb)
1369+
self._mapboundarydrawn = limb
13681370
if fill_color is None:
13691371
limb.set_fill(False)
13701372
else:
@@ -1378,6 +1380,7 @@ def drawmapboundary(self,color='k',linewidth=1.0,fill_color=None,\
13781380
limb = Circle((0.5*(self.xmax+self.xmin),0.5*(self.ymax+self.ymin)),
13791381
radius=0.5*(self.xmax-self.xmin),fc='none')
13801382
ax.add_patch(limb)
1383+
self._mapboundarydrawn = limb
13811384
if fill_color is None:
13821385
limb.set_fill(False)
13831386
else:
@@ -1430,6 +1433,7 @@ def drawmapboundary(self,color='k',linewidth=1.0,fill_color=None,\
14301433
# draw and fill map projection limb, clipped
14311434
# to rectangular region.
14321435
ax.add_patch(limb)
1436+
self._mapboundarydrawn = limb
14331437
if fill_color is None:
14341438
limb.set_fill(False)
14351439
else:
@@ -1441,7 +1445,6 @@ def drawmapboundary(self,color='k',linewidth=1.0,fill_color=None,\
14411445
limb.set_zorder(zorder)
14421446
limb.set_clip_on(True)
14431447
# set axes limits to fit map region.
1444-
self._mapboundarydrawn = True
14451448
self.set_axes_limits(ax=ax)
14461449
return limb
14471450

@@ -2819,19 +2822,20 @@ def set_axes_limits(self,ax=None):
28192822
ax.set_ylim((self.llcrnry, self.urcrnry))
28202823
# if map boundary not yet drawn, draw it with default values.
28212824
if not self._mapboundarydrawn:
2822-
# elliptical map, turn off axis_frame, draw boundary manually.
2823-
if (self.projection in ['ortho','geos','nsper','aeqd'] and
2824-
self._fulldisk) or self.round or self.projection in _pseudocyl:
2825-
# turn off axes frame.
2826-
ax.set_frame_on(False)
2827-
# first draw boundary, no fill
2828-
limb1 = self.drawmapboundary(fill_color='none')
2829-
# draw another filled patch, with no boundary.
2830-
limb2 = self.drawmapboundary(linewidth=0)
2831-
self._mapboundarydrawn = True
2825+
# is the map boundary already drawn on the current axes?
2826+
if self._mapboundarydrawn not in ax.patches:
2827+
# elliptical map, turn off axis_frame, draw boundary manually.
2828+
if (self.projection in ['ortho','geos','nsper','aeqd'] and
2829+
self._fulldisk) or self.round or self.projection in _pseudocyl:
2830+
# turn off axes frame.
2831+
ax.set_frame_on(False)
2832+
# first draw boundary, no fill
2833+
limb1 = self.drawmapboundary(fill_color='none')
2834+
# draw another filled patch, with no boundary.
2835+
limb2 = self.drawmapboundary(linewidth=0)
2836+
self._mapboundarydrawn = True
28322837
else: # square map, just turn on axis frame.
28332838
ax.set_frame_on(True)
2834-
self._mapboundarydrawn = True
28352839
# make sure aspect ratio of map preserved.
28362840
# plot is re-centered in bounding rectangle.
28372841
# (anchor instance var determines where plot is placed)

lib/mpl_toolkits/basemap/geodesicline.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ class GeodesicLine(object):
3232
"""Points on a geodesic path"""
3333

3434
def __init__(self, geod, lat1, lon1, azi1, caps = GeodesicCapability.ALL):
35-
from pyproj.geodesic import Geodesic
35+
from mpl_toolkits.basemap.geodesic import Geodesic
3636
self._a = geod._a
3737
self._f = geod._f
3838
self._b = geod._b
@@ -137,7 +137,7 @@ def __init__(self, geod, lat1, lon1, azi1, caps = GeodesicCapability.ALL):
137137
# return a12, lat2, lon2, azi2, s12, m12, M12, M21, S12
138138
def GenPosition(self, arcmode, s12_a12, outmask):
139139

140-
from pyproj.geodesic import Geodesic
140+
from mpl_toolkits.basemap.geodesic import Geodesic
141141
a12 = lat2 = lon2 = azi2 = s12 = m12 = M12 = M21 = S12 = Math.nan
142142
outmask &= self._caps & Geodesic.OUT_ALL
143143
if not (arcmode or (self._caps & Geodesic.DISTANCE_IN & Geodesic.OUT_ALL)):
@@ -312,7 +312,7 @@ def Position(self, s12,
312312
Geodesic.ALL
313313
"""
314314

315-
from pyproj.geodesic import Geodesic
315+
from mpl_toolkits.basemap.geodesic import Geodesic
316316
Geodesic.CheckDistance(s12)
317317
result = {'lat1': self._lat1, 'lon1': self._lon1, 'azi1': self._azi1,
318318
's12': s12}

lib/mpl_toolkits/basemap/polygonarea.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ class PolygonArea(object):
2323
def transit(lon1, lon2):
2424
# Return 1 or -1 if crossing prime meridian in east or west direction.
2525
# Otherwise return zero.
26-
from pyproj.geodesic import Geodesic
26+
from mpl_toolkits.basemap.geodesic import Geodesic
2727
lon1 = Geodesic.AngNormalize(lon1)
2828
lon2 = Geodesic.AngNormalize(lon2)
2929
# treat lon12 = -180 as an eastward geodesic, so convert to 180.
@@ -38,7 +38,7 @@ def transit(lon1, lon2):
3838
transit = staticmethod(transit)
3939

4040
def __init__(self, earth, polyline = False):
41-
from pyproj.geodesic import Geodesic
41+
from mpl_toolkits.basemap.geodesic import Geodesic
4242
self._earth = earth
4343
self._area0 = 4 * math.pi * earth._c2
4444
self._polyline = polyline

0 commit comments

Comments
 (0)