§
    Ÿj$  ã                   ó~   — d Z ddlmZ ddlmZ ddlmZ ddlmZ ddl	m
Z
 ddlmZ ddlmZmZ  G d	„ d
e¦  «        ZdS )a�  
DataSource is a wrapper for the OGR Data Source object, which provides
an interface for reading vector geometry data from many different file
formats (including ESRI shapefiles).

When instantiating a DataSource object, use the filename of a
GDAL-supported data source.  For example, a SHP file or a
TIGER/Line file from the government.

The ds_driver keyword is used internally when a ctypes pointer
is passed in directly.

Example:
 ds = DataSource('/home/foo/bar.shp')
 for layer in ds:
     for feature in layer:
         # Getting the geometry for the feature.
         g = feature.geom

         # Getting the 'description' field for the feature.
         desc = feature['description']

         # We can also increment through all of the fields
         #  attached to this feature.
         for field in feature:
             # Get the name of the field (e.g. 'description')
             nm = field.name

             # Get the type (integer) of the field, e.g. 0 => OFTInteger
             t = field.type

             # Returns the value the field; OFTIntegers return ints,
             #  OFTReal returns floats, all else returns string.
             val = field.value
é    )ÚPath)ÚGDALBase)ÚDriver)ÚGDALException)ÚLayer)Úds)Úforce_bytesÚ	force_strc                   óf   — e Zd ZdZej        Zdd„Zd„ Zd„ Z	d„ Z
ed„ ¦   «         Zed	„ ¦   «         Zd
S )Ú
DataSourcez Wraps an OGR Data Source object.Fúutf-8c                 óŠ  — |rt           j        nt           j        | _        || _        t          j        ¦   «          t          |t          t          f¦  «        rY	 t          j
        t          |¦  «        | j        t           j        z  d d d ¦  «        }nq# t          $ r t          d|z  ¦  «        ‚w xY wt          || j        ¦  «        rt          |t
          j        ¦  «        r|}nt          dt          |¦  «        z  ¦  «        ‚|r1|| _        t          j        |¦  «        }t          |¦  «        | _        d S t          d|z  ¦  «        ‚)Nz%Could not open the datasource at "%s"z"Invalid data source input type: %szInvalid data source file "%s")ÚcapiÚGDAL_OF_UPDATEÚGDAL_OF_READONLYÚ_writeÚencodingr   Úensure_registeredÚ
isinstanceÚstrr   Úopen_dsr	   ÚGDAL_OF_VECTORr   Úptr_typeÚtypeÚptrÚget_dataset_driverÚdriver)ÚselfÚds_inputÚ	ds_driverÚwriter   r   r   s          úo/var/www/finuniver-perm.ru/html/student/venv/lib/python3.11/site-packages/django/contrib/gis/gdal/datasource.pyÚ__init__zDataSource.__init__8   sQ  € à-2ÐM•dÔ)Ð)½Ô8MˆŒà ˆŒåÔ Ñ"Ô"Ð"å�h¥¥d Ñ,Ô,ð 	WðXå”\Ý Ñ)Ô)Ø”K¥$Ô"5Ñ5ØØØñô ��øõ !ð Xð Xð Xõ $Ð$KÈhÑ$VÑWÔWÐWðXøøøõ ˜ $¤-Ñ0Ô0ð 	WµZØ•v”ñ6
ô 6
ð 	Wð ˆBˆBåÐ DÅtÈHÁ~Ä~Ñ UÑVÔVÐVàð 	LØˆDŒHÝÔ,¨RÑ0Ô0ˆFÝ  ™.œ.ˆDŒKˆKˆKõ  Ð ?À(Ñ JÑKÔKÐKs   Á7B ÂB,c                 óÊ  — t          |t          ¦  «        rI	 t          j        | j        t          |¦  «        ¦  «        }n–# t          $ r t          d|z  ¦  «        ‚w xY wt          |t          ¦  «        rBd|cxk    r| j	        k     rn nt          j
        | j        |¦  «        }n1t          d|z  ¦  «        ‚t          dt          |¦  «        z  ¦  «        ‚t          || ¦  «        S )z@Allows use of the index [] operator to get a layer at the index.z!Invalid OGR layer name given: %s.r   z=Index out of range when accessing layers in a datasource: %s.zInvalid index type: %s)r   r   r   Úget_layer_by_namer   r	   r   Ú
