
    Oi%                         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	_        dS )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                   B   e Zd ZU dZd ed<   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        j        Zdez  Z ej        e          ZeZd	ez  Ze j!        Z!e j"        Z"e j#        Z#e j$        Z$e j%        Z%e j&        Z&e j'        Z'e j(        Z(e j)        Z)e j*        Z*e+d
             Z,e+d             Z-e+d             Z.e+d             Z/e+d             Z0e+d             Z1e+d             Z2d Z3d Z4d Z5d Z6d Z7d Z8d Z9d Z:d Z;d Z<d Z=e j>        fdZ?d Z@e j>        fdZAe j>        fdZBe j>        e jC        z  fd ZDe j>        e jC        z  fd!ZEe j>        e jC        z  fd"ZFe j>        e jC        z  fd#ZGe j>        e jC        z  fd$ZHd(d&ZIe jJ        ZJ	 e jK        ZK	 e jL        ZL	 e jM        ZM	 e jN        ZN	 e j>        Z>	 e jC        ZC	 e jO        ZO	 e jP        ZP	 e jQ        ZQ	 e jR        ZR	 e jS        ZSd'S ))GeodesiczSolve geodesic problemsWGS84            
      i  c                    t          |          }|| z
  }d||z
  z  ||z   z  }d}|dz  r|dz  }||         }nd}|dz  }|r3|dz  }|dz  }||z  |z
  ||         z   }|dz  }||z  |z
  ||         z   }|3| rd|z  |z  |z  n|||z
  z  S )z9Private: Evaluate a trig series using Clenshaw summation.r   r   r
   )len)	sinpsinxcosxcknary1y0s	            N/srv/django_bis/venv311/lib/python3.11/site-packages/geographiclib/geodesic.py_SinCosSerieszGeodesic._SinCosSeries{   s     	AA	DA	
dTk	dTk	*B	
B1u 1fa1Q4bbb	QA
 '1fa1fa27R<!A$&b1fa27R<!A$&b	  '
 &* #QX_r!!"r'"%    c                 6   t          j        |           }t          j        |          }||z   dz
  dz  }|dk    r|dk    sV||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k    r||z  ndz   z  }	nLt          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  }n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66a1ff a%!)a71::br6b !a"f*d
a	V 	"q&&tydioo=IbMM	QAFF"q&&** jD5))QV955 	
QUTXcAg&&&&
)DGAJJN
#
#aa%%1A;;QUb6a!e
a 	"twqzz/**Q.
/aa 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   ^      E 	qAQq$'#,,//%A,>AGC  r   c                    g d}t          j        |           }| }d}t          dt          j        dz             D ]M}t          j        |z
  dz  }|t          j        ||||          z  |||z   dz            z  ||<   ||dz   z  }|| z  }NdS )zPrivate: return C1.)r	       r8      	   rE      r         rN   rI   r   r
   r   N)r   r    ranger   nC1_r;   r=   r   r>   eps2dolr?   s           r   _C1fzGeodesic._C1f         E 73<<DA	A1hma'((  =1
"aa40005Q3CCad1q5ja3haa	 r   c                    g d}t          j        |           }| }d}t          dt          j        dz             D ]M}t          j        |z
  dz  }|t          j        ||||          z  |||z   dz            z  ||<   ||dz   z  }|| z  }NdS )zPrivate: return C1')   iPrK   i   i  ii   i 0  it     ii
     i  r]   i  i   r   r
   r   N)r   r    rP   r   nC1p_r;   rR   s           r   _C1pfzGeodesic._C1pf   s      E 73<<DA	A1hnq())  >A!
