a
    1$e9                  
   @   s   d Z ddlZddlZddlmZmZ ddlZddlmZ ddl	m
Z
 ddlmZ ejddeejd	d
ddejdd
ddejdd
ddeeje
dd ZdS )z$ fio bounds    N)precision_opt
use_rs_opt)obj_gen)with_context_env)ObjectEncoderz#Print the extent of GeoJSON objects)
short_helpz--explode/--no-explodeFz0Explode collections into features (default: no).)defaulthelpz--with-id/--without-idzAPrint GeoJSON ids and bounding boxes together (default: without).z--with-obj/--without-objzEPrint GeoJSON objects and bounding boxes together (default: without).c                    s  t d}t|}t|D ]\}}	|	ddt| }
g }g }|	dpN|	g}t|D ]\}}|ddt| }t|\}}}} dkr fdd||||fD \}}}}|r&|r|
|||||fd	}n,|r|j|
||||fd
 |}n||||f}|rt j	ddd t 	t
j|td qX|||g |||g qX|st|t|t|t|f\}}}}|r|
||||fd}n.|r|	j|
||||fd |	}n||||f}|rt j	ddd t 	t
j|td qdS )a  Print the bounding boxes of GeoJSON objects read from stdin.

    Optionally explode collections and print the bounds of their
    features.

    To print identifiers for input objects along with their bounds
    as a {id: identifier, bbox: bounds} JSON object, use --with-id.

    To print the input objects themselves along with their bounds
    as GeoJSON object, use --with-obj. This has the effect of updating
    input objects with {id: identifier, bbox: bounds}.

    stdinidzcollection:featureszfeature:r   c                 3   s   | ]}t | V  qd S )N)round).0v	precision L/var/www/html/django/DPS/env/lib/python3.9/site-packages/fiona/fio/bounds.py	<genexpr>7       zbounds.<locals>.<genexpr>)parentr   bbox)r   r   F)nl)cls)r   r   N)clickget_text_streamr   	enumerategetstrfionaboundsupdateechojsondumpsr   extendminmax)ctxr   ZexplodeZwith_idZwith_objZuse_rsr
   sourceiobjobj_idZxsZysr   jZfeatZfeat_idwsenZrecr   r   r   r!      sF    
"$r!   )__doc__r$   r   Zcligjr   r   r    Zfiona.fio.helpersr   Z	fiona.fior   Zfiona.modelr   commandoptionpass_contextr!   r   r   r   r   <module>   s,   
