a
    1$e                     @   s  d Z g dZddlZddlZddlmZmZ ddlmZ ddlm	Z	m
Z
 ddlmZ ddlmZmZ dd	lmZ dd
lmZmZmZmZ ddlmZ ddlmZ ddlmZmZ ddlmZ ddl m!Z!m"Z"m#Z#m$Z$ ddl%m&Z& ddl'm(Z(m)Z)m*Z* ddl+m,Z, ddl-m.Z. ddl/m0Z0m1Z1 G dd deZ2eddG dd de2Z3eddG dd de2Z4eddG dd de2Z5G dd  d e#Z6G d!d" d"ej7Z8G d#d$ d$Z9d,eeeeee ee e:e:e:d&	d'd(Z;d-eee	e	 e:e:e:e:e:d)d*d+Z<dS ).zH
The transformer module is for performing cartographic transformations.
)	transform
itransformTransformerTransformerGroupAreaOfInterest    N)ABCabstractmethod)array)IterableIterator)	dataclass)chainislice)Path)AnyOptionalUnionoverload)CRS)
cstrencode)	AreaOfUseCoordinateOperation)_clear_proj_error)r   _Transformer_TransformerGroupproj_version_str)get_user_data_dir)ProjVersionTransformDirection
WktVersion)	ProjError)_download_resource_file)_convertback_copytobufferc                   @   s"   e Zd ZdZeedddZdS )TransformerMakerz
    .. versionadded:: 3.1.0

    Base class for generating new instances
    of the Cython _Transformer class for
    thread safety in the Transformer class.
    returnc                 C   s   t dS )>
        Returns
        -------
        _Transformer
        N)NotImplementedErrorself r+   N/var/www/html/django/DPS/env/lib/python3.9/site-packages/pyproj/transformer.py__call__/   s    zTransformerMaker.__call__N)__name__
__module____qualname____doc__r   r   r-   r+   r+   r+   r,   r$   &   s   r$   T)frozenc                   @   s(   e Zd ZU dZeed< edddZdS )TransformerUnsafezk
    .. versionadded:: 3.1.0

    Returns the original Cython _Transformer
    and is not thread-safe.
    transformerr%   c                 C   s   | j S r'   )r4   r)   r+   r+   r,   r-   D   s    zTransformerUnsafe.__call__N)r.   r/   r0   r1   r   __annotations__r-   r+   r+   r+   r,   r3   9   s   
r3   c                   @   s   e Zd ZU dZeed< eed< eed< ee ed< ee	 ed< ee	 ed< ee ed< d	Z
eed
< dZee ed< edddZdS )TransformerFromCRSz
    .. versionadded:: 3.1.0

    .. versionadded:: 3.4.0 force_over

    Generates a Cython _Transformer class from input CRS data.
    crs_fromcrs_to	always_xyarea_of_interest	authorityaccuracyallow_ballparkF
force_overN	only_bestr%   c                 C   s.   t j| j| j| j| j| j| j| j| j	| j
d	S )r'   r:   r;   r<   r=   r>   r?   r@   )r   from_crsr8   r9   r:   r;   r<   r=   r>   r?   r@   r)   r+   r+   r,   r-   c   s    zTransformerFromCRS.__call__)r.   r/   r0   r1   bytesr6   boolr   r   strr?   r@   r   r-   r+   r+   r+   r,   r7   M   s   
r7   c                   @   s(   e Zd ZU dZeed< edddZdS )TransformerFromPipelinezf
    .. versionadded:: 3.1.0

    Generates a Cython _Transformer class from input pipeline data.
    proj_pipeliner%   c                 C   s   t | jS r5   )r   from_pipelinerG   r)   r+   r+   r,   r-      s    z TransformerFromPipeline.__call__N)r.   r/   r0   r1   rC   r6   r   r-   r+   r+   r+   r,   rF   v   s   
rF   c                       s   e Zd ZdZdeeeee ee ee	 eedd	 fddZ
eed d	d
dZeee d	ddZeed	ddZdeeeef  eeddddZed	ddZ  ZS )r   ab  
    The TransformerGroup is a set of possible transformers from one CRS to another.

    .. versionadded:: 2.3.0

    .. warning:: CoordinateOperation and Transformer objects
                 returned are not thread-safe.

    From PROJ docs::

        The operations are sorted with the most relevant ones first: by
        descending area (intersection of the transformation area with the
        area of interest, or intersection of the transformation with the
        area of use of the CRS), and by increasing accuracy. Operations
        with unknown accuracy are sorted last, whatever their area.

    FNT)	r8   r9   r:   r;   r<   r=   r>   allow_supersededr&   c	              
      sb   t  jt|jt|j||||du r,dn|||d t| jD ]\}	}
