Skip to content

Commit 3da8d5e

Browse files
committed
crs: also test geodetic
1 parent fd3c818 commit 3da8d5e

1 file changed

Lines changed: 41 additions & 3 deletions

File tree

tests/test_crs.py

Lines changed: 41 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -70,7 +70,7 @@ def proj_gt_98():
7070
reason=
7171
'EPSG:4326 and cartopy PlateCarree are no longer identical in proj>=9.8',
7272
strict=True)
73-
def test_proj_4326_97():
73+
def test_proj_4326_platecarree_default():
7474
# These used to be identical before Proj 9.8.1
7575
dcrs = CRS.from_proj4("+proj=lonlat +datum=WGS84 +ellps=WGS84 +no_defs")
7676
# gcrs = CRS.from_proj4(
@@ -91,7 +91,7 @@ def test_proj_4326_97():
9191
condition=not proj_gt_98(),
9292
reason='EPSG:4326 and cartopy PlateCarree are identical in proj>=9.8',
9393
strict=True)
94-
def test_proj_4326_98():
94+
def test_proj_4326_platecarree_ellipsoid():
9595
# These used to be identical before Proj 9.8.1
9696
dcrs = CRS.from_proj4("+proj=lonlat +datum=WGS84 +ellps=WGS84 +no_defs")
9797

@@ -114,10 +114,48 @@ def test_proj_4326_98():
114114
assert tla == approx(60., abs=0.00001)
115115

116116

117+
def test_proj_4326_geodetic_default():
118+
dcrs = CRS.from_proj4("+proj=lonlat +datum=WGS84 +ellps=WGS84 +no_defs")
119+
# gcrs = CRS.from_proj4(
120+
# "+proj=eqc +ellps=WGS84 +lon_0=0.0 +to_meter=111319.4907932736 +vto_meter=1 +no_defs"
121+
# )
122+
gcrs = ccrs.Geodetic()
123+
print(gcrs)
124+
125+
t = Transformer.from_crs(dcrs, gcrs, always_xy=True)
126+
print(t.transform(5, 60))
127+
128+
tlo, tla = t.transform(5, 60)
129+
assert tlo == approx(5., abs=0.00001)
130+
assert tla == approx(60., abs=0.00001)
131+
132+
133+
def test_proj_4326_geodetic_default_vs_ellipsoid():
134+
# dcrs = CRS.from_proj4("+proj=lonlat +datum=WGS84 +ellps=WGS84 +no_defs")
135+
dcrs = ccrs.Geodetic()
136+
137+
WGS84_SEMIMAJOR_AXIS = 6378137
138+
gcrs = ccrs.Geodetic(
139+
globe=ccrs.Globe(ellipse='WGS84',
140+
semimajor_axis=WGS84_SEMIMAJOR_AXIS,
141+
semiminor_axis=WGS84_SEMIMAJOR_AXIS))
142+
143+
print(gcrs)
144+
# gcrs = CRS.from_proj4(
145+
# "+proj=eqc +ellps=WGS84 +lon_0=0.0 +to_meter=111319.4907932736 +vto_meter=1 +no_defs"
146+
# )
147+
148+
t = Transformer.from_crs(dcrs, gcrs, always_xy=True)
149+
print(t.transform(5, 60))
150+
151+
tlo, tla = t.transform(5, 60)
152+
assert tlo == approx(5., abs=0.00001)
153+
assert tla == approx(60., abs=0.00001)
154+
117155
@pytest.mark.xfail(
118156
reason='cartopy PlateCarree with and without ellipsoid should never be equal.',
119157
strict=True)
120-
def test_proj_platecarree_ellipsoid():
158+
def test_proj_platecarree_default_vs_ellipsoid():
121159
# This should fail on all versions of proj.
122160
dcrs = ccrs.PlateCarree()
123161

0 commit comments

Comments
 (0)