Skip to content

Commit

Permalink
Merge pull request #2378 from dopplershift/fix-2377
Browse files Browse the repository at this point in the history
Fix incorrect internal use of PlateCarree
  • Loading branch information
greglucas committed Apr 29, 2024
2 parents 631a8db + a286d48 commit fadfa19
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 2 deletions.
4 changes: 2 additions & 2 deletions lib/cartopy/crs.py
Original file line number Diff line number Diff line change
Expand Up @@ -1790,7 +1790,7 @@ def __init__(self, central_longitude=-96.0, central_latitude=39.0,
lons[1:-1] = np.linspace(central_longitude - 180 + 0.001,
central_longitude + 180 - 0.001, n)

points = self.transform_points(PlateCarree(globe=globe), lons, lats)
points = self.transform_points(self.as_geodetic(), lons, lats)

self._boundary = sgeom.LinearRing(points)
mins = np.min(points, axis=0)
Expand Down Expand Up @@ -1866,7 +1866,7 @@ def __init__(self, central_longitude=0.0, central_latitude=0.0,
lon = central_longitude + 180
sign = np.sign(central_latitude) or 1
lat = -central_latitude + sign * 0.01
x, max_y = self.transform_point(lon, lat, PlateCarree(globe=globe))
x, max_y = self.transform_point(lon, lat, self.as_geodetic())

coords = _ellipse_boundary(a * 1.9999, max_y - false_northing,
false_easting, false_northing, 61)
Expand Down
12 changes: 12 additions & 0 deletions lib/cartopy/tests/crs/test_lambert_conformal.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
# This file is part of Cartopy and is released under the BSD 3-clause license.
# See LICENSE in the root of the repository for full licensing details.

import numpy as np
from numpy.testing import assert_array_almost_equal
import pyproj
import pytest
Expand Down Expand Up @@ -38,6 +39,17 @@ def test_default_with_cutoff():
(-49788019.81831982, 30793476.08487709))


def test_sphere():
"""Test LambertConformal with spherical globe. (#2377)"""
globe = ccrs.Globe(ellipse='sphere')

# This would error creating a boundary
crs = ccrs.LambertConformal(globe=globe)

assert np.all(np.isfinite(crs.x_limits))
assert np.all(np.isfinite(crs.y_limits))


def test_specific_lambert():
# This projection comes from EPSG Projection 3034 - ETRS89 / ETRS-LCC.
crs = ccrs.LambertConformal(central_longitude=10,
Expand Down

0 comments on commit fadfa19

Please sign in to comment.