SciTools/cartopy — pull request #185 by esc24 (2012-12-18 14:30:25+00:00)
Title: Modified logic in _project_linear_ring()

When attempting to contour a particular dataset, matplotlib is generating a set of polygons, one of which, when projected from PlateCarree to PlateCarree, results in a multilinestring even though it is nowhere near the boundary. The contained linestrings are combined in ```_project_linear_ring()```, but by returning a multilinestring rather than a LinearRing, the geometry goes through the attach to boundary process. This pull request has a reordering of the logic in ```_project_linear_ring()``` that enables combined linestrings to be returned as a single LinearRing if the appropriate conditions are met.

The geometry that highlights the issue is shown below with the resulting multilinestring containing two elements rather than just one:
```python
import matplotlib.pyplot as plt
import numpy
from shapely.geometry.polygon import LinearRing

import cartopy
import cartopy.crs

src_ring = LinearRing([(313.1250000000000000, -71.3593745002992534),
(315.0000000000000000, -71.3370095114407547),
(315.2159082254760847, -71.2500000000000000),
(315.0000000000000000, -71.1406254997007466),
(313.1250000000000000, -70.0000000000000000),
(313.1250000000000000, -69.9999999999999858),
(313.1249999999999432, -70.0000000000000000),
(312.4943213750468090, -71.2500000000000000),
(313.1250000000000000, -71.3593745002992534)])

src_crs = cartopy.crs.PlateCarree()
target_crs = cartopy.crs.PlateCarree()
multi_line_string = cartopy.trace.project_linear(src_ring, src_crs, target_crs)

plt.plot(multi_line_string[1].xy[0], multi_line_string[1].xy[1], 'go-')
plt.plot(multi_line_string[0].xy[0], multi_line_string[0].xy[1], 'r+-')
plt.plot(numpy.array(src_ring.xy[0]) - 360, src_ring.xy[1], 'bo-')
plt.show()
```
The problem occurs around the top of the polygon at about (-46.9, -70.1)