IndexErrorÚintÚlayer_countÚ	get_layerÚ_ptrÚ	TypeErrorr   r   )r   ÚindexÚlayers      r"   Ú__getitem__zDataSource.__getitem__]   s  € å�e�SÑ!Ô!ð 	DðNÝÔ.¨t¬x½ÀUÑ9KÔ9KÑLÔL��øÝ ð Nð Nð NÝ Ð!DÀuÑ!LÑMÔMÐMðNøøøå˜�sÑ#Ô#ð 		DØ�EÐ,Ð,Ò,Ð,˜DÔ,Ò,Ð,Ð,Ð,Ð,Ýœ t¤y°%Ñ8Ô8��å ØSØññô ð õ
 Ð4µt¸E±{´{ÑBÑCÔCÐCÝ�U˜DÑ!Ô!Ð!s	   —'? ¿Ac                 ó   — | j         S )z3Return the number of layers within the data source.)r(   ©r   s    r"   Ú__len__zDataSource.__len__p   s   € àÔÐó    c                 ó&   — | j         ›d| j        ›d�S )z2Return OGR GetName and Driver for the Data Source.z (ú))Únamer   r0   s    r"   Ú__str__zDataSource.__str__t   s   € à œI˜I˜I t¤{ { {Ð3Ð3r2   c                 ó4   — t          j        | j        ¦  «        S )z/Return the number of layers in the data source.)r   Úget_layer_countr*   r0   s    r"   r(   zDataSource.layer_countx   s   € õ Ô# D¤IÑ.Ô.Ð.r2   c                 ób   — t          j        | j        ¦  «        }t          || j        d¬¦  «        S )z#Return the name of the data source.T)Ústrings_only)r   Úget_ds_namer*   r
   r   )r   r5   s     r"   r5   zDataSource.name}   s-   € õ Ô ¤	Ñ*Ô*ˆÝ˜˜tœ}¸4Ð@Ñ@Ô@Ð@r2   N)FFr   )Ú__name__Ú
__module__Ú__qualname__Ú__doc__r   Ú
destroy_dsÚ
destructorr#   r.   r1   r6   Úpropertyr(   r5   © r2   r"   r   r   3   s¢   € € € € € Ø&Ð&à”€Jð#Lð #Lð #Lð #LðJ"ð "ð "ð& ð  ð  ð4ð 4ð 4ð ð/ð /ñ „Xð/ð ðAð Añ „XðAð Að Ar2   r   N)r?   Úpathlibr   Údjango.contrib.gis.gdal.baser   Údjango.contrib.gis.gdal.driverr   Údjango.contrib.gis.gdal.errorr   Údjango.contrib.gis.gdal.layerr   Ú"django.contrib.gis.gdal.prototypesr   r   Údjango.utils.encodingr	   r
   r   rC   r2   r"   ú<module>rK      sÞ   ðð"ð "ðH Ð Ð Ð Ð Ð à 1Ð 1Ð 1Ð 1Ð 1Ð 1Ø 1Ð 1Ð 1Ð 1Ð 1Ð 1Ø 7Ð 7Ð 7Ð 7Ð 7Ð 7Ø /Ð /Ð /Ð /Ð /Ð /Ø 9Ð 9Ð 9Ð 9Ð 9Ð 9Ø 8Ð 8Ð 8Ð 8Ð 8Ð 8Ð 8Ð 8ðNAð NAð NAð NAð NA�ñ NAô NAð NAð NAð NAr2   