#aa40005Q3CCad1q5ja3haa	 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   r9   r   r   r
   )r   nA2_r   r;   r    r<   s       r   _A2m1fzGeodesic._A2m1f   rB   r   c                    g d}t          j        |           }| }d}t          dt          j        dz             D ]M}t          j        |z
  dz  }|t          j        ||||          z  |||z   dz            z  ||<   ||dz   z  }|| z  }NdS )zPrivate: return C2)r
   r      rF   #   r8   r\   rI      P   rK      re   rM   ?   rO   M   rI   r   r
   r   N)r   r    rP   r   nC2_r;   rR   s           r   _C2fzGeodesic._C2f   rX   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k    r+t          j        t          j        | j                            n+t          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k    st-          d          t          j        | j	                  r| j	        dk    st-          d          t/          t1          t           j                            | _        t/          t1          t           j                            | _        t/          t1          t           j                            | _        |                                  |                                   | !                                 d	S )
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listrP   nA3x__A3xnC3x__C3xnC4x__C4x_A3coeff_C3coeff_C4coeff)selfrq   rr   s      r   __init__zGeodesic.__init__  sP    1XXDF41XXDF#46zDHvTV$DH4748,,,DIfTV$DGftxDG$'$'"2"2h!mm59X\\$*TYtx00111)DItxi00113tx==))*#+ + -.	.DH &Cs46{{4K4K47QtvaxZ4H4H5IKL5M *O *O ODK=   <TVaZZ:;;;=!! :dgkk8999U8>**++DIU8>**++DIU8>**++DIMMOOOMMOOOMMOOOOOr   c                    g d}d}d}t          t          j        dz
  dd          D ]b}t          t          j        |z
  dz
  |          }t	          j        |||| j                  |||z   dz            z  | j        |<   |dz  }||dz   z  }cdS )z#Private: return coefficients for A3)   r   r8   rD   r   rD   rd   r   rD   r      r
   rD   r   r
   r
   r   r
   rD   r   N)rP   r   nA3_r~   r   r;   rv   r   )r   r>   rU   r   jr?   s         r   r   zGeodesic._A3coeffD  s      E 	
Aq18=1$b"--  
hma!#Q
'
'a\!UAtw77%A	:JJdil1fa1q5jaa	 r   c                 X   g d}d}d}t          dt          j                  D ]}t          t          j        dz
  |dz
  d          D ]b}t          t          j        |z
  dz
  |          }t	          j        |||| j                  |||z   dz            z  | j        |<   |dz  }||dz   z  }cdS )z#Private: return coefficients for C3)-r   r   r      r   rD   r   r   r8   rD   r   r
   r   rD   r
   r   r   r9   r
   r   r   r   r   r   r8   r
   r   r   rF   rh   rM   irJ   r\   r   rG   r      rh   rM   irh   rM      i 
  r   r
   rD   r   N)rP   r   nC3_r~   r   r;   rv   r   r   r>   rU   r   rV   r   r?   s          r   r   zGeodesic._C3coeffU  s      E" 	
Aq11hm$$  X]Q&Ar22  !!A%q))|Aua99E!a%!)<LL	!	Q	QU
	 r   c                 :   g d}d}d}t          t          j                  D ]x}t          t          j        dz
  |dz
  d          D ]T}t          j        |z
  dz
  }t          j        |||| j                  |||z   dz            z  | j        |<   |dz  }||dz   z  }UydS )z#Private: return coefficients for C4)Ma   :  i@       i iPi%  r   i`i@7   ir   r8   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 rH   r   i i@  i/ r   i r   r
   rD   r   N)rP   r   nC4_r   r;   rv   r   r   s          r   r   zGeodesic._C4coeffp  s      E. 	
Aq18=!!  X]Q&Ar22  !MA!|Aua99E!a%!)<LL	!	Q	QU
	 r   c                 T    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#     <)49a===r   c                     d}d}t          dt          j                  D ]C}t          j        |z
  dz
  }||z  }|t          j        || j        ||          z  ||<   ||dz   z  }DdS )zPrivate: return C3r
   r   N)rP   r   r   r   r;   r   r   r=   r   multrU   rV   r?   s          r   _C3fzGeodesic._C3f  s|     D	A1hm$$  
-!
a
a
ckdDLDIq#666ad1q5jaa	 r   c                     d}d}t          t          j                  D ]C}t          j        |z
  dz
  }|t          j        || j        ||          z  ||<   ||dz   z  }||z  }DdS )zPrivate: return C4r
   r   N)rP   r   r   r   r;   r   r   s          r   _C4fzGeodesic._C4f  sz     D	A8=!!  
