
v^                 @   s9   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   s  t  |  t  r t |   }  n t  |  t  r0 n t d   x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 | } x t | d |   D] \ } } t d |  x | j D]{ }	 | |	 j }
 | |	 |
 f } | j |	  } | rt  | t  rd } n d } | | | 7} n
 | d 7} t |  qSWq/WqI Wd 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   B/tmp/pip-build-8lau8j11/django/django/contrib/gis/utils/ogrinfo.pyogrinfo   s:    (
#	
r   N)__doc__Zdjango.contrib.gis.gdalr   Z"django.contrib.gis.gdal.geometriesr   r   r   r   r   r   <module>   s   