a
    J5db	                     @   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   L/var/www/html/django/DPS/env/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