
    !\i                     P    S r SSKrSSKrSSKrSSKJr  S r SS jr S	S jrS r	g)
z/
Helper objects used by multiple CLI commands.
    N)FileOverwriteErrorc              #     #    [        U [        [        45      (       a  U nO!SU ;   a	  U S   S   nOU R                  SU 5      nU H@  n[        U[        [
        45      (       a  [        U5      v     g[        U5       Sh  vN   MB     g N	7f)z_Yield all coordinate coordinate tuples from a geometry or feature.
From python-geojson package.geometrycoordinatesN)
isinstancetuplelistgetfloatintcoords)objr   es      W/var/www/html/kml_chatgpt/mouzaenv/lib/python3.13/site-packages/rasterio/rio/helpers.pyr   r      s~      #t}%%	s	*om4ggmS1a%&&$$ay   
 !s   A=B?B	 
Bc                    U(       a  U" 5        H  n[        [        U5      6 u  px[        U5      [        U5      [        U5      [        U5      4n	U(       a  U R	                  S5        US:X  a'  U R	                  [
        R                  " U	40 UD65        O&U R	                  [
        R                  " U40 UD65        U R	                  S5        M     g[        U" 5       5      n
US:X  a1  U R	                  [
        R                  " UR                  40 UD65        O4U R	                  [
        R                  " UR                  SU
S.40 UD65        U R	                  S5        g)zRRead an iterator of (feat, bbox) pairs and write to file using
the selected modes.bbox
FeatureCollection)r   typefeaturesN)	zipr   minmaxwritejsondumpsr	   r   )fobj
collectionsequencegeojson_typeuse_rs	dump_kwdsfeatxsysr   r   s              r   write_featuresr'      s    LD&,'FBGSWc"gs2w7D

8$v%

4::d8i89

4::d8i89JJt ! 
%6!JJtzz*//?Y?@JJtzz"+$#&  	 
 	

4    c                    U=(       d    U(       a  US   OSnU(       d6  U(       a/  [         R                  R                  U5      (       a  [        S5      eU (       a  U /O"U(       a  / [	        USU(       d  SOS 5      -   O/ nUbJ  [        U5      U:  a  [        R                  " S5      e[        U5      U:  a  [        R                  " S5      eXV4$ )a  Resolves inputs and outputs from standard args and options.

Parameters
----------
input : str
    A single input filename, optional.
output : str
    A single output filename, optional.
files : str
    A sequence of filenames in which the last is the output filename.
overwrite : bool
    Whether to force overwriting the output file.
num_inputs : int
    Raise exceptions if the number of resolved input files is higher
    or lower than this number.

Returns
-------
tuple (str, list of str)
    The resolved output filename and input filenames as a tuple of
    length 2.

If provided, the output file may be overwritten. An output
file extracted from files will not be overwritten unless
overwrite is True.

Raises
------
click.BadParameter

NzMfile exists and won't be overwritten without use of the `--overwrite` option.zInsufficient inputszToo many inputs)ospathexistsr   r	   lenclickBadParameter)inputoutputfiles	overwrite
num_inputsresolved_outputresolved_inputss          r   resolve_inoutr8   ?   s    D >erORWW^^O-L-L [
 	

 49 !U.fB$/01?A  *,$$%:;;!J.$$%677++r(   c                 "    UR                  5       $ )z-Click callback, converts values to lowercase.)lower)ctxparamvalues      r   to_lowerr>   u   s    ;;=r(   )FfeatureF)NNNFN)
__doc__r   r+   r/   rasterio.errorsr   r   r'   r8   r>    r(   r   <module>rC      s<     	  .!$ JOD FJ3,lr(   