o
    ÓèFhÁÄ  ã                   @   sZ   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„ 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                   @   sŠ  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  d ZeZeed  d ZdZeejj d Ze ejj¡ZejjZde Ze e¡Zee Zde 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	d
„ ƒZ+e*dd„ ƒZ,e*dd„ ƒZ-e*dd„ ƒZ.e*dd„ ƒZ/e*dd„ ƒZ0e*dd„ ƒZ1dd„ Z2dd„ Z3dd„ Z4dd„ Z5dd „ Z6d!d"„ Z7d#d$„ Z8d%d&„ Z9d'd(„ Z:d)d*„ Z;d+d,„ Z<ej=fd-d.„Z>d/d0„ Z?ej=fd1d2„Z@ej=fd3d4„ZAej=ejBB fd5d6„ZCej=ejBB fd7d8„ZDej=ejBB fd9d:„ZEej=ejBB fd;d<„ZFej=ejBB fd=d>„ZGdCd@dA„ZHejIZI	 ejJZJ	 ejKZK	 ejLZL	 ejMZM	 ej=Z=	 ejBZB	 ejNZN	 ejOZO	 ejPZP	 ejQZQ	 ejRZRdBS )DÚGeodesiczSolve geodesic problemsé   é   é   é   é
   éÈ   iè  c           	      C   s¶   t |ƒ}||  }d||  ||  }d}|d@ r!|d8 }|| }nd}|d }|rK|d8 }|d8 }|| | ||  }|d8 }|| | ||  }|s)| rUd| | | S |||  S )z9Private: Evaluate a trig series using Clenshaw summation.r   r   r   )Úlen)	ÚsinpÚsinxÚcosxÚcÚkÚnÚarÚy1Úy0© r   úO/var/www/html/loop/nvenv/lib/python3.10/site-packages/geographiclib/geodesic.pyÚ_SinCosSeriesz   s    ü
ÿzGeodesic._SinCosSeriesc                 C   s\  t  | ¡}t  |¡}|| d d }|dkr|dksª|| d }t  |¡}|| }||d|   }|}	|dkr`|| }
|
|
dk rFt |¡ nt |¡7 }
t  |
¡}|	||dkr[|| nd 7 }	nt t | ¡||  ¡}|	d| t |d ¡ 7 }	t t  |	¡| ¡}|	dk rŽ|||	  n|	| }|| d|  }|t |t  |¡ ¡|  }|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   r   r   r   Ú_Astroid”   s.   


"
ÿzGeodesic._Astroidc                 C   sD   g d¢}t jd }t ||dt | ¡¡||d   }||  d|   S )zPrivate: return A1-1.)r   r   é@   r   é   r   r   r   )r   ÚnA1_r   Úpolyvalr   ©ÚepsÚcoeffÚmÚtr   r   r   Ú_A1m1fÃ   ó   
"zGeodesic._A1m1fc                 C   ó~   g d¢}t  | ¡}| }d}tdtjd ƒD ]'}tj| d }|t  ||||¡ ||| d   ||< ||d 7 }|| 9 }qdS )zPrivate: return C1.)éÿÿÿÿr   éðÿÿÿé    é÷ÿÿÿr2   é€ÿÿÿé   é	   r?   é   r   éûÿÿÿé   éùÿÿÿé   rH   rC   r   r   r   N)r   r   Úranger   ÚnC1_r5   ©r7   r   r8   Úeps2ÚdÚoÚlr9   r   r   r   Ú_C1fÍ   ó   
(
üzGeodesic._C1fc                 C   r=   )zPrivate: return C1')éÍ   iPþÿÿrE   i   i¥  i€íÿÿi   i 0  iÿÿÿét   é€  iûãÿÿi‡
  é   i‹  rV   iÁ”  i ð  r   r   r   N)r   r   rJ   r   ÚnC1p_r5   rL   r   r   r   Ú_C1pfá   rR   zGeodesic._C1pfc                 C   sD   g d¢}t jd }t ||dt | ¡¡||d   }||  d|   S )zPrivate: return A2-1)iõÿÿÿiäÿÿÿi@ÿÿÿr   r3   r   r   r   )r   ÚnA2_r   r5   r   r6   r   r   r   Ú_A2m1fõ   r<   zGeodesic._A2m1fc                 C   r=   )zPrivate: return C2)r   r   é   r@   é#   r2   rU   rC   é   éP   rE   é   r\   rG   é?   rI   éM   rC   r   r   r   N)r   r   rJ   r   ÚnC2_r5   rL   r   r   r   Ú_C2fÿ   rR   zGeodesic._C2fc              	   C   s˜  t |ƒ| _	 t |ƒ| _	 d| j | _| jd| j  | _| jt | j¡ | _| jd| j  | _| j| j | _	t | j¡t | j	¡| jdkrFdn| jdkrTt
 t
 | j¡¡n	t
 t
 | j ¡¡t
 t| jƒ¡   d | _dtj t
 tdt| jƒƒtdd| jd  ƒ d ¡ | _t
 | j¡r“| jdks—tdƒ‚t
 | j	¡r¢| j	dks¦tdƒ‚tttjƒƒ| _tttjƒƒ| _tt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   çš™™™™™¹?gü©ñÒMbP?ç      ð?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ÚlistrJ   ÚnA3x_Ú_A3xÚnC3x_Ú_C3xÚnC4x_Ú_C4xÚ_A3coeffÚ_C3coeffÚ_C4coeff)Úselfrg   rh   r   r   r   Ú__init__  sB   

þþüÿ
ÿzGeodesic.__init__c                 C   s|   g d¢}d}d}t tjd ddƒD ]*}ttj| d |ƒ}t |||| j¡||| d   | j|< |d7 }||d 7 }qdS )z#Private: return coefficients for A3)éýÿÿÿé€   éþÿÿÿr„   r2   r>   r„   r>   r[   r   r>   r†   é   r   r>   r   r   r   r   r   r>   r   N)rJ   r   ÚnA3_rt   r   r5   rl   rz   )r‚   r8   rO   r   Újr9   r   r   r   r   C  s   (üzGeodesic._A3coeffc                 C   s’   g d¢}d}d}t dtjƒD ]8}t tjd |d dƒD ]*}ttj| d |ƒ}t |||| j¡||| d   | j|< |d7 }||d 7 }qqdS )z#Private: return coefficients for C3)-r   r…   r   é   r…   r>   r   r   r2   r>   r   r   r‡   r>   r   r   rŠ   r3   r   r   r…   r„   r†   r   r2   r   r„   r   r@   r_   rG   iöÿÿÿrD   rU   rŠ   rA   rŠ   éÀ   r_   rG   iòÿÿÿr_   rG   é   i 
  r   r   r>   r   N)rJ   r   ÚnC3_rt   r   r5   rl   r|   ©r‚   r8   rO   r   rP   r‰   r9   r   r   r   r€   T  s   (üÿzGeodesic._C3coeffc                 C   sŠ   g d¢}d}d}t tjƒD ]5}t tjd |d dƒD ]'}tj| d }t |||| j¡||| d   | j|< |d7 }||d 7 }qqdS )z#Private: return coefficients for C4)Méa   é§:  i@  éœ   éõ¯  i ÿÿÿiPíÿÿi%  r’   i`Öÿÿi@7  é îÿÿi¦üÿÿr’   r2   ip  r“   iÐ  iEôÿÿr�   éd   éÐ   i<  ih  iÑÿÿiNu  r’   r   i1#  i€ôÿÿiÔ  éß i   i  iùúÿÿr–   i@  i€ÒÿÿiÀ#  iòõÿÿr–   iÀÿÿÿi�ýÿÿià  i0åÿÿi»  r–   r‡   iå)  i@  iXüÿÿéÉo i ßÿÿi€  iˆûÿÿr—   i`úÿÿi@  r“   i´  r—   ixÿÿÿiWö  i   i0ÿÿÿi‘š i   i óÿÿix  i³Ï rB   r–   i öÿÿi@  i�/ r…   iƒ r   r   r>   r   N)rJ   r   ÚnC4_r   r5   rl   r~   rŽ   r   r   r   r�   o  s   (üÿzGeodesic._C4coeffc                 C   s   t  tjd | jd|¡S )zPrivate: return A3r   r   )r   r5   r   rˆ   rz   )r‚   r7   r   r   r   Ú_A3f�  s   zGeodesic._A3fc                 C   sZ   d}d}t dtjƒD ] }tj| d }||9 }|t || j||¡ ||< ||d 7 }q
dS )zPrivate: return C3r   r   N)rJ   r   r�   r   r5   r|   ©r‚   r7   r   ÚmultrO   rP   r9   r   r   r   Ú_C3f•  s   üzGeodesic._C3fc                 C   sX   d}d}t tjƒD ] }tj| d }|t || j||¡ ||< ||d 7 }||9 }q	dS )zPrivate: return C4r   r   N)rJ   r   r˜   r   r5   r~   rš   r   r   r   Ú_C4f¡  s   
üzGeodesic._C4fc                 C   s"  |t jM }tj } } } }}|t jt jB t jB @ rEt  |¡}t  ||¡ |t jt jB @ rAt  	|¡}t  
||¡ || }d| }d| }|t j@ r…t  d|||¡t  d|||¡ }|||  }|t jt jB @ r„t  d|||¡t  d|||¡ }|| || ||   }n3|t jt jB @ r¸tdt jƒD ]}|||  |||   ||< q“|| t  d|||¡t  d|||¡  }|t j@ rÑ|}|||  |||   || |  }|t j@ �r
|| ||  }| j|	|
  |	|
  ||  }||| ||  | |  }||| ||  | |  }|||||fS )z"Private: return a bunch of lengthsr   T)r   ÚOUT_MASKr   ÚnanÚDISTANCEÚREDUCEDLENGTHÚGEODESICSCALEr;   rQ   rZ   rc   r   rJ   rb   rk   )r‚   r7   Úsig12Ússig1Úcsig1Údn1Ússig2Úcsig2Údn2Úcbet1Úcbet2ÚoutmaskÚC1aÚC2aÚs12bÚm12bÚm0ÚM12ÚM21ÚA1ÚA2Úm0xÚB1ÚB2ÚJ12rP   Úcsig12r:   r   r   r   Ú_Lengths®  sR   
ÿ


ÿÿ€ÿ

ÿzGeodesic._Lengthsc           *      C   s,  d}t j } }}|| ||  }|| ||  }|| }||| 7 }|dko0|dk o0|| dk }|rat || ¡}||t || ¡  }t  d| j|  ¡}|| j|  }t  |¡}t  |¡}n|}|	}|| }|dkr|||| t |¡ d|   n||| t |¡ d|   }t  	||¡}|| || |  }|rÍ|| j
k rÍ|| }||| |dkr·t |¡d|  nd|   }t ||¡\}}t  ||¡}�n/t| jƒdksé|dksé|dt| jƒ t j t |¡ krë�nt  | |	 ¡}| jdk�r*t |¡| j }|ddt  d| ¡  |  }| j| |  |¡ t j }|| } || }!||  }"nT|| ||  }#t  ||#¡}$|  | jt j|$ || ||||||tj|
|¡\}%}&}'}%}%d|&|| |' t j   }!|!dk �rj||! n| j t |¡ t j } | | }|| }"|"tj k�r¾|!dtj k�r¾| jdk�r¥td	|! ƒ}t  dt |¡ ¡ }nWt|!tj k�r¯d
nd|!ƒ}t  dt |¡ ¡}n>t |!|"¡}(|| jdk�rÔ|! |( d|(  n|" d|(  |(  })t  |)¡}t  |)¡ }|| }||| t |¡ d|   }|dk�s
t ||¡\}}nd}d}||||||fS )z3Private: Find a starting value for Newton's method.r>   r   g      à?r   rd   r   r   g{®Gáz„¿re   ç        ç      ð¿)r   rŸ   r   r   r   rk   ri   Úsinr    Úhypotru   Únormr   rp   rl   Úpirh   r™   r»   r   r¡   Útol1_Úxthresh_rt   rs   r1   )*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Úk2r7   ÚlamscaleÚbetscaler!   r"   Úcbet12aÚbet12aÚdummyr°   r±   r   Úomg12ar   r   r   Ú_InverseStartä  sˆ   &þÿÿ"
þÿ$$ ÿ
zGeodesic._InverseStartc           &      C   sv  |dkr|dkrt j }|| }t ||| ¡}|}|| }||  }}t ||¡\}}||kr4|| n|}||ksAt|ƒ| krbt t || ¡|| k rV|| ||  n|| ||   ¡| nt|ƒ}|}|| }||  }}t ||¡\}}t 	t
d|| ||  ƒd || ||  ¡}t
d|| ||  ƒd }|| ||  }t 	||
 ||	  ||
 ||	  ¡}t |¡| j }|ddt d| ¡  |  } |  | |¡ t  d|||¡t  d|||¡ }!| j |  | ¡ | ||!  }"||" }#|�r+|dk�r
d| j | | }$n$|  | |||||||||t j||¡\}%}$}%}%}%|$| j||  9 }$ntj}$|#|||||||| |"|$fS )zPrivate: Solve hybrid problemr   r¼   r   r   Tr†   )r   Útiny_r   r¿   r   rÀ   rp   r   r   r   rs   rk   rœ   r   rh   r™   ri   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Ø   r7   ÚB312Údomg12rÆ   Údlam12rÝ   r   r   r   Ú	_Lambda12p  s`   ýþþýÿÿÿ
þÿzGeodesic._Lambda12c           L      C   s˜	  t j } } } }	 }
}|tjM }t ||¡\}}t  d|¡}|| }|| }t  |¡}t ||¡\}}d| | }t 	t 
|¡¡}t 	t 
|¡¡}t|ƒt|ƒk sXt  |¡rZdnd}|dk ri|d9 }||}}t  d| ¡}||9 }||9 }t |¡\}}|| j9 }t ||¡\}}ttj|ƒ}t |¡\}}|| j9 }t ||¡\}}ttj|ƒ}|| k r¼||kr»t  ||¡}n	t|ƒ| krÅ|}t  d| jt |¡  ¡}t  d| jt |¡  ¡}tttjd ƒƒ}tttjd ƒƒ}tttjƒƒ}|dkpÿ|dk}|�r…|}|}d} d}!|}"|| }#|}$| | }%t  td|#|$ |"|%  ƒd |#|% |"|$  ¡}&|  | j|&|"|#||$|%||||tjB tjB ||¡\}'}(})}	}
|&dk �sU|(dk�rƒ|&dtj k �sm|&tjk �rs|'dk �sm|(dk �rsd }& }(}'|(| j 9 }(|'| j 9 }'t  !|&¡}nd	}d
}*d}+d},|�sÑ|dk�rÑ| j"dk�s¡|| j"d k�rÑd }} d }}!| j#| }'|| j  }&},| j t  $|&¡ }(|tj%@ �rÊt  &|&¡ }	}
|| j }�n§|�sx|  '|||||||||||¡\}&}}}!} }-|&dk�r!|&| j  |- }'t |-¡| j  t  $|&|- ¡ }(|tj%@ �rt  &|&|- ¡ }	}
t  !|&¡}|| j|-  },�nWd}.d	 }/}0tj}1d}2tj}3d}4|.tj(k �r"|  )|||||||||||.tj*k |||¡\}5}!} }&}"}#}$}%}6}7}8|0�sit|5ƒ|/�rbdndtj k�sjn¸|5dk�rƒ|.tj*k�s~|| |4|3 k�rƒ|}3|}4n|5dk �r›|.tj*k�s—|| |2|1 k �r›|}1|}2|.d7 }.|.tj*k �rë|8dk�rë|5 |8 }9t  $|9¡}:t  &|9¡};||; ||:  }<|<dk�rët|9ƒt j+k �rë||; ||:  }|<}t ||¡\}}t|5ƒdtj k}/�q1|1|3 d }|2|4 d }t ||¡\}}d	}/t|1| ƒ|2|  tj,k �pt||3 ƒ||4  tj,k }0|.tj(k �s7||tjtj%B @ �r/tjntj-B }=|  |6|&|"|#||$|%||||=||¡\}'}(})}	}
|(| j 9 }(|'| j 9 }'t  !|&¡}|tj.@ �rxt  $|7¡}>t  &|7¡}?||? ||>  }*||? ||>  }+|tj@ �r‚d|' }|tj@ �rŒd|( }|tj.@ �rŽ|| }@t  /||| ¡}A|Adk�r|@dk�r|}"|| }#|}$| | }%t |A¡| j }B|Bddt  d|B ¡  |B  }6t | j#¡|A |@ | j0 }Ct |"|#¡\}"}#t |$|%¡\}$}%tttj1ƒƒ}D|  2|6|D¡ t 3d	|"|#|D¡}Et 3d	|$|%|D¡}F|C|F|E  }nd}|�s |*d
k�r t  $|,¡}*t  &|,¡}+|�sT|+dk�rT|| dk �rTd|+ }7d| }Gd| }Hdt  |*||H ||G   |7|| |G|H   ¡ }In'|!| | |  }J| | |!|  }K|Jdk�ru|Kdk �rutj| }Jd}Kt  |J|K¡}I|| j4|I 7 }||| | 9 }|d7 }|dk �r¨||!}!}|| } }|tj%@ �r¨|	|
}
}	||| 9 }||| 9 }|!|| 9 }!| || 9 } |||||!| ||	|
|f
S )z/Private: General version of the inverse problemr   é´   r>   r   i¦ÿÿÿre   r¼   r   Fg       @r½   r‡   r[   r   gà-� æ¿g      ü?)5r   rŸ   r   rž   r   ÚAngDiffÚcopysignÚradiansÚsincosdeÚAngRoundÚLatFixrp   ÚisnanÚsincosdri   rÀ   rs   rà   r   rk   r   rx   rJ   rK   rb   r�   r   r»   rl   r    r¡   Útol0_rm   Údegreesrh   rg   r¾   r¢   r    rß   Úmaxit2_rï   Úmaxit1_rÁ   Útolb_ÚEMPTYÚAREAr¿   rj   r˜   r�   r   rq   )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Úcalp1br.   r7   rí   ÚdvÚdalp1Úsdalp1Úcdalp1Únsalp1Ú
lengthmaskÚsdomg12Úcdomg12rå   ræ   rØ   ÚA4ÚC4aÚB41ÚB42Údbet1Údbet2Úalp12Úsalp12Úcalp12r   r   r   Ú_GenInverse½  sf  

"


€ÿþ 



ÿ



ýÿ$

	ÿÓ0ÿ
ÿüþ



ÿ




zGeodesic._GenInversec              
   C   s  |   |||||¡\
}}}}	}
}}}}}|tjM }|tj@ r,t ||¡\}}|| | }nt |¡}t |¡|tj@ r<|nt |¡t |¡|dœ}||d< |tj@ rU||d< |tj	@ rjt 
||	¡|d< t 
|
|¡|d< |tj@ rs||d< |tj@ r€||d< ||d< |tj@ 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Úresultr   r   r   ÚInverseô  s0   
ÿ


ü

zGeodesic.Inversec           	      C   s8   ddl m} |s|tjO }|| ||||ƒ}| |||¡S )z*Private: General version of direct problemr   ©ÚGeodesicLine)Úgeographiclib.geodesicliner3  r   ÚDISTANCE_INÚ_GenPosition)	r‚   r   r  r)  ÚarcmodeÚs12_a12r¬   r3  Úliner   r   r   Ú
_GenDirect  s   zGeodesic._GenDirectc              	   C   sÞ   |   |||d||¡\	}}}}	}}
}}}|tjM }t |¡|tj@ r#|nt |¡t |¡|dœ}||d< |tj@ r<||d< |tj@ rE||d< |tj	@ rN|	|d< |tj
@ rW|
|d< |tj@ rd||d< ||d	< |tj@ rm||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  )r:  r   rž   r   rö   r+  r,  ÚLATITUDEÚ	LONGITUDEr-  r¡   r¢   rÿ   )r‚   r   r  r)  r  r¬   r  r  r  r*  r  r²   r³   r  r0  r   r   r   ÚDirect'  s&   ÿ
ü
zGeodesic.Directc              	   C   sè   |   |||d||¡\	}}}}}	}
}}}|tjM }t |¡|tj@ r#|nt |¡t |¡|dœ}|tj@ r8|	|d< |tj@ rA||d< |tj	@ rJ||d< |tj
@ rS||d< |tj@ r\|
|d< |tj@ ri||d< ||d	< |tj@ rr||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  )r:  r   rž   r   rö   r+  r,  r    r;  r<  r-  r¡   r¢   rÿ   )r‚   r   r  r)  r  r¬   r  r  r*  r  r  r²   r³   r  r0  r   r   r   Ú	ArcDirectL  s&   ÿ
ü
zGeodesic.ArcDirectc                 C   s   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   r2  )r4  r3  )r‚   r   r  r)  Úcapsr3  r   r   r   ÚLineq  s   zGeodesic.Linec           	      C   sJ   ddl m} |s|tjO }|| ||||ƒ}|r| |¡ |S | |¡ |S )z#Private: general form of DirectLiner   r2  )r4  r3  r   r5  ÚSetArcÚSetDistance)	r‚   r   r  r)  r7  r8  r?  r3  r9  r   r   r   Ú_GenDirectLine†  s   

ÿzGeodesic._GenDirectLinec                 C   ó   |   |||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©rC  )r‚   r   r  r)  r  r?  r   r   r   Ú
DirectLine”  ó   zGeodesic.DirectLinec                 C   rD  )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.

    TrE  )r‚   r   r  r)  r  r?  r   r   r   ÚArcDirectLine«  rG  zGeodesic.ArcDirectLinec              
   C   sz   ddl m} |  ||||d¡\
}}}	}
}}}}}}t |	|
¡}|tjtj@ @ r,|tjO }|| |||||	|
ƒ}| 	|¡ |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   r2  )
r4  r3  r(  r   r.  r   rž   r5  r    rA  )r‚   r   r  r  r  r?  r3  r  Ú_rÔ   rÕ   r)  r9  r   r   r   ÚInverseLineÂ  s   
ÿ

zGeodesic.InverseLineFc                 C   s   ddl m} || |ƒS )z¾Return 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.polygonarearK  )r‚   ÚpolylinerK  r   r   r   ÚPolygonß  s   	
zGeodesic.PolygonN)F)SÚ__name__Ú
__module__Ú__qualname__Ú__doc__ÚGEOGRAPHICLIB_GEODESIC_ORDERr4   rK   rW   rY   rb   rˆ   ry   r�   r{   r˜   r}   rü   ÚsysÚ
float_infoÚmant_digrû   r   r   rt   rà   Úepsilonrù   rÂ   rr   rý   rÃ   r   ÚCAP_NONEÚCAP_C1ÚCAP_C1pÚCAP_C2ÚCAP_C3ÚCAP_C4ÚCAP_ALLÚCAP_MASKÚOUT_ALLrž   Ústaticmethodr   r1   r;   rQ   rX   rZ   rc   rƒ   r   r€   r�   r™   rœ   r�   r»   rß   rï   r(  ÚSTANDARDr1  r:  r=  r>  r5  r@  rC  rF  rH  rJ  rN  rþ   r;  r<  r-  r    r¡   r¢   rÿ   ÚALLr+  r   r   r   r   r   V   sà    


.
	


	
0!6 M  :
ÿ+	
ÿ&
ÿ&ÿ
ÿÿ
ÿÿ
ÿÿ
ÿÿ
ÿ
r   )rR  r   rT  Úgeographiclib.geomathr   Úgeographiclib.constantsr   Ú geographiclib.geodesiccapabilityr   r   ÚWGS84_aÚWGS84_fÚWGS84r   r   r   r   Ú<module>   s$    O         ;