§
    ¤”jy"  ã                   óÎ   — d dl mZmZ d dlm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 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 )é    )ÚbyrefÚc_double)ÚGDALBase)ÚEnvelopeÚOGREnvelope)ÚGDALExceptionÚSRSException)ÚFeature)ÚOGRFieldTypes)ÚOGRGeometry)ÚOGRGeomType)Úds©Úgeom)Úsrs)ÚSpatialReference)Úforce_bytesÚ	force_strc                   óL  — e Zd ZdZd„ Zd„ Zd„ Zd„ Zd„ Zd„ Z	e
d„ ¦   «         Ze
d	„ ¦   «         Ze
dd„¦   «         Ze
d„ ¦   «         Ze
d„ ¦   «         Ze
d„ ¦   «         Ze
d„ ¦   «         Ze
d„ ¦   «         Ze
d„ ¦   «         Ze
d„ ¦   «         Zd„ Zd„ Z e
ee¦  «        Zd„ Zdd„Zd„ ZdS )ÚLayerza
    A class that wraps an OGR Layer, needs to be instantiated from a DataSource
    object.
    c                 ó´   — |st          d¦  «        ‚|| _        || _        t          j        | j        ¦  «        | _        |                      d¦  «        | _        dS )a7  
        Initialize on an OGR C pointer to the Layer and the `DataSource` object
        that owns this layer.  The `DataSource` object is required so that a
        reference to it is kept with this Layer.  This prevents garbage
        collection of the `DataSource` while this Layer is still active.
        z*Cannot create Layer, invalid pointer givens
   RandomReadN)	r   ÚptrÚ_dsÚcapiÚget_layer_defnÚ_ptrÚ_ldefnÚtest_capabilityÚ_random_read)ÚselfÚ	layer_ptrr   s      úl/var/www/finuniver-perm.ru/html/portfolio/venv/lib/python3.11/site-packages/django/contrib/gis/gdal/layer.pyÚ__init__zLayer.__init__   sZ   € ð ð 	NÝÐ LÑMÔMÐMØˆŒØˆŒÝÔ)¨$¬)Ñ4Ô4ˆŒà ×0Ò0°Ñ?Ô?ˆÔÐÐó    c                 ó@  ‡ — t          |t          ¦  «        r*|dk     rt          d¦  «        ‚‰                      |¦  «        S t          |t          ¦  «        r;|                     ‰ j        ¦  «        \  }}}ˆ fd„t          |||¦  «        D ¦   «         S t          d¦  «        ‚)z'Get the Feature at the specified index.r   z/Negative indices are not allowed on OGR Layers.c                 ó:   •— g | ]}‰                      |¦  «        ‘ŒS © )Ú_make_feature)Ú.0Úfidr    s     €r"   ú
