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 Aug 13, 2021
1 parent 726ebac commit b6a879c
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 @@ -1267,12 +1267,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 @@ -1287,7 +1288,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 @@ -1336,7 +1337,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 b6a879c

Please sign in to comment.