Skip to content

Commit

Permalink
MAINT: Changing PlateCarree projection to be more lat/lon like
Browse files Browse the repository at this point in the history
- This pushes the units conversion up to PROJ and allows a globe
  to be defined with a WGS84 semimajor axis which helps for
  coordinate conversions down the line.
  • Loading branch information
greglucas authored and snowman2 committed Jun 24, 2021
1 parent 4d72cfa commit 0a41861
Showing 1 changed file with 8 additions and 8 deletions.
16 changes: 8 additions & 8 deletions lib/cartopy/crs.py
Original file line number Diff line number Diff line change
Expand Up @@ -1235,12 +1235,13 @@ def _ellipse_boundary(semimajor=2, semiminor=1, easting=0, northing=0, n=201):

class PlateCarree(_CylindricalProjection):
def __init__(self, central_longitude=0.0, globe=None):
proj4_params = [('proj', 'eqc'), ('lon_0', central_longitude)]
if globe is None:
globe = Globe(semimajor_axis=math.degrees(1))
a_rad = math.radians(globe.semimajor_axis or WGS84_SEMIMAJOR_AXIS)
x_max = a_rad * 180
y_max = a_rad * 90
globe = globe or Globe(semimajor_axis=WGS84_SEMIMAJOR_AXIS)
proj4_params = [('proj', 'eqc'), ('lon_0', central_longitude),
('to_meter', math.radians(1) * (
globe.semimajor_axis or WGS84_SEMIMAJOR_AXIS)),
('vto_meter', 1)]
x_max = 180
y_max = 90
# Set the threshold around 0.5 if the x max is 180.
self._threshold = x_max / 360
super().__init__(proj4_params, x_max, y_max, globe=globe)
Expand All @@ -1259,7 +1260,7 @@ def _bbox_and_offset(self, other_plate_carree):
>>> src = ccrs.PlateCarree(central_longitude=10)
>>> bboxes, offset = ccrs.PlateCarree()._bbox_and_offset(src)
>>> print(bboxes)
[[-180.0, -170.0], [-170.0, 180.0]]
[[-180, -170.0], [-170.0, 180]]
>>> print(offset)
10.0
Expand Down Expand Up @@ -1308,7 +1309,6 @@ def quick_vertices_transform(self, vertices, src_crs):
potential = (self_params == src_params and
self.y_limits[0] <= ys.min() and
self.y_limits[1] >= ys.max())

if potential:
mod = np.diff(src_crs.x_limits)[0]
bboxes, proj_offset = self._bbox_and_offset(src_crs)
Expand Down

0 comments on commit 0a41861

Please sign in to comment.