<listcomp>z%Layer.__getitem__.<locals>.<listcomp>6   s'   ø€ ÐRÐRÐR°�D×&Ò& sÑ+Ô+ÐRÐRÐRr$   z>Integers and slices may only be used when indexing OGR Layers.)	Ú
isinstanceÚintÚ
IndexErrorr(   ÚsliceÚindicesÚnum_featÚrangeÚ	TypeError)r    ÚindexÚstartÚstopÚstrides   `    r"   Ú__getitem__zLayer.__getitem__*   sª   ø€ å�e�SÑ!Ô!ð 	ð �qŠyˆyÝ Ð!RÑSÔSÐSØ×%Ò% eÑ,Ô,Ð,Ý˜�uÑ%Ô%ð 	à"'§-¢-°´Ñ">Ô">ÑˆE�4˜ØRÐRÐRÐRµu¸UÀDÈ&Ñ7QÔ7QÐRÑRÔRÐRåØPñô ð r$   c              #   ó¼   K  — t          j        | j        ¦  «         t          | j        ¦  «        D ]+}t          t          j        | j        ¦  «        | ¦  «        V — Œ,dS )z'Iterate over each Feature in the Layer.N)r   Úreset_readingr   r2   r1   r
   Úget_next_feature)r    Úis     r"   Ú__iter__zLayer.__iter__<   sh   è è € õ 	Ô˜4œ9Ñ%Ô%Ð%Ý�t”}Ñ%Ô%ð 	Bð 	BˆAÝ�$Ô/°´	Ñ:Ô:¸DÑAÔAÐAÐAÐAÐAð	Bð 	Br$   c                 ó   — | j         S )z%The length is the number of features.)r1   ©r    s    r"   Ú__len__zLayer.__len__C   s
   € àŒ}Ðr$   c                 ó   — | j         S )zThe string name of the layer.)Únamer?   s    r"   Ú__str__zLayer.__str__G   s
   € àŒyÐr$   c                 óÎ   — | j         r9	 t          t          j        | j        |¦  «        | ¦  «        S # t
          $ r Y nw xY w| D ]}|j        |k    r|c S Œt          d|z  ¦  «        ‚)a.  
        Helper routine for __getitem__ that constructs a Feature from the given
        Feature ID.  If the OGR Layer does not support random-access reading,
        then each feature of the layer will be incremented through until the
        a Feature is found matching the given feature ID.
        zInvalid feature id: %s.)r   r
   r   Úget_featurer   r   r*   r.   )r    Úfeat_idÚfeats      r"   r(   zLayer._make_featureK   s•   € ð Ôð 	 ðÝ�tÔ/°´¸'ÑBÔBÀDÑIÔIÐIøÝ ð ð ð Ø�ðøøøð
 ð  ð  �Ø”8˜wÒ&Ð&Ø�K�K�Kð 'õ Ð2°WÑ<Ñ=Ô=Ð=s   ‰'1 ±
>½>c                 óŒ   — t          ¦   «         }t          j        | j        t	          |¦  «        d¦  «         t          |¦  «        S )z.Return the extent (an Envelope) of this layer.é   )r   r   Ú
get_extentr   r   r   )r    Úenvs     r"   ÚextentzLayer.extentb   s5   € õ ‰mŒmˆÝŒ˜œ¥%¨¡*¤*¨aÑ0Ô0Ð0Ý˜‰}Œ}Ðr$   c                 ól   — t          j        | j        ¦  «        }t          || j        j        d¬¦  «        S )z1Return the name of this layer in the Data Source.T©Ústrings_only)r   Úget_fd_namer   r   r   Úencoding)r    rB   s     r"   rB   z
Layer.namei   s0   € õ Ô ¤Ñ,Ô,ˆÝ˜˜tœxÔ0¸tÐDÑDÔDÐDr$   rI   c                 ó6   — t          j        | j        |¦  «        S )z+Return the number of features in the Layer.)r   Úget_feature_countr   )r    Úforces     r"   r1   zLayer.num_feato   s   € õ Ô% d¤h°Ñ6Ô6Ð6r$   c                 ó4   — t          j        | j        ¦  «        S )z)Return the number of fields in the Layer.)r   Úget_field_countr   r?   s    r"   Ú
num_fieldszLayer.num_fieldst   s   € õ Ô# D¤KÑ0Ô0Ð0r$   c                 óN   — t          t          j        | j        ¦  «        ¦  «        S )z4Return the geometry type (OGRGeomType) of the Layer.)r   r   Úget_fd_geom_typer   r?   s    r"   Ú	geom_typezLayer.geom_typey   s   € õ �4Ô0°´Ñ=Ô=Ñ>Ô>Ð>r$   c                 óš   — 	 t          j        | j        ¦  «        }t          t	          j        |¦  «        ¦  «        S # t          $ r Y dS w xY w)z0Return the Spatial Reference used in this Layer.N)r   Úget_layer_srsr   r   Úsrs_apiÚ	clone_srsr	   )r    r   s     r"   r   z	Layer.srs~   sT   € ð	ÝÔ$ T¤XÑ.Ô.ˆCÝ#¥GÔ$5°cÑ$:Ô$:Ñ;Ô;Ð;øÝð 	ð 	ð 	Ø�4�4ð	øøøs   ‚9< ¼
A
Á	A
c                 óD   ‡ — ˆ fd„t          ‰ j        ¦  «        D ¦   «         S )zt
        Return a list of string names corresponding to each of the Fields
        available in this Layer.
        c           
      óœ   •— g | ]H}t          t          j        t          j        ‰j        |¦  «        ¦  «        ‰j        j        d ¬¦  «        ‘ŒIS )TrN   )r   r   Úget_field_nameÚget_field_defnr   r   rQ   ©r)   r<   r    s     €r"   r+   z Layer.fields.<locals>.<listcomp>�   sb   ø€ ð 
ð 
ð 
ð õ ÝÔ#¥DÔ$7¸¼ÀQÑ$GÔ$GÑHÔHØ”Ô!Ø!ðñ ô ð
ð 
ð 
r$   ©r2   rW   r?   s   `r"   ÚfieldszLayer.fields‡   s:   ø€ ð
ð 
ð 
ð 
õ ˜4œ?Ñ+Ô+ð
ñ 
ô 
ð 	
r$   c                 óD   ‡ — ˆ fd„t          ‰ j        ¦  «        D ¦   «         S )zß
        Return a list of the types of fields in this Layer.  For example,
        return the list [OFTInteger, OFTReal, OFTString] for an OGR layer that
        has an integer, a floating-point, and string fields.
        c           	      ó~   •— g | ]9}t           t          j        t          j        ‰j        |¦  «        ¦  «                 ‘Œ:S r'   )r   r   Úget_field_typerb   r   rc   s     €r"   r+   z%Layer.field_types.<locals>.<listcomp>�   sH   ø€ ð 
