a
    1$e;                     @   s$  d Z ddlZddlZddlZddlmZ ddlZddlZe dkrej	
ej	edZej	erree n@dejv rejd ejD ]"Zeej	
edree qd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# ddl$m%Z% ddl&m'Z' ddl(m)Z)m*Z*m+Z+ ddl,m-Z-m.Z.m/Z/m0Z0m1Z1m2Z2 ddl3m4Z4m5Z5m6Z6 ddl7m8Z9 ddl:m;Z;m<Z<m=Z= ddl>Z>g dZ?dZ@e ZAe ZBeCeDZEeEFeG  e"d)ddZHeHZIe"d*ddZJe"dd ZKe"d+dd ZLd!d" ZMd#d$ ZNd%d& ZOd'd( ZPdS ),a  
Fiona is OGR's neat, nimble API.

Fiona provides a minimal, uncomplicated Python interface to the open
source GIS community's most trusted geodata access library and
integrates readily with other Python GIS packages such as pyproj, Rtree
and Shapely.

A Fiona feature is a Python mapping inspired by the GeoJSON format. It
has ``id``, ``geometry``, and ``properties`` attributes. The value of
``id`` is a string identifier unique within the feature's parent
collection. The ``geometry`` is another mapping with ``type`` and
``coordinates`` keys. The ``properties`` of a feature is another mapping
corresponding to its attribute table.

Features are read and written using the ``Collection`` class.  These
``Collection`` objects are a lot like Python ``file`` objects. A
``Collection`` opened in reading mode serves as an iterator over
features. One opened in a writing mode provides a ``write`` method.

    N)PathWindowsz.libsPATHz	gdal*.dll)calc_gdal_version_numget_gdal_release_nameget_gdal_version_numget_gdal_version_tuple)driver_count)show_versions)BytesCollection
Collection)supported_drivers)ensure_env_with_credentialsEnv)FionaDeprecationWarning)
MemoryFile)FeatureGeometry
Properties)FIELD_TYPES_MAP_bounds_listdir_listlayers_remove_remove_layer)
ParsedPath
parse_pathvsi_path)parse_paths)	_geometry_errrfc3339)
r   r   r   bounds
listlayerslistdiropen	prop_type
prop_widthremovez1.9.4.post1rFc                    s  |dkrNt  drNt  jf |||||||
d|}|j |S |dkrt  drt jf |||||||
|	d|}|j  fdd}|j| |S |d	krt  drtd
nt tr2|	dr  jf ||
d|}n.|	dr. jf |||||||
|	d|}|S t t
rFt  |r|tjdtdd t |d\}}}t|||}nt }|dv rt||f|||||
d|}n8|dkrt||f|||||||	|
d|}ntd|S dS )a  Open a collection for read, append, or write

    In write mode, a driver name such as "ESRI Shapefile" or "GPX" (see
    OGR docs or ``ogr2ogr --help`` on the command line) and a schema
    mapping such as:

      {'geometry': 'Point',
       'properties': [('class', 'int'), ('label', 'str'),
                      ('value', 'float')]}

    must be provided. If a particular ordering of properties ("fields"
    in GIS parlance) in the written file is desired, a list of (key,
    value) pairs as above or an ordered dict is required. If no ordering
    is needed, a standard dict will suffice.

    A coordinate reference system for collections in write mode can be
    defined by the ``crs`` parameter. It takes Proj4 style mappings like

      {'proj': 'longlat', 'ellps': 'WGS84', 'datum': 'WGS84',
       'no_defs': True}

    short hand strings like

      EPSG:4326

    or WKT representations of coordinate reference systems.

    The drivers used by Fiona will try to detect the encoding of data
    files. If they fail, you may provide the proper ``encoding``, such
    as 'Windows-1252' for the Natural Earth datasets.

    When the provided path is to a file containing multiple named layers
    of data, a layer can be singled out by ``layer``.

    The drivers enabled for opening datasets may be restricted to those
    listed in the ``enabled_drivers`` parameter. This and the ``driver``
    parameter afford much control over opening of files.

      # Trying only the GeoJSON driver when opening to read, the
      # following raises ``DataIOError``:
      fiona.open('example.shp', driver='GeoJSON')

      # Trying first the GeoJSON driver, then the Shapefile driver,
      # the following succeeds:
      fiona.open(
          'example.shp', enabled_drivers=['GeoJSON', 'ESRI Shapefile'])

    Parameters
    ----------
    fp : URI (str or pathlib.Path), or file-like object
        A dataset resource identifier or file object.
    mode : str
        One of 'r', to read (the default); 'a', to append; or 'w', to
        write.
    driver : str
        In 'w' mode a format driver name is required. In 'r' or 'a'
        mode this parameter has no effect.
    schema : dict
        Required in 'w' mode, has no effect in 'r' or 'a' mode.
    crs : str or dict
        Required in 'w' mode, has no effect in 'r' or 'a' mode.
    encoding : str
        Name of the encoding used to encode or decode the dataset.
    layer : int or str
        The integer index or name of a layer in a multi-layer dataset.
    vfs : str
        This is a deprecated parameter. A URI scheme such as "zip://"
        should be used instead.
    enabled_drivers : list
        An optional list of driver names to used when opening a
        collection.
    crs_wkt : str
        An optional WKT representation of a coordinate reference
        system.
    ignore_fields : list
        List of field names to ignore on load.
    ignore_geometry : bool
        Ignore the geometry on load.
    include_fields : list
        List of a subset of field names to include on load.
    wkt_version : fiona.enums.WktVersion or str, optional
        Version to use to for the CRS WKT.
        Defaults to GDAL's default (WKT1_GDAL for GDAL 3).
    allow_unsupported_drivers : bool
        If set to true do not limit GDAL drivers to set set of known working.
    kwargs : mapping
        Other driver-specific parameters that will be interpreted by
        the OGR library as layer creation or opening options.

    Returns
    -------
    Collection

    r)   read)drivercrsschemalayerencodingenabled_driversallow_unsupported_driverswwrite)r+   r,   r-   r.   r/   r0   r1   crs_wktc                     s    d    d S )Nr   )seekr3   r*   )argskwdsfpmemfile J/var/www/html/django/DPS/env/lib/python3.9/site-packages/fiona/__init__.pyfunc   s    
