U
    ‹Ha\  ã                   @   s4   d Z ddlmZ G dd„ deƒZG dd„ deƒZdS )z[
SimpleWebFeature is a working example of a class that satisfies the Python geo
interface.
é    )ÚGeoJSONc                       s*   e Zd ZdZd‡ fdd„	Zdd„ Z‡  ZS )ÚFeaturez)
    Represents a WGS84 GIS feature.
    Nc                    sL   t t| ƒjf |Ž |dk	r"|| d< |r4| j|ddnd| d< |pBi | d< dS )a†  
        Initialises a Feature object with the given parameters.

        :param id: Feature identifier, such as a sequential number.
        :type id: str, int
        :param geometry: Geometry corresponding to the feature.
        :param properties: Dict containing properties of the feature.
        :type properties: dict
        :return: Feature object
        :rtype: Feature
        NÚidT)ÚstrictÚgeometryÚ
properties)Úsuperr   Ú__init__Zto_instance)Úselfr   r   r   Úextra©Ú	__class__© ú3/tmp/pip-unpacked-wheel-kunv6awc/geojson/feature.pyr	      s    ÿÿzFeature.__init__c                 C   s   |   d¡}|r| ¡ S d S )Nr   )ÚgetÚerrors)r
   Zgeor   r   r   r   !   s    
zFeature.errors)NNN)Ú__name__Ú
__module__Ú__qualname__Ú__doc__r	   r   Ú__classcell__r   r   r   r   r   	   s   r   c                       s4   e Zd ZdZ‡ fdd„Zdd„ Z‡ fdd„Z‡  ZS )ÚFeatureCollectionzL
    Represents a FeatureCollection, a set of multiple Feature objects.
    c                    s   t t| ƒjf |Ž || d< dS )zù
        Initialises a FeatureCollection object from the
        :param features: List of features to constitute the FeatureCollection.
        :type features: list
        :return: FeatureCollection object
        :rtype: FeatureCollection
        ÚfeaturesN)r   r   r	   )r
   r   r   r   r   r   r	   +   s    zFeatureCollection.__init__c                 C   s   |   dd„ | j¡S )Nc                 S   s   |   ¡ S )N)r   )Úxr   r   r   Ú<lambda>7   ó    z*FeatureCollection.errors.<locals>.<lambda>)Zcheck_list_errorsr   )r
   r   r   r   r   6   s    zFeatureCollection.errorsc              
      sB   z|   dd¡| W S  tttfk
r<   tt| ƒ |¡ Y S X d S )Nr   r   )r   ÚKeyErrorÚ	TypeErrorÚ
IndexErrorr   r   Ú__getitem__)r
   Úkeyr   r   r   r   9   s    zFeatureCollection.__getitem__)r   r   r   r   r	   r   r   r   r   r   r   r   r   &   s   r   N)r   Zgeojson.baser   r   r   r   r   r   r   Ú<module>   s   