ð 
ð 
àõ �$Ô-­dÔ.AÀ$Ä+ÈqÑ.QÔ.QÑRÔRÔSð
ð 
ð 
r$   rd   r?   s   `r"   Úfield_typeszLayer.field_types–   s8   ø€ ð
ð 
ð 
ð 
å˜4œ?Ñ+Ô+ð
ñ 
ô 
ð 	
r$   c                 óD   ‡ — ˆ fd„t          ‰ j        ¦  «        D ¦   «         S )z;Return a list of the maximum field widths for the features.c                 óh   •— g | ].}t          j        t          j        ‰j        |¦  «        ¦  «        ‘Œ/S r'   )r   Úget_field_widthrb   r   rc   s     €r"   r+   z&Layer.field_widths.<locals>.<listcomp>¥   sC   ø€ ð 
ð 
ð 
àõ Ô ¥Ô!4°T´[À!Ñ!DÔ!DÑEÔEð
ð 
ð 
r$   rd   r?   s   `r"   Úfield_widthszLayer.field_widths¢   ó8   ø€ ð
ð 
ð 
ð 
å˜4œ?Ñ+Ô+ð
ñ 
ô 
ð 	
r$   c                 óD   ‡ — ˆ fd„t          ‰ j        ¦  «        D ¦   «         S )z-Return the field precisions for the features.c                 óh   •— g | ].}t          j        t          j        ‰j        |¦  «        ¦  «        ‘Œ/S r'   )r   Úget_field_precisionrb   r   rc   s     €r"   r+   z*Layer.field_precisions.<locals>.<listcomp>­   sC   ø€ ð 
ð 
ð 
àõ Ô$¥TÔ%8¸¼ÀaÑ%HÔ%HÑIÔIð
ð 
ð 
r$   rd   r?   s   `r"   Úfield_precisionszLayer.field_precisionsª   rn   r$   c                 ó–   — 	 t          t          j        t          j        | j        ¦  «        ¦  «        ¦  «        S # t          $ r Y d S w xY w)N)r   Úgeom_apiÚ
clone_geomr   Úget_spatial_filterr   r   r?   s    r"   Ú_get_spatial_filterzLayer._get_spatial_filter²   sO   € ð	Ý�xÔ2µ4Ô3JÈ4Ì8Ñ3TÔ3TÑUÔUÑVÔVÐVøÝð 	ð 	ð 	Ø�4�4ð	øøøs   ‚7: º
AÁAc                 ó¶  — t          |t          ¦  «        r!t          j        | j        |j        ¦  «         d S t          |t
          t          f¦  «        r[t          |¦  «        dk    st          d¦  «        ‚t          t          |¦  «        \  }}}}t          j        | j        ||||¦  «         d S |€t          j        | j        d ¦  «         d S t          d¦  «        ‚)Né   z/Spatial filter list/tuple must have 4 elements.zJSpatial filter must be either an OGRGeometry instance, a 4-tuple, or None.)r,   r   r   Úset_spatial_filterr   ÚtupleÚlistÚlenÚ
ValueErrorÚmapr   Úset_spatial_filter_rectr3   )r    ÚfilterÚxminÚyminÚxmaxÚymaxs         r"   Ú_set_spatial_filterzLayer._set_spatial_filter¸   sÙ   € Ý�f�kÑ*Ô*ð 	ÝÔ# D¤H¨f¬jÑ9Ô9Ð9Ð9Ð9Ý˜¥­ Ñ.Ô.ð 	Ý�v‘;”; !Ò#Ð#Ý Ð!RÑSÔSÐSõ &)­°6Ñ%:Ô%:Ñ"ˆD�$˜˜dÝÔ(¨¬°4¸¸tÀTÑJÔJÐJÐJÐJØˆ^ÝÔ# D¤H¨dÑ3Ô3Ð3Ð3Ð3åðñô ð r$   c                 óV   ‡— ‰| j         vrt          d‰z  ¦  «        ‚ˆfd„| D ¦   «         S )zg
        Return a list containing the given field name for every Feature
        in the Layer.
        zinvalid field name: %sc                 ó:   •— g | ]}|                      ‰¦  «        ‘ŒS r'   )Úget)r)   rG   Ú
field_names     €r"   r+   z$Layer.get_fields.<locals>.<listcomp>Ô   s%   ø€ Ð6Ð6Ð6¨�—’˜Ñ$Ô$Ð6Ð6Ð6r$   )re   r   )r    rŠ   s    `r"   Ú
get_fieldszLayer.get_fieldsÍ   s@   ø€ ð
 ˜Tœ[Ð(Ð(ÝÐ 8¸:Ñ EÑFÔFÐFØ6Ð6Ð6Ð6°Ð6Ñ6Ô6Ð6r$   Fc                 óH   ‡— |rddl mŠ ˆfd„| D ¦   «         S d„ | D ¦   «         S )zb
        Return a list containing the OGRGeometry for every Feature in
        the Layer.
        r   )ÚGEOSGeometryc                 ó:   •— g | ]} ‰|j         j        ¦  «        ‘ŒS r'   )r   Úwkb)r)   rG   r�   s     €r"   r+   z#Layer.get_geoms.<locals>.<listcomp>Þ   s'   ø€ ÐAÐAÐA°D�L�L ¤¤Ñ/Ô/ÐAÐAÐAr$   c                 ó   — g | ]	}|j         ‘Œ