-!
a
aDLDIq#666ad1q5ja
ckdd	 r   c                    |t           j        z  }t          j        x}x}x}x}x}x}}|t           j        t           j        z  t           j        z  z  rt                               |          }t                               ||           |t           j        t           j        z  z  r?t           	                    |          }t           
                    ||           ||z
  }d|z   }d|z   }|t           j        z  rt                               d|||          t                               d|||          z
  }|||z   z  }|t           j        t           j        z  z  rLt                               d|||          t                               d|||          z
  }||z  ||z  ||z  z
  z   }n|t           j        t           j        z  z  rxt          dt           j                  D ]}|||         z  |||         z  z
  ||<   ||z  t                               d|||          t                               d|||          z
  z   }|t           j        z  r|}|||z  z  |||z  z  z
  ||z  |z  z
  }|t           j        z  rL||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GEODESICSCALErA   rW   rb   rl   r   rP   rk   ru   )r   r=   sig12ssig1csig1dn1ssig2csig2dn2cbet1cbet2outmaskC1aC2as12bm12bm0m0xJ12M12M21A1A2B1B2rV   csig12r@   s                               r   _LengthszGeodesic._Lengths  s
    x  G
 04x7D747"7s7S73(#h&<<() * 	??3bmmC	H*X-CC	D __S!!c32gVr6b"" L""4s;;""4s;;<b 52:d	H*X-CC	D 0$$T5%==$$T5%==>EkR"WrBw./	H*X-CC	D LQ&& + +!c!frCF{*A%K811$ucJJ#11$ucJ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    o|dk     o||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   }|rm|| j
        k     rb||z  }|||z  |dk    rt          j        |          d|z   z  nd|z
  z  z
  }t          j        ||          \  }}t          j        ||          }nt          | j                  dk    sC|dk    s=|dt          | j                  z  t           j        z  t          j        |          z  k    rnt          j        | |	           }| j        dk    r|t          j        |          | j        z  }|ddt          j        d|z             z   z  |z   z  }| j        |z  |                     |          z  t           j        z  }||z  } ||z  }!|| z  }"n||z  ||z  z
  }#t          j        ||#          }$|                     | j        t           j        |$z   || ||||||t&          j        |
|          \  }%}&}'}%}%d|&||z  |'z  t           j        z  z  z   }!|!dk     r||!z  n)| j         t          j        |          z  t           j        z  } | |z  }||z  }"|"t&          j         k    r|!dt&          j        z
  k    r| j        dk    r<t/          d	|!           }t          j        dt          j        |          z
             }nt1          |!t&          j         k    rd
nd|!          }t          j        dt          j        |          z
            }nt&                              |!|"          }(|| 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.rD   r   g      ?r
   rn   r	   r   g{Gzro                 )r!   r   r   r    r"   ru   rs   sinr%   hypotr   normr$   rz   rv   pirr   r   r   r   r   tol1_xthresh_r~   r}   r6   )*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=    Edh..U]UU]*FU]UU]*F emGuu}G!DD1DI 	'wuu}%%f ////fIa$)f,,--ctx#~&exf%fvFNEAG1fuu}twv.!f*===UU]TWV__4F
CC 
 Zu%%FU]UU]V33F ZIVdk))fneuu}+1Q;; )-1v:(F(F<=JH HeYue,,leUj((ee
dg,,#


A++
ADG$tw.?
?
?

 z6'F7++f	1WU^^di'ATYq2v.../"456E>DIIcNN2TW<e#Xh %-%%-/GW-- )-
'47V#UUFCs
.S): ):%tR +dg566#$u99GaKK&475>>1DG; 	e#X	
hn_		R(*;%;!;!;6Q;;cA2,,%$)A4F*G*G(Ga8>/11ssta@@%)A.//%%H a##!qb1fa!enn$%2Q<>4&!!TXf-=-=,=6%%-$'&//9QZHHQJJYue,,leUUe%uc11r   c                 r   |dk    r|dk    rt           j         }||z  }t          j        |||z            }|}||z  }||z  x}}t	          j        ||          \  }}||k    r||z  n|}||k    st          |          | k    rJt          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  } |                     | |           t                               d|||          t                               d|||          z
  }!| j         |                     |           z  |z  ||!z   z  }"||"z   }#|rY|dk    rd| j        z  |z  |z  }$nN|                     | |||||||||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   rz   r"   r    r$   r}   ru   r   r   rr   r   rs   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._Lambda12q  sT   
 zzeqjj ~oe EMEJueem,,E
 E55=5EM!EE9UE**LE5 #e^^EEMME #e**"6"6 Ytwuu}--=BeV^^55=99#em>@ A ACHI I =@JJ 
 E55=5EM!EE9UE**LE5 Js3 =>>D % =? ?E eemeem344s:Femeem3F