tt|
| j|	< qBdS )u  Get all possible transformations from a :obj:`pyproj.crs.CRS`
        or input used to create one.

        .. versionadded:: 3.4.0 authority, accuracy, allow_ballpark
        .. versionadded:: 3.6.0 allow_superseded

        Parameters
        ----------
        crs_from: pyproj.crs.CRS or input used to create one
            Projection of input data.
        crs_to: pyproj.crs.CRS or input used to create one
            Projection of output data.
        always_xy: bool, default=False
            If true, the transform method will accept as input and return as output
            coordinates using the traditional GIS order, that is longitude, latitude
            for geographic CRS and easting, northing for most projected CRS.
        area_of_interest: :class:`.AreaOfInterest`, optional
            The area of interest to help order the transformations based on the
            best operation for the area.
        authority: str, optional
            When not specified, coordinate operations from any authority will be
            searched, with the restrictions set in the
            authority_to_authority_preference database table related to the
            authority of the source/target CRS themselves. If authority is set
            to “any”, then coordinate operations from any authority will be
            searched. If authority is a non-empty string different from "any",
            then coordinate operations will be searched only in that authority
            namespace (e.g. EPSG).
        accuracy: float, optional
            The minimum desired accuracy (in metres) of the candidate
            coordinate operations.
        allow_ballpark: bool, default=True
            Set to False to disallow the use of Ballpark transformation
            in the candidate coordinate operations. Default is to allow.
        allow_superseded: bool, default=False
            Set to True to allow the use of superseded (but not deprecated)
            transformations in the candidate coordinate operations. Default is
            to disallow.

        N)r:   r;   r<   r=   r>   rI   )	super__init__r   from_user_inputZ_crs	enumerate_transformersr   r3   )r*   r8   r9   r:   r;   r<   r=   r>   rI   Ziiir4   	__class__r+   r,   rL      s    3


zTransformerGroup.__init__r   r%   c                 C   s   | j S )z
        list[:obj:`Transformer`]:
            List of available :obj:`Transformer`
            associated with the transformation.
        )rO   r)   r+   r+   r,   transformers   s    zTransformerGroup.transformersc                 C   s   | j S )z
        list[:obj:`pyproj.crs.CoordinateOperation`]:
            List of :obj:`pyproj.crs.CoordinateOperation` that are not
            available due to missing grids.
        )Z_unavailable_operationsr)   r+   r+   r,   unavailable_operations   s    z'TransformerGroup.unavailable_operationsc                 C   s   | j S )zL
        bool: If True, the best possible transformer is available.
        )Z_best_availabler)   r+   r+   r,   best_available   s    zTransformerGroup.best_available)	directoryopen_licenseverboser&   c                 C   s   |du rt d}| jD ]d}|jD ]X}|js^|j|jr^|jr^|jsH|s^t	|j|j||d q |js |r t
d|  q qdS )a1  
        .. versionadded:: 3.0.0

        Download missing grids that can be downloaded automatically.

        .. warning:: There are cases where the URL to download the grid is missing.
                     In those cases, you can enable enable
                     :ref:`debugging-internal-proj` and perform a
                     transformation. The logs will show the grids PROJ searches for.

        Parameters
        ----------
        directory: str or Path, optional
            The directory to download the grids to.
            Defaults to :func:`pyproj.datadir.get_user_data_dir`
        open_license: bool, default=True
            If True, will only download grids with an open license.
        verbose: bool, default=False
            If True, will print information about grids downloaded.
        NT)file_url
short_namerU   rW   z	Skipped: )r   rS   Zgrids	availableurlendswithrY   Zdirect_downloadrV   r!   warningswarn)r*   rU   rV   rW   Zunavailable_operationgridr+   r+   r,   download_grids   s,    


