ó
    µRjy"  ã                   óÆ   • S SK JrJr  S SKJr  S SKJrJr  S SKJ	r	J
r
  S SKJr  S SKJr  S SKJr  S SKJr  S S	KJr  S S
KJr  S SKJr  S SKJr  S SKJrJr   " S S\5      rg)é    )ÚbyrefÚc_double)ÚGDALBase)ÚEnvelopeÚOGREnvelope)ÚGDALExceptionÚSRSException)ÚFeature)ÚOGRFieldTypes)ÚOGRGeometry)ÚOGRGeomType)Úds)Úgeom)Úsrs)ÚSpatialReference)Úforce_bytesÚ	force_strc                   ó  • \ rS rSrSrS rS rS rS rS r	S r
\S	 5       r\S
 5       r\SS j5       r\S 5       r\S 5       r\S 5       r\S 5       r\S 5       r\S 5       r\S 5       rS rS r\" \\5      rS rSS jrS rSrg)ÚLayeré   zU
A class that wraps an OGR Layer, needs to be instantiated from a DataSource
object.
c                 ó¶   • U(       d  [        S5      eXl        X l        [        R                  " U R
                  5      U l        U R                  S5      U l        g)a  
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      ÚID:\diplom_project\venv\Lib\site-packages\django/contrib/gis/gdal/layer.pyÚ__init__ÚLayer.__init__   sF   € ö ÜÐ LÓMÐMØŒØŒÜ×)Ò)¨$¯)©)Ó4ˆŒà ×0Ñ0°Ó?ˆÕó    c                 óL  • [        U[        5      (       a"  US:  a  [        S5      eU R                  U5      $ [        U[        5      (       aI  UR                  U R                  5      u  p#n[        X#U5       Vs/ s H  oPR                  U5      PM     sn$ [        S5      es  snf )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__ÚLayer.__getitem__*   s–   € ä�eœS×!Ñ!ð �q‹yÜ Ð!RÓSÐSØ×%Ñ% eÓ,Ð,Ü˜œu×%Ñ%à"'§-¡-°·±Ó">ÑˆE˜Ü7<¸UÈ&Ô7QÓRÒ7Q°×&Ñ& sÖ+Ñ7QÑRÐRäØPóð ùò Ss   Á9B!c              #   óÜ   #   • [         R                  " U R                  5        [        U R                  5       H/  n[        [         R                  " U R                  5      U 5      v •  M1     g7f)z'Iterate over each Feature in the Layer.N)r   Úreset_readingr   r.   r-   r
   Úget_next_feature©r    Úis     r"   Ú__iter__ÚLayer.__iter__<   sH   é € ô 	×Ò˜4Ÿ9™9Ô%Ü�t—}‘}Ö%ˆAÜœ$×/Ò/°·	±	Ó:¸DÓAÔAò &ùs   ‚A*A,c                 ó   • U R                   $ )z%The length is the number of features.)r-   ©r    s    r"   Ú__len__ÚLayer.__len__C   s   € à�}‰}Ðr%   c                 ó   • U R                   $ )zThe string name of the layer.)Únamer?   s    r"   Ú__str__ÚLayer.__str__G   s   € à�y‰yÐr%   c                 óò   • U R                   (       a,   [        [        R                  " U R                  U5      U 5      $ U  H  nUR                  U:X  d  M  Us  $    [        SU-  5      e! [
         a     Nf = f)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   r4   r)   )r    Úfeat_idÚfeats      r"   r*   ÚLayer._make_featureK   st   € ð ××ðÜœt×/Ò/°·±¸'ÓBÀDÓIÐIó �Ø—8‘8˜wÕ&Ø’Kñ ô Ð2°WÑ<Ó=Ð=øô !ó Ùðús   “*A) Á)
A6Á5A6c                 ó‚   • [        5       n[        R                  " U R                  [	        U5      S5        [        U5      $ )z.Return the extent (an Envelope) of this layer.é   )r   r   Ú
get_extentr   r   r   )r    Úenvs     r"   ÚextentÚLayer.extentb   s-   € ô ‹mˆÜ�Š˜Ÿ™¤%¨£*¨aÔ0Ü˜‹}Ðr%   c                 ó~   • [         R                  " U R                  5      n[        XR                  R
                  SS9$ )z1Return the name of this layer in the Data Source.T©Ústrings_only)r   Úget_fd_namer   r   r   Úencoding)r    rC   s     r"   rC   Ú
