Ë
    Ï.fÒ  ã                   ó^   — d dl mZ d dlmZ d dlmZmZ d dlmZ d dl	m
Z
 dZ G d„ de«      Zy	)
é    )Úpartial)Ú	urlencode)ÚDEFAULT_SENTINELÚGeocoder)ÚLocation)Úlogger)Ú	BANFrancec                   óf   ‡ — e Zd ZdZdZdZddeededdœˆ fd„
Zdded	œd
„Zdedœd„Z	d„ Z
d„ Zˆ xZS )r	   zzGeocoder using the Base Adresse Nationale France API.

    Documentation at:
        https://adresse.data.gouv.fr/api
    z/searchz/reversezapi-adresse.data.gouv.frN)ÚdomainÚschemeÚtimeoutÚproxiesÚ
user_agentÚssl_contextÚadapter_factoryc                ó  •— t         ‰| �  ||||||¬«       |j                  d«      | _        | j                  ›d| j                  ›| j
                  ›�| _        | j                  ›d| j                  ›| j                  ›�| _        y)a/  

        :param str domain: Currently it is ``'api-adresse.data.gouv.fr'``, can
            be changed for testing purposes.

        :param str scheme:
            See :attr:`geopy.geocoders.options.default_scheme`.

        :param int timeout:
            See :attr:`geopy.geocoders.options.default_timeout`.

        :param dict proxies:
            See :attr:`geopy.geocoders.options.default_proxies`.

        :param str user_agent:
            See :attr:`geopy.geocoders.options.default_user_agent`.

        :type ssl_context: :class:`ssl.SSLContext`
        :param ssl_context:
            See :attr:`geopy.geocoders.options.default_ssl_context`.

        :param callable adapter_factory:
            See :attr:`geopy.geocoders.options.default_adapter_factory`.

            .. versionadded:: 2.0

        )r   r   r   r   r   r   ú/z://N)	ÚsuperÚ__init__Ústripr   r   Úgeocode_pathÚgeocode_apiÚreverse_pathÚreverse_api)	Úselfr   r   r   r   r   r   r   Ú	__class__s	           €úXC:\Users\user\Documents\project_loop\venv\Lib\site-packages\geopy/geocoders/banfrance.pyr   zBANFrance.__init__   s€   ø€ ôL 	‰ÑØØØØ!Ø#Ø+ð 	ô 	
ð —l‘l 3Ó'ˆŒð  Ÿ;›;¨¯ª°T×5FÒ5FÐGð 	Ôð  Ÿ;›;¨¯ª°T×5FÒ5FÐGð 	Õó    T)ÚlimitÚexactly_oner   c                ó  — d|i}|�||d<   dj                  | j                  t        |«      f«      }t        j                  d| j
                  j                  |«       t        | j                  |¬«      }| j                  |||¬«      S )a“  
        Return a location point by address.

        :param str query: The address or query you wish to geocode.

        :param int limit: Defines the maximum number of items in the
            response structure. If not provided and there are multiple
            results the BAN API will return 5 results by default.
            This will be reset to one if ``exactly_one`` is True.

        :param bool exactly_one: Return one result or a list of results, if
            available.

        :param int timeout: Time, in seconds, to wait for the geocoding service
            to respond before raising a :class:`geopy.exc.GeocoderTimedOut`
            exception. Set this only if you wish to override, on this call
            only, the value set during the geocoder's initialization.

        :rtype: ``None``, :class:`geopy.location.Location` or a list of them, if
            ``exactly_one=False``.

        Úqr   ú?z%s.geocode: %s©r    ©r   )
