a
    ßÁdb	  ã                   @   s2   d Z ddlmZ ddlZG dd„ dƒZdd„ ZdS )z0
Support for GEOS prepared geometry operations.
é    ©ÚPicklingErrorNc                   @   sh   e Zd ZdZdd„ Zdd„ Zdd„ Zdd	„ Zd
d„ Zdd„ Z	dd„ Z
dd„ Zdd„ Zdd„ Zdd„ ZdS )ÚPreparedGeometrya-  
    A geometry prepared for efficient comparison to a set of other geometries.

    Example:

      >>> from shapely.geometry import Point, Polygon
      >>> triangle = Polygon([(0.0, 0.0), (1.0, 1.0), (1.0, -1.0)])
      >>> p = prep(triangle)
      >>> p.intersects(Point(0.5, 0.5))
      True
    c                 C   s.   t |tƒr|j| _nt |¡ || _d| _d S )NT)Ú
isinstancer   ÚcontextÚshapelyÚprepareÚprepared)Úselfr   © r   úS/home/yuhw/wc/wire-cell-python/wcpy/lib/python3.9/site-packages/shapely/prepared.pyÚ__init__   s
    


zPreparedGeometry.__init__c                 C   s   | j  |¡S )z;Returns True if the geometry contains the other, else False)r   Úcontains©r
   Úotherr   r   r   r      s    zPreparedGeometry.containsc                 C   s2   ddl m} ||gƒ}|j| jdd�}tt|ƒƒS )zDReturns True if the geometry properly contains the other, else Falser   )ÚSTRtreeÚcontains_properly)Ú	predicate)r   r   Úqueryr   ÚboolÚlen)r
   r   r   ÚtreeÚidxr   r   r   r   "   s    
z"PreparedGeometry.contains_properlyc                 C   s   | j  |¡S )z9Returns True if the geometry covers the other, else False)r   Úcoversr   r   r   r   r   +   s    zPreparedGeometry.coversc                 C   s   | j  |¡S )z0Returns True if the geometries cross, else False)r   Úcrossesr   r   r   r   r   /   s    zPreparedGeometry.crossesc                 C   s   | j  |¡S )z3Returns True if geometries are disjoint, else False)r   Údisjointr   r   r   r   r   3   s    zPreparedGeometry.disjointc                 C   s   | j  |¡S )z0Returns True if geometries intersect, else False)r   Ú
intersectsr   r   r   r   r   7   s    zPreparedGeometry.intersectsc                 C   s   | j  |¡S )z.Returns True if geometries overlap, else False)r   Úoverlapsr   r   r   r   r   ;   s    zPreparedGeometry.overlapsc                 C   s   | j  |¡S )z,Returns True if geometries touch, else False)r   Útouchesr   r   r   r   r   ?   s    zPreparedGeometry.touchesc                 C   s   | j  |¡S )z8Returns True if geometry is within the other, else False)r   Úwithinr   r   r   r   r   C   s    zPreparedGeometry.withinc                 C   s   t dƒ‚d S )Nz&Prepared geometries cannot be pickled.r   )r
   r   r   r   Ú
__reduce__G   s    zPreparedGeometry.__reduce__N)Ú__name__Ú
__module__Ú__qualname__Ú__doc__r   r   r   r   r   r   r   r   r   r   r    r   r   r   r   r   	   s   	r   c                 C   s   t | ƒS )z0Creates and returns a prepared geometric object.)r   )Úobr   r   r   ÚprepK   s    r&   )r$   Úpickler   r   r   r&   r   r   r   r   Ú<module>   s   B