
    Dvg                     ^    d dl mZ d dlmZ d dlmZ d dlmZ d dl	m
Z
  G d de
          ZdS )	    )c_uint)gdal)
prototypes)GEOSException)GEOSGeometryc                   t    e Zd ZdZdZdZd fd	Z fdZ fdZ fdZ	e
d	             Ze
d
             Zd Zd Zd Zd Zd ZeZed             Zej        d             Zed             Zej        d             Zed             Zej        d             Zed             Zej        d             ZeZ xZS )Point      TNc                    |g }nt          |t          t          f          r|}nnt          |t          t          f          rCt          |t          t          f          r't          |t          t          f          r|||g}n||g}nt          d          |                     t          |          |          }t                      	                    ||           dS )a  
        The Point object may be initialized with either a tuple, or individual
        parameters.

        For example:
        >>> p = Point((5, 23))  # 2D point, passed in as a tuple
        >>> p = Point(5, 23, 8)  # 3D point, passed in with individual parameters
        Nz2Invalid parameters given for Point initialization.)srid)

isinstancetuplelistfloatint	TypeError_create_pointlensuper__init__)selfxyzr   coordspoint	__class__s          Z/var/www/pixelcanvas.ch/venv/lib/python3.11/site-packages/django/contrib/gis/geos/point.pyr   zPoint.__init__   s     9FFE4=)) 
	RFFE3<(( 	RZE3<-H-H 	R!eS\**  QQPQQQ""3v;;77 	T*****    c                 V    | j         rd nt                                                      S N)emptyr   _to_pickle_wkbr   r   s    r   r$   zPoint._to_pickle_wkb+   s$    z?ttuww'='='?'??r    c                 r    ||                                  n t                                          |          S r"   )_create_emptyr   _from_pickle_wkb)r   wkbr   s     r   r(   zPoint._from_pickle_wkb.   s1    '*{t!!###8P8PQT8U8UUr    c                     | j         r#t          j        j                                        nt                                                      S r"   )r#   r   
geometriesr	   r'   r   _ogr_ptrr%   s    r   r,   zPoint._ogr_ptr1   s8    59ZWDO!//111UWWEUEUEWEW	
r    c                 .    |                      d d           S r"   )r   )clss    r   r'   zPoint._create_empty6   s      t,,,r    c                    |st          j        d          S |dk     s|dk    rt          d|z            t          j        t	          d          t	          |                    }t          |          }t          j        |dt          |                     t          j        |dt          |                     |dk    r#t          j	        |dt          |                     t          j        |          S )zO
        Create a coordinate sequence, set X, Y, [Z], and create point
        Nr
   r   zInvalid point dimension: %s   r   )
capicreate_pointr   	create_csr   itercs_setxnextcs_setycs_setz)r.   ndimr   csis        r   r   zPoint._create_point:   s    
  	+$T***!88taxx9D@AAA^F1IIvd||44LLRDGG$$$RDGG$$$199LQQ((( $$$r    c                     |                      ||          }|rF| j        }t          j        | j                   || _        ||| _        |                                  d S t          d          )Nz3Geometry resulting from slice deletion was invalid.)r   r   r1   destroy_geomptr_ptr
_post_initr   )r   lengthitemsr>   r   s        r   	_set_listzPoint._set_listN   su      // 		W9Ddh'''DI 	OO   UVVVr    c                 >    | j                             |d|           d S )Nr   _cssetOrdinate)r   indexvalues      r   _set_singlezPoint._set_single[   s"    UAu-----r    c              #   \   K   t          t          |                     D ]}| |         V  dS )z'Iterate over coordinates of this Point.N)ranger   )r   r;   s     r   __iter__zPoint.__iter__^   s<      s4yy!! 	 	Aq'MMMM	 	r    c                 *    | j         rdS | j        rdS dS )zBReturn the number of dimensions for this Point (either 0, 2 or 3).r   r   r
   )r#   haszr   s    r   __len__zPoint.__len__c   s%    : 	19 	11r    c                 T    |dk    r| j         S |dk    r| j        S |dk    r| j        S d S )Nr   r0   r
   )r   r   r   )r   rH   s     r   _get_single_externalzPoint._get_single_externall   s9    A::6MaZZ6MaZZ6M Zr    c                 8    | j                             dd          S )z$Return the X component of the Point.r   rF   getOrdinaterP   s    r   r   zPoint.xv        x##Aq)))r    c                 >    | j                             dd|           dS )z!Set the X component of the Point.r   NrE   r   rI   s     r   r   zPoint.x{   $     	Q5)))))r    c                 8    | j                             dd          S )z$Return the Y component of the Point.r0   r   rU   rP   s    r   r   zPoint.y   rW   r    c                 >    | j                             dd|           dS )z!Set the Y component of the Point.r0   r   NrE   rY   s     r   r   zPoint.y   rZ   r    c                 J    | j         r| j                            dd          ndS )z$Return the Z component of the Point.r
   r   N)rO   rF   rV   rP   s    r   r   zPoint.z   s(     .2Y@tx##Aq)))D@r    c                 j    | j         st          d          | j                            dd|           dS )z!Set the Z component of the Point.zCannot set Z on 2D Point.r
   r   N)rO   r   rF   rG   rY   s     r   r   zPoint.z   s=     y 	= ;<<<Q5)))))r    c                     | j         j        S )zReturn a tuple of the point.)rF   r   rP   s    r   r   zPoint.tuple   s     x~r    c                     || j         d<   dS )z6Set the coordinates of the point with the given tuple.r   N)rF   )r   tups     r   r   zPoint.tuple   s     r    )NNNN)__name__
__module____qualname__
_minlength
_maxlengthhas_csr   r$   r(   r,   classmethodr'   r   rC   rJ   rM   rQ   rS   _get_single_internalpropertyr   setterr   r   r   r   __classcell__)r   s   @r   r	   r	   	   s	       JJF+ + + + + +:@ @ @ @ @V V V V V
 
 
 
 

 - - [- % % [%&W W W. . .  
     0* * X* X* * X* * * X* X* * X* A A XA X* * X*   X \  \
 FFFFFr    r	   N)ctypesr   django.contrib.gisr   django.contrib.gis.geosr   r1   django.contrib.gis.geos.errorr    django.contrib.gis.geos.geometryr   r	    r    r   <module>rs      s          # # # # # # 6 6 6 6 6 6 7 7 7 7 7 7 9 9 9 9 9 9Y Y Y Y YL Y Y Y Y Yr    