Újoinr   r   r   Údebugr   Ú__name__r   Ú_parse_jsonÚ_call_geocoder)r   Úqueryr   r    r   ÚparamsÚurlÚcallbacks           r   ÚgeocodezBANFrance.geocodeL   s…   € ð@ �ð
ˆð ÐØ#ˆF�7‰Oà�h‰h˜×(Ñ(¬)°FÓ*;Ð<Ó=ˆä�‰Ð% t§~¡~×'>Ñ'>ÀÔDÜ˜4×+Ñ+¸ÔEˆØ×"Ñ" 3¨¸'Ð"ÓBÐBr   )r    r   c                ó|  — 	 | j                  |«      j                  d«      \  }}||dœ}dj                  | j                  t        |«      f«      }t        j                  d| j                  j                  |«       t        | j                  |¬«      }| j                  |||¬«      S # t        $ r t        d«      ‚w xY w)aM  
        Return an address by location point.

        :param query: The coordinates for which you wish to obtain the
            closest human-readable addresses.
        :type query: :class:`geopy.point.Point`, list or tuple of ``(latitude,
            longitude)``, or string as ``"%(latitude)s, %(longitude)s"``.

        :param bool exactly_one: Return one result or a list of results, if
            available.

        :param int timeout: Time, in seconds, to wait for the geocoding service
            to respond before raising a :class:`geopy.exc.GeocoderTimedOut`
            exception. Set this only if you wish to override, on this call
            only, the value set during the geocoder's initialization.

        :rtype: ``None``, :class:`geopy.location.Location` or a list of them, if
            ``exactly_one=False``.

        ú,z"Must be a coordinate pair or Point)ÚlatÚlonr#   z%s.reverse: %sr$   r%   )Ú_coerce_point_to_stringÚsplitÚ
ValueErrorr&   r   r   r   r'   r   r(   r   r)   r*   )	r   r+   r    r   r2   r3   r,   r-   r.   s	            r   ÚreversezBANFrance.reversex   sº   € ð8	CØ×3Ñ3°EÓ:×@Ñ@ÀÓE‰HˆC�ð
 Øñ
ˆð
 �h‰h˜×(Ñ(¬)°FÓ*;Ð<Ó=ˆÜ�‰Ð% t§~¡~×'>Ñ'>ÀÔDÜ˜4×+Ñ+¸ÔEˆØ×"Ñ" 3¨¸'Ð"ÓBÐBøô ò 	CÜÐAÓBÐBð	Cús   ‚#B& Â&B;c                 óö   — |j                  di «      j                  dg «      d   }|j                  di «      j                  dg «      d   }|j                  di «      j                  d«      }t        |||f|«      S )NÚgeometryÚcoordinatesé   r   Ú
propertiesÚlabel)Úgetr   )r   ÚfeatureÚlatitudeÚ	longitudeÚ	placenames        r   Ú_parse_featurezBANFrance._parse_feature£   su   € à—;‘;˜z¨2Ó.×2Ñ2°=À"ÓEÀaÑHˆØ—K‘K 
¨BÓ/×3Ñ3°MÀ2ÓFÀqÑIˆ	Ø—K‘K ¨bÓ1×5Ñ5°gÓ>ˆ	ä˜	 H¨iÐ#8¸'ÓBÐBr   c                 ó¦   — |�d|vry |d   }t        |«      sy |r| j                  |d   «      S |D �cg c]  }| j                  |«      ‘Œ c}S c c}w )NÚfeaturesr   )ÚlenrC   )r   Úresponser    rE   r?   s        r   r)   zBANFrance._parse_json«   s]   € ØÐ˜z°Ñ9ØØ˜JÑ'ˆÜ�8Œ}ØÙØ×&Ñ& x°¡{Ó3Ð3à@HÖI°W�D×'Ñ'¨Õ0ÒIÐIùÒIs   ³A)r(   Ú
__module__Ú__qualname__Ú__doc__r   r   r   r   r/   r7   rC   r)   Ú__classcell__)r   s   @r   r	   r	      s^   ø„ ñð €LØ€Lð
 .ØØ$Ø$ØØ(Ø ö5
ðv ØØ$ô*Cð` Ø$ô)CòVCö	Jr   r	   N)Ú	functoolsr   Úurllib.parser   Úgeopy.geocoders.baser   r   Úgeopy.locationr   Ú
geopy.utilr   Ú__all__r	   © r   r   ú<module>rS      s)   ðÝ Ý "ç ;Ý #Ý à
€ôiJ�õ iJr   