Ë
    ¹ûàgy"  ã                   óÆ   — 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y)é    )ÚbyrefÚc_double)ÚGDALBase)ÚEnvelopeÚOGREnvelope)ÚGDALExceptionÚSRSException)ÚFeature)ÚOGRFieldTypes)ÚOGRGeometry)ÚOGRGeomType)Úds)Úgeom)Úsrs)ÚSpatialReference)Úforce_bytesÚ	force_strc                   ó  — 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y)ÚLayerza
    A class that wraps an OGR Layer, needs to be instantiated from a DataSource
    object.
    c                 ó®   — |st        d«      ‚|| _        || _        t        j                  | j
                  «      | _        | j                  d«      | _        y)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      ú[/var/www/skyplay_api_hub/venv/lib/python3.12/site-packages/django/contrib/gis/gdal/layer.pyÚ__init__zLayer.__init__   sJ   € ñ ÜÐ LÓMÐMØˆŒØˆŒÜ×)Ñ)¨$¯)©)Ó4ˆŒà ×0Ñ0°Ó?ˆÕó    c                 ó6  — t        |t        «      r!|dk  rt        d«      ‚| j                  |«      S t        |t        «      rI|j                  | j                  «      \  }}}t        |||«      D �cg c]  }| j                  |«      ‘Œ c}S t        d«      ‚c c}w )z'Get the Feature at the specified index.r   z/Negative indices are not allowed on OGR Layers.z>Integers and slices may only be used when indexing OGR Layers.)	Ú
isinstanceÚintÚ
IndexErrorÚ_make_featureÚsliceÚindicesÚnum_featÚrangeÚ	TypeError)r   ÚindexÚstartÚstopÚstrideÚfids         r!   Ú__getitem__zLayer.__getitem__*   s�   € ä�eœSÔ!ð �qŠyÜ Ð!RÓSÐSØ×%Ñ% eÓ,Ð,Ü˜œuÔ%à"'§-¡-°·±Ó">ÑˆE�4˜Ü7<¸UÀDÈ&Ó7QÖR°�D×&Ñ& sÕ+ÒRÐRäØPóð ùò Ss   Á0Bc              #   óÔ   K  — t        j                  | j                  «       t        | j                  «      D ]-  }t        t        j                  | j                  «      | «      –— Œ/ y­w)z'Iterate over each Feature in the Layer.N)r   Úreset_readingr   r,   r+   r
   Úget_next_feature©r   Úis     r!   Ú__iter__zLayer.__iter__<   sP   è ø€ ô 	×Ñ˜4Ÿ9™9Ô%Ü�t—}‘}Ó%ò 	BˆAÜœ$×/Ñ/°·	±	Ó:¸DÓAÓAñ	Bùs   ‚A&A(c                 ó   — | j                   S )z%The length is the number of features.)r+   ©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‰yÐr#   c                 óÞ   — | j                   r+	 t        t        j                  | j                  |«      | «      S | D ]  }|j                  |k(  sŒ|c S  t        d|z  «      ‚# t
        $ r Y Œw xY w)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   r2   r'   )r   Úfeat_idÚfeats      r!   r(   zLayer._make_featureK   sy   € ð ×ÒðÜœt×/Ñ/°·±¸'ÓBÀDÓIÐIð ò  �Ø—8‘8˜wÓ&Ø’Kð ô Ð2°WÑ<Ó=Ð=øô !ò Ùðús   Ž)A  Á 	A,Á+A,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   s-   € ô ‹mˆÜ�‰˜Ÿ™¤%¨£*¨aÔ0Ü˜‹}Ðr#   c                 ó„   — 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   r>   s     r!   r>   z
Layer.namei   s1   € ô ×Ñ §¡Ó,ˆÜ˜˜tŸx™x×0Ñ0¸tÔDÐDr#   c                 óB   — t        j                  | j                  |«      S )z+Return the number of features in the Layer.)r   Úget_feature_countr   )r   Úforces     r!   r+   zLayer.num_feato   s   € ô ×%Ñ% d§h¡h°Ó6Ð6r#   c                 ó@   — 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¡KÓ0Ð0r#   c                 óR   — 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Ñ0°·±Ó=Ó>Ð>r#   c                 óœ   — 	 t        j                  | j                  «      }t        t	        j
                  |«      «      S # t        $ r Y y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~   sC   € ð	Ü×$Ñ$ T§X¡XÓ.ˆCÜ#¤G×$5Ñ$5°cÓ$:Ó;Ð;øÜò 	Ùð	ús   ‚<? ¿	AÁ
Ac                 óô   — t        | j                  «      D �cg c]U  }t        t        j                  t        j
                  | j                  |«      «      | j                  j                  d¬«      ‘ŒW c}S c c}w )zt
        Return a list of string names corresponding to each of the Fields
        available in this Layer.
        TrJ   )	r,   rS   r   r   Úget_field_nameÚget_field_defnr   r   rM   r7   s     r!   ÚfieldszLayer.fields‡   sc   € ô ˜4Ÿ?™?Ó+ö