Layer.namei   s/   € ô ×Ò §¡Ó,ˆÜ˜Ÿx™x×0Ñ0¸tÑDÐDr%   c                 óD   • [         R                  " U R                  U5      $ )z+Return the number of features in the Layer.)r   Úget_feature_countr   )r    Úforces     r"   r-   ÚLayer.num_feato   s   € ô ×%Ò% d§h¡h°Ó6Ð6r%   c                 óB   • [         R                  " U R                  5      $ )z)Return the number of fields in the Layer.)r   Úget_field_countr   r?   s    r"   Ú
num_fieldsÚLayer.num_fieldst   s   € ô ×#Ò# D§K¡KÓ0Ð0r%   c                 óT   • [        [        R                  " U R                  5      5      $ )z4Return the geometry type (OGRGeomType) of the Layer.)r   r   Úget_fd_geom_typer   r?   s    r"   Ú	geom_typeÚLayer.geom_typey   s   € ô œ4×0Ò0°·±Ó=Ó>Ð>r%   c                 ó¢   •  [         R                  " U R                  5      n[        [        R
                  " U5      5      $ ! [         a     gf = f)z0Return the Spatial Reference used in this Layer.N)r   Úget_layer_srsr   r   Úsrs_apiÚ	clone_srsr	   )r    r   s     r"   r   Ú	Layer.srs~   sC   € ð	Ü×$Ò$ T§X¡XÓ.ˆCÜ#¤G×$5Ò$5°cÓ$:Ó;Ð;øÜó 	Ùð	ús   ‚>A Á
AÁAc                 óø   • [        U R                  5       Vs/ s HU  n[        [        R                  " [        R
                  " U R                  U5      5      U R                  R                  SS9PMW     sn$ s  snf )z\
Return a list of string names corresponding to each of the Fields
available in this Layer.
TrR   )	r.   r]   r   r   Úget_field_nameÚget_field_defnr   r   rU   r:   s     r"   ÚfieldsÚLayer.fields‡   sj   € ô ˜4Ÿ?™?Ô+ó
ò ,�ô Ü×#Ò#¤D×$7Ò$7¸¿¹ÀQÓ$GÓHØ—‘×!Ñ!Ø!ôñ
 ,ñ
ð 	
ùò 
s   ˜AA7c           
      óÌ   • [        U R                  5       Vs/ s H?  n[        [        R                  " [        R
                  " U R                  U5      5         PMA     sn$ s  snf )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.   r]   r   r   Úget_field_typerj   r   r:   s     r"   Úfield_typesÚLayer.field_types–   sS   € ô ˜4Ÿ?™?Ô+ó
â+�ô œ$×-Ò-¬d×.AÒ.AÀ$Ç+Á+ÈqÓ.QÓRÔSÙ+ñ
ð 	
ùò 
s   ˜AA!c           	      ó¾   • [        U R                  5       Vs/ s H8  n[        R                  " [        R                  " U R
                  U5      5      PM:     sn$ s  snf )z;Return a list of the maximum field widths for the features.)r.   r]   r   Úget_field_widthrj   r   r:   s     r"   Úfield_widthsÚLayer.field_widths¢   sN   € ô
 ˜4Ÿ?™?Ô+ó
â+�ô × Ò ¤×!4Ò!4°T·[±[À!Ó!DÖEÙ+ñ
ð 	
ùò 
ó   ˜?Ac           	      ó¾   • [        U R                  5       Vs/ s H8  n[        R                  " [        R                  " U R
                  U5      5      PM:     sn$ s  snf )z-Return the field precisions for the features.)r.   r]   r   Úget_field_precisionrj   r   r:   s     r"   Úfield_precisionsÚLayer.field_precisionsª   sN   € ô
 ˜4Ÿ?™?Ô+ó
â+�ô ×$Ò$¤T×%8Ò%8¸¿¹ÀaÓ%HÖIÙ+ñ
ð 	
ùò 
ru   c                 óž   •  [        [        R                  " [        R                  " U R
                  5      5      5      $ ! [         a     g f = f)N)r   Úgeom_apiÚ
clone_geomr   Úget_spatial_filterr   r   r?   s    r"   Ú_get_spatial_filterÚLayer._get_spatial_filter²   s>   € ð	Üœx×2Ò2´4×3JÒ3JÈ4Ï8É8Ó3TÓUÓVÐVøÜó 	Ùð	ús   ‚<? ¿
AÁAc                 óº  • [        U[        5      (       a,  [        R                  " U R                  UR                  5        g [        U[
        [        45      (       aP  [        U5      S:X  d  [        S5      e[        [        U5      u  p#pE[        R                  " U R                  X#XE5        g Uc"  [        R                  " U R                  S 5        g [        S5      e)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_filterÚLayer._set_spatial_filter¸   s¤   € Ü�fœk×*Ñ*Ü×#Ò# D§H¡H¨f¯j©jÕ9Ü˜¤¬ ×.Ñ.Ü�v“; !Ó#Ü Ð!RÓSÐSô &)¬°6Ó%:Ñ"ˆD˜Ü×(Ò(¨¯©°4¸tÕJØ‰^Ü×#Ò# D§H¡H¨dÕ3äðóð r%   c                 óˆ   • XR                   ;  a  [        SU-  5      eU  Vs/ s H  o"R                  U5      PM     sn$ s  snf )zO
Return a list containing the given field name for every Feature
in the Layer.
zinvalid field name: %s)rk   r   Úget)r    Ú
field_namerI   s      r"   Ú
get_fieldsÚLayer.get_fieldsÍ   s>   € ð
 Ÿ[™[Ó(ÜÐ 8¸:Ñ EÓFÐFÙ15Ó6²¨—‘˜Ö$±Ñ6Ð6ùÒ6s   ¢?c                 óÀ   • U(       a2  SSK Jn  U  Vs/ s H  o2" UR                  R                  5      PM      sn$ U  Vs/ s H  o3R                  PM     sn$ s  snf s  snf )zJ
Return a list containing the OGRGeometry for every Feature in
the Layer.
r   )ÚGEOSGeometry)Údjango.contrib.gis.geosr–   r   Úwkb)r    Úgeosr–   rI   s       r"   Ú	get_geomsÚLayer.get_geomsÖ   sL   € ö
 Ý<á<@ÓAºD°D�L §¡§¡Ö/¹DÑAÐAá*.Ó/ª$ $—I”I©$Ñ/Ð/ùò Bùâ/s
   ’%A¾Ac                 óh   • [        [        R                  " U R                  [	        U5      5      5      $ )a8  
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   ÚLayer.test_capabilityâ   s%   € ô ”D×(Ò(¨¯©´;¸zÓ3JÓKÓLÐLr%   )r   r   r   r   N)rL   )F)Ú__name__Ú
__module__Ú__qualname__Ú__firstlineno__Ú__doc__r#   r5   r<   r@   rD   r*   ÚpropertyrO   rC   r-   r]   ra   r   rk   ro   rs   rx   r~   rŽ   Úspatial_filterr“   rš   r   Ú__static_attributes__© 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   r{   r   re   Ú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%   