
     hz              	           d Z ddlZddlmZ ddlmZmZ ddlmZ dedefdZ	dedefd	Z
 G d
 dej                        Z G d de      Zdedeeef   fdZddededeeef   fdZdededefdZy)z&
Utility functions used within pyproj
    N)array)Enumauto)Anyvaluereturnc                     | | k7  xs | du S )z'
    Check if value is NaN or None
    N r   s    h/home/developers/rajanand/mypropertyqr-fmb-refixing-v2/venv/lib/python3.12/site-packages/pyproj/utils.pyis_nullr      s    
 E>*Ud]*    c                 f    t        |       j                         } | dv ry| dv ryt        d|  d      )z
    https://docs.python.org/3.9/distutils/apiref.html#distutils.util.strtobool

    Here since distutils is deprecated.

    Convert a string representation of truth to True or False.
    )yyesttrueon1T)nnoffalseoff0Fzinvalid truth value: '')strlower
ValueErrorr   s    r   	strtoboolr       sC     JE4455
-eWA6
77r   c                       e Zd ZdZd Zy)NumpyEncoderz1
    Handle numpy types when dumping to JSON
    c                 4   	 |j                         S # t        $ r Y nw xY w	 |j                  j                  dk(  rt	        |      S |j                  j                  dk(  rt        |      S n# t        $ r Y nw xY wt        j                  j                  | |      S )Nr   i)	tolistAttributeErrordtypekindfloatintjsonJSONEncoderdefault)selfobjs     r   r-   zNumpyEncoder.default(   s    	::< 			yy~~$Sz!yy~~$3x % 		''c22s#    	#A+ #A+ +	A76A7N)__name__
__module____qualname____doc__r-   r
   r   r   r"   r"   #   s    3r   r"   c                   H    e Zd ZdZ e       Z e       Z e       Z e       Zy)DataTypezA
    Data type for copy to buffer and convertback operations
    N)	r0   r1   r2   r3   r   FLOATLISTTUPLEARRAYr
   r   r   r5   r5   8   s%     FE6DFEFEr   r5   xxxc                     	 t        dt        |       f      t        j                  fS # t        $ r t        d      dw xY w)a  
    Prepares scalar for PROJ C-API:
    - Makes a copy because PROJ modifies buffer in place
    - Make sure dtype is double as that is what PROJ expects
    - Makes sure object supports Python Buffer API

    Parameters
    -----------
    xxx: float or 0-d numpy array

    Returns
    -------
    tuple[Any, DataType]
        The copy of the data prepared for the PROJ API & Python Buffer API.
    dzinput must be a scalarN)r   r)   r5   r6   	Exception	TypeError)r:   s    r   _copytobuffer_return_scalarr?   C   s@     <S5:-((..88 <01t;<s   %( >inplacec                 j   t        | d      s1t        | d      r%t        | j                        r| j                         } t        | d      r?| j                  dk(  rt	        |       S | j                  dd|       t        j                  fS t        j                  }t        | t              r!|r| j                  dk7  rt        d|       } | |fS t        | t              r t        d|       } t        j                  }| |fS t        | t              r t        d|       } t        j                  }| |fS t	        |       S )a  
    Prepares data for PROJ C-API:
    - Makes a copy because PROJ modifies buffer in place
    - Make sure dtype is double as that is what PROJ expects
    - Makes sure object supports Python Buffer API

    If the data is a numpy array, it ensures the data is in C order.

    Parameters
    ----------
    xxx: Any
        A scalar, list, tuple, numpy.array,
        pandas.Series, xaray.DataArray, or dask.array.Array.
    inplace: bool, default=False
        If True, will return the array without a copy if it
        meets the requirements of the Python Buffer API & PROJ C-API.

    Returns
    -------
    tuple[Any, DataType]
        The copy of the data prepared for the PROJ API & Python Buffer API.
    hardmask	__array__shaper
   r<   C)ordercopy)hasattrcallablerC   rD   r?   astyper5   r9   
isinstancer   typecodelistr7   tupler8   )r:   r@   	data_types      r   _copytobufferrP   Y   s   8 C$C%S]]#mmo sG99? /s33zz#S7{z;X^^KKI#u#,,#-S/C 	> 
C	CoMM	 	> 
C	CoNN	 	> +3//r   rO   inxc                     | t         j                  k(  r|d   S | t         j                  k(  r|j                         S | t         j                  k(  rt        |      S |S )Nr   )r5   r6   r7   r%   r8   rN   )rO   rQ   s     r   _convertbackrS      sJ    HNN"1vHMM!zz|HNN"SzJr   )F)r3   r+   r   enumr   r   typingr   boolr   r    r,   r"   r5   rN   r?   rP   rS   r
   r   r   <module>rW      s       +3 +4 +8S 8T 8 34## 3*t <S <U5(?-C <,6s 6T 6eCM6J 6rH 3 3 r   