*Vg%(88g%(88: :C 
$)	#B
Q1r6***+b0
1CIIc3""4s;;""4s;;<Dvg		#&.%$,?F&LE 		!tx#%--1]]
ueUCsE5

 #s., .,*vueU 	$(eem,,xf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          j        dz                       }t+          t-          t          j                            }|dk    p|dk    }|r
|}|}d} d}!|}"||z  }#|}$| |z  }%t          j        t!          d|#|$z  |"|%z  z
            dz   |#|%z  |"|$z  z             }&|                     | j        |&|"|#||$|%||||t          j        z  t          j        z  ||          \  }'}(})}	}
|&t          j        k     s|(dk    r^|&dt          j        z  k     s|&t          j         k     r|'dk     s|(dk     rdx}&x}(}'|(| j!        z  }(|'| j!        z  }'t          j"        |&          }nd	}d
}*d}+d},|s|dk    r| j#        dk    s|| j#        dz  k    rkdx}} dx}}!| j$        |z  }'|| j        z  x}&},| j!        t          j%        |&          z  }(|t          j&        z  rt          j'        |&          x}	}
|| j        z  }n|s| (                    |||||||||||          \  }&}}}!} }-|&dk    r|&| j!        z  |-z  }'t	          j        |-          | j!        z  t          j%        |&|-z            z  }(|t          j&        z  rt          j'        |&|-z            x}	}
t          j"        |&          }|| j        |-z  z  },nd}.d	x}/}0t          j        }1d}2t          j        }3d}4	 | )                    |||||||||||.t          j*        k     |||          \  }5}!} }&}"}#}$}%}6}7}8|0s4t          |5          |/rdndt          j         z  k    r|.t          j+        k    rn|5dk    r!|.t          j*        k    s||z  |4|3z  k    r|}3|}4n&|5dk     r |.t          j*        k    s||z  |2|1z  k     r|}1|}2|.dz  }.|.t          j*        k     r|8dk    r|5 |8z  }9t          |9          t           j,        k     rt          j%        |9          }:t          j'        |9          };||;z  ||:z  z   }<|<d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          j-        k     p%t          ||3z
            ||4z
  z   t          j-        k     }0||t          j        t          j&        z  z  rt          j        nt          j.        z  }=|                     |6|&|"|#||$|%||||=||          \  }'}(})}	}
|(| j!        z  }(|'| j!        z  }'t          j"        |&          }|t          j/        z  r>t          j%        |7          }>t          j'        |7          }?||?z  ||>z  z
  }*||?z  ||>z  z   }+|t          j        z  rd|'z   }|t          j        z  rd|(z   }|t          j/        z  r6||z  }@t          j0        |||z            }A|Adk    r*|@dk    r#|}"||z  }#|}$| |z  }%t	          j        |A          | j        z  }B|Bddt          j        d|Bz             z   z  |Bz   z  }6t	          j        | j$                  |Az  |@z  | j1        z  }Ct	          j        |"|#          \  }"}#t	          j        |$|%          \  }$}%t+          t-          t          j2                            }D| 3                    |6|D           t          4                    d	|"|#|D          }Et          4                    d	|$|%|D          }F|C|F|Ez
  z  }nd}|s.|*d
