Skip to content

Commit 6b19788

Browse files
committed
test float32 geodetic2ecef
1 parent 2917d40 commit 6b19788

File tree

2 files changed

+19
-2
lines changed

2 files changed

+19
-2
lines changed

src/pymap3d/ecef.py

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -88,8 +88,7 @@ def geodetic2ecef(
8888
N = ell.semimajor_axis ** 2 / sqrt(
8989
ell.semimajor_axis ** 2 * cos(lat) ** 2 + ell.semiminor_axis ** 2 * sin(lat) ** 2
9090
)
91-
# Compute cartesian (geocentric) coordinates given (curvilinear) geodetic
92-
# coordinates.
91+
# Compute cartesian (geocentric) coordinates given (curvilinear) geodetic coordinates.
9392
x = (N + alt) * cos(lat) * cos(lon)
9493
y = (N + alt) * cos(lat) * sin(lon)
9594
z = (N * (ell.semiminor_axis / ell.semimajor_axis) ** 2 + alt) * sin(lat)

src/pymap3d/tests/test_geodetic.py

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -240,3 +240,21 @@ def test_numpy_ecef2geodetic(xyz, lla):
240240
assert lat[0] == approx(lla[0])
241241
assert lon[0] == approx(lla[1])
242242
assert alt[0] == approx(lla[2])
243+
244+
245+
@pytest.mark.parametrize("lla, xyz", llaxyz)
246+
def test_numpy_geodetic2ecef(lla, xyz):
247+
np = pytest.importorskip("numpy")
248+
x, y, z = pm.geodetic2ecef(
249+
*np.array(
250+
[
251+
[lla],
252+
],
253+
dtype=np.float32,
254+
).T
255+
)
256+
257+
atol_dist = 1 # meters
258+
assert x[0] == approx(xyz[0], abs=atol_dist)
259+
assert y[0] == approx(xyz[1], abs=atol_dist)
260+
assert z[0] == approx(xyz[2], abs=atol_dist)

0 commit comments

Comments
 (0)