|
8 | 8 | import numpy as np
|
9 | 9 | import matplotlib as mpl
|
10 | 10 | import matplotlib.pyplot as plt
|
| 11 | +from matplotlib.collections import LineCollection |
11 | 12 | from matplotlib.image import AxesImage
|
12 | 13 | from matplotlib.patches import Polygon
|
13 | 14 | from mpl_toolkits.basemap import Basemap
|
@@ -85,6 +86,46 @@ def test_init_with_optional_casting(self):
|
85 | 86 | bmap2 = Basemap(lat_1=bmap2_lat_1, **kwds)
|
86 | 87 | self.assertEqual(bmap1.proj4string, bmap2.proj4string)
|
87 | 88 |
|
| 89 | + def test_drawcoastlines(self, axs=None, axslen0=10): |
| 90 | + """Test that no lines are missing when drawing coastlines.""" |
| 91 | + |
| 92 | + axs_obj = plt.gca() if axs is None else axs |
| 93 | + axs_children = axs_obj.get_children() |
| 94 | + self.assertEqual(len(axs_children), axslen0) |
| 95 | + |
| 96 | + bmap = Basemap(projection="merc", resolution="i", lat_ts=20, |
| 97 | + llcrnrlat=36.0, llcrnrlon=6.0, |
| 98 | + urcrnrlat=47.7, urcrnrlon=19.0) |
| 99 | + |
| 100 | + collection = bmap.drawcoastlines(linewidth=1, color="red") |
| 101 | + self.assertIsInstance(collection, LineCollection) |
| 102 | + |
| 103 | + axs_children = axs_obj.get_children() |
| 104 | + self.assertEqual(len(axs_children), axslen0 + 1) |
| 105 | + |
| 106 | + lines = collection.get_paths() |
| 107 | + self.assertEqual(len(lines), 27) |
| 108 | + |
| 109 | + def test_drawcountries(self, axs=None, axslen0=10): |
| 110 | + """Test that no lines are missing when drawing country boundaries.""" |
| 111 | + |
| 112 | + axs_obj = plt.gca() if axs is None else axs |
| 113 | + axs_children = axs_obj.get_children() |
| 114 | + self.assertEqual(len(axs_children), axslen0) |
| 115 | + |
| 116 | + bmap = Basemap(projection="merc", resolution="i", lat_ts=20, |
| 117 | + llcrnrlat=36.0, llcrnrlon=6.0, |
| 118 | + urcrnrlat=47.7, urcrnrlon=19.0) |
| 119 | + |
| 120 | + collection = bmap.drawcountries(linewidth=1, color="blue") |
| 121 | + self.assertIsInstance(collection, LineCollection) |
| 122 | + |
| 123 | + axs_children = axs_obj.get_children() |
| 124 | + self.assertEqual(len(axs_children), axslen0 + 1) |
| 125 | + |
| 126 | + lines = collection.get_paths() |
| 127 | + self.assertEqual(len(lines), 29) |
| 128 | + |
88 | 129 | @unittest.skipIf(PIL is None, reason="pillow unavailable")
|
89 | 130 | def test_arcgisimage_with_cyl(self, axs=None, axslen0=10):
|
90 | 131 | """Test showing an ArcGIS image as background."""
|
|
0 commit comments