k    r(t          j%        |,          }*t          j'        |,          }+|sO|+dk    rI||z
  dk     r@d|+z   }7d|z   }Gd|z   }Hdt          j        |*||Hz  ||Gz  z   z  |7||z  |G|Hz  z   z            z  }InH|!|z  | |z  z
  }J| |z  |!|z  z   }K|Jdk    r|Kdk     rt          j        |z  }Jd}Kt          j        |J|K          }I|| j5        |Iz  z  }|||z  |z  z  }|dz  }|dk     r||!}}!|| }} |t          j&        z  r|	|
}	}
|||z  z  }|||z  z  }|!||z  z  }!| ||z  z  } |||||!| ||	|
|f
S )z/Private: General version of the inverse problemr
      rD   r   iro   r   r   Fg       @r   Tr   rd   r   g-g      ?)6r!   r   r   r   r   AngDiffcopysignradianssincosdeAngRoundLatFixrz   isnansincosdrs   r   r}   r   r"   ru   r    r   rP   rQ   rk   r   r$   r   rv   r   r   r|   tol0_rw   degreesrr   rq   r   r   r%   r   r  maxit1_maxit2_r   tolb_EMPTYAREAr   rt   r   r   r   r{   )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calp1br3   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  s   (,0C0#00c0C#x  G Lt,,ME6mAu%%GeOEg&6VLE]5&11NFFEkV#F =T**++D=T**++D d))c$ii''4:d+;+;'BBEqyymgDdmAu%%GGODGOD <%%LE5u'8u9UE**LE5C4N4NE<%%LE5u'8u9UE**LE5C4N4NE v~~	%eU++	Uv		
)A	DGENN22
3
3C
)A	DGENN22
3
3C uX]Q&''
(
(C
uX]Q&''
(
(C
uX]##
$
$Cs{)fkH %
 efee35 eUU]UeUU]U jS%%-%%-"?@@3F"'%-%%-"?A Ae %)MMuc5%eU(##h&<<c3%H %H!dD%c 
		4199A&&&X^##TAXX #
#%
#$l5!!  F3& u7

	1$&3,.. ee3.55Ve^ddh&&eeWtx&d	8)	) $HUOO#cDHcc g7 04/A/Auc5%eVVS#0O 0O,eUE5% 
!tw$tw&%#+)>)>>X++ 	,hus{++
+#l5!!C( #$0	L #nnE3ucE66583C+C#s 1eUE5%
  CFFE'8qqqHN&JJJx'''UU 000efVm33FUFF1uu%("222+v55FUF
1*%X%%%"q&&BrEE5zzDG##xf%v~6f!7#y66u A"x~"55 F?A%%F?A%%5%00,%%v~&&&5.9HNJ Kuv~&&%&.9HNJ _0	Ld "h&<&.&<'= >+x(( %N	,

 '+mm
ueUCsE5
c3'  ' #dE3 	l5!!X]" 	7HV$$'0@0@gG#fw&66&G#fw&66& "" $Jc'' $Jc 4emej..e	!

uu}uuu}uWU^^di'ATYq2v.../"45WTV__u$u,tx7y..uy..u5''((		#s$$UE5#>>$$UE5#>>C#I  ;&C--%48E??& +
7


%-$

 VQYUE	DJ55=55=+H J &55=55=+H JM M M ..
 Q;;6A::>E)&&
66**	TXc	UW_w&&c	Sjc qyyEUeEUe	8)	) S	UW_Eeuw6e	UW_Eeuw6eUE5%c3CCr   c           
         |                      |||||          \
  }}}}	}
}}}}}|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  r0t	          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  s   $ >B=M=M
D$g>' >':CeE5S#sx  G%% %dD))heQUladdt$$dk$''%(<< &dd%%k$''	 F
 F5M""7CF5M!! 1{5%00fVn{5%00fVn''<'' /fUm36%=3uMr   c                 |    ddl m} |s|t          j        z  } || ||||          }|                    |||          S )z*Private: General version of direct problemr   GeodesicLine)geographiclib.geodesiclinerI  r   DISTANCE_IN_GenPosition)	r   r  r  r>  arcmodes12_a12r   rI  lines	            r   
