
    N}bg                     ^    d 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 )
z<
Mapzen geocoder, contributed by Michal Migurski of Mapzen.
    )	urlencode)DEFAULT_SENTINELGeocoder)Location)logger)Mapzenc            
       l     e Zd ZdZddddeedddef
 fd	ZdefdZdefdZed             Z	d	 Z
 xZS )
r   zMapzen Search geocoder.

    Documentation at:
        https://mapzen.com/documentation/search/

    .. warning::
       Please note that Mapzen has shut down their API so this geocoder
       class might be removed in future releases.
    Nzsearch.mapzen.comc                    t          t          |                               ||	||||
           || _        || _        || _        |                    d          | _        | j        d| j        d| _	        | j        d| j        d| _
        dS )a(  
        :param str api_key: Mapzen API key, optional.

        :param str format_string:
            See :attr:`geopy.geocoders.options.default_format_string`.

        :param tuple boundary_rect: Coordinates to restrict search within,
            given as (west, south, east, north) coordinate tuple.

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

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

            .. versionadded:: 1.12.0

        :param str domain: Specify a custom domain for Mapzen API.

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

            .. versionadded:: 1.14.0

        )format_stringschemetimeoutproxies
user_agentssl_context/z://z
/v1/searchz/v1/reverseN)superr   __init__country_biasboundary_rectapi_keystripdomainr   geocode_apireverse_api)selfr   r   r   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/mapzen.pyr   zMapzen.__init__   s    ^ 	fd$$'!# 	% 	
 	
 	
 )*ll3''26+++t{{{K37;;;L    Tc                    d| j         |z  i}| j        r|                    d| j        i           | j        r@| j        d         |d<   | j        d         |d<   | j        d         |d<   | j        d	         |d
<   | j        r
| j        |d<   d                    | j        t          |          f          }t          j	        d| j
        j        |           |                     |                     ||          |          S )a  
        Return a location point by address.

        :param str query: The address, query or structured query to geocode
            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.

        :rtype: ``None``, :class:`geopy.location.Location` or a list of them, if
            ``exactly_one=False``.
        textr   r   zboundary.rect.min_lon   zboundary.rect.min_lat   zboundary.rect.max_lon   zboundary.rect.max_latzboundary.country?z%s.geocode_api: %sr   )r   r   updater   r   joinr   r   r   debugr   __name___parse_json_call_geocoder)r   queryexactly_oner   paramsurls         r   geocodezMapzen.geocodeW   s    . $,u45< 	MM4<     	D.2.@.CF*+.2.@.CF*+.2.@.CF*+.2.@.CF*+ 	;)-):F%&hh()F*;*;<==)4>+BCHHHW55{
 
 	
r   c                    	 d |                      |                              d          D             \  }}n# t          $ r t          d          w xY w||d}| j        r|                    d| j        i           d                    | j        t          |          f          }t          j	        d| j
        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``.
        c                 6    g | ]}|                                 S  )r   ).0xs     r   
<listcomp>z"Mapzen.reverse.<locals>.<listcomp>   s-       		  r   ,z"Must be a coordinate pair or Point)z	point.latz	point.lonr   r$   z%s.reverse: %sr%   )_coerce_point_to_stringsplit
ValueErrorr   r&   r'   r   r   r   r(   r   r)   r*   r+   )r   r,   r-   r   latlonr.   r/   s           r   reversezMapzen.reverse   s'   2	C ,,U3399#>>  HC  	C 	C 	CABBB	C 
 

 < 	MM4<    hh()F*;*;<==%t~'>DDDW55{
 
 	
s	   58 Ac                 :   |                      di                                dg           d         }|                      di                                dg           d         }|                      di                                d          }t          |||f|           S )Ngeometrycoordinatesr!   r   
propertiesname)getr   )featurelatitude	longitude	placenames       r   
parse_codezMapzen.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 r3   )rH   )r4   rD   r   s     r   r6   z&Mapzen._parse_json.<locals>.<listcomp>   s%    EEEDOOG,,EEEr   )lenrH   )r   responser-   rJ   s   `   r   r*   zMapzen._parse_json   sd    4J'8}} 	4 	F??8A;///EEEEHEEEEr   )r)   
__module____qualname____doc__r   r   r0   r=   staticmethodrH   r*   __classcell__)r   s   @r   r   r      s          $$&(=M =M =M =M =M =MD $	+
 +
 +
 +
` $	.
 .
 .
 .
` C C \C	F 	F 	F 	F 	F 	F 	Fr   r   N)rP   geopy.compatr   geopy.geocoders.baser   r   geopy.locationr   
geopy.utilr   __all__r   r3   r   r   <module>rX      s     # " " " " " ; ; ; ; ; ; ; ; # # # # # #      
yF yF yF yF yFX yF yF yF yF yFr   