S r'   r   )r)   rG   s     r"   r+   z#Layer.get_geoms.<locals>.<listcomp>à   s   € Ð/Ð/Ð/ $�D”IÐ/Ð/Ð/r$   )Údjango.contrib.gis.geosr�   )r    Úgeosr�   s     @r"   Ú	get_geomszLayer.get_geomsÖ   sM   ø€ ð
 ð 	0Ø<Ð<Ð<Ð<Ð<Ð<àAÐAÐAÐA¸DÐAÑAÔAÐAà/Ð/¨$Ð/Ñ/Ô/Ð/r$   c                 ój   — t          t          j        | j        t	          |¦  «        ¦  «        ¦  «        S )ah  
        Return a bool indicating whether the this Layer supports the given
        capability (a string).  Valid capability strings include:
          'RandomRead', 'SequentialWrite', 'RandomWrite', 'FastSpatialFilter',
          'FastFeatureCount', 'FastGetExtent', 'CreateField', 'Transactions',
          'DeleteFeature', and 'FastSetNextByIndex'.
        )Úboolr   r   r   r   )r    Ú
capabilitys     r"   r   zLayer.test_capabilityâ   s)   € õ •DÔ(¨¬µ;¸zÑ3JÔ3JÑKÔKÑLÔLÐLr$   N)rI   )F)Ú__name__Ú
__module__Ú__qualname__Ú__doc__r#   r8   r=   r@   rC   r(   ÚpropertyrL   rB   r1   rW   rZ   r   re   ri   rm   rr   rw   r†   Úspatial_filterr‹   r“   r   r'   r$   r"   r   r      sþ  € € € € € ðð ð
@ð @ð @ðð ð ð$Bð Bð Bðð ð ðð ð ð>ð >ð >ð. ðð ñ „Xðð ðEð Eñ „XðEð
 ð7ð 7ð 7ñ „Xð7ð ð1ð 1ñ „Xð1ð ð?ð ?ñ „Xð?ð ðð ñ „Xðð ð
ð 
ñ „Xð
ð ð	
ð 	
ñ „Xð	
ð ð
ð 
ñ „Xð
ð ð
ð 
ñ „Xð
ðð ð ðð ð ð$ �XÐ1Ð3FÑGÔG€Nð7ð 7ð 7ð
0ð 
0ð 
0ð 
0ðMð Mð Mð Mð Mr$   r   N) Úctypesr   r   Údjango.contrib.gis.gdal.baser   Ú django.contrib.gis.gdal.enveloper   r   Údjango.contrib.gis.gdal.errorr   r	   Údjango.contrib.gis.gdal.featurer
   Údjango.contrib.gis.gdal.fieldr   Ú"django.contrib.gis.gdal.geometriesr   Ú django.contrib.gis.gdal.geomtyper   Ú"django.contrib.gis.gdal.prototypesr   r   r   rt   r   r]   Údjango.contrib.gis.gdal.srsr   Údjango.utils.encodingr   r   r   r'   r$   r"   ú<module>r¨      sO  ðØ "Ð "Ð "Ð "Ð "Ð "Ð "Ð "à 1Ð 1Ð 1Ð 1Ð 1Ð 1Ø BÐ BÐ BÐ BÐ BÐ BÐ BÐ BØ EÐ EÐ EÐ EÐ EÐ EÐ EÐ EØ 3Ð 3Ð 3Ð 3Ð 3Ð 3Ø 7Ð 7Ð 7Ð 7Ð 7Ð 7Ø :Ð :Ð :Ð :Ð :Ð :Ø 8Ð 8Ð 8Ð 8Ð 8Ð 8Ø 9Ð 9Ð 9Ð 9Ð 9Ð 9Ø ?Ð ?Ð ?Ð ?Ð ?Ð ?Ø =Ð =Ð =Ð =Ð =Ð =Ø 8Ð 8Ð 8Ð 8Ð 8Ð 8Ø 8Ð 8Ð 8Ð 8Ð 8Ð 8Ð 8Ð 8ðUMð UMð UMð UMð UMˆHñ UMô UMð UMð UMð UMr$   