3
®?d]Ñ  ã               @   sˆ   d Z ddlmZmZ ddlmZmZ G dd„ deƒZG dd„ deƒZ	G dd	„ d	e	ƒZ
G d
d„ de	ƒZG dd„ de	ƒZG dd„ de	ƒZdS )zð
Intermediaries supporting GEOS topological operations

These methods all take Shapely geometries and other Python objects and delegate
to GEOS functions via ctypes.

These methods return ctypes objects that should be recast by the caller.
é    )ÚbyrefÚc_double)ÚTopologicalErrorÚlgeosc               @   s   e Zd Zddd„ZdS )Ú
ValidatingFc             C   s6   |d ks|j d krtdƒ‚|r2t|dƒ r2tdƒ‚d S )Nz$Null geometry supports no operationsÚtypez)Prepared geometries cannot be operated on)Ú_geomÚ
ValueErrorÚhasattr)ÚselfÚobÚstop_prepared© r   ú3/tmp/pip-build-op5p2y5_/shapely/shapely/topology.pyÚ	_validate   s    zValidating._validateN)F)Ú__name__Ú
__module__Ú__qualname__r   r   r   r   r   r      s   r   c               @   s   e Zd Zdd„ Zdd„ ZdS )Ú
Delegatingc             C   s   t j| | _d S )N)r   ÚmethodsÚfn)r   Únamer   r   r   Ú__init__   s    zDelegating.__init__c             G   s4   x*|D ]"}|j std| jjt|ƒf ƒ‚qW |‚dS )zZRaise TopologicalError if geoms are invalid.

        Else, raise original error.
        zXThe operation '%s' could not be performed. Likely cause is invalidity of the geometry %sN)Zis_validr   r   r   Úrepr)r   ÚerrZgeomsZgeomr   r   r   Ú_check_topology   s    
zDelegating._check_topologyN)r   r   r   r   r   r   r   r   r   r      s   r   c               @   s   e Zd Zdd„ ZdS )ÚBinaryRealPropertyc             C   s:   | j |ƒ | j |dd� tƒ }| j|j|jt|ƒƒ}|jS )NT)r   )r   r   r   r   r   Úvalue)r   ÚthisÚotherÚdÚretvalr   r   r   Ú__call__,   s
    
zBinaryRealProperty.__call__N)r   r   r   r"   r   r   r   r   r   *   s   r   c               @   s   e Zd Zdd„ ZdS )ÚUnaryRealPropertyc             C   s(   | j |ƒ tƒ }| j|jt|ƒƒ}|jS )N)r   r   r   r   r   r   )r   r   r    r!   r   r   r   r"   6   s    
zUnaryRealProperty.__call__N)r   r   r   r"   r   r   r   r   r#   4   s   r#   c               @   s   e Zd Zdd„ ZdS )ÚBinaryTopologicalOpc             G   sP   | j |ƒ | j |dd� | j|j|jf|žŽ }|d krLtdƒ}| j|||ƒ |S )NT)r   z6This operation could not be performed. Reason: unknown)r   r   r   r   r   )r   r   r   ÚargsÚproductr   r   r   r   r"   ?   s    
zBinaryTopologicalOp.__call__N)r   r   r   r"   r   r   r   r   r$   =   s   r$   c               @   s   e Zd Zdd„ ZdS )ÚUnaryTopologicalOpc             G   s   | j |ƒ | j|jf|žŽ S )N)r   r   r   )r   r   r%   r   r   r   r"   L   s    
zUnaryTopologicalOp.__call__N)r   r   r   r"   r   r   r   r   r'   J   s   r'   N)Ú__doc__Úctypesr   r   Zshapely.geosr   r   Úobjectr   r   r   r#   r$   r'   r   r   r   r   Ú<module>   s   	
	