
    .h                     V    S 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	)
z<
Mapzen geocoder, contributed by Michal Migurski of Mapzen.
    )	urlencode)DEFAULT_SENTINELGeocoder)Location)logger)Mapzenc            
       v   ^  \ rS rSrSrSSSS\\SSS\4
U 4S jjrS\4S jrS\4S jr\	S	 5       r
S
 rSrU =r$ )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           	        > [         [        U ]  UU	UUUU
S9  X@l        X0l        Xl        UR                  S5      U l        U R                  < SU R                  < S3U l	        U R                  < SU R                  < S3U l
        g)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              iC:\Users\julio\OneDrive\Documentos\Trabajo\Ideas Frescas\venv\Lib\site-packages\geopy/geocoders/mapzen.pyr   Mapzen.__init__   sy    ^ 	fd$'!# 	% 	
 )*ll3'26++t{{K37;;L    Tc                 T   SU R                   U-  0nU R                  (       a  UR                  SU R                  05        U R                  (       aH  U R                  S   US'   U R                  S   US'   U R                  S   US'   U R                  S	   US
'   U R                  (       a  U R                  US'   SR                  U R                  [        U5      45      n[        R                  " SU R                  R                  U5        U R                  U R                  XSS9U5      $ )aJ  
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   geocodeMapzen.geocodeW   s   . $,,u45<<MM4<<  .2.@.@.CF*+.2.@.@.CF*+.2.@.@.CF*+.2.@.@.CF*+)-):):F%&hh(()F*;<=)4>>+B+BCH5{
 	
r    c                     U R                  U5      R                  S5       Vs/ s H  oDR                  5       PM     snu  pVUUS.nU R                  (       a  UR                  SU R                  05        SR                  U R                  [        U5      45      n[        R                  " SU R                  R                  U5        U R                  U R                  XS9U5      $ s  snf ! [         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)z	point.latz	point.lonr   r&   z%s.reverse: %sr'   )_coerce_point_to_stringsplitr   
ValueErrorr   r(   r)   r   r   r   r*   r   r+   r,   r-   )	r   r.   r/   r   xlatlonr0   r1   s	            r   reverseMapzen.reverse   s    2	C ,,U399#>>  	>HC 

 <<MM4<<  hh(()F*;<=%t~~'>'>D5{
 	
%  	CABB	Cs   "C+ C&C+ &C+ +D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[        X1U4U 5      $ )Ngeometrycoordinatesr#   r   
propertiesname)getr   )featurelatitude	longitude	placenames       r   
parse_codeMapzen.parse_code   su     ;;z2.22="EaHKK
B/33M2FqI	KKb155f=		i#8'BBr    c                     Uc  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   )lenrH   )r   responser/   rK   rD   s        r   r,   Mapzen._parse_json   sV    J'8}}??8A;//<DEHOOG,HEEEs   A)r   r   r   r   r   r   )r+   
__module____qualname____firstlineno____doc__r   r   r2   r<   staticmethodrH   r,   __static_attributes____classcell__)r   s   @r   r   r      sm     $$&(=MD $	+
` $	.
` C C	F 	Fr    r   N)rR   geopy.compatr   geopy.geocoders.baser   r   geopy.locationr   
geopy.utilr   __all__r    r    r   <module>r\      s-    # ; # 
yFX yFr    