zopen.<locals>.funcazBAppend mode is not supported for datasets in a Python file object.)r+   r1   zThe vfs keyword argument is deprecated and will be removed in version 2.0.0. Instead, pass a URL that uses a zip or tar (for example) scheme.   
stacklevel)vfs)r>   r)   )r+   r/   r.   r0   r1   )r,   r+   r-   r/   r.   r0   r4   r1   z*mode string must be one of {'r', 'w', 'a'}N)hasattrr   r*   r%   _enventer_contextcallbackOSError
isinstance
startswithr   strwarningswarnr   vfs_parse_pathsr   r   r   
ValueError)r9   moder+   r-   r,   r/   r.   rB   r0   r4   r1   kwargsZcolxnr=   pathschemearchiver;   r8   r<   r%   ^   s    m
		


r%   c                 C   s`   t | tr$| }|j}|j}|  nt | tr8t| }n| }|du rPt|| nt||| dS )a}  Delete an OGR data source or one of its layers.

    If no layer is specified, the entire dataset and all of its layers
    and associated sidecar files will be deleted.

    Parameters
    ----------
    path_or_collection : str, pathlib.Path, or Collection
        The target Collection or its path.
    driver : str, optional
        The name of a driver to be used for deletion, optional. Can
        usually be detected.
    layer : str or int, optional
        The name or index of a specific layer.

    Returns
    -------
    None

    Raises
    ------
    DatasetDeleteError
        If the data source cannot be deleted.

    N)	rH   r   rQ   r+   closer   rJ   r   r   )Zpath_or_collectionr+   r.   
collectionrQ   r;   r;   r<   r(   E  s    



r(   c                 C   s<   t | trt| } t | ts(td|  t| }tt|S )ak  Lists the datasets in a directory or archive file.

    Archive files must be prefixed like "zip://" or "tar://".

    Parameters
    ----------
    fp : str or pathlib.Path
        Directory or archive path.

    Returns
    -------
    list of str
        A list of datasets.

    Raises
    ------
    TypeError
        If the input is not a str or Path.

    invalid path: %r)rH   r   rJ   	TypeErrorr   r   r   )r9   pobjr;   r;   r<   r$   o  s    

r$   c                 K   s   t | drJt|  "}t|jfi |W  d   S 1 s>0    Y  nt| tr\t| } t| tsrtd|  |rt|tstd| |rt	j
dtdd t|}t| }t|j|j|j}nt| }tt|fi |S dS )am  Lists the layers (collections) in a dataset.

    Archive files must be prefixed like "zip://" or "tar://".

    Parameters
    ----------
    fp : str, pathlib.Path, or file-like object
        A dataset identifier or file object containing a dataset.
    vfs : str
        This is a deprecated parameter. A URI scheme such as "zip://"
        should be used instead.
    kwargs : dict
        Dataset opening options and other keyword args.

    Returns
    -------
    list of str
        A list of layer name strings.

    Raises
    ------
    TypeError
        If the input is not a str, Path, or file object.

    r*   NrV   zinvalid vfs: %rzThe vfs keyword argument is deprecated and will be removed in 2.0. Instead, pass a URL that uses a zip or tar (for example) scheme.r?   r@   )rC   r   r*   r   namerH   r   rJ   rW   rK   rL   r   r   r   rQ   rR   r   )r9   rB   rP   r:   Zpobj_vfsZ	pobj_pathrX   r;   r;   r<   r#     s(    
2

r#   c                 C   s.   |  dr*t| ddd p"dgd S dS )aB  Returns the width of a str type property.

    Undefined for non-str properties.

    Parameters
    ----------
    val : str
        A type:width string from a collection schema.

    Returns
    -------
    int or None

    Examples
    --------
    >>> prop_width('str:25')
    25
    >>> prop_width('str')
    80

    rJ   :   N80r   )rI   intsplit)valr;   r;   r<   r'     s    
 r'   c                 C   s   |  dd }t| S )a<  Returns a schema property's proper Python type.

    Parameters
    ----------
    text : str
        A type name, with or without width.

    Returns
    -------
    obj
        A Python class.

    Examples
    --------
    >>> prop_type('int')
    <class 'int'>
    >>> prop_type('str:25')
    <class 'str'>

    rZ   r   )r^   r   )textkeyr;   r;   r<   r&     s    r&   c                  O   sL   t jdtdd tdkr0td tf i |S td tf i |S dS )zGReturns a context manager with registered drivers.

    DEPRECATED
    zUse fiona.Env() instead.r?   r@   r   z%Creating a chief GDALEnv in drivers()z/Creating a not-responsible GDALEnv in drivers()N)rK   rL   r   r	   logdebugr   )r6   rP   r;   r;   r<   drivers  s    

rd   c                 C   s   |  dp| }t|S )zeReturns a (minx, miny, maxx, maxy) bounding box.

    The ``ob`` may be a feature record or geometry.Zgeometry)getr   )obZgeomr;   r;   r<   r"   	  s    r"   )
r)   NNNNNNNNF)NN)N)Q__doc__globloggingospathlibr   platformrK   systemrQ   joindirname__file__Z_whl_direxistsZadd_dll_directoryenvironr^   pathseppZ
fiona._envr   r   r   r   r	   Zfiona._show_versionsr
   Zfiona.collectionr   r   Zfiona.drvsupportr   Z	fiona.envr   r   Zfiona.errorsr   Zfiona.ior   Zfiona.modelr   r   r   Zfiona.ogrextr   r   r   r   r   r   Z
fiona.pathr   r   r   Z	fiona.vfsr   rM   Zfionar   r    r!   uuid__all____version__Z__gdal_version__Zgdal_version	getLogger__name__rb   
addHandlerNullHandlerr%   rU   r(   r$   r#   r'   r&   rd   r"   r;   r;   r;   r<   <module>   st   
 
           d)
6