
    Dvg                         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dS )    )
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          s0t          rt          |t          j                  st          d          |                    d          }t          |          }|s8t                      	                    | 
                    d          |           dS || j        k     r$t          d| j        j        | j        |fz            t          |t          t          f           }|rM|j        }t          |          dk    rt          d	          |                     |d                    |d         }nd}|D ]|}	t          |	t          t          t"          f          st          d
          |%t          |	          }|                     |           Zt          |	          |k    rt          d          }t%          t'          j        ||          t+          |dk                        }
|dk    r|
j        n|
j        }t1          |          D ]N}|r||ddf         }n1t          ||         t"                    r||         j        }n||         } |||           Ot                      	                    | 
                    |
j                  |           dS )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                 _/var/www/pixelcanvas.ch/venv/lib/python3.11/site-packages/django/contrib/gis/geos/linestring.pyr   zLineString.__init__   s    t99>>!WFFF vt}--	M	M 65=11	M
 KLLL zz&!!f++ 	GGT__T22>>>FT_$$9N+O   &fudm<<< 	;LE5zzQ 6777NN58$$$8DD D 
; 
;!%%u)=>> #N   <u::DNN4((((ZZ4''#$9::: (
 $.$774	??KKK+/199r''":Jw 	* 	*A )%ad|F1Iu-- )%ay%ayLL)))) 	00t<<<<<    c              #   \   K   t          t          |                     D ]}| |         V  dS )z%Allow iteration over this LineString.N)r)   r   )r+   r5   s     r7   __iter__zLineString.__iter__c   s<      s4yy!! 	 	Aq'MMMM	 	r8   c                 *    t          | j                  S )z/Return the number of points in this LineString.)r   _csr+   s    r7   __len__zLineString.__len__h   s    48}}r8   c                     | j         |         S Nr<   )r+   indexs     r7   _get_single_externalzLineString._get_single_externall   s    xr8   c                    | j         j        }| j         j        }| j        }t	          t          j        ||          |          }t          |          D ]
\  }}|||<   |                     |j	                  }	|	r?t          j
        | j	                   |	| _	        ||| _        |                                  d S 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    x}x}y $.66$???e$$ 	 	DAqBqEEoobf%% 	Wdh'''DH 	OO   UVVVr8   c                     || j         |<   d S r@   rA   )r+   rB   values      r7   _set_singlezLineString._set_single   s    r8   c                 ,    |dvrt          d          d S )N)r   r   r   )r   )r+   dims     r7   r#   zLineString._checkdim   s$    f12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     x~r8   c                     fdt          t          |                     D             }t          rt          j        |          S |S )z{
        Return a sequence (list) corresponding with the given function.
        Return a numpy array if possible.
        c                 &    g | ]} |          S  rV   ).0r5   funcs     r7   
<listcomp>z'LineString._listarr.<locals>.<listcomp>   s!    1111ttAww111r8   )r)   r   r	   array)r+   rX   lsts    ` r7   _listarrzLineString._listarr   sI    
 2111c$ii 0 0111 	;s###Jr8   c                 @    |                      | j        j                  S )z(Return a numpy array for the LineString.)r\   r<   __getitem__r=   s    r7   rZ   zLineString.array   s     }}TX1222r8   c                 @    |                      | j        j                  S )z/Return a list or numpy array of the X variable.)r\   r<   getXr=   s    r7   xzLineString.x        }}TX]+++r8   c                 @    |                      | j        j                  S )z/Return a list or numpy array of the Y variable.)r\   r<   getYr=   s    r7   yzLineString.y   rb   r8   c                 R    | j         sdS |                     | j        j                  S )z/Return a list or numpy array of the Z variable.N)rF   r\   r<   getZr=   s    r7   r   zLineString.z   s)     y 	04==///r8   )r!   
__module____qualname__r$   create_linestringr   r   has_csr   r:   r>   rC   _get_single_internalrM   rP   r#   propertyr   r.   r\   rZ   ra   re   r   __classcell__)r    s   @r7   r   r   	   sR       'JJFS= S= S= S= S=j  
     0W W W*     3 3 3
   X F	 	 	 3 3 X3 , , X, , , X, 0 0 X0 0 0 0 0r8   r   c                   6    e Zd ZdZej        Zed             ZdS )
LinearRing   c                 F    | j         rt          d          | j        j        S )Nz8Orientation of an empty LinearRing cannot be determined.)emptyr   r<   is_counterclockwiser=   s    r7   rt   zLinearRing.is_counterclockwise   s'    : 	YWXXXx++r8   N)	r!   rh   ri   r   r$   create_linearringr   rm   rt   rV   r8   r7   rp   rp      s:        J'J, , X, , ,r8   rp   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   rp   rV   r8   r7   <module>r|      s    6 6 6 6 6 6 9 9 9 9 9 9 7 7 7 7 7 7 N N N N N N N N / / / / / / . . . . . .l0 l0 l0 l0 l0$l l0 l0 l0`, , , , , , , , , ,r8   