ð ô Ü×#Ñ#¤D×$7Ñ$7¸¿¹ÀQÓ$GÓHØ—‘×!Ñ!Ø!öò
ð 	
ùò 
s   ˜AA5c           
      óÂ   — t        | j                  «      D �cg c]<  }t        t        j                  t        j
                  | j                  |«      «         ‘Œ> c}S c c}w )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.
        )r,   rS   r   r   Úget_field_typer]   r   r7   s     r!   Úfield_typeszLayer.field_types–   sN   € ô ˜4Ÿ?™?Ó+ö
àô œ$×-Ñ-¬d×.AÑ.AÀ$Ç+Á+ÈqÓ.QÓRÓSò
ð 	
ùò 
s   ˜AAc           	      ó´   — t        | j                  «      D �cg c]5  }t        j                  t        j                  | j
                  |«      «      ‘Œ7 c}S c c}w )z;Return a list of the maximum field widths for the features.)r,   rS   r   Úget_field_widthr]   r   r7   s     r!   Úfield_widthszLayer.field_widths¢   sI   € ô
 ˜4Ÿ?™?Ó+ö
àô × Ñ ¤×!4Ñ!4°T·[±[À!Ó!DÕEò
ð 	
ùò 
ó   ˜:Ac           	      ó´   — t        | j                  «      D �cg c]5  }t        j                  t        j                  | j
                  |«      «      ‘Œ7 c}S c c}w )z-Return the field precisions for the features.)r,   rS   r   Úget_field_precisionr]   r   r7   s     r!   Úfield_precisionszLayer.field_precisionsª   sI   € ô
 ˜4Ÿ?™?Ó+ö
àô ×$Ñ$¤T×%8Ñ%8¸¿¹ÀaÓ%HÕIò
ð 	
ùò 
re   c                 ó˜   — 	 t        t        j                  t        j                  | j
                  «      «      «      S # t        $ r Y y w xY w)N)r   Úgeom_apiÚ
clone_geomr   Úget_spatial_filterr   r   r;   s    r!   Ú_get_spatial_filterzLayer._get_spatial_filter²   s>   € ð	Üœx×2Ñ2´4×3JÑ3JÈ4Ï8É8Ó3TÓUÓVÐVøÜò 	Ùð	ús   ‚:= ½	A	ÁA	c                 ó¤  — t        |t        «      r+t        j                  | j                  |j                  «       y t        |t
        t        f«      rRt        |«      dk(  st        d«      ‚t        t        |«      \  }}}}t        j                  | j                  ||||«       y |€!t        j                  | j                  d «       y 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_rectr-   )r   ÚfilterÚxminÚyminÚxmaxÚymaxs         r!   Ú_set_spatial_filterzLayer._set_spatial_filter¸   s¦   € Ü�fœkÔ*Ü×#Ñ# D§H¡H¨f¯j©jÕ9Ü˜¤¬ Ô.Ü�v“; !Ò#Ü Ð!RÓSÐSô &)¬°6Ó%:Ñ"ˆD�$˜˜dÜ×(Ñ(¨¯©°4¸¸tÀTÕJØˆ^Ü×#Ñ# D§H¡H¨dÕ3äðóð r#   c                 ó‚   — || j                   vrt        d|z  «      ‚| D �cg c]  }|j                  |«      ‘Œ c}S c c}w )zg
        Return a list containing the given field name for every Feature
        in the Layer.
        zinvalid field name: %s)r^   r   Úget)r   Ú
field_namerC   s      r!   Ú
get_fieldszLayer.get_fieldsÍ   s>   € ð
 ˜TŸ[™[Ñ(ÜÐ 8¸:Ñ EÓFÐFØ15Ö6¨�—‘˜Õ$Ò6Ð6ùÒ6s   ¡<c                 ó®   — |r0ddl m} | D �cg c]  } ||j                  j                  «      ‘Œ  c}S | D �cg c]  }|j                  ‘Œ c}S c c}w c c}w )zb
        Return a list containing the OGRGeometry for every Feature in
        the Layer.
        r   )ÚGEOSGeometry)Údjango.contrib.gis.geosr‚   r   Úwkb)r   Úgeosr‚   rC   s       r!   Ú	get_geomszLayer.get_geomsÖ   sF   € ñ
 Ý<à<@ÖA°D‘L §¡§¡Õ/ÒAÐAà*.Ö/ $�D—I“IÒ/Ð/ùò Bùâ/s
   �#A·Ac                 óf   — 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ÓKÓLÐLr#   N)rE   )F)Ú__name__Ú
__module__Ú__qualname__Ú__doc__r"   r3   r9   r<   r?   r(   ÚpropertyrH   r>   r+   rS   rV   r   r^   ra   rd   rh   rm   r|   Úspatial_filterr€   r†   r   © r#   r!   r   r      s  „ ñò
@òò$Bòòò>ð. ñó ðð ñEó ðEð
 ò7ó ð7ð ñ1ó ð1ð ñ?ó ð?ð ñó ðð ñ
ó ð
ð ñ	
ó ð	
ð ñ
ó ð
ð ñ
ó ð
òòñ$ Ð1Ð3FÓG€Nò7ó
0ó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   rj   r   rY   Údjango.contrib.gis.gdal.srsr   Údjango.utils.encodingr   r   r   r�   r#   r!   ú<module>rœ      s<   ðß "å 1ß Bß EÝ 3Ý 7Ý :Ý 8Ý 9Ý ?Ý =Ý 8ß 8ôUMˆHõ UMr#   