
    g                         d Z ddlZddlZddlmZ ddlmZ ddlmZ  G d d      Z	 e	ej                  ej                        e	_        y)aO  Define the :class:`~geographiclib.geodesic.Geodesic` class

The ellipsoid parameters are defined by the constructor.  The direct and
inverse geodesic problems are solved by

  * :meth:`~geographiclib.geodesic.Geodesic.Inverse` Solve the inverse
    geodesic problem
  * :meth:`~geographiclib.geodesic.Geodesic.Direct` Solve the direct
    geodesic problem
  * :meth:`~geographiclib.geodesic.Geodesic.ArcDirect` Solve the direct
    geodesic problem in terms of spherical arc length

:class:`~geographiclib.geodesicline.GeodesicLine` objects can be created
with

  * :meth:`~geographiclib.geodesic.Geodesic.Line`
  * :meth:`~geographiclib.geodesic.Geodesic.DirectLine`
  * :meth:`~geographiclib.geodesic.Geodesic.ArcDirectLine`
  * :meth:`~geographiclib.geodesic.Geodesic.InverseLine`

:class:`~geographiclib.polygonarea.PolygonArea` objects can be created
with

  * :meth:`~geographiclib.geodesic.Geodesic.Polygon`

The public attributes for this class are

  * :attr:`~geographiclib.geodesic.Geodesic.a`
    :attr:`~geographiclib.geodesic.Geodesic.f`

*outmask* and *caps* bit masks are

  * :const:`~geographiclib.geodesic.Geodesic.EMPTY`
  * :const:`~geographiclib.geodesic.Geodesic.LATITUDE`
  * :const:`~geographiclib.geodesic.Geodesic.LONGITUDE`
  * :const:`~geographiclib.geodesic.Geodesic.AZIMUTH`
  * :const:`~geographiclib.geodesic.Geodesic.DISTANCE`
  * :const:`~geographiclib.geodesic.Geodesic.STANDARD`
  * :const:`~geographiclib.geodesic.Geodesic.DISTANCE_IN`
  * :const:`~geographiclib.geodesic.Geodesic.REDUCEDLENGTH`
  * :const:`~geographiclib.geodesic.Geodesic.GEODESICSCALE`
  * :const:`~geographiclib.geodesic.Geodesic.AREA`
  * :const:`~geographiclib.geodesic.Geodesic.ALL`
  * :const:`~geographiclib.geodesic.Geodesic.LONG_UNROLL`

:Example:

    >>> from geographiclib.geodesic import Geodesic
    >>> # The geodesic inverse problem
    ... Geodesic.WGS84.Inverse(-41.32, 174.81, 40.96, -5.50)
    {'lat1': -41.32,
     'a12': 179.6197069334283,
     's12': 19959679.26735382,
     'lat2': 40.96,
     'azi2': 18.825195123248392,
     'azi1': 161.06766998615882,
     'lon1': 174.81,
     'lon2': -5.5}

    N)Math)	Constants)GeodesicCapabilityc                      e Zd ZdZdZeZeZeZeZeZ	eZ
e
ZeZeedz
  z  dz  ZeZeedz   z  dz  ZdZeej$                  j&                  z   dz   Z ej,                  ej$                  j.                        Zej$                  j2                  Zdez  Z ej,                  e      Zeez  Zdez  Zej@                  Z ejB                  Z!ejD                  Z"ejF                  Z#ejH                  Z$ejJ                  Z%ejL                  Z&ejN                  Z'ejP                  Z(ejR                  Z)e*d	        Z+e*d
        Z,e*d        Z-e*d        Z.e*d        Z/e*d        Z0e*d        Z1d Z2d Z3d Z4d Z5d Z6d Z7d Z8d Z9d Z:d Z;d Z<ejz                  fdZ>d Z?ejz                  fdZ@ejz                  fdZAejz                  ej                  z  fdZCejz                  ej                  z  fd ZDejz                  ej                  z  fd!ZEejz                  ej                  z  fd"ZFejz                  ej                  z  fd#ZGd&d$ZHej                  ZI	 ej                  ZJ	 ej                  ZK	 ej                  ZL	 ej                  ZM	 ejz                  Z=	 ej                  ZB	 ej                  ZN	 ej                  ZO	 ej                  ZP	 ej                  ZQ	 ej                  ZRy%)'GeodesiczSolve geodesic problems            
      i  c                     t        |      }|| z
  }d||z
  z  ||z   z  }d}|dz  r|dz  }||   }nd}|dz  }|r.|dz  }|dz  }||z  |z
  ||   z   }|dz  }||z  |z
  ||   z   }|r.| rd|z  |z  |z  S |||z
  z  S )z9Private: Evaluate a trig series using Clenshaw summation.r
   r   r	   )len)	sinpsinxcosxcknary1y0s	            V/var/www/api/v1/venv_getwork_v1/lib/python3.12/site-packages/geographiclib/geodesic.py_SinCosSerieszGeodesic._SinCosSeriesz   s     	AA	DA	
