11#!/usr/bin/env python
22import pytest
33from pytest import approx
4- import pymap3d as pm
54from math import radians , nan
65import numpy as np
76
7+ import pymap3d as pm
8+
89lla0 = (42 , - 82 , 200 )
910rlla0 = (radians (lla0 [0 ]), radians (lla0 [1 ]), lla0 [2 ])
1011lla1 = (42.002582 , - 81.997752 , 1.1397018e3 )
1920
2021E = pm .Ellipsoid ()
2122
23+ atol_dist = 1e-6 # 1 micrometer
24+
2225
2326def test_ecef ():
2427 xyz = pm .geodetic2ecef (* lla0 )
@@ -36,7 +39,28 @@ def test_ecef():
3639 assert pm .ecef2geodetic (* xyz , deg = False ) == approx (rlla0 )
3740
3841 assert pm .ecef2geodetic ((E .a - 1 ) / np .sqrt (2 ),
39- (E .a - 1 ) / np .sqrt (2 ), 0 )
42+ (E .a - 1 ) / np .sqrt (2 ), 0 ) == approx ([0 , 45 , - 1 ])
43+
44+
45+ @pytest .mark .parametrize ('lla, xyz' , [((0 , 0 , - 1 ), (E .a - 1 , 0 , 0 )),
46+ ((0 , 90 , - 1 ), (0 , E .a - 1 , 0 )),
47+ ((0 , - 90 , - 1 ), (0 , - E .a + 1 , 0 )),
48+ ((90 , 0 , - 1 ), (0 , 0 , E .b - 1 )),
49+ ((90 , 15 , - 1 ), (0 , 0 , E .b - 1 )),
50+ ((- 90 , 0 , - 1 ), (0 , 0 , - E .b + 1 ))
51+ ])
52+ def test_geodetic2ecef (lla , xyz ):
53+ assert pm .geodetic2ecef (* lla ) == approx (xyz , abs = atol_dist )
54+
55+
56+ @pytest .mark .parametrize ('xyz, lla' , [((E .a - 1 , 0 , 0 ), (0 , 0 , - 1 )),
57+ ((0 , E .a - 1 , 0 ), (0 , 90 , - 1 )),
58+ ((0 , 0 , E .b - 1 ), (90 , 0 , - 1 )),
59+ ((0 , 0 , - E .b + 1 ), (- 90 , 0 , - 1 )),
60+ ((- E .a + 1 , 0 , 0 ), (0 , 180 , - 1 )),
61+ ])
62+ def test_ecef2geodetic (xyz , lla ):
63+ assert pm .ecef2geodetic (* xyz ) == approx (lla )
4064
4165
4266def test_aer ():
0 commit comments