U
    e                     @   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| qqq0d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-lctamlir/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   