dTk	dTk	*B	
B1u1fa1Q4bb	QA
1fa1fa27R<!A$&b1fa27R<!A$&b	 
 &*QX_r! %"r'"%    c                 F   t        j                  |       }t        j                  |      }||z   dz
  dz  }|dk(  r|dk  s^||z  dz  }t        j                  |      }||z  }||d|z  z   z  }|}	|dk\  r`||z   }
|
|
dk  rt        j                  |       nt        j                  |      z  }
t        j                  |
      }|	||dk7  r||z  ndz   z  }	nOt        j
                  t        j                  |       ||z          }|	d|z  t        j                  |dz        z  z  }	t        j                  t        j                  |	      |z         }|	dk  r|||	z
  z  n|	|z   }||z
  d|z  z  }|t        j                  |t        j                  |      z         |z   z  }|S d}|S )z Private: solve astroid equation.r	   r   r      r
      )r   sqmathsqrtcbrtatan2cos)xypqrSr2r3discuT3Tangvuvwr   s                    r   _AstroidzGeodesic._Astroid   s   
 	
A
A	
QaA6a1f a%!)a771:br6b !a"f*d
a	V 	"q&tyydiio=IIbM	QAF"q&** jjD5)QV95 	
QUTXXcAg&&&
))DGGAJN
#aa%1A;QUb6a!e
a 		"twwqz/*Q.
/a
 H aHr   c                     g d}t         j                  dz  }t        j                  ||dt        j                  |             ||dz      z  }|| z   d| z
  z  S )zPrivate: return A1-1.)r	   r   @   r      r
   r   r	   )r   nA1_r   polyvalr   epscoeffmts       r   _A1m1fzGeodesic._A1m1f   U    E 	qAQq$''#,/%A,>AGC  r   c                    g d}t        j                  |       }| }d}t        dt        j                  dz         D ]O  }t        j                  |z
  dz  }|t        j
                  ||||      z  |||z   dz      z  ||<   ||dz   z  }|| z  }Q y)zPrivate: return C1.)r       r7      	   rD      r         rM   rH   r   r	   r
   N)r   r   ranger   nC1_r:   r<   r   r=   eps2dolr>   s           r   _C1fzGeodesic._C1f       E 773<DA	A1hmma'(==1
"aa4005Q3CCad1q5ja3ha	 )r   c                    g d}t        j                  |       }| }d}t        dt        j                  dz         D ]O  }t        j                  |z
  dz  }|t        j
                  ||||      z  |||z   dz      z  ||<   ||dz   z  }|| z  }Q y)zPrivate: return C1')   iPrJ   i   i  ii   i 0  it     ii
     i  r\   i  i   r   r	   r
   N)r   r   rO   r   nC1p_r:   rQ   s           r   _C1pfzGeodesic._C1pf   s    E 773<DA	A1hnnq()>>A!
#aa4005Q3CCad1q5ja3ha	 *r   c                     g d}t         j                  dz  }t        j                  ||dt        j                  |             ||dz      z  }|| z
  d| z   z  S )zPrivate: return A2-1)iii@r   r8   r
   r   r	   )r   nA2_r   r:   r   r;   s       r   _A2m1fzGeodesic._A2m1f   rA   r   c                    g d}t        j                  |       }| }d}t        dt        j                  dz         D ]O  }t        j                  |z
  dz  }|t        j
                  ||||      z  |||z   dz      z  ||<   ||dz   z  }|| z  }Q y)zPrivate: return C2)r	   r
      rE   #   r7   r[   rH      P   rJ      rd   rL   ?   rN   M   rH   r   r	   r
   N)r   r   rO   r   nC2_r:   rQ   s           r   _C2fzGeodesic._C2f   rW   r   c           
         t        |      | _        	 t        |      | _        	 d| j                  z
  | _        | j                  d| j                  z
  z  | _        | j                  t        j                  | j                        z  | _        | j                  d| j                  z
  z  | _        | j                  | j                  z  | _	        t        j                  | j                        t        j                  | j                        | j                  dk(  rdn| j                  dkD  r2t        j                  t        j                  | j                              n2t        j                  t        j                  | j                               t        j                  t        | j                              z  z  z   dz  | _        dt         j"                  z  t        j                  t%        dt        | j                              t'        dd| j                  dz  z
        z  dz        z  | _        t        j*                  | j                        r| j                  dkD  st-        d      t        j*                  | j                        r| j                  dkD  st-        d      t/        t1        t         j2                              | _        t/        t1        t         j6                              | _        t/        t1        t         j:                              | _        | j?                          | jA                          | jC                          y	)
a  Construct a Geodesic object

    :param a: the equatorial radius of the ellipsoid in meters
    :param f: the flattening of the ellipsoid

    An exception is thrown if *a* or the polar semi-axis *b* = *a* (1 -
    *f*) is not a finite positive quantity.

    r	   r
   r   皙?gMbP?      ?z!Equatorial radius is not positivezPolar semi-axis is not positiveN)"floataf_f1_e2r   r   _ep2_n_br    atanhr!   atanabs_c2r   tol2_maxmin_etol2isfinite
ValueErrorlistrO   nA3x__A3xnC3x__C3xnC4x__C4x_A3coeff_C3coeff_C4coeff)selfrp   rq   s      r   __init__zGeodesic.__init__  s*    1XDF41XDF#466zDHvvTVV$DH477488,,DIffTVV$DGfftxxDG$''$''"2hh!m59XX\$**TYYtxx01))DIItxxi013txx=)*#+ + -.	.DH &Cs466{4K47QtvvaxZ4H5IKL5M *O ODK== TVVaZ:;;==!dggk899U8>>*+DIU8>>*+DIU8>>*+DIMMOMMOMMOr   c                 *   g d}d}d}t        t        j                  dz
  dd      D ]j  }t        t        j                  |z
  dz
  |      }t	        j
                  |||| j                        |||z   dz      z  | j                  |<   |dz  }||dz   z  }l y)z#Private: return coefficients for A3)   r   r7   rC   r   rC   rc   r   rC   r      r	   rC   r
   r	   r	   r   r	   rC   r
   N)rO   r   nA3_r}   r   r:   ru   r   )r   r=   rT   r   jr>   s         r   r   zGeodesic._A3coeffC  s    E 	
Aq18==1$b"-
hmma!#Q
'a\\!UAtww7%A	:JJdiil1fa1q5ja	 .r   c                 n   g d}d}d}t        dt        j                        D ]  }t        t        j                  dz
  |dz
  d      D ]j  }t        t        j                  |z
  dz
  |      }t	        j
                  |||| j                        |||z   dz      z  | j                  |<   |dz  }||dz   z  }l  y)z#Private: return coefficients for C3)-r   r   r
      r   rC   r   r   r7   rC   r   r	   r   rC   r	   r   r   r8   r	   r   r   r   r   r   r7   r	   r   r
   rE   rg   rL   irI   r[   r   rF   r      rg   rL   irg   rL      i 
  r   r	   rC   r
   N)rO   r   nC3_r}   r   r:   ru   r   r   r=   rT   r   rU   r   r>   s          r   r   zGeodesic._C3coeffT  s    E" 	
Aq11hmm$X]]Q&Ar2!!A%q)||Aua9E!a%!)<LL		!	Q	QU
	 3 %r   c                 X   g d}d}d}t        t        j                        D ]  }t        t        j                  dz
  |dz
  d      D ]`  }t        j                  |z
  dz
  }t        j                  |||| j
                        |||z   dz      z  | j                  |<   |dz  }||dz   z  }b  y)z#Private: return coefficients for C4)Ma   :  i@       i iPi%  r   i`i@7   ir   r7   ip  r   i  iEr   d      i<  ih  iiNu  r   r	   i1#  ii   i  i  ir   i@  ii#  ir   iii  i0i  r   r   i)  i@  iXo i i  ir   i`i@  r   i  r   ixiW  i   i0i i   i ix  i rG   r   i i@  i/ r   i r   r	   rC   r
   N)rO   r   nC4_r   r:   ru   r   r   s          r   r   zGeodesic._C4coeffo  s    E. 	
