Ë
    øi¯e  ã                   ó‚   — 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 dd	lmZmZ  G d
„ de«      Zy)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
é    )Úbyref)ÚPath)ÚGDALBase)ÚDriver)ÚGDALException)ÚLayer)Úds)Úforce_bytesÚ	force_strc                   ób   — e Zd ZdZej
                  Zd	d„Zd„ Zd„ Z	d„ Z
ed„ «       Zed„ «       Zy)
Ú
DataSourcez Wraps an OGR Data Source object.c                 ó2  — |rd| _         nd| _         || _        t        j                  «        t	        |t
        t        f«      rIt        j                  «       }	 t        j                  t        |«      | j                   t        |«      «      }nJt	        || j                  «      rt	        |t        j                  «      r|}nt        dt        |«      z  «      ‚|r|| _        t        |«      | _        y t        d|z  «      ‚# t        $ r t        d|z  «      ‚w xY w)Né   r   z%Could not open the datasource at "%s"z"Invalid data source input type: %szInvalid data source file "%s")Ú_writeÚencodingr   Úensure_registeredÚ
isinstanceÚstrr   Úptr_typeÚcapiÚopen_dsr
   r   r   ÚtypeÚptrÚdriver)ÚselfÚds_inputÚ	ds_driverÚwriter   r	   s         úKE:\TRUCKING_PROJECT\Lib\site-packages\django/contrib/gis/gdal/datasource.pyÚ__init__zDataSource.__init__7   sñ   € áØˆD�KàˆDŒKà ˆŒä× Ñ Ô"ä�h¤¤d Ô,äŸ™Ó)ˆIðXä—\‘\¤+¨hÓ"7¸¿¹ÄeÈIÓFVÓW‘ô
 ˜ $§-¡-Ô0´ZØ”v—‘ô6
ð ‰BäÐ DÄtÈHÃ~Ñ UÓVÐVáØˆDŒHÜ  Ó+ˆD�Kô  Ð ?À(Ñ JÓKÐKøô! !ò Xô $Ð$KÈhÑ$VÓWÐWðXús   Á3C> Ã>Dc                 ó¢  — t        |t        «      r+	 t        j                  | j                  t        |«      «      }nnt        |t        «      rGd|cxk  r| j                  k  r$n n!t        j                  | j                  |«      }n%t        d|z  «      ‚t        dt        |«      z  «      ‚t        || «      S # t        $ r t        d|z  «      ‚w xY w)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__Z   sÀ   € ä�eœSÔ!ðNÜ×.Ñ.¨t¯x©x¼ÀUÓ9KÓL‘ô ˜œsÔ#Ø�EÔ,˜D×,Ñ,Õ,ÜŸ™ t§y¡y°%Ó8‘ä ØSØñóð ô
 Ð4´t¸E³{ÑBÓCÐCÜ�U˜DÓ!Ð!øô !ò NÜ Ð!DÀuÑ!LÓMÐMðNús   ’)B6 Â6Cc                 ó   — | j                   S )z3Return the number of layers within the data source.)r%   ©r   s    r   Ú__len__zDataSource.__len__m   s   € à×ÑÐó    c                 ó:   — | j                   ›d| j                  ›d�S )z2Return OGR GetName and Driver for the Data Source.z (ú))Únamer   r-   s    r   Ú__str__zDataSource.__str__q   s   € à ŸI›I t§{£{Ð3Ð3r/   c                 ó@   — t        j                  | j                  «      S )z/Return the number of layers in the data source.)r   Úget_layer_countr'   r-   s    r   r%   zDataSource.layer_countu   s   € ô ×#Ñ# D§I¡IÓ.Ð.r/   c                 óp   — 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   r2   s     r   r2   zDataSource.namez   s+   € ô ×Ñ §	¡	Ó*ˆÜ˜˜tŸ}™}¸4Ô@Ð@r/   N)FFzutf-8)Ú__name__Ú
__module__Ú__qualname__Ú__doc__r   Ú
destroy_dsÚ
destructorr    r+   r.   r3   Úpropertyr%   r2   © r/   r   r   r   3   sN   „ Ù&Ø—‘€Jó!LòF"ò& ò4ð ñ/ó ð/ð ñAó ñAr/   r   N)r<   Úctypesr   Ú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   r@   r/   r   ú<module>rI      s5   ðñ"õF Ý å 1Ý 1Ý 7Ý /Ý 9ß 8ôKA�õ KAr/   