Repository: SciTools/cartopy

Issue:
Gridliner inline label projection hard-coded for WGS84
### Description

Calling `cartopy.crs.Projection.gridlines()` with a CRS using a non-WGS84 `Globe` and with `x_inline=True` raises an exception during drawing, apparently due to [`gridliner.py:800`](https://github.com/SciTools/cartopy/blob/f187916d69fa922beba53f2593ccfc3676374e4c/lib/cartopy/mpl/gridliner.py#L800): when either axis is specified as inline, the transform used comes from a newly-instantiated `PlateCarree` projection with a default `Globe` (i.e., a WGS84 globe).

The raised exception message is `ProjError: Error creating Transformer from CRS.: (Internal Proj Error: proj_create_operations: Source and target ellipsoid do not belong to the same celestial body)`.

#### Code to reproduce

```
import matplotlib.pyplot as plt
import cartopy.crs as ccrs

globe = ccrs.Globe(semimajor_axis=1, semiminor_axis=1, ellipse=None)
projection = data_ccrs = ccrs.PlateCarree(globe=globe)

plt.figure()
ax = plt.subplot(111, projection=projection)
ax.set_global()
ax.gridlines(crs=data_ccrs, draw_labels=['x'], x_inline=True)
plt.show()
```

#### Traceback 

```
Traceback (most recent call last):
  File "/usr/lib64/python3.10/site-packages/matplotlib/backends/backend_gtk3cairo.py", line 31, in on_draw_event
    self.figure.draw(self._renderer)
  File "/usr/lib64/python3.10/site-packages/matplotlib/artist.py", line 72, in draw_wrapper
    result = draw(artist, renderer, *args, **kwargs)
  File "/usr/lib64/python3.10/site-packages/matplotlib/artist.py", line 49, in draw_wrapper
    return draw(artist, renderer)
  File "/usr/lib64/python3.10/site-packages/matplotlib/figure.py", line 2799, in draw
    mimage._draw_list_compositing_images(
  File "/usr/lib64/python3.10/site-packages/matplotlib/image.py", line 132, in _draw_list_compositing_images
    a.draw(renderer)
  File "/usr/lib64/python3.10/site-packages/matplotlib/artist.py", line 49, in draw_wrapper
    return draw(artist, renderer)
  File "/usr/lib64/python3.10/site-packages/cartopy/mpl/geoaxes.py", line 543, in draw
    self._draw_preprocess(renderer)
  File "/usr/lib64/python3.10/site-packages/cartopy/mpl/geoaxes.py", line 517, in _draw_preprocess
    gl._draw_gridliner(renderer=renderer)
  File "/usr/lib64/python3.10/site-packages/cartopy/mpl/gridliner.py", line 948, in _draw_gridliner
    this_path = update_artist(artist, renderer)
  File "/usr/lib64/python3.10/site-packages/cartopy/mpl/gridliner.py", line 775, in update_artist
    artist.update_bbox_position_size(renderer)
  File "/usr/lib64/python3.10/site-packages/matplotlib/text.py", line 506, in update_bbox_position_size
    posx, posy = self.get_transform().transform((posx, posy))
  File "/usr/lib64/python3.10/site-packages/matplotlib/transforms.py", line 1463, in transform
    res = self.transform_affine(self.transform_non_affine(values))
  File "/usr/lib64/python3.10/site-packages/matplotlib/transforms.py", line 2386, in transform_non_affine
    return self._a.transform_non_affine(points)
  File "/usr/lib64/python3.10/site-packages/cartopy/mpl/geoaxes.py", line 134, in transform_non_affine
    return prj.transform_points(self.source_projection,
  File "/usr/lib64/python3.10/site-packages/cartopy/crs.py", line 401, in transform_points
    _safe_pj_transform(src_crs, self, x, y, z, trap=trap)
  File "/usr/lib64/python3.10/site-packages/cartopy/crs.py", line 43, in _safe_pj_transform
    transformer = Transformer.from_crs(src_crs, tgt_crs, always_xy=True)
  File "/usr/lib64/python3.10/site-packages/pyproj/transformer.py", line 534, in from_crs
    return Transformer(
  File "/usr/lib64/python3.10/site-packages/pyproj/transformer.py", line 310, in __init__
    self._local.transformer = transformer_maker()
  File "/usr/lib64/python3.10/site-packages/pyproj/transformer.py", line 97, in __call__
    return _Transformer.from_crs(
  File "pyproj/_transformer.pyx", line 643, in pyproj._transformer._Transformer.from_crs
pyproj.exceptions.ProjError: Error creating Transformer from CRS.: (Internal Proj Error: proj_create_operations: Source and target ellipsoid do not belong to the same celestial body)
```

<details>
 <summary>Full environment definition</summary>

### Operating system
Fedora 35

### Cartopy version
v0.20.0, but appears to be an issue on master.

</details>



Discussion:
That makes it seem like all inline grid labels would have to be in lat/lon coordinates currently. I'm not entirely clear why the crs transform the user inputs with the gridliner isn't used for that. A PR to address this would be welcome!

Resolving patch:
diff --git a/lib/cartopy/mpl/gridliner.py b/lib/cartopy/mpl/gridliner.py
--- a/lib/cartopy/mpl/gridliner.py
+++ b/lib/cartopy/mpl/gridliner.py
@@ -796,8 +796,6 @@ def update_artist(artist, renderer):
         # Cache a few things so they aren't re-calculated in the loops.
         crs_transform = self._crs_transform().transform
         inverse_data_transform = self.axes.transData.inverted().transform_point
-        if self.x_inline or self.y_inline:
-            pc_transform = PlateCarree()
 
         for xylabel, lines, line_ticks, formatter, label_style in (
                 ('x', lon_lines, lon_ticks,
@@ -899,7 +897,7 @@ def update_artist(artist, renderer):
                     # Initial text specs
                     x0, y0 = pt0
                     if x_inline or y_inline:
-                        kw = {'rotation': 0, 'transform': pc_transform,
+                        kw = {'rotation': 0, 'transform': self.crs,
                               'ha': 'center', 'va': 'center'}
                         loc = 'inline'
                     else:


Test patch: