a
    J5d                     @   sZ   d dl Z dd Zdd Zdd ZG dd	 d	Zi fd
dZdddZdd ZdddZdS )    Nc                 C   s    t | }| | }||d d  S )zParse an encoded geocoordinate value into real degrees.

    :param float coord: encoded geocoordinate value
    :return: real degrees
    :rtype: float
          int)coorddegreesminutes r	   J/var/www/html/django/DPS/env/lib/python3.9/site-packages/tsplib95/utils.pyparse_degrees   s    r   c                 C   s   t | d S )zrRound a value to an integer.

    :param float x: original value
    :return: rounded integer
    :rtype: int
    g      ?r   )xr	   r	   r
   nint   s    r   c                 C   s   dd t || D S )Nc                 s   s   | ]\}}|| V  qd S Nr	   ).0esr	   r	   r
   	<genexpr>       zdeltas.<locals>.<genexpr>)zip)startendr	   r	   r
   deltas   s    r   c                   @   s    e Zd Zdd Zedd ZdS )	RadianGeoc                 C   s(   |\}}| j || _| j || _d S r   )	__class__parse_componentZlatZlng)selfr   r   yr	   r	   r
   __init__    s    zRadianGeo.__init__c                 C   s   t t| S r   )mathradiansr   )	componentr	   r	   r
   r   %   s    zRadianGeo.parse_componentN)__name__
__module____qualname__r   staticmethodr   r	   r	   r	   r
   r      s   r   c                 C   s(   | |vr | | d  d }||| < ||  S )N      r	   )nmemor   r	   r	   r
   _int_sum*   s    r)   c                 C   s   t | }|r|t |8 }|S r   )r)   )r'   mr   r	   r	   r
   integer_sum1   s    r+   c                 C   s*   t | }t |}||dg7 }t||S )Nr   )listpopr   )ZindexesZstartsZendsr	   r	   r
   pairwise8   s    r.   c                 C   s   | sdS |d ur@t | | }| d | } |dkr@| | d | ^ } }| sVt|S t | dkrt| d  d| S d|  d| S )N r   z morer%   z and z, z, and )lenappendstrjoin)itemslimit	truncatedZ	last_itemr	   r	   r
   friendly_joinD   s    
r7   )N)N)	r   r   r   r   r   r)   r+   r.   r7   r	   r	   r	   r
   <module>   s   

