
    N}bgu!                     n    d dl Z 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 )
    N)partial)	urlencode)DEFAULT_SENTINELGeocoder)Location)logger)Peliasc                   p     e Zd ZdZdZdZ	 deeddedd fdZdedddddd	Zdedd
dZ	d Z
d Z xZS )r	   zPelias geocoder.

    Documentation at:
        https://github.com/pelias/documentation

    See also :class:`geopy.geocoders.GeocodeEarth` which is a Pelias-based
    service provided by the developers of Pelias itself.
    z
/v1/searchz/v1/reverseN)timeoutproxies
user_agentschemessl_contextadapter_factoryc                   t                                          ||||||           || _        |                    d          | _        | j        d| j        | j        | _        | j        d| j        | j        | _	        dS )a%  
        :param str domain: Specify a domain for Pelias API.

        :param str api_key: Pelias API key, optional.

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

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

        :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__api_keystripdomainr   geocode_pathgeocode_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/pelias.pyr   zPelias.__init__   s    R 	!#+ 	 	
 	
 	
 ll3''  ;;;T5F5FG 	  ;;;T5F5FG 	    T)exactly_oner   boundary_rect	countriescountry_biaslanguagec                N   d|i}| j         r|                    d| j         i           |rB|                     |d                              d          \  }	}
}}|	|d<   |
|d<   ||d<   ||d<   |r!t	          j        d	t          d
           ||d<   |rd                    |          |d<   |r||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 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.

        :type boundary_rect: list or tuple of 2 items of :class:`geopy.point.Point`
            or ``(latitude, longitude)`` or ``"%(latitude)s, %(longitude)s"``.
        :param boundary_rect: Coordinates to restrict search within.
            Example: ``[Point(22, 180), Point(-22, -180)]``.

        :param list countries: A list of country codes specified in
            `ISO 3166-1 alpha-2 or alpha-3
            <https://en.wikipedia.org/wiki/ISO_3166-1_alpha-3>`_
            format, e.g. ``['USA', 'CAN']``.
            This is a hard filter.

            .. versionadded:: 2.3

        :param str country_bias: Bias results to this country (ISO alpha-3).

            .. deprecated:: 2.3
                Use ``countries`` instead. This option behaves the same way,
                i.e. it's not a soft filter as the name suggests.
                This parameter is scheduled for removal in geopy 3.0.

        :param str language: Preferred language in which to return results.
            Either uses standard
            `RFC2616 <http://www.ietf.org/rfc/rfc2616.txt>`_
            accept-language string or a simple comma-separated
            list of language codes.

        :rtype: ``None``, :class:`geopy.location.Location` or a list of them, if
            ``exactly_one=False``.
        textr   z#%(lon1)s,%(lat1)s,%(lon2)s,%(lat2)s,zboundary.rect.min_lonzboundary.rect.min_latzboundary.rect.max_lonzboundary.rect.max_latz`country_bias` is deprecated, because it's not a soft filter as the name suggests. Pass a list to the `countries` option instead, which behaves the same way. In geopy 3 the `country_bias` option will be removed.   )
stacklevelzboundary.countrylang?z%s.geocode_api: %sr    r   )r   update_format_bounding_boxsplitwarningswarnDeprecationWarningjoinr   r   r   debugr   __name__r   _parse_json_call_geocoder)r   queryr    r   r!   r"   r#   r$   paramslon1lat1lon2lat2urlcallbacks                  r   geocodezPelias.geocodeU   sz   j %< 	MM4<     	3%)%>%>D&F &FFKeCjj #D$d.2F*+.2F*+.2F*+.2F*+ 		6MM #    *6F%& 	=),))<)<F%& 	&%F6Nhh()F*;*;<==)4>+BCHHH4+EEE""3'"BBBr   )r    r   r$   c                   	 |                      |                              d          \  }}n# t          $ r t          d          w xY w||d}|r||d<   | j        r|                    d| j        i           d                    | j        t          |          f          }t          j	        d| j
        j        |           t          | j        |          }	|                     ||	|	          S )
aZ  
        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.

        :param str language: Preferred language in which to return results.
            Either uses standard
            `RFC2616 <http://www.ietf.org/rfc/rfc2616.txt>`_
            accept-language string or a simple comma-separated
            list of language codes.

        :rtype: ``None``, :class:`geopy.location.Location` or a list of them, if
            ``exactly_one=False``.
        r'   z"Must be a coordinate pair or Point)z	point.latz	point.lonr*   r   r+   z%s.reverse: %sr,   r-   )_coerce_point_to_stringr0   
ValueErrorr   r.   r4   r   r   r   r5   r   r6   r   r7   r8   )
r   r9   r    r   r$   latlonr:   r?   r@   s
             r   reversezPelias.reverse   s   B	C33E::@@EEHC 	C 	C 	CABBB	C 
 

  	&%F6N< 	MM4<    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name)getr   )r   featurelatitude	longitude	placenames        r   _parse_codezPelias._parse_code   s    ;;z2..22="EEaHKK
B//33M2FFqI	KKb1155f==		Hi#8'BBBr   c                      |d S |d         }t          |          sd S |r                     |d                   S  fd|D             S )Nfeaturesr   c                 :    g | ]}                     |          S  )rS   ).0rO   r   s     r   
<listcomp>z&Pelias._parse_json.<locals>.<listcomp>   s'    FFF'D$$W--FFFr   )lenrS   )r   responser    rU   s   `   r   r7   zPelias._parse_json   sf    4J'8}} 	4 	G##HQK000FFFFXFFFFr   )N)r6   
__module____qualname____doc__r   r   r   r   rA   rG   rS   r7   __classcell__)r   s   @r   r	   r	      s          L L
 :

 %$( :
 :
 :
 :
 :
 :
 :
@ $XC XC XC XC XC| $5C 5C 5C 5C 5CnC C C	G 	G 	G 	G 	G 	G 	Gr   r	   )r1   	functoolsr   urllib.parser   geopy.geocoders.baser   r   geopy.locationr   
geopy.utilr   __all__r	   rW   r   r   <module>rf      s           " " " " " " ; ; ; ; ; ; ; ; # # # # # #      
jG jG jG jG jGX jG jG jG jG jGr   