Aq18==!X]]Q&Ar2!MMA!||Aua9E!a%!)<LL		!	Q	QU
	 3 "r   c                 h    t        j                  t        j                  dz
  | j                  d|      S )zPrivate: return A3r	   r   )r   r:   r   r   r   )r   r<   s     r   _A3fzGeodesic._A3f  s&     <<)499a==r   c                     d}d}t        dt        j                        D ]M  }t        j                  |z
  dz
  }||z  }|t        j                  || j
                  ||      z  ||<   ||dz   z  }O y)zPrivate: return C3r	   r   N)rO   r   r   r   r:   r   r   r<   r   multrT   rU   r>   s          r   _C3fzGeodesic._C3f  sm     D	A1hmm$
--!
a
a
ckdDLLDIIq#66ad1q5ja	 %r   c                     d}d}t        t        j                        D ]M  }t        j                  |z
  dz
  }|t        j                  || j
                  ||      z  ||<   ||dz   z  }||z  }O y)zPrivate: return C4r	   r   N)rO   r   r   r   r:   r   r   s          r   _C4fzGeodesic._C4f  sk     D	A8==!
--!
a
aDLLDIIq#66ad1q5ja
ckd	 "r   c                    |t         j                  z  }t        j                  x}x}x}x}}|t         j                  t         j
                  z  t         j                  z  z  rt         j                  |      }t         j                  ||       |t         j
                  t         j                  z  z  r5t         j                  |      }t         j                  ||       ||z
  }d|z   }d|z   }|t         j                  z  rt         j                  d|||      t         j                  d|||      z
  }||z   z  }|t         j
                  t         j                  z  z  rt         j                  d|||      t         j                  d|||      z
  }|z  ||z  |z  z
  z   }n|t         j
                  t         j                  z  z  rjt        dt         j                        D ]  }||   z  ||   z  z
  ||<    |z  t         j                  d|||      t         j                  d|||      z
  z   }|t         j
                  z  r}|||z  z  |||z  z  z
  ||z  z  z
  }|t         j                  z  rQ||z  ||z  z   }| j                  |	|
z
  z  |	|
