
    N}bg                         d dl mZ d dlmZ d dlmZmZmZmZ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)GeocoderAuthenticationFailureGeocoderQueryErrorGeocoderQuotaExceededGeocoderServiceErrorGeocoderUnavailable)DEFAULT_SENTINELGeocoder)Location)logger)Geokeoc                   h     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dZ
d Z xZS )r   zGeocoder using the geokeo API.

    Documentation at:
        https://geokeo.com/documentation.php

    .. versionadded:: 2.4
    z/geocode/v1/search.phpz/geocode/v1/reverse.phpz
geokeo.comN)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 api_key: The API key required by Geokeo.com
            to perform geocoding requests. You can get your key here:
            https://geokeo.com/

        :param str domain: Domain where the target Geokeo service
            is hosted.

        :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`.

        )r   r   r   r   r   r   /z://N)
super__init__api_keystripr   r   geocode_pathapireverse_pathreverse_api)
selfr   r   r   r   r   r   r   r   	__class__s
            i/home/e360mart.nyusoft.in/public_html/e360mart_env/lib/python3.11/site-packages/geopy/geocoders/geokeo.pyr   zGeokeo.__init__   s    R 	!#+ 	 	
 	
 	
 ll3''"&+++t{{D<M<MN*.+++t{{DDUDUV    T)countryexactly_oner   c                   | j         |d}|r||d<   d                    | j        t          |          f          }t	          j        d| j        j        |           t          | j	        |          }| 
                    |||          S )aJ  
        Return a location point by address.

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

        :param str country: Restricts the results to the specified
            country. The country code is a 2 character code as
            defined by the ISO 3166-1 Alpha 2 standard (e.g. ``us``).

        :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``.
        )r   qr%   ?z%s.geocode: %sr&   r   )r   joinr   r   r   debugr"   __name__r   _parse_json_call_geocoder)r!   queryr%   r&   r   paramsurlcallbacks           r#   geocodezGeokeo.geocodeU   s    : <
 

  	( 'F9hh)F"3"3455%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| j        ||d}d                    | j        t          |          f          }t          j        d| j	        j
        |           t          | j        |          }|                     |||          S )aL  
        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)r   latlngr)   z%s.reverse: %sr*   r+   )_coerce_point_to_stringsplit
ValueErrorr   r,   r    r   r   r-   r"   r.   r   r/   r0   )	r!   r1   r&   r   r8   r9   r2   r3   r4   s	            r#   reversezGeokeo.reverse   s    6	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g           }|                     |           |sd S d |r |d                   S fd|D             S )Nresultsc                     |                      d          }| d         d         d         }| d         d         d         }t          |||f|           S )z4Get the location, lat, lng from a single json place.formatted_addressgeometrylocationr8   r9   )getr   )placerC   latitude	longitudes       r#   parse_placez'Geokeo._parse_json.<locals>.parse_place   sS    yy!455HZ(4U;Hj)*5e<IHx&;UCCCr$   r   c                 &    g | ]} |          S  rJ   ).0rE   rH   s     r#   
<listcomp>z&Geokeo._parse_json.<locals>.<listcomp>   s#    ;;;5KK&&;;;r$   )rD   _check_status)r!   pager&   placesrH   s       @r#   r/   zGeokeo._parse_json   s    )R((4    	4	D 	D 	D  	<;vay)));;;;F;;;;r$   c                 :   |                     d          pd                                }|dk    rd S |dk    rd S |dk    rt          d          |dk    rt          d          |d	k    rt	          d
          |dk    rt          d          t          d          )Nstatus OKZERO_RESULTSINVALID_REQUESTzInvalid request parametersACCESS_DENIEDzAccess deniedOVER_QUERY_LIMITzOver query limitINTERNAL_SERVER_ERRORzInternal server errorzUnknown error)rD   upperr   r   r   r	   r   )r!   rN   rQ   s      r#   rM   zGeokeo._check_status   s    ((8$$*1133 T>>F^##F&&&$%ABBB&&/@@@)))'(:;;;...%&=>>> '777r$   )T)r.   
__module____qualname____doc__r   r   r
   r   r5   r=   r/   rM   __classcell__)r"   s   @r#   r   r      s          ,L,L  $$( 5W 5W 5W 5W 5W 5W 5Wv $(C (C (C (C (C\ $*C *C *C *C *CX< < < <$8 8 8 8 8 8 8r$   r   N)	functoolsr   urllib.parser   	geopy.excr   r   r   r   r	   geopy.geocoders.baser
   r   geopy.locationr   
geopy.utilr   __all__r   rJ   r$   r#   <module>re      s          " " " " " "              < ; ; ; ; ; ; ; # # # # # #      
~8 ~8 ~8 ~8 ~8X ~8 ~8 ~8 ~8 ~8r$   