
    .h                     ^    S SK Jr  S SKJr  S SKJrJr  S SKJr  S SK	J
r
  Sr " S S\5      rg	)
    )partial)	urlencode)DEFAULT_SENTINELGeocoder)Location)logger)	BANFrancec                   v   ^  \ rS rSrSrSrSrSS\\S\SS.U 4S jjrSS	\S
.S jr	S	\S.S jr
S rS rSrU =r$ )r	      znGeocoder 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U ]  UUUUUUS9  UR                  S5      U l        U R                  < SU R                  < U R
                  < 3U l        U R                  < SU R                  < U R                  < 3U l        g)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	           lC:\Users\julio\OneDrive\Documentos\Trabajo\Ideas Frescas\venv\Lib\site-packages\geopy/geocoders/banfrance.pyr   BANFrance.__init__   s    L 	!#+ 	 	
 ll3'  ;;T5F5FG 	  ;;T5F5FG 	    T)limitexactly_oner   c                   SU0nUb  X%S'   SR                  U R                  [        U5      45      n[        R                  " SU R
                  R                  U5        [        U R                  US9nU R                  XgUS9$ )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   geocodeBANFrance.geocodeL   s    @ 
 #7Ohh(()F*;<=%t~~'>'>D4++E""3'"BBr    )r"   r   c                p    U R                  U5      R                  S5      u  pEUUS.nSR                  U R                  [        U5      45      n[        R                  " SU R                  R                  U5        [        U R                  US9nU R                  XxUS9$ ! [         a    [        S5      ef = f)a  
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   r5   r6   r.   r/   r0   s	            r   reverseBANFrance.reversex   s    8	C33E:@@EHC
 

 hh(()F*;<=%t~~'>'>D4++E""3'"BB  	CABB	Cs   "B B5c                     UR                  S0 5      R                  S/ 5      S   nUR                  S0 5      R                  S/ 5      S   nUR                  S0 5      R                  S5      n[        XBU4U5      $ )Ngeometrycoordinates   r   
propertieslabel)getr   )r   featurelatitude	longitude	placenames        r   _parse_featureBANFrance._parse_feature   ss    ;;z2.22="EaHKK
B/33M2FqI	KKb155g>		i#8'BBr    c                     Ub  SU;  a  g US   n[        U5      (       d  g U(       a  U R                  US   5      $ U Vs/ s H  o@R                  U5      PM     sn$ s  snf )Nfeaturesr   )lenrG   )r   responser"   rJ   rC   s        r   r+   BANFrance._parse_json   sa    z9J'8}}&&x{33@HIW''0IIIs    A)r   r   r   )r*   
__module____qualname____firstlineno____doc__r   r   r   r   r1   r:   rG   r+   __static_attributes____classcell__)r   s   @r   r	   r	      si     LL
 .$$( 5
 5
v $*C` $)CVC	J 	Jr    r	   N)	functoolsr   urllib.parser   geopy.geocoders.baser   r   geopy.locationr   
geopy.utilr   __all__r	    r    r   <module>r[      s)     " ; # 
iJ iJr    