zTransformerGroup.download_gridsc                 C   s$   d| j  dt| j dt| j S )Nz"<TransformerGroup: best_available=z>
- transformers: z
- unavailable_operations: )rT   lenrR   rS   r)   r+   r+   r,   __repr__$  s    
zTransformerGroup.__repr__)FNNNTF)NTF)r.   r/   r0   r1   r   rD   r   r   rE   floatrL   propertylistrR   r   rS   rT   r   r   r`   rb   __classcell__r+   r+   rP   r,   r      sD         A   .r   c                       s    e Zd ZdZ fddZ  ZS )TransformerLocalz
    Threading local instance for cython _Transformer class.

    For more details, see:
    https://github.com/pyproj4/pyproj/issues/782
    c                    s   d | _ t   d S N)r4   rK   rL   r)   rP   r+   r,   rL   4  s    zTransformerLocal.__init__)r.   r/   r0   r1   rL   rf   r+   r+   rP   r,   rg   ,  s   rg   c                   @   s  e Zd ZdZdUeedf ddddZeee	f dddZ
eee	f d	d
dZedd ZeedddZeedddZeedddZeedddZeedddZeedddZeedddZeedddZeeee  dddZd dd d!Zeedd"d#Zeee dd$d%Z eee dd&d'Z!e"dVe	e	eee# d d)d*d+Z$e"dWe	e	eee# ee ee ee eee d d,
d-d.Z%e"ed d/d0d1Z&e'd(d(e(j)d(fe	e	eeee(ef eee	e	f d2d3d4Z*e'd(d(e(j)d(fe	e	e	eeee(ef eee	e	e	f d5d6d4Z*e'd(d(e(j)d(fe	e	e	e	eeee(ef eee	e	e	e	f d7	d8d4Z*ddd(d(e(j)d(fd9d4Z*d(d(d(d(e(j)fe	eeeeee(ef e+e, d:d;d<Z-d=d(d(e(j)feeeee.eeee(ef eeeeef d>	d?d@Z/e0j1d(fee0ef eedAdBdCZ2e3j4d(fee3ef eedAdDdEZ5dXee.edGdHdIZ6eddJdKZ7eddLdMZ8eddNdOZ9e	edPdQdRZ:e	edPdSdTZ;dS )Yr   a  
    The Transformer class is for facilitating re-using
    transforms without needing to re-create them. The goal
    is to make repeated transforms faster.

    Additionally, it provides multiple methods for initialization.

    .. versionadded:: 2.1.0

    N)transformer_makerr&   c                 C   s4   t |tst  tdt | _| | j_|| _d S )NzETransformer must be initialized using: 'from_crs' or 'from_pipeline'.)
isinstancer$   r   r    rg   _localr4   _transformer_maker)r*   ri   r+   r+   r,   rL   E  s    

zTransformer.__init__r%   c                 C   s
   d| j iS )Nrl   )rl   r)   r+   r+   r,   __getstate__T  s    zTransformer.__getstate__)statec                 C   s$   | j | t | _|  | j_d S rh   )__dict__updaterg   rk   rl   r4   )r*   rn   r+   r+   r,   __setstate__W  s    zTransformer.__setstate__c                 C   s    | j jdu r|  | j _| j jS )zw
        The Cython _Transformer object for this thread.

        Returns
        -------
        _Transformer
        N)rk   r4   rl   r)   r+   r+   r,   _transformer\  s    	zTransformer._transformerc                 C   s   | j jS )z.
        str: Name of the projection.
        )rr   idr)   r+   r+   r,   namei  s    zTransformer.namec                 C   s   | j jS )z5
        str: Description of the projection.
        )rr   descriptionr)   r+   r+   r,   ru   p  s    zTransformer.descriptionc                 C   s   | j jS )z4
        str: Definition of the projection.
        )rr   
definitionr)   r+   r+   r,   rv   w  s    zTransformer.definitionc                 C   s   | j jS )z:
        bool: True if an inverse mapping exists.
        )rr   has_inverser)   r+   r+   r,   rw   ~  s    zTransformer.has_inversec                 C   s   | j jS )zP
        float: Expected accuracy of the transformation. -1 if unknown.
        )rr   r=   r)   r+   r+   r,   r=     s    zTransformer.accuracyc                 C   s   | j jS )z
        .. versionadded:: 2.3.0

        Returns
        -------
        AreaOfUse:
            The area of use object with associated attributes.
        )rr   area_of_user)   r+   r+   r,   rx     s    
zTransformer.area_of_usec                 C   s   | j jS )zy
        .. versionadded:: 2.4.0

        Returns
        -------
        str:
            Remarks about object.
        )rr   remarksr)   r+   r+   r,   ry     s    
zTransformer.remarksc                 C   s   | j jS )zt
        .. versionadded:: 2.4.0

        Returns
        -------
        str:
            Scope of object.
        )rr   scoper)   r+   r+   r,   rz     s    
zTransformer.scopec                 C   s   | j jS )z
        .. versionadded:: 2.4.0

        Returns
        -------
        tuple[CoordinateOperation]:
            The operations in a concatenated operation.
        )rr   
operationsr)   r+   r+   r,   r{     s    
zTransformer.operationsc                 C   s   t t| j S )z
        .. versionadded:: 3.4.0

        .. note:: Requires PROJ 9.1+

        See: :c:func:`proj_trans_get_last_used_operation`

        Returns
        -------
        Transformer:
            The operation used in the transform call.
        )r   r3   rr   get_last_used_operationr)   r+   r+   r,   r|     s    z#Transformer.get_last_used_operationc                 C   s   | j jS )z
        .. versionadded:: 3.0.0

        Returns
        -------
        bool:
            If the network is enabled.
        )rr   is_network_enabledr)   r+   r+   r,   r}     s    
zTransformer.is_network_enabledc                 C   s   | j jdu rdS t| j jS )z
        .. versionadded:: 3.3.0

        Returns
        -------
        Optional[CRS]:
            The source CRS of a CoordinateOperation.
        N)rr   
source_crsr   r)   r+   r+   r,   r~     s    

zTransformer.source_crsc                 C   s   | j jdu rdS t| j jS )z
        .. versionadded:: 3.3.0

        Returns
        -------
        Optional[CRS]:
            The target CRS of a CoordinateOperation.
        N)rr   
target_crsr   r)   r+   r+   r,   r     s    

zTransformer.target_crsF)	proj_fromproj_tor:   r;   r&   c                 C   sF   ddl m} t| |s|| } t||s0||}tj| j|j||dS )a  Make a Transformer from a :obj:`pyproj.Proj` or input used to create one.

        .. deprecated:: 3.4.1 :meth:`~Transformer.from_crs` is preferred.

        .. versionadded:: 2.2.0 always_xy
        .. versionadded:: 2.3.0 area_of_interest

        Parameters
        ----------
        proj_from: :obj:`pyproj.Proj` or input used to create one
            Projection of input data.
        proj_to: :obj:`pyproj.Proj` or input used to create one
            Projection of output data.
        always_xy: bool, default=False
            If true, the transform method will accept as input and return as output
            coordinates using the traditional GIS order, that is longitude, latitude
            for geographic CRS and easting, northing for most projected CRS.
        area_of_interest: :class:`.AreaOfInterest`, optional
            The area of interest to help select the transformation.

        Returns
        -------
        Transformer

        r   )Proj)r:   r;   )pyprojr   rj   r   rB   Zcrs)r   r   r:   r;   r   r+   r+   r,   	from_proj  s    !

zTransformer.from_proj)
r8   r9   r:   r;   r<   r=   r>   r?   r@   r&   c	           	      C   sF   t ttt| jtt|j||||du r2|nt||||d	S )u  Make a Transformer from a :obj:`pyproj.crs.CRS` or input used to create one.

        See:

        - :c:func:`proj_create_crs_to_crs`
        - :c:func:`proj_create_crs_to_crs_from_pj`

        .. versionadded:: 2.2.0 always_xy
        .. versionadded:: 2.3.0 area_of_interest
        .. versionadded:: 3.1.0 authority, accuracy, allow_ballpark
        .. versionadded:: 3.4.0 force_over
        .. versionadded:: 3.5.0 only_best

        Parameters
        ----------
        crs_from: pyproj.crs.CRS or input used to create one
            Projection of input data.
        crs_to: pyproj.crs.CRS or input used to create one
            Projection of output data.
        always_xy: bool, default=False
            If true, the transform method will accept as input and return as output
            coordinates using the traditional GIS order, that is longitude, latitude
            for geographic CRS and easting, northing for most projected CRS.
        area_of_interest: :class:`.AreaOfInterest`, optional
            The area of interest to help select the transformation.
        authority: str, optional
            When not specified, coordinate operations from any authority will be
            searched, with the restrictions set in the
            authority_to_authority_preference database table related to the
            authority of the source/target CRS themselves. If authority is set
            to “any”, then coordinate operations from any authority will be
            searched. If authority is a non-empty string different from "any",
            then coordinate operations will be searched only in that authority
            namespace (e.g. EPSG).
        accuracy: float, optional
            The minimum desired accuracy (in metres) of the candidate
            coordinate operations.
        allow_ballpark: bool, optional
            Set to False to disallow the use of Ballpark transformation
            in the candidate coordinate operations. Default is to allow.
        force_over: bool, default=False
            If True, it will to force the +over flag on the transformation.
            Requires PROJ 9+.
        only_best: bool, optional
            Can be set to True to cause PROJ to error out if the best
            transformation known to PROJ and usable by PROJ if all grids known and
            usable by PROJ were accessible, cannot be used. Best transformation should
            be understood as the transformation returned by
            :c:func:`proj_get_suggested_operation` if all known grids were
            accessible (either locally or through network).
            Note that the default value for this option can be also set with the
            :envvar:`PROJ_ONLY_BEST_DEFAULT` environment variable, or with the
            ``only_best_default`` setting of :ref:`proj-ini`.
            The only_best kwarg overrides the default value if set.
            Requires PROJ 9.2+.

        Returns
        -------
        Transformer

        NrA   )r   r7   r   r   rM   ZsrsrE   )	r8   r9   r:   r;   r<   r=   r>   r?   r@   r+   r+   r,   rB   (  s    IzTransformer.from_crs)rG   r&   c                 C   s   t tt| S )a  Make a Transformer from a PROJ pipeline string.

        :ref:`pipeline`

        See:

        - :c:func:`proj_create`
        - :c:func:`proj_create_from_database`

        .. versionadded:: 3.1.0 AUTH:CODE string support (e.g. EPSG:1671)

        Allowed input:
          - a PROJ string
          - a WKT string
          - a PROJJSON string
          - an object code (e.g. "EPSG:1671"
            "urn:ogc:def:coordinateOperation:EPSG::1671")
          - an object name. e.g "ITRF2014 to ETRF2014 (1)".
            In that case as uniqueness is not guaranteed,
            heuristics are applied to determine the appropriate best match.
          - a OGC URN combining references for concatenated operations
            (e.g. "urn:ogc:def:coordinateOperation,coordinateOperation:EPSG::3895,
            coordinateOperation:EPSG::1618")

        Parameters
        ----------
        proj_pipeline: str
            Projection pipeline string.

        Returns
        -------
        Transformer

        )r   rF   r   )rG   r+   r+   r,   rH     s    $zTransformer.from_pipeline)xxyyradianserrcheck	directioninplacer&   c                 C   s   d S rh   r+   )r*   r   r   r   r   r   r   r+   r+   r,   r     s    
zTransformer.transform)r   r   zzr   r   r   r   r&   c                 C   s   d S rh   r+   )r*   r   r   r   r   r   r   r   r+   r+   r,   r     s    )	r   r   r   ttr   r   r   r   r&   c	           	      C   s   d S rh   r+   )	r*   r   r   r   r   r   r   r   r   r+   r+   r,   r     s    c	              	   C   s   z| j j|||||||dW S  ty.   Y n0 t||d\}	}
t||d\}}|durjt||d\}}nd}|durt||d\}}nd}| j j|	||||||d t|
|	}t||}||f}|dur|t||f7 }|dur|t||f7 }|S )aL  
        Transform points between two coordinate systems.

        See: :c:func:`proj_trans_generic`

        .. versionadded:: 2.1.1 errcheck
        .. versionadded:: 2.2.0 direction
        .. versionadded:: 3.2.0 inplace

        Accepted numeric scalar or array:

        - :class:`int`
        - :class:`float`
        - :class:`numpy.floating`
        - :class:`numpy.integer`
        - :class:`list`
        - :class:`tuple`
        - :class:`array.array`
        - :class:`numpy.ndarray`
        - :class:`xarray.DataArray`
        - :class:`pandas.Series`

        Parameters
        ----------
        xx: scalar or array
            Input x coordinate(s).
        yy: scalar or array
            Input y coordinate(s).
        zz: scalar or array, optional
            Input z coordinate(s).
        tt: scalar or array, optional
            Input time coordinate(s).
        radians: bool, default=False
            If True, will expect input data to be in radians and will return radians
            if the projection is geographic. Otherwise, it uses degrees.
            Ignored for pipeline transformations with pyproj 2,
            but will work in pyproj 3.
        errcheck: bool, default=False
            If True, an exception is raised if the errors are found in the process.
            If False, ``inf`` is returned for errors.
        direction: pyproj.enums.TransformDirection, optional
            The direction of the transform.
            Default is :attr:`pyproj.enums.TransformDirection.FORWARD`.
        inplace: bool, default=False
            If True, will attempt to write the results to the input array
            instead of returning a new array. This will fail if the input
            is not an array in C order with the double data type.

        Example
        --------

        >>> from pyproj import Transformer
        >>> transformer = Transformer.from_crs("EPSG:4326", "EPSG:3857")
        >>> x3, y3 = transformer.transform(33, 98)
        >>> f"{x3:.3f}  {y3:.3f}"
        '10909310.098  3895303.963'
        >>> pipeline_str = (
        ...     "+proj=pipeline +step +proj=longlat +ellps=WGS84 "
        ...     "+step +proj=unitconvert +xy_in=rad +xy_out=deg"
        ... )
        >>> pipe_trans = Transformer.from_pipeline(pipeline_str)
        >>> xt, yt = pipe_trans.transform(2.1, 0.001)
        >>> f"{xt:.3f}  {yt:.3f}"
        '2.100  0.001'
        >>> transproj = Transformer.from_crs(
        ...     {"proj":'geocent', "ellps":'WGS84', "datum":'WGS84'},
        ...     "EPSG:4326",
        ...     always_xy=True,
        ... )
        >>> xpj, ypj, zpj = transproj.transform(
        ...     -2704026.010,
        ...     -4253051.810,
        ...     3895878.820,
        ...     radians=True,
        ... )
        >>> f"{xpj:.3f} {ypj:.3f} {zpj:.3f}"
        '-2.137 0.661 -20.531'
        >>> transprojr = Transformer.from_crs(
        ...     "EPSG:4326",
        ...     {"proj":'geocent', "ellps":'WGS84', "datum":'WGS84'},
        ...     always_xy=True,
        ... )
        >>> xpjr, ypjr, zpjr = transprojr.transform(xpj, ypj, zpj, radians=True)
        >>> f"{xpjr:.3f} {ypjr:.3f} {zpjr:.3f}"
        '-2704026.010 -4253051.810 3895878.820'
        >>> transformer = Transformer.from_crs("EPSG:4326", 4326)
        >>> xeq, yeq = transformer.transform(33, 98)
        >>> f"{xeq:.0f}  {yeq:.0f}"
        '33  98'

        )inxinyinzintimer   r   r   )r   N)rr   Z_transform_point	TypeErrorr#   Z
_transformr"   )r*   r   r   r   r   r   r   r   r   r   Zx_data_typer   Zy_data_typer   Zz_data_typer   Zt_data_typeZoutxZoutyZreturn_datar+   r+   r,   r     sJ    f	


)pointsswitchtime_3rdr   r   r   r&   c              	   #   s   t |}zt|}W n ty0   tddY n0 t|  dvrJtd|r^ dkr^tdt| fdd|D }	td	t|	d
d  }
t|
d
krq| jj	 |
|||||d t
t |
g   E dH  qvdS )ae  
        Iterator/generator version of the function pyproj.Transformer.transform.

        See: :c:func:`proj_trans_generic`

        .. versionadded:: 2.1.1 errcheck
        .. versionadded:: 2.2.0 direction

        Parameters
        ----------
        points: list
            List of point tuples.
        switch: bool, default=False
            If True x, y or lon,lat coordinates of points are switched to y, x
            or lat, lon. Default is False.
        time_3rd: bool, default=False
            If the input coordinates are 3 dimensional and the 3rd dimension is time.
        radians: bool, default=False
            If True, will expect input data to be in radians and will return radians
            if the projection is geographic. Otherwise, it uses degrees.
            Ignored for pipeline transformations with pyproj 2,
            but will work in pyproj 3.
        errcheck: bool, default=False
            If True, an exception is raised if the errors are found in the process.
            If False, ``inf`` is returned for errors.
        direction: pyproj.enums.TransformDirection, optional
            The direction of the transform.
            Default is :attr:`pyproj.enums.TransformDirection.FORWARD`.


        Example
        --------

        >>> from pyproj import Transformer
        >>> transformer = Transformer.from_crs(4326, 2100)
        >>> points = [(22.95, 40.63), (22.81, 40.53), (23.51, 40.86)]
        >>> for pt in transformer.itransform(points): '{:.3f} {:.3f}'.format(*pt)
        '2221638.801 2637034.372'
        '2212924.125 2619851.898'
        '2238294.779 2703763.736'
        >>> pipeline_str = (
        ...     "+proj=pipeline +step +proj=longlat +ellps=WGS84 "
        ...     "+step +proj=unitconvert +xy_in=rad +xy_out=deg"
        ... )
        >>> pipe_trans = Transformer.from_pipeline(pipeline_str)
        >>> for pt in pipe_trans.itransform([(2.1, 0.001)]):
        ...     '{:.3f} {:.3f}'.format(*pt)
        '2.100 0.001'
        >>> transproj = Transformer.from_crs(
        ...     {"proj":'geocent', "ellps":'WGS84', "datum":'WGS84'},
        ...     "EPSG:4326",
        ...     always_xy=True,
        ... )
        >>> for pt in transproj.itransform(
        ...     [(-2704026.010, -4253051.810, 3895878.820)],
        ...     radians=True,
        ... ):
        ...     '{:.3f} {:.3f} {:.3f}'.format(*pt)
        '-2.137 0.661 -20.531'
        >>> transprojr = Transformer.from_crs(
        ...     "EPSG:4326",
        ...     {"proj":'geocent', "ellps":'WGS84', "datum":'WGS84'},
        ...     always_xy=True,
        ... )
        >>> for pt in transprojr.itransform(
        ...     [(-2.137, 0.661, -20.531)],
        ...     radians=True
        ... ):
        ...     '{:.3f} {:.3f} {:.3f}'.format(*pt)
        '-2704214.394 -4254414.478 3894270.731'
        >>> transproj_eq = Transformer.from_crs(
        ...     'EPSG:4326',
        ...     '+proj=longlat +datum=WGS84 +no_defs +type=crs',
        ...     always_xy=True,
        ... )
        >>> for pt in transproj_eq.itransform([(-2.137, 0.661)]):
        ...     '{:.3f} {:.3f}'.format(*pt)
        '-2.137 0.661'

        z(iterable must contain at least one pointN)         z&points can contain up to 4 coordinatesr   z+'time_3rd' is only valid for 3 coordinates.c                 3   s$   | ]}t  D ]}|| V  qqd S rh   )range).0ZcoordscZstrider+   r,   	<genexpr>      z)Transformer.itransform.<locals>.<genexpr>dr   @   )r   r   r   r   r   )iternextStopIteration
ValueErrorra   r   r	   r   rr   Z_transform_sequencezip)r*   r   r   r   r   r   r   Zpoint_itZfst_ptZ	coord_genZbuffr+   r   r,   r   ^  s4    Y
zTransformer.itransform   )	leftbottomrighttopdensify_ptsr   r   r   r&   c	           	   
   C   s   | j j||||||||dS )aj
  
        .. versionadded:: 3.1.0

        See: :c:func:`proj_trans_bounds`

        Transform boundary densifying the edges to account for nonlinear
        transformations along these edges and extracting the outermost bounds.

        If the destination CRS is geographic and right < left then the bounds
        crossed the antimeridian. In this scenario there are two polygons,
        one on each side of the antimeridian. The first polygon should be
        constructed with (left, bottom, 180, top) and the second with
        (-180, bottom, top, right).

        To construct the bounding polygons with shapely::

            def bounding_polygon(left, bottom, right, top):
                if right < left:
                    return shapely.geometry.MultiPolygon(
                        [
                            shapely.geometry.box(left, bottom, 180, top),
                            shapely.geometry.box(-180, bottom, right, top),
                        ]
                    )
                return shapely.geometry.box(left, bottom, right, top)


        Parameters
        ----------
        left: float
            Minimum bounding coordinate of the first axis in source CRS
            (or the target CRS if using the reverse direction).
        bottom: float
            Minimum bounding coordinate of the second axis in source CRS.
            (or the target CRS if using the reverse direction).
        right: float
            Maximum bounding coordinate of the first axis in source CRS.
            (or the target CRS if using the reverse direction).
        top: float
            Maximum bounding coordinate of the second axis in source CRS.
            (or the target CRS if using the reverse direction).
        densify_points: uint, default=21
            Number of points to add to each edge to account for nonlinear edges
            produced by the transform process. Large numbers will produce worse
            performance.
        radians: bool, default=False
            If True, will expect input data to be in radians and will return radians
            if the projection is geographic. Otherwise, it uses degrees.
        errcheck: bool, default=False
            If True, an exception is raised if the errors are found in the process.
            If False, ``inf`` is returned for errors.
        direction: pyproj.enums.TransformDirection, optional
            The direction of the transform.
            Default is :attr:`pyproj.enums.TransformDirection.FORWARD`.

        Returns
        -------
        left, bottom, right, top: float
            Outermost coordinates in target coordinate reference system.
        )r   r   r   r   r   r   r   r   )rr   Z_transform_bounds)	r*   r   r   r   r   r   r   r   r   r+   r+   r,   transform_bounds  s    GzTransformer.transform_bounds)versionprettyr&   c                 C   s   | j j||dS )a  
        Convert the projection to a PROJ string.

        .. versionadded:: 3.1.0

        Parameters
        ----------
        version: pyproj.enums.ProjVersion
            The version of the PROJ string output.
            Default is :attr:`pyproj.enums.ProjVersion.PROJ_5`.
        pretty: bool, default=False
            If True, it will set the output to be a multiline string.

        Returns
        -------
        str:
            The PROJ string.

        r   r   )rr   to_proj4r*   r   r   r+   r+   r,   r   0  s    zTransformer.to_proj4c                 C   s   | j j||dS )ai  
        Convert the projection to a WKT string.

        Version options:
          - WKT2_2015
          - WKT2_2015_SIMPLIFIED
          - WKT2_2019
          - WKT2_2019_SIMPLIFIED
          - WKT1_GDAL
          - WKT1_ESRI


        Parameters
        ----------
        version: pyproj.enums.WktVersion, optional
            The version of the WKT output.
            Default is :attr:`pyproj.enums.WktVersion.WKT2_2019`.
        pretty: bool, default=False
            If True, it will set the output to be a multiline string.

        Returns
        -------
        str:
            The WKT string.
        r   )rr   to_wktr   r+   r+   r,   r   J  s    zTransformer.to_wktr   )r   indentationr&   c                 C   s   | j j||dS )a  
        Convert the projection to a JSON string.

        .. versionadded:: 2.4.0

        Parameters
        ----------
        pretty: bool, default=False
            If True, it will set the output to be a multiline string.
        indentation: int, default=2
            If pretty is True, it will set the width of the indentation.

        Returns
        -------
        str:
            The JSON string.
        )r   r   )rr   to_json)r*   r   r   r+   r+   r,   r   j  s    zTransformer.to_jsonc                 C   s
   | j  S )z
        Convert the projection to a JSON dictionary.

        .. versionadded:: 2.4.0

        Returns
        -------
        dict:
            The JSON dictionary.
        )rr   to_json_dictr)   r+   r+   r,   r   ~  s    zTransformer.to_json_dictc                 C   s   | j S rh   )rv   r)   r+   r+   r,   __str__  s    zTransformer.__str__c                 C   s*   d| j j d| j d| j d| jp$d S )N<z: z>
Description: z
Area of Use:
z- undefined)rr   	type_namert   ru   rx   r)   r+   r+   r,   rb     s    zTransformer.__repr__)otherr&   c                 C   s   t |tsdS | j|jS )NF)rj   r   rr   __eq__r*   r   r+   r+   r,   r     s    
zTransformer.__eq__c                 C   s   t |tsdS | j|jS )z
        Check if the Transformer objects are the exact same.
        If it is not a Transformer, then it returns False.

        Parameters
        ----------
        other: Any

        Returns
        -------
        bool
        F)rj   r   rr   is_exact_samer   r+   r+   r,   r     s    
zTransformer.is_exact_same)N)FN)FNNNNFN)Fr   )<r.   r/   r0   r1   r   r$   rL   dictrE   r   rm   rq   rd   rr   rt   ru   rv   rD   rw   rc   r=   r   rx   ry   rz   r   tupler   r{   r|   r}   r   r~   r   staticmethodr   r   rB   rH   r   r   ZFORWARDr   r   r
   r   intr   r   ZPROJ_5r   r   Z	WKT2_2019r   r   r   r   rb   r   r   r+   r+   r+   r,   r   9  sT   

  .       V%




 
 
T

 r   F	p1p2xyzr   r   r   r:   c	           	      C   s2   t jdtdd tj| ||dj||||||dS )a  
    .. versionadded:: 2.2.0 always_xy

    .. deprecated:: 2.6.1
        This function is deprecated. See: :ref:`upgrade_transformer`

    x2, y2, z2 = transform(p1, p2, x1, y1, z1)

    Transform points between two coordinate systems defined by the
    Proj instances p1 and p2.

    The points x1,y1,z1 in the coordinate system defined by p1 are
    transformed to x2,y2,z2 in the coordinate system defined by p2.

    z1 is optional, if it is not set it is assumed to be zero (and
    only x2 and y2 are returned). If the optional keyword
    'radians' is True (default is False), then all input and
    output coordinates will be in radians instead of the default
    of degrees for geographic input/output projections.
    If the optional keyword 'errcheck' is set to True an
    exception is raised if the transformation is
    invalid. By default errcheck=False and ``inf`` is returned for an
    invalid transformation (and no exception is raised).
    If `always_xy` is toggled, the transform method will accept as
    input and return as output coordinates using the traditional GIS order,
    that is longitude, latitude for geographic CRS and easting,
    northing for most projected CRS.

    In addition to converting between cartographic and geographic
    projection coordinates, this function can take care of datum
    shifts (which cannot be done using the __call__ method of the
    Proj instances). It also allows for one of the coordinate
    systems to be geographic (proj = 'latlong').

    x,y and z can be numpy or regular python arrays, python
    lists/tuples or scalars. Arrays are fastest.  For projections in
    geocentric coordinates, values of x and y are given in meters.
    z is always meters.

    zThis function is deprecated. See: https://pyproj4.github.io/pyproj/stable/gotchas.html#upgrading-to-pyproj-2-from-pyproj-1r   
stacklevelr:   )r   r   r   r   r   r   )r]   r^   FutureWarningr   r   r   r   r+   r+   r,   r     s    3	r   r   r   r   r   r   r   r   r:   c                 C   s0   t jdtdd tj| ||dj|||||dS )aU
  
    .. versionadded:: 2.2.0 always_xy

    .. deprecated:: 2.6.1
        This function is deprecated. See: :ref:`upgrade_transformer`

    points2 = itransform(p1, p2, points1)
    Iterator/generator version of the function pyproj.transform.
    Transform points between two coordinate systems defined by the
    Proj instances p1 and p2. This function can be used as an alternative
    to pyproj.transform when there is a need to transform a big number of
    coordinates lazily, for example when reading and processing from a file.
    Points1 is an iterable/generator of coordinates x1,y1(,z1) or lon1,lat1(,z1)
    in the coordinate system defined by p1. Points2 is an iterator that returns tuples
    of x2,y2(,z2) or lon2,lat2(,z2) coordinates in the coordinate system defined by p2.
    z are provided optionally.

    Points1 can be:
        - a tuple/list of tuples/lists i.e. for 2d points: [(xi,yi),(xj,yj),....(xn,yn)]
        - a Nx3 or Nx2 2d numpy array where N is the point number
        - a generator of coordinates (xi,yi) for 2d points or (xi,yi,zi) for 3d

    If optional keyword 'switch' is True (default is False) then x, y or lon,lat
    coordinates of points are switched to y, x or lat, lon.
    If the optional keyword 'radians' is True (default is False),
    then all input and output coordinates will be in radians instead
    of the default of degrees for geographic input/output projections.
    If the optional keyword 'errcheck' is set to True an
    exception is raised if the transformation is
    invalid. By default errcheck=False and ``inf`` is returned for an
    invalid transformation (and no exception is raised).
    If `always_xy` is toggled, the transform method will accept as
    input and return as output coordinates using the traditional GIS order,
    that is longitude, latitude for geographic CRS and easting, northing
    for most projected CRS.


    Example usage:

    >>> from pyproj import Proj, itransform
    >>> # projection 1: WGS84
    >>> # (defined by epsg code 4326)
    >>> p1 = Proj('epsg:4326', preserve_units=False)
    >>> # projection 2: GGRS87 / Greek Grid
    >>> p2 = Proj('epsg:2100', preserve_units=False)
    >>> # Three points with coordinates lon, lat in p1
    >>> points = [(22.95, 40.63), (22.81, 40.53), (23.51, 40.86)]
    >>> # transform this point to projection 2 coordinates.
    >>> for pt in itransform(p1,p2,points, always_xy=True): '%6.3f %7.3f' % pt
    '411050.470 4497928.574'
    '399060.236 4486978.710'
    '458553.243 4523045.485'
    >>> for pt in itransform(4326, 4326, [(30, 60)]):
    ...     '{:.0f} {:.0f}'.format(*pt)
    '30 60'

    r   r   r   r   )r   r   r   r   )r]   r^   r   r   r   r   r   r+   r+   r,   r     s    C	
r   )NNFFF)FFFFF)=r1   __all__	threadingr]   abcr   r   r	   collections.abcr
   r   dataclassesr   	itertoolsr   r   pathlibr   typingr   r   r   r   r   r   Zpyproj._compatr   Zpyproj._crsr   r   Zpyproj._datadirr   Zpyproj._transformerr   r   r   r   Zpyproj.datadirr   Zpyproj.enumsr   r   r   Zpyproj.exceptionsr    Zpyproj.syncr!   Zpyproj.utilsr"   r#   r$   r3   r7   rF   r   localrg   r   rD   r   r   r+   r+   r+   r,   <module>   s   
( $      ~     E     