ó
i4Vdc           @   s²   d  d l  m Z d  d l m Z m Z d  d l m Z d  d l m Z m	 Z	 d  d l
 m Z m Z d  d l m Z d  d l m Z m Z d  d l m Z d	 e f d
 „  ƒ  YZ d S(   iÿÿÿÿ(   t   GDALBase(   t   GDALExceptiont   OGRIndexError(   t   Field(   t   OGRGeometryt   OGRGeomType(   t   dst   geom(   t   six(   t   force_bytest
   force_text(   t   ranget   Featurec           B   sÈ   e  Z d  Z d „  Z d „  Z d „  Z d „  Z d „  Z d „  Z d „  Z	 e
 d „  ƒ Z e
 d	 „  ƒ Z e
 d
 „  ƒ Z e
 d „  ƒ Z e
 d „  ƒ Z e
 d „  ƒ Z e
 d „  ƒ Z d „  Z d „  Z RS(   sa   
    This class that wraps an OGR Feature, needs to be instantiated
    from a Layer object.
    c         C   s+   | s t  d ƒ ‚ n  | |  _ | |  _ d S(   sJ   
        Initializes Feature from a pointer and its Layer object.
        s1   Cannot create OGR Feature, invalid pointer given.N(   R   t   ptrt   _layer(   t   selft   featt   layer(    (    sm   /var/www/html/phendo-backend/phendo_python/env/lib/python2.7/site-packages/django/contrib/gis/gdal/feature.pyt   __init__   s    	c         C   s&   |  j  r" t r" t j |  j  ƒ n  d S(   s$   Releases a reference to this object.N(   t   _ptrt   capit   destroy_feature(   R   (    (    sm   /var/www/html/phendo-backend/phendo_python/env/lib/python2.7/site-packages/django/contrib/gis/gdal/feature.pyt   __del__   s    c         C   sa   t  | t j ƒ r$ |  j | ƒ } n0 | d k  s? | |  j k rN t d ƒ ‚ n  | } t |  | ƒ S(   s/  
        Gets the Field object at the specified index, which may be either
        an integer or the Field's string label.  Note that the Field object
        is not the field's _value_ -- use the `get` method instead to
        retrieve the value (e.g. an integer) instead of a Field instance.
        i    s   index out of range(   t
   isinstanceR   t   string_typest   indext
   num_fieldsR   R   (   R   R   t   i(    (    sm   /var/www/html/phendo-backend/phendo_python/env/lib/python2.7/site-packages/django/contrib/gis/gdal/feature.pyt   __getitem__#   s    c         c   s'   x  t  |  j ƒ D] } |  | Vq Wd S(   s(   Iterates over each field in the Feature.N(   R   R   (   R   R   (    (    sm   /var/www/html/phendo-backend/phendo_python/env/lib/python2.7/site-packages/django/contrib/gis/gdal/feature.pyt   __iter__2   s    c         C   s   |  j  S(   s,   Returns the count of fields in this feature.(   R   (   R   (    (    sm   /var/www/html/phendo-backend/phendo_python/env/lib/python2.7/site-packages/django/contrib/gis/gdal/feature.pyt   __len__7   s    c         C   s   d |  j  |  j f S(   s   The string name of the feature.s   Feature FID %d in Layer<%s>(   t   fidt
   layer_name(   R   (    (    sm   /var/www/html/phendo-backend/phendo_python/env/lib/python2.7/site-packages/django/contrib/gis/gdal/feature.pyt   __str__;   s    c         C   s   t  t j |  j | j ƒ ƒ S(   s)   Does equivalence testing on the features.(   t   boolR   t   feature_equalR   R   (   R   t   other(    (    sm   /var/www/html/phendo-backend/phendo_python/env/lib/python2.7/site-packages/django/contrib/gis/gdal/feature.pyt   __eq__?   s    c         C   s   |  j  j j S(   N(   R   t   _dst   encoding(   R   (    (    sm   /var/www/html/phendo-backend/phendo_python/env/lib/python2.7/site-packages/django/contrib/gis/gdal/feature.pyR'   D   s    c         C   s   t  j |  j ƒ S(   s   Returns the feature identifier.(   R   t   get_fidR   (   R   (    (    sm   /var/www/html/phendo-backend/phendo_python/env/lib/python2.7/site-packages/django/contrib/gis/gdal/feature.pyR   H   s    c         C   s+   t  j |  j j ƒ } t | |  j d t ƒS(   s.   Returns the name of the layer for the feature.t   strings_only(   R   t   get_feat_nameR   t   _ldefnR
   R'   t   True(   R   t   name(    (    sm   /var/www/html/phendo-backend/phendo_python/env/lib/python2.7/site-packages/django/contrib/gis/gdal/feature.pyR    M   s    c         C   s   t  j |  j ƒ S(   s,   Returns the number of fields in the Feature.(   R   t   get_feat_field_countR   (   R   (    (    sm   /var/www/html/phendo-backend/phendo_python/env/lib/python2.7/site-packages/django/contrib/gis/gdal/feature.pyR   S   s    c         C   s;   g  t  |  j ƒ D]' } t j t j |  j j | ƒ ƒ ^ q S(   s(   Returns a list of fields in the Feature.(   R   R   R   t   get_field_namet   get_field_defnR   R+   (   R   R   (    (    sm   /var/www/html/phendo-backend/phendo_python/env/lib/python2.7/site-packages/django/contrib/gis/gdal/feature.pyt   fieldsX   s    c         C   s%   t  j |  j ƒ } t t j | ƒ ƒ S(   s*   Returns the OGR Geometry for this Feature.(   R   t   get_feat_geom_refR   R   t   geom_apit
   clone_geom(   R   t   geom_ptr(    (    sm   /var/www/html/phendo-backend/phendo_python/env/lib/python2.7/site-packages/django/contrib/gis/gdal/feature.pyR   ^   s    c         C   s   t  t j |  j j ƒ ƒ S(   s.   Returns the OGR Geometry Type for this Feture.(   R   R   t   get_fd_geom_typeR   R+   (   R   (    (    sm   /var/www/html/phendo-backend/phendo_python/env/lib/python2.7/site-packages/django/contrib/gis/gdal/feature.pyt	   geom_typee   s    c         C   s   t  | d | ƒ } |  | j S(   s³   
        Returns the value of the field, instead of an instance of the Field
        object.  May take a string of the field name or a Field object as
        parameters.
        R-   (   t   getattrt   value(   R   t   fieldt
   field_name(    (    sm   /var/www/html/phendo-backend/phendo_python/env/lib/python2.7/site-packages/django/contrib/gis/gdal/feature.pyt   getk   s    c         C   s>   t  j |  j t | ƒ ƒ } | d k  r: t d | ƒ ‚ n  | S(   s*   Returns the index of the given field name.i    s"   invalid OFT field name given: "%s"(   R   t   get_field_indexR   R	   R   (   R   R;   R   (    (    sm   /var/www/html/phendo-backend/phendo_python/env/lib/python2.7/site-packages/django/contrib/gis/gdal/feature.pyR   t   s    (   t   __name__t
   __module__t   __doc__R   R   R   R   R   R!   R%   t   propertyR'   R   R    R   R1   R   R7   R<   R   (    (    (    sm   /var/www/html/phendo-backend/phendo_python/env/lib/python2.7/site-packages/django/contrib/gis/gdal/feature.pyR      s"   										N(   t   django.contrib.gis.gdal.baseR    t   django.contrib.gis.gdal.errorR   R   t   django.contrib.gis.gdal.fieldR   t"   django.contrib.gis.gdal.geometriesR   R   t"   django.contrib.gis.gdal.prototypesR   R   R   R3   t   django.utilsR   t   django.utils.encodingR	   R
   t   django.utils.six.movesR   R   (    (    (    sm   /var/www/html/phendo-backend/phendo_python/env/lib/python2.7/site-packages/django/contrib/gis/gdal/feature.pyt   <module>   s   