
    .hv                     n    S SK Jr  S SKJrJr  S SKJrJr  S SKJ	r	  S SK
Jr  S SKJr  Sr " S S	\5      rg
)    )partial)quote	urlencode)DEFAULT_SENTINELGeocoderLocation)Point)logger)MapBoxc            	       x   ^  \ rS rSrSrSrS\\S\SSSS.U 4S jjrSS	 jrS\SSSSS
.S jr	S\S.S jr
SrU =r$ )r      z`Geocoder using the Mapbox API.

Documentation at:
    https://www.mapbox.com/api-documentation/
z+/geocoding/v5/mapbox.places/%(query)s.json/Nzapi.mapbox.com)schemetimeoutproxies
user_agentssl_contextadapter_factorydomainrefererc          	         > [         T
U ]  UUUUUUS9  Xl        UR                  S5      U l        U R
                  < SU R                  < U R                  < 3U l        U	(       a  XR                  S'   gg)a  
:param str api_key: The API key required by Mapbox to perform
    geocoding requests. API keys are managed through Mapox's account
    page (https://www.mapbox.com/account/access-tokens).

: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

:param str domain: base api domain for mapbox

:param str referer: The URL used to satisfy the URL restriction of
    mapbox tokens.

    .. versionadded:: 2.3
)r   r   r   r   r   r   /z://RefererN)	super__init__api_keystripr   r   api_pathapiheaders)selfr   r   r   r   r   r   r   r   r   	__class__s             iC:\Users\julio\OneDrive\Documentos\Trabajo\Ideas Frescas\venv\Lib\site-packages\geopy/geocoders/mapbox.pyr   MapBox.__init__   so    \ 	!#+ 	 	
 ll3'"&++t{{DMMJ&-LL#     Tc                 ~    US   nU/ :X  a  gS nU(       a  U" US   5      $ U Vs/ s H
  oT" U5      PM     sn$ s  snf )z7Returns location, (latitude, longitude) from json feed.featuresNc                 T    U S   nU S   S   S   nU S   S   S   n[        XU4U 5      $ )N
place_namegeometrycoordinatesr      r   )featurelocation	longitudelatitudes       r#   parse_feature)MapBox._parse_json.<locals>.parse_featureW   sF    |,H
+M:1=Iz*=9!<HH&;WEEr%   r    )r!   jsonexactly_oner'   r1   r-   s         r#   _parse_jsonMapBox._parse_jsonQ   sM    
#r>	F
  !--:BC(wM'*(CCCs   :)r5   r   	proximitycountrylanguagebboxc                   0 nU R                   US'   U(       a  U R                  US5      US'   U(       d  / n[        U[        5      (       a  U/nU(       a  SR	                  U5      US'   U(       a+  [        U5      n	U	R                  < SU	R                  < 3US'   U(       a  XhS'   [        UR                  S5      5      n
S	R	                  U R                  [        U
S
9-  [        U5      45      n[        R                  " SU R                  R                   U5        [#        U R$                  US9nU R'                  XUS9$ )u<  
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.

:param proximity: A coordinate to bias local results based on a provided
    location.
:type proximity: :class:`geopy.point.Point`, list or tuple of ``(latitude,
    longitude)``, or string as ``"%(latitude)s, %(longitude)s"``.

:param country: Country to filter result in form of
    ISO 3166-1 alpha-2 country code (e.g. ``FR``).
    Might be a Python list of strings.

:type country: str or list

:param str language: This parameter controls the language of the text supplied in
    responses, and also affects result scoring, with results matching the user’s
    query in the requested language being preferred over results that match in
    another language. You can pass two letters country codes (ISO 639-1).

    .. versionadded:: 2.3

:param bbox: The bounding box of the viewport within which
    to bias geocode results more prominently.
    Example: ``[Point(22, 180), Point(-22, -180)]``.
:type bbox: list or tuple of 2 items of :class:`geopy.point.Point` or
    ``(latitude, longitude)`` or ``"%(latitude)s, %(longitude)s"``.

:rtype: ``None``, :class:`geopy.location.Location` or a list of them, if
    ``exactly_one=False``.
access_tokenz#%(lon1)s,%(lat1)s,%(lon2)s,%(lat2)sr;   ,r9   r8   r:   utf-8?queryz%s.geocode: %sr5   r   )r   _format_bounding_box
isinstancestrjoinr
   r/   r0   r   encoder   dictr   r   debugr"   __name__r   r6   _call_geocoder)r!   rB   r5   r   r8   r9   r:   r;   paramspquoted_queryurlcallbacks                r#   geocodeMapBox.geocodea   s   f !%~!66;=F6N Ggs##iG # 1F9i A-.[[!**"EF;!):U\\'23hh4l#;;!&)+ ,%t~~'>'>D4++E""3'"BBr%   )r5   r   c                |   0 nU R                   US'   U R                  US5      n[        UR                  S5      5      nSR	                  U R
                  [        US9-  [        U5      45      n[        R                  " SU R                  R                  U5        [        U R                  US9nU R                  XxUS9$ )	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``.
r=   z%(lon)s,%(lat)sr?   r@   rA   z%s.reverse: %srC   rD   )r   _coerce_point_to_stringr   rI   rH   r   rJ   r   r   rK   r"   rL   r   r6   rM   )	r!   rB   r5   r   rN   pointrP   rQ   rR   s	            r#   reverseMapBox.reverse   s    4 !%~,,U4EFU\\'23hh4l#;;!&)+ ,%t~~'>'>D4++E""3'"BBr%   )r   r   r   )T)rL   
__module____qualname____firstlineno____doc__r   r   r   r6   rS   rX   __static_attributes____classcell__)r"   s   @r#   r   r      sj     =H $$( #:. :.xD( $MCf $#C #Cr%   r   N)	functoolsr   urllib.parser   r   geopy.geocoders.baser   r   geopy.locationr	   geopy.pointr
   
geopy.utilr   __all__r   r3   r%   r#   <module>rg      s,     ) ; #  
GCX GCr%   