z   z  ||z   z  }|||z  |z  z
  |z  |z  z   }|||z  ||z  z
  |z  |z  z
  }|||||fS )z"Private: return a bunch of lengthsr	   T)r   OUT_MASKr    nanDISTANCEREDUCEDLENGTHGEODESICSCALEr@   rV   ra   rk   r   rO   rj   rt   )r   r<   sig12ssig1csig1dn1ssig2csig2dn2cbet1cbet2outmaskC1aC2as12bm12bm0M12M21A1A2m0xB1B2J12rU   csig12r?   s                               r   _LengthszGeodesic._Lengths  s    x   G
 $(88+D+4+"+sS(##h&<&<<(() *??3bmmC	H**X-C-CC	D__S!c32gVr6b"""""4s;""4s;<b 52:d	H**X-C-CC	D$$T5%=$$T5%=>EkR"WrBw./	H**X-C-CC	DQ&!c!frCF{*A '%K811$ucJ#11$ucJK Lc'''b UU]#cUU]&;;emc!"d'''u}uu},f
))uu}
%
739
Eaa%i%#+-6<<ca%i%#+-6<<cr3##r   c                 |
   d}t         j                  x}x}}||z  ||z  z
  }||z  ||z  z   }||z  }|||z  z  }|dk\  xr |dk  xr ||z  dk  }|rt        j                  ||z         }||t        j                  ||z         z   z  }t        j                  d| j
                  |z  z         }|| j                  |z  z  }t        j                  |      }t        j                  |      }n|}|	}||z  }|dk\  r$|||z  t        j                  |      z  d|z   z  z   n#|||z  t        j                  |      z  d|z
  z  z
  }t        j                  ||      }||z  ||z  |z  z   }|rs|| j                  k  rd||z  }|||z  |dk\  rt        j                  |      d|z   z  nd|z
  z  z
  }t        j                  ||      \  }}t        j                  ||      }n:t        | j                        dk\  sG|dk\  sB|dt        | j                        z  t         j                  z  t        j                  |      z  k\  rnt        j                  | |	       }| j                   dk\  rt        j                  |      | j
                  z  }|ddt        j                  d|z         z   z  |z   z  }| j                   |z  | j#                  |      z  t         j                  z  }||z  } ||z  }!|| z  }"n||z  ||z  z
  }#t        j                  ||#      }$| j%                  | j                  t         j                  |$z   || ||||||t&        j(                  |
|      \  }%}&}'}%}%d|&||z  |'z  t         j                  z  z  z   }!|!dk  r||!z  n3| j                    t        j                  |      z  t         j                  z  } | |z  }||z  }"|"t&        j*                   kD  r|!dt&        j,                  z
  kD  r| j                   dk\  r:t/        d	|!       }t        j                  dt        j                  |      z
         }nt1        |!t&        j*                   kD  rd
nd|!      }t        j                  dt        j                  |      z
        }nt&        j3                  |!|"      }(|| j                   dk\  r|! |(z  d|(z   z  n|" d|(z   z  |(z  z  })t        j                  |)      }t        j                  |)       }||z  }|||z  t        j                  |      z  d|z
  z  z
  }|dk  st        j                  ||      \  }}nd}d}||||||fS )z3Private: Find a starting value for Newton's method.rC   r   g      ?r	   rm   r   r
   g{Gzrn                 )r    r   r   r   r!   rt   rr   sinr$   hypotr~   normr#   ry   ru   pirq   r   r   r   r   tol1_xthresh_r}   r|   r5   )*r   sbet1r   r   sbet2r   r   lam12slam12clam12r   r   r   salp2calp2dnmsbet12cbet12sbet12a	shortlinesbetm2omg12somg12comg12salp1calp1ssig12r   lam12xk2r<   lamscalebetscaler%   r&   cbet12abet12adummyr   r   r   omg12as*                                             r   _InverseStartzGeodesic._InverseStart  s    Edhh..U]UU]*FU]UU]*F emGuu}G!DD1DIwwuu}%f ///fIIa$))f,,-ctxx#~&exxf%fvFNEAG1fuu}twwv.!f*==UU]TWWV_4F
CC 
 ZZu%FU]UU]V33FVdkk)fneuu}+1Q; )-1v:(F<=JH HeYYue,leUjj(e
dgg,#

A+
ADGG$tww.?
?

 zz6'F7+f	1WWU^dii'ATYYq2v../"4566E>DIIcN2TWW<e#Xh %-%%-/GW- )-
''477V#UUFCs
..S):%tR +dgg566#$u9GaK&&4775>1DGG; 	e#X	
hnn_	R(*;*;%;!;66Q;cA2,%$))A4F*G(Ga8>>/1sta@%))A./%H a#!qb1fa!en$%2Q<>4&!TXXf-=,=6%%-$''&/9QZHHQJYYue,leUe%uc11r   c                 j   |dk(  r|dk(  rt         j                   }||z  }t        j                  |||z        }|}||z  }||z  x}}t	        j
                  ||      \  }}||k7  r||z  n|}||k7  st        |      | k7  rKt        j                  t	        j                  ||z        || k  r||z
  ||z   z  n
||z
  ||z   z  z         |z  n
t        |      }|}||z  }||z  x}}t	        j
                  ||      \  }}t        j                  t        d||z  ||z  z
        dz   ||z  ||z  z         }t        d||z  ||z  z
        dz   }||z  ||z  z   }t        j                  ||
z  ||	z  z
  ||
z  ||	z  z         }t	        j                  |      | j                  z  }|ddt        j                  d|z         z   z  |z   z  } | j                  | |       t         j                  d|||      t         j                  d|||      z
  }!| j                   | j                  |       z  |z  ||!z   z  }"||"z   }#|rb|dk(  rd| j                   z  |z  |z  }$nW| j#                  | |||||||||t         j$                  ||      \  }%}$}%}%}%|$| j                   ||z  z  z  }$nt        j&                  }$|#|||||||| |"|$fS )zPrivate: Solve hybrid problemr   r   r
   r	   Tr   )r   tiny_r    r   r   r   ry   r!   r   r#   r|   rt   r   r   rq   r   rr   r   r   r   )&r   r   r   r   r   r   r   r   r   slam120clam120diffpr   r   C3asalp0calp0r   somg1r   comg1r   r   r   somg2r   comg2r   r   r   etar   r<   B312domg12r   dlam12r   s&                                         r   	_Lambda12zGeodesic._Lambda12p  s   
 zeqj ~~oe EMEJJueem,E
 E55=5EM!EE99UE*LE5 #e^EEME #e*"6 YYtwwuu}-=BeV^55=9#em>@ ACHI =@J 
 E55=5EM!EE99UE*LE5 JJs3 =>D % =?E eemeem34s:Femeem3F
**Vg%(88g%(88:C 
$))	#B
Q1r6**+b0
1CIIc3""4s;""4s;<Dvvg		#&.%$,?F&LE	!txx#%--1]]
ueUCsE5

 
 #s.,*vueU 	$((eem,,xxf5%ueUCF r   c                 ^   t         j                  x}x}x}x}	x}
}|t        j                  z  }t	        j
                  ||      \  }}t        j                  d|      }||z  }||z  }t        j                  |      }t	        j                  ||      \  }}d|z
  |z
  }t	        j                  t	        j                  |            }t	        j                  t	        j                  |            }t        |      t        |      k  st        j                  |      rdnd}|dk  r	|dz  }||}}t        j                  d|       }||z  }||z  }t	        j                  |      \  }}|| j                  z  }t	        j                  ||      \  }}t!        t        j"                  |      }t	        j                  |      \  }}|| j                  z  }t	        j                  ||      \  }}t!        t        j"                  |      }|| k  r||k(  r(t        j                  ||      }nt        |      | k(  r|}t        j$                  d| j&                  t	        j(                  |      z  z         }t        j$                  d| j&                  t	        j(                  |      z  z         }t+        t-        t        j.                  dz               }t+        t-        t        j0                  dz               }t+        t-        t        j2                              }|dk(  xs |dk(  }|r|}|}d} d}!|}"||z  }#|}$| |z  }%t        j4                  t!        d|#|$z  |"|%z  z
        dz   |#|%z  |"|$z  z         }&| j7                  | j8                  |&|"|#||$|%||||t        j:                  z  t        j<                  z  ||      \  }'}(})}	}
|&dk  s|(dk\  rm|&dt        j"                  z  k  s|&t        j>                  k  r|'dk  s|(dk  rdx}&x}(}'|(| j@                  z  }(|'| j@                  z  }'t        jB                  |&      }nd	}d
}*d}+d},|s|dk(  r| jD                  dk  s|| jD                  dz  k\  rdx}} dx}}!| jF                  |z  }'|| j                  z  x}&},| j@                  t        jH                  |&      z  }(|t        jJ                  z  rt        jL                  |&      x}	}
|| j                  z  }n|s| jO                  |||||||||||      \  }&}}}!} }-|&dk\  r|&| j@                  z  |-z  }'t	        j(                  |-      | j@                  z  t        jH                  |&|-z        z  }(|t        jJ                  z  rt        jL                  |&|-z        x}	}
t        jB                  |&      }|| j                  |-z  z  },n+d}.d	x}/}0t        j"                  }1d}2t        j"                  }3d}4|.t        jP                  k  r| jS                  |||||||||||.t        jT                  k  |||      \  }5}!} }&}"}#}$}%}6}7}8|0s#t        |5      |/rdndt        j>                  z  k\  sn|5dkD  r#|.t        jT                  kD  s||z  |4|3z  kD  r|}3|}4n'|5dk  r"|.t        jT                  kD  s||z  |2|1z  k  r|}1|}2|.dz  }.|.t        jT                  k  r|8dkD  r|5 |8z  }9t        jH                  |9      }:t        jL                  |9      };||;z  ||:z  z   }<|<dkD  rct        |9      t         jV                  k  rG||;z  ||:z  z
  }|<}t	        j                  ||      \  }}t        |5      dt        j>                  z  k  }/|1|3z   dz  }|2|4z   dz  }t	        j                  ||      \  }}d	}/t        |1|z
        |2|z
  z   t        jX                  k  xs% t        ||3z
        ||4z
  z   t        jX                  k  }0|.t        jP                  k  r||t        j<                  t        jJ                  z  z  rt        j:                  nt        jZ                  z  }=| j7                  6|&"#|$%||||=||      \  }'}(})}	}
|(| j@                  z  }(|'| j@                  z  }'t        jB                  |&      }|t        j\                  z  r@t        jH                  7      }>t        jL                  |7      }?||?z  ||>z  z
  }*||?z  ||>z  z   }+|t        j:                  z  rd'z   }|t        j<                  z  rd(z   }|t        j\                  z  r?|z  }@t        j^                  ||z        }A|Adk7  r+@dk7  r%|}"||z  }#|}$ |z  }%t	        j(                  A      | j&                  z  }B|Bddt        j$                  d|Bz         z   z  |Bz   z  }6t	        j(                  | jF                        |Az  @z  | j`                  z  }Ct	        j                  |"|#      \  }"}#t	        j                  |$|%      \  }$}%t+        t-        t        jb                              }D| je                  |6|D       t        jg                  d	|"|#|D      }Et        jg                  d	|$|%|D      }F|C|F|Ez
  z  }nd}|s/|*d
k(  r*t        jH                  |,      }*t        jL                  |,      }+|sN|+dkD  rI||z
  dk  rAd|+z   }7d|z   }Gd|z   }Hdt        j4                  |*||Hz  ||Gz  z   z  |7||z  |G|Hz  z   z        z  }InK!|z   |z  z
  }J| |z  |!|z  z   }K|Jdk(  rKdk  rt        j"                  |z  }Jd}Kt        j4                  JK      }I|| jh                  Iz  z  }|||z  |z  z  }|dz  }|dk  r!}}! }} |t        jJ                  z  r|	|
}	}
||z  z  }||z  z  }!||z  z  }! ||z  z  } |||||!| ||	|
|f
S )z/Private: General version of the inverse problemr	      rC   r   irn   r   r   Fg       @r   r   rc   r
   g-g      ?)5r    r   r   r   r   AngDiffcopysignradianssincosdeAngRoundLatFixry   isnansincosdrr   r   r|   r   r!   rt   r   r   rO   rP   rj   r   r#   r   ru   r   r   tol0_rv   degreesrq   rp   r   r   r$   r   maxit2_r  maxit1_r   tolb_EMPTYAREAr   rs   r   r   r   rz   )Lr   lat1lon1lat2lon2r   a12s12m12r   r   S12lon12lon12slonsignr   r   r   swapplatsignr   r   r   r   r   r   r   r   r   meridianr   r   r   r   r   r   r   r   r   s12xm12xr   r   r   r   r   numittripntripbsalp1acalp1asalp1bcalp1br2   r<   r   dvdalp1sdalp1cdalp1nsalp1
lengthmasksdomg12cdomg12r   r   r   A4C4aB41B42dbet1dbet2alp12salp12calp12sL                                                                               r   _GenInversezGeodesic._GenInverse  sh   (,0C0#00c0C#x   G LLt,ME6mmAu%GeOEg&6VLLE]]5&1NFFEkV#F ==T*+D==T*+D d)c$i'4::d+;BEqymgDdmmAu%GGODGOD <<%LE5u'8u99UE*LE5C4NE<<%LE5u'8u99UE*LE5C4NE v~	%eU+	Uv	
))A		DGGEN22
3C
))A		DGGEN22
3C uX]]Q&'
(C
uX]]Q&'
(C
uX]]#
$Cs{)fkH
 efee35 eUU]UeUU]U jjS%%-%%-"?@3F"'%-%%-"?Ae %)MMuc5%eU(###h&<&<<c3%H!dD%c 
daiA&&X^^#TAX #
#%
#$ll5!  F3&
	1$&&3,. ee3.55VVe^ddhh&&eeWWtxx&d	8))	)HHUO#cDHHc 04/A/Auc5%eVVS#0O,eUE5% 
!tww$tww&%#+)>>X+++hhus{+
+#ll5!C( #$h&&& #nnE3ucE66583C3C+C#s1eUE5%
 3q65aa8>>%IIU 0 00efVm3FUF1u%("2"22+v5FUF
1*%X%%%"q&BrEEXXe_FtxxfV^efn4Fzc%j4772fnuv~5ee!YYue4leU !fX^^ 33e F?A%%F?A%%5%0,%%v~&&5.9HNNJ Kuv~&%&.9HNNJ [ h&&&` "h&<&<&.&<&<'= >  (( %NN	,

 '+mm
ueUCsE5
c3' #dE3 	ll5!X]]"HHV$'0@gG#fw&66&G#fw&66& """$Jc'''$Jcemejj.e	!
uu}uuu}uWWU^dii'ATYYq2v../"45WWTVV_u$u,txx7yy.uyy.u5'(		#s$$UE5#>$$UE5#>C#I &C-%488E?&
7

%-$
 VQYUE	DJJ55=55=+H J &55=55=+H JM M ..
 Q;6A:>>E)&&

66*	TXXc	UW_w&&c	Sjc qyEUeEUe	8))	)S	UW_Eeuw6e	UW_Eeuw6eUE5%c3CCr   c           
         | j                  |||||      \
  }}}}	}
}}}}}|t        j                  z  }|t        j                  z  r"t	        j
                  ||      \  }}||z   |z   }nt	        j                  |      }t	        j                  |      |t        j                  z  r|nt	        j                  |      t	        j                  |      |d}||d<   |t        j                  z  r||d<   |t        j                  z  r2t	        j                  ||	      |d<   t	        j                  |
|      |d<   |t        j                  z  r||d<   |t        j                  z  r
||d<   ||d<   |t        j                  z  r||d	<   |S )
a7  Solve the inverse geodesic problem

    :param lat1: latitude of the first point in degrees
    :param lon1: longitude of the first point in degrees
    :param lat2: latitude of the second point in degrees
    :param lon2: longitude of the second point in degrees
    :param outmask: the :ref:`output mask <outmask>`
    :return: a :ref:`dict`

    Compute geodesic between (*lat1*, *lon1*) and (*lat2*, *lon2*).
    The default value of *outmask* is STANDARD, i.e., the *lat1*,
    *lon1*, *azi1*, *lat2*, *lon2*, *azi2*, *s12*, *a12* entries are
    returned.

    )r  r  r  r  r  r  azi1azi2r  r   r   r  )r;  r   r   LONG_UNROLLr   r  AngNormalizer	  r   AZIMUTHatan2dr   r   r  )r   r  r  r  r  r   r  r  r   r   r   r   r  r   r   r  r  eresults                      r   InversezGeodesic.Inverse  sj   $ >B=M=M
D$g>':CeE5S#sx   G%%%dD)heQUladt$dkk$'%(<(<<d%kk$'	F
 F5M"""CF5M!!!{{5%0fVn{{5%0fVn''''''fUm36%=uMr   c                 v    ddl m} |s|t        j                  z  } || ||||      }|j	                  |||      S )z*Private: General version of direct problemr   GeodesicLine)geographiclib.geodesiclinerH  r   DISTANCE_IN_GenPosition)	r   r  r  r=  arcmodes12_a12r   rH  lines	            r   
_GenDirectzGeodesic._GenDirect  s>    7Gx333GdD$8DWgw77r   c           	      J   | j                  |||d||      \	  }}}}	}}
}}}|t        j                  z  }t        j                  |      |t        j
                  z  r|nt        j                  |      t        j                  |      |d}||d<   |t        j                  z  r||d<   |t        j                  z  r||d<   |t        j                  z  r|	|d<   |t        j                  z  r|
|d<   |t        j                  z  r
||d<   ||d	<   |t        j                  z  r||d
<   |S )a_  Solve the direct geodesic problem

    :param lat1: latitude of the first point in degrees
    :param lon1: longitude of the first point in degrees
    :param azi1: azimuth at the first point in degrees
    :param s12: the distance from the first point to the second in
      meters
    :param outmask: the :ref:`output mask <outmask>`
    :return: a :ref:`dict`

    Compute geodesic starting at (*lat1*, *lon1*) with azimuth *azi1*
    and length *s12*.  The default value of *outmask* is STANDARD, i.e.,
    the *lat1*, *lon1*, *azi1*, *lat2*, *lon2*, *azi2*, *s12*, *a12*
    entries are returned.

    F)r  r  r=  r  r  r  r  r>  r  r   r   r  )rO  r   r   r   r	  r?  r@  LATITUDE	LONGITUDErA  r   r   r  )r   r  r  r=  r  r   r  r  r  r>  r  r   r   r  rD  s                  r   DirectzGeodesic.Direct'  s   & 6:__
D$sG6-2CtT3S#sx   Gkk$'%(<(<<d%''-	F
 F5M"""TF6N###dVF^!!!D6&>''''''fUm36%=uMr   c           	      p   | j                  |||d||      \	  }}}}}	}
}}}|t        j                  z  }t        j                  |      |t        j
                  z  r|nt        j                  |      t        j                  |      |d}|t        j                  z  r|	|d<   |t        j                  z  r||d<   |t        j                  z  r||d<   |t        j                  z  r||d<   |t        j                  z  r|
|d<   |t        j                  z  r
||d<   ||d	<   |t        j                  z  r||d
<   |S )a  Solve the direct geodesic problem in terms of spherical arc length

    :param lat1: latitude of the first point in degrees
    :param lon1: longitude of the first point in degrees
    :param azi1: azimuth at the first point in degrees
    :param a12: spherical arc length from the first point to the second
      in degrees
    :param outmask: the :ref:`output mask <outmask>`
    :return: a :ref:`dict`

    Compute geodesic starting at (*lat1*, *lon1*) with azimuth *azi1*
    and arc length *a12*.  The default value of *outmask* is STANDARD,
    i.e., the *lat1*, *lon1*, *azi1*, *lat2*, *lon2*, *azi2*, *s12*,
    *a12* entries are returned.

    T)r  r  r=  r  r  r  r  r>  r  r   r   r  )rO  r   r   r   r	  r?  r@  r   rQ  rR  rA  r   r   r  )r   r  r  r=  r  r   r  r  r>  r  r  r   r   r  rD  s                  r   	ArcDirectzGeodesic.ArcDirectL  s,   & 6:__
D$c76,2CtT3S#sx   Gkk$'%(<(<<d%''-	F
 """CF5M"""TF6N###dVF^!!!D6&>''''''fUm36%=uMr   c                 &    ddl m}  || ||||      S )a  Return a GeodesicLine object

    :param lat1: latitude of the first point in degrees
    :param lon1: longitude of the first point in degrees
    :param azi1: azimuth at the first point in degrees
    :param caps: the :ref:`capabilities <outmask>`
    :return: a :class:`~geographiclib.geodesicline.GeodesicLine`

    This allows points along a geodesic starting at (*lat1*, *lon1*),
    with azimuth *azi1* to be found.  The default value of *caps* is
    STANDARD | DISTANCE_IN, allowing direct geodesic problem to be
    solved.

    r   rG  )rI  rH  )r   r  r  r=  capsrH  s         r   LinezGeodesic.Lineq  s    $ 8dD$55r   c                     ddl m} |s|t        j                  z  } || ||||      }|r|j	                  |       |S |j                  |       |S )z#Private: general form of DirectLiner   rG  )rI  rH  r   rJ  SetArcSetDistance)	r   r  r  r=  rL  rM  rW  rH  rN  s	            r   _GenDirectLinezGeodesic._GenDirectLine  sV     8DH000DdD$5D
kk' K wKr   c                 .    | j                  |||d||      S )a  Define a GeodesicLine object in terms of the direct geodesic
    problem specified in terms of spherical arc length

    :param lat1: latitude of the first point in degrees
    :param lon1: longitude of the first point in degrees
    :param azi1: azimuth at the first point in degrees
    :param s12: the distance from the first point to the second in
      meters
    :param caps: the :ref:`capabilities <outmask>`
    :return: a :class:`~geographiclib.geodesicline.GeodesicLine`

    This function sets point 3 of the GeodesicLine to correspond to
    point 2 of the direct geodesic problem.  The default value of *caps*
    is STANDARD | DISTANCE_IN, allowing direct geodesic problem to be
    solved.

    Fr\  )r   r  r  r=  r  rW  s         r   
DirectLinezGeodesic.DirectLine  s    * tT4TBBr   c                 .    | j                  |||d||      S )a  Define a GeodesicLine object in terms of the direct geodesic
    problem specified in terms of spherical arc length

    :param lat1: latitude of the first point in degrees
    :param lon1: longitude of the first point in degrees
    :param azi1: azimuth at the first point in degrees
    :param a12: spherical arc length from the first point to the second
      in degrees
    :param caps: the :ref:`capabilities <outmask>`
    :return: a :class:`~geographiclib.geodesicline.GeodesicLine`

    This function sets point 3 of the GeodesicLine to correspond to
    point 2 of the direct geodesic problem.  The default value of *caps*
    is STANDARD | DISTANCE_IN, allowing direct geodesic problem to be
    solved.

    Tr^  )r   r  r  r=  r  rW  s         r   ArcDirectLinezGeodesic.ArcDirectLine  s    * tT4sDAAr   c           
      *   ddl m} | j                  ||||d      \
  }}}	}
}}}}}}t        j                  |	|
      }|t
        j                  t
        j                  z  z  r|t
        j                  z  } || |||||	|
      }|j                  |       |S )a  Define a GeodesicLine object in terms of the invese geodesic problem

    :param lat1: latitude of the first point in degrees
    :param lon1: longitude of the first point in degrees
    :param lat2: latitude of the second point in degrees
    :param lon2: longitude of the second point in degrees
    :param caps: the :ref:`capabilities <outmask>`
    :return: a :class:`~geographiclib.geodesicline.GeodesicLine`

    This function sets point 3 of the GeodesicLine to correspond to
    point 2 of the inverse geodesic problem.  The default value of *caps*
    is STANDARD | DISTANCE_IN, allowing direct geodesic problem to be
    solved.

    r   rG  )
rI  rH  r;  r   rB  r   r   rJ  r   rZ  )r   r  r  r  r  rW  rH  r  _r   r   r=  rN  s                r   InverseLinezGeodesic.InverseLine  s    & 8-1-=-=
D$a.!*CE5!Q1a;;ue$Dx  8#7#778
hddD$eUCDKKKr   c                      ddl m}  || |      S )zReturn a PolygonArea object

    :param polyline: if True then the object describes a polyline
      instead of a polygon
    :return: a :class:`~geographiclib.polygonarea.PolygonArea`

    r   )PolygonArea)geographiclib.polygonarearf  )r   polylinerf  s      r   PolygonzGeodesic.Polygon  s     6tX&&r   N)F)S__name__
__module____qualname____doc__GEOGRAPHICLIB_GEODESIC_ORDERr9   rP   r]   r`   rj   r   r   r   r   r   r   r  sys
float_infomant_digr  r    r!   r}   r   epsilonr  r   r{   r  r   r   CAP_NONECAP_C1CAP_C1pCAP_C2CAP_C3CAP_C4CAP_ALLCAP_MASKOUT_ALLr   staticmethodr   r5   r@   rV   r^   ra   rk   r   r   r   r   r   r   r   r   r   r  r;  STANDARDrE  rO  rS  rU  rJ  rX  r\  r_  ra  rd  ri  r  rQ  rR  rA  r   r   r   r  ALLr?   r   r   r   r   V   s   !"	%$	%$
&%	%$	%$	%$
%	%$4!8
"%	%$4!8
"%'cnn---2'
$))CNN&&
'%
..
 
 %
+%
$))E
%
%-%E\((((&&&'''&&&&&&&&&'''((('''(((% %2 , ,\ ! !  &  & ! !  &.`"6B>


3$lH2XJZuDp	 +33(V8 *22#L -55#L %--))*6, /77'334 +33#//0C0 +33#//0B0 ,44$001:
' %**%#$--("$..)#$,,'-$--(!$--($00+$22-'$22-2$))$$((#$00+r   r   )rm  r    ro  geographiclib.geomathr   geographiclib.constantsr    geographiclib.geodesiccapabilityr   r   WGS84_aWGS84_fWGS84r  r   r   <module>r     sH   ;^  
 & - ?p pd% )++Y->->? +r   