a
    1$e#                     @   s   d Z ddlmZ ddlZddlZddlZddlmZmZ ddl	m
Z
mZ ddlmZ ddlmZ ejdd	ejd
ddejddddddejejddddejejddejddejejejddddejedd ZdS )z
$ fio load    )partialN)optionswith_context_env)FeatureGeometry)FIELD_TYPES_MAP_REV)transform_geomz,Load GeoJSON to a dataset in another format.)
short_helpoutputT)requiredz-fz--formatz--driverdriverzOutput format driver name.)helpz	--dst-crsz	--dst_crsz7Destination CRS.  Defaults to --src-crs when not given.z--layerz
INDEX|NAMEz\Load features into specified layer.  Layers use zero-based numbering when accessed by index.)metavarcallbackr   z--appendz&Open destination layer in append mode.)is_flagr   c
                    s  |p|}|r*|r*||kr*t t||ddndd  fdd}
|
 }zt|}W n tyn   tdY n0 d|jji}d	d
 |j	 D |d< |	rt
j|dfd|i|}nt
j|df||||d|}|$}|| || W d   n1 s0    Y  dS )zLoad features from JSON to a file in another format.

    The input is a GeoJSON feature collection or optionally a sequence of
    GeoJSON feature objects.

    T)Zantimeridian_cuttingc                 S   s   t jf i | S )N)r   	from_dict)x r   J/var/www/html/django/DPS/env/lib/python3.9/site-packages/fiona/fio/load.pytransformer?   s    zload.<locals>.transformerc                  3   s^   z< D ]2} t jf i | d | d< tjf i | V  qW n tyX   tdY n0 dS )z\Convert stream of JSON to features.

        Yields
        ------
        Feature

        geometryInvalid input.N)r   r   r   	TypeErrorclickClickException)Zfeatfeaturesr   r   r   feature_genB   s    zload.<locals>.feature_genr   r   c                 S   s$   i | ]\}}|t t|pd qS )str)r   gettype).0kvr   r   r   
<dictcomp>\   s   zload.<locals>.<dictcomp>
propertiesalayerw)r   Zcrsschemar'   N)r   r   nextr   r   r   r   r    r%   itemsfionaopenwriteZwriterecords)ctxr
   r   Zsrc_crsZdst_crsr   r'   Zcreation_optionsZopen_optionsappendr   sourcefirstr)   openerdstr   r   r   load   s@    (


r5   )__doc__	functoolsr   r   Zcligjr,   Z	fiona.fior   r   Zfiona.modelr   r   Zfiona.schemar   Zfiona.transformr   commandargumentoptionZsrc_crs_optZfeatures_in_argZcb_layerZcreation_optZopen_optpass_contextr5   r   r   r   r   <module>   s<   
