
    N}bg                     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d	S )
    )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                                          ||||||           |                    d          | _        | j        d| j        | j        | _        | j        d| j        | j        | _        dS )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	           l/home/e360mart.nyusoft.in/public_html/e360mart_env/lib/python3.11/site-packages/geopy/geocoders/banfrance.pyr   zBANFrance.__init__   s    L 	!#+ 	 	
 	
 	
 ll3''  ;;;T5F5FG 	  ;;;T5F5FG 	    T)limitexactly_oner   c                   d|i}|||d<   d                     | j        t          |          f          }t          j        d| j        j        |           t          | 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``.

        qNr   ?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    @ 
 #F7Ohh()F*;*;<==%t~'>DDD4+EEE""3'"BBBr   )r    r   c                   	 |                      |                              d          \  }}n# t          $ r t          d          w xY w||d}d                    | j        t          |          f          }t          j        d| j        j	        |           t          | j        |          }|                     |||          S )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3E::@@EEHC 	C 	C 	CABBB	C 
 

 hh()F*;*;<==%t~'>DDD4+EEE""3'"BBBs	   +. Ac                 :   |                     di                                dg           d         }|                     di                                dg           d         }|                     di                                d          }t          |||f|          S )Ngeometrycoordinates   r   
propertieslabel)getr   )r   featurelatitude	longitude	placenames        r   _parse_featurezBANFrance._parse_feature   s    ;;z2..22="EEaHKK
B//33M2FFqI	KKb1155g>>		Hi#8'BBBr   c                      |d|vrd S |d         }t          |          sd S |r                     |d                   S  fd|D             S )Nfeaturesr   c                 :    g | ]}                     |          S  )rC   ).0r?   r   s     r   
<listcomp>z)BANFrance._parse_json.<locals>.<listcomp>   s'    IIIWD''00IIIr   )lenrC   )r   responser    rE   s   `   r   r)   zBANFrance._parse_json   sp    z994J'8}} 	4 	J&&x{333IIIIIIIIr   )r(   
__module____qualname____doc__r   r   r   r   r/   r7   rC   r)   __classcell__)r   s   @r   r	   r	      s          LL
 .$$( 5
 5
 5
 5
 5
 5
 5
v $*C *C *C *C *C` $)C )C )C )C )CVC C C	J 	J 	J 	J 	J 	J 	Jr   r	   N)	functoolsr   urllib.parser   geopy.geocoders.baser   r   geopy.locationr   
geopy.utilr   __all__r	   rG   r   r   <module>rV      s          " " " " " " ; ; ; ; ; ; ; ; # # # # # #      
iJ iJ iJ iJ iJ iJ iJ iJ iJ iJr   