_GenDirectzGeodesic._GenDirect"  sU    7777773Gx33G<dD$88DWgw777r   c           	         |                      |||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  )rP  r   r   r   r
  r@  rA  LATITUDE	LONGITUDErB  r   r   r  )r   r  r  r>  r  r   r  r  r  r?  r  r   r   r  rE  s                  r   DirectzGeodesic.Direct*  s.   & 6:__
D$sG6- 6-2CtT3S#sx  Gk$''%(<< &dd%%'--	 F
 F5M""9TF6N##:dVF^!!8D6&>''<'' /fUm36%=3uMr   c           	      *   |                      |||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  )rP  r   r   r   r
  r@  rA  r   rR  rS  rB  r   r   r  )r   r  r  r>  r  r   r  r  r?  r  r  r   r   r  rE  s                  r   	ArcDirectzGeodesic.ArcDirectO  s;   & 6:__
D$c76, 6,2CtT3S#sx  Gk$''%(<< &dd%%'--	 F
 ""7CF5M""9TF6N##:dVF^!!8D6&>''<'' /fUm36%=3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   rH  )rJ  rI  )r   r  r  r>  capsrI  s         r   LinezGeodesic.Linet  s.    $ 877777<dD$555r   c                     ddl m} |s|t          j        z  } || ||||          }|r|                    |           n|                    |           |S )z#Private: general form of DirectLiner   rH  )rJ  rI  r   rK  SetArcSetDistance)	r   r  r  r>  rM  rN  rX  rI  rO  s	            r   _GenDirectLinezGeodesic._GenDirectLine  su     8777770DH00D<dD$55D  
kk'
wKr   c                 6    |                      |||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  rX  s         r   
DirectLinezGeodesic.DirectLine  s"    * tT4TBBBr   c                 6    |                      |||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  rX  s         r   ArcDirectLinezGeodesic.ArcDirectLine  s"    * tT4sDAAAr   c           
      &   ddl m} |                     ||||d          \
  }}}	}
}}}}}}t          j        |	|
          }|t
          j        t
          j        z  z  r|t
          j        z  } || |||||	|
          }|	                    |           |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   rH  )
rJ  rI  r<  r   rC  r   r   rK  r   r[  )r   r  r  r  r  rX  rI  r  _r   r   r>  rO  s                r   InverseLinezGeodesic.InverseLine  s    & 877777-1-=-=
D$a.! .!*CE5!Q1a;ue$$Dx 8#778  
hd<dD$eUCCDKKKr   Fc                 &    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.polygonarearg  )r   polylinerg  s      r   PolygonzGeodesic.Polygon  s(     655555;tX&&&r   N)F)T__name__
__module____qualname____doc____annotations__GEOGRAPHICLIB_GEODESIC_ORDERr:   rQ   r^   ra   rk   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   r6   rA   rW   r_   rb   rl   r   r   r   r   r   r   r   r   r   r  r<  STANDARDrF  rP  rT  rV  rK  rY  r]  r`  rb  re  rj  r  rR  rS  rB  r   r   r   r  ALLr@   r   r   r   r   V   so        	!"	%$	%$
&%	%$	%$	%$
%	%$4!8
"%	%$4!8
"%'cn--2'
$)CN&
'
'%
.
 %
+%
$)E

%
%E\(((&&''&&&&&&''((''((% % <%2 , , <,\ ! ! <!   <&   <& ! ! <!   <&. . .`  "  6  B> > >

 
 

 
 
3$ 3$ 3$lH2 H2 H2XJ J JZwD wD wDt	 +3( ( ( (V8 8 8 *2# # # #L -5# # # #L %-)*6 6 6 6, /7'34    +3#/0C C C C0 +3#/0B B B B0 ,4$01   :
' 
' 
' 
' %*%#$-("$.)#$,'-$-(!$-($0+$2-'$2-2$)$$(#$0+ r   r   )rn  r!   rq  geographiclib.geomathr   geographiclib.constantsr    geographiclib.geodesiccapabilityr   r   WGS84_aWGS84_fr   r  r   r   <module>r     s   ; ;^  



 & & & & & & - - - - - - ? ? ? ? ? ?s s s s s s s sj% )+Y->?? + +r   