1616
1717from .ellipsoid import Ellipsoid
1818from .mathfun import atan , atan2 , cos , degrees , hypot , isclose , radians , sin , sqrt , tan
19- from .utils import sanitize
2019
2120__all__ = [
2221 "geodetic2ecef" ,
3029 "enu2ecef" ,
3130]
3231
32+ ELL = Ellipsoid .from_name ("wgs84" )
33+
3334
3435def geodetic2ecef (
3536 lat ,
3637 lon ,
3738 alt ,
38- ell : Ellipsoid = None ,
39+ ell : Ellipsoid = ELL ,
3940 deg : bool = True ,
4041) -> tuple :
4142 """
@@ -68,8 +69,9 @@ def geodetic2ecef(
6869 z
6970 target z ECEF coordinate (meters)
7071 """
71- lat , ell = sanitize ( lat , ell , deg )
72+
7273 if deg :
74+ lat = radians (lat )
7375 lon = radians (lon )
7476
7577 # radius of curvature of the prime vertical section
@@ -88,7 +90,7 @@ def ecef2geodetic(
8890 x ,
8991 y ,
9092 z ,
91- ell : Ellipsoid = None ,
93+ ell : Ellipsoid = ELL ,
9294 deg : bool = True ,
9395) -> tuple :
9496 """
@@ -121,9 +123,6 @@ def ecef2geodetic(
121123 Journal of Surveying Engineering. doi: 10.1061/(ASCE)0733-9453
122124 """
123125
124- if ell is None :
125- ell = Ellipsoid .from_name ("wgs84" )
126-
127126 try :
128127 x = asarray (x )
129128 y = asarray (y )
@@ -167,10 +166,7 @@ def ecef2geodetic(
167166 # eqn. 13
168167 Beta += (
169168 (ell .semiminor_axis * u - ell .semimajor_axis * huE + E ** 2 ) * sin (Beta )
170- ) / (
171- ell .semimajor_axis * huE * 1 / cos (Beta )
172- - E ** 2 * cos (Beta )
173- )
169+ ) / (ell .semimajor_axis * huE * 1 / cos (Beta ) - E ** 2 * cos (Beta ))
174170 except (ArithmeticError , RuntimeWarning ):
175171 if isclose (z , 0 ):
176172 Beta = 0
@@ -281,7 +277,7 @@ def ecef2enu(
281277 lat0 ,
282278 lon0 ,
283279 h0 ,
284- ell : Ellipsoid = None ,
280+ ell : Ellipsoid = ELL ,
285281 deg : bool = True ,
286282) -> tuple :
287283 """
@@ -407,7 +403,7 @@ def uvw2enu(u, v, w, lat0, lon0, deg: bool = True) -> tuple:
407403 return East , North , Up
408404
409405
410- def eci2geodetic (x , y , z , t : datetime , ell : Ellipsoid = None , * , deg : bool = True ) -> tuple :
406+ def eci2geodetic (x , y , z , t : datetime , ell : Ellipsoid = ELL , * , deg : bool = True ) -> tuple :
411407 """
412408 convert Earth Centered Internal ECI to geodetic coordinates
413409
@@ -448,7 +444,7 @@ def eci2geodetic(x, y, z, t: datetime, ell: Ellipsoid = None, *, deg: bool = Tru
448444 return ecef2geodetic (xecef , yecef , zecef , ell , deg )
449445
450446
451- def geodetic2eci (lat , lon , alt , t : datetime , ell : Ellipsoid = None , * , deg : bool = True ) -> tuple :
447+ def geodetic2eci (lat , lon , alt , t : datetime , ell : Ellipsoid = ELL , * , deg : bool = True ) -> tuple :
452448 """
453449 convert geodetic coordinates to Earth Centered Internal ECI
454450
@@ -496,7 +492,7 @@ def enu2ecef(
496492 lat0 ,
497493 lon0 ,
498494 h0 ,
499- ell : Ellipsoid = None ,
495+ ell : Ellipsoid = ELL ,
500496 deg : bool = True ,
501497) -> tuple :
502498 """
@@ -532,6 +528,7 @@ def enu2ecef(
532528 z
533529 target z ECEF coordinate (meters)
534530 """
531+
535532 x0 , y0 , z0 = geodetic2ecef (lat0 , lon0 , h0 , ell , deg = deg )
536533 dx , dy , dz = enu2uvw (e1 , n1 , u1 , lat0 , lon0 , deg = deg )
537534
0 commit comments