
    +'&h
                     r   U 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Zddl	Zddlm
Z
 dZdZn# e$ rZd	ZeZY dZ[ndZ[ww xY wdd
lmZ ddlmZ ed             Z e            deeef         fd            Z e            ddedee         defd            ZddgZee         ed<   dee         fdZdS )zThis module provides utility functions for integrating with Shapely.

.. note::

    As GeoAlchemy 2 itself has no dependency on `Shapely`, applications using
    functions of this module have to ensure that `Shapely` is available.
    )contextmanager)List)Optional)UnionN)dumpsTF)
WKBElement)
WKTElementc               #   J   K   t           st          d          t          d V  d S )NznThis feature needs the optional Shapely dependency. Please install it with 'pip install geoalchemy2[shapely]'.)HAS_SHAPELYImportError_shapely_exc     L/var/www/html/reinick/venv/lib/python3.11/site-packages/geoalchemy2/shape.pycheck_shapelyr      s:       I
 
 	 
EEEEEr   elementc                     t          | t                    r]t          | j        t                    r	| j        dfnt	          | j                  df\  }}t
          j                            ||          S t          | t                    ri| j	        r>t
          j
                            | j                            dd          d                   S t
          j
                            | j                  S t          d          )a	  Function to convert a :class:`geoalchemy2.types.SpatialElement` to a Shapely geometry.

    Args:
        element: The element to convert into a ``Shapely`` object.

    Example::

        lake = Session.query(Lake).get(1)
        polygon = to_shape(lake.geom)
    TF)hex;   z4Only WKBElement and WKTElement objects are supported)
isinstancer   datastrbytesshapelywkbloadsr	   extendedwktsplit	TypeError)r   r   r   s      r   to_shaper"   '   s     ':&& P$.w|S$A$AcW\4  glH[H[]bGc 	c {  3 ///	GZ	(	( P 	3;$$W\%7%7Q%?%?%BCCC;$$W\222NOOOr   sridr   returnc                 f    t          t          t          | |r|nd                    ||          S )aG  Function to convert a Shapely geometry to a :class:`geoalchemy2.types.WKBElement`.

    Args:
        shape: The shape to convert.
        srid: An integer representing the spatial reference system. E.g. ``4326``.
            Default value is ``-1``, which means no/unknown reference system.
        extended: A boolean to switch between WKB and EWKB.
            Default value is False.

    Example::

        from shapely.geometry import Point
        wkb_element = from_shape(Point(5, 45), srid=4326)
        ewkb_element = from_shape(Point(5, 45), srid=4326, extended=True)
    N)r$   )r$   r   )r   
memoryviewr   )shaper$   r   s      r   
from_shaper)   A   sB    " 5X%?TT4@@@AA   r   r)   r"   __all__c                      t           S )N)r*   r   r   r   __dir__r,   _   s    Nr   )r#   F)__doc__
contextlibr   typingr   r   r   shapely.wkbr   shapely.wktr   r   r   r   excgeoalchemy2.elementsr   r	   r   r"   intboolr)   r*   r   __annotations__r,   r   r   r   <module>r7      s     & % % % % %                  	!!!!!!KLL   KLLLLLL , + + + + + + + + + + + 
 
 
 PeJ
23 P P P P2  C  :    0 c   c      s   0 A>A