
    .h                      z    S SK Jr  S SKJrJr  S SKJ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)    )partial)quote	urlencode)AdapterHTTPError)GeocoderQuotaExceeded)DEFAULT_SENTINELGeocoderLocation)logger)TomTomc                      ^  \ rS rSrSrSrSrS\\S\SSS.U 4S jjrS	\SS
SS.S jr	S	\SS.S jr
S rS rS rS rS rS rS rS rSrU =r$ )r      ziTomTom geocoder.

Documentation at:
    https://developer.tomtom.com/search-api/search-api-documentation
z /search/2/geocode/%(query)s.jsonz*/search/2/reverseGeocode/%(position)s.jsonNzapi.tomtom.com)schemetimeoutproxies
user_agentssl_contextadapter_factorydomainc          	         > [         T	U ]  UUUUUUS9  Xl        U R                  < SU< U R                  < 3U l        U R                  < SU< U R                  < 3U l        g)a  
:param str api_key: TomTom API key.

: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: Domain where the target TomTom service
    is hosted.
)r   r   r   r   r   r   z://N)super__init__api_keyr   geocode_pathapireverse_pathapi_reverse)
selfr   r   r   r   r   r   r   r   	__class__s
            iC:\Users\julio\OneDrive\Documentos\Trabajo\Ideas Frescas\venv\Lib\site-packages\geopy/geocoders/tomtom.pyr   TomTom.__init__   sb    N 	!#+ 	 	
 "&++vt7H7HI*.++vt?P?PQ    TF)exactly_oner   limit	typeaheadlanguagec                   U R                  U5      nU R                  U5      US'   U(       a  [        [        U5      5      US'   U(       a  SUS'   U(       a  XgS'   [	        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$ )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.

:param int limit: Maximum amount of results to return from the service.
    Unless exactly_one is set to False, limit will always be 1.

:param bool typeahead: If the "typeahead" flag is set, the query
    will be interpreted as a partial input and the search will
    enter predictive mode.

:param str language: Language in which search results should be
    returned. When data in specified language is not
    available for a specific field, default language is used.
    List of supported languages (case-insensitive):
    https://developer.tomtom.com/online-search/online-search-documentation/supported-languages

:rtype: ``None``, :class:`geopy.location.Location` or a list of them, if
    ``exactly_one=False``.
r&   r%   1r'   utf-8?)queryz%s.geocode: %sr$   r   )_geocode_params_boolean_valuestrintr   encodejoinr   dictr   r   debugr    __name__r   _parse_json_call_geocoder)r   r,   r$   r   r%   r&   r'   paramsquoted_queryurlcallbacks              r!   geocodeTomTom.geocodeJ   s    N %%e,"11)<{!#e*oF7O!F7O!):U\\'23hh4l#;;!&)+ ,%t~~'>'>D4++E""3'"BBr#   )r$   r   r'   c                   U R                  U5      nU R                  U5      nU(       a  XFS'   [        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$ )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.

:param str language: Language in which search results should be
    returned. When data in specified language is not
    available for a specific field, default language is used.
    List of supported languages (case-insensitive):
    https://developer.tomtom.com/online-search/online-search-documentation/supported-languages

:rtype: ``None``, :class:`geopy.location.Location` or a list of them, if
    ``exactly_one=False``.
r'   r*   r+   )positionz%s.reverse: %sr-   r.   )_coerce_point_to_string_reverse_paramsr   r3   r4   r   r5   r   r   r6   r    r7   r   _parse_reverse_jsonr9   )
r   r,   r$   r   r'   rA   r:   quoted_positionr<   r=   s
             r!   reverseTomTom.reverse   s    B //6%%h/!): 89hh((4+II!&)+ ,%t~~'>'>D433M""3'"BBr#   c                     U(       a  S$ S$ )Ntruefalse )r   
bool_values     r!   r0   TomTom._boolean_value   s    #v00r#   c                     SU R                   0$ Nkeyr   )r   formatted_querys     r!   r/   TomTom._geocode_params       4<<
 	
r#   c                     SU R                   0$ rO   rQ   )r   rA   s     r!   rC   TomTom._reverse_params   rT   r#   c                     U(       a
  US   (       d  g U(       a  U R                  US   S   5      $ US    Vs/ s H  nU R                  U5      PM     sn$ s  snf )Nresultsr   )_parse_search_resultr   	resourcesr$   results       r!   r8   TomTom._parse_json   sd    	) 4,,Yy-A!-DEE #,I"68"6 --f5"68 8 8   Ac                 J    US   S   nUS   S   n[        US   S   X#4U5      $ )NrA   latlonaddressfreeformAddressr
   r   r\   latitude	longitudes       r!   rY   TomTom._parse_search_result   sB    *%e,:&u-	y)*;<!-v7 	7r#   c                     U(       a
  US   (       d  g U(       a  U R                  US   S   5      $ US    Vs/ s H  nU R                  U5      PM     sn$ s  snf )N	addressesr   )_parse_reverse_resultrZ   s       r!   rD   TomTom._parse_reverse_json   sd    	+ 6--i.DQ.GHH #,K"8:"8 ..v6"8: : :r^   c                 V    US   R                  S5      u  p#[        US   S   X#4U5      $ )NrA   ,rb   rc   )splitr   rd   s       r!   rj   TomTom._parse_reverse_result   s<    $Z066s;y)*;<!-v7 	7r#   c                     [        U[        5      (       d  g UR                  b  UR                  c  g UR                  S:  a  SUR                  ;   a  [	        S5      Ueg g )Ni  zDeveloper Over Qps)
isinstancer   status_codetextr   )r   errors     r!   _geocoder_exception_handler"TomTom._geocoder_exception_handler   s\    %!122$

(:#(<

(J'(<=5H )K#r#   )r   r   r   )r7   
__module____qualname____firstlineno____doc__r   r   r   r   r>   rF   r0   r/   rC   r8   rY   rD   rj   ru   __static_attributes____classcell__)r    s   @r!   r   r      s     6L?L $$( #1R 1Rn $7Cz $,C\1



87:7
I Ir#   r   N)	functoolsr   urllib.parser   r   geopy.adaptersr   	geopy.excr   geopy.geocoders.baser   r	   geopy.locationr   
geopy.utilr   __all__r   rK   r#   r!   <module>r      s/     ) + + ; # 
VIX VIr#   