
    g                     ~    d dl mZ d dlmZ d dlmZ d dlmZm	Z	 d dl
mZ d dlmZ  G d de	e      Z G d	 d
e      Zy)    )
prototypes)GEOSCoordSeq)GEOSException)GEOSGeometryLinearGeometryMixin)Point)numpyc                        e Zd Zej                  ZdZdZ fdZd Z	d Z
d ZeZd Zd Zd	 Zed
        ZeZd Zed        Zed        Zed        Zed        Z xZS )
LineString   Tc                    t        |      dk(  r|d   }n|}t        |t        t        f      s+t        rt        |t        j
                        st        d      |j                  d      }t        |      }|s!t        | %  | j                  d      |       y|| j                  k  r/t        d| j                  j                  | j                  |fz        t        |t        t        f       }|r?|j                  }t        |      dk7  rt        d	      | j!                  |d          |d   }ngd}|D ]`  }	t        |	t        t        t"        f      st        d
      |t        |	      }| j!                  |       Ht        |	      |k7  sWt        d       t%        t'        j(                  ||      t+        |dk(              }
|dk(  r|
j,                  n|
j.                  }t1        |      D ]?  }|r
||ddf   }n(t        ||   t"              r||   j                  }n||   } |||       A t        | %  | j                  |
j2                        |       y)a  
        Initialize on the given sequence -- may take lists, tuples, NumPy arrays
        of X,Y pairs, or Point objects.  If Point objects are used, ownership is
        _not_ transferred to the LineString object.

        Examples:
         ls = LineString((1, 1), (2, 2))
         ls = LineString([(1, 1), (2, 2)])
         ls = LineString(array([(1, 1), (2, 2)]))
         ls = LineString(Point(1, 1), Point(2, 2))
           r   z-Invalid initialization input for LineStrings.sridN)r   z'%s requires at least %d points, got %s.r   zToo many dimensions.z4Each coordinate should be a sequence (list or tuple)Dimension mismatch.   z)len
isinstancetuplelistr	   ndarray	TypeErrorgetsuper__init__
_init_func
_minlength
ValueError	__class____name__shape	_checkdimr   r   capi	create_csbool_set_point_3d_set_point_2drangeptr)selfargskwargscoordsr   ncoordsnumpy_coordsr"   ndimcoordcspoint_setteripoint_coordsr    s                 z/var/www/python.vincentserveurtest.ovh/public_html/venv/lib/python3.12/site-packages/django/contrib/gis/geos/linestring.pyr   zLineString.__init__   s     t9>!WFF vt}-65==1KLL zz&!f+GT__T2>T__$9NN++OO  &fudm<<LLE5zQ 677NN58$8D D!%%u)=>#N  <u:DNN4(Z4'#$9::   $..$74	?K+/19r''":J:JwA%ad|F1Iu-%ay%ayL)   	0t<    c              #   L   K   t        t        |             D ]	  }| |     yw)z%Allow iteration over this LineString.N)r)   r   )r+   r5   s     r7   __iter__zLineString.__iter__c   s"     s4y!Aq'M "s   "$c                 ,    t        | j                        S )z/Return the number of points in this LineString.)r   _csr+   s    r7   __len__zLineString.__len__h   s    488}r8   c                      | j                   |   S Nr<   )r+   indexs     r7   _get_single_externalzLineString._get_single_externall   s    xxr8   c                    | j                   j                  }| j                   j                  }| j                  }t	        t        j                  ||      |      }t        |      D ]
  \  }}|||<    | j                  |j                        }	|	r@t        j                  | j                         |	| _	        ||| _        | j                          y t        d      )Nr   z3Geometry resulting from slice deletion was invalid.)r<   dimshaszr   r   r$   r%   	enumerater   r*   destroy_geom
_post_initr   )
r+   lengthitemsr1   rF   r   r3   r5   cr*   s
             r7   	_set_listzLineString._set_listq   s    xx}}xx}}yy $..6$?e$DAqBqE % oobff%dhh'DH 	OO   UVVr8   c                 "    || j                   |<   y r@   rA   )r+   rB   values      r7   _set_singlezLineString._set_single   s    r8   c                 "    |dvrt        d      y )N)r   r   r   )r   )r+   dims     r7   r#   zLineString._checkdim   s    f122 r8   c                 .    | j                   j                  S )zDReturn a tuple version of the geometry from the coordinate sequence.)r<   r   r=   s    r7   r   zLineString.tuple   s     xx~~r8   c                     t        t        |             D cg c]
  } ||       }}t        rt        j                  |      S |S c c}w )z{
        Return a sequence (list) corresponding with the given function.
        Return a numpy array if possible.
        )r)   r   r	   array)r+   funcr5   lsts       r7   _listarrzLineString._listarr   sC    
 !&c$i 01 01tAw 01;;s##J	 2s   Ac                 L    | j                  | j                  j                        S )z(Return a numpy array for the LineString.)rX   r<   __getitem__r=   s    r7   rU   zLineString.array   s     }}TXX1122r8   c                 L    | j                  | j                  j                        S )z/Return a list or numpy array of the X variable.)rX   r<   getXr=   s    r7   xzLineString.x        }}TXX]]++r8   c                 L    | j                  | j                  j                        S )z/Return a list or numpy array of the Y variable.)rX   r<   getYr=   s    r7   yzLineString.y   r^   r8   c                 f    | j                   sy| j                  | j                  j                        S )z/Return a list or numpy array of the Z variable.N)rF   rX   r<   getZr=   s    r7   r   zLineString.z   s%     yy==//r8   )r!   
__module____qualname__r$   create_linestringr   r   has_csr   r:   r>   rC   _get_single_internalrM   rP   r#   propertyr   r.   rX   rU   r]   ra   r   __classcell__)r    s   @r7   r   r   	   s    ''JJFS=j
 0W* 3
   F	 3 3 , , , , 0 0r8   r   c                   8    e Zd ZdZej
                  Zed        Zy)
LinearRing   c                 \    | j                   rt        d      | j                  j                  S )Nz8Orientation of an empty LinearRing cannot be determined.)emptyr   r<   is_counterclockwiser=   s    r7   rp   zLinearRing.is_counterclockwise   s%    ::WXXxx+++r8   N)	r!   rd   re   r   r$   create_linearringr   ri   rp    r8   r7   rl   rl      s$    J''J, ,r8   rl   N)django.contrib.gis.geosr   r$    django.contrib.gis.geos.coordseqr   django.contrib.gis.geos.errorr    django.contrib.gis.geos.geometryr   r   django.contrib.gis.geos.pointr   django.contrib.gis.shortcutsr	   r   rl   rr   r8   r7   <module>ry      s5    6 9 7 N / .l0$l l0`, ,r8   