Ë
    Ï.f´  ã                   ó^   — d dl m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y	)
é    )Úpartial)Ú	urlencode)ÚDEFAULT_SENTINELÚGeocoder©ÚLocation)Úlogger)ÚMapQuestc                   ód   ‡ — e Zd ZdZdZdZdeededddœˆ fd„
Zdd	„Zdeddd
œd„Z	dedœd„Z
ˆ xZS )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         ‰	| �  ||||||¬«       || _        |j                  d«      | _        | j
                  ›d| j                  ›| j                  ›�| _        | j
                  ›d| j                  ›| j                  ›�| _	        y)aÈ  
        :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
            €úWC:\Users\user\Documents\project_loop\venv\Lib\site-packages\geopy/geocoders/mapquest.pyr   zMapQuest.__init__   s‡   ø€ ôP 	‰ÑØØØØ!Ø#Ø+ð 	ô 	
ð ˆŒØ—l‘l 3Ó'ˆŒð  Ÿ;›;¨¯ª°T×5FÒ5FÐGð 	Ôð  Ÿ;›;¨¯ª°T×5FÒ5FÐGð 	Õó    Tc                 ó†   ‡— |d   d   d   }|g k(  ryd„ Šˆfd„}|r ||d   «      S |D �cg c]
  } ||«      ‘Œ c}S c c}w )z7Returns location, (latitude, longitude) from json feed.Úresultsr   Ú	locationsNc                 ó~   — g d¢}|D �cg c]  }| j                  |«      sŒ| |   ‘Œ }}dj                  |«      S c c}w )N)ÚstreetÚ
adminArea6Ú
adminArea5Ú
adminArea4Ú
adminArea3Ú
adminArea2Ú
adminArea1Ú
postalCodez, )ÚgetÚjoin)ÚfeatureÚ	addr_keysÚkÚlocations       r   Úparse_locationz,MapQuest._parse_json.<locals>.parse_location^   sA   € ò	ˆIð -6ÖH q¸¿¹ÀQ½˜ ›
ÐHˆHÐHØ—9‘9˜XÓ&Ð&ùò Is   ‰: :c                 óR   •—  ‰| «      }| d   d   }| d   d   }t        |||f| «      S )NÚlatLngÚlngÚlatr   )r/   r2   Ú	longitudeÚlatituder3   s       €r   Úparse_featurez+MapQuest._parse_json.<locals>.parse_featurem   s?   ø€ Ù% gÓ.ˆHØ Ñ)¨%Ñ0ˆIØ˜xÑ(¨Ñ/ˆHÜ˜H x°Ð&;¸WÓEÐEr    © )r   ÚjsonÚexactly_oneÚfeaturesr:   r/   r3   s         @r   Ú_parse_jsonzMapQuest._parse_jsonW   sX   ø€ à˜	‘? 1Ñ% kÑ2ˆà�rŠ>Øò	'ô	Fñ Ù  ¨!¡Ó-Ð-à:BÖC¨w‘M 'Õ*ÒCÐCùÒCs   ¬>)r=   r   ÚlimitÚboundsc                óp  — i }| j                   |d<   ||d<   |�||d<   |rd|d<   |r| j                  |d«      |d<   dj                  | j                  t	        |«      f«      }t        j                  d| j                  j                  |«       t        | j                  |¬	«      }| j                  |||¬
«      S )af  
        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``.
        Úkeyr2   Ú
maxResultsé   z#%(lat2)s,%(lon1)s,%(lat1)s,%(lon2)sÚboundingBoxú?z%s.geocode: %s©r=   ©r   )r   Ú_format_bounding_boxr.   r   r   r	   Údebugr   Ú__name__r   r?   Ú_call_geocoder)	r   Úqueryr=   r   r@   rA   ÚparamsÚurlÚcallbacks	            r   ÚgeocodezMapQuest.geocodex   sÁ   € ðD ˆØŸ™ˆˆu‰Ø"ˆˆzÑàÐØ#(ˆF�<Ñ áØ#$ˆF�<Ñ áØ$(×$=Ñ$=ØÐ=ó%ˆF�=Ñ!ð �h‰h˜×(Ñ(¬)°FÓ*;Ð<Ó=ˆä�‰Ð% t§~¡~×'>Ñ'>ÀÔDÜ˜4×+Ñ+¸ÔEˆØ×"Ñ" 3¨¸'Ð"ÓBÐBr    )r=   r   c                óJ  — i }| j                   |d<   | j                  |d«      }||d<   dj                  | j                  t	        |«      f«      }t        j                  d| j                  j                  |«       t        | 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``.
        rC   z%(lat)s,%(lon)sr2   rG   z%s.reverse: %srH   rI   )r   Ú_coerce_point_to_stringr.   r   r   r	   rK   r   rL   r   r?   rM   )r   rN   r=   r   rO   ÚpointrP   rQ   s           r   ÚreversezMapQuest.reverse¯   s–   € ð4 ˆØŸ™ˆˆu‰à×,Ñ,¨UÐ4EÓFˆØ"ˆˆzÑà�h‰h˜×(Ñ(¬)°FÓ*;Ð<Ó=ˆä�‰Ð% t§~¡~×'>Ñ'>ÀÔDÜ˜4×+Ñ+¸ÔEˆØ×"Ñ" 3¨¸'Ð"ÓBÐBr    )T)rL   Ú
__module__Ú__qualname__Ú__doc__r   r   r   r   r?   rR   rV   Ú__classcell__)r   s   @r   r
   r
      sa   ø„ ñð +€LØ*€Lð Ø$Ø$ØØ(Ø Ø(ö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>ra      s)   ðÝ Ý "ç ;Ý #Ý à
€ôHCˆxõ HCr    