
    .h                     ^    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)	urlencode)DEFAULT_SENTINELGeocoderLocation)logger)MapQuestc                   v   ^  \ rS rSrSrSrSrS\\S\SSS.U 4S jjrSS
 jr	S	\SSS.S jr
S	\S.S jrSrU =r$ )r
      a  Geocoder using the MapQuest API based on Licensed data.

Documentation at:
    https://developer.mapquest.com/documentation/geocoding-api/

MapQuest provides two Geocoding APIs:

- :class:`geopy.geocoders.OpenMapQuest` Nominatim-alike API
  which is based on Open data from OpenStreetMap.
- :class:`geopy.geocoders.MapQuest` (this class) MapQuest's own API
  which is based on Licensed data.
z/geocoding/v1/addressz/geocoding/v1/reverseNzwww.mapquestapi.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5      U l        U R
                  < SU R                  < U R                  < 3U l        U R
                  < SU R                  < U R                  < 3U l	        g)a0  
:param str api_key: The API key required by Mapquest to perform
    geocoding requests. API keys are managed through MapQuest's "Manage Keys"
    page (https://developer.mapquest.com/user/me/apps).

: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 mapquest
)r   r   r   r   r   r   /z://N)
super__init__api_keystripr   r   geocode_pathgeocode_apireverse_pathreverse_api)
selfr   r   r   r   r   r   r   r   	__class__s
            kC:\Users\julio\OneDrive\Documentos\Trabajo\Ideas Frescas\venv\Lib\site-packages\geopy/geocoders/mapquest.pyr   MapQuest.__init__   s    P 	!#+ 	 	
 ll3'  ;;T5F5FG 	  ;;T5F5FG 	    Tc                    ^ US   S   S   nU/ :X  a  gS mU4S j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.resultsr   	locationsNc                     / SQnU Vs/ s H  o R                  U5      (       d  M  X   PM      nnSR                  U5      $ s  snf )N)street
adminArea6
adminArea5
adminArea4
adminArea3
adminArea2
adminArea1
postalCodez, )getjoin)feature	addr_keysklocations       r    parse_location,MapQuest._parse_json.<locals>.parse_location^   s@    	I -6HIqQ

IHH99X&& Is
   AAc                 P   > T" U 5      nU S   S   nU S   S   n[        XU4U 5      $ )NlatLnglnglatr   )r1   r4   	longitudelatituder5   s       r    parse_feature+MapQuest._parse_json.<locals>.parse_featurem   s=    %g.H)%0Ix(/HH&;WEEr"    )r   jsonexactly_onefeaturesr=   r1   r5   s         @r    _parse_jsonMapQuest._parse_jsonW   s\    	?1%k2r>	'	F  !--:BC(wM'*(CCCs   A)rA   r   limitboundsc                v   0 nU R                   US'   XS'   Ub  XFS'   U(       a  SUS'   U(       a  U R                  US5      US'   SR                  U R                  [	        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 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: Limit the maximum number of items in the
    response. This will be reset to one if ``exactly_one`` is True.

:param bounds: The bounding box of the viewport within which
    to bias geocode results more prominently.
    Example: ``[Point(22, 180), Point(-22, -180)]``.
:type bounds: 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``.
keyr4   
maxResults   z#%(lat2)s,%(lon1)s,%(lat1)s,%(lon2)sboundingBox?z%s.geocode: %srA   r   )r   _format_bounding_boxr0   r   r   r	   debugr   __name__r   rC   _call_geocoder)	r   queryrA   r   rE   rF   paramsurlcallbacks	            r    geocodeMapQuest.geocodex   s    D u"z#(< #$F< $($=$==%F=! hh(()F*;<=%t~~'>'>D4++E""3'"BBr"   )rA   r   c                <   0 nU R                   US'   U R                  US5      nXTS'   SR                  U R                  [	        U5      45      n[
        R                  " SU R                  R                  U5        [        U R                  US9nU R                  XgU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``.
rH   z%(lat)s,%(lon)sr4   rL   z%s.reverse: %srM   rN   )r   _coerce_point_to_stringr0   r   r   r	   rP   r   rQ   r   rC   rR   )r   rS   rA   r   rT   pointrU   rV   s           r    reverseMapQuest.reverse   s    4 u,,U4EF"zhh(()F*;<=%t~~'>'>D4++E""3'"BBr"   )r   r   r   r   )T)rQ   
__module____qualname____firstlineno____doc__r   r   r   r   rC   rW   r\   __static_attributes____classcell__)r   s   @r    r
   r
      sf     +L*L $$( (9
 9
vDJ $5Cv $$C $Cr"   r
   N)	functoolsr   urllib.parser   geopy.geocoders.baser   r   geopy.locationr   
geopy.utilr	   __all__r
   r?   r"   r    <module>rj      s)     " ; # 
HCx HCr"   