3
®?d]û  ã            !   @   sˆ  d 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
mZ ddlmZmZ dd	lmZmZ dd
lmZmZ G dd„ deeeƒZdd„ ZG dd„ deƒZG dd„ deƒZedfedfedfedfedfedfedfedfedfedfedfedfedfed fed!fed"fed#fed$fed%fed&fed'fed(fed)fed*fed+fed,fed-fed.fed/fed0fed1fejd2fd3œ Zed4fed5fed6fed7fed8fed9fed:fed;fed<fed=fed>fd?œZi Zed@fe
dAfe
dBfedCfedDfedEfedFfdGœZ dHedHfiZ!dIdJ„ Z"ee#e"eƒƒƒZ$ej%dMk�r2e$j&e"eƒƒ ej%dNk�rLe$j&e"eƒƒ ej%dOk�rfe$j&e"e ƒƒ ej%dPk�r€e$j&e"e!ƒƒ e$Z'dS )Qaß  Implementation of the intermediary layer between Shapely and GEOS

This is layer number 2 from the list below.

1) geometric objects: the Python OO API.
2) implementation map: an abstraction that permits different backends.
3) backend: callable objects that take Shapely geometric objects as arguments
   and, with GEOS as a backend, translate them to C data structures.
4) GEOS library: algorithms implemented in C++.

Shapely 1.2 includes a GEOS backend and it is the default.
é   )Úwrapsé    )Úcga)ÚBoundsOp)Úlgeos)Ú	ProjectOpÚInterpolateOp)ÚBinaryPredicateÚUnaryPredicate)ÚBinaryRealPropertyÚBinaryTopologicalOp)ÚUnaryRealPropertyÚUnaryTopologicalOpc               @   s   e Zd ZdZdS )ÚImplementationErrorzZTo be raised when the registered implementation does not
    support the requested method.N)Ú__name__Ú
__module__Ú__qualname__Ú__doc__© r   r   ú//tmp/pip-build-op5p2y5_/shapely/shapely/impl.pyr      s   r   c                s   t ˆ ƒ‡ fdd„ƒ}|S )zOA delegated method raises AttributeError in the absence of backend
    support.c                 s<   y
ˆ | |ŽS  t k
r6   tdˆ j| d jf ƒ‚Y nX d S )Nz:Method '%s' not provided by registered implementation '%s'r   )ÚKeyErrorr   r   Úimpl)ÚargsÚkwargs)Úfuncr   r   Úwrapper"   s    
zdelegated.<locals>.wrapper)r   )r   r   r   )r   r   Ú	delegated   s    r   c               @   s0   e Zd ZdZdd„ Zdd„ Zdd„ Zdd	„ Zd
S )ÚBaseImplz+Base class for registrable implementations.c             C   s   t |ƒ| _d S )N)ÚdictÚmap)ÚselfÚvaluesr   r   r   Ú__init__2   s    zBaseImpl.__init__c             C   s   | j j|ƒ d S )N)r   Úupdate)r    r!   r   r   r   r#   5   s    zBaseImpl.updatec             C   s6   y
| j | S  tk
r0   td|| j f ƒ‚Y nX d S )Nz:Method '%s' not provided by registered implementation '%s')r   r   r   )r    Úkeyr   r   r   Ú__getitem__8   s    
zBaseImpl.__getitem__c             C   s
   || j kS )N)r   )r    r$   r   r   r   Ú__contains__@   s    zBaseImpl.__contains__N)r   r   r   r   r"   r#   r%   r&   r   r   r   r   r   /   s
   r   c               @   s   e Zd ZdZdd„ ZdS )ÚGEOSImplzGEOS implementationc             C   s   dt jf S )Nz(<GEOSImpl object: GEOS C API version %s>)r   Zgeos_capi_version)r    r   r   r   Ú__repr__G   s    zGEOSImpl.__repr__N)r   r   r   r   r(   r   r   r   r   r'   D   s   r'   ÚareaÚdistanceÚlengthÚboundaryNÚcentroidÚrepresentative_pointÚenvelopeÚconvex_hullÚbufferÚ
differenceÚintersectionÚsymmetric_differenceÚunionÚhas_zÚis_emptyÚis_ringÚ	is_simpleÚis_validÚrelateÚcontainsÚcrossesÚdisjointÚequalsÚ
intersectsÚoverlapsÚtouchesÚwithinÚcoversÚequals_exactÚrelate_patternÚis_ccw) r)   r*   r+   r,   Zboundsr-   r.   r/   r0   r1   r2   r3   r4   r5   r6   r7   r8   r9   r:   r;   r<   r=   r>   r?   r@   rA   rB   rC   rD   rE   rF   rG   ÚsimplifyÚtopology_preserve_simplifyÚprepared_disjointÚprepared_touchesÚprepared_crossesÚprepared_withinÚprepared_overlapsÚprepared_intersectsÚprepared_containsÚprepared_contains_properlyÚprepared_covers)rH   rI   rJ   rK   rL   rM   rN   rO   rP   rQ   rR   Úparallel_offsetÚproject_normalizedÚprojectÚinterpolate_normalizedÚinterpolateÚbuffer_with_styleÚhausdorff_distance)rS   rT   rU   rV   rW   rX   rY   Z	is_closedc             C   s   dd„ t | jƒ ƒD ƒS )Nc             S   s$   g | ]\}}||d  |d ƒf‘qS )r   r   r   )Ú.0ÚkÚvr   r   r   ú
<listcomp>—   s    zimpl_items.<locals>.<listcomp>)ÚlistÚitems)Zdefsr   r   r   Ú
impl_items–   s    r`   é   é   )ra   r   r   )ra   r   r   )ra   rb   r   )ra   ra   r   )(r   Zftoolsr   Zshapely.algorithmsr   Zshapely.coordsr   Zshapely.geosr   Zshapely.linrefr   r   Zshapely.predicatesr	   r
   Zshapely.topologyr   r   r   r   ÚAttributeErrorr   ÚNotImplementedErrorr   r   Úobjectr   r'   Zis_ccw_implZIMPL300ZIMPL310ZIMPL311ZIMPL320ZIMPL330r`   r   ÚimpZgeos_versionr#   ZDefaultImplementationr   r   r   r   Ú<module>   s˜   

	