U
    8ÄT_Ž  ã                   @   s*   d Z ddlmZ ddlmZ ddd„ZdS )	z°
This module includes some utility functions for inspecting the layout
of a GDAL data source -- the functionality is analogous to the output
produced by the `ogrinfo` utility.
é    )Ú
DataSource)ÚGEO_CLASSESé
   c                 C   sf  t | tƒrt| ƒ} nt | tƒr ntdƒ‚t| ƒD �].\}}td| j ƒ td| ƒ tdt|jj	 j
 ƒ tdt|ƒ ƒ td|j ƒ |jj}td|dd	… |d	d
… f ƒ td| ƒ ttt|jƒŽ }d| }t|d|… ƒD ]z\}}td| ƒ |jD ]^}	||	 j}
||	|
f }| |	¡}|�rLt |tƒ�r:d}nd}||| 7 }n|d7 }t|ƒ qþqäq0dS )zƒ
    Walk the available layers in the supplied `data_source`, displaying
    the fields for the first `num_features` features.
    z>Data source parameter must be a string or a DataSource object.zdata source : %sz==== layer %sz  shape type: %sz  # features: %sz         srs: %sz      extent: %s - %sr   é   é   z%Displaying the first %s features ====z %%%ss: %%sNz=== Feature %sz ("%s")z (%s)z (None))Ú
isinstanceÚstrr   Ú	ExceptionÚ	enumerateÚprintÚnamer   Z	geom_typeÚnumÚ__name__ÚlenZsrsZextentÚtupleÚmaxÚmapÚfieldsÚ	type_nameÚget)Zdata_sourceZnum_featuresÚiZlayerZ
extent_tupÚwidthÚfmtÚjZfeatureZfld_namer   ÚoutputÚvalZval_fmt© r   úD/tmp/pip-unpacked-wheel-dv63caxw/django/contrib/gis/utils/ogrinfo.pyÚogrinfo   s:    


 


r   N)r   )Ú__doc__Zdjango.contrib.gis.gdalr   Z"django.contrib.gis.gdal.geometriesr   r   r   r   r   r   Ú<module>   s   