
 XQ                 @   s   d  d l  Z  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 d  d l m Z d  d l m Z Gd	 d
   d
 e	  Z d S)    N)c_uint)
prototypes)GEOSException)GEOSGeometry)six)RemovedInDjango20Warning)rangec                   s  e  Z d  Z d Z d Z d Z d d d d   f d d  Z d d   Z d	 d
   Z d d   Z	 d d   Z
 d d   Z d d   Z e Z e d d    Z e j d d    Z e d d    Z e j d d    Z e d d    Z e j d d    Z d d   Z d d   Z d  d!   Z d" d#   Z d$ d%   Z d& d'   Z e d( d)    Z e j d* d)    Z d+ d,   Z d- d.   Z e Z   S)/Point      TNc                s   | d k r g  } n t  | t t f  r3 | } nx t  | t j t f  r t  | t j t f  r t  | t j t f  r | | | g } q | | g } n t d   |  j t |  |  } t	 t
 |   j | d | 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listr   integer_typesfloat	TypeError_create_pointlensuperr	   __init__)selfxyzr   coordsZpoint)	__class__ K/home/ubuntu/projects/ifolica/build/django/django/contrib/gis/geos/point.pyr      s    			2zPoint.__init__c             C   s   | s t  j d  S| d k  s+ | d k rD t d t |    n  t  j t d  t |   } t |  } t  j | d t |   t  j	 | d t |   | d k r t  j
 | d t |   n  t  j |  S)zO
        Create a coordinate sequence, set X, Y, [Z], and create point
        Nr
   r   zInvalid point dimension: %s   r   )capiZcreate_pointr   strZ	create_csr   iterZcs_setxnextZcs_setyZcs_setz)r   ndimr   csir   r   r   r   .   s    zPoint._create_pointc             C   sN   |  j  | |  } | r> t j |  j  | |  _ |  j   n t d   d  S)Nz3Geometry resulting from slice deletion was invalid.)r   r    Zdestroy_geomptrZ_ptrZ_set_csr   )r   lengthitemsr'   r   r   r   	_set_listA   s    	zPoint._set_listc             C   s   |  j  j | d |  d  S)Nr   )_cssetOrdinate)r   indexvaluer   r   r   _set_singleK   s    zPoint._set_singlec             c   s*   x# t  t |    D] } |  | Vq Wd S)z0Allows iteration over coordinates of this Point.N)r   r   )r   r&   r   r   r   __iter__N   s    zPoint.__iter__c             C   s"   |  j  r d S|  j r d Sd Sd S)zCReturns the number of dimensions for this Point (either 0, 2 or 3).r   r   r
   N)emptyhasz)r   r   r   r   __len__S   s
    		zPoint.__len__c             C   s=   | d k r |  j  S| d k r& |  j S| d k r9 |  j Sd  S)Nr   r   r
   )r   r   r   )r   r-   r   r   r   _get_single_external\   s    zPoint._get_single_externalc             C   s   |  j  j d d  S)z%Returns the X component of the Point.r   )r+   getOrdinate)r   r   r   r   r   f   s    zPoint.xc             C   s   |  j  j d d |  d S)z"Sets the X component of the Point.r   N)r+   r,   )r   r.   r   r   r   r   k   s    c             C   s   |  j  j d d  S)z%Returns the Y component of the Point.r   r   )r+   r5   )r   r   r   r   r   p   s    zPoint.yc             C   s   |  j  j d d |  d S)z"Sets the Y component of the Point.r   r   N)r+   r,   )r   r.   r   r   r   r   u   s    c             C   s    |  j  r |  j j d d  Sd S)z%Returns the Z component of the Point.r
   r   N)r2   r+   r5   )r   r   r   r   r   z   s    zPoint.zc             C   s2   |  j  s t d   n  |  j j d d |  d S)z"Sets the Z component of the Point.zCannot set Z on 2D Point.r
   r   N)r2   r   r+   r,   )r   r.   r   r   r   r      s    	c             C   s   t  j d t d  |  j S)Nz6`get_x()` is deprecated, use the `x` property instead.r
   )warningswarnr   r   )r   r   r   r   get_x   s    
zPoint.get_xc             C   s    t  j d t d  | |  _ d  S)Nz6`set_x()` is deprecated, use the `x` property instead.r
   )r6   r7   r   r   )r   r.   r   r   r   set_x   s    
zPoint.set_xc             C   s   t  j d t d  |  j S)Nz6`get_y()` is deprecated, use the `y` property instead.r
   )r6   r7   r   r   )r   r   r   r   get_y   s    
zPoint.get_yc             C   s    t  j d t d  | |  _ d  S)Nz6`set_y()` is deprecated, use the `y` property instead.r
   )r6   r7   r   r   )r   r.   r   r   r   set_y   s    
zPoint.set_yc             C   s   t  j d t d  |  j S)Nz6`get_z()` is deprecated, use the `z` property instead.r
   )r6   r7   r   r   )r   r   r   r   get_z   s    
zPoint.get_zc             C   s    t  j d t d  | |  _ d  S)Nz6`set_z()` is deprecated, use the `z` property instead.r
   )r6   r7   r   r   )r   r.   r   r   r   set_z   s    
zPoint.set_zc             C   s
   |  j  j S)zReturns a tuple of the point.)r+   r   )r   r   r   r   r      s    zPoint.tuplec             C   s   | |  j  d <d S)z7Sets the coordinates of the point with the given tuple.r   N)r+   )r   tupr   r   r   r      s    c             C   s   t  j d t d  |  j S)Nz?`get_coords()` is deprecated, use the `tuple` property instead.r
   )r6   r7   r   r   )r   r   r   r   
get_coords   s    
zPoint.get_coordsc             C   s    t  j d t d  | |  _ d  S)Nz?`set_coords()` is deprecated, use the `tuple` property instead.r
   )r6   r7   r   r   )r   r>   r   r   r   
set_coords   s    
zPoint.set_coords)__name__
__module____qualname__Z
_minlengthZ
_maxlengthZhas_csr   r   r*   r/   r0   r3   r4   Z_get_single_internalpropertyr   setterr   r   r8   r9   r:   r;   r<   r=   r   r?   r@   r   r   r   )r   r   r	      s8   
	r	   )r6   ctypesr   Zdjango.contrib.gis.geosr   r    Zdjango.contrib.gis.geos.errorr   Z django.contrib.gis.geos.geometryr   Zdjango.utilsr   Zdjango.utils.deprecationr   Zdjango.utils.six.movesr   r	